From: dvlierop2 Date: Sat, 4 Aug 2007 09:10:17 +0000 (+0000) Subject: Make snapping to the item's transformation center optional, but not yet available... X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=2be7d23c40148bb4a74c541f6847518e21392591;p=inkscape.git Make snapping to the item's transformation center optional, but not yet available in the snapping preferences dialog --- diff --git a/src/selection.cpp b/src/selection.cpp index 2b143dd5a..ca3de5927 100644 --- a/src/selection.cpp +++ b/src/selection.cpp @@ -371,7 +371,7 @@ NR::Maybe Selection::center() const { * Compute the list of points in the selection that are to be considered for snapping. * This includes all special points of each item in the selection, except path nodes */ -std::vector Selection::getSnapPoints() const { +std::vector Selection::getSnapPoints(bool includeItemCenter) const { GSList const *items = const_cast(this)->itemList(); std::vector p; for (GSList const *iter = items; iter != NULL; iter = iter->next) { @@ -385,7 +385,9 @@ std::vector Selection::getSnapPoints() const { } //Include the transformation origin for snapping //For a group only the group's origin is considered - p.push_back(this_item->getCenter()); + if (includeItemCenter) { + p.push_back(this_item->getCenter()); + } } return p; diff --git a/src/selection.h b/src/selection.h index d8427108f..58204160b 100644 --- a/src/selection.h +++ b/src/selection.h @@ -259,7 +259,7 @@ public: * @brief Gets the selection's snap points. * @return Selection's snap points */ - std::vector getSnapPoints() const; + std::vector getSnapPoints(bool includeItemCenter) const; /** * @brief Gets the snap points of a selection that form a convex hull. diff --git a/src/seltrans.cpp b/src/seltrans.cpp index 465813ae0..ad37e24cf 100644 --- a/src/seltrans.cpp +++ b/src/seltrans.cpp @@ -268,7 +268,8 @@ void Inkscape::SelTrans::grab(NR::Point const &p, gdouble x, gdouble y, bool sho // Next, get all special points for snapping - _snap_points = selection->getSnapPoints(); // Excludes path nodes + SnapManager const &m = _desktop->namedview->snap_manager; + _snap_points = selection->getSnapPoints(m.getIncludeItemCenter()); // Excludes path nodes std::vector snap_points_hull = selection->getSnapPointsConvexHull(); // Includes path nodes if (_snap_points.size() > 100) { /* Snapping a huge number of nodes will take way too long, so limit the number of snappable nodes diff --git a/src/snap.cpp b/src/snap.cpp index 3ef246447..f5c1c9589 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -36,7 +36,8 @@ SnapManager::SnapManager(SPNamedView const *v) : guide(v, 0), object(v, 0), - _named_view(v) + _named_view(v), + _include_item_center(false) { } diff --git a/src/snap.h b/src/snap.h index 401fd60ba..c60d866ad 100644 --- a/src/snap.h +++ b/src/snap.h @@ -127,6 +127,14 @@ public: bool getSnapModeBBox() const; bool getSnapModeNode() const; + void setIncludeItemCenter(bool enabled) { + _include_item_center = enabled; + } + + bool getIncludeItemCenter() const { + return _include_item_center; + } + protected: SPNamedView const *_named_view; @@ -139,6 +147,8 @@ private: SKEW }; + bool _include_item_center; //If true, snapping nodes will also snap the item's center + std::pair _snapTransformed(Inkscape::Snapper::PointType type, std::vector const &points, std::list const &ignore,