summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 5c4cc33)
raw | patch | inline | side by side (parent: 5c4cc33)
author | Diederik van Lierop <mailat-signdiedenrezidotnl> | |
Thu, 22 Apr 2010 20:42:03 +0000 (22:42 +0200) | ||
committer | Diederik van Lierop <mailat-signdiedenrezidotnl> | |
Thu, 22 Apr 2010 20:42:03 +0000 (22:42 +0200) |
src/display/curve.cpp | patch | blob | history | |
src/display/curve.h | patch | blob | history | |
src/object-snapper.cpp | patch | blob | history | |
src/sp-image.cpp | patch | blob | history |
diff --git a/src/display/curve.cpp b/src/display/curve.cpp
index 1b54c981c25c8277917bc8477283972d549e2485..73b8dc36dbf3a1c2fda0079aa573c5748b17513b 100644 (file)
--- a/src/display/curve.cpp
+++ b/src/display/curve.cpp
}
SPCurve *
-SPCurve::new_from_rect(Geom::Rect const &rect)
+SPCurve::new_from_rect(Geom::Rect const &rect, bool all_four_sides)
{
SPCurve *c = new SPCurve();
for (int i=3; i>=1; i--) {
c->lineto(rect.corner(i));
}
- c->closepath();
+
+ if (all_four_sides) {
+ // When _constrained_ snapping to a path, the 2geom::SimpleCrosser will be invoked which doesn't consider the closing segment.
+ // of a path. Consequently, in case we want to snap to for example the page border, we must provide all four sides of the
+ // rectangle explicitly
+ c->lineto(rect.corner(0));
+ } else {
+ // ... instead of just three plus a closing segment
+ c->closepath();
+ }
return c;
}
diff --git a/src/display/curve.h b/src/display/curve.h
index 79a385b09f2a9e5eee526e8e6a269b10077d90b8..fe072019522aff84a053137832ba6d381d10603f 100644 (file)
--- a/src/display/curve.h
+++ b/src/display/curve.h
/* Constructors */
explicit SPCurve();
explicit SPCurve(Geom::PathVector const& pathv);
- static SPCurve * new_from_rect(Geom::Rect const &rect);
+ static SPCurve * new_from_rect(Geom::Rect const &rect, bool all_four_sides = false);
virtual ~SPCurve();
diff --git a/src/object-snapper.cpp b/src/object-snapper.cpp
index a3285b4069e57c531291a8e812aaffe5e12dc2ba..77449ddc3d3092cadb4be15f06eed8180a53358e 100644 (file)
--- a/src/object-snapper.cpp
+++ b/src/object-snapper.cpp
Geom::PathVector* Inkscape::ObjectSnapper::_getPathvFromRect(Geom::Rect const rect) const
{
- SPCurve const *border_curve = SPCurve::new_from_rect(rect);
+ SPCurve const *border_curve = SPCurve::new_from_rect(rect, true);
if (border_curve) {
Geom::PathVector *dummy = new Geom::PathVector(border_curve->get_pathvector());
return dummy;
diff --git a/src/sp-image.cpp b/src/sp-image.cpp
index bb867e969aa205906e117efb6f09f73d1aee1917..68bafdeab9345e0c50c9e0bc43d99e4136740124 100644 (file)
--- a/src/sp-image.cpp
+++ b/src/sp-image.cpp
NRRect rect;
sp_image_bbox(image, &rect, Geom::identity(), 0);
Geom::Rect rect2 = to_2geom(*rect.upgrade());
- SPCurve *c = SPCurve::new_from_rect(rect2);
+ SPCurve *c = SPCurve::new_from_rect(rect2, true);
if (image->curve) {
image->curve = image->curve->unref();