Code

Mark suspicious ignoring of parameters
[inkscape.git] / src / seltrans.cpp
index e34f6ba83d837acb1d79a16e5e1ad491bf9d37f1..a3e0c9f0b4cec86f897f6c5439acd7542c4389b5 100644 (file)
@@ -52,7 +52,6 @@
 #include "2geom/angle.h"
 #include "display/snap-indicator.h"
 
-#include "isnan.h" //temp fix.  make sure included last
 
 static void sp_remove_handles(SPKnot *knot[], gint num);
 
@@ -269,7 +268,7 @@ void Inkscape::SelTrans::grab(NR::Point const &p, gdouble x, gdouble y, bool sho
         SPItem *it = (SPItem *)sp_object_ref(SP_OBJECT(l->data), NULL);
         _items.push_back(it);
         _items_const.push_back(it);
-        _items_affines.push_back(sp_item_i2d_affine(it));
+        _items_affines.push_back(from_2geom(sp_item_i2d_affine(it)));
         _items_centers.push_back(it->getCenter()); // for content-dragging, we need to remember original centers
     }
 
@@ -373,7 +372,7 @@ void Inkscape::SelTrans::transform(NR::Matrix const &rel_affine, NR::Point const
         for (unsigned i = 0; i < _items.size(); i++) {
             SPItem &item = *_items[i];
             NR::Matrix const &prev_transform = _items_affines[i];
-            sp_item_set_i2d_affine(&item, prev_transform * affine);
+            sp_item_set_i2d_affine(&item, to_2geom(prev_transform * affine));
         }
     } else {
         if (_bbox) {
@@ -526,9 +525,9 @@ void Inkscape::SelTrans::stamp()
 
             NR::Matrix const *new_affine;
             if (_show == SHOW_OUTLINE) {
-                NR::Matrix const i2d(sp_item_i2d_affine(original_item));
+                NR::Matrix const i2d(from_2geom(sp_item_i2d_affine(original_item)));
                 NR::Matrix const i2dnew( i2d * _current_relative_affine );
-                sp_item_set_i2d_affine(copy_item, i2dnew);
+                sp_item_set_i2d_affine(copy_item, to_2geom(i2dnew));
                 new_affine = &copy_item->transform;
             } else {
                 new_affine = &original_item->transform;
@@ -1261,7 +1260,7 @@ gboolean Inkscape::SelTrans::centerRequest(NR::Point &pt, guint state)
 {
     SnapManager &m = _desktop->namedview->snap_manager;
     m.setup(_desktop);
-    pt = m.freeSnap(Snapper::SNAPPOINT_NODE, pt).getPoint();
+    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 +1368,7 @@ void Inkscape::SelTrans::moveTo(NR::Point const &xy, guint state)
         ** FIXME: this will snap to more than just the grid, nowadays.
         */
 
-        dxy = m.freeSnap(Snapper::SNAPPOINT_NODE, dxy).getPoint();
+        m.freeSnapReturnByRef(Snapper::SNAPPOINT_NODE, dxy);
 
     } else if (!shift) {
 
@@ -1386,6 +1385,11 @@ void Inkscape::SelTrans::moveTo(NR::Point const &xy, guint state)
             /* Snap to things, and also constrain to horizontal or vertical movement */
 
             for (unsigned int dim = 0; dim < 2; dim++) {
+                // When doing a constrained translation, all points will move in the same direction, i.e.
+                // either horizontally or vertically. Therefore we only have to specify the direction of
+                // the constraint-line once. The constraint lines are parallel, but might not be colinear.
+                // Therefore we will have to set the point through which the constraint-line runs
+                // individually for each point to be snapped; this will be handled however by _snapTransformed()
                 s.push_back(m.constrainedSnapTranslation(Inkscape::Snapper::SNAPPOINT_BBOX,
                                                          _bbox_points,
                                                          Inkscape::Snapper::ConstraintLine(component_vectors[dim]),
@@ -1418,31 +1422,30 @@ void Inkscape::SelTrans::moveTo(NR::Point const &xy, guint state)
         g_assert(best_snapped_point.getDistance() == NR_HUGE);
         for (std::list<Inkscape::SnappedPoint>::const_iterator i = s.begin(); i != s.end(); i++) {
             if (i->getSnapped()) {
-                // std::cout << "moveTo() -> snapped to point: " << i->getPoint() << " with transformation: " << i->getTransformation();
                 if (i->getDistance() < best_snapped_point.getDistance()) {
                     best_snapped_point = *i;
                     dxy = i->getTransformation();
-                    // std::cout << " SEL";
                 }
-                //std::cout << std::endl;
             }
         }
         if (best_snapped_point.getSnapped()) {
             _desktop->snapindicator->set_new_snappoint(best_snapped_point);
         } else {
-            _desktop->snapindicator->remove_snappoint();
-        }
-    }
-
-    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;
+            // We didn't snap, so remove any previous snap indicator 
+            _desktop->snapindicator->remove_snappoint();            
+            if (control) {
+                // If we didn't snap, then we should still constrain horizontally or vertically
+                // (When we did snap, then this constraint has already been enforced by
+                // calling constrainedSnapTranslation() above)
+                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);
     transform(move, norm);