summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/object-snapper.cpp15
-rw-r--r--src/snap-preferences.cpp4
-rw-r--r--src/snap-preferences.h1
-rw-r--r--src/snap.cpp10
-rw-r--r--src/snap.h2
-rw-r--r--src/snapper.h2
-rw-r--r--src/widgets/toolbox.cpp5
7 files changed, 22 insertions, 17 deletions
diff --git a/src/object-snapper.cpp b/src/object-snapper.cpp
index fd8ef0c7c..5bb7f0d00 100644
--- a/src/object-snapper.cpp
+++ b/src/object-snapper.cpp
@@ -227,6 +227,9 @@ void Inkscape::ObjectSnapper::_collectNodes(SnapSourceType const &t,
// paths though but only to item nodes then we should still look for the intersections in sp_item_snappoints()
bool old_pref = _snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_PATH_INTERSECTION);
if (_snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_PATH)) {
+ // So if we snap to paths, then findBestSnap will find the intersections
+ // and therefore we temporarily disable SNAPTARGET_PATH_INTERSECTION, which will
+ // avoid root_item->getSnappoints() below from returning intersections
_snapmanager->snapprefs.setTargetSnappable(SNAPTARGET_PATH_INTERSECTION, false);
}
@@ -322,7 +325,7 @@ void Inkscape::ObjectSnapper::_snapTranslatingGuide(SnappedConstraints &sc,
// Iterate through all nodes, find out which one is the closest to this guide, and snap to it!
_collectNodes(SNAPSOURCE_GUIDE, true);
- if (_snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_PATH, SNAPTARGET_BBOX_EDGE, SNAPTARGET_PAGE_BORDER)) {
+ if (_snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_PATH, SNAPTARGET_PATH_INTERSECTION, SNAPTARGET_BBOX_EDGE, SNAPTARGET_PAGE_BORDER)) {
_collectPaths(p, SNAPSOURCE_GUIDE, true);
_snapPaths(sc, SnapCandidatePoint(p, SNAPSOURCE_GUIDE), NULL, NULL);
}
@@ -399,7 +402,7 @@ void Inkscape::ObjectSnapper::_collectPaths(Geom::Point /*p*/,
//Build a list of all paths considered for snapping to
//Add the item's path to snap to
- if (_snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_PATH, SNAPTARGET_TEXT_BASELINE)) {
+ if (_snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_PATH, SNAPTARGET_PATH_INTERSECTION, SNAPTARGET_TEXT_BASELINE)) {
if (p_is_other || p_is_a_node || (!_snapmanager->snapprefs.getStrictSnapping() && p_is_a_bbox)) {
if (SP_IS_TEXT(root_item) || SP_IS_FLOWTEXT(root_item)) {
if (_snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_TEXT_BASELINE)) {
@@ -420,7 +423,7 @@ void Inkscape::ObjectSnapper::_collectPaths(Geom::Point /*p*/,
very_complex_path = sp_nodes_in_path(SP_PATH(root_item)) > 500;
}
- if (!very_complex_path && root_item && _snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_PATH)) {
+ if (!very_complex_path && root_item && _snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_PATH, SNAPTARGET_PATH_INTERSECTION)) {
SPCurve *curve = NULL;
if (SP_IS_SHAPE(root_item)) {
curve = SP_SHAPE(root_item)->getCurve();
@@ -474,7 +477,7 @@ void Inkscape::ObjectSnapper::_snapPaths(SnappedConstraints &sc,
g_assert(_snapmanager->getDesktop() != NULL);
Geom::Point const p_doc = _snapmanager->getDesktop()->dt2doc(p.getPoint());
- bool const node_tool_active = _snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_PATH) && selected_path != NULL;
+ bool const node_tool_active = _snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_PATH, SNAPTARGET_PATH_INTERSECTION) && selected_path != NULL;
if (p.getSourceNum() <= 0) {
/* findCandidates() is used for snapping to both paths and nodes. It ignores the path that is
@@ -689,7 +692,7 @@ void Inkscape::ObjectSnapper::freeSnap(SnappedConstraints &sc,
_snapNodes(sc, p, unselected_nodes);
- if (_snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_PATH, SNAPTARGET_BBOX_EDGE, SNAPTARGET_PAGE_BORDER, SNAPTARGET_TEXT_BASELINE)) {
+ if (_snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_PATH, SNAPTARGET_PATH_INTERSECTION, SNAPTARGET_BBOX_EDGE, SNAPTARGET_PAGE_BORDER, SNAPTARGET_TEXT_BASELINE)) {
unsigned n = (unselected_nodes == NULL) ? 0 : unselected_nodes->size();
if (n > 0) {
/* While editing a path in the node tool, findCandidates must ignore that path because
@@ -737,7 +740,7 @@ void Inkscape::ObjectSnapper::constrainedSnap( SnappedConstraints &sc,
_snapNodes(sc, p, unselected_nodes, c, pp);
- if (_snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_PATH, SNAPTARGET_BBOX_EDGE, SNAPTARGET_PAGE_BORDER, SNAPTARGET_TEXT_BASELINE)) {
+ if (_snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_PATH, SNAPTARGET_PATH_INTERSECTION, SNAPTARGET_BBOX_EDGE, SNAPTARGET_PAGE_BORDER, SNAPTARGET_TEXT_BASELINE)) {
_snapPathsConstrained(sc, p, c, pp);
}
}
diff --git a/src/snap-preferences.cpp b/src/snap-preferences.cpp
index d655564f2..a1d4b62fa 100644
--- a/src/snap-preferences.cpp
+++ b/src/snap-preferences.cpp
@@ -273,6 +273,10 @@ bool Inkscape::SnapPreferences::isTargetSnappable(Inkscape::SnapTargetType const
return isTargetSnappable(target1) || isTargetSnappable(target2) || isTargetSnappable(target3) || isTargetSnappable(target4);
}
+bool Inkscape::SnapPreferences::isTargetSnappable(Inkscape::SnapTargetType const target1, Inkscape::SnapTargetType const target2, Inkscape::SnapTargetType const target3, Inkscape::SnapTargetType const target4, Inkscape::SnapTargetType const target5) const {
+ return isTargetSnappable(target1) || isTargetSnappable(target2) || isTargetSnappable(target3) || isTargetSnappable(target4) || isTargetSnappable(target5);
+}
+
bool Inkscape::SnapPreferences::isSnapButtonEnabled(Inkscape::SnapTargetType const target) const
{
bool always_on = false; // Only needed as a dummy
diff --git a/src/snap-preferences.h b/src/snap-preferences.h
index cfcdf6137..9f126d791 100644
--- a/src/snap-preferences.h
+++ b/src/snap-preferences.h
@@ -28,6 +28,7 @@ public:
bool isTargetSnappable(Inkscape::SnapTargetType const target1, Inkscape::SnapTargetType const target2) const;
bool isTargetSnappable(Inkscape::SnapTargetType const target1, Inkscape::SnapTargetType const target2, Inkscape::SnapTargetType const target3) const;
bool isTargetSnappable(Inkscape::SnapTargetType const target1, Inkscape::SnapTargetType const target2, Inkscape::SnapTargetType const target3, Inkscape::SnapTargetType const target4) const;
+ bool isTargetSnappable(Inkscape::SnapTargetType const target1, Inkscape::SnapTargetType const target2, Inkscape::SnapTargetType const target3, Inkscape::SnapTargetType const target4, Inkscape::SnapTargetType const target5) const;
bool isSnapButtonEnabled(Inkscape::SnapTargetType const target) const;
void setSnapModeBBox(bool enabled);
diff --git a/src/snap.cpp b/src/snap.cpp
index 7647341fe..67630399f 100644
--- a/src/snap.cpp
+++ b/src/snap.cpp
@@ -288,7 +288,7 @@ Geom::Point SnapManager::multipleOfGridPitch(Geom::Point const &t, Geom::Point c
// Find the best snap for this grid, including intersections of the grid-lines
bool old_val = _snapindicator;
_snapindicator = false;
- Inkscape::SnappedPoint s = findBestSnap(Inkscape::SnapCandidatePoint(t_offset, Inkscape::SNAPSOURCE_GRID_PITCH), sc, false, false, true);
+ Inkscape::SnappedPoint s = findBestSnap(Inkscape::SnapCandidatePoint(t_offset, Inkscape::SNAPSOURCE_GRID_PITCH), sc, false, true);
_snapindicator = old_val;
if (s.getSnapped() && (s.getSnapDistance() < nearest_distance)) {
// use getSnapDistance() instead of getWeightedDistance() here because the pointer's position
@@ -584,7 +584,7 @@ void SnapManager::guideFreeSnap(Geom::Point &p, Geom::Point const &guide_normal,
(*i)->freeSnap(sc, candidate, Geom::OptRect(), NULL, NULL);
}
- Inkscape::SnappedPoint const s = findBestSnap(candidate, sc, false, false);
+ Inkscape::SnappedPoint const s = findBestSnap(candidate, sc, false);
s.getPointIfSnapped(p);
}
@@ -1135,7 +1135,6 @@ Inkscape::SnappedPoint SnapManager::constrainedSnapRotate(std::vector<Inkscape::
* \param p Source point to be snapped
* \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 themselves
* \param allowOffScreen If true, then snapping to points which are off the screen is allowed (needed for example when pasting to the grid)
* \return An instance of the SnappedPoint class, which holds data on the snap source, snap target, and various metrics
*/
@@ -1143,7 +1142,6 @@ Inkscape::SnappedPoint SnapManager::constrainedSnapRotate(std::vector<Inkscape::
Inkscape::SnappedPoint SnapManager::findBestSnap(Inkscape::SnapCandidatePoint const &p,
SnappedConstraints const &sc,
bool constrained,
- bool noCurves,
bool allowOffScreen) const
{
g_assert(_desktop != NULL);
@@ -1151,7 +1149,7 @@ Inkscape::SnappedPoint SnapManager::findBestSnap(Inkscape::SnapCandidatePoint co
/*
std::cout << "Type and number of snapped constraints: " << std::endl;
std::cout << " Points : " << sc.points.size() << std::endl;
- std::cout << " Lines : " << sc.lines.size() << std::endl;
+ // std::cout << " Lines : " << sc.lines.size() << std::endl;
std::cout << " Grid lines : " << sc.grid_lines.size()<< std::endl;
std::cout << " Guide lines : " << sc.guide_lines.size()<< std::endl;
std::cout << " Curves : " << sc.curves.size()<< std::endl;
@@ -1167,7 +1165,7 @@ Inkscape::SnappedPoint SnapManager::findBestSnap(Inkscape::SnapCandidatePoint co
}
// search for the closest snapped curve
- if (!noCurves) {
+ if (snapprefs.isTargetSnappable(Inkscape::SNAPTARGET_PATH)) { // We might have been looking for path intersections only, and not for the paths themselves
Inkscape::SnappedCurve closestCurve;
if (getClosestCurve(sc.curves, closestCurve)) {
sp_list.push_back(Inkscape::SnappedPoint(closestCurve));
diff --git a/src/snap.h b/src/snap.h
index 8f8416ee5..a7b98748e 100644
--- a/src/snap.h
+++ b/src/snap.h
@@ -199,7 +199,7 @@ public:
bool getSnapIndicator() const {return _snapindicator;}
- Inkscape::SnappedPoint findBestSnap(Inkscape::SnapCandidatePoint const &p, SnappedConstraints const &sc, bool constrained, bool noCurves = false, bool allowOffScreen = false) const;
+ Inkscape::SnappedPoint findBestSnap(Inkscape::SnapCandidatePoint const &p, SnappedConstraints const &sc, bool constrained, bool allowOffScreen = false) const;
void keepClosestPointOnly(std::vector<Inkscape::SnapCandidatePoint> &points, const Geom::Point &reference) const;
protected:
diff --git a/src/snapper.h b/src/snapper.h
index 91784d3ae..b3bf9f726 100644
--- a/src/snapper.h
+++ b/src/snapper.h
@@ -25,7 +25,7 @@
struct SnappedConstraints {
std::list<Inkscape::SnappedPoint> points;
- std::list<Inkscape::SnappedLineSegment> lines;
+ //std::list<Inkscape::SnappedLineSegment> lines;
std::list<Inkscape::SnappedLine> grid_lines;
std::list<Inkscape::SnappedLine> guide_lines;
std::list<Inkscape::SnappedCurve> curves;
diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp
index 26947979d..41e6eb626 100644
--- a/src/widgets/toolbox.cpp
+++ b/src/widgets/toolbox.cpp
@@ -2529,11 +2529,10 @@ void ToolboxFactory::updateSnapToolbox(SPDesktop *desktop, SPEventContext * /*ev
gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act5->gobj()), c3);
gtk_action_set_sensitive(GTK_ACTION(act5->gobj()), c1);
- bool const c4 = nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_PATH);
- gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act6->gobj()), c4);
+ gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act6->gobj()), nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_PATH));
gtk_action_set_sensitive(GTK_ACTION(act6->gobj()), c1 && c3);
gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act6b->gobj()), nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_PATH_INTERSECTION));
- gtk_action_set_sensitive(GTK_ACTION(act6b->gobj()), c1 && c3 && c4);
+ gtk_action_set_sensitive(GTK_ACTION(act6b->gobj()), c1 && c3);
gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act7->gobj()), nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_NODE_CUSP));
gtk_action_set_sensitive(GTK_ACTION(act7->gobj()), c1 && c3);
gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act8->gobj()), nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_NODE_SMOOTH));