summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: dec35c3)
raw | patch | inline | side by side (parent: dec35c3)
author | dvlierop2 <dvlierop2@users.sourceforge.net> | |
Sat, 7 Mar 2009 20:47:00 +0000 (20:47 +0000) | ||
committer | dvlierop2 <dvlierop2@users.sourceforge.net> | |
Sat, 7 Mar 2009 20:47:00 +0000 (20:47 +0000) |
- 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)
src/draw-context.cpp | patch | blob | history | |
src/object-snapper.cpp | patch | blob | history | |
src/pen-context.cpp | patch | blob | history | |
src/snapped-point.cpp | patch | blob | history |
diff --git a/src/draw-context.cpp b/src/draw-context.cpp
index b860c457d32a97838fe56e6b3ece410bc6bd4a59..c86e2cc69826f0ebad07620ebdee98efed572e78 100644 (file)
--- 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 3d06925a1aa50329229189d5b772579317533409..0223ee132786e8270be27c3e7bc2670383933b3b 100644 (file)
--- a/src/object-snapper.cpp
+++ b/src/object-snapper.cpp
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 d0889b4ec3a0cefa7ba9d8cde54926efea917e0d..7ffabcefdcc5051853634607147d904e3083c884 100644 (file)
--- 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 d7f13d82fa298ae6fa0d91b75a34bb7edbc4229d..7e9a16a66e38b0e4205860209f9d88092c31d7df 100644 (file)
--- 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;
}
/*