Code

Provide knotholder for LPEPerpBisector; TODO: this replaces the usual nodepath in...
[inkscape.git] / src / shape-editor.cpp
index b1da900f40a3153d2a38244ec60151bd33536f90..f0bec7ba91ac88529a56f2ff098dd740fdbc976e 100644 (file)
@@ -22,6 +22,7 @@
 #include "desktop.h"
 #include "desktop-handles.h"
 #include "knotholder.h"
+#include "live_effects/parameter/pointparam-knotholder.h"
 #include "node-context.h"
 #include "xml/node-event-vector.h"
 #include "prefs-utils.h"
@@ -189,7 +190,14 @@ void ShapeEditor::set_item(SPItem *item) {
     this->grab_node = -1;
 
     if (item) {
-        this->nodepath = sp_nodepath_new(desktop, item, (prefs_get_int_attribute("tools.nodes", "show_handles", 1) != 0));
+        SPLPEItem *lpeitem = SP_LPE_ITEM(item);
+        if (!sp_lpe_item_has_path_effect(lpeitem) ||
+            !sp_lpe_item_get_livepatheffect(lpeitem)->providesKnotholder()) {
+            // only create nodepath if the item either doesn't have an LPE
+            // or the LPE doesn't provide a knotholder itself
+            this->nodepath =
+                sp_nodepath_new(desktop, item, (prefs_get_int_attribute("tools.nodes", "show_handles", 1) != 0));
+        }
         if (this->nodepath) {
             this->nodepath->shape_editor = this;
         }
@@ -213,8 +221,8 @@ void ShapeEditor::set_item(SPItem *item) {
 /** Please note that this function only works for path parameters.
 *  All other parameters probably will crash Inkscape!
 */
-void ShapeEditor::set_item_lpe_path_parameter(SPItem *item, SPObject *lpeobject, const char * key) {
-
+void ShapeEditor::set_item_lpe_path_parameter(SPItem *item, SPObject *lpeobject, const char * key)
+{
     unset_item();
 
     this->grab_node = -1;
@@ -236,11 +244,19 @@ void ShapeEditor::set_item_lpe_path_parameter(SPItem *item, SPObject *lpeobject,
     }
 }
 
-/** Please note that this function only works for point parameters.
-*  All other parameters probably will crash Inkscape!
+/** 
+*  pass a new knotholder to ShapeEditor to manage (and delete)
 */
-void ShapeEditor::set_item_lpe_point_parameter(SPItem */*item*/, SPObject */*lpeobject*/, const char * /*key*/) {
-    g_message("ShapeEditor::set_item_lpe_point_parameter has not been implemented yet!");
+void
+ShapeEditor::set_knotholder(SPKnotHolder * knot_holder)
+{
+    unset_item();
+
+    this->grab_node = -1;
+
+    if (knot_holder) {
+        this->knotholder = knot_holder;
+    }
 }
 
 
@@ -296,9 +312,9 @@ bool ShapeEditor::is_over_stroke (NR::Point event_p, bool remember) {
         (( !SP_OBJECT_STYLE(item)->stroke.isNone() ?
            desktop->current_zoom() *
            SP_OBJECT_STYLE (item)->stroke_width.computed * 0.5 *
-           sp_item_i2d_affine (item).expansion()
+           NR::expansion(sp_item_i2d_affine(item))
          : 0.0)
-         + prefs_get_int_attribute_limited("options.dragtolerance", "value", 0, 0, 100)) /sp_item_i2d_affine (item).expansion(); 
+         + prefs_get_int_attribute_limited("options.dragtolerance", "value", 0, 0, 100)) /NR::expansion(sp_item_i2d_affine(item)); 
     bool close = (NR::L2 (delta) < stroke_tolerance);
 
     if (remember && close) {