summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c325659)
raw | patch | inline | side by side (parent: c325659)
author | cilix42 <cilix42@users.sourceforge.net> | |
Wed, 18 Jun 2008 02:13:55 +0000 (02:13 +0000) | ||
committer | cilix42 <cilix42@users.sourceforge.net> | |
Wed, 18 Jun 2008 02:13:55 +0000 (02:13 +0000) |
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-copy_rotate.cpp | [new file with mode: 0644] | patch | blob |
src/live_effects/lpe-copy_rotate.h | [new file with mode: 0644] | patch | blob |
index 245a9bd60b7463e349c38d61b1bddbbddcd7b055..d0bfb5b998d68ed8fa5c7af8728668907c3549d4 100644 (file)
live_effects/lpe-angle_bisector.cpp \
live_effects/lpe-angle_bisector.h \
live_effects/lpe-parallel.cpp \
- live_effects/lpe-parallel.h
+ live_effects/lpe-parallel.h \
+ live_effects/lpe-copy_rotate.cpp \
+ live_effects/lpe-copy_rotate.h
index 73b5a578685b9a5845e86809a7285736c6422377..08745a74ea331331117954cd5c2f5b44be2b2e76 100644 (file)
#include "live_effects/lpe-circle_3pts.h"
#include "live_effects/lpe-angle_bisector.h"
#include "live_effects/lpe-parallel.h"
+#include "live_effects/lpe-copy_rotate.h"
// end of includes
namespace Inkscape {
{CIRCLE_3PTS, N_("Circle through 3 points"), "circle_3pts"},
{ANGLE_BISECTOR, N_("Angle bisector"), "angle_bisector"},
{PARALLEL, N_("Parallel"), "parallel"},
+ {COPY_ROTATE, N_("Rotate copies"), "copy_rotate"},
};
const Util::EnumDataConverter<EffectType> LPETypeConverter(LPETypeData, INVALID_LPE);
case PARALLEL:
neweffect = static_cast<Effect*> ( new LPEParallel(lpeobj) );
break;
+ case COPY_ROTATE:
+ neweffect = static_cast<Effect*> ( new LPECopyRotate(lpeobj) );
+ break;
default:
g_warning("LivePathEffect::Effect::New called with invalid patheffect type (%d)", lpenr);
neweffect = NULL;
index 09a07039a6de36bfec62be1d9ccb11c5e4f7253f..672b90b87cb71bcdacaf3d2b9198be920041e06a 100644 (file)
CIRCLE_3PTS,
ANGLE_BISECTOR,
PARALLEL,
+ COPY_ROTATE,
INVALID_LPE // This must be last
};
diff --git a/src/live_effects/lpe-copy_rotate.cpp b/src/live_effects/lpe-copy_rotate.cpp
--- /dev/null
@@ -0,0 +1,83 @@
+#define INKSCAPE_LPE_COPY_ROTATE_CPP
+/** \file
+ * LPE <copy_rotate> implementation
+ */
+/*
+ * Authors:
+ * Maximilian Albert
+ *
+ * Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl>
+ * Copyright (C) Maximilian Albert 2008 <maximilian.albert@gmail.com>
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "live_effects/lpe-copy_rotate.h"
+#include "sp-shape.h"
+#include "display/curve.h"
+
+#include <2geom/path.h>
+#include <2geom/transforms.h>
+#include <2geom/d2-sbasis.h>
+
+namespace Inkscape {
+namespace LivePathEffect {
+
+LPECopyRotate::LPECopyRotate(LivePathEffectObject *lpeobject) :
+ Effect(lpeobject),
+ angle(_("Angle"), _("Angle"), "angle", &wr, this, 30.0),
+ num_copies(_("Number of copies"), _("Number of copies of the original path"), "num_copies", &wr, this, 1),
+ origin(_("Origin"), _("Origin of the rotation"), "origin", &wr, this)
+{
+ show_orig_path = true;
+
+ // register all your parameters here, so Inkscape knows which parameters this effect has:
+ registerParameter( dynamic_cast<Parameter *>(&angle) );
+ registerParameter( dynamic_cast<Parameter *>(&num_copies) );
+ registerParameter( dynamic_cast<Parameter *>(&origin) );
+
+ num_copies.param_make_integer(true);
+}
+
+LPECopyRotate::~LPECopyRotate()
+{
+
+}
+
+void
+LPECopyRotate::doOnApply(SPLPEItem *lpeitem)
+{
+ origin.param_setValue(SP_SHAPE(lpeitem)->curve->first_point().to_2geom());
+}
+
+Geom::Piecewise<Geom::D2<Geom::SBasis> >
+LPECopyRotate::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_in)
+{
+ using namespace Geom;
+
+ Piecewise<D2<SBasis> > output;
+
+ for (int i = 1; i <= num_copies; ++i) {
+ Rotate rot(deg_to_rad(angle * i));
+ Matrix t = Translate(-origin) * rot * Translate(origin);
+ output.concat(pwd2_in * t);
+ }
+
+ 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-copy_rotate.h b/src/live_effects/lpe-copy_rotate.h
--- /dev/null
@@ -0,0 +1,56 @@
+#ifndef INKSCAPE_LPE_COPY_ROTATE_H
+#define INKSCAPE_LPE_COPY_ROTATE_H
+
+/** \file
+ * LPE <copy_rotate> implementation, see lpe-copy_rotate.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/point.h"
+
+namespace Inkscape {
+namespace LivePathEffect {
+
+class LPECopyRotate : public Effect {
+public:
+ LPECopyRotate(LivePathEffectObject *lpeobject);
+ virtual ~LPECopyRotate();
+
+ virtual void doOnApply (SPLPEItem *lpeitem);
+
+ virtual Geom::Piecewise<Geom::D2<Geom::SBasis> > doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_in);
+
+private:
+ ScalarParam angle;
+ ScalarParam num_copies;
+
+ PointParam origin;
+
+ LPECopyRotate(const LPECopyRotate&);
+ LPECopyRotate& operator=(const LPECopyRotate&);
+};
+
+} //namespace LivePathEffect
+} //namespace Inkscape
+
+#endif
+
+/*
+ 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 :