From 6b758e6a30ea6f0a640c847643b78d9b109dc5b2 Mon Sep 17 00:00:00 2001 From: Johan Engelen Date: Tue, 27 Jul 2010 01:43:02 +0200 Subject: [PATCH] more powerstroke build infrastructure --- src/live_effects/lpe-powerstroke.cpp | 29 +++------------------- src/live_effects/lpe-powerstroke.h | 16 ++---------- src/live_effects/parameter/CMakeLists.txt | 1 + src/live_effects/parameter/Makefile_insert | 2 ++ src/live_effects/parameter/array.cpp | 16 ++++++++++++ 5 files changed, 24 insertions(+), 40 deletions(-) diff --git a/src/live_effects/lpe-powerstroke.cpp b/src/live_effects/lpe-powerstroke.cpp index c3de621ee..b349f9aa6 100644 --- a/src/live_effects/lpe-powerstroke.cpp +++ b/src/live_effects/lpe-powerstroke.cpp @@ -28,18 +28,15 @@ LPEPowerStroke::LPEPowerStroke(LivePathEffectObject *lpeobject) : Effect(lpeobject), offset_1(_("Start Offset"), _("Handle to control the distance of the offset from the curve"), "offset_1", &wr, this), offset_2(_("End Offset"), _("Handle to control the distance of the offset from the curve"), "offset_2", &wr, this), - offset_3(_("End Offset"), _("Handle to control the distance of the offset from the curve"), "offset_3", &wr, this) -// offset_points(_("Offset points"), _("Offset points"), "offset_points", &wr, this) + offset_3(_("End Offset"), _("Handle to control the distance of the offset from the curve"), "offset_3", &wr, this), + offset_points(_("Offset points"), _("Offset points"), "offset_points", &wr, this) { show_orig_path = true; registerParameter( dynamic_cast(&offset_1) ); registerParameter( dynamic_cast(&offset_2) ); registerParameter( dynamic_cast(&offset_3) ); -// registerParameter( dynamic_cast(&offset_points) ); - - /* register all your knotholder handles here: */ - //registerKnotHolderHandle(new PowerStroke::KnotHolderEntityAttachMyHandle(), _("help message")); + registerParameter( dynamic_cast(&offset_points) ); } LPEPowerStroke::~LPEPowerStroke() @@ -119,26 +116,6 @@ LPEPowerStroke::doEffect_pwd2 (Geom::Piecewise > const & return output; } - -/* ######################## - * Define the classes for your knotholder handles here - */ - -/* -namespace PowerStroke { - -class KnotHolderEntityMyHandle : public LPEKnotHolderEntity -{ -public: - // the set() and get() methods must be implemented, click() is optional - virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state); - virtual Geom::Point knot_get(); - //virtual void knot_click(guint state); -}; - -} // namespace PowerStroke -*/ - /* ######################## */ } //namespace LivePathEffect diff --git a/src/live_effects/lpe-powerstroke.h b/src/live_effects/lpe-powerstroke.h index 9c6e3effe..811c63259 100644 --- a/src/live_effects/lpe-powerstroke.h +++ b/src/live_effects/lpe-powerstroke.h @@ -14,20 +14,11 @@ #include "live_effects/effect.h" #include "live_effects/parameter/point.h" -#include "live_effects/parameter/array.h" +#include "live_effects/parameter/powerstrokepointarray.h" namespace Inkscape { namespace LivePathEffect { -// each knotholder handle for your LPE requires a separate class derived from KnotHolderEntity; -// define it in lpe-powerstroke.cpp and register it in the effect's constructor -/** -namespace PowerStroke { - // we need a separate namespace to avoid clashes with other LPEs - class KnotHolderEntityMyHandle; -} -**/ - class LPEPowerStroke : public Effect { public: LPEPowerStroke(LivePathEffectObject *lpeobject); @@ -37,14 +28,11 @@ public: virtual void doOnApply(SPLPEItem *lpeitem); - /* the knotholder entity classes (if any) must be declared friends */ - //friend class PowerStroke::KnotHolderEntityMyHandle; - private: PointParam offset_1; PointParam offset_2; PointParam offset_3; -// ArrayParam offset_points; + PowerStrokePointArrayParam offset_points; LPEPowerStroke(const LPEPowerStroke&); LPEPowerStroke& operator=(const LPEPowerStroke&); diff --git a/src/live_effects/parameter/CMakeLists.txt b/src/live_effects/parameter/CMakeLists.txt index 2fa0d5bc6..8657b2bec 100644 --- a/src/live_effects/parameter/CMakeLists.txt +++ b/src/live_effects/parameter/CMakeLists.txt @@ -5,6 +5,7 @@ parameter.cpp path.cpp path-reference.cpp point.cpp +powerstrokepointarray.cpp random.cpp text.cpp unit.cpp diff --git a/src/live_effects/parameter/Makefile_insert b/src/live_effects/parameter/Makefile_insert index 74b166e8b..99cd88d62 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/powerstrokepointarray.cpp \ + live_effects/parameter/powerstrokepointarray.h \ live_effects/parameter/text.cpp \ live_effects/parameter/text.h \ live_effects/parameter/unit.cpp \ diff --git a/src/live_effects/parameter/array.cpp b/src/live_effects/parameter/array.cpp index c576bedd5..d1c30edf7 100644 --- a/src/live_effects/parameter/array.cpp +++ b/src/live_effects/parameter/array.cpp @@ -12,6 +12,7 @@ #include "svg/stringstream.h" #include <2geom/coord.h> +#include <2geom/point.h> namespace Inkscape { @@ -35,6 +36,21 @@ ArrayParam::readsvg(const gchar * str) return newx; } +template <> +Geom::Point +ArrayParam::readsvg(const gchar * str) +{ + gchar ** strarray = g_strsplit(str, ",", 2); + double newx, newy; + unsigned int success = sp_svg_number_read_d(strarray[0], &newx); + success += sp_svg_number_read_d(strarray[1], &newy); + g_strfreev (strarray); + if (success == 2) { + return Geom::Point(newx, newy); + } + return Geom::Point(Geom::infinity(),Geom::infinity()); +} + } /* namespace LivePathEffect */ } /* namespace Inkscape */ -- 2.30.2