Code

Make snapping to the item's transformation center optional, but not yet available...
authordvlierop2 <dvlierop2@users.sourceforge.net>
Sat, 4 Aug 2007 09:10:17 +0000 (09:10 +0000)
committerdvlierop2 <dvlierop2@users.sourceforge.net>
Sat, 4 Aug 2007 09:10:17 +0000 (09:10 +0000)
src/selection.cpp
src/selection.h
src/seltrans.cpp
src/snap.cpp
src/snap.h

index 2b143dd5a3f379c707be65604113fd2c2d84ed92..ca3de5927e7c41705de52a7df30b384719cabc5f 100644 (file)
@@ -371,7 +371,7 @@ NR::Maybe<NR::Point> 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<NR::Point> Selection::getSnapPoints() const {
+std::vector<NR::Point> Selection::getSnapPoints(bool includeItemCenter) const {
     GSList const *items = const_cast<Selection *>(this)->itemList();
     std::vector<NR::Point> p;
     for (GSList const *iter = items; iter != NULL; iter = iter->next) {
@@ -385,7 +385,9 @@ std::vector<NR::Point> 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;
index d8427108f344eece726a6846e5e5b66f2ded30ed..58204160b7de9e1972728912f3f4e27c7a4670bc 100644 (file)
@@ -259,7 +259,7 @@ public:
      * @brief Gets the selection's snap points.
      * @return Selection's snap points
      */
-    std::vector<NR::Point> getSnapPoints() const;
+    std::vector<NR::Point> getSnapPoints(bool includeItemCenter) const;
 
     /**
      * @brief Gets the snap points of a selection that form a convex hull.
index 465813ae0b68834f6704e25f95918d71ce70e587..ad37e24cf9b3ab5eda2c500fddff5432d9171fea 100644 (file)
@@ -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<NR::Point> 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
index 3ef246447f3a317b4d5e9b5c45cbd10b85537dbe..f5c1c9589811f95bf88c4bc890afebcf4c9cd70c 100644 (file)
@@ -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)
 {
        
 }
index 401fd60bad1eeafa2ebd0484348b75bdae054821..c60d866ad34d0bce75a65f667c961f605b82e9c6 100644 (file)
@@ -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<NR::Point, bool> _snapTransformed(Inkscape::Snapper::PointType type,
                                                 std::vector<NR::Point> const &points,
                                                 std::list<SPItem const *> const &ignore,