Code

patch by Diederik for jumping images, bug 168384
[inkscape.git] / src / selection.cpp
index 4ed6c0842b92ba71d7fa884fd171deb8ef77b01e..4d92a18df77948f7de0620a8609566eb9e33075e 100644 (file)
@@ -383,11 +383,11 @@ NRRect *Selection::bounds(NRRect *bbox, SPItem::BBoxType type) const
     return bbox;
 }
 
-boost::optional<Geom::Rect> Selection::bounds(SPItem::BBoxType type) const
+Geom::OptRect Selection::bounds(SPItem::BBoxType type) const
 {
     GSList const *items = const_cast<Selection *>(this)->itemList();
 
-    boost::optional<Geom::Rect> bbox;
+    Geom::OptRect bbox;
     for ( GSList const *i = items ; i != NULL ; i = i->next ) {
         bbox = unify(bbox, sp_item_bbox_desktop(SP_ITEM(i->data), type));
     }
@@ -415,7 +415,7 @@ NRRect *Selection::boundsInDocument(NRRect *bbox, SPItem::BBoxType type) const {
     return bbox;
 }
 
-boost::optional<Geom::Rect> Selection::boundsInDocument(SPItem::BBoxType type) const {
+Geom::OptRect Selection::boundsInDocument(SPItem::BBoxType type) const {
     NRRect r;
     return to_2geom(boundsInDocument(&r, type)->upgrade());
 }
@@ -430,7 +430,7 @@ boost::optional<Geom::Point> Selection::center() const {
             return first->getCenter();
         }
     }
-    boost::optional<Geom::Rect> bbox = bounds();
+    Geom::OptRect bbox = bounds();
     if (bbox) {
         return bounds()->midpoint();
     } else {
@@ -441,48 +441,48 @@ boost::optional<Geom::Point> Selection::center() const {
 /**
  * Compute the list of points in the selection that are to be considered for snapping.
  */
-std::vector<Geom::Point> Selection::getSnapPoints(SnapPreferences const *snapprefs) const {
+std::vector<std::pair<Geom::Point, int> > 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
-    
-    std::vector<Geom::Point> p;
+
+    std::vector<std::pair<Geom::Point, int> > p;
     for (GSList const *iter = items; iter != NULL; iter = iter->next) {
         SPItem *this_item = SP_ITEM(iter->data);
-        sp_item_snappoints(this_item, SnapPointsIter(p), &snapprefs_dummy);
-       
+        sp_item_snappoints(this_item, false, p, &snapprefs_dummy);
+
         //Include the transformation origin for snapping
         //For a selection or group only the overall origin is considered
         if (snapprefs != NULL && snapprefs->getIncludeItemCenter()) {
-               p.push_back(this_item->getCenter());
-        }  
+               p.push_back(std::make_pair(this_item->getCenter(), SNAPSOURCE_ROTATION_CENTER));
+        }
     }
 
     return p;
 }
 
-std::vector<Geom::Point> Selection::getSnapPointsConvexHull(SnapPreferences const *snapprefs) const {
+std::vector<std::pair<Geom::Point, int> > Selection::getSnapPointsConvexHull(SnapPreferences const *snapprefs) const {
     GSList const *items = const_cast<Selection *>(this)->itemList();
 
-    std::vector<Geom::Point> p;
+    std::vector<std::pair<Geom::Point, int> > p;
     for (GSList const *iter = items; iter != NULL; iter = iter->next) {
-               sp_item_snappoints(SP_ITEM(iter->data), SnapPointsIter(p), snapprefs);
+               sp_item_snappoints(SP_ITEM(iter->data), false, p, snapprefs);
     }
 
-    std::vector<Geom::Point> pHull;
+    std::vector<std::pair<Geom::Point, int> > pHull;
     if (!p.empty()) {
-        std::vector<Geom::Point>::iterator i;
-        Geom::RectHull cvh(p.front());
+       std::vector<std::pair<Geom::Point, int> >::iterator i;
+        Geom::RectHull cvh((p.front()).first);
         for (i = p.begin(); i != p.end(); i++) {
             // these are the points we get back
-            cvh.add(*i);
+            cvh.add((*i).first);
         }
 
-        boost::optional<Geom::Rect> rHull = cvh.bounds();
+        Geom::OptRect rHull = cvh.bounds();
         if (rHull) {
             for ( unsigned i = 0 ; i < 4 ; ++i ) {
-                pHull.push_back(rHull->corner(i));
+                pHull.push_back(std::make_pair(rHull->corner(i), SNAPSOURCE_CONVEX_HULL_CORNER));
             }
         }
     }