diff --git a/src/snap.cpp b/src/snap.cpp
index 265b7c19af8d17e135bd7fe991f7c5973a8608f7..ccbd449bd4c461a5757a3323975f28b764d6baa2 100644 (file)
--- a/src/snap.cpp
+++ b/src/snap.cpp
Inkscape::SnapSourceType const source_type,
Geom::OptRect const &bbox_to_snap) const
{
- //TODO: SnapCandidatePoint and point_type are somewhat redundant; can't we get rid of the point_type parameter?
Inkscape::SnappedPoint const s = freeSnap(Inkscape::SnapCandidatePoint(p, source_type), bbox_to_snap);
s.getPoint(p);
}
@@ -366,12 +365,6 @@ Inkscape::SnappedPoint SnapManager::constrainedSnap(Inkscape::SnapCandidatePoint
Geom::Point pp = constraint.projection(p.getPoint());
Inkscape::SnappedPoint no_snap = Inkscape::SnappedPoint(pp, p.getSourceType(), p.getSourceNum(), Inkscape::SNAPTARGET_CONSTRAINT, NR_HUGE, 0, false, true, false);
- if (constraint.isCircular()) {
- Geom::Point v_orig = constraint.getDirection(); // vector from the origin to the original (untransformed) point
- Geom::Point v_proj = pp - constraint.getPoint(); // vector from the origin to the projected point
- Geom::Coord angle = atan2(Geom::dot(Geom::rot90(v_orig), v_proj), Geom::dot(v_orig, v_proj));
- no_snap.setTransformation(Geom::Point(angle, angle)); // Store the rotation (in radians), needed in case of snapping while rotating
- }
if (!someSnapperMightSnap()) {
// Always return point on constraint
@@ -414,7 +407,7 @@ void SnapManager::guideFreeSnap(Geom::Point &p, Geom::Point const &guide_normal,
return;
}
- if (!(object.GuidesMightSnap() || snapprefs.getSnapToGuides())) {
+ if (!(object.ThisSnapperMightSnap() || snapprefs.getSnapToGuides())) {
return;
}
@@ -425,7 +418,7 @@ void SnapManager::guideFreeSnap(Geom::Point &p, Geom::Point const &guide_normal,
// Snap to nodes
SnappedConstraints sc;
- if (object.GuidesMightSnap()) {
+ if (object.ThisSnapperMightSnap()) {
object.guideFreeSnap(sc, p, guide_normal);
}
@@ -436,8 +429,7 @@ void SnapManager::guideFreeSnap(Geom::Point &p, Geom::Point const &guide_normal,
(*i)->freeSnap(sc, candidate, Geom::OptRect(), NULL, NULL);
}
- // Snap to intersections of curves, but not to the curves themselves! (see _snapTranslatingGuideToNodes in object-snapper.cpp)
- Inkscape::SnappedPoint const s = findBestSnap(candidate, sc, false, true);
+ Inkscape::SnappedPoint const s = findBestSnap(candidate, sc, false, false);
s.getPoint(p);
}
/* We snapped. Find the transformation that describes where the snapped point has
** ended up, and also the metric for this transformation.
*/
- Geom::Point const a = (snapped_point.getPoint() - origin); // vector to snapped point
+ Geom::Point const a = snapped_point.getPoint() - origin; // vector to snapped point
//Geom::Point const b = (*i - origin); // vector to original point
switch (transformation_type) {
snapped_point.setSecondSnapDistance(NR_HUGE);
break;
case SKEW:
- result[0] = (snapped_point.getPoint()[dim] - ((*i).getPoint())[dim]) / (((*i).getPoint())[1 - dim] - origin[1 - dim]); // skew factor
+ result[0] = (snapped_point.getPoint()[dim] - ((*i).getPoint())[dim]) / b[1 - dim]; // skew factor
result[1] = transformation[1]; // scale factor
// Store the metric for this transformation as a virtual distance
snapped_point.setSnapDistance(std::abs(result[0] - transformation[0]));
snapped_point.setSecondSnapDistance(NR_HUGE);
break;
case ROTATE:
- result = snapped_point.getTransformation();
+ // a is vector to snapped point; b is vector to original point; now lets calculate angle between a and b
+ result[0] = atan2(Geom::dot(Geom::rot90(b), a), Geom::dot(b, a));
+ result[1] = result[1]; // how else should we store an angle in a point ;-)
// Store the metric for this transformation as a virtual distance (we're storing an angle)
snapped_point.setSnapDistance(std::abs(result[0] - transformation[0]));
snapped_point.setSecondSnapDistance(NR_HUGE);