Code

Merge and cleanup of GSoC C++-ification project.
[inkscape.git] / src / snapped-line.h
index 3fed89d7de56f27573ec7fd7686188291a21d939..b95e7a7dff3d9f5884718b31fbe5e92ec8f11ce8 100644 (file)
@@ -13,9 +13,6 @@
 
 #include <vector>
 #include <list>
-#include "libnr/nr-coord.h"
-#include "libnr/nr-point.h"
-#include <libnr/nr-point-fns.h>
 #include "snapped-point.h"
 
 namespace Inkscape
@@ -26,13 +23,14 @@ class SnappedLineSegment : public SnappedPoint
 {
 public:
     SnappedLineSegment();
-    SnappedLineSegment(NR::Point snapped_point, NR::Coord snapped_distance, NR::Point start_point_of_line, NR::Point end_point_of_line);
+    SnappedLineSegment(Geom::Point const &snapped_point, Geom::Coord const &snapped_distance, SnapSourceType const &source, long source_num, SnapTargetType const &target, Geom::Coord const &snapped_tolerance,bool const &always_snap, Geom::Point const &start_point_of_line, Geom::Point const &end_point_of_line);
     ~SnappedLineSegment();
     Inkscape::SnappedPoint intersect(SnappedLineSegment const &line) const; //intersect with another SnappedLineSegment
-    
+    Geom::LineSegment getLineSegment() const {return Geom::LineSegment(_start_point_of_line, _end_point_of_line);}
+
 private:
-    NR::Point _start_point_of_line;
-    NR::Point _end_point_of_line;    
+    Geom::Point _start_point_of_line;
+    Geom::Point _end_point_of_line;
 };
 
 
@@ -41,26 +39,29 @@ class SnappedLine : public SnappedPoint
 {
 public:
     SnappedLine();
-    SnappedLine(NR::Point snapped_point, NR::Coord snapped_distance, NR::Point normal_to_line, NR::Point point_on_line);
+    SnappedLine(Geom::Point const &snapped_point, Geom::Coord const &snapped_distance, SnapSourceType const &source, long source_num, SnapTargetType const &target, Geom::Coord const &snapped_tolerance, bool const &always_snap, Geom::Point const &normal_to_line, Geom::Point const &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)
-    NR::Point getPointOnLine() const {return _point_on_line;}                        // p = (px, py)
-    NR::Coord getConstTerm() const {return dot(_normal_to_line, _point_on_line);}     // c = n.p = nx*px + ny*py;
-    
+    Geom::Point getNormal() const {return _normal_to_line;}                             // n = (nx, ny)
+    Geom::Point getPointOnLine() const {return _point_on_line;}                         // p = (px, py)
+    Geom::Coord getConstTerm() const {return dot(_normal_to_line, _point_on_line);}     // c = n.p = nx*px + ny*py;
+    Geom::Line getLine() const {return Geom::Line(_point_on_line, _point_on_line + Geom::rot90(_normal_to_line));}
+
 private:
-    NR::Point _normal_to_line;
-    NR::Point _point_on_line;    
+    Geom::Point _normal_to_line;
+    Geom::Point _point_on_line;
 };
 
 }
 
-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);
+bool getClosestSLS(std::list<Inkscape::SnappedLineSegment> const &list, Inkscape::SnappedLineSegment &result);
+bool getClosestIntersectionSLS(std::list<Inkscape::SnappedLineSegment> const &list, Inkscape::SnappedPoint &result);
+bool getClosestSL(std::list<Inkscape::SnappedLine> const &list, Inkscape::SnappedLine &result);
+bool getClosestIntersectionSL(std::list<Inkscape::SnappedLine> const &list, Inkscape::SnappedPoint &result);
+bool getClosestIntersectionSL(std::list<Inkscape::SnappedLine> const &list1, std::list<Inkscape::SnappedLine> const &list2, Inkscape::SnappedPoint &result);
+
 
 #endif /* !SEEN_SNAPPEDLINE_H */