Code

No more NRMatrix or NRPoint.
[inkscape.git] / src / shape-editor.cpp
index a2a9a86ebb38952f289c40dea12371aace0d548f..d73e99e7c8905ca484200ee6e3fead5d6a33e361 100644 (file)
@@ -12,6 +12,7 @@
 #include "config.h"
 #endif
 
+#include <string.h>
 #include <glibmm/i18n.h>
 
 #include "sp-object.h"
@@ -21,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"
@@ -211,16 +213,14 @@ void ShapeEditor::set_item(SPItem *item) {
 
 /** Please note that this function only works for path parameters.
 *  All other parameters probably will crash Inkscape!
-*  Fortunately, there are no other on-canvas edittable objects at this moment :)
 */
-void ShapeEditor::set_item_livepatheffect_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;
 
     if (lpeobject) {
-        this->knotholder = NULL; // it's a path, no special knotholder needed.
         this->nodepath = sp_nodepath_new( desktop, lpeobject,
                                           (prefs_get_int_attribute("tools.nodes", "show_handles", 1) != 0),
                                           key, item);
@@ -237,6 +237,22 @@ void ShapeEditor::set_item_livepatheffect_parameter(SPItem *item, SPObject *lpeo
     }
 }
 
+/** 
+*  pass a new knotholder to ShapeEditor to manage (and delete)
+*/
+void
+ShapeEditor::set_knotholder(SPKnotHolder * knot_holder)
+{
+    unset_item();
+
+    this->grab_node = -1;
+
+    if (knot_holder) {
+        this->knotholder = knot_holder;
+    }
+}
+
+
 /** FIXME: think about this. Is this thing only called when the item needs to be updated?
    Why not make a reload function in NodePath and in KnotHolder? */
 void ShapeEditor::reset_item ()
@@ -245,7 +261,7 @@ void ShapeEditor::reset_item ()
         SPItem * item = this->nodepath->item;
         SPObject *obj = this->nodepath->object;
         char * key = g_strdup(this->nodepath->repr_key);
-        set_item_livepatheffect_parameter(item, obj, key);
+        set_item_lpe_path_parameter(item, obj, key); // the above checks for nodepath, so it is indeed a path that we are editing
         g_free(key);
     } else {
         SPItem * item = get_item();
@@ -289,9 +305,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) {
@@ -479,6 +495,10 @@ void ShapeEditor::show_handles (bool show) {
         sp_nodepath_show_handles (this->nodepath, show);
 }
 
+void ShapeEditor::show_helperpath (bool show) {
+    if (this->nodepath)
+        sp_nodepath_show_helperpath (this->nodepath, show);
+}
 
 void ShapeEditor::flip (NR::Dim2 axis, NR::Maybe<NR::Point> center) {
     if (this->nodepath)