diff options
| author | Maximilian Albert <maximilian.albert@gmail.com> | 2008-06-18 02:13:55 +0000 |
|---|---|---|
| committer | cilix42 <cilix42@users.sourceforge.net> | 2008-06-18 02:13:55 +0000 |
| commit | d92779f71e03f35d7cb2a29c0cb8c8065eff8fe6 (patch) | |
| tree | 805184533d9db13929c7d645b2b2dbdc308793a9 /src | |
| parent | update 2geom (diff) | |
| download | inkscape-d92779f71e03f35d7cb2a29c0cb8c8065eff8fe6.tar.gz inkscape-d92779f71e03f35d7cb2a29c0cb8c8065eff8fe6.zip | |
New LPE: Copy rotate
(bzr r5978)
Diffstat (limited to 'src')
| -rw-r--r-- | src/live_effects/Makefile_insert | 4 | ||||
| -rw-r--r-- | src/live_effects/effect.cpp | 5 | ||||
| -rw-r--r-- | src/live_effects/effect.h | 1 | ||||
| -rw-r--r-- | src/live_effects/lpe-copy_rotate.cpp | 83 | ||||
| -rw-r--r-- | src/live_effects/lpe-copy_rotate.h | 56 |
5 files changed, 148 insertions, 1 deletions
diff --git a/src/live_effects/Makefile_insert b/src/live_effects/Makefile_insert index 245a9bd60..d0bfb5b99 100644 --- a/src/live_effects/Makefile_insert +++ b/src/live_effects/Makefile_insert @@ -58,5 +58,7 @@ live_effects_liblive_effects_a_SOURCES = \ 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 diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp index 73b5a5786..08745a74e 100644 --- a/src/live_effects/effect.cpp +++ b/src/live_effects/effect.cpp @@ -59,6 +59,7 @@ #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 { @@ -89,6 +90,7 @@ const Util::EnumData<EffectType> LPETypeData[INVALID_LPE] = { {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); @@ -159,6 +161,9 @@ Effect::New(EffectType lpenr, LivePathEffectObject *lpeobj) 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; diff --git a/src/live_effects/effect.h b/src/live_effects/effect.h index 09a07039a..672b90b87 100644 --- a/src/live_effects/effect.h +++ b/src/live_effects/effect.h @@ -76,6 +76,7 @@ enum EffectType { 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 new file mode 100644 index 000000000..e3f996a1b --- /dev/null +++ b/src/live_effects/lpe-copy_rotate.cpp @@ -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 new file mode 100644 index 000000000..72b46b5d6 --- /dev/null +++ b/src/live_effects/lpe-copy_rotate.h @@ -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 : |
