summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: fb7b7f4)
raw | patch | inline | side by side (parent: fb7b7f4)
author | Diederik van Lierop <mailat-signdiedenrezidotnl> | |
Fri, 21 May 2010 21:46:07 +0000 (23:46 +0200) | ||
committer | Diederik van Lierop <mailat-signdiedenrezidotnl> | |
Fri, 21 May 2010 21:46:07 +0000 (23:46 +0200) |
- Improved snap tooltips
diff --git a/src/object-snapper.cpp b/src/object-snapper.cpp
index 536affb8239750f437cb8eef6e694066b40c6eec..5c0ea419b0ba6535ab96a5607dd5baa27ceae793 100644 (file)
--- a/src/object-snapper.cpp
+++ b/src/object-snapper.cpp
bool Inkscape::ObjectSnapper::ThisSnapperMightSnap() const
{
bool snap_to_something = _snapmanager->snapprefs.getSnapToItemPath()
- || _snapmanager->snapprefs.getSnapToItemNode()
+ || _snapmanager->snapprefs.getSnapToItemNode() || _snapmanager->snapprefs.getSnapSmoothNodes()
|| _snapmanager->snapprefs.getSnapToBBoxPath()
|| _snapmanager->snapprefs.getSnapToBBoxNode()
|| _snapmanager->snapprefs.getSnapToPageBorder()
bool Inkscape::ObjectSnapper::GuidesMightSnap() const // almost the same as ThisSnapperMightSnap above, but only looking at points (and not paths)
{
- bool snap_to_something = _snapmanager->snapprefs.getSnapToItemNode()
+ bool snap_to_something = _snapmanager->snapprefs.getSnapToItemNode() || _snapmanager->snapprefs.getSnapSmoothNodes()
|| _snapmanager->snapprefs.getSnapToPageBorder()
|| (_snapmanager->snapprefs.getSnapModeBBox() && _snapmanager->snapprefs.getSnapToBBoxNode())
|| (_snapmanager->snapprefs.getSnapModeBBox() && (_snapmanager->snapprefs.getSnapBBoxEdgeMidpoints() || _snapmanager->snapprefs.getSnapBBoxMidpoints()))
diff --git a/src/selection.cpp b/src/selection.cpp
index 1e14591fae7474ffb838c274aabdf53f29328b7e..96c66e0c506496ec96ac1b8f99e425fb103a66e0 100644 (file)
--- a/src/selection.cpp
+++ b/src/selection.cpp
}
/**
- * Compute the list of points in the selection that are to be considered for snapping.
+ * Compute the list of points in the selection that are to be considered for snapping from.
*/
std::vector<Inkscape::SnapCandidatePoint> Selection::getSnapPoints(SnapPreferences const *snapprefs) const {
GSList const *items = const_cast<Selection *>(this)->itemList();
SnapPreferences snapprefs_dummy = *snapprefs; // create a local copy of the snapping prefs
snapprefs_dummy.setIncludeItemCenter(false); // locally disable snapping to the item center
-
+ snapprefs_dummy.setSnapToItemNode(true); // consider any type of nodes as a snap source
+ snapprefs_dummy.setSnapSmoothNodes(true); // i.e. disregard the smooth / cusp node preference
std::vector<Inkscape::SnapCandidatePoint> p;
for (GSList const *iter = items; iter != NULL; iter = iter->next) {
SPItem *this_item = SP_ITEM(iter->data);
@@ -446,13 +447,18 @@ std::vector<Inkscape::SnapCandidatePoint> Selection::getSnapPoints(SnapPreferenc
return p;
}
-
+// TODO: both getSnapPoints and getSnapPointsConvexHull are called, subsequently. Can we do this more efficient?
+// Why do we need to include the transformation center in one case and not the other?
std::vector<Inkscape::SnapCandidatePoint> Selection::getSnapPointsConvexHull(SnapPreferences const *snapprefs) const {
GSList const *items = const_cast<Selection *>(this)->itemList();
+ SnapPreferences snapprefs_dummy = *snapprefs; // create a local copy of the snapping prefs
+ snapprefs_dummy.setSnapToItemNode(true); // consider any type of nodes as a snap source
+ snapprefs_dummy.setSnapSmoothNodes(true); // i.e. disregard the smooth / cusp node preference
+
std::vector<Inkscape::SnapCandidatePoint> p;
for (GSList const *iter = items; iter != NULL; iter = iter->next) {
- sp_item_snappoints(SP_ITEM(iter->data), p, snapprefs);
+ sp_item_snappoints(SP_ITEM(iter->data), p, &snapprefs_dummy);
}
std::vector<Inkscape::SnapCandidatePoint> pHull;
diff --git a/src/seltrans.cpp b/src/seltrans.cpp
index aef608420ac258085a45754a7240a6f7b4b3452d..05f47d4ab017b02996ee661592d8fc5aadfba778 100644 (file)
--- a/src/seltrans.cpp
+++ b/src/seltrans.cpp
@@ -289,13 +289,9 @@ void Inkscape::SelTrans::grab(Geom::Point const &p, gdouble x, gdouble y, bool s
// Next, get all points to consider for snapping
SnapManager const &m = _desktop->namedview->snap_manager;
- Inkscape::SnapPreferences local_snapprefs = m.snapprefs;
- local_snapprefs.setSnapToItemNode(true); // We should get at least the cusp nodes here. This might
- // have been turned off because (for example) the user only want paths as a snap target, not nodes
- // but as a snap source we still need some nodes though!
_snap_points.clear();
- _snap_points = selection->getSnapPoints(&local_snapprefs);
- std::vector<Inkscape::SnapCandidatePoint> snap_points_hull = selection->getSnapPointsConvexHull(&local_snapprefs);
+ _snap_points = selection->getSnapPoints(&m.snapprefs);
+ std::vector<Inkscape::SnapCandidatePoint> snap_points_hull = selection->getSnapPointsConvexHull(&m.snapprefs);
if (_snap_points.size() > 200) {
/* Snapping a huge number of nodes will take way too long, so limit the number of snappable nodes
An average user would rarely ever try to snap such a large number of nodes anyway, because
diff --git a/src/snap-enums.h b/src/snap-enums.h
index cf09ba45bc22c45e9bd90f5247dfc43a7aaf6e1a..4e6854054df213dad7d3ee19e29ab2d74e355eac 100644 (file)
--- a/src/snap-enums.h
+++ b/src/snap-enums.h
//-------------------------------------------------------------------
// For the same reason, nodes will not snap to bbox points
SNAPSOURCE_NODE_CATEGORY = 512, // will be used as a flag and must therefore be a power of two
- SNAPSOURCE_NODE_SMOOTH,
+ SNAPSOURCE_NODE_SMOOTH, // Symmetrical nodes are also considered to be smooth; there's no dedicated type for symm. nodes
SNAPSOURCE_NODE_CUSP,
SNAPSOURCE_LINE_MIDPOINT,
SNAPSOURCE_PATH_INTERSECTION,
diff --git a/src/sp-shape.cpp b/src/sp-shape.cpp
index dadcb5f57d522e72ec9f10f8b7da0d9fd3d8ddec..3064341b66238b48b2842c7514771033183f0eb3 100644 (file)
--- a/src/sp-shape.cpp
+++ b/src/sp-shape.cpp
@@ -1227,7 +1227,24 @@ static void sp_shape_snappoints(SPItem const *item, std::vector<Inkscape::SnapCa
bool c2 = snapprefs->getSnapSmoothNodes() && (nodetype == Geom::NODE_SMOOTH || nodetype == Geom::NODE_SYMM);
if (c1 || c2) {
- p.push_back(Inkscape::SnapCandidatePoint(curve_it1->finalPoint() * i2d, Inkscape::SNAPSOURCE_NODE_CUSP, Inkscape::SNAPTARGET_NODE_CUSP));
+ Inkscape::SnapSourceType sst;
+ Inkscape::SnapTargetType stt;
+ switch (nodetype) {
+ case Geom::NODE_CUSP:
+ sst = Inkscape::SNAPSOURCE_NODE_CUSP;
+ stt = Inkscape::SNAPTARGET_NODE_CUSP;
+ break;
+ case Geom::NODE_SMOOTH:
+ case Geom::NODE_SYMM:
+ sst = Inkscape::SNAPSOURCE_NODE_SMOOTH;
+ stt = Inkscape::SNAPTARGET_NODE_SMOOTH;
+ break;
+ default:
+ sst = Inkscape::SNAPSOURCE_UNDEFINED;
+ stt = Inkscape::SNAPTARGET_UNDEFINED;
+ break;
+ }
+ p.push_back(Inkscape::SnapCandidatePoint(curve_it1->finalPoint() * i2d, sst, stt));
}
// Consider midpoints of line segments for snapping