diff --git a/src/selection.cpp b/src/selection.cpp
index 05bd8d030283fd1d94d40fb2dfe46e8ba933fcba..68a9a2cd92e719ebd151cbbcb78725a113452743 100644 (file)
--- a/src/selection.cpp
+++ b/src/selection.cpp
#include "sp-shape.h"
#include "sp-path.h"
+#include "sp-item-group.h"
#include <sigc++/functors/mem_fun.h>
/* Handler for selected objects "modified" signal */
-void Selection::_schedule_modified(SPObject *obj, guint flags) {
+void Selection::_schedule_modified(SPObject */*obj*/, guint flags) {
if (!this->_idle) {
/* Request handling to be run in _idle loop */
this->_idle = g_idle_add_full(SP_SELECTION_UPDATE_PRIORITY, GSourceFunc(&Selection::_emit_modified), this, NULL);
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();
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 */
/**
* 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) {
- // getSnapPoints() is only being used in the selector tool, which should
- // not snap path nodes. Only the node tool should snap those.
SPItem *this_item = SP_ITEM(iter->data);
- 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;
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;