Code

Connector tool: make connectors avoid the convex hull of shapes.
[inkscape.git] / src / snapper.h
index 0110a9154a92d399d2f8c689e96c594373ed49c3..110b3d36ad5292fa721e1db7e55b76af01c5ce19 100644 (file)
@@ -51,8 +51,11 @@ public:
     */
     virtual bool ThisSnapperMightSnap() const {return _snap_enabled;} // will likely be overridden by derived classes
 
-    void setEnabled(bool s); // This is only used for grids, for which snapping can be enabled individually
+    // These four methods are only used for grids, for which snapping can be enabled individually
+    void setEnabled(bool s);
+       void setSnapVisibleOnly(bool s);
     bool getEnabled() const {return _snap_enabled;}
+    bool getSnapVisibleOnly() const {return _snap_visible_only;}
 
     virtual void freeSnap(SnappedConstraints &/*sc*/,
                           SnapPreferences::PointType const &/*t*/,
@@ -86,6 +89,12 @@ public:
             _has_point = true;
         }
 
+        Geom::Point projection(Geom::Point const &p) const { // returns the projection of p on this constraintline
+               Geom::Point const p1_on_cl = _has_point ? _point : p;
+                       Geom::Point const p2_on_cl = p1_on_cl + _direction;
+               return Geom::projection(p, Geom::Line(p1_on_cl, p2_on_cl));
+        }
+
     private:
 
         bool _has_point;
@@ -105,8 +114,9 @@ public:
 protected:
        SnapManager *_snapmanager;
 
+       // This is only used for grids, for which snapping can be enabled individually
        bool _snap_enabled; ///< true if this snapper is enabled, otherwise false
-                                               // This is only used for grids, for which snapping can be enabled individually
+       bool _snap_visible_only;
 };
 
 }