Code

Fix a regression in the snapper, caused by me. Sorry!
authordvlierop2 <dvlierop2@users.sourceforge.net>
Fri, 16 May 2008 21:53:27 +0000 (21:53 +0000)
committerdvlierop2 <dvlierop2@users.sourceforge.net>
Fri, 16 May 2008 21:53:27 +0000 (21:53 +0000)
14 files changed:
src/arc-context.cpp
src/box3d-context.cpp
src/connector-context.cpp
src/context-fns.cpp
src/draw-context.cpp
src/gradient-context.cpp
src/object-edit.cpp
src/pencil-context.cpp
src/rect-context.cpp
src/seltrans.cpp
src/snap.cpp
src/snap.h
src/spiral-context.cpp
src/star-context.cpp

index 6169d000fec26d75ebe5806dd6e0273f024c9093..b06b5fb86d879e0b23f31209c653d62c3c34a696 100644 (file)
@@ -265,7 +265,7 @@ static gint sp_arc_context_root_handler(SPEventContext *event_context, GdkEvent
 
                 SnapManager &m = desktop->namedview->snap_manager;
                 m.setup(desktop, ac->item);                
-                m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, ac->center);
+                m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, ac->center);
                 
                 sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate),
                                     GDK_KEY_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
@@ -292,7 +292,7 @@ static gint sp_arc_context_root_handler(SPEventContext *event_context, GdkEvent
                 
                 SnapManager &m = desktop->namedview->snap_manager;
                 m.setup(desktop, ac->item);            
-                m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, motion_dt);
+                m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, motion_dt);
 
                 sp_arc_drag(ac, motion_dt, event->motion.state);
 
index a7cead93e4a2a00d8629c069a9aa4535e142be5f..c1af593d4f617b4ca437c85e23633a2d1bd26a44 100644 (file)
@@ -317,7 +317,7 @@ static gint sp_box3d_context_root_handler(SPEventContext *event_context, GdkEven
             dragging = true;
             
             /*  */
-            NR::Point const button_dt(desktop->w2d(button_w));
+            NR::Point button_dt(desktop->w2d(button_w));
             bc->drag_origin = button_dt;
             bc->drag_ptB = button_dt;
             bc->drag_ptC = button_dt;
@@ -332,7 +332,7 @@ static gint sp_box3d_context_root_handler(SPEventContext *event_context, GdkEven
             /* Snap center */
             SnapManager &m = desktop->namedview->snap_manager;
             m.setup(desktop, bc->item);
-            m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, button_dt);
+            m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, button_dt);
             bc->center = button_dt;
 
             sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate),
@@ -364,7 +364,7 @@ static gint sp_box3d_context_root_handler(SPEventContext *event_context, GdkEven
 
             SnapManager &m = desktop->namedview->snap_manager;
             m.setup(desktop, bc->item);
-            m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, motion_dt);
+            m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, motion_dt);
 
             bc->ctrl_dragged  = event->motion.state & GDK_CONTROL_MASK;
 
@@ -397,7 +397,7 @@ static gint sp_box3d_context_root_handler(SPEventContext *event_context, GdkEven
                     bc->drag_ptB_proj.normalize();
                     bc->drag_ptC_proj = cur_persp->tmat.preimage (motion_dt, bc->drag_ptB_proj[Proj::X], Proj::X);
                 }
-                m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, bc->drag_ptC);
+                m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, bc->drag_ptC);
             }
 
             sp_box3d_drag(*bc, event->motion.state);
index e33b11e640fde32fdcb664c743835c19e5a16bf4..028467b44dc60d85e9fb967734cb6e296d50a180 100644 (file)
@@ -532,7 +532,7 @@ connector_handle_button_press(SPConnectorContext *const cc, GdkEventButton const
                         // as there's no other points to go off.
                         SnapManager &m = cc->desktop->namedview->snap_manager;
                         m.setup(cc->desktop);
-                        m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, p);
+                        m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, p);
                     }
                     spcc_connector_set_initial_point(cc, p);
 
index 2ae4c3901b8dd41968f9cdff67a959d1c867b06a..28725c64ff2c8d86aa9c1ca85fce6b08f49ab379 100644 (file)
@@ -197,11 +197,8 @@ NR::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;
-        //std::cout << "pt        = " << pt << std::endl;
         snappoint = m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, pt);
-        //std::cout << "snappoint.getPoint() = " << snappoint.getPoint() << std::endl;
         if (snappoint.getSnapped()) {
-            //std::cout << "we snapped here ..." << std::endl;
             p[1] = snappoint.getPoint();
         }
     }
