summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 222f93a)
raw | patch | inline | side by side (parent: 222f93a)
author | dvlierop2 <dvlierop2@users.sourceforge.net> | |
Thu, 28 Jun 2007 19:34:45 +0000 (19:34 +0000) | ||
committer | dvlierop2 <dvlierop2@users.sourceforge.net> | |
Thu, 28 Jun 2007 19:34:45 +0000 (19:34 +0000) |
src/object-edit.cpp | patch | blob | history |
diff --git a/src/object-edit.cpp b/src/object-edit.cpp
index 14539417b8f01b9bb3662fa1c66c00b321c184ef..ea0be7ef5a2283c0a023d8ee1d2db731f1750bd9 100644 (file)
--- a/src/object-edit.cpp
+++ b/src/object-edit.cpp
static NR::Point snap_knot_position(SPItem *item, NR::Point const &p)
{
SPDesktop const *desktop = inkscape_active_desktop();
- NR::Point s = sp_desktop_dt2root_xy_point(desktop, p);
+ NR::Matrix const i2d (sp_item_i2d_affine (item));
+ NR::Point s = p * i2d;
SnapManager const &m = desktop->namedview->snap_manager;
s = m.freeSnap(Inkscape::Snapper::BBOX_POINT | Inkscape::Snapper::SNAP_POINT, s, item).getPoint();
- return sp_desktop_root2dt_xy_point(desktop, s);
+ return s * i2d.inverse();
}
static NR::Point sp_rect_rx_get(SPItem *item)
@@ -233,15 +234,17 @@ static void sp_rect_rx_set(SPItem *item, NR::Point const &p, NR::Point const &or
{
SPRect *rect = SP_RECT(item);
- NR::Point const s = snap_knot_position(rect, p);
+ //In general we cannot just snap this radius to an arbitrary point, as we have only a single
+ //degree of freedom. For snapping to an arbitrary point we need two DOF. If we're going to snap
+ //the radius then we should have a constrained snap. snap_knot_position() is unconstrained
if (state & GDK_CONTROL_MASK) {
gdouble temp = MIN(rect->height.computed, rect->width.computed) / 2.0;
- rect->rx.computed = rect->ry.computed = CLAMP(rect->x.computed + rect->width.computed - s[NR::X], 0.0, temp);
+ rect->rx.computed = rect->ry.computed = CLAMP(rect->x.computed + rect->width.computed - p[NR::X], 0.0, temp);
rect->rx._set = rect->ry._set = true;
} else {
- rect->rx.computed = CLAMP(rect->x.computed + rect->width.computed - s[NR::X], 0.0, rect->width.computed / 2.0);
+ rect->rx.computed = CLAMP(rect->x.computed + rect->width.computed - p[NR::X], 0.0, rect->width.computed / 2.0);
rect->rx._set = true;
}
@@ -260,19 +263,21 @@ static void sp_rect_ry_set(SPItem *item, NR::Point const &p, NR::Point const &or
{
SPRect *rect = SP_RECT(item);
- NR::Point const s = snap_knot_position(rect, p);
+ //In general we cannot just snap this radius to an arbitrary point, as we have only a single
+ //degree of freedom. For snapping to an arbitrary point we need two DOF. If we're going to snap
+ //the radius then we should have a constrained snap. snap_knot_position() is unconstrained
if (state & GDK_CONTROL_MASK) {
gdouble temp = MIN(rect->height.computed, rect->width.computed) / 2.0;
- rect->rx.computed = rect->ry.computed = CLAMP(s[NR::Y] - rect->y.computed, 0.0, temp);
+ rect->rx.computed = rect->ry.computed = CLAMP(p[NR::Y] - rect->y.computed, 0.0, temp);
rect->ry._set = rect->rx._set = true;
} else {
if (!rect->rx._set || rect->rx.computed == 0) {
- rect->ry.computed = CLAMP(s[NR::Y] - rect->y.computed,
+ rect->ry.computed = CLAMP(p[NR::Y] - rect->y.computed,
0.0,
MIN(rect->height.computed / 2.0, rect->width.computed / 2.0));
} else {
- rect->ry.computed = CLAMP(s[NR::Y] - rect->y.computed,
+ rect->ry.computed = CLAMP(p[NR::Y] - rect->y.computed,
0.0,
rect->height.computed / 2.0);
}