summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2006-05-05 15:07:33 +0000
committercth103 <cth103@users.sourceforge.net>2006-05-05 15:07:33 +0000
commit899143e7e4c7447f089eb436e0f4250864ad276e (patch)
treeb985139268ff5ff8dccd1cad6ed85a701bc086e2 /src
parentadded sections for lt, ko, zh_TW, resolution for patch #1399508 (copy README.*) (diff)
downloadinkscape-899143e7e4c7447f089eb436e0f4250864ad276e.tar.gz
inkscape-899143e7e4c7447f089eb436e0f4250864ad276e.zip
Remove some old snap code.
(bzr r738)
Diffstat (limited to 'src')
-rw-r--r--src/seltrans.cpp32
-rw-r--r--src/snap.cpp51
-rw-r--r--src/snap.h6
3 files changed, 26 insertions, 63 deletions
diff --git a/src/seltrans.cpp b/src/seltrans.cpp
index 2d4201fac..70dd0d1a0 100644
--- a/src/seltrans.cpp
+++ b/src/seltrans.cpp
@@ -889,6 +889,8 @@ gboolean Inkscape::SelTrans::stretchRequest(SPSelTransHandle const &handle, NR::
it.push_back(reinterpret_cast<SPItem*>(i->data));
}
+ SnapManager const &m = _desktop->namedview->snap_manager;
+
if ( state & GDK_CONTROL_MASK ) {
s[perp] = fabs(s[axis]);
@@ -906,17 +908,27 @@ gboolean Inkscape::SelTrans::stretchRequest(SPSelTransHandle const &handle, NR::
s[axis] = fabs(ratio) * sign(s[axis]);
s[perp] = fabs(s[axis]);
} else {
- std::pair<NR::Coord, bool> bb = namedview_dim_snap_list_scale(_desktop->namedview, Snapper::BBOX_POINT,
- _bbox_points, _origin,
- s[axis], axis, it);
- std::pair<NR::Coord, bool> sn = namedview_dim_snap_list_scale(_desktop->namedview, Snapper::SNAP_POINT,
- _snap_points, _origin,
- s[axis], axis, it);
- /* Pick the snap that puts us closest to the original scale */
- NR::Coord bd = bb.second ? fabs(bb.first - s[axis]) : NR_HUGE;
- NR::Coord sd = sn.second ? fabs(sn.first - s[axis]) : NR_HUGE;
- s[axis] = (bd < sd) ? bb.first : sn.first;
+ std::pair<NR::scale, bool> const bb = m.constrainedSnapScale(
+ Snapper::BBOX_POINT,
+ _bbox_points,
+ it,
+ Inkscape::Snapper::ConstraintLine(component_vectors[axis]),
+ s,
+ _origin);
+
+ std::pair<NR::scale, bool> const sn = m.constrainedSnapScale(
+ Snapper::SNAP_POINT,
+ _snap_points,
+ it,
+ Inkscape::Snapper::ConstraintLine(component_vectors[axis]),
+ s,
+ _origin);
+
+ /* Choose the smaller difference in scale */
+ NR::Coord const bd = bb.second ? fabs(bb.first[axis] - s[axis]) : NR_HUGE;
+ NR::Coord const sd = sn.second ? fabs(sn.first[axis] - s[axis]) : NR_HUGE;
+ s = (bd < sd) ? bb.first : sn.first;
}
pt = ( _point - _origin ) * NR::scale(s) + _origin;
diff --git a/src/snap.cpp b/src/snap.cpp
index 7c68ae877..bf5385910 100644
--- a/src/snap.cpp
+++ b/src/snap.cpp
@@ -165,11 +165,15 @@ std::pair<NR::Point, bool> SnapManager::_snapTransformed(Inkscape::Snapper::Poin
metric = NR::L2(result);
break;
case SCALE:
+ {
NR::Point const a = (snapped.getPoint() - origin);
NR::Point const b = (*i - origin);
result = NR::Point(a[NR::X] / b[NR::X], a[NR::Y] / b[NR::Y]);
metric = std::abs(NR::L2(result) - NR::L2(transformation));
break;
+ }
+ default:
+ g_assert_not_reached();
}
/* Note it if it's the best so far */
@@ -336,53 +340,6 @@ std::pair<double, bool> namedview_vector_snap_list(SPNamedView const *nv, Inksca
/**
- * Try to snap points in \a p after they have been scaled by \a sx with respect to
- * the origin \a norm. The best snap is the one that changes the scale least.
- *
- * \return Pair containing snapped scale and a flag which is true if a snap was made.
- */
-std::pair<double, bool> namedview_dim_snap_list_scale(SPNamedView const *nv, Inkscape::Snapper::PointType t,
- const std::vector<NR::Point> &p, NR::Point const &norm,
- double const sx, NR::Dim2 dim,
- std::list<const SPItem *> const &it)
-{
- SnapManager const &m = nv->snap_manager;
- if (m.willSnapSomething() == false) {
- return std::make_pair(sx, false);
- }
-
- g_assert(dim < 2);
-
- NR::Coord dist = NR_HUGE;
- double scale = sx;
-
- for (std::vector<NR::Point>::const_iterator i = p.begin(); i != p.end(); i++) {
- NR::Point q = *i;
- NR::Point check = q;
-
- /* Scaled version of the point we are looking at */
- check[dim] = (sx * (q - norm) + norm)[dim];
-
- if (fabs (q[dim] - norm[dim]) > MIN_DIST_NORM) {
- /* Snap this point */
- const NR::Coord d = namedview_dim_snap (nv, t, check, dim, it);
- /* Work out the resulting scale factor */
- double snapped_scale = (check[dim] - norm[dim]) / (q[dim] - norm[dim]);
-
- if (dist == NR_HUGE || fabs(snapped_scale - sx) < fabs(scale - sx)) {
- /* This is either the first point, or the snapped scale
- ** is the closest yet to the original.
- */
- scale = snapped_scale;
- dist = d;
- }
- }
- }
-
- return std::make_pair(scale, dist < NR_HUGE);
-}
-
-/**
* Try to snap points after they have been skewed.
*/
double namedview_dim_snap_list_skew(SPNamedView const *nv, Inkscape::Snapper::PointType t,
diff --git a/src/snap.h b/src/snap.h
index a37878f9c..d7050d822 100644
--- a/src/snap.h
+++ b/src/snap.h
@@ -120,12 +120,6 @@ std::pair<double, bool> namedview_vector_snap_list(SPNamedView const *nv,
);
-std::pair<double, bool> namedview_dim_snap_list_scale(SPNamedView const *nv,
- Inkscape::Snapper::PointType t, const std::vector<NR::Point> &p,
- NR::Point const &norm, double const sx,
- NR::Dim2 const dim,
- std::list<SPItem const *> const &it);
-
NR::Coord namedview_dim_snap_list_skew(SPNamedView const *nv, Inkscape::Snapper::PointType t,
const std::vector<NR::Point> &p,
NR::Point const &norm, double const sx, NR::Dim2 const dim);