@@ -213,8 +210,6 @@ NR::Rect Inkscape::snap_rectangular_box(SPDesktop const *desktop, SPItem *item,
     p[0] = sp_desktop_dt2root_xy_point(desktop, p[0]);
     p[1] = sp_desktop_dt2root_xy_point(desktop, p[1]);
     
-    //std::cout << "after: p[0] vs. p[1] = " << p[0] << " | " << p[1] << std::endl;  
-
     return NR::Rect(NR::Point(MIN(p[0][NR::X], p[1][NR::X]), MIN(p[0][NR::Y], p[1][NR::Y])),
                     NR::Point(MAX(p[0][NR::X], p[1][NR::X]), MAX(p[0][NR::Y], p[1][NR::Y])));
 }
index f4d7a856959c76f7c160f60d91904855a59bc805..9a2c1215c0f3bf2692dccd970db816e3fcc28a07 100644 (file)
@@ -356,7 +356,7 @@ void spdc_endpoint_snap_rotation(SPEventContext const *const ec, NR::Point &p, N
         /* Snap it along best vector */
         SnapManager &m = SP_EVENT_CONTEXT_DESKTOP(ec)->namedview->snap_manager;
         m.setup(SP_EVENT_CONTEXT_DESKTOP(ec), NULL);
-        m.constrainedSnap( Inkscape::Snapper::SNAPPOINT_NODE, p, Inkscape::Snapper::ConstraintLine(best));
+        m.constrainedSnapReturnByRef( Inkscape::Snapper::SNAPPOINT_NODE, p, Inkscape::Snapper::ConstraintLine(best));
     }
 }
 
@@ -370,7 +370,7 @@ void spdc_endpoint_snap_free(SPEventContext const * const ec, NR::Point& p, guin
 
     SnapManager &m = SP_EVENT_CONTEXT_DESKTOP(ec)->namedview->snap_manager;
     m.setup(SP_EVENT_CONTEXT_DESKTOP(ec), NULL);
-    m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, p);
+    m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, p);
 }
 
 static SPCurve *
index e4cdd707fe10a1c41ed77922d86be327576f6af9..01964b8e7794444c7967ed3d017eab37db17633d 100644 (file)
@@ -533,7 +533,7 @@ sp_gradient_context_root_handler(SPEventContext *event_context, GdkEvent *event)
         break;
     case GDK_BUTTON_PRESS:
         if ( event->button.button == 1 && !event_context->space_panning ) {
-            NR::Point const button_w(event->button.x, event->button.y);
+            NR::Point button_w(event->button.x, event->button.y);
 
             // save drag origin
             event_context->xp = (gint) button_w[NR::X];
@@ -542,7 +542,7 @@ sp_gradient_context_root_handler(SPEventContext *event_context, GdkEvent *event)
 
             dragging = true;
 
-            NR::Point const button_dt = desktop->w2d(button_w);
+            NR::Point button_dt = desktop->w2d(button_w);
             if (event->button.state & GDK_SHIFT_MASK) {
                 Inkscape::Rubberband::get()->start(desktop, button_dt);
             } else {
@@ -554,7 +554,7 @@ sp_gradient_context_root_handler(SPEventContext *event_context, GdkEvent *event)
                 /* Snap center to nearest magnetic point */
                 SnapManager &m = desktop->namedview->snap_manager;
                 m.setup(desktop);
-                m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, button_dt);
+                m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, button_dt);
                 rc->origin = button_dt;
             }
 
index 0abf84a1ff5371e58a4a222f6579d3b3cbbcdd86..65b256b340394870e5497a34ab6bb86e09ef79fd 100644 (file)
@@ -224,7 +224,7 @@ static NR::Point snap_knot_position(SPItem *item, NR::Point const &p)
     NR::Point s = p * i2d;
     SnapManager &m = desktop->namedview->snap_manager;
     m.setup(desktop, item);
-    m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, s);
+    m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, s);
     return s * i2d.inverse();
 }
 
index 87cbb8d12879c5bb00ba5da9b0bbe57084a93f1c..6af9f7956c768412f9ab31c705f6ba59712e0e17 100644 (file)
@@ -248,7 +248,7 @@ pencil_handle_button_press(SPPencilContext *const pc, GdkEventButton const &beve
                         desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Creating new path"));
                         SnapManager &m = desktop->namedview->snap_manager;
                         m.setup(desktop);
-                        m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, p);
+                        m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, p);
                     } else if (selection->singleItem() && SP_IS_PATH(selection->singleItem())) {
                         desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Appending to selected path"));
                     }
