summaryrefslogtreecommitdiffstats
path: root/src/object-snapper.cpp
diff options
context:
space:
mode:
authorMartin Owens <doctormo@gmail.com>2014-03-27 01:33:44 +0000
committerMartin Owens <doctormo@gmail.com>2014-03-27 01:33:44 +0000
commit5a4fb2325f60d292b47330f540b26a3279341c90 (patch)
treed2aa7967be25450b83e625025366c618101ae49f /src/object-snapper.cpp
parentThe Polar Arrange Tab of the Arrange Dialog now hides the parametric (diff)
parentRemove Snap menu item and improve grid menu item text (diff)
downloadinkscape-5a4fb2325f60d292b47330f540b26a3279341c90.tar.gz
inkscape-5a4fb2325f60d292b47330f540b26a3279341c90.zip
Commit a merge to trunk, with probabal errors
(bzr r11073.1.36)
Diffstat (limited to 'src/object-snapper.cpp')
-rw-r--r--src/object-snapper.cpp71
1 files changed, 35 insertions, 36 deletions
diff --git a/src/object-snapper.cpp b/src/object-snapper.cpp
index e6f6d87db..3b8956bc8 100644
--- a/src/object-snapper.cpp
+++ b/src/object-snapper.cpp
@@ -106,12 +106,11 @@ void Inkscape::ObjectSnapper::_findCandidates(SPObject* parent,
if (it == NULL || i == it->end()) {
SPItem *item = SP_ITEM(o);
if (item) {
- SPObject *obj = NULL;
if (!clip_or_mask) { // cannot clip or mask more than once
// The current item is not a clipping path or a mask, but might
// still be the subject of clipping or masking itself ; if so, then
// we should also consider that path or mask for snapping to
- obj = SP_OBJECT(item->clip_ref ? item->clip_ref->getObject() : NULL);
+ SPObject *obj = SP_OBJECT(item->clip_ref ? item->clip_ref->getObject() : NULL);
if (obj && _snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_PATH_CLIP)) {
_findCandidates(obj, it, false, bbox_to_snap, true, item->i2doc_affine());
}
@@ -120,35 +119,35 @@ void Inkscape::ObjectSnapper::_findCandidates(SPObject* parent,
_findCandidates(obj, it, false, bbox_to_snap, true, item->i2doc_affine());
}
}
- }
- if (SP_IS_GROUP(o)) {
- _findCandidates(o, it, false, bbox_to_snap, clip_or_mask, additional_affine);
- } else {
- Geom::OptRect bbox_of_item;
- Preferences *prefs = Preferences::get();
- int prefs_bbox = prefs->getBool("/tools/bounding_box", 0);
- // We'll only need to obtain the visual bounding box if the user preferences tell
- // us to, AND if we are snapping to the bounding box itself. If we're snapping to
- // paths only, then we can just as well use the geometric bounding box (which is faster)
- SPItem::BBoxType bbox_type = (!prefs_bbox && _snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_BBOX_CATEGORY)) ?
- SPItem::VISUAL_BBOX : SPItem::GEOMETRIC_BBOX;
- if (clip_or_mask) {
- // Oh oh, this will get ugly. We cannot use sp_item_i2d_affine directly because we need to
- // insert an additional transformation in document coordinates (code copied from sp_item_i2d_affine)
- bbox_of_item = item->bounds(bbox_type, item->i2doc_affine() * additional_affine * dt->doc2dt());
+ if (SP_IS_GROUP(o)) {
+ _findCandidates(o, it, false, bbox_to_snap, clip_or_mask, additional_affine);
} else {
- bbox_of_item = item->desktopBounds(bbox_type);
- }
- if (bbox_of_item) {
- // See if the item is within range
- if (bbox_to_snap_incl.intersects(*bbox_of_item)
- || (_snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_ROTATION_CENTER) && bbox_to_snap_incl.contains(item->getCenter()))) { // rotation center might be outside of the bounding box
- // This item is within snapping range, so record it as a candidate
- _candidates->push_back(SnapCandidateItem(item, clip_or_mask, additional_affine));
- // For debugging: print the id of the candidate to the console
- // SPObject *obj = (SPObject*)item;
- // std::cout << "Snap candidate added: " << obj->getId() << std::endl;
+ Geom::OptRect bbox_of_item;
+ Preferences *prefs = Preferences::get();
+ int prefs_bbox = prefs->getBool("/tools/bounding_box", 0);
+ // We'll only need to obtain the visual bounding box if the user preferences tell
+ // us to, AND if we are snapping to the bounding box itself. If we're snapping to
+ // paths only, then we can just as well use the geometric bounding box (which is faster)
+ SPItem::BBoxType bbox_type = (!prefs_bbox && _snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_BBOX_CATEGORY)) ?
+ SPItem::VISUAL_BBOX : SPItem::GEOMETRIC_BBOX;
+ if (clip_or_mask) {
+ // Oh oh, this will get ugly. We cannot use sp_item_i2d_affine directly because we need to
+ // insert an additional transformation in document coordinates (code copied from sp_item_i2d_affine)
+ bbox_of_item = item->bounds(bbox_type, item->i2doc_affine() * additional_affine * dt->doc2dt());
+ } else {
+ bbox_of_item = item->desktopBounds(bbox_type);
+ }
+ if (bbox_of_item) {
+ // See if the item is within range
+ if (bbox_to_snap_incl.intersects(*bbox_of_item)
+ || (_snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_ROTATION_CENTER) && bbox_to_snap_incl.contains(item->getCenter()))) { // rotation center might be outside of the bounding box
+ // This item is within snapping range, so record it as a candidate
+ _candidates->push_back(SnapCandidateItem(item, clip_or_mask, additional_affine));
+ // For debugging: print the id of the candidate to the console
+ // SPObject *obj = (SPObject*)item;
+ // std::cout << "Snap candidate added: " << obj->getId() << std::endl;
+ }
}
}
}
@@ -195,7 +194,7 @@ void Inkscape::ObjectSnapper::_collectNodes(SnapSourceType const &t,
//Geom::Affine i2doc(Geom::identity());
SPItem *root_item = (*i).item;
if (SP_IS_USE((*i).item)) {
- root_item = sp_use_root(SP_USE((*i).item));
+ root_item = SP_USE((*i).item)->root();
}
g_return_if_fail(root_item);
@@ -383,8 +382,8 @@ void Inkscape::ObjectSnapper::_collectPaths(Geom::Point /*p*/,
SPItem *root_item = NULL;
/* We might have a clone at hand, so make sure we get the root item */
if (SP_IS_USE((*i).item)) {
- i2doc = sp_use_get_root_transform(SP_USE((*i).item));
- root_item = sp_use_root(SP_USE((*i).item));
+ i2doc = SP_USE((*i).item)->get_root_transform();
+ root_item = SP_USE((*i).item)->root();
g_return_if_fail(root_item);
} else {
i2doc = (*i).item->i2doc_affine();
@@ -539,7 +538,7 @@ void Inkscape::ObjectSnapper::_snapPaths(IntermSnapResults &isr,
* - Linking the individual nodes of the SPPath we have here, to the nodes of the NodePath::SubPath class as being
* used in sp_nodepath_selected_nodes_move. This class has a member variable called "selected". For this the nodes
* should be in the exact same order for both classes, so we can index them
- * - Replacing the SPPath being used here by the the NodePath::SubPath class; but how?
+ * - Replacing the SPPath being used here by the NodePath::SubPath class; but how?
*/
}
@@ -771,7 +770,7 @@ void Inkscape::ObjectSnapper::_clear_paths() const
Geom::PathVector* Inkscape::ObjectSnapper::_getBorderPathv() const
{
- Geom::Rect const border_rect = Geom::Rect(Geom::Point(0,0), Geom::Point((_snapmanager->getDocument())->getWidth(),(_snapmanager->getDocument())->getHeight()));
+ Geom::Rect const border_rect = Geom::Rect(Geom::Point(0,0), Geom::Point((_snapmanager->getDocument())->getWidth().value("px"),(_snapmanager->getDocument())->getHeight().value("px")));
return _getPathvFromRect(border_rect);
}
@@ -788,8 +787,8 @@ Geom::PathVector* Inkscape::ObjectSnapper::_getPathvFromRect(Geom::Rect const re
void Inkscape::ObjectSnapper::_getBorderNodes(std::vector<SnapCandidatePoint> *points) const
{
- Geom::Coord w = (_snapmanager->getDocument())->getWidth();
- Geom::Coord h = (_snapmanager->getDocument())->getHeight();
+ Geom::Coord w = (_snapmanager->getDocument())->getWidth().value("px");
+ Geom::Coord h = (_snapmanager->getDocument())->getHeight().value("px");
points->push_back(SnapCandidatePoint(Geom::Point(0,0), SNAPSOURCE_UNDEFINED, SNAPTARGET_PAGE_CORNER));
points->push_back(SnapCandidatePoint(Geom::Point(0,h), SNAPSOURCE_UNDEFINED, SNAPTARGET_PAGE_CORNER));
points->push_back(SnapCandidatePoint(Geom::Point(w,h), SNAPSOURCE_UNDEFINED, SNAPTARGET_PAGE_CORNER));