From: dvlierop2 Date: Tue, 20 May 2008 20:58:56 +0000 (+0000) Subject: Fix snapping for constrained translation in the selector tool X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=b07935a463203d40998fab67c59d7a34bb86e99d;p=inkscape.git Fix snapping for constrained translation in the selector tool --- diff --git a/src/seltrans.cpp b/src/seltrans.cpp index bdb0f794a..2c021a724 100644 --- a/src/seltrans.cpp +++ b/src/seltrans.cpp @@ -1386,6 +1386,11 @@ void Inkscape::SelTrans::moveTo(NR::Point const &xy, guint state) /* Snap to things, and also constrain to horizontal or vertical movement */ for (unsigned int dim = 0; dim < 2; dim++) { + // When doing a constrained translation, all points will move in the same direction, i.e. + // either horizontally or vertically. Therefore we only have to specify the direction of + // the constraint-line once. The constraint lines are parallel, but might not be colinear. + // Therefore we will have to set the point through which the constraint-line runs + // individually for each point to be snapped; this will be handled however by _snapTransformed() s.push_back(m.constrainedSnapTranslation(Inkscape::Snapper::SNAPPOINT_BBOX, _bbox_points, Inkscape::Snapper::ConstraintLine(component_vectors[dim]), @@ -1418,13 +1423,10 @@ void Inkscape::SelTrans::moveTo(NR::Point const &xy, guint state) g_assert(best_snapped_point.getDistance() == NR_HUGE); for (std::list::const_iterator i = s.begin(); i != s.end(); i++) { if (i->getSnapped()) { - // std::cout << "moveTo() -> snapped to point: " << i->getPoint() << " with transformation: " << i->getTransformation(); if (i->getDistance() < best_snapped_point.getDistance()) { best_snapped_point = *i; dxy = i->getTransformation(); - // std::cout << " SEL"; } - //std::cout << std::endl; } } if (best_snapped_point.getSnapped()) { diff --git a/src/snap.cpp b/src/snap.cpp index 46d043ec1..09cdbbaba 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -432,7 +432,13 @@ Inkscape::SnappedPoint SnapManager::_snapTransformed( dedicated_constraint = Inkscape::Snapper::ConstraintLine(origin, (*i) - origin); } else if (transformation_type == STRETCH) { // when non-uniform stretching { dedicated_constraint = Inkscape::Snapper::ConstraintLine((*i), component_vectors[dim]); - } // else: leave the original constraint, e.g. for constrained translation and skewing + } else if (transformation_type == TRANSLATION) { + // When doing a constrained translation, all points will move in the same direction, i.e. + // either horizontally or vertically. The lines along which they move are therefore all + // parallel, but might not be colinear. Therefore we will have to set the point through + // which the constraint-line runs here, for each point individually. + dedicated_constraint.setPoint(*i); + } // else: leave the original constraint, e.g. for skewing if (transformation_type == SCALE && !uniform) { g_warning("Non-uniform constrained scaling is not supported!"); } diff --git a/src/snapper.h b/src/snapper.h index 1fb03d704..f79573990 100644 --- a/src/snapper.h +++ b/src/snapper.h @@ -88,6 +88,11 @@ public: NR::Point getDirection() const { return _direction; } + + void setPoint(NR::Point const &p) { + _point = p; + _has_point = true; + } private: