summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e3d8c95)
raw | patch | inline | side by side (parent: e3d8c95)
author | dvlierop2 <dvlierop2@users.sourceforge.net> | |
Fri, 9 Nov 2007 09:48:27 +0000 (09:48 +0000) | ||
committer | dvlierop2 <dvlierop2@users.sourceforge.net> | |
Fri, 9 Nov 2007 09:48:27 +0000 (09:48 +0000) |
index 32e08828f80e5168c095d8d2087f186ffd54ad56..cb83900bbd8838fd813dd72774b2100df0f03bc9 100644 (file)
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);
}
index 5f68f58bd5d965f8fa7f30036cc29c7bf58ce178..b4568d2e45110ad6ad4d26d9116549bfe6b8d11f 100644 (file)
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 473198af34d3fbfe9ebfb21e6fc3d31fc4e5d895..a1df5f1cd339aa906888050d793cbbb4e2483c0a 100644 (file)
--- a/src/guide-snapper.cpp
+++ b/src/guide-snapper.cpp
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 f8efbed4952b1729739c461052a20b5c675d31ea..f0ca38e3a9d144c9e1052d31cfd30c48217de755 100644 (file)
--- a/src/line-snapper.cpp
+++ b/src/line-snapper.cpp
//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 d5ec91f863819e14ad0e20e1786d9e432ff49ccb..4e4e048445f7b318871d26c877b6571fd70f3421 100644 (file)
--- 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 9c7697dc83d87dc72d204c7d843ba3ef4631004a..663da2e8af6745320d78213871dfdcd7ad745edc 100644 (file)
--- a/src/snapped-line.cpp
+++ b/src/snapped-line.cpp
/**
* \file src/snapped-line.cpp
- * \brief SnappedInfiniteLine class.
+ * \brief SnappedLine class.
*
* Authors:
* Diederik van Lierop <mail@diedenrezi.nl>
#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;
_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);
}
-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);
-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;
_at_intersection = false;
}
-Inkscape::SnappedInfiniteLine::SnappedInfiniteLine()
+Inkscape::SnappedLine::SnappedLine()
{
_normal_to_line = NR::Point(0,0);
_point_on_line = NR::Point(0,0);
_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);
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 92f16d905041b299962cc32410bc16e41f142313..3fed89d7de56f27573ec7fd7686188291a21d939 100644 (file)
--- a/src/snapped-line.h
+++ b/src/snapped-line.h
/**
* \file src/snapped-line.h
- * \brief SnappedInfiniteLine class.
+ * \brief SnappedLine class.
*
* Authors:
* Diederik van Lierop <mail@diedenrezi.nl>
{
/// 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;
};
-/// 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)
}
-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 64150be187de3f5cc34fd106d78ecf06d7d26c8c..c5c111cffe3ee914b99639f2002b39147cde2bcd 100644 (file)
--- a/src/snapper.h
+++ b/src/snapper.h
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;