summaryrefslogtreecommitdiffstats
path: root/src/line-snapper.cpp
diff options
context:
space:
mode:
authorAndrew Higginson <at.higginson@gmail.com>2011-12-27 21:04:47 +0000
committerAndrew <at.higginson@gmail.com>2011-12-27 21:04:47 +0000
commit80960b623a99aae1402ab651b2974ef544ed3b03 (patch)
treeba49d42c2789e9e11f805e2d5263e10f9fedeef8 /src/line-snapper.cpp
parenttry to fix bug (diff)
parentGDL: Cherry-pick upstream patch 73852 (2011-03-23) - Add missing return value. (diff)
downloadinkscape-80960b623a99aae1402ab651b2974ef544ed3b03.tar.gz
inkscape-80960b623a99aae1402ab651b2974ef544ed3b03.zip
merged with trunk so I can build again...
(bzr r10092.1.36)
Diffstat (limited to 'src/line-snapper.cpp')
-rw-r--r--src/line-snapper.cpp31
1 files changed, 15 insertions, 16 deletions
diff --git a/src/line-snapper.cpp b/src/line-snapper.cpp
index 22a964d43..3fb503354 100644
--- a/src/line-snapper.cpp
+++ b/src/line-snapper.cpp
@@ -1,6 +1,5 @@
-/**
- * \file line-snapper.cpp
- * \brief LineSnapper class.
+/*
+ * LineSnapper class.
*
* Authors:
* Diederik van Lierop <mail@diedenrezi.nl>
@@ -21,20 +20,20 @@ Inkscape::LineSnapper::LineSnapper(SnapManager *sm, Geom::Coord const d) : Snapp
{
}
-void Inkscape::LineSnapper::freeSnap(SnappedConstraints &sc,
+void Inkscape::LineSnapper::freeSnap(IntermSnapResults &isr,
Inkscape::SnapCandidatePoint const &p,
Geom::OptRect const &/*bbox_to_snap*/,
std::vector<SPItem const *> const */*it*/,
std::vector<Inkscape::SnapCandidatePoint> */*unselected_nodes*/) const
{
- if (!(_snap_enabled && _snapmanager->snapprefs.getSnapFrom(p.getSourceType())) ) {
+ if (!(_snap_enabled && _snapmanager->snapprefs.isSourceSnappable(p.getSourceType())) ) {
return;
}
/* Get the lines that we will try to snap to */
const LineList lines = _getSnapLines(p.getPoint());
- for (LineList::const_iterator i = lines.begin(); i != lines.end(); i++) {
+ for (LineList::const_iterator i = lines.begin(); i != lines.end(); ++i) {
Geom::Point const p1 = i->second; // point at guide/grid line
Geom::Point const p2 = p1 + Geom::rot90(i->first); // 2nd point at guide/grid line
// std::cout << " line through " << i->second << " with normal " << i->first;
@@ -44,13 +43,13 @@ void Inkscape::LineSnapper::freeSnap(SnappedConstraints &sc,
Geom::Coord const dist = Geom::L2(p_proj - p.getPoint());
//Store any line that's within snapping range
if (dist < getSnapperTolerance()) {
- _addSnappedLine(sc, p_proj, dist, p.getSourceType(), p.getSourceNum(), i->first, i->second);
+ _addSnappedLine(isr, p_proj, dist, p.getSourceType(), p.getSourceNum(), i->first, i->second);
// For any line that's within range, we will also look at it's "point on line" p1. For guides
// this point coincides with its origin; for grids this is of no use, but we cannot
// discern between grids and guides here
Geom::Coord const dist_p1 = Geom::L2(p1 - p.getPoint());
if (dist_p1 < getSnapperTolerance()) {
- _addSnappedLinesOrigin(sc, p1, dist_p1, p.getSourceType(), p.getSourceNum(), false);
+ _addSnappedLinesOrigin(isr, p1, dist_p1, p.getSourceType(), p.getSourceNum(), false);
// Only relevant for guides; grids don't have an origin per line
// Therefore _addSnappedLinesOrigin() will only be implemented for guides
}
@@ -60,7 +59,7 @@ void Inkscape::LineSnapper::freeSnap(SnappedConstraints &sc,
}
}
-void Inkscape::LineSnapper::constrainedSnap(SnappedConstraints &sc,
+void Inkscape::LineSnapper::constrainedSnap(IntermSnapResults &isr,
Inkscape::SnapCandidatePoint const &p,
Geom::OptRect const &/*bbox_to_snap*/,
SnapConstraint const &c,
@@ -68,7 +67,7 @@ void Inkscape::LineSnapper::constrainedSnap(SnappedConstraints &sc,
std::vector<SnapCandidatePoint> */*unselected_nodes*/) const
{
- if (_snap_enabled == false || _snapmanager->snapprefs.getSnapFrom(p.getSourceType()) == false) {
+ if (_snap_enabled == false || _snapmanager->snapprefs.isSourceSnappable(p.getSourceType()) == false) {
return;
}
@@ -78,7 +77,7 @@ void Inkscape::LineSnapper::constrainedSnap(SnappedConstraints &sc,
/* Get the lines that we will try to snap to */
const LineList lines = _getSnapLines(pp);
- for (LineList::const_iterator i = lines.begin(); i != lines.end(); i++) {
+ for (LineList::const_iterator i = lines.begin(); i != lines.end(); ++i) {
Geom::Point const point_on_line = c.hasPoint() ? c.getPoint() : pp;
Geom::Line gridguide_line(i->second, i->second + Geom::rot90(i->first));
@@ -91,7 +90,7 @@ void Inkscape::LineSnapper::constrainedSnap(SnappedConstraints &sc,
Geom::Coord radius = c.getRadius();
if (dist == radius) {
// Only one point of intersection;
- _addSnappedPoint(sc, p_proj, Geom::L2(pp - p_proj), p.getSourceType(), p.getSourceNum(), true);
+ _addSnappedPoint(isr, p_proj, Geom::L2(pp - 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
@@ -99,8 +98,8 @@ void Inkscape::LineSnapper::constrainedSnap(SnappedConstraints &sc,
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;
- _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);
+ _addSnappedPoint(isr, p_proj + v, Geom::L2(p.getPoint() - (p_proj + v)), p.getSourceType(), p.getSourceNum(), true);
+ _addSnappedPoint(isr, p_proj - v, Geom::L2(p.getPoint() - (p_proj - v)), p.getSourceType(), p.getSourceNum(), true);
}
}
} else {
@@ -125,7 +124,7 @@ void Inkscape::LineSnapper::constrainedSnap(SnappedConstraints &sc,
// 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);
+ _addSnappedPoint(isr, t, dist, p.getSourceType(), p.getSourceNum(), true);
}
}
}
@@ -134,7 +133,7 @@ void Inkscape::LineSnapper::constrainedSnap(SnappedConstraints &sc,
// Will only be overridden in the guide-snapper class, because grid lines don't have an origin; the
// grid-snapper classes will use this default empty method
-void Inkscape::LineSnapper::_addSnappedLinesOrigin(SnappedConstraints &/*sc*/, Geom::Point const /*origin*/, Geom::Coord const /*snapped_distance*/, SnapSourceType const &/*source_type*/, long /*source_num*/, bool /*constrained_snap*/) const
+void Inkscape::LineSnapper::_addSnappedLinesOrigin(IntermSnapResults &/*isr*/, Geom::Point const /*origin*/, Geom::Coord const /*snapped_distance*/, SnapSourceType const &/*source_type*/, long /*source_num*/, bool /*constrained_snap*/) const
{
}