From: dvlierop2 Date: Sat, 31 Mar 2007 12:01:58 +0000 (+0000) Subject: bug #1524444 (partially solved): while uniformly scaling (with ctrl-key), the correct... X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=edb2e759ea9d4ae7a56b539be4508bd48970bd82;p=inkscape.git bug #1524444 (partially solved): while uniformly scaling (with ctrl-key), the correct scaling must be applied BEFORE trying to snap --- diff --git a/src/geom.cpp b/src/geom.cpp index bc161bf9f..e59b0f302 100644 --- a/src/geom.cpp +++ b/src/geom.cpp @@ -18,7 +18,8 @@ * * This function finds the intersection of the two lines (infinite) * defined by n0.X = d0 and x1.X = d1. The algorithm is as follows: - * To compute the intersection point use kramer's rule: + * To compute the intersection point use Cramer's rule: + * (see http://en.wikipedia.org/wiki/Cramer%27s_rule) * \verbatim * convert lines to form * ax + by = c diff --git a/src/seltrans.cpp b/src/seltrans.cpp index 5ace790ec..f62e18ac2 100644 --- a/src/seltrans.cpp +++ b/src/seltrans.cpp @@ -864,10 +864,17 @@ gboolean Inkscape::SelTrans::scaleRequest(NR::Point &pt, guint state) } if ((state & GDK_CONTROL_MASK) || _desktop->isToolboxButtonActive ("lock")) { - /* Scale is locked to a 1:1 aspect ratio, so that s[X] must be made to equal s[Y]. - ** To do this, we snap along a suitable constraint vector from the origin. - */ - + // Scale is locked to a 1:1 aspect ratio, so that s[X] must be made to equal s[Y]. + // + // The aspect-ratio must be locked before snapping + if (fabs(s[NR::X]) > fabs(s[NR::Y])) { + s[NR::X] = fabs(s[NR::Y]) * sign(s[NR::X]); + } else { + s[NR::Y] = fabs(s[NR::X]) * sign(s[NR::Y]); + } + + // Snap along a suitable constraint vector from the origin. + // The inclination of the constraint vector is calculated from the aspect ratio NR::Point bbox_dim = _box->dimensions(); double const aspect_ratio = bbox_dim[1] / bbox_dim[0]; // = height / width @@ -893,16 +900,8 @@ gboolean Inkscape::SelTrans::scaleRequest(NR::Point &pt, guint state) _origin_for_snappoints); if (bb.second == false && sn.second == false) { - - /* We didn't snap, so just lock aspect ratio */ - if (fabs(s[NR::X]) > fabs(s[NR::Y])) { - s[NR::X] = fabs(s[NR::Y]) * sign(s[NR::X]); - } else { - s[NR::Y] = fabs(s[NR::X]) * sign(s[NR::Y]); - } - + /* We didn't snap, so just keep the locked aspect ratio */ } else { - /* Choose the smaller difference in scale. Since s[X] == s[Y] we can ** just compare difference in s[X]. */ @@ -993,6 +992,7 @@ gboolean Inkscape::SelTrans::stretchRequest(SPSelTransHandle const &handle, NR:: SnapManager const &m = _desktop->namedview->snap_manager; if ( state & GDK_CONTROL_MASK ) { + // on ctrl, apply symmetrical scaling instead of stretching s[perp] = fabs(s[axis]); std::pair const bb = m.freeSnapStretch(