Code

Updated version files that were missed.
[inkscape.git] / src / seltrans.cpp
index 8f060725bb155a080e0c21a4bd38bed8bc93c812..8ff00d60ae902f654b23e21055e657220d66f1ed 100644 (file)
@@ -333,9 +333,9 @@ void Inkscape::SelTrans::grab(Geom::Point const &p, gdouble x, gdouble y, bool s
         // stroke width. (see get_scale_transform_with_stroke()). This however is currently only implemented for a single bbox.
         // That's why we have both _bbox_points_for_translating and _bbox_points.
         getBBoxPoints(selection->bounds(_snap_bbox_type), &_bbox_points, false, true, emp, mp);
-        if ((_items.size() > 0) && (_items.size() < 50)) { // more than 50 items will produce at least 200 bbox points, which might
-            // make Inkscape crawl (see the comment a few lines above). In that case we will use the bbox of the selection
-            // as a whole
+        if (((_items.size() > 0) && (_items.size() < 50)) || prefs->getBool("/options/snapclosestonly/value", false)) {
+            // More than 50 items will produce at least 200 bbox points, which might make Inkscape crawl
+            // (see the comment a few lines above). In that case we will use the bbox of the selection as a whole
             for (unsigned i = 0; i < _items.size(); i++) {
                 getBBoxPoints(sp_item_bbox_desktop(_items[i], _snap_bbox_type), &_bbox_points_for_translating, false, true, emp, mp);
             }
@@ -408,8 +408,9 @@ void Inkscape::SelTrans::grab(Geom::Point const &p, gdouble x, gdouble y, bool s
         // Optionally, show the snap source
         if (!(_state == STATE_ROTATE && x != 0.5 && y != 0.5)) { // but not when we're dragging a rotation handle, because that won't snap
             // Now either _bbox_points or _snap_points has a single element, the other one has zero..... or both have zero elements
-            g_assert((_snap_points.size() + _bbox_points.size() + _bbox_points_for_translating.size()) == 1);
-            if (m.snapprefs.getSnapEnabledGlobally()) {
+            if ((_snap_points.size() + _bbox_points.size() + _bbox_points_for_translating.size()) > 1) {
+                g_warning("too many snap sources to display, please fix this");
+            } else if (m.snapprefs.getSnapEnabledGlobally()) {
                 if (_bbox_points.size() == 1) {
                     _desktop->snapindicator->set_new_snapsource(_bbox_points.at(0));
                 } else if (_bbox_points_for_translating.size() == 1) {
@@ -525,10 +526,10 @@ void Inkscape::SelTrans::ungrab()
         if (_current_relative_affine.isTranslation()) {
             sp_document_done(sp_desktop_document(_desktop), SP_VERB_CONTEXT_SELECT,
                              _("Move"));
-        } else if (_current_relative_affine.isScale()) {
+        } else if (_current_relative_affine.without_translation().isScale()) {
             sp_document_done(sp_desktop_document(_desktop), SP_VERB_CONTEXT_SELECT,
                              _("Scale"));
-        } else if (_current_relative_affine.isRotation()) {
+        } else if (_current_relative_affine.without_translation().isRotation()) {
             sp_document_done(sp_desktop_document(_desktop), SP_VERB_CONTEXT_SELECT,
                              _("Rotate"));
         } else {
@@ -1629,10 +1630,17 @@ Geom::Point Inkscape::SelTrans::_calcAbsAffineGeom(Geom::Scale const geom_scale)
 
     Inkscape::Preferences *prefs = Inkscape::Preferences::get();
     bool const transform_stroke = prefs->getBool("/options/transform/stroke", true);
-    Geom::Rect visual_bbox = get_visual_bbox(_geometric_bbox, _absolute_affine, _strokewidth, transform_stroke);
+    if (_geometric_bbox) {
+        Geom::Rect visual_bbox = get_visual_bbox(_geometric_bbox, _absolute_affine, _strokewidth, transform_stroke);
+        // return the new handle position
+        return visual_bbox.min() + visual_bbox.dimensions() * Geom::Scale(_handle_x, _handle_y);
+    }
 
-    // return the new handle position
-    return visual_bbox.min() + visual_bbox.dimensions() * Geom::Scale(_handle_x, _handle_y);
+    // Fall back scenario, in case we don't have a geometric bounding box at hand;
+    // (Due to some bugs related to bounding boxes having at least one zero dimension; For more details
+    // see https://bugs.launchpad.net/inkscape/+bug/318726)
+    g_warning("No geometric bounding box has been calculated; this is a bug that needs fixing!");
+    return _calcAbsAffineDefault(geom_scale); // this is bogus, but we must return _something_
 }
 
 void Inkscape::SelTrans::_keepClosestPointOnly(std::vector<std::pair<Geom::Point, int> > &points, const Geom::Point &reference)