Code

Merge and cleanup of GSoC C++-ification project.
[inkscape.git] / src / live_effects / parameter / path.cpp
index 1214a1766db3281d66926d12c91bcd9475159468..8d9b2376ff586770d7b5b8da664c629fa6b770f0 100644 (file)
@@ -1,7 +1,6 @@
-#define INKSCAPE_LIVEPATHEFFECT_PARAMETER_PATH_CPP
-
 /*
  * Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl>
+ *   Abhishek Sharma
  *
  * Released under GNU GPL, read the file 'COPYING' for more information
  */
 // needed for on-canvas editting:
 #include "tools-switch.h"
 #include "shape-editor.h"
-#include "node-context.h"
 #include "desktop-handles.h"
 #include "selection.h"
-#include "nodepath.h"
 // clipboard support
 #include "ui/clipboard.h"
 // required for linking to other paths
 #include "sp-text.h"
 #include "display/curve.h"
 
+#include "ui/tool/node-tool.h"
+#include "ui/tool/multi-path-manipulator.h"
+#include "ui/tool/shape-record.h"
+
 
 namespace Inkscape {
 
@@ -147,7 +148,7 @@ PathParam::param_newWidget(Gtk::Tooltips * tooltips)
     static_cast<Gtk::HBox*>(_widget)->pack_start(*pLabel, true, true);
     tooltips->set_tip(*pLabel, param_tooltip);
 
-    Gtk::Widget*  pIcon = Gtk::manage( sp_icon_get_icon( "draw_node", Inkscape::ICON_SIZE_BUTTON) );
+    Gtk::Widget*  pIcon = Gtk::manage( sp_icon_get_icon( "tool-node-editor", Inkscape::ICON_SIZE_BUTTON) );
     Gtk::Button * pButton = Gtk::manage(new Gtk::Button());
     pButton->set_relief(Gtk::RELIEF_NONE);
     pIcon->show();
@@ -177,7 +178,7 @@ PathParam::param_newWidget(Gtk::Tooltips * tooltips)
     static_cast<Gtk::HBox*>(_widget)->pack_start(*pButton, true, true);
     tooltips->set_tip(*pButton, _("Paste path"));
 
-    pIcon = Gtk::manage( sp_icon_get_icon( "edit_clone", Inkscape::ICON_SIZE_BUTTON) );
+    pIcon = Gtk::manage( sp_icon_get_icon( "edit-clone", Inkscape::ICON_SIZE_BUTTON) );
     pButton = Gtk::manage(new Gtk::Button());
     pButton->set_relief(Gtk::RELIEF_NONE);
     pIcon->show();
@@ -193,28 +194,35 @@ PathParam::param_newWidget(Gtk::Tooltips * tooltips)
 }
 
 void
-PathParam::param_editOncanvas(SPItem * item, SPDesktop * dt)
+PathParam::param_editOncanvas(SPItem *item, SPDesktop * dt)
 {
-    // If not already in nodecontext, goto it!
+    using namespace Inkscape::UI;
+
+    // TODO remove the tools_switch atrocity.
     if (!tools_isactive(dt, TOOLS_NODES)) {
         tools_switch(dt, TOOLS_NODES);
     }
 
-    ShapeEditor * shape_editor = dt->event_context->shape_editor;
+    InkNodeTool *nt = static_cast<InkNodeTool*>(dt->event_context);
+    std::set<ShapeRecord> shapes;
+    ShapeRecord r;
+
+    r.role = SHAPE_ROLE_LPE_PARAM;
+    r.edit_transform = item->i2d_affine(); // TODO is it right?
     if (!href) {
-        shape_editor->set_item_lpe_path_parameter(item, SP_OBJECT(param_effect->getLPEObj()), param_key.c_str());
+        r.item = reinterpret_cast<SPItem*>(param_effect->getLPEObj());
+        r.lpe_key = param_key;
     } else {
-        // set referred item for editing
-        shape_editor->set_item(ref.getObject(), SH_NODEPATH);
+        r.item = ref.getObject();
     }
+    shapes.insert(r);
+    nt->_multipath->setItems(shapes);
 }
 
 void
-PathParam::param_setup_nodepath(Inkscape::NodePath::Path *np)
+PathParam::param_setup_nodepath(Inkscape::NodePath::Path *)
 {
-    np->show_helperpath = true;
-    np->helperpath_rgba = 0x009000ff;
-    np->helperpath_width = 1.0;
+    // TODO this method should not exist at all!
 }
 
 void
@@ -357,7 +365,7 @@ PathParam::linked_modified(SPObject *linked_obj, guint /*flags*/)
 {
     SPCurve *curve = NULL;
     if (SP_IS_SHAPE(linked_obj)) {
-        curve = sp_shape_get_curve(SP_SHAPE(linked_obj));
+        curve = SP_SHAPE(linked_obj)->getCurve();
     }
     if (SP_IS_TEXT(linked_obj)) {
         curve = SP_TEXT(linked_obj)->getNormalizedBpath();
@@ -403,10 +411,10 @@ void
 PathParam::on_paste_button_click()
 {
     Inkscape::UI::ClipboardManager *cm = Inkscape::UI::ClipboardManager::get();
-    Glib::ustring svgd = cm->getPathParameter();
+    Glib::ustring svgd = cm->getPathParameter(SP_ACTIVE_DESKTOP);
     paste_param_path(svgd.data());
-    sp_document_done(param_effect->getSPDoc(), SP_VERB_DIALOG_LIVE_PATH_EFFECT,
-                     _("Paste path parameter"));
+    DocumentUndo::done(param_effect->getSPDoc(), SP_VERB_DIALOG_LIVE_PATH_EFFECT,
+                       _("Paste path parameter"));
 }
 
 void
@@ -420,7 +428,7 @@ void
 PathParam::on_link_button_click()
 {
     Inkscape::UI::ClipboardManager *cm = Inkscape::UI::ClipboardManager::get();
-    Glib::ustring pathid = cm->getShapeOrTextObjectId();
+    Glib::ustring pathid = cm->getShapeOrTextObjectId(SP_ACTIVE_DESKTOP);
 
     if (pathid == "") {
         return;
@@ -437,8 +445,8 @@ PathParam::on_link_button_click()
         // check if linking to object to which LPE is applied (maybe delegated to PathReference
 
         param_write_to_repr(pathid.c_str());
-        sp_document_done(param_effect->getSPDoc(), SP_VERB_DIALOG_LIVE_PATH_EFFECT,
-                         _("Link path parameter to path"));
+        DocumentUndo::done(param_effect->getSPDoc(), SP_VERB_DIALOG_LIVE_PATH_EFFECT,
+                           _("Link path parameter to path"));
     }
 }