Code

Node tool: special case node duplication for endnodes - select new endnode
[inkscape.git] / src / context-fns.cpp
index e6ebbe337c49669d28b1369c0ff3b338d90e0e12..81eb6fdb5b1467f0de1609bde5731c4a70e3575d 100644 (file)
@@ -9,7 +9,6 @@
 #include "message-stack.h"
 #include "context-fns.h"
 #include "snap.h"
-#include "desktop-affine.h"
 #include "event-context.h"
 #include "sp-namedview.h"
 #include "display/snap-indicator.h"
@@ -132,15 +131,15 @@ Geom::Rect Inkscape::snap_rectangular_box(SPDesktop const *desktop, SPItem *item
             Inkscape::SnappedPoint s[2];
 
             /* Try to snap p[0] (the opposite corner) along the constraint vector */
-            s[0] = m.constrainedSnap(Inkscape::Snapper::SNAPPOINT_NODE, to_2geom(p[0]),
-                                     Inkscape::Snapper::ConstraintLine(p[0] - p[1]));
+            s[0] = m.constrainedSnap(Inkscape::SnapCandidatePoint(p[0], Inkscape::SNAPSOURCE_NODE_HANDLE),
+                                     Inkscape::Snapper::SnapConstraint(p[0] - p[1]));
 
             /* Try to snap p[1] (the dragged corner) along the constraint vector */
-            s[1] = m.constrainedSnap(Inkscape::Snapper::SNAPPOINT_NODE, to_2geom(p[1]),
-                                     Inkscape::Snapper::ConstraintLine(p[1] - p[0]));
+            s[1] = m.constrainedSnap(Inkscape::SnapCandidatePoint(p[1], Inkscape::SNAPSOURCE_NODE_HANDLE),
+                                     Inkscape::Snapper::SnapConstraint(p[1] - p[0]));
 
             /* Choose the best snap and update points accordingly */
-            if (s[0].getDistance() < s[1].getDistance()) {
+            if (s[0].getSnapDistance() < s[1].getSnapDistance()) {
                 if (s[0].getSnapped()) {
                     p[0] = s[0].getPoint();
                     p[1] = 2 * center - s[0].getPoint();
@@ -157,8 +156,8 @@ Geom::Rect Inkscape::snap_rectangular_box(SPDesktop const *desktop, SPItem *item
 
             /* Our origin is the opposite corner.  Snap the drag point along the constraint vector */
             p[0] = center;
-            snappoint = m.constrainedSnap(Inkscape::Snapper::SNAPPOINT_NODE, to_2geom(p[1]),
-                                          Inkscape::Snapper::ConstraintLine(p[1] - p[0]));
+            snappoint = m.constrainedSnap(Inkscape::SnapCandidatePoint(p[1], Inkscape::SNAPSOURCE_NODE_HANDLE),
+                                          Inkscape::Snapper::SnapConstraint(p[1] - p[0]));
             if (snappoint.getSnapped()) {
                 p[1] = snappoint.getPoint();
             }
@@ -175,10 +174,10 @@ Geom::Rect Inkscape::snap_rectangular_box(SPDesktop const *desktop, SPItem *item
 
         Inkscape::SnappedPoint s[2];
 
-        s[0] = m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, to_2geom(p[0]));
-        s[1] = m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, to_2geom(p[1]));
+        s[0] = m.freeSnap(Inkscape::SnapCandidatePoint(p[0], Inkscape::SNAPSOURCE_NODE_HANDLE));
+        s[1] = m.freeSnap(Inkscape::SnapCandidatePoint(p[1], Inkscape::SNAPSOURCE_NODE_HANDLE));
 
-        if (s[0].getDistance() < s[1].getDistance()) {
+        if (s[0].getSnapDistance() < s[1].getSnapDistance()) {
             if (s[0].getSnapped()) {
                 p[0] = s[0].getPoint();
                 p[1] = 2 * center - s[0].getPoint();
@@ -197,19 +196,21 @@ Geom::Rect Inkscape::snap_rectangular_box(SPDesktop const *desktop, SPItem *item
         /* There's no constraint on the corner point, so just snap it to anything */
         p[0] = center;
         p[1] = pt;
-        snappoint = m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, to_2geom(pt));
+        snappoint = m.freeSnap(Inkscape::SnapCandidatePoint(pt, Inkscape::SNAPSOURCE_NODE_HANDLE));
         if (snappoint.getSnapped()) {
             p[1] = snappoint.getPoint();
         }
     }
 
     if (snappoint.getSnapped()) {
-        desktop->snapindicator->set_new_snappoint(snappoint);
+        desktop->snapindicator->set_new_snaptarget(snappoint);
     }
 
-    p[0] = sp_desktop_dt2root_xy_point(desktop, p[0]);
-    p[1] = sp_desktop_dt2root_xy_point(desktop, p[1]);
-    
+    p[0] *= desktop->dt2doc();
+    p[1] *= desktop->dt2doc();
+
+    m.unSetup();
+
     return Geom::Rect(Geom::Point(MIN(p[0][Geom::X], p[1][Geom::X]), MIN(p[0][Geom::Y], p[1][Geom::Y])),
                     Geom::Point(MAX(p[0][Geom::X], p[1][Geom::X]), MAX(p[0][Geom::Y], p[1][Geom::Y])));
 }
@@ -237,4 +238,4 @@ Geom::Point Inkscape::setup_for_drag_start(SPDesktop *desktop, SPEventContext* e
   fill-column:99
   End:
 */
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :