From eae8322c8b968bbf076323eb68707124bfc810d9 Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Sat, 18 Jul 2009 12:56:25 +0000 Subject: Make the snap delay mechanism easier to implement for the devs, and get rid of the related warning messages (bzr r8302) --- src/snap.cpp | 26 ++------------------------ 1 file changed, 2 insertions(+), 24 deletions(-) (limited to 'src/snap.cpp') diff --git a/src/snap.cpp b/src/snap.cpp index 91d5d64ec..4d5dad55a 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -206,13 +206,6 @@ Inkscape::SnappedPoint SnapManager::freeSnap(Inkscape::SnapPreferences::PointTyp bool first_point, Geom::OptRect const &bbox_to_snap) const { - if (_desktop->event_context && _desktop->event_context->_snap_window_open == false) { - g_warning("The current tool tries to snap, but it hasn't yet opened the snap window. Please report this!"); - // When the context goes into dragging-mode, then Inkscape should call this: sp_event_context_snap_window_open(event_context); - } - - //std::cout << "SnapManager::freeSnap -> postponed: " << snapprefs.getSnapPostponedGlobally() << std::endl; - if (!someSnapperMightSnap()) { return Inkscape::SnappedPoint(p, source_type, Inkscape::SNAPTARGET_UNDEFINED, NR_HUGE, 0, false, false); } @@ -371,12 +364,7 @@ Inkscape::SnappedPoint SnapManager::constrainedSnap(Inkscape::SnapPreferences::P bool first_point, Geom::OptRect const &bbox_to_snap) const { - if (_desktop->event_context && _desktop->event_context->_snap_window_open == false) { - g_warning("The current tool tries to snap, but it hasn't yet opened the snap window. Please report this!"); - // When the context goes into dragging-mode, then Inkscape should call this: sp_event_context_snap_window_open(event_context); - } - - if (!someSnapperMightSnap()) { + if (!someSnapperMightSnap()) { return Inkscape::SnappedPoint(p, source_type, Inkscape::SNAPTARGET_UNDEFINED, NR_HUGE, 0, false, false); } @@ -419,11 +407,6 @@ Inkscape::SnappedPoint SnapManager::constrainedSnap(Inkscape::SnapPreferences::P */ void SnapManager::guideFreeSnap(Geom::Point &p, Geom::Point const &guide_normal) const { - if (_desktop->event_context && _desktop->event_context->_snap_window_open == false) { - g_warning("The current tool tries to snap, but it hasn't yet opened the snap window. Please report this!"); - // When the context goes into dragging-mode, then Inkscape should call this: sp_event_context_snap_window_open(event_context); - } - if (!snapprefs.getSnapEnabledGlobally() || snapprefs.getSnapPostponedGlobally()) { return; } @@ -465,12 +448,7 @@ void SnapManager::guideFreeSnap(Geom::Point &p, Geom::Point const &guide_normal) void SnapManager::guideConstrainedSnap(Geom::Point &p, SPGuide const &guideline) const { - if (_desktop->event_context && _desktop->event_context->_snap_window_open == false) { - g_warning("The current tool tries to snap, but it hasn't yet opened the snap window. Please report this!"); - // When the context goes into dragging-mode, then Inkscape should call this: sp_event_context_snap_window_open(event_context); - } - - if (!snapprefs.getSnapEnabledGlobally() || snapprefs.getSnapPostponedGlobally()) { + if (!snapprefs.getSnapEnabledGlobally() || snapprefs.getSnapPostponedGlobally()) { return; } -- cgit v1.2.3 From 2400be6dd81349d88a004ad61be6aac7772bf750 Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Wed, 29 Jul 2009 20:55:51 +0000 Subject: Snap guides to intersections of curves too (see bug #405419) (bzr r8361) --- src/snap.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src/snap.cpp') diff --git a/src/snap.cpp b/src/snap.cpp index 4d5dad55a..9b8a7aea7 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -428,7 +428,9 @@ void SnapManager::guideFreeSnap(Geom::Point &p, Geom::Point const &guide_normal) // We won't snap to grids, what's the use? - Inkscape::SnappedPoint const s = findBestSnap(p, Inkscape::SNAPSOURCE_GUIDE, sc, false); + // Including snapping to intersections of curves, but not to the curves themself! (see _snapTranslatingGuideToNodes in object-snapper.cpp) + Inkscape::SnappedPoint const s = findBestSnap(p, Inkscape::SNAPSOURCE_GUIDE, sc, false, true); + s.getPoint(p); } @@ -900,13 +902,15 @@ Inkscape::SnappedPoint SnapManager::constrainedSnapSkew(Inkscape::SnapPreference * \param source_type Detailed description of the source type, will be used by the snap indicator * \param sc A structure holding all snap targets that have been found so far * \param constrained True if the snap is constrained, e.g. for stretching or for purely horizontal translation. + * \param noCurves If true, then do consider snapping to intersections of curves, but not to the curves themself * \return An instance of the SnappedPoint class, which holds data on the snap source, snap target, and various metrics */ Inkscape::SnappedPoint SnapManager::findBestSnap(Geom::Point const &p, Inkscape::SnapSourceType const source_type, SnappedConstraints &sc, - bool constrained) const + bool constrained, + bool noCurves) const { /* @@ -928,9 +932,11 @@ Inkscape::SnappedPoint SnapManager::findBestSnap(Geom::Point const &p, } // search for the closest snapped curve - Inkscape::SnappedCurve closestCurve; - if (getClosestCurve(sc.curves, closestCurve)) { - sp_list.push_back(Inkscape::SnappedPoint(closestCurve)); + if (!noCurves) { + Inkscape::SnappedCurve closestCurve; + if (getClosestCurve(sc.curves, closestCurve)) { + sp_list.push_back(Inkscape::SnappedPoint(closestCurve)); + } } if (snapprefs.getSnapIntersectionCS()) { -- cgit v1.2.3 From 211ec1ef762f2c2447fe8b5fc5c6ab8459a57558 Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Sun, 2 Aug 2009 09:55:12 +0000 Subject: Snap guides to grids (fixes bug #170741) (bzr r8381) --- src/snap.cpp | 41 ++++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 17 deletions(-) (limited to 'src/snap.cpp') diff --git a/src/snap.cpp b/src/snap.cpp index 9b8a7aea7..f0769e0a1 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -405,7 +405,7 @@ Inkscape::SnappedPoint SnapManager::constrainedSnap(Inkscape::SnapPreferences::P * \param p Current position of the point on the guide that is to be snapped; will be overwritten by the position of the snap target if snapping has occurred * \param guide_normal Vector normal to the guide line */ -void SnapManager::guideFreeSnap(Geom::Point &p, Geom::Point const &guide_normal) const +void SnapManager::guideFreeSnap(Geom::Point &p, Geom::Point const &guide_normal, SPGuideDragType drag_type) const { if (!snapprefs.getSnapEnabledGlobally() || snapprefs.getSnapPostponedGlobally()) { return; @@ -415,21 +415,26 @@ void SnapManager::guideFreeSnap(Geom::Point &p, Geom::Point const &guide_normal) return; } + Inkscape::SnapSourceType source_type = Inkscape::SNAPSOURCE_GUIDE_ORIGIN; + if (drag_type == SP_DRAG_ROTATE) { + source_type = Inkscape::SNAPSOURCE_GUIDE; + } + // Snap to nodes SnappedConstraints sc; if (object.GuidesMightSnap()) { object.guideFreeSnap(sc, p, guide_normal); } - // Snap to guides - if (snapprefs.getSnapToGuides()) { - guide.freeSnap(sc, Inkscape::SnapPreferences::SNAPPOINT_GUIDE, p, Inkscape::SNAPSOURCE_GUIDE, true, Geom::OptRect(), NULL, NULL); - } - - // We won't snap to grids, what's the use? + // Snap to guides & grid lines + SnapperList snappers = getGridSnappers(); + snappers.push_back(&guide); + for (SnapperList::const_iterator i = snappers.begin(); i != snappers.end(); i++) { + (*i)->freeSnap(sc, Inkscape::SnapPreferences::SNAPPOINT_GUIDE, p, source_type, true, Geom::OptRect(), NULL, NULL); + } - // Including snapping to intersections of curves, but not to the curves themself! (see _snapTranslatingGuideToNodes in object-snapper.cpp) - Inkscape::SnappedPoint const s = findBestSnap(p, Inkscape::SNAPSOURCE_GUIDE, sc, false, true); + // Snap to intersections of curves, but not to the curves themselves! (see _snapTranslatingGuideToNodes in object-snapper.cpp) + Inkscape::SnappedPoint const s = findBestSnap(p, source_type, sc, false, true); s.getPoint(p); } @@ -458,21 +463,23 @@ void SnapManager::guideConstrainedSnap(Geom::Point &p, SPGuide const &guideline) return; } + Inkscape::SnapSourceType source_type = Inkscape::SNAPSOURCE_GUIDE_ORIGIN; + // Snap to nodes or paths SnappedConstraints sc; Inkscape::Snapper::ConstraintLine cl(guideline.point_on_line, Geom::rot90(guideline.normal_to_line)); if (object.ThisSnapperMightSnap()) { - object.constrainedSnap(sc, Inkscape::SnapPreferences::SNAPPOINT_GUIDE, p, Inkscape::SNAPSOURCE_GUIDE_ORIGIN, true, Geom::OptRect(), cl, NULL); - } - - // Snap to guides - if (snapprefs.getSnapToGuides()) { - guide.constrainedSnap(sc, Inkscape::SnapPreferences::SNAPPOINT_GUIDE, p, Inkscape::SNAPSOURCE_GUIDE_ORIGIN, true, Geom::OptRect(), cl, NULL); + object.constrainedSnap(sc, Inkscape::SnapPreferences::SNAPPOINT_GUIDE, p, source_type, true, Geom::OptRect(), cl, NULL); } - // We won't snap to grids, what's the use? + // Snap to guides & grid lines + SnapperList snappers = getGridSnappers(); + snappers.push_back(&guide); + for (SnapperList::const_iterator i = snappers.begin(); i != snappers.end(); i++) { + (*i)->constrainedSnap(sc, Inkscape::SnapPreferences::SNAPPOINT_GUIDE, p, source_type, true, Geom::OptRect(), cl, NULL); + } - Inkscape::SnappedPoint const s = findBestSnap(p, Inkscape::SNAPSOURCE_GUIDE, sc, false); + Inkscape::SnappedPoint const s = findBestSnap(p, source_type, sc, false); s.getPoint(p); } -- cgit v1.2.3 From 8b04d0db6c55e36935690d37defb6f9b68945796 Mon Sep 17 00:00:00 2001 From: johnce Date: Wed, 5 Aug 2009 05:40:36 +0000 Subject: SPDocument->Document (bzr r8404) --- src/snap.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/snap.cpp') diff --git a/src/snap.cpp b/src/snap.cpp index f0769e0a1..48f3a8fea 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -1092,7 +1092,7 @@ void SnapManager::setup(SPDesktop const *desktop, _guide_to_ignore = guide_to_ignore; } -SPDocument *SnapManager::getDocument() const +Document *SnapManager::getDocument() const { return _named_view->document; } -- cgit v1.2.3 From 51c2905fd3e99955db2d823b79abb763d8097028 Mon Sep 17 00:00:00 2001 From: Maximilian Albert Date: Thu, 6 Aug 2009 14:17:17 +0000 Subject: Revert recent refactoring changes by johnce because they break the build, which cannot be fixed easily. (bzr r8422) --- src/snap.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/snap.cpp') diff --git a/src/snap.cpp b/src/snap.cpp index 48f3a8fea..f0769e0a1 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -1092,7 +1092,7 @@ void SnapManager::setup(SPDesktop const *desktop, _guide_to_ignore = guide_to_ignore; } -Document *SnapManager::getDocument() const +SPDocument *SnapManager::getDocument() const { return _named_view->document; } -- cgit v1.2.3 From b3f3d7ad268f67e27792ecfbcebab1bbbe646b74 Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Sun, 23 Aug 2009 13:55:47 +0000 Subject: When dragging a knot along a constraint line, then allow snapping the position of the mouse pointer instead of its projection onto the constraint line (for this a check box has been added to the preferences dialog) (bzr r8523) --- src/snap.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/snap.cpp') diff --git a/src/snap.cpp b/src/snap.cpp index f0769e0a1..c03f2e1e6 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -378,7 +378,10 @@ Inkscape::SnappedPoint SnapManager::constrainedSnap(Inkscape::SnapPreferences::P items_to_ignore = _items_to_ignore; } + + // First project the mouse pointer onto the constraint Geom::Point pp = constraint.projection(p); + // Then try to snap the projected point SnappedConstraints sc; SnapperList const snappers = getSnappers(); -- cgit v1.2.3 From ac652771931c1730c623848c75e8cbdd3f9fde84 Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Sun, 23 Aug 2009 19:56:43 +0000 Subject: - fix bug #414142 (Moving path nodes twice is hard when snap is enabled) - constrained snap: use projected point to calculate the snap distance (bzr r8526) --- src/snap.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/snap.cpp') diff --git a/src/snap.cpp b/src/snap.cpp index c03f2e1e6..545607889 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -393,7 +393,7 @@ Inkscape::SnappedPoint SnapManager::constrainedSnap(Inkscape::SnapPreferences::P delete items_to_ignore; } - return findBestSnap(p, source_type, sc, true); + return findBestSnap(pp, source_type, sc, true); } /** -- cgit v1.2.3