summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 01db00e)
raw | patch | inline | side by side (parent: 01db00e)
author | Diederik van Lierop <mailat-signdiedenrezidotnl> | |
Sat, 17 Jul 2010 20:13:52 +0000 (22:13 +0200) | ||
committer | Diederik van Lierop <mailat-signdiedenrezidotnl> | |
Sat, 17 Jul 2010 20:13:52 +0000 (22:13 +0200) |
index d17689b063050dc5f471bcd3ebed4e75aae66eab..37469fa737bdede42dd9c7a3b564ef53892ce5ea 100644 (file)
@@ -794,10 +794,9 @@ void CanvasAxonomGridSnapper::_addSnappedLine(SnappedConstraints &sc, Geom::Poin
sc.grid_lines.push_back(dummy);
}
-void CanvasAxonomGridSnapper::_addSnappedPoint(SnappedConstraints &sc, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap, Geom::Coord angle) const
+void CanvasAxonomGridSnapper::_addSnappedPoint(SnappedConstraints &sc, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const
{
SnappedPoint dummy = SnappedPoint(snapped_point, source, source_num, Inkscape::SNAPTARGET_GRID, snapped_distance, getSnapperTolerance(), getSnapperAlwaysSnap(), constrained_snap, true);
- dummy.setTransformation(Geom::Point(angle, angle)); // Store the rotation (in radians), needed in case of snapping while rotating
sc.points.push_back(dummy);
}
index 4a9820792b8bc1e72bb07d4793f75d900014c382..58185e2e6a4bbf940666689c12e049172d18b551 100644 (file)
private:
LineList _getSnapLines(Geom::Point const &p) const;
void _addSnappedLine(SnappedConstraints &sc, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, Geom::Point const normal_to_line, const Geom::Point point_on_line) const;
- void _addSnappedPoint(SnappedConstraints &sc, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap, Geom::Coord angle) const;
+ void _addSnappedPoint(SnappedConstraints &sc, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const;
CanvasAxonomGrid *grid;
};
index fe1e9282458ba34644583b70282e62dc8b1f403a..a79a6b610c1bc947b0ede5f7bf2c6d4007d86dec 100644 (file)
@@ -1030,10 +1030,9 @@ void CanvasXYGridSnapper::_addSnappedLine(SnappedConstraints &sc, Geom::Point co
sc.grid_lines.push_back(dummy);
}
-void CanvasXYGridSnapper::_addSnappedPoint(SnappedConstraints &sc, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap, Geom::Coord angle) const
+void CanvasXYGridSnapper::_addSnappedPoint(SnappedConstraints &sc, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const
{
SnappedPoint dummy = SnappedPoint(snapped_point, source, source_num, Inkscape::SNAPTARGET_GRID, snapped_distance, getSnapperTolerance(), getSnapperAlwaysSnap(), constrained_snap, true);
- dummy.setTransformation(Geom::Point(angle, angle)); // Store the rotation (in radians), needed in case of snapping while rotating
sc.points.push_back(dummy);
}
index 0aedb02a03b85d9c08fd1fffef24e39551c9a899..a11d77d1dc86d9eb5372c10e6dc50ddfad6c7426 100644 (file)
private:
LineList _getSnapLines(Geom::Point const &p) const;
void _addSnappedLine(SnappedConstraints &sc, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, Geom::Point const normal_to_line, const Geom::Point point_on_line) const;
- void _addSnappedPoint(SnappedConstraints &sc, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap, Geom::Coord angle) const;
+ void _addSnappedPoint(SnappedConstraints &sc, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const;
CanvasXYGrid *grid;
};
diff --git a/src/guide-snapper.cpp b/src/guide-snapper.cpp
index aad4502ca280806c108b4595fb6e470c45d9e7ff..4f70521e0904a5fd9a4f9e3ee823be462d17266b 100644 (file)
--- a/src/guide-snapper.cpp
+++ b/src/guide-snapper.cpp
}
-void Inkscape::GuideSnapper::_addSnappedPoint(SnappedConstraints &sc, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap, Geom::Coord angle) const
+void Inkscape::GuideSnapper::_addSnappedPoint(SnappedConstraints &sc, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const
{
SnappedPoint dummy = SnappedPoint(snapped_point, source, source_num, Inkscape::SNAPTARGET_GUIDE, snapped_distance, getSnapperTolerance(), getSnapperAlwaysSnap(), constrained_snap, true);
- dummy.setTransformation(Geom::Point(angle, angle)); // Store the rotation (in radians), needed in case of snapping while rotating
sc.points.push_back(dummy);
}
diff --git a/src/guide-snapper.h b/src/guide-snapper.h
index 4e5e5d1d14949436badec82fc15fa81876b991ba..5de1b56a4ae20474a183a8c17de683cf2bec2b35 100644 (file)
--- a/src/guide-snapper.h
+++ b/src/guide-snapper.h
LineList _getSnapLines(Geom::Point const &p) const;
void _addSnappedLine(SnappedConstraints &sc, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, Geom::Point const normal_to_line, Geom::Point const point_on_line) const;
void _addSnappedLinesOrigin(SnappedConstraints &sc, Geom::Point const origin, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const;
- void _addSnappedPoint(SnappedConstraints &sc, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap, Geom::Coord angle) const;
+ void _addSnappedPoint(SnappedConstraints &sc, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const;
};
}
diff --git a/src/line-snapper.cpp b/src/line-snapper.cpp
index 5ceece66bc4d6832e6737f70ab0f5f239ff39b5b..19e6c0fe67b56108957c937ccee6b24bb4179783 100644 (file)
--- a/src/line-snapper.cpp
+++ b/src/line-snapper.cpp
// First, project the origin of the circle onto the line
Geom::Point const origin = c.getPoint();
Geom::Point const p_proj = Geom::projection(origin, gridguide_line);
- Geom::Point v_orig = c.getDirection(); // vector from the origin to the original (untransformed) point
- Geom::Point v_proj = p_proj - origin;
- Geom::Coord dist = Geom::L2(v_proj); // distance from circle origin to constraint line
+ Geom::Coord dist = Geom::L2(p_proj - origin); // distance from circle origin to constraint line
Geom::Coord radius = c.getRadius();
- Geom::Coord radians = NR_HUGE;
if (dist == radius) {
// Only one point of intersection;
- // Calculate the rotation in radians...
- radians = atan2(Geom::dot(Geom::rot90(v_orig), v_proj), Geom::dot(v_orig, v_proj));
- _addSnappedPoint(sc, p_proj, Geom::L2(p.getPoint() - p_proj), p.getSourceType(), p.getSourceNum(), true, radians);
+ _addSnappedPoint(sc, p_proj, Geom::L2(p.getPoint() - p_proj), p.getSourceType(), p.getSourceNum(), true);
} else if (dist < radius) {
// Two points of intersection, symmetrical with respect to the projected point
// Calculate half the length of the linesegment between the two points of intersection
Geom::Coord d = Geom::L2(gridguide_line.versor()); // length of versor, needed to normalize the versor
if (d > 0) {
Geom::Point v = l*gridguide_line.versor()/d;
- v_proj = p_proj + v - origin;
- radians = atan2(Geom::dot(Geom::rot90(v_orig), v_proj), Geom::dot(v_orig, v_proj));
- _addSnappedPoint(sc, p_proj + v, Geom::L2(p.getPoint() - (p_proj + v)), p.getSourceType(), p.getSourceNum(), true, radians);
- v_proj = p_proj - v - origin;
- radians = atan2(Geom::dot(Geom::rot90(v_orig), v_proj), Geom::dot(v_orig, v_proj));
- _addSnappedPoint(sc, p_proj - v, Geom::L2(p.getPoint() - (p_proj - v)), p.getSourceType(), p.getSourceNum(), true, radians);
+ _addSnappedPoint(sc, p_proj + v, Geom::L2(p.getPoint() - (p_proj + v)), p.getSourceType(), p.getSourceNum(), true);
+ _addSnappedPoint(sc, p_proj - v, Geom::L2(p.getPoint() - (p_proj - v)), p.getSourceType(), p.getSourceNum(), true);
}
}
} else {
// This snappoint is therefore fully constrained, so there's no need
// to look for additional intersections; just return the snapped point
// and forget about the line
- _addSnappedPoint(sc, t, dist, p.getSourceType(), p.getSourceNum(), true, 1);
+ _addSnappedPoint(sc, t, dist, p.getSourceType(), p.getSourceNum(), true);
}
}
}
diff --git a/src/line-snapper.h b/src/line-snapper.h
index 403c8cbba77154b8760c01b206a9ea90450f20d7..4f3d17998f9fe371612506b1e8c2aed6020dfb60 100644 (file)
--- a/src/line-snapper.h
+++ b/src/line-snapper.h
// Will only be implemented for guide lines, because grid lines don't have an origin
virtual void _addSnappedLinesOrigin(SnappedConstraints &sc, Geom::Point const origin, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const;
- virtual void _addSnappedPoint(SnappedConstraints &sc, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap, Geom::Coord angle) const = 0;
+ virtual void _addSnappedPoint(SnappedConstraints &sc, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const = 0;
};
}
diff --git a/src/object-snapper.cpp b/src/object-snapper.cpp
index f96335c4a63df72e7ba6f8fdcc262375a84766bf..22d5f35aa8f122f8aeb0fac28c9ccbc5450bfecf 100644 (file)
--- a/src/object-snapper.cpp
+++ b/src/object-snapper.cpp
Geom::Coord dist = Geom::L2(p_proj_on_cl - p_inters);
SnappedPoint s = SnappedPoint(p_inters, p.getSourceType(), p.getSourceNum(), k->target_type, dist, getSnapperTolerance(), getSnapperAlwaysSnap(), true, k->target_bbox);;
if (dist <= tolerance) { // If the intersection is within snapping range, then we might snap to it
- if (c.isCircular()) {
- Geom::Point v_orig = c.getDirection(); // vector from the origin to the original (untransformed) point
- Geom::Point v_inters = p_inters - c.getPoint();
- Geom::Coord radians = atan2(Geom::dot(Geom::rot90(v_orig), v_inters), Geom::dot(v_orig, v_inters));
- s.setTransformation(Geom::Point(radians, radians));
- }
sc.points.push_back(s);
}
}
diff --git a/src/snap.cpp b/src/snap.cpp
index 265b7c19af8d17e135bd7fe991f7c5973a8608f7..1127ccba186408b174304400dde4a576b32c1ebe 100644 (file)
--- a/src/snap.cpp
+++ b/src/snap.cpp
@@ -366,12 +366,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
/* 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);