measure-context.cpp revision 1137482ecab2928952d08127515e9d0fc31a29d4
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b * Our nice measuring tool
9589ae957c17876584db2e3f997664f80bd72136Alex Valavanis * Felipe Correa da Silva Sanches <juca@members.fsf.org>
9589ae957c17876584db2e3f997664f80bd72136Alex Valavanis * Jon A. Cruz <jon@joncruz.org>
9589ae957c17876584db2e3f997664f80bd72136Alex Valavanis * Copyright (C) 2011 Authors
9589ae957c17876584db2e3f997664f80bd72136Alex Valavanis * Released under GNU GPL, read the file 'COPYING' for more information
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bstatic bool within_tolerance = false;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bstd::vector<Inkscape::Display::TemporaryItem*> measure_tmp_items;
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_b bool measureContextRegistered = ToolFactory::instance().registerObject("/tools/measure", createMeasureContext);
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bconst std::string& SPMeasureContext::getPrefsPath() {
a0df1b8dd5b14367c583ce2f72a2ca6bf1cde799gustav_bconst std::string SPMeasureContext::prefsPath = "/tools/measure";
7a10406c7610c65f3600986ded11320fe870ccb9Alex Valavanis * Simple class to use for removing label overlap.
double lengthVal;
double offset;
void 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);
// 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;