summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: ef3d1be)
raw | patch | inline | side by side (parent: ef3d1be)
author | dvlierop2 <dvlierop2@users.sourceforge.net> | |
Mon, 12 May 2008 18:58:04 +0000 (18:58 +0000) | ||
committer | dvlierop2 <dvlierop2@users.sourceforge.net> | |
Mon, 12 May 2008 18:58:04 +0000 (18:58 +0000) |
19 files changed:
diff --git a/src/arc-context.cpp b/src/arc-context.cpp
index 07f5f4826ad306e559722819d7bd252eee732b83..6169d000fec26d75ebe5806dd6e0273f024c9093 100644 (file)
--- a/src/arc-context.cpp
+++ b/src/arc-context.cpp
SnapManager &m = desktop->namedview->snap_manager;
m.setup(desktop, ac->item);
- ac->center = m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, ac->center).getPoint();
+ m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, ac->center);
sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate),
GDK_KEY_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
SnapManager &m = desktop->namedview->snap_manager;
m.setup(desktop, ac->item);
- motion_dt = m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, motion_dt).getPoint();
+ m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, motion_dt);
sp_arc_drag(ac, motion_dt, event->motion.state);
diff --git a/src/box3d-context.cpp b/src/box3d-context.cpp
index ca6822dda66b4fa6e4050dfa3f1dc1b77123cf3c..a7cead93e4a2a00d8629c069a9aa4535e142be5f 100644 (file)
--- a/src/box3d-context.cpp
+++ b/src/box3d-context.cpp
@@ -332,7 +332,8 @@ static gint sp_box3d_context_root_handler(SPEventContext *event_context, GdkEven
/* Snap center */
SnapManager &m = desktop->namedview->snap_manager;
m.setup(desktop, bc->item);
- bc->center = m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, button_dt).getPoint();
+ m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, button_dt);
+ bc->center = button_dt;
sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate),
( GDK_KEY_PRESS_MASK |
@@ -363,7 +364,7 @@ static gint sp_box3d_context_root_handler(SPEventContext *event_context, GdkEven
SnapManager &m = desktop->namedview->snap_manager;
m.setup(desktop, bc->item);
- motion_dt = m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, motion_dt).getPoint();
+ m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, motion_dt);
bc->ctrl_dragged = event->motion.state & GDK_CONTROL_MASK;
@@ -396,7 +397,7 @@ static gint sp_box3d_context_root_handler(SPEventContext *event_context, GdkEven
bc->drag_ptB_proj.normalize();
bc->drag_ptC_proj = cur_persp->tmat.preimage (motion_dt, bc->drag_ptB_proj[Proj::X], Proj::X);
}
- bc->drag_ptC = m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, bc->drag_ptC).getPoint();
+ m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, bc->drag_ptC);
}
sp_box3d_drag(*bc, event->motion.state);
index 3c1669fa6e4e1a3b0a3d9044af67da4148fb6e1c..e33b11e640fde32fdcb664c743835c19e5a16bf4 100644 (file)
@@ -532,7 +532,7 @@ connector_handle_button_press(SPConnectorContext *const cc, GdkEventButton const
// as there's no other points to go off.
SnapManager &m = cc->desktop->namedview->snap_manager;
m.setup(cc->desktop);
- p = m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, p).getPoint();
+ m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, p);
}
spcc_connector_set_initial_point(cc, p);
diff --git a/src/context-fns.cpp b/src/context-fns.cpp
index 83048af40ac3901285dab35ce4c07a359532dac9..61b6a2fc492b686b12231ac8763c903d2c3844c4 100644 (file)
--- a/src/context-fns.cpp
+++ b/src/context-fns.cpp
bool const control = state & GDK_CONTROL_MASK;
SnapManager &m = desktop->namedview->snap_manager;
- m.setup(desktop, item);
+ m.setup(NULL, item);
Inkscape::SnappedPoint snappoint;
if (control) {
@@ -141,23 +141,27 @@ NR::Rect Inkscape::snap_rectangular_box(SPDesktop const *desktop, SPItem *item,
/* Choose the best snap and update points accordingly */
if (s[0].getDistance() < s[1].getDistance()) {
- p[0] = s[0].getPoint();
- p[1] = 2 * center - s[0].getPoint();
- snappoint = s[0];
+ if (s[0].getSnapped()) {
+ p[0] = s[0].getPoint();
+ p[1] = 2 * center - s[0].getPoint();
+ snappoint = s[0];
+ }
} else {
- p[0] = 2 * center - s[1].getPoint();
- p[1] = s[1].getPoint();
- snappoint = s[1];
+ if (s[1].getSnapped()) {
+ p[0] = 2 * center - s[1].getPoint();
+ p[1] = s[1].getPoint();
+ snappoint = s[1];
+ }
}
- desktop->snapindicator->set_new_snappoint(snappoint);
-
} else {
/* Our origin is the opposite corner. Snap the drag point along the constraint vector */
p[0] = center;
snappoint = m.constrainedSnap(Inkscape::Snapper::SNAPPOINT_NODE, p[1],
Inkscape::Snapper::ConstraintLine(p[1] - p[0]));
- p[1] = snappoint.getPoint();
+ if (snappoint.getSnapped()) {
+ p[1] = snappoint.getPoint();
+ }
}
} else if (shift) {
@@ -175,13 +179,17 @@ NR::Rect Inkscape::snap_rectangular_box(SPDesktop const *desktop, SPItem *item,
s[1] = m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, p[1]);
if (s[0].getDistance() < s[1].getDistance()) {
- p[0] = s[0].getPoint();
- p[1] = 2 * center - s[0].getPoint();
- snappoint = s[0];
+ if (s[0].getSnapped()) {
+ p[0] = s[0].getPoint();
+ p[1] = 2 * center - s[0].getPoint();
+ snappoint = s[0];
+ }
} else {
- p[0] = 2 * center - s[1].getPoint();
- p[1] = s[1].getPoint();
- snappoint = s[1];
+ if (s[1].getSnapped()) {
+ p[0] = 2 * center - s[1].getPoint();
+ p[1] = s[1].getPoint();
+ snappoint = s[1];
+ }
}
} else {
@@ -189,12 +197,13 @@ NR::Rect Inkscape::snap_rectangular_box(SPDesktop const *desktop, SPItem *item,
/* There's no constraint on the corner point, so just snap it to anything */
p[0] = center;
snappoint = m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, pt);
- p[1] = snappoint.getPoint();
+ if (snappoint.getSnapped()) {
+ p[1] = snappoint.getPoint();
+ }
}
if (snappoint.getSnapped()) {
- // this does not work well enough yet.
-// desktop->snapindicator->set_new_snappoint(snappoint);
+ desktop->snapindicator->set_new_snappoint(snappoint);
}
p[0] = sp_desktop_dt2root_xy_point(desktop, p[0]);
diff --git a/src/desktop-events.cpp b/src/desktop-events.cpp
index 29734f45979fe7cf0ba20fd0eb01f3f86288c465..e151f0ac918936057a552e5b83b149d1f9b6ba91 100644 (file)
--- a/src/desktop-events.cpp
+++ b/src/desktop-events.cpp
@@ -144,9 +144,8 @@ static gint sp_dt_ruler_event(GtkWidget *widget, GdkEvent *event, SPDesktopWidge
SnapManager &m = desktop->namedview->snap_manager;
m.setup(desktop);
- Inkscape::SnappedPoint snappoint = m.guideSnap(event_dt, normal);
- event_dt = snappoint.getPoint();
-
+ m.guideSnap(event_dt, normal);
+
sp_guideline_set_position(SP_GUIDELINE(guide), event_dt.to_2geom());
desktop->set_coordinate_status(event_dt);
desktop->setPosition (event_dt);
@@ -160,7 +159,7 @@ static gint sp_dt_ruler_event(GtkWidget *widget, GdkEvent *event, SPDesktopWidge
SnapManager &m = desktop->namedview->snap_manager;
m.setup(desktop);
- event_dt = m.guideSnap(event_dt, normal).getPoint();
+ m.guideSnap(event_dt, normal);
dragging = false;
gtk_object_destroy(GTK_OBJECT(guide));
// which are dragged off the ruler, are being snapped in sp_dt_ruler_event
SnapManager &m = desktop->namedview->snap_manager;
m.setup(desktop);
- Inkscape::SnappedPoint snappoint = m.guideSnap(motion_dt, guide->normal_to_line);
- motion_dt = snappoint.getPoint();
-
+ m.guideSnap(motion_dt, guide->normal_to_line);
+
sp_guide_moveto(*guide, motion_dt.to_2geom(), false);
moved = true;
desktop->set_coordinate_status(motion_dt);
SnapManager &m = desktop->namedview->snap_manager;
m.setup(desktop);
- event_dt = m.guideSnap(event_dt, guide->normal_to_line).getPoint();
+ m.guideSnap(event_dt, guide->normal_to_line);
if (sp_canvas_world_pt_inside_window(item->canvas, event_w)) {
sp_guide_moveto(*guide, event_dt.to_2geom(), true);
index e08fc06d65a6a682caf72ff5558288851904fcb8..59578123e12e4d9e754c1897a9cf422d21a11634 100644 (file)
remove_snappoint();
g_assert(_desktop != NULL);
+
+ /* Commented out for now, because this might hide any snapping bug!
+ if (!p.getSnapped()) {
+ return; // If we haven't snapped, then it is of no use to draw a snapindicator
+ }
+ */
+
SPNamedView *nv = sp_desktop_namedview(_desktop);
if (nv->snapindicator) {
diff --git a/src/draw-context.cpp b/src/draw-context.cpp
index 50799b55fe45f2b19c9c1a95e708bf6675976e50..f4d7a856959c76f7c160f60d91904855a59bc805 100644 (file)
--- a/src/draw-context.cpp
+++ b/src/draw-context.cpp
@@ -356,9 +356,7 @@ void spdc_endpoint_snap_rotation(SPEventContext const *const ec, NR::Point &p, N
/* Snap it along best vector */
SnapManager &m = SP_EVENT_CONTEXT_DESKTOP(ec)->namedview->snap_manager;
m.setup(SP_EVENT_CONTEXT_DESKTOP(ec), NULL);
- Inkscape::SnappedPoint const s = m.constrainedSnap( Inkscape::Snapper::SNAPPOINT_NODE,
- p, Inkscape::Snapper::ConstraintLine(best));
- p = s.getPoint();
+ m.constrainedSnap( Inkscape::Snapper::SNAPPOINT_NODE, p, Inkscape::Snapper::ConstraintLine(best));
}
}
@@ -372,8 +370,7 @@ void spdc_endpoint_snap_free(SPEventContext const * const ec, NR::Point& p, guin
SnapManager &m = SP_EVENT_CONTEXT_DESKTOP(ec)->namedview->snap_manager;
m.setup(SP_EVENT_CONTEXT_DESKTOP(ec), NULL);
- Inkscape::SnappedPoint const s = m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, p);
- p = s.getPoint();
+ m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, p);
}
static SPCurve *
index 86bce50b95c9d2ddac2ff742b68d2c6671b24874..e4cdd707fe10a1c41ed77922d86be327576f6af9 100644 (file)
--- a/src/gradient-context.cpp
+++ b/src/gradient-context.cpp
@@ -554,7 +554,8 @@ sp_gradient_context_root_handler(SPEventContext *event_context, GdkEvent *event)
/* Snap center to nearest magnetic point */
SnapManager &m = desktop->namedview->snap_manager;
m.setup(desktop);
- rc->origin = m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, button_dt).getPoint();
+ m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, button_dt);
+ rc->origin = button_dt;
}
ret = TRUE;
diff --git a/src/nodepath.cpp b/src/nodepath.cpp
index c3d0f09b41d06b1a4c58534fcd27587dce5ccbca..ffbec8a8b945bb4baabeaa0f95653bc30c3cc1d0 100644 (file)
--- a/src/nodepath.cpp
+++ b/src/nodepath.cpp
@@ -1233,7 +1233,7 @@ static void sp_nodepath_selected_nodes_move(Inkscape::NodePath::Path *nodepath,
Inkscape::NodePath::Node *n = (Inkscape::NodePath::Node *) l->data;
m.setup(nodepath->desktop, SP_PATH(n->subpath->nodepath->item), &unselected_nodes);
Inkscape::SnappedPoint s = m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, n->pos + delta);
- if (s.getDistance() < best) {
+ if (s.getSnapped() && (s.getDistance() < best)) {
best = s.getDistance();
best_abs = s;
best_pt = s.getPoint() - n->pos;
@@ -3684,8 +3684,8 @@ static gboolean node_handle_request(SPKnot *knot, NR::Point *p, guint /*state*/,
s = m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, *p);
}
- *p = s.getPoint();
-
+ s.getPoint(*p);
+
sp_node_adjust_handle(n, -which);
return FALSE;
diff --git a/src/object-edit.cpp b/src/object-edit.cpp
index 3d4aaae399097fced9d1adfd384a40a0705f3ee6..0abf84a1ff5371e58a4a222f6579d3b3cbbcdd86 100644 (file)
--- a/src/object-edit.cpp
+++ b/src/object-edit.cpp
NR::Point s = p * i2d;
SnapManager &m = desktop->namedview->snap_manager;
m.setup(desktop, item);
- s = m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, s).getPoint();
+ m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, s);
return s * i2d.inverse();
}
diff --git a/src/pencil-context.cpp b/src/pencil-context.cpp
index ae3a2fa48dcb10980b6136bab98f4b867d2f0eb8..87cbb8d12879c5bb00ba5da9b0bbe57084a93f1c 100644 (file)
--- a/src/pencil-context.cpp
+++ b/src/pencil-context.cpp
@@ -248,7 +248,7 @@ pencil_handle_button_press(SPPencilContext *const pc, GdkEventButton const &beve
desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Creating new path"));
SnapManager &m = desktop->namedview->snap_manager;
m.setup(desktop);
- p = m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, p).getPoint();
+ m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, p);
} else if (selection->singleItem() && SP_IS_PATH(selection->singleItem())) {
desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Appending to selected path"));
}
@@ -325,8 +325,7 @@ pencil_handle_motion_notify(SPPencilContext *const pc, GdkEventMotion const &mev
} else if ((mevent.state & GDK_SHIFT_MASK) == 0) {
SnapManager &m = dt->namedview->snap_manager;
m.setup(dt, NULL);
- Inkscape::SnappedPoint const s = m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, p);
- p = s.getPoint();
+ m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, p);
}
if ( pc->npoints != 0 ) { // buttonpress may have happened before we entered draw context!
spdc_add_freehand_point(pc, p, mevent.state);
diff --git a/src/rect-context.cpp b/src/rect-context.cpp
index ad383b0144d24fdefa49fd2b4f1a583f38b0bd6c..b8047b201eae2544285c0d83dfa4b732dc878df1 100644 (file)
--- a/src/rect-context.cpp
+++ b/src/rect-context.cpp
@@ -306,8 +306,8 @@ static gint sp_rect_context_root_handler(SPEventContext *event_context, GdkEvent
/* Snap center */
SnapManager &m = desktop->namedview->snap_manager;
m.setup(desktop, rc->item);
- Inkscape::SnappedPoint s = m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, button_dt);
- rc->center = s.getPoint();
+ m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, button_dt);
+ rc->center = button_dt;
sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate),
( GDK_KEY_PRESS_MASK |
@@ -338,8 +338,7 @@ static gint sp_rect_context_root_handler(SPEventContext *event_context, GdkEvent
SnapManager &m = desktop->namedview->snap_manager;
m.setup(desktop, rc->item);
- Inkscape::SnappedPoint s = m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, motion_dt);
- motion_dt = s.getPoint();
+ m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, motion_dt);
sp_rect_drag(*rc, motion_dt, event->motion.state);
gobble_motion_events(GDK_BUTTON1_MASK);
diff --git a/src/seltrans.cpp b/src/seltrans.cpp
index e34f6ba83d837acb1d79a16e5e1ad491bf9d37f1..432b1e67067b15dbdc4931a747608d901e0990df 100644 (file)
--- a/src/seltrans.cpp
+++ b/src/seltrans.cpp
{
SnapManager &m = _desktop->namedview->snap_manager;
m.setup(_desktop);
- pt = m.freeSnap(Snapper::SNAPPOINT_NODE, pt).getPoint();
+ m.freeSnap(Snapper::SNAPPOINT_NODE, pt);
if (state & GDK_CONTROL_MASK) {
if ( fabs(_point[NR::X] - pt[NR::X]) > fabs(_point[NR::Y] - pt[NR::Y]) ) {
** FIXME: this will snap to more than just the grid, nowadays.
*/
- dxy = m.freeSnap(Snapper::SNAPPOINT_NODE, dxy).getPoint();
+ m.freeSnap(Snapper::SNAPPOINT_NODE, dxy);
} else if (!shift) {
diff --git a/src/snap.cpp b/src/snap.cpp
index 8851470634a04e1a51893bfefd0ae23b11e615cd..bc81bdf3ad589d2b5918156af7cd257865527c19 100644 (file)
--- a/src/snap.cpp
+++ b/src/snap.cpp
return object.getSnapFrom(Inkscape::Snapper::SNAPPOINT_GUIDE);
}
+/**
+ * Try to snap a point to any of the specified snappers.
+ *
+ * \param point_type Type of point.
+ * \param p Point.
+ * \param first_point If true then this point is the first one from a whole bunch of points
+ * \param points_to_snap The whole bunch of points, all from the same selection and having the same transformation
+ * \param snappers List of snappers to try to snap to
+ * \return Snapped point.
+ */
+
+void SnapManager::freeSnapVoid(Inkscape::Snapper::PointType point_type,
+ NR::Point &p,
+ bool first_point,
+ NR::Maybe<NR::Rect> const &bbox_to_snap) const
+{
+ Inkscape::SnappedPoint const s = freeSnap(point_type, p, first_point, bbox_to_snap);
+ s.getPoint(p);
+}
+
/**
* Try to snap a point to any of the specified snappers.
*
@@ -212,6 +232,28 @@ Inkscape::SnappedPoint SnapManager::freeSnap(Inkscape::Snapper::PointType point_
return findBestSnap(p, sc, false);
}
+/**
+ * Try to snap a point to any interested snappers. A snap will only occur along
+ * a line described by a Inkscape::Snapper::ConstraintLine.
+ *
+ * \param point_type Type of point.
+ * \param p Point.
+ * \param first_point If true then this point is the first one from a whole bunch of points
+ * \param points_to_snap The whole bunch of points, all from the same selection and having the same transformation
+ * \param constraint Constraint line.
+ * \return Snapped point.
+ */
+
+void SnapManager::constrainedSnapVoid(Inkscape::Snapper::PointType point_type,
+ NR::Point &p,
+ Inkscape::Snapper::ConstraintLine const &constraint,
+ bool first_point,
+ NR::Maybe<NR::Rect> const &bbox_to_snap) const
+{
+ Inkscape::SnappedPoint const s = constrainedSnap(point_type, p, constraint, first_point, bbox_to_snap);
+ s.getPoint(p);
+}
+
/**
* Try to snap a point to any interested snappers. A snap will only occur along
* a line described by a Inkscape::Snapper::ConstraintLine.
@@ -257,19 +299,19 @@ Inkscape::SnappedPoint SnapManager::constrainedSnap(Inkscape::Snapper::PointType
return findBestSnap(p, sc, true);
}
-Inkscape::SnappedPoint SnapManager::guideSnap(NR::Point const &p,
- NR::Point const &guide_normal) const
+void SnapManager::guideSnap(NR::Point &p, NR::Point const &guide_normal) const
{
// This method is used to snap a guide to nodes, while dragging the guide around
if (!(object.GuidesMightSnap() && _snap_enabled_globally)) {
- return Inkscape::SnappedPoint(p, Inkscape::SNAPTARGET_UNDEFINED, NR_HUGE, 0, false);
+ return;
}
SnappedConstraints sc;
object.guideSnap(sc, p, guide_normal);
- return findBestSnap(p, sc, false);
+ Inkscape::SnappedPoint const s = findBestSnap(p, sc, false);
+ s.getPoint(p);
}
** Also used to globally disable all snapping
*/
if (SomeSnapperMightSnap() == false) {
+ g_assert(points.size() > 0);
return Inkscape::SnappedPoint();
}
diff --git a/src/snap.h b/src/snap.h
index f49eb7145a3c22bdf1f933119f43e6b5d099fc17..900f548cef9bd049c04c2a83864c4215293caf94 100644 (file)
--- a/src/snap.h
+++ b/src/snap.h
void setup(SPDesktop const *desktop_for_snapindicator = NULL, SPItem const *item_to_ignore = NULL, std::vector<NR::Point> *unselected_nodes = NULL);
void setup(SPDesktop const *desktop_for_snapindicator, std::vector<SPItem const *> &items_to_ignore, std::vector<NR::Point> *unselected_nodes = NULL);
+ // freeSnapVoid() is preferred over freeSnap(), because it only returns a
+ // point, by overwriting p, if snapping has occured; otherwise p is untouched
+ void freeSnapVoid(Inkscape::Snapper::PointType point_type,
+ NR::Point &p,
+ bool first_point = true,
+ NR::Maybe<NR::Rect> const &bbox_to_snap = NR::Nothing()) const;
+
Inkscape::SnappedPoint freeSnap(Inkscape::Snapper::PointType point_type,
NR::Point const &p,
bool first_point = true,
NR::Maybe<NR::Rect> const &bbox_to_snap = NR::Nothing()) const;
-
+
+ // constrainedSnapVoid() is preferred over constrainedSnap(), because it only returns a
+ // point, by overwriting p, if snapping has occured; otherwise p is untouched
+ void constrainedSnapVoid(Inkscape::Snapper::PointType point_type,
+ NR::Point &p,
+ Inkscape::Snapper::ConstraintLine const &constraint,
+ bool first_point = true,
+ NR::Maybe<NR::Rect> const &bbox_to_snap = NR::Nothing()) const;
+
Inkscape::SnappedPoint constrainedSnap(Inkscape::Snapper::PointType point_type,
NR::Point const &p,
Inkscape::Snapper::ConstraintLine const &constraint,
bool first_point = true,
NR::Maybe<NR::Rect> const &bbox_to_snap = NR::Nothing()) const;
- Inkscape::SnappedPoint guideSnap(NR::Point const &p,
- NR::Point const &guide_normal) const;
+ void guideSnap(NR::Point &p, NR::Point const &guide_normal) const;
Inkscape::SnappedPoint freeSnapTranslation(Inkscape::Snapper::PointType point_type,
std::vector<NR::Point> const &p,
NR::Point const &o) const;
Inkscape::SnappedPoint constrainedSnapStretch(Inkscape::Snapper::PointType point_type,
- std::vector<NR::Point> const &p,
- NR::Coord const &s,
- NR::Point const &o,
- NR::Dim2 d,
- bool uniform) const;
+ std::vector<NR::Point> const &p,
+ NR::Coord const &s,
+ NR::Point const &o,
+ NR::Dim2 d,
+ bool uniform) const;
Inkscape::SnappedPoint constrainedSnapSkew(Inkscape::Snapper::PointType point_type,
- std::vector<NR::Point> const &p,
- Inkscape::Snapper::ConstraintLine const &constraint,
- NR::Point const &s, // s[0] = skew factor, s[1] = scale factor
- NR::Point const &o,
- NR::Dim2 d) const;
+ std::vector<NR::Point> const &p,
+ Inkscape::Snapper::ConstraintLine const &constraint,
+ NR::Point const &s, // s[0] = skew factor, s[1] = scale factor
+ NR::Point const &o,
+ NR::Dim2 d) const;
Inkscape::GuideSnapper guide; ///< guide snapper
Inkscape::ObjectSnapper object; ///< snapper to other objects
diff --git a/src/snapped-point.cpp b/src/snapped-point.cpp
index 4e5ca836daa957905e84852a3616b946b1a077f2..02f7ed165b0cf25b83c71e0f5651bb6565e4dd6b 100644 (file)
--- a/src/snapped-point.cpp
+++ b/src/snapped-point.cpp
}
-NR::Point Inkscape::SnappedPoint::getPoint() const
+void Inkscape::SnappedPoint::getPoint(NR::Point &p) const
{
- return _point;
+ // When we have snapped
+ if (getSnapped()) {
+ // then return the snapped point by overwriting p
+ p = _point;
+ } //otherwise p will be left untouched; this way the caller doesn't have to check wether we've snapped
}
// search for the closest snapped point
diff --git a/src/snapped-point.h b/src/snapped-point.h
index 3720319558768b3b11eeec328b7f2a2f07dd0a02..2c74025c806d797ebc61916ce9926a3ab1ec19b9 100644 (file)
--- a/src/snapped-point.h
+++ b/src/snapped-point.h
NR::Coord getSecondDistance() const;
NR::Coord getSecondTolerance() const;
bool getSecondAlwaysSnap() const;
- NR::Point getPoint() const;
+
+ /* This is the preferred method to find out which point we have snapped,
+ * to because it only returns a point if snapping has actually occured
+ * (by overwriting p)
+ */
+ void getPoint(NR::Point &p) const;
+
+ /* This method however always returns a point, even if no snapping
+ * has occured; A check should be implemented in the calling code
+ * to check for snapping. Use this method only when really needed, e.g.
+ * when the calling code is trying to snap multiple points and must
+ * determine itself which point is most appropriate
+ */
+ NR::Point getPoint() const {return _point;}
+
bool getAtIntersection() const {return _at_intersection;}
bool getSnapped() const {return _distance < NR_HUGE;}
NR::Point getTransformation() const {return _transformation;}
diff --git a/src/spiral-context.cpp b/src/spiral-context.cpp
index a4c402f407b3f81fb5f98ebf38cda8c7ef1a6f5e..57c06e4a315730da08c08880ec9e2dc87a1a62af 100644 (file)
--- a/src/spiral-context.cpp
+++ b/src/spiral-context.cpp
SnapManager &m = desktop->namedview->snap_manager;
m.setup(desktop, sc->item);
- sc->center = m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, sc->center).getPoint();
+ m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, sc->center);
sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate),
( GDK_KEY_PRESS_MASK |
SnapManager &m = desktop->namedview->snap_manager;
m.setup(desktop, sc->item);
- motion_dt = m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, motion_dt).getPoint();
+ m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, motion_dt);
sp_spiral_drag(sc, motion_dt, event->motion.state);
gobble_motion_events(GDK_BUTTON1_MASK);
NR::Point p1 = sp_desktop_dt2root_xy_point(desktop, p);
SnapManager &m = desktop->namedview->snap_manager;
m.setup(desktop, sc->item);
- p1 = m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, p1).getPoint();
+ m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, p1);
SPSpiral *spiral = SP_SPIRAL(sc->item);
diff --git a/src/star-context.cpp b/src/star-context.cpp
index 816e6b7793871d100a98d33d0a20c2d286c199c9..afdb14a0c84e6171948d29ed25f0684dcb9a8155 100644 (file)
--- a/src/star-context.cpp
+++ b/src/star-context.cpp
@@ -282,7 +282,7 @@ static gint sp_star_context_root_handler(SPEventContext *event_context, GdkEvent
SnapManager &m = desktop->namedview->snap_manager;
m.setup(desktop, sc->item);
- sc->center = m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, sc->center).getPoint();
+ m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, sc->center);
sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate),
GDK_KEY_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
@@ -309,7 +309,7 @@ static gint sp_star_context_root_handler(SPEventContext *event_context, GdkEvent
SnapManager &m = desktop->namedview->snap_manager;
m.setup(desktop, sc->item);
- motion_dt = m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, motion_dt).getPoint();
+ m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, motion_dt);
sp_star_drag (sc, motion_dt, event->motion.state);
/* Snap corner point with no constraints */
SnapManager &m = desktop->namedview->snap_manager;
m.setup(desktop, sc->item);
- p1 = m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, p1).getPoint();
+ m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, p1);
SPStar *star = SP_STAR(sc->item);