summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDiederik van Lierop <mail@diedenrezi.nl>2009-03-07 20:47:00 +0000
committerdvlierop2 <dvlierop2@users.sourceforge.net>2009-03-07 20:47:00 +0000
commit86f80d1c9bd6cc3716c049da3d8c94887211648e (patch)
treebed9547bd809863fa7c66af9ec1f1c654f1f8b54 /src
parentSnap indicators and filters, mainly... (diff)
downloadinkscape-86f80d1c9bd6cc3716c049da3d8c94887211648e.tar.gz
inkscape-86f80d1c9bd6cc3716c049da3d8c94887211648e.zip
- When finalizing a curve by double clicking then don't snap to the curve itself
- When a node and an intersection coincide then snap to the node, not the intersection (but only if snapping is turned on for both of them of course) (bzr r7438)
Diffstat (limited to 'src')
-rw-r--r--src/draw-context.cpp12
-rw-r--r--src/object-snapper.cpp3
-rw-r--r--src/pen-context.cpp2
-rw-r--r--src/snapped-point.cpp17
4 files changed, 25 insertions, 9 deletions
diff --git a/src/draw-context.cpp b/src/draw-context.cpp
index b860c457d..c86e2cc69 100644
--- a/src/draw-context.cpp
+++ b/src/draw-context.cpp
@@ -507,7 +507,7 @@ void spdc_endpoint_snap_rotation(SPEventContext const *const ec, Geom::Point &p,
p = o + bdot * best;
if (!(state & GDK_SHIFT_MASK)) { //SHIFT disables all snapping, except the angular snapping above
- //After all, the user explicitely asked for angular snapping by
+ //After all, the user explicitly asked for angular snapping by
//pressing CTRL
/* Snap it along best vector */
SnapManager &m = SP_EVENT_CONTEXT_DESKTOP(ec)->namedview->snap_manager;
@@ -522,8 +522,14 @@ void spdc_endpoint_snap_rotation(SPEventContext const *const ec, Geom::Point &p,
void spdc_endpoint_snap_free(SPEventContext const * const ec, Geom::Point& p, guint const /*state*/)
{
- SnapManager &m = SP_EVENT_CONTEXT_DESKTOP(ec)->namedview->snap_manager;
- m.setup(SP_EVENT_CONTEXT_DESKTOP(ec));
+ SPDesktop *dt = SP_EVENT_CONTEXT_DESKTOP(ec);
+ SnapManager &m = dt->namedview->snap_manager;
+ Inkscape::Selection *selection = sp_desktop_selection (dt);
+
+ // selection->singleItem() is the item that is currently being drawn. This item will not be snapped to (to avoid self-snapping)
+ // TODO: Allow snapping to the stationary parts of the item, and only ignore the last segment
+
+ m.setup(dt, true, selection->singleItem());
Geom::Point pt2g = to_2geom(p);
m.freeSnapReturnByRef(Inkscape::SnapPreferences::SNAPPOINT_NODE, pt2g, Inkscape::SNAPSOURCE_HANDLE);
p = from_2geom(pt2g);
diff --git a/src/object-snapper.cpp b/src/object-snapper.cpp
index 3d06925a1..0223ee132 100644
--- a/src/object-snapper.cpp
+++ b/src/object-snapper.cpp
@@ -161,6 +161,9 @@ void Inkscape::ObjectSnapper::_findCandidates(SPObject* parent,
if (bbox_to_snap_incl.intersects(*bbox_of_item)) {
// This item is within snapping range, so record it as a candidate
_candidates->push_back(SnapCandidate(item, clip_or_mask, additional_affine));
+ // For debugging: print the id of the candidate to the console
+ // SPObject *obj = (SPObject*)item;
+ // std::cout << "Snap candidate added: " << obj->id << std::endl;
}
}
}
diff --git a/src/pen-context.cpp b/src/pen-context.cpp
index d0889b4ec..7ffabcefd 100644
--- a/src/pen-context.cpp
+++ b/src/pen-context.cpp
@@ -476,7 +476,7 @@ static gint pen_handle_button_press(SPPenContext *const pc, GdkEventButton const
if (!(bevent.state & GDK_SHIFT_MASK)) {
SnapManager &m = desktop->namedview->snap_manager;
m.setup(desktop);
- m.freeSnapReturnByRef(Inkscape::SnapPreferences::SNAPPOINT_NODE, p, Inkscape::SNAPSOURCE_HANDLE);
+ m.freeSnapReturnByRef(Inkscape::SnapPreferences::SNAPPOINT_NODE, p, Inkscape::SNAPSOURCE_HANDLE);
}
spdc_create_single_dot(event_context, p, "/tools/freehand/pen", bevent.state);
ret = TRUE;
diff --git a/src/snapped-point.cpp b/src/snapped-point.cpp
index d7f13d82f..7e9a16a66 100644
--- a/src/snapped-point.cpp
+++ b/src/snapped-point.cpp
@@ -126,13 +126,20 @@ bool Inkscape::SnappedPoint::isOtherSnapBetter(Inkscape::SnappedPoint const &oth
bool c3 = other_one.getFullyConstrained() && !getFullyConstrained();
// But in no case fall back; (has less priority than c3n, so it is allowed to fall back when c3 is true, see below)
bool c3n = !other_one.getFullyConstrained() && getFullyConstrained();
+
+ // When both are fully constrained AND coincident, then prefer nodes over intersections
+ bool d = other_one.getFullyConstrained() && getFullyConstrained() && (Geom::L2(other_one.getPoint() - getPoint()) < 1e-9);
+ bool c4 = d && !other_one.getAtIntersection() && getAtIntersection();
+ // But don't fall back...
+ bool c4n = d && other_one.getAtIntersection() && !getAtIntersection();
+
// or, if it's just as close then consider the second distance
- bool c4a = (dist_other == dist_this);
- bool c4b = other_one.getSecondSnapDistance() < getSecondSnapDistance();
+ bool c5a = (dist_other == dist_this);
+ bool c5b = other_one.getSecondSnapDistance() < getSecondSnapDistance();
- // std::cout << other_one.getPoint() << " (Other one) vs. " << getPoint() << " (this one) ---> ";
- // std::cout << "c1 = " << c1 << " | c2 = " << c2 << " | c2n = " << c2n << " | c3 = " << c3 << " | c3n = " << c3n << " | c4a = " << c4a << " | c4b = " << c4b << std::endl;
- return (c1 || c2 || c3 || (c4a && c4b)) && !c2n && (!c3n || c2);
+ // std::cout << other_one.getPoint() << " (Other one, dist = " << dist_other << ") vs. " << getPoint() << " (this one, dist = " << dist_this << ") ---> ";
+ // std::cout << "c1 = " << c1 << " | c2 = " << c2 << " | c2n = " << c2n << " | c3 = " << c3 << " | c3n = " << c3n << " | c4 = " << c4 << " | c4n = " << c4n << " | c5a = " << c5a << " | c5b = " << c5b << std::endl;
+ return (c1 || c2 || c3 || c4 || (c5a && c5b)) && !c2n && (!c3n || c2) && !c4n;
}
/*