summaryrefslogtreecommitdiffstats
path: root/src/live_effects/parameter
diff options
context:
space:
mode:
authorJohan B. C. Engelen <jbc.engelen@swissonline.ch>2012-01-12 21:06:16 +0000
committerJohan Engelen <goejendaagh@zonnet.nl>2012-01-12 21:06:16 +0000
commit76f0853b7d6bbe1233daa3141ce1379e2df1e934 (patch)
treecaeee88d187ec0312914f48953729d6f7f0b21d9 /src/live_effects/parameter
parentInitial C++ification of SPCanvas. (diff)
downloadinkscape-76f0853b7d6bbe1233daa3141ce1379e2df1e934.tar.gz
inkscape-76f0853b7d6bbe1233daa3141ce1379e2df1e934.zip
LPE: add new LPE that outputs the original path data. used to make a clone (without LPE) of a path with an LPE applied
(bzr r10874)
Diffstat (limited to 'src/live_effects/parameter')
-rw-r--r--src/live_effects/parameter/Makefile_insert2
-rw-r--r--src/live_effects/parameter/originalpath.cpp120
-rw-r--r--src/live_effects/parameter/originalpath.h49
-rw-r--r--src/live_effects/parameter/path.cpp7
-rw-r--r--src/live_effects/parameter/path.h1
5 files changed, 178 insertions, 1 deletions
diff --git a/src/live_effects/parameter/Makefile_insert b/src/live_effects/parameter/Makefile_insert
index 99cd88d62..efdda686a 100644
--- a/src/live_effects/parameter/Makefile_insert
+++ b/src/live_effects/parameter/Makefile_insert
@@ -16,6 +16,8 @@ ink_common_sources += \
live_effects/parameter/path-reference.h \
live_effects/parameter/path.cpp \
live_effects/parameter/path.h \
+ live_effects/parameter/originalpath.cpp \
+ live_effects/parameter/originalpath.h \
live_effects/parameter/powerstrokepointarray.cpp \
live_effects/parameter/powerstrokepointarray.h \
live_effects/parameter/text.cpp \
diff --git a/src/live_effects/parameter/originalpath.cpp b/src/live_effects/parameter/originalpath.cpp
new file mode 100644
index 000000000..3092f678b
--- /dev/null
+++ b/src/live_effects/parameter/originalpath.cpp
@@ -0,0 +1,120 @@
+/*
+ * Copyright (C) Johan Engelen 2012 <j.b.c.engelen@alumnus.utwente.nl>
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "live_effects/parameter/originalpath.h"
+
+#include <gtkmm.h>
+#include "widgets/icon.h"
+#include <glibmm/i18n.h>
+
+#include "uri.h"
+#include "sp-shape.h"
+#include "sp-text.h"
+#include "display/curve.h"
+#include "live_effects/effect.h"
+
+namespace Inkscape {
+
+namespace LivePathEffect {
+
+OriginalPathParam::OriginalPathParam( const Glib::ustring& label, const Glib::ustring& tip,
+ const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr,
+ Effect* effect)
+ : PathParam(label, tip, key, wr, effect, "")
+{
+ oncanvas_editable = false;
+}
+
+OriginalPathParam::~OriginalPathParam()
+{
+
+}
+
+Gtk::Widget *
+OriginalPathParam::param_newWidget()
+{
+ Gtk::HBox *_widget = Gtk::manage(new Gtk::HBox());
+
+ { // Label
+ Gtk::Label *pLabel = Gtk::manage(new Gtk::Label(param_label));
+ static_cast<Gtk::HBox*>(_widget)->pack_start(*pLabel, true, true);
+ pLabel->set_tooltip_text(param_tooltip);
+ }
+
+ { // Paste path to link button
+ Gtk::Widget *pIcon = Gtk::manage( sp_icon_get_icon( GTK_STOCK_PASTE, Inkscape::ICON_SIZE_BUTTON) );
+ Gtk::Button *pButton = Gtk::manage(new Gtk::Button());
+ pButton->set_relief(Gtk::RELIEF_NONE);
+ pIcon->show();
+ pButton->add(*pIcon);
+ pButton->show();
+ pButton->signal_clicked().connect(sigc::mem_fun(*this, &OriginalPathParam::on_link_button_click));
+ static_cast<Gtk::HBox*>(_widget)->pack_start(*pButton, true, true);
+ pButton->set_tooltip_text(_("Link to path"));
+ }
+
+ { // Select original button
+ Gtk::Widget *pIcon = Gtk::manage( sp_icon_get_icon("edit-select-original", Inkscape::ICON_SIZE_BUTTON) );
+ Gtk::Button *pButton = Gtk::manage(new Gtk::Button());
+ pButton->set_relief(Gtk::RELIEF_NONE);
+ pIcon->show();
+ pButton->add(*pIcon);
+ pButton->show();
+ pButton->signal_clicked().connect(sigc::mem_fun(*this, &OriginalPathParam::on_select_original_button_click));
+ static_cast<Gtk::HBox*>(_widget)->pack_start(*pButton, true, true);
+ pButton->set_tooltip_text(_("Select original"));
+ }
+
+ static_cast<Gtk::HBox*>(_widget)->show_all_children();
+
+ return dynamic_cast<Gtk::Widget *> (_widget);
+}
+
+void
+OriginalPathParam::linked_modified_callback(SPObject *linked_obj, guint /*flags*/)
+{
+ SPCurve *curve = NULL;
+ if (SP_IS_SHAPE(linked_obj)) {
+ curve = SP_SHAPE(linked_obj)->getCurveBeforeLPE();
+ }
+ if (SP_IS_TEXT(linked_obj)) {
+ curve = SP_TEXT(linked_obj)->getNormalizedBpath();
+ }
+
+ if (curve == NULL) {
+ // curve invalid, set empty pathvector
+ _pathvector = Geom::PathVector();
+ } else {
+ _pathvector = curve->get_pathvector();
+ curve->unref();
+ }
+
+ must_recalculate_pwd2 = true;
+ emit_changed();
+ SP_OBJECT(param_effect->getLPEObj())->requestModified(SP_OBJECT_MODIFIED_FLAG);
+}
+
+void
+OriginalPathParam::on_select_original_button_click()
+{
+ /// \todo select original path
+ SPItem *original = ref.getObject();
+}
+
+} /* namespace LivePathEffect */
+
+} /* namespace Inkscape */
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
diff --git a/src/live_effects/parameter/originalpath.h b/src/live_effects/parameter/originalpath.h
new file mode 100644
index 000000000..e56dbf2df
--- /dev/null
+++ b/src/live_effects/parameter/originalpath.h
@@ -0,0 +1,49 @@
+#ifndef INKSCAPE_LIVEPATHEFFECT_PARAMETER_ORIGINAL_PATH_H
+#define INKSCAPE_LIVEPATHEFFECT_PARAMETER_ORIGINAL_PATH_H
+
+/*
+ * Inkscape::LivePathEffectParameters
+ *
+* Copyright (C) Johan Engelen 2012 <j.b.c.engelen@alumnus.utwente.nl>
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "live_effects/parameter/path.h"
+
+namespace Inkscape {
+
+namespace LivePathEffect {
+
+class OriginalPathParam: public PathParam {
+public:
+ OriginalPathParam ( const Glib::ustring& label,
+ const Glib::ustring& tip,
+ const Glib::ustring& key,
+ Inkscape::UI::Widget::Registry* wr,
+ Effect* effect);
+ virtual ~OriginalPathParam();
+
+ bool linksToPath() { return (href != NULL); }
+
+ virtual Gtk::Widget * param_newWidget();
+ /** Disable the canvas indicators of parent class by overriding this method */
+ virtual void param_editOncanvas(SPItem * /*item*/, SPDesktop * /*dt*/) {};
+ /** Disable the canvas indicators of parent class by overriding this method */
+ virtual void addCanvasIndicators(SPLPEItem * /*lpeitem*/, std::vector<Geom::PathVector> & /*hp_vec*/) {};
+
+protected:
+ virtual void linked_modified_callback(SPObject *linked_obj, guint flags);
+ void on_select_original_button_click();
+
+private:
+ OriginalPathParam(const OriginalPathParam&);
+ OriginalPathParam& operator=(const OriginalPathParam&);
+};
+
+
+} //namespace LivePathEffect
+
+} //namespace Inkscape
+
+#endif
diff --git a/src/live_effects/parameter/path.cpp b/src/live_effects/parameter/path.cpp
index 8188ea19a..5adba9aac 100644
--- a/src/live_effects/parameter/path.cpp
+++ b/src/live_effects/parameter/path.cpp
@@ -360,8 +360,13 @@ PathParam::linked_delete(SPObject */*deleted*/)
set_new_value (_pathvector, true);
}
+void PathParam::linked_modified(SPObject *linked_obj, guint flags)
+{
+ linked_modified_callback(linked_obj, flags);
+}
+
void
-PathParam::linked_modified(SPObject *linked_obj, guint /*flags*/)
+PathParam::linked_modified_callback(SPObject *linked_obj, guint /*flags*/)
{
SPCurve *curve = NULL;
if (SP_IS_SHAPE(linked_obj)) {
diff --git a/src/live_effects/parameter/path.h b/src/live_effects/parameter/path.h
index 854c29708..7b51dc48a 100644
--- a/src/live_effects/parameter/path.h
+++ b/src/live_effects/parameter/path.h
@@ -76,6 +76,7 @@ protected:
void quit_listening(void);
void linked_delete(SPObject *deleted);
void linked_modified(SPObject *linked_obj, guint flags);
+ virtual void linked_modified_callback(SPObject *linked_obj, guint flags);
void on_edit_button_click();
void on_copy_button_click();