summaryrefslogtreecommitdiffstats
path: root/src/snapped-line.cpp
diff options
context:
space:
mode:
authorDiederik van Lierop <mail@diedenrezi.nl>2007-11-09 09:48:27 +0000
committerdvlierop2 <dvlierop2@users.sourceforge.net>2007-11-09 09:48:27 +0000
commitf45e886fef31d000e419216ecb8732b772876455 (patch)
tree702d3fe9bb08797d3f43000fe84feb33cacfe4b9 /src/snapped-line.cpp
parentrefactoring, one MakeTweak method instead of a bunch largely similar methods (diff)
downloadinkscape-f45e886fef31d000e419216ecb8732b772876455.tar.gz
inkscape-f45e886fef31d000e419216ecb8732b772876455.zip
Renaming classes: SnappedLine -> SnappedLineSegment, and SnappedInfiniteLine -> SnappedLine
(bzr r4048)
Diffstat (limited to 'src/snapped-line.cpp')
-rw-r--r--src/snapped-line.cpp49
1 files changed, 21 insertions, 28 deletions
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()) {