Code

Changed preference to use file chooser button
[inkscape.git] / src / selection.cpp
index 05bd8d030283fd1d94d40fb2dfe46e8ba933fcba..af5db825c0c19efc905bfef8a4559a298fa10da9 100644 (file)
@@ -28,6 +28,7 @@
 
 #include "sp-shape.h"
 #include "sp-path.h"
+#include "sp-item-group.h"
 
 #include <sigc++/functors/mem_fun.h>
 
@@ -304,25 +305,25 @@ Inkscape::XML::Node *Selection::singleRepr() {
     return obj ? SP_OBJECT_REPR(obj) : NULL;
 }
 
-NRRect *Selection::bounds(NRRect *bbox) const
+NRRect *Selection::bounds(NRRect *bbox, SPItem::BBoxType type) const
 {
     g_return_val_if_fail (bbox != NULL, NULL);
-    *bbox = NRRect(bounds());
+    *bbox = NRRect(bounds(type));
     return bbox;
 }
 
-NR::Maybe<NR::Rect> Selection::bounds() const
+NR::Maybe<NR::Rect> Selection::bounds(SPItem::BBoxType type) const
 {
     GSList const *items = const_cast<Selection *>(this)->itemList();
 
     NR::Maybe<NR::Rect> bbox = NR::Nothing();
     for ( GSList const *i = items ; i != NULL ; i = i->next ) {
-        bbox = NR::union_bounds(bbox, sp_item_bbox_desktop(SP_ITEM(i->data)));
+        bbox = NR::union_bounds(bbox, sp_item_bbox_desktop(SP_ITEM(i->data), type));
     }
     return bbox;
 }
 
-NRRect *Selection::boundsInDocument(NRRect *bbox) const {
+NRRect *Selection::boundsInDocument(NRRect *bbox, SPItem::BBoxType type) const {
     g_return_val_if_fail (bbox != NULL, NULL);
 
     GSList const *items=const_cast<Selection *>(this)->itemList();
@@ -336,16 +337,16 @@ NRRect *Selection::boundsInDocument(NRRect *bbox) const {
 
     for ( GSList const *iter=items ; iter != NULL ; iter = iter->next ) {
         SPItem *item=SP_ITEM(iter->data);
-        NR::Matrix const i2doc(sp_item_i2doc_affine(item));
-        sp_item_invoke_bbox(item, bbox, i2doc, FALSE);
+        NR::Matrix i2doc(sp_item_i2doc_affine(item));
+        sp_item_invoke_bbox(item, bbox, i2doc, FALSE, type);
     }
 
     return bbox;
 }
 
-NR::Maybe<NR::Rect> Selection::boundsInDocument() const {
+NR::Maybe<NR::Rect> Selection::boundsInDocument(SPItem::BBoxType type) const {
     NRRect r;
-    return boundsInDocument(&r)->upgrade();
+    return boundsInDocument(&r, type)->upgrade();
 }
 
 /** Extract the position of the center from the first selected object */
@@ -370,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) {
@@ -380,8 +381,13 @@ std::vector<NR::Point> Selection::getSnapPoints() const {
         if (!SP_IS_PATH(this_item)) {
             // Only snap if we don't have a path at hand
             // (Same check occurs in sp-item-group)
-            sp_item_snappoints(this_item, SnapPointsIter(p));
+            sp_item_snappoints(this_item, false, SnapPointsIter(p));
         }
+        //Include the transformation origin for snapping
+        //For a group only the group's origin is considered
+        if (includeItemCenter) {
+               p.push_back(this_item->getCenter());
+        }  
     }
 
     return p;
@@ -392,7 +398,7 @@ std::vector<NR::Point> Selection::getSnapPointsConvexHull() const {
 
     std::vector<NR::Point> p;
     for (GSList const *iter = items; iter != NULL; iter = iter->next) {
-       sp_item_snappoints(SP_ITEM(iter->data), SnapPointsIter(p));
+               sp_item_snappoints(SP_ITEM(iter->data), false, SnapPointsIter(p));
     }
 
     std::vector<NR::Point> pHull;