summaryrefslogtreecommitdiffstats
path: root/src/live_effects
diff options
context:
space:
mode:
authorJohan B. C. Engelen <jbc.engelen@swissonline.ch>2007-10-30 22:37:20 +0000
committerjohanengelen <johanengelen@users.sourceforge.net>2007-10-30 22:37:20 +0000
commit2fb0d596bc5823f8d72a8a4262e147231170c9cd (patch)
tree8bee900fb0996e66b273f598174f67bd12375407 /src/live_effects
parentr16896@shi: ted | 2007-10-30 12:16:06 -0700 (diff)
downloadinkscape-2fb0d596bc5823f8d72a8a4262e147231170c9cd.tar.gz
inkscape-2fb0d596bc5823f8d72a8a4262e147231170c9cd.zip
LPE: implement NEW path-along-path effect, i think that old one has become obsolete and is renamed accordingly. implement straight path node editting for gears effect.
(bzr r3983)
Diffstat (limited to 'src/live_effects')
-rw-r--r--src/live_effects/effect.cpp18
-rw-r--r--src/live_effects/effect.h18
-rw-r--r--src/live_effects/lpe-gears.cpp2
-rw-r--r--src/live_effects/parameter/path.cpp9
-rw-r--r--src/live_effects/parameter/path.h2
5 files changed, 41 insertions, 8 deletions
diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp
index 3802066ec..859bf8230 100644
--- a/src/live_effects/effect.cpp
+++ b/src/live_effects/effect.cpp
@@ -29,6 +29,7 @@
// include effects:
#include "live_effects/lpe-skeletalstrokes.h"
+#include "live_effects/lpe-pathalongpath.h"
#include "live_effects/lpe-slant.h"
#include "live_effects/lpe-test-doEffect-stack.h"
#include "live_effects/lpe-gears.h"
@@ -40,7 +41,8 @@ namespace LivePathEffect {
const Util::EnumData<EffectType> LPETypeData[INVALID_LPE] = {
// {constant defined in effect.h, N_("name of your effect"), "name of your effect in SVG"}
- {SKELETAL_STROKES, N_("Path along path"), "skeletal"},
+ {PATH_ALONG_PATH, N_("Path along path"), "path_along_path"},
+ {SKELETAL_STROKES, N_("[obsolete?] Pattern along path"), "skeletal"},
#ifdef LPE_ENABLE_TEST_EFFECTS
{SLANT, N_("Slant"), "slant"},
{DOEFFECTSTACK_TEST, N_("doEffect stack test"), "doeffectstacktest"},
@@ -58,6 +60,9 @@ Effect::New(EffectType lpenr, LivePathEffectObject *lpeobj)
case SKELETAL_STROKES:
neweffect = (Effect*) new LPESkeletalStrokes(lpeobj);
break;
+ case PATH_ALONG_PATH:
+ neweffect = (Effect*) new LPEPathAlongPath(lpeobj);
+ break;
#ifdef LPE_ENABLE_TEST_EFFECTS
case SLANT:
neweffect = (Effect*) new LPESlant(lpeobj);
@@ -91,6 +96,7 @@ Effect::Effect(LivePathEffectObject *lpeobject)
tooltips = NULL;
lpeobj = lpeobject;
oncanvasedit_it = param_map.begin();
+ straight_original_path = false;
}
Effect::~Effect()
@@ -303,6 +309,16 @@ Effect::editNextParamOncanvas(SPItem * item, SPDesktop * desktop)
}
}
+/* This function should reset the defaults and is used for example to initialize an effect right after it has been applied to a path
+* The nice thing about this is that this function can use knowledge of the original path and set things accordingly for example to the size or origin of the original path!
+*/
+void
+Effect::resetDefaults(SPItem * /*item*/)
+{
+ // do nothing for simple effects
+}
+
+
} /* namespace LivePathEffect */
} /* namespace Inkscape */
diff --git a/src/live_effects/effect.h b/src/live_effects/effect.h
index 844a158b5..07dd72e47 100644
--- a/src/live_effects/effect.h
+++ b/src/live_effects/effect.h
@@ -42,7 +42,8 @@ namespace XML {
namespace LivePathEffect {
enum EffectType {
- SKELETAL_STROKES = 0,
+ PATH_ALONG_PATH = 0,
+ SKELETAL_STROKES,
#ifdef LPE_ENABLE_TEST_EFFECTS
SLANT,
DOEFFECTSTACK_TEST,
@@ -59,18 +60,19 @@ class Parameter;
class Effect {
public:
- virtual ~Effect();
+ static Effect* New(EffectType lpenr, LivePathEffectObject *lpeobj);
- Glib::ustring getName();
+ virtual ~Effect();
virtual void doEffect (SPCurve * curve);
- static Effect* New(EffectType lpenr, LivePathEffectObject *lpeobj);
-
virtual Gtk::Widget * getWidget();
- Inkscape::XML::Node * getRepr();
- SPDocument * getSPDoc();
+ virtual void resetDefaults(SPItem * item);
+
+ Glib::ustring getName();
+ Inkscape::XML::Node * getRepr();
+ SPDocument * getSPDoc();
LivePathEffectObject * getLPEObj() {return lpeobj;};
void readallParameters(Inkscape::XML::Node * repr);
@@ -78,6 +80,8 @@ public:
void editNextParamOncanvas(SPItem * item, SPDesktop * desktop);
+ bool straight_original_path;
+
protected:
Effect(LivePathEffectObject *lpeobject);
diff --git a/src/live_effects/lpe-gears.cpp b/src/live_effects/lpe-gears.cpp
index 2176f3ba7..30500e3ab 100644
--- a/src/live_effects/lpe-gears.cpp
+++ b/src/live_effects/lpe-gears.cpp
@@ -212,6 +212,8 @@ LPEGears::LPEGears(LivePathEffectObject *lpeobject) :
{
registerParameter( dynamic_cast<Parameter *>(&teeth) );
registerParameter( dynamic_cast<Parameter *>(&phi) );
+
+ straight_original_path = true;
}
LPEGears::~LPEGears()
diff --git a/src/live_effects/parameter/path.cpp b/src/live_effects/parameter/path.cpp
index 2b558d2dd..68f7be4a9 100644
--- a/src/live_effects/parameter/path.cpp
+++ b/src/live_effects/parameter/path.cpp
@@ -147,6 +147,15 @@ PathParam::param_write_to_repr(const char * svgd)
}
+void
+PathParam::param_set_and_write_new_value (Geom::Piecewise<Geom::D2<Geom::SBasis> > newpath)
+{
+ const std::vector<Geom::Path> temppath = Geom::path_from_piecewise(newpath, LPE_CONVERSION_TOLERANCE);
+ gchar * svgd = SVGD_from_2GeomPath( temppath );
+ param_write_to_repr(svgd);
+ g_free(svgd);
+}
+
/* CALLBACK FUNCTIONS FOR THE BUTTONS */
void
PathParam::on_edit_button_click()
diff --git a/src/live_effects/parameter/path.h b/src/live_effects/parameter/path.h
index 6ba6e7e4b..23f168c48 100644
--- a/src/live_effects/parameter/path.h
+++ b/src/live_effects/parameter/path.h
@@ -44,6 +44,8 @@ public:
void param_set_default();
+ void param_set_and_write_new_value (Geom::Piecewise<Geom::D2<Geom::SBasis> > newpath);
+
void param_editOncanvas(SPItem * item, SPDesktop * dt);
sigc::signal <void> signal_path_pasted;