diff options
| author | Johan B. C. Engelen <jbc.engelen@swissonline.ch> | 2012-01-12 21:06:16 +0000 |
|---|---|---|
| committer | Johan Engelen <goejendaagh@zonnet.nl> | 2012-01-12 21:06:16 +0000 |
| commit | 76f0853b7d6bbe1233daa3141ce1379e2df1e934 (patch) | |
| tree | caeee88d187ec0312914f48953729d6f7f0b21d9 /src | |
| parent | Initial C++ification of SPCanvas. (diff) | |
| download | inkscape-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')
| -rw-r--r-- | src/live_effects/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | src/live_effects/Makefile_insert | 2 | ||||
| -rw-r--r-- | src/live_effects/effect-enum.h | 1 | ||||
| -rw-r--r-- | src/live_effects/effect.cpp | 5 | ||||
| -rw-r--r-- | src/live_effects/lpe-clone-original.cpp | 50 | ||||
| -rw-r--r-- | src/live_effects/lpe-clone-original.h | 36 | ||||
| -rw-r--r-- | src/live_effects/parameter/Makefile_insert | 2 | ||||
| -rw-r--r-- | src/live_effects/parameter/originalpath.cpp | 120 | ||||
| -rw-r--r-- | src/live_effects/parameter/originalpath.h | 49 | ||||
| -rw-r--r-- | src/live_effects/parameter/path.cpp | 7 | ||||
| -rw-r--r-- | src/live_effects/parameter/path.h | 1 |
11 files changed, 274 insertions, 1 deletions
diff --git a/src/live_effects/CMakeLists.txt b/src/live_effects/CMakeLists.txt index 94112a52e..bb97e6f1d 100644 --- a/src/live_effects/CMakeLists.txt +++ b/src/live_effects/CMakeLists.txt @@ -7,6 +7,7 @@ set(live_effects_SRC lpe-boolops.cpp lpe-circle_3pts.cpp lpe-circle_with_radius.cpp + lpe-clone-original.cpp lpe-constructgrid.cpp lpe-copy_rotate.cpp lpe-curvestitch.cpp @@ -45,6 +46,7 @@ set(live_effects_SRC parameter/bool.cpp parameter/parameter.cpp parameter/path.cpp + parameter/originalpath.cpp parameter/path-reference.cpp parameter/point.cpp parameter/powerstrokepointarray.cpp diff --git a/src/live_effects/Makefile_insert b/src/live_effects/Makefile_insert index 692503201..74356f563 100644 --- a/src/live_effects/Makefile_insert +++ b/src/live_effects/Makefile_insert @@ -72,6 +72,8 @@ ink_common_sources += \ live_effects/lpe-powerstroke-interpolators.h \ live_effects/lpe-offset.cpp \ live_effects/lpe-offset.h \ + live_effects/lpe-clone-original.cpp \ + live_effects/lpe-clone-original.h \ live_effects/lpe-ruler.cpp \ live_effects/lpe-ruler.h \ live_effects/lpe-recursiveskeleton.cpp \ diff --git a/src/live_effects/effect-enum.h b/src/live_effects/effect-enum.h index 535cc2564..43af33b53 100644 --- a/src/live_effects/effect-enum.h +++ b/src/live_effects/effect-enum.h @@ -49,6 +49,7 @@ enum EffectType { RECURSIVE_SKELETON, EXTRUDE, POWERSTROKE, + CLONE_ORIGINAL, INVALID_LPE // This must be last (I made it such that it is not needed anymore I think..., Don't trust on it being last. - johan) }; diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp index 3ce2aeef3..35e87f76c 100644 --- a/src/live_effects/effect.cpp +++ b/src/live_effects/effect.cpp @@ -75,6 +75,7 @@ #include "live_effects/lpe-recursiveskeleton.h" #include "live_effects/lpe-extrude.h" #include "live_effects/lpe-powerstroke.h" +#include "live_effects/lpe-clone-original.h" namespace Inkscape { @@ -122,6 +123,7 @@ const Util::EnumData<EffectType> LPETypeData[] = { {RULER, N_("Ruler"), "ruler"}, /* 0.49 ?*/ {POWERSTROKE, N_("[Unstable!] Power stroke"), "powerstroke"}, + {CLONE_ORIGINAL, N_("[Unstable!] Clone original path"), "clone_original"}, }; const Util::EnumDataConverter<EffectType> LPETypeConverter(LPETypeData, sizeof(LPETypeData)/sizeof(*LPETypeData)); @@ -242,6 +244,9 @@ Effect::New(EffectType lpenr, LivePathEffectObject *lpeobj) case POWERSTROKE: neweffect = static_cast<Effect*> ( new LPEPowerStroke(lpeobj) ); break; + case CLONE_ORIGINAL: + neweffect = static_cast<Effect*> ( new LPECloneOriginal(lpeobj) ); + break; default: g_warning("LivePathEffect::Effect::New called with invalid patheffect type (%d)", lpenr); neweffect = NULL; diff --git a/src/live_effects/lpe-clone-original.cpp b/src/live_effects/lpe-clone-original.cpp new file mode 100644 index 000000000..ce51f4aa2 --- /dev/null +++ b/src/live_effects/lpe-clone-original.cpp @@ -0,0 +1,50 @@ +#define INKSCAPE_LPE_CLONE_ORIGINAL_CPP + +/* + * 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/lpe-clone-original.h" + +#include "display/curve.h" + +namespace Inkscape { +namespace LivePathEffect { + +LPECloneOriginal::LPECloneOriginal(LivePathEffectObject *lpeobject) : + Effect(lpeobject), + linked_path(_("Linked path:"), _("Path from which to take the original path data"), "linkedpath", &wr, this) +{ + registerParameter( dynamic_cast<Parameter *>(&linked_path) ); +} + +LPECloneOriginal::~LPECloneOriginal() +{ + +} + +void LPECloneOriginal::doEffect (SPCurve * curve) +{ + if ( linked_path.linksToPath() ) { + std::vector<Geom::Path> linked_pathv = linked_path.get_pathvector(); + if ( !linked_pathv.empty() ) { + curve->set_pathvector(linked_pathv); + } + } +} + +} // 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/lpe-clone-original.h b/src/live_effects/lpe-clone-original.h new file mode 100644 index 000000000..abf65ded8 --- /dev/null +++ b/src/live_effects/lpe-clone-original.h @@ -0,0 +1,36 @@ +#ifndef INKSCAPE_LPE_CLONE_ORIGINAL_H +#define INKSCAPE_LPE_CLONE_ORIGINAL_H + +/* + * Inkscape::LPECloneOriginal + * + * 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/effect.h" +#include "live_effects/parameter/originalpath.h" + +namespace Inkscape { +namespace LivePathEffect { + +class LPECloneOriginal : public Effect { +public: + LPECloneOriginal(LivePathEffectObject *lpeobject); + virtual ~LPECloneOriginal(); + + virtual void doEffect (SPCurve * curve); + +private: + OriginalPathParam linked_path; + +private: + LPECloneOriginal(const LPECloneOriginal&); + LPECloneOriginal& operator=(const LPECloneOriginal&); +}; + +}; //namespace LivePathEffect +}; //namespace Inkscape + +#endif 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(); |
