Code

No more NRMatrix or NRPoint.
[inkscape.git] / src / tweak-context.cpp
index 85831a648f77f8728cf3ae7a6ce40ad3438dcd56..d2ec3d3c0f4c80e23c2b78be9a78c0ab94c92b1c 100644 (file)
@@ -264,6 +264,14 @@ sp_tweak_context_setup(SPEventContext *ec)
     tc->style_set_connection = ec->desktop->connectSetStyle( // catch style-setting signal in this tool
         sigc::bind(sigc::ptr_fun(&sp_tweak_context_style_set), tc)
     );
+
+    if (prefs_get_int_attribute("tools.tweak", "selcue", 0) != 0) {
+        ec->enableSelectionCue();
+    }
+
+    if (prefs_get_int_attribute("tools.tweak", "gradientdrag", 0) != 0) {
+        ec->enableGrDrag();
+    }
 }
 
 static void
@@ -329,6 +337,12 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, NR::Poi
 {
     bool did = false;
 
+    if (SP_IS_BOX3D(item)) {
+        // convert 3D boxes to ordinary groups before tweaking their shapes
+        item = SP_ITEM(box3d_convert_to_group(SP_BOX3D(item)));
+        selection->add(item);
+    }
+
     if (SP_IS_GROUP(item)) {
         for (SPObject *child = sp_object_first_child(SP_OBJECT(item)) ; child != NULL; child = SP_OBJECT_NEXT(child) ) {
             if (SP_IS_ITEM(child)) {
@@ -376,8 +390,9 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, NR::Poi
 
         Shape *theShape = new Shape;
         Shape *theRes = new Shape;
+        NR::Matrix i2doc(sp_item_i2doc_affine(item));
 
-        orig->ConvertWithBackData(0.08 - (0.07 * fidelity)); // default 0.059
+        orig->ConvertWithBackData((0.08 - (0.07 * fidelity)) / NR::expansion(i2doc)); // default 0.059
         orig->Fill(theShape, 0);
 
         SPCSSAttr *css = sp_repr_css_attr(SP_OBJECT_REPR(item), "style");
@@ -399,7 +414,6 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, NR::Poi
             vector = 1/NR::L2(vector) * vector;
 
         bool did_this = false;
-        NR::Matrix i2doc(sp_item_i2doc_affine(item));
         if (mode == TWEAK_MODE_SHRINK || mode == TWEAK_MODE_GROW) {
             if (theShape->MakeTweak(tweak_mode_grow, theRes,
                                  mode == TWEAK_MODE_GROW? force : -force,
@@ -414,7 +428,7 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, NR::Poi
               did_this = true;
         } else if (mode == TWEAK_MODE_PUSH) {
             if (theShape->MakeTweak(tweak_mode_push, theRes,
-                                 0,
+                                 1.0,
                                  join_straight, 4.0,
                                  true, p, force*2*vector, radius, &i2doc) == 0)
               did_this = true;
@@ -433,10 +447,10 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, NR::Poi
             res->Reset();
             theRes->ConvertToForme(res);
 
-            double th_max = 0.6 - 0.59*sqrt(fidelity);
+            double th_max = (0.6 - 0.59*sqrt(fidelity)) / NR::expansion(i2doc);
             double threshold = MAX(th_max, th_max*force);
             res->ConvertEvenLines(threshold);
-            res->Simplify(threshold);
+            res->Simplify(threshold / (SP_ACTIVE_DESKTOP->current_zoom()));
 
             if (newrepr) { // converting to path, need to replace the repr
                 bool is_selected = selection->includes(item);
@@ -836,12 +850,6 @@ sp_tweak_dilate (SPTweakContext *tc, NR::Point event_p, NR::Point p, NR::Point v
 
         SPItem *item = (SPItem *) items->data;
 
-        if (SP_IS_BOX3D(item)) {
-            // convert 3D boxes to ordinary groups before tweaking their shapes
-            item = SP_ITEM(box3d_convert_to_group(SP_BOX3D(item)));
-            selection->add(item);
-        }
-
         if (tc->mode == TWEAK_MODE_COLORPAINT || tc->mode == TWEAK_MODE_COLORJITTER) {
             if (do_fill || do_stroke || do_opacity) {
                 if (sp_tweak_color_recursive (tc->mode, item, item_at_point,