summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/display/canvas-axonomgrid.cpp2
-rw-r--r--src/display/canvas-grid.cpp2
-rw-r--r--src/guide-snapper.cpp2
-rw-r--r--src/line-snapper.cpp2
-rw-r--r--src/snap.cpp14
-rw-r--r--src/snapped-line.cpp49
-rw-r--r--src/snapped-line.h30
-rw-r--r--src/snapper.h6
8 files changed, 50 insertions, 57 deletions
diff --git a/src/display/canvas-axonomgrid.cpp b/src/display/canvas-axonomgrid.cpp
index 32e08828f..cb83900bb 100644
--- a/src/display/canvas-axonomgrid.cpp
+++ b/src/display/canvas-axonomgrid.cpp
@@ -652,7 +652,7 @@ CanvasAxonomGridSnapper::_getSnapLines(NR::Point const &p) const
void CanvasAxonomGridSnapper::_addSnappedLine(SnappedConstraints &sc, NR::Point const snapped_point, NR::Coord const snapped_distance, NR::Point const normal_to_line, NR::Point const point_on_line) const
{
- SnappedInfiniteLine dummy = SnappedInfiniteLine(snapped_point, snapped_distance, normal_to_line, point_on_line);
+ SnappedLine dummy = SnappedLine(snapped_point, snapped_distance, normal_to_line, point_on_line);
sc.grid_lines.push_back(dummy);
}
diff --git a/src/display/canvas-grid.cpp b/src/display/canvas-grid.cpp
index 5f68f58bd..b4568d2e4 100644
--- a/src/display/canvas-grid.cpp
+++ b/src/display/canvas-grid.cpp
@@ -852,7 +852,7 @@ CanvasXYGridSnapper::_getSnapLines(NR::Point const &p) const
void CanvasXYGridSnapper::_addSnappedLine(SnappedConstraints &sc, NR::Point const snapped_point, NR::Coord const snapped_distance, NR::Point const normal_to_line, NR::Point const point_on_line) const
{
- SnappedInfiniteLine dummy = SnappedInfiniteLine(snapped_point, snapped_distance, normal_to_line, point_on_line);
+ SnappedLine dummy = SnappedLine(snapped_point, snapped_distance, normal_to_line, point_on_line);
sc.grid_lines.push_back(dummy);
}
diff --git a/src/guide-snapper.cpp b/src/guide-snapper.cpp
index 473198af3..a1df5f1cd 100644
--- a/src/guide-snapper.cpp
+++ b/src/guide-snapper.cpp
@@ -54,7 +54,7 @@ bool Inkscape::GuideSnapper::ThisSnapperMightSnap() const
void Inkscape::GuideSnapper::_addSnappedLine(SnappedConstraints &sc, NR::Point const snapped_point, NR::Coord const snapped_distance, NR::Point const normal_to_line, NR::Point const point_on_line) const
{
- SnappedInfiniteLine dummy = SnappedInfiniteLine(snapped_point, snapped_distance, normal_to_line, point_on_line);
+ SnappedLine dummy = SnappedLine(snapped_point, snapped_distance, normal_to_line, point_on_line);
sc.guide_lines.push_back(dummy);
}
diff --git a/src/line-snapper.cpp b/src/line-snapper.cpp
index f8efbed49..f0ca38e3a 100644
--- a/src/line-snapper.cpp
+++ b/src/line-snapper.cpp
@@ -56,7 +56,7 @@ void Inkscape::LineSnapper::_doConstrainedSnap(SnappedConstraints &sc,
//Store any line that's within snapping range
if (dist < getDistance()) {
_addSnappedLine(sc, t, dist, c.getDirection(), t);
- //SnappedInfiniteLine dummy = SnappedInfiniteLine(t, dist, c.getDirection(), t);
+ //SnappedLine dummy = SnappedLine(t, dist, c.getDirection(), t);
//sc.infinite_lines.push_back(dummy);
}
}
diff --git a/src/snap.cpp b/src/snap.cpp
index d5ec91f86..4e4e04844 100644
--- a/src/snap.cpp
+++ b/src/snap.cpp
@@ -686,32 +686,32 @@ Inkscape::SnappedPoint SnapManager::findBestSnap(NR::Point const &p, SnappedCons
}
// search for the closest snapped grid line
- Inkscape::SnappedInfiniteLine closestGridLine;
- if (getClosestSIL(sc.grid_lines, closestGridLine)) {
+ Inkscape::SnappedLine closestGridLine;
+ if (getClosestSL(sc.grid_lines, closestGridLine)) {
sp_list.push_back(std::make_pair(Inkscape::SnappedPoint(closestGridLine), NR_HUGE));
}
// search for the closest snapped guide line
- Inkscape::SnappedInfiniteLine closestGuideLine;
- if (getClosestSIL(sc.guide_lines, closestGuideLine)) {
+ Inkscape::SnappedLine closestGuideLine;
+ if (getClosestSL(sc.guide_lines, closestGuideLine)) {
sp_list.push_back(std::make_pair(Inkscape::SnappedPoint(closestGuideLine), NR_HUGE));
}
// search for the closest snapped intersection of grid lines
Inkscape::SnappedPoint closestGridPoint;
- if (getClosestIntersectionSIL(sc.grid_lines, closestGridPoint)) {
+ if (getClosestIntersectionSL(sc.grid_lines, closestGridPoint)) {
sp_list.push_back(std::make_pair(closestGridPoint, NR_HUGE));
}
// search for the closest snapped intersection of guide lines
Inkscape::SnappedPoint closestGuidePoint;
- if (getClosestIntersectionSIL(sc.guide_lines, closestGuidePoint)) {
+ if (getClosestIntersectionSL(sc.guide_lines, closestGuidePoint)) {
sp_list.push_back(std::make_pair(closestGuidePoint, NR_HUGE));
}
// search for the closest snapped intersection of grid with guide lines
Inkscape::SnappedPoint closestGridGuidePoint;
- if (getClosestIntersectionSIL(sc.grid_lines, sc.guide_lines, closestGridGuidePoint)) {
+ if (getClosestIntersectionSL(sc.grid_lines, sc.guide_lines, closestGridGuidePoint)) {
sp_list.push_back(std::make_pair(closestGridGuidePoint, std::min(guide_sens, grid_sens)));
}
diff --git a/src/snapped-line.cpp b/src/snapped-line.cpp
index 9c7697dc8..663da2e8a 100644
--- a/src/snapped-line.cpp
+++ b/src/snapped-line.cpp
@@ -1,6 +1,6 @@
/**
* \file src/snapped-line.cpp
- * \brief SnappedInfiniteLine class.
+ * \brief SnappedLine class.
*
* Authors:
* Diederik van Lierop <mail@diedenrezi.nl>
@@ -12,7 +12,7 @@
#include "geom.h"
#include "libnr/nr-values.h"
-Inkscape::SnappedLine::SnappedLine(NR::Point snapped_point, NR::Coord snapped_distance, NR::Point start_point_of_line, NR::Point end_point_of_line)
+Inkscape::SnappedLineSegment::SnappedLineSegment(NR::Point snapped_point, NR::Coord snapped_distance, NR::Point start_point_of_line, NR::Point end_point_of_line)
: _start_point_of_line(start_point_of_line), _end_point_of_line(end_point_of_line)
{
_distance = snapped_distance;
@@ -20,7 +20,7 @@ Inkscape::SnappedLine::SnappedLine(NR::Point snapped_point, NR::Coord snapped_di
_at_intersection = false;
}
-Inkscape::SnappedLine::SnappedLine()
+Inkscape::SnappedLineSegment::SnappedLineSegment()
{
_start_point_of_line = NR::Point(0,0);
_end_point_of_line = NR::Point(0,0);
@@ -30,11 +30,11 @@ Inkscape::SnappedLine::SnappedLine()
}
-Inkscape::SnappedLine::~SnappedLine()
+Inkscape::SnappedLineSegment::~SnappedLineSegment()
{
}
-Inkscape::SnappedPoint Inkscape::SnappedLine::intersect(SnappedLine const &line) const
+Inkscape::SnappedPoint Inkscape::SnappedLineSegment::intersect(SnappedLineSegment const &line) const
{
//TODO: Diederik, implement the intersection
NR::Point const intersection = NR::Point(NR_HUGE, NR_HUGE);
@@ -55,7 +55,7 @@ Inkscape::SnappedPoint Inkscape::SnappedLine::intersect(SnappedLine const &line)
-Inkscape::SnappedInfiniteLine::SnappedInfiniteLine(NR::Point snapped_point, NR::Coord snapped_distance, NR::Point normal_to_line, NR::Point point_on_line)
+Inkscape::SnappedLine::SnappedLine(NR::Point snapped_point, NR::Coord snapped_distance, NR::Point normal_to_line, NR::Point point_on_line)
: _normal_to_line(normal_to_line), _point_on_line(point_on_line)
{
_distance = snapped_distance;
@@ -63,7 +63,7 @@ Inkscape::SnappedInfiniteLine::SnappedInfiniteLine(NR::Point snapped_point, NR::
_at_intersection = false;
}
-Inkscape::SnappedInfiniteLine::SnappedInfiniteLine()
+Inkscape::SnappedLine::SnappedLine()
{
_normal_to_line = NR::Point(0,0);
_point_on_line = NR::Point(0,0);
@@ -72,13 +72,13 @@ Inkscape::SnappedInfiniteLine::SnappedInfiniteLine()
_at_intersection = false;
}
-Inkscape::SnappedInfiniteLine::~SnappedInfiniteLine()
+Inkscape::SnappedLine::~SnappedLine()
{
}
-Inkscape::SnappedPoint Inkscape::SnappedInfiniteLine::intersect(SnappedInfiniteLine const &line) const
+Inkscape::SnappedPoint Inkscape::SnappedLine::intersect(SnappedLine const &line) const
{
- // Calculate the intersection of to infinite lines, which are both within snapping range
+ // Calculate the intersection of to lines, which are both within snapping range
// The point of intersection should be considered for snapping, but might be outside the snapping range
NR::Point intersection = NR::Point(NR_HUGE, NR_HUGE);
@@ -87,11 +87,6 @@ Inkscape::SnappedPoint Inkscape::SnappedInfiniteLine::intersect(SnappedInfiniteL
IntersectorKind result = intersector_line_intersection(getNormal(), getConstTerm(),
line.getNormal(), line.getConstTerm(), intersection);
- /*std::cout << "n0 = " << getNormal() << std::endl;
- std::cout << "n1 = " << line.getNormal() << std::endl;
- std::cout << "c0 = " << getConstTerm() << std::endl;
- std::cout << "c1 = " << line.getConstTerm() << std::endl;*/
-
if (result == INTERSECTS) {
/* The relevant snapped distance is the distance to the closest snapped line, not the
distance to the intersection. For example, when a box is almost aligned with a grid
@@ -105,17 +100,15 @@ Inkscape::SnappedPoint Inkscape::SnappedInfiniteLine::intersect(SnappedInfiniteL
//std::cout << "Intersected nicely, now getSIL distance = " << distance << std::endl;
}
- //std::cout << "getSIL distance = " << distance << std::endl;
-
return SnappedPoint(intersection, distance, result == INTERSECTS);
}
-// search for the closest snapped infinite line
-bool getClosestSIL(std::list<Inkscape::SnappedInfiniteLine> &list, Inkscape::SnappedInfiniteLine &result)
+// search for the closest snapped line
+bool getClosestSL(std::list<Inkscape::SnappedLine> &list, Inkscape::SnappedLine &result)
{
bool success = false;
- for (std::list<Inkscape::SnappedInfiniteLine>::const_iterator i = list.begin(); i != list.end(); i++) {
+ for (std::list<Inkscape::SnappedLine>::const_iterator i = list.begin(); i != list.end(); i++) {
if ((i == list.begin()) || (*i).getDistance() < result.getDistance()) {
result = *i;
success = true;
@@ -125,13 +118,13 @@ bool getClosestSIL(std::list<Inkscape::SnappedInfiniteLine> &list, Inkscape::Sna
return success;
}
-// search for the closest intersection of two snapped infinite lines, which are both member of the same collection
-bool getClosestIntersectionSIL(std::list<Inkscape::SnappedInfiniteLine> &list, Inkscape::SnappedPoint &result)
+// search for the closest intersection of two snapped lines, which are both member of the same collection
+bool getClosestIntersectionSL(std::list<Inkscape::SnappedLine> &list, Inkscape::SnappedPoint &result)
{
bool success = false;
- for (std::list<Inkscape::SnappedInfiniteLine>::const_iterator i = list.begin(); i != list.end(); i++) {
- std::list<Inkscape::SnappedInfiniteLine>::const_iterator j = i;
+ for (std::list<Inkscape::SnappedLine>::const_iterator i = list.begin(); i != list.end(); i++) {
+ std::list<Inkscape::SnappedLine>::const_iterator j = i;
j++;
for (; j != list.end(); j++) {
Inkscape::SnappedPoint sp = (*i).intersect(*j);
@@ -148,13 +141,13 @@ bool getClosestIntersectionSIL(std::list<Inkscape::SnappedInfiniteLine> &list, I
return success;
}
-// search for the closest intersection of two snapped infinite lines, which are in two different collections
-bool getClosestIntersectionSIL(std::list<Inkscape::SnappedInfiniteLine> &list1, std::list<Inkscape::SnappedInfiniteLine> &list2, Inkscape::SnappedPoint &result)
+// search for the closest intersection of two snapped lines, which are in two different collections
+bool getClosestIntersectionSL(std::list<Inkscape::SnappedLine> &list1, std::list<Inkscape::SnappedLine> &list2, Inkscape::SnappedPoint &result)
{
bool success = false;
- for (std::list<Inkscape::SnappedInfiniteLine>::const_iterator i = list1.begin(); i != list1.end(); i++) {
- for (std::list<Inkscape::SnappedInfiniteLine>::const_iterator j = list2.begin(); j != list2.end(); j++) {
+ for (std::list<Inkscape::SnappedLine>::const_iterator i = list1.begin(); i != list1.end(); i++) {
+ for (std::list<Inkscape::SnappedLine>::const_iterator j = list2.begin(); j != list2.end(); j++) {
Inkscape::SnappedPoint sp = (*i).intersect(*j);
if (sp.getAtIntersection()) {
if (!success || sp.getDistance() < result.getDistance()) {
diff --git a/src/snapped-line.h b/src/snapped-line.h
index 92f16d905..3fed89d7d 100644
--- a/src/snapped-line.h
+++ b/src/snapped-line.h
@@ -3,7 +3,7 @@
/**
* \file src/snapped-line.h
- * \brief SnappedInfiniteLine class.
+ * \brief SnappedLine class.
*
* Authors:
* Diederik van Lierop <mail@diedenrezi.nl>
@@ -22,13 +22,13 @@ namespace Inkscape
{
/// Class describing the result of an attempt to snap to a line segment.
-class SnappedLine : public SnappedPoint
+class SnappedLineSegment : public SnappedPoint
{
public:
- SnappedLine();
- SnappedLine(NR::Point snapped_point, NR::Coord snapped_distance, NR::Point start_point_of_line, NR::Point end_point_of_line);
- ~SnappedLine();
- Inkscape::SnappedPoint intersect(SnappedLine const &line) const; //intersect with another SnappedLine
+ SnappedLineSegment();
+ SnappedLineSegment(NR::Point snapped_point, NR::Coord snapped_distance, NR::Point start_point_of_line, NR::Point end_point_of_line);
+ ~SnappedLineSegment();
+ Inkscape::SnappedPoint intersect(SnappedLineSegment const &line) const; //intersect with another SnappedLineSegment
private:
NR::Point _start_point_of_line;
@@ -36,14 +36,14 @@ private:
};
-/// Class describing the result of an attempt to snap to an infinite line.
-class SnappedInfiniteLine : public SnappedPoint
+/// Class describing the result of an attempt to snap to a line.
+class SnappedLine : public SnappedPoint
{
public:
- SnappedInfiniteLine();
- SnappedInfiniteLine(NR::Point snapped_point, NR::Coord snapped_distance, NR::Point normal_to_line, NR::Point point_on_line);
- ~SnappedInfiniteLine();
- Inkscape::SnappedPoint intersect(SnappedInfiniteLine const &line) const; //intersect with another SnappedInfiniteLine
+ SnappedLine();
+ SnappedLine(NR::Point snapped_point, NR::Coord snapped_distance, NR::Point normal_to_line, NR::Point point_on_line);
+ ~SnappedLine();
+ Inkscape::SnappedPoint intersect(SnappedLine const &line) const; //intersect with another SnappedLine
// This line is described by this equation:
// a*x + b*y = c <-> nx*px + ny+py = c <-> n.p = c
NR::Point getNormal() const {return _normal_to_line;} // n = (nx, ny)
@@ -57,9 +57,9 @@ private:
}
-bool getClosestSIL(std::list<Inkscape::SnappedInfiniteLine> &list, Inkscape::SnappedInfiniteLine &result);
-bool getClosestIntersectionSIL(std::list<Inkscape::SnappedInfiniteLine> &list, Inkscape::SnappedPoint &result);
-bool getClosestIntersectionSIL(std::list<Inkscape::SnappedInfiniteLine> &list1, std::list<Inkscape::SnappedInfiniteLine> &list2, Inkscape::SnappedPoint &result);
+bool getClosestSL(std::list<Inkscape::SnappedLine> &list, Inkscape::SnappedLine &result);
+bool getClosestIntersectionSL(std::list<Inkscape::SnappedLine> &list, Inkscape::SnappedPoint &result);
+bool getClosestIntersectionSL(std::list<Inkscape::SnappedLine> &list1, std::list<Inkscape::SnappedLine> &list2, Inkscape::SnappedPoint &result);
#endif /* !SEEN_SNAPPEDLINE_H */
diff --git a/src/snapper.h b/src/snapper.h
index 64150be18..c5c111cff 100644
--- a/src/snapper.h
+++ b/src/snapper.h
@@ -21,9 +21,9 @@
struct SnappedConstraints {
std::list<Inkscape::SnappedPoint> points;
- std::list<Inkscape::SnappedLine> lines;
- std::list<Inkscape::SnappedInfiniteLine> grid_lines;
- std::list<Inkscape::SnappedInfiniteLine> guide_lines;
+ std::list<Inkscape::SnappedLineSegment> lines;
+ std::list<Inkscape::SnappedLine> grid_lines;
+ std::list<Inkscape::SnappedLine> guide_lines;
};
struct SPNamedView;