@@ -325,7 +325,7 @@ pencil_handle_motion_notify(SPPencilContext *const pc, GdkEventMotion const &mev
                 } else if ((mevent.state & GDK_SHIFT_MASK) == 0) {
                     SnapManager &m = dt->namedview->snap_manager;
                     m.setup(dt, NULL);
-                    m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, p);
+                    m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, p);
                 }
                 if ( pc->npoints != 0 ) { // buttonpress may have happened before we entered draw context!
                     spdc_add_freehand_point(pc, p, mevent.state);
index b8047b201eae2544285c0d83dfa4b732dc878df1..3ecd89113724f9a81fdfb2cf6115b2e26117ecbd 100644 (file)
@@ -302,11 +302,6 @@ static gint sp_rect_context_root_handler(SPEventContext *event_context, GdkEvent
 
             /* Position center */
             NR::Point const button_dt(desktop->w2d(button_w));
-
-            /* Snap center */
-            SnapManager &m = desktop->namedview->snap_manager;
-            m.setup(desktop, rc->item);
-            m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, button_dt);
             rc->center = button_dt;
             
             sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate),
@@ -315,6 +310,7 @@ static gint sp_rect_context_root_handler(SPEventContext *event_context, GdkEvent
                                   GDK_POINTER_MOTION_MASK       |
                                   GDK_BUTTON_PRESS_MASK ),
                                 NULL, event->button.time);
+                                
             ret = TRUE;
         }
         break;
@@ -336,11 +332,11 @@ static gint sp_rect_context_root_handler(SPEventContext *event_context, GdkEvent
                                      event->motion.y);
             NR::Point motion_dt(desktop->w2d(motion_w));
             
-            SnapManager &m = desktop->namedview->snap_manager;
-            m.setup(desktop, rc->item);
-            m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, motion_dt);
+            //SnapManager &m = desktop->namedview->snap_manager;
+            //m.setup(desktop, rc->item);
+            //m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, motion_dt);
             
-            sp_rect_drag(*rc, motion_dt, event->motion.state);
+            sp_rect_drag(*rc, motion_dt, event->motion.state); // this will also handle the snapping
             gobble_motion_events(GDK_BUTTON1_MASK);
             ret = TRUE;
         }
@@ -500,6 +496,11 @@ static void sp_rect_drag(SPRectContext &rc, NR::Point const pt, guint state)
         rc.item->updateRepr();
 
         sp_canvas_force_full_redraw_after_interruptions(desktop->canvas, 5);
+        
+        /* Snap center */
+        SnapManager &m = desktop->namedview->snap_manager;
+        m.setup(desktop, rc.item);
+        m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, rc.center);     
     }
 
     NR::Rect const r = Inkscape::snap_rectangular_box(desktop, rc.item, pt, rc.center, state);
