measure-context.cpp revision 6ccdb18a54dcf42ccf8a0854542a6cfc973c9061
6199N/A#include "sp-shape.h"
6199N/A#include "sp-flowtext.h"
6199N/A#include "text-editing.h"
6199N/A#include "display/sp-ctrlline.h"
6199N/A#include "display/sodipodi-ctrl.h"
6199N/A#include "display/sp-canvas-item.h"
6199N/A#include "display/sp-canvas-util.h"
6199N/A#include "document.h"
6199N/A#include "pixmaps/cursor-measure.xpm"
6199N/A#include "preferences.h"
6199N/A#include "inkscape.h"
6199N/A#include "desktop-handles.h"
6199N/A#include "measure-context.h"
6199N/A#include "draw-context.h"
6199N/A#include "display/canvas-text.h"
6199N/A#include "path-chemistry.h"
6199N/A#include "sp-namedview.h"
6199N/A#include "ui/control-manager.h"
6199N/Astatic gint sp_measure_context_item_handler(SPEventContext *event_context, SPItem *item, GdkEvent *event);
6199N/Astatic bool within_tolerance = false;
6199N/A#include "sp-factory.h"
6199N/A return new SPMeasureContext();
6199N/A bool measureContextRegistered = ToolFactory::instance().registerObject("/tools/measure", createMeasureContext);
6199N/Aclass LabelPlacement {
6199N/Avoid repositionOverlappingLabels(std::vector<LabelPlacement> &placements, SPDesktop *desktop, Geom::Point const &normal, double fontsize)
bool changed = false;
changed = false;
bool overlaps = false;
overlaps = true;
if (overlaps) {
changed = true;
} while (changed);
double fontsize)
return where;
* Given an angle, the arc center and edge point, draw an arc segment centered around that edge point.
void createAngleDisplayCurve(SPDesktop *desktop, Geom::Point const ¢er, Geom::Point const &end, Geom::Point const &anchor, double angle)
// Given that we have a point on the arc's edge and the angle of the arc, we need to get the two endpoints.
SPCtrlCurve *curve = ControlManager::getManager().createControlCurve(sp_desktop_tempgroup(desktop), p1, p2, p3, p4, CTLINE_SECONDARY);
CMeasureContext::CMeasureContext(SPMeasureContext* measurecontext) : CEventContext(measurecontext) {
static gint sp_measure_context_item_handler(SPEventContext *event_context, SPItem *item, GdkEvent *event)
// ret = SP_EVENT_CONTEXT_CLASS(sp_measure_context_parent_class)->item_handler(event_context, item, event);
return ret;
static void calculate_intersections(SPDesktop * /*desktop*/, SPItem* item, Geom::PathVector const &lineseg, SPCurve *curve, std::vector<Geom::Point> &intersections)
case GDK_BUTTON_PRESS:
within_tolerance = true;
m.unSetup();
GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK,
case GDK_KEY_PRESS:
if (lastEnd) {
case GDK_MOTION_NOTIFY:
m.unSetup();
if ( within_tolerance
within_tolerance = false;
m.unSetup();
double baseAngle = 0;
if (explicitBase) {
for (double i = 0; i < NPOINTS; i++) {
// TODO: Felipe, why don't you simply iterate over all items, and test whether their bounding boxes intersect
// with the measurement line, instead of interpolating? E.g. bbox_of_measurement_line.intersects(*bbox_of_item).
// That's also how the object-snapper works, see _findCandidates() in object-snapper.cpp.
if (!ignore_1st_and_last) {
if (!curve) {
if (!ignore_1st_and_last) {
fontsize);
NULL );
SPCtrlLine *control_line = ControlManager::getManager().createControlLine(sp_desktop_tempgroup(desktop),
if (explicitBase) {
SPCtrlLine *control_line = ControlManager::getManager().createControlLine(sp_desktop_tempgroup(desktop),
NULL );
case GDK_BUTTON_RELEASE:
xp = 0;
yp = 0;
if (!ret) {
// ret = SP_EVENT_CONTEXT_CLASS(sp_measure_context_parent_class)->root_handler(event_context, event);
return ret;