diff --git a/src/object-snapper.cpp b/src/object-snapper.cpp
index 922c35bcbe545689f53e1de49a075dd009ea797f..35841891f69969d3e16d896edcae6a1f83dd5d96 100644 (file)
--- a/src/object-snapper.cpp
+++ b/src/object-snapper.cpp
if (it == NULL || i == it->end()) {
SPItem *item = SP_ITEM(o);
if (it == NULL || i == it->end()) {
SPItem *item = SP_ITEM(o);
- Geom::Matrix transform = Geom::identity();
if (item) {
SPObject *obj = NULL;
if (item) {
SPObject *obj = NULL;
- if (clip_or_mask) { // If the current item is a clipping path or a mask
- // then store the transformation of the clipped path or mask itself
- // but also take into account the additional affine of the object
- // being clipped / masked
- transform = to_2geom(item->transform) * additional_affine;
- } else { // cannot clip or mask more than once
+ 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->getObject());
if (obj) {
// 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->getObject());
if (obj) {
- _findCandidates(obj, it, false, bbox_to_snap, snap_dim, true, item->transform);
+ _findCandidates(obj, it, false, bbox_to_snap, snap_dim, true, sp_item_i2doc_affine(item));
}
obj = SP_OBJECT(item->mask_ref->getObject());
if (obj) {
}
obj = SP_OBJECT(item->mask_ref->getObject());
if (obj) {
- _findCandidates(obj, it, false, bbox_to_snap, snap_dim, true, item->transform);
+ _findCandidates(obj, it, false, bbox_to_snap, snap_dim, true, sp_item_i2doc_affine(item));
}
}
}
if (SP_IS_GROUP(o)) {
}
}
}
if (SP_IS_GROUP(o)) {
- _findCandidates(o, it, false, bbox_to_snap, snap_dim, false, Geom::identity());
+ _findCandidates(o, it, false, bbox_to_snap, snap_dim, clip_or_mask, additional_affine);
} else {
Geom::OptRect bbox_of_item = Geom::Rect();
if (clip_or_mask) {
} else {
Geom::OptRect bbox_of_item = Geom::Rect();
if (clip_or_mask) {
// insert an additional transformation in document coordinates (code copied from sp_item_i2d_affine)
sp_item_invoke_bbox(item,
bbox_of_item,
// insert an additional transformation in document coordinates (code copied from sp_item_i2d_affine)
sp_item_invoke_bbox(item,
bbox_of_item,
- sp_item_i2doc_affine(item) * matrix_to_desktop(additional_affine, item),
+ sp_item_i2doc_affine(item) * additional_affine * _snapmanager->getDesktop()->doc2dt(),
true);
} else {
sp_item_invoke_bbox(item, bbox_of_item, sp_item_i2d_affine(item), true);
true);
} else {
sp_item_invoke_bbox(item, bbox_of_item, sp_item_i2d_affine(item), true);
@@ -244,11 +238,7 @@ void Inkscape::ObjectSnapper::_collectNodes(Inkscape::SnapPreferences::PointType
// of the item AND the bbox of the clipping path at the same time
if (!(*i).clip_or_mask) {
Geom::OptRect b = sp_item_bbox_desktop(root_item, bbox_type);
// of the item AND the bbox of the clipping path at the same time
if (!(*i).clip_or_mask) {
Geom::OptRect b = sp_item_bbox_desktop(root_item, bbox_type);
- if (b) {
- for ( unsigned k = 0 ; k < 4 ; k++ ) {
- _points_to_snap_to->push_back(b->corner(k));
- }
- }
+ getBBoxPoints(b, _points_to_snap_to, _snapmanager->snapprefs.getSnapMidpoints());
}
}
}
}
}
}
if (!being_edited || (c1 && c2)) {
Geom::Coord const dist = Geom::distance(sp_doc, p_doc);
if (dist < getSnapperTolerance()) {
if (!being_edited || (c1 && c2)) {
Geom::Coord const dist = Geom::distance(sp_doc, p_doc);
if (dist < getSnapperTolerance()) {
- sc.curves.push_back(Inkscape::SnappedCurve(from_2geom(sp_dt), dist, getSnapperTolerance(), getSnapperAlwaysSnap(), false, curve));
+ sc.curves.push_back(Inkscape::SnappedCurve(sp_dt, dist, getSnapperTolerance(), getSnapperAlwaysSnap(), false, curve));
}
}
}
}
}
}
@@ -742,6 +732,20 @@ void Inkscape::ObjectSnapper::_getBorderNodes(std::vector<Geom::Point> *points)
points->push_back(Geom::Point(w,0));
}
points->push_back(Geom::Point(w,0));
}
+void Inkscape::getBBoxPoints(Geom::OptRect const bbox, std::vector<Geom::Point> *points, bool const includeMidpoints)
+{
+ if (bbox) {
+ // collect the corners of the bounding box
+ for ( unsigned k = 0 ; k < 4 ; k++ ) {
+ points->push_back(bbox->corner(k));
+ // optionally, collect the midpoints of the bounding box's edges too
+ if (includeMidpoints) {
+ points->push_back((bbox->corner(k) + bbox->corner((k+1) % 4))/2);
+ }
+ }
+ }
+}
+
/*
Local Variables:
mode:c++
/*
Local Variables:
mode:c++