index 432b1e67067b15dbdc4931a747608d901e0990df..94baf12d709bb5337873996da0840ad23bd1e941 100644 (file)
@@ -1261,7 +1261,7 @@ gboolean Inkscape::SelTrans::centerRequest(NR::Point &pt, guint state)
 {
     SnapManager &m = _desktop->namedview->snap_manager;
     m.setup(_desktop);
-    m.freeSnap(Snapper::SNAPPOINT_NODE, pt);
+    m.freeSnapReturnByRef(Snapper::SNAPPOINT_NODE, pt);
 
     if (state & GDK_CONTROL_MASK) {
         if ( fabs(_point[NR::X] - pt[NR::X]) > fabs(_point[NR::Y] - pt[NR::Y]) ) {
@@ -1369,7 +1369,7 @@ void Inkscape::SelTrans::moveTo(NR::Point const &xy, guint state)
         ** FIXME: this will snap to more than just the grid, nowadays.
         */
 
-        m.freeSnap(Snapper::SNAPPOINT_NODE, dxy);
+        m.freeSnapReturnByRef(Snapper::SNAPPOINT_NODE, dxy);
 
     } else if (!shift) {
 
@@ -1434,14 +1434,14 @@ void Inkscape::SelTrans::moveTo(NR::Point const &xy, guint state)
         }
     }
 
-    if (control) {
-        /* Ensure that the horizontal and vertical constraint has been applied */
-        if (fabs(dxy[NR::X]) > fabs(dxy[NR::Y])) {
-            dxy[NR::Y] = 0;
-        } else {
-            dxy[NR::X] = 0;
-        }
-    }
+    //if (control) {
+    //    /* Ensure that the horizontal and vertical constraint has been applied */
+    //   if (fabs(dxy[NR::X]) > fabs(dxy[NR::Y])) {
+    //        dxy[NR::Y] = 0;
+    //    } else {
+    //        dxy[NR::X] = 0;
+    //    }
+    //}
 
     NR::Matrix const move((NR::translate(dxy)));
     NR::Point const norm(0, 0);
index bc81bdf3ad589d2b5918156af7cd257865527c19..46d043ec17e46b681b755268dd1a6e1883e602bc 100644 (file)
@@ -179,7 +179,7 @@ bool SnapManager::getSnapModeGuide() const
  *  \return Snapped point.
  */
 
-void SnapManager::freeSnapVoid(Inkscape::Snapper::PointType point_type,
+void SnapManager::freeSnapReturnByRef(Inkscape::Snapper::PointType point_type,
                                              NR::Point &p,
                                              bool first_point,
                                              NR::Maybe<NR::Rect> const &bbox_to_snap) const
@@ -244,7 +244,7 @@ Inkscape::SnappedPoint SnapManager::freeSnap(Inkscape::Snapper::PointType point_
  *  \return Snapped point.
  */
 
-void SnapManager::constrainedSnapVoid(Inkscape::Snapper::PointType point_type,
+void SnapManager::constrainedSnapReturnByRef(Inkscape::Snapper::PointType point_type,
                                                     NR::Point &p,
                                                     Inkscape::Snapper::ConstraintLine const &constraint,
                                                     bool first_point,
index 900f548cef9bd049c04c2a83864c4215293caf94..4c5e57b73c2987a6372d38ebf3e90c93cb6924e9 100644 (file)
@@ -50,9 +50,9 @@ 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);
 
-    // freeSnapVoid() is preferred over freeSnap(), because it only returns a 
-    // point, by overwriting p, if snapping has occured; otherwise p is untouched    
-    void freeSnapVoid(Inkscape::Snapper::PointType point_type,
+    // 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,
                       NR::Maybe<NR::Rect> const &bbox_to_snap = NR::Nothing()) const;
@@ -62,9 +62,9 @@ public:
                                     bool first_point = true,
                                     NR::Maybe<NR::Rect> const &bbox_to_snap = NR::Nothing()) const;
     
-    // constrainedSnapVoid() is preferred over constrainedSnap(), because it only returns a 
+    // constrainedSnapReturnByRef() is preferred over constrainedSnap(), because it only returns a 
     // point, by overwriting p, if snapping has occured; otherwise p is untouched
-    void constrainedSnapVoid(Inkscape::Snapper::PointType point_type,
+    void constrainedSnapReturnByRef(Inkscape::Snapper::PointType point_type,
                              NR::Point &p,
                              Inkscape::Snapper::ConstraintLine const &constraint,
                              bool first_point = true,
index 57c06e4a315730da08c08880ec9e2dc87a1a62af..31ec40d5033eb357536740029678d56ba298dc92 100644 (file)
@@ -267,7 +267,7 @@ sp_spiral_context_root_handler(SPEventContext *event_context, GdkEvent *event)
 
                 SnapManager &m = desktop->namedview->snap_manager;
                 m.setup(desktop, sc->item);
-                m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, sc->center);
+                m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, sc->center);
 
                 sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate),
                                     ( GDK_KEY_PRESS_MASK |
@@ -296,7 +296,7 @@ sp_spiral_context_root_handler(SPEventContext *event_context, GdkEvent *event)
                 
                 SnapManager &m = desktop->namedview->snap_manager;
                 m.setup(desktop, sc->item);
-                m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, motion_dt);
+                m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, motion_dt);
                 sp_spiral_drag(sc, motion_dt, event->motion.state);
 
                 gobble_motion_events(GDK_BUTTON1_MASK);
@@ -440,7 +440,7 @@ sp_spiral_drag(SPSpiralContext *sc, NR::Point p, guint state)
     NR::Point p1 = sp_desktop_dt2root_xy_point(desktop, p);
     SnapManager &m = desktop->namedview->snap_manager;
     m.setup(desktop, sc->item);
-    m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, p1);
+    m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, p1);
 
     SPSpiral *spiral = SP_SPIRAL(sc->item);
 
index afdb14a0c84e6171948d29ed25f0684dcb9a8155..b6b3c340e01a15286b10676eaf518861eb808478 100644 (file)
@@ -282,7 +282,7 @@ static gint sp_star_context_root_handler(SPEventContext *event_context, GdkEvent
 
             SnapManager &m = desktop->namedview->snap_manager;
             m.setup(desktop, sc->item);
-            m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, sc->center);
+            m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, sc->center);
 
             sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate),
                                 GDK_KEY_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
@@ -309,7 +309,7 @@ static gint sp_star_context_root_handler(SPEventContext *event_context, GdkEvent
             
             SnapManager &m = desktop->namedview->snap_manager;
             m.setup(desktop, sc->item);
-            m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, motion_dt);
+            m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, motion_dt);
             
             sp_star_drag (sc, motion_dt, event->motion.state);
 
@@ -455,7 +455,7 @@ static void sp_star_drag(SPStarContext *sc, NR::Point p, guint state)
     /* Snap corner point with no constraints */
     SnapManager &m = desktop->namedview->snap_manager;
     m.setup(desktop, sc->item);
-    m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, p1);
+    m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, p1);
 
     SPStar *star = SP_STAR(sc->item);