summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: b646aaa)
raw | patch | inline | side by side (parent: b646aaa)
author | cilix42 <cilix42@users.sourceforge.net> | |
Sun, 30 Mar 2008 16:42:27 +0000 (16:42 +0000) | ||
committer | cilix42 <cilix42@users.sourceforge.net> | |
Sun, 30 Mar 2008 16:42:27 +0000 (16:42 +0000) |
This is just a proof-of-concept implementation for my tech drawing proposal for GSoC '08.
src/live_effects/Makefile_insert | patch | blob | history | |
src/live_effects/effect.cpp | patch | blob | history | |
src/live_effects/effect.h | patch | blob | history | |
src/live_effects/lpe-circle_with_radius.cpp | [new file with mode: 0644] | patch | blob |
src/live_effects/lpe-circle_with_radius.h | [new file with mode: 0644] | patch | blob |
index fee34a9d675341322e76e1e3175fa98c6494b416..0c6ba4a0099ee48163b186096d1e3992a9bcb604 100644 (file)
live_effects/lpe-test-doEffect-stack.cpp \
live_effects/lpe-test-doEffect-stack.h \
live_effects/lpe-slant.cpp \
- live_effects/lpe-slant.h
+ live_effects/lpe-slant.h \
+ live_effects/lpe-circle_with_radius.cpp \
+ live_effects/lpe-circle_with_radius.h
index dc43af0d5073023a93f7fbfaeef94c7fee01e999..48a3ab9ff02112c5f74c2c92fd49f17d4ce8b1d6 100644 (file)
#include "live_effects/lpe-test-doEffect-stack.h"
#include "live_effects/lpe-gears.h"
#include "live_effects/lpe-curvestitch.h"
+#include "live_effects/lpe-circle_with_radius.h"
#include "nodepath.h"
{DOEFFECTSTACK_TEST, N_("doEffect stack test"), "doeffectstacktest"},
#endif
{GEARS, N_("Gears"), "gears"},
- {CURVE_STITCH, N_("Stitch Sub-Paths"), "curvestitching"},
+ {CURVE_STITCH, N_("Stitch Sub-Paths"), "curvestitching"},
+ {CIRCLE_WITH_RADIUS, N_("Circle (center+radius)"), "circle_with_radius"},
};
const Util::EnumDataConverter<EffectType> LPETypeConverter(LPETypeData, INVALID_LPE);
case CURVE_STITCH:
neweffect = (Effect*) new LPECurveStitch(lpeobj);
break;
+ case CIRCLE_WITH_RADIUS:
+ neweffect = (Effect*) new LPECircleWithRadius(lpeobj);
+ break;
default:
g_warning("LivePathEffect::Effect::New called with invalid patheffect type (%d)", lpenr);
neweffect = NULL;
index b13ec5f6d1428d4254ddce176b5ea3c4b52c968d..f3143124b9668b9ce0354d4c97c1c9eb2e33c4d3 100644 (file)
#endif
GEARS,
CURVE_STITCH,
+ CIRCLE_WITH_RADIUS,
INVALID_LPE // This must be last
};
diff --git a/src/live_effects/lpe-circle_with_radius.cpp b/src/live_effects/lpe-circle_with_radius.cpp
--- /dev/null
@@ -0,0 +1,113 @@
+#define INKSCAPE_LPE_CIRCLE_WITH_RADIUS_CPP
+/** \file
+ * LPE <circle_with_radius> implementation, used as an example for a base starting class
+ * when implementing new LivePathEffects.
+ *
+ * In vi, three global search-and-replaces will let you rename everything
+ * in this and the .h file:
+ *
+ * :%s/CIRCLE_WITH_RADIUS/YOURNAME/g
+ * :%s/CircleWithRadius/Yourname/g
+ * :%s/circle_with_radius/yourname/g
+ */
+/*
+ * Authors:
+ * Johan Engelen
+*
+* Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl>
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "live_effects/lpe-circle_with_radius.h"
+#include "display/curve.h"
+#include <libnr/n-art-bpath.h>
+
+// You might need to include other 2geom files. You can add them here:
+#include <2geom/path.h>
+#include <2geom/sbasis.h>
+#include <2geom/bezier-to-sbasis.h>
+#include <2geom/d2.h>
+
+using namespace Geom;
+
+namespace Inkscape {
+namespace LivePathEffect {
+
+LPECircleWithRadius::LPECircleWithRadius(LivePathEffectObject *lpeobject) :
+ Effect(lpeobject)//,
+ // initialise your parameters here:
+ //radius(_("Float parameter"), _("just a real number like 1.4!"), "svgname", &wr, this, 50)
+{
+ // register all your parameters here, so Inkscape knows which parameters this effect has:
+ //registerParameter( dynamic_cast<Parameter *>(&radius) );
+}
+
+LPECircleWithRadius::~LPECircleWithRadius()
+{
+
+}
+
+
+/* ########################
+ * Choose to implement one of the doEffect functions. You can delete or comment out the others.
+*/
+
+D2<SBasis> _circle(Geom::Point center, double radius) {
+ D2<SBasis> B;
+ Linear bo = Linear(0, 2 * M_PI);
+
+ B[0] = cos(bo,2);
+ B[1] = sin(bo,2);
+
+ B = B*radius + center;
+ return B;
+}
+
+std::vector<Geom::Path>
+LPECircleWithRadius::doEffect_path (std::vector<Geom::Path> & path_in)
+{
+ std::vector<Geom::Path> path_out = std::vector<Geom::Path>();
+ Geom::Path pb;
+
+ Geom::Point center = path_in[0].initialPoint();
+ Geom::Point pt = path_in[0].finalPoint();
+
+ double radius = Geom::L2(pt - center);
+
+ pb.append(SBasisCurve(_circle(center, radius)));
+
+ path_out.push_back(pb);
+
+ return path_out;
+}
+
+/*
+
+Geom::Piecewise<Geom::D2<Geom::SBasis> >
+LPECircleWithRadius::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > & pwd2_in)
+{
+ Geom::Piecewise<Geom::D2<Geom::SBasis> > output;
+
+ output = pwd2_in; // spice this up to make the effect actually *do* something!
+
+ return output;
+}
+
+*/
+
+/* ######################## */
+
+} //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-circle_with_radius.h b/src/live_effects/lpe-circle_with_radius.h
--- /dev/null
@@ -0,0 +1,45 @@
+#ifndef INKSCAPE_LPE_CIRCLE_WITH_RADIUS_H
+#define INKSCAPE_LPE_CIRCLE_WITH_RADIUS_H
+
+/** \file
+ * LPE <circle_with_radius> implementation, see lpe-circle_with_radius.cpp.
+ */
+
+/*
+ * Authors:
+ * Johan Engelen
+*
+* Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl>
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "live_effects/effect.h"
+#include "live_effects/parameter/parameter.h"
+#include "live_effects/parameter/path.h"
+#include "live_effects/parameter/point.h"
+
+namespace Inkscape {
+namespace LivePathEffect {
+
+class LPECircleWithRadius : public Effect {
+public:
+ LPECircleWithRadius(LivePathEffectObject *lpeobject);
+ virtual ~LPECircleWithRadius();
+
+// Choose to implement one of the doEffect functions. You can delete or comment out the others.
+ virtual std::vector<Geom::Path> doEffect_path (std::vector<Geom::Path> & path_in);
+
+private:
+ // add the parameters for your effect here:
+ //ScalarParam radius;
+ // there are all kinds of parameters. Check the /live_effects/parameter directory which types exist!
+
+ LPECircleWithRadius(const LPECircleWithRadius&);
+ LPECircleWithRadius& operator=(const LPECircleWithRadius&);
+};
+
+} //namespace LivePathEffect
+} //namespace Inkscape
+
+#endif