From 1079b1b4c0331e5d4bd62f3c93349aec50f520f0 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Thu, 23 Jun 2011 18:38:51 +0200 Subject: Update 2Geom to pull in integer rectangle class (bzr r10347.1.1) --- src/selection.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/selection.cpp') diff --git a/src/selection.cpp b/src/selection.cpp index 7564fad3a..3c4ccccf2 100644 --- a/src/selection.cpp +++ b/src/selection.cpp @@ -375,7 +375,7 @@ Geom::OptRect Selection::bounds(SPItem::BBoxType type) const Geom::OptRect bbox; for ( GSList const *i = items ; i != NULL ; i = i->next ) { - bbox = unify(bbox, SP_ITEM(i->data)->getBboxDesktop(type)); + bbox.unionWith(SP_ITEM(i->data)->getBboxDesktop(type)); } return bbox; } -- cgit v1.2.3 From ab143333746e25648b253f13c0539adff089b1b6 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Fri, 24 Jun 2011 00:22:07 +0200 Subject: Remove more of libnr (bzr r10347.1.2) --- src/selection.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/selection.cpp') diff --git a/src/selection.cpp b/src/selection.cpp index 3c4ccccf2..3007a3d1f 100644 --- a/src/selection.cpp +++ b/src/selection.cpp @@ -403,7 +403,7 @@ NRRect *Selection::boundsInDocument(NRRect *bbox, SPItem::BBoxType type) const { Geom::OptRect Selection::boundsInDocument(SPItem::BBoxType type) const { NRRect r; - return to_2geom(boundsInDocument(&r, type)->upgrade()); + return to_2geom(boundsInDocument(&r, type)); } /** Extract the position of the center from the first selected object */ -- cgit v1.2.3 From babb7a67749cb691674bdd9758f0568d4b094b56 Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Mon, 22 Aug 2011 20:27:53 +0200 Subject: Refactoring of the snapping preferences; mainly about storing all toggles in a single array, instead of each having its own member variable (bzr r10569) --- src/selection.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/selection.cpp') diff --git a/src/selection.cpp b/src/selection.cpp index 3007a3d1f..677e57d5f 100644 --- a/src/selection.cpp +++ b/src/selection.cpp @@ -433,9 +433,9 @@ std::vector Selection::getSnapPoints(SnapPreferenc GSList const *items = const_cast(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 - snapprefs_dummy.setSnapToItemNode(true); // consider any type of nodes as a snap source - snapprefs_dummy.setSnapSmoothNodes(true); // i.e. disregard the smooth / cusp node preference + snapprefs_dummy.setTargetSnappable(Inkscape::SNAPTARGET_ROTATION_CENTER, false); // locally disable snapping to the item center + //snapprefs_dummy.setTargetSnappable(Inkscape::SNAPTARGET_NODE_CUSP, true); // consider any type of nodes as a snap source + //snapprefs_dummy.setTargetSnappable(Inkscape::SNAPTARGET_NODE_SMOOTH, true); // i.e. disregard the smooth / cusp node preference std::vector p; for (GSList const *iter = items; iter != NULL; iter = iter->next) { SPItem *this_item = SP_ITEM(iter->data); @@ -443,7 +443,7 @@ std::vector Selection::getSnapPoints(SnapPreferenc //Include the transformation origin for snapping //For a selection or group only the overall origin is considered - if (snapprefs != NULL && snapprefs->getIncludeItemCenter()) { + if (snapprefs != NULL && snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_ROTATION_CENTER)) { p.push_back(Inkscape::SnapCandidatePoint(this_item->getCenter(), SNAPSOURCE_ROTATION_CENTER)); } } @@ -456,8 +456,8 @@ std::vector Selection::getSnapPointsConvexHull(Sna GSList const *items = const_cast(this)->itemList(); SnapPreferences snapprefs_dummy = *snapprefs; // create a local copy of the snapping prefs - snapprefs_dummy.setSnapToItemNode(true); // consider any type of nodes as a snap source - snapprefs_dummy.setSnapSmoothNodes(true); // i.e. disregard the smooth / cusp node preference + snapprefs_dummy.setTargetSnappable(Inkscape::SNAPTARGET_NODE_CUSP, true); // consider any type of nodes as a snap source + snapprefs_dummy.setTargetSnappable(Inkscape::SNAPTARGET_NODE_SMOOTH, true); // i.e. disregard the smooth / cusp node preference std::vector p; for (GSList const *iter = items; iter != NULL; iter = iter->next) { -- cgit v1.2.3 From 72cc39b9f0b340548f395c7f61ca9662b34aea09 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Sat, 27 Aug 2011 11:04:37 +0200 Subject: Refactor SPItem bounding box methods: remove NRRect usage and make code using them more obvious. Fix filter region computation. (bzr r10582.1.1) --- src/selection.cpp | 46 ++++++++++++++++++++++------------------------ 1 file changed, 22 insertions(+), 24 deletions(-) (limited to 'src/selection.cpp') diff --git a/src/selection.cpp b/src/selection.cpp index 677e57d5f..92b35bce7 100644 --- a/src/selection.cpp +++ b/src/selection.cpp @@ -362,50 +362,48 @@ Inkscape::XML::Node *Selection::singleRepr() { return obj ? obj->getRepr() : NULL; } -NRRect *Selection::bounds(NRRect *bbox, SPItem::BBoxType type) const +Geom::OptRect Selection::bounds(SPItem::BBoxType type) const { - g_return_val_if_fail (bbox != NULL, NULL); - *bbox = NRRect(bounds(type)); - return bbox; + return (type == SPItem::GEOMETRIC_BBOX) ? + geometricBounds() : visualBounds(); } -Geom::OptRect Selection::bounds(SPItem::BBoxType type) const +Geom::OptRect Selection::geometricBounds() const { GSList const *items = const_cast(this)->itemList(); Geom::OptRect bbox; for ( GSList const *i = items ; i != NULL ; i = i->next ) { - bbox.unionWith(SP_ITEM(i->data)->getBboxDesktop(type)); + bbox.unionWith(SP_ITEM(i->data)->desktopGeometricBounds()); } return bbox; } -NRRect *Selection::boundsInDocument(NRRect *bbox, SPItem::BBoxType type) const { - g_return_val_if_fail (bbox != NULL, NULL); +Geom::OptRect Selection::visualBounds() const +{ + GSList const *items = const_cast(this)->itemList(); - GSList const *items=const_cast(this)->itemList(); - if (!items) { - bbox->x0 = bbox->y0 = bbox->x1 = bbox->y1 = 0.0; - return bbox; + Geom::OptRect bbox; + for ( GSList const *i = items ; i != NULL ; i = i->next ) { + bbox.unionWith(SP_ITEM(i->data)->desktopVisualBounds()); } + return bbox; +} - bbox->x0 = bbox->y0 = 1e18; - bbox->x1 = bbox->y1 = -1e18; +Geom::OptRect Selection::documentBounds(SPItem::BBoxType type) const +{ + Geom::OptRect bbox; + GSList const *items = const_cast(this)->itemList(); + if (!items) return bbox; for ( GSList const *iter=items ; iter != NULL ; iter = iter->next ) { - SPItem *item=SP_ITEM(iter->data); - Geom::Affine i2doc(item->i2doc_affine()); - item->invoke_bbox( bbox, i2doc, FALSE, type); + SPItem *item = SP_ITEM(iter->data); + bbox |= item->documentBounds(type); } return bbox; } -Geom::OptRect Selection::boundsInDocument(SPItem::BBoxType type) const { - NRRect r; - return to_2geom(boundsInDocument(&r, type)); -} - /** Extract the position of the center from the first selected object */ // If we have a selection of multiple items, then the center of the first item // will be returned; this is also the case in SelTrans::centerRequest() @@ -418,9 +416,9 @@ boost::optional Selection::center() const { return first->getCenter(); } } - Geom::OptRect bbox = bounds(); + Geom::OptRect bbox = visualBounds(); if (bbox) { - return bounds()->midpoint(); + return bbox->midpoint(); } else { return boost::optional(); } -- cgit v1.2.3 From 1c0a4eca434ada5675c6edc476325b7bb64da1a6 Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Sun, 4 Sep 2011 20:11:51 +0200 Subject: 1) Fix absolute scaling in transform dialog 2) Transform dialog now follows the user prefs for geometric vs. visual bounding box (bzr r10615) --- src/selection.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/selection.cpp') diff --git a/src/selection.cpp b/src/selection.cpp index 92b35bce7..5376311b1 100644 --- a/src/selection.cpp +++ b/src/selection.cpp @@ -27,6 +27,7 @@ #include "selection.h" #include "helper/recthull.h" #include "xml/repr.h" +#include "preferences.h" #include "sp-shape.h" #include "sp-path.h" @@ -390,6 +391,15 @@ Geom::OptRect Selection::visualBounds() const return bbox; } +Geom::OptRect Selection::preferredBounds() const +{ + if (Inkscape::Preferences::get()->getInt("/tools/bounding_box") == 0) { + return bounds(SPItem::VISUAL_BBOX); + } else { + return bounds(SPItem::GEOMETRIC_BBOX); + } +} + Geom::OptRect Selection::documentBounds(SPItem::BBoxType type) const { Geom::OptRect bbox; -- cgit v1.2.3 From 2633767789e4264b13ef91a684accf734fb4e94f Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Wed, 26 Oct 2011 21:55:51 -0700 Subject: Fixing more broken and split doc comments. (bzr r10697) --- src/selection.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'src/selection.cpp') diff --git a/src/selection.cpp b/src/selection.cpp index 5376311b1..ff444fa98 100644 --- a/src/selection.cpp +++ b/src/selection.cpp @@ -1,4 +1,4 @@ -/** \file +/* * Per-desktop selection container * * Authors: @@ -414,7 +414,6 @@ Geom::OptRect Selection::documentBounds(SPItem::BBoxType type) const return bbox; } -/** Extract the position of the center from the first selected object */ // If we have a selection of multiple items, then the center of the first item // will be returned; this is also the case in SelTrans::centerRequest() boost::optional Selection::center() const { @@ -434,9 +433,6 @@ boost::optional Selection::center() const { } } -/** - * Compute the list of points in the selection that are to be considered for snapping from. - */ std::vector Selection::getSnapPoints(SnapPreferences const *snapprefs) const { GSList const *items = const_cast(this)->itemList(); @@ -458,6 +454,7 @@ std::vector Selection::getSnapPoints(SnapPreferenc return p; } + // TODO: both getSnapPoints and getSnapPointsConvexHull are called, subsequently. Can we do this more efficient? // Why do we need to include the transformation center in one case and not the other? std::vector Selection::getSnapPointsConvexHull(SnapPreferences const *snapprefs) const { -- cgit v1.2.3