Code

NR::Maybe => boost::optional
[inkscape.git] / src / snap.h
index f11b7c743ad45193d5bcdf0efd5cc36f1495b2f0..966d2a5431127968a7de6089d16ed1d3bdf79024 100644 (file)
@@ -50,19 +50,33 @@ public:
     void setup(SPDesktop const *desktop_for_snapindicator = NULL, SPItem const *item_to_ignore = NULL, std::vector<NR::Point> *unselected_nodes = NULL);
     void setup(SPDesktop const *desktop_for_snapindicator, std::vector<SPItem const *> &items_to_ignore, std::vector<NR::Point> *unselected_nodes = NULL);
 
+    // freeSnapReturnByRef() is preferred over freeSnap(), because it only returns a 
+    // point if snapping has occured (by overwriting p); otherwise p is untouched    
+    void freeSnapReturnByRef(Inkscape::Snapper::PointType point_type,
+                      NR::Point &p,
+                      bool first_point = true,
+                      boost::optional<NR::Rect> const &bbox_to_snap = boost::optional<NR::Rect>()) const;
+    
     Inkscape::SnappedPoint freeSnap(Inkscape::Snapper::PointType point_type,
                                     NR::Point const &p,
                                     bool first_point = true,
-                                    NR::Maybe<NR::Rect> const &bbox_to_snap = NR::Nothing()) const;
-
+                                    boost::optional<NR::Rect> const &bbox_to_snap = boost::optional<NR::Rect>() ) const;
+    
+    // constrainedSnapReturnByRef() is preferred over constrainedSnap(), because it only returns a 
+    // point, by overwriting p, if snapping has occured; otherwise p is untouched
+    void constrainedSnapReturnByRef(Inkscape::Snapper::PointType point_type,
+                             NR::Point &p,
+                             Inkscape::Snapper::ConstraintLine const &constraint,
+                             bool first_point = true,
+                             boost::optional<NR::Rect> const &bbox_to_snap = boost::optional<NR::Rect>()) const;
+    
     Inkscape::SnappedPoint constrainedSnap(Inkscape::Snapper::PointType point_type,
                                            NR::Point const &p,
                                            Inkscape::Snapper::ConstraintLine const &constraint,
                                            bool first_point = true,
-                                           NR::Maybe<NR::Rect> const &bbox_to_snap = NR::Nothing()) const;
+                                           boost::optional<NR::Rect> const &bbox_to_snap = boost::optional<NR::Rect>()) const;
                                            
-    Inkscape::SnappedPoint guideSnap(NR::Point const &p,
-                                     NR::Point const &guide_normal) const;
+    void guideSnap(NR::Point &p, NR::Point const &guide_normal) const;
 
     Inkscape::SnappedPoint freeSnapTranslation(Inkscape::Snapper::PointType point_type,
                                                std::vector<NR::Point> const &p,
@@ -84,22 +98,19 @@ public:
                                                 NR::Point const &o) const;
 
     Inkscape::SnappedPoint constrainedSnapStretch(Inkscape::Snapper::PointType point_type,
-                                                   std::vector<NR::Point> const &p,
-                                                   NR::Coord const &s,
-                                                   NR::Point const &o,
-                                                   NR::Dim2 d,
-                                                   bool uniform) const;
-
-    Inkscape::SnappedPoint freeSnapSkew(Inkscape::Snapper::PointType point_type,
-                                        std::vector<NR::Point> const &p,
-                                        NR::Coord const &s,
-                                        NR::Point const &o,
-                                        NR::Dim2 d) const;
-                                            
-       //Inkscape::SnappedPoint guideSnap(NR::Point const &p,
-    //                       Inkscape::ObjectSnapper::DimensionToSnap const snap_dim) const;
-  
+                                                  std::vector<NR::Point> const &p,
+                                                  NR::Coord const &s,
+                                                  NR::Point const &o,
+                                                  NR::Dim2 d,
+                                                  bool uniform) const;
 
+    Inkscape::SnappedPoint constrainedSnapSkew(Inkscape::Snapper::PointType point_type,
+                                               std::vector<NR::Point> const &p,
+                                               Inkscape::Snapper::ConstraintLine const &constraint,
+                                               NR::Point const &s, // s[0] = skew factor, s[1] = scale factor
+                                               NR::Point const &o,
+                                               NR::Dim2 d) const;
+                                        
     Inkscape::GuideSnapper guide;      ///< guide snapper
     Inkscape::ObjectSnapper object;    ///< snapper to other objects