summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 681efa8)
raw | patch | inline | side by side (parent: 681efa8)
author | johanengelen <johanengelen@users.sourceforge.net> | |
Thu, 8 May 2008 18:52:45 +0000 (18:52 +0000) | ||
committer | johanengelen <johanengelen@users.sourceforge.net> | |
Thu, 8 May 2008 18:52:45 +0000 (18:52 +0000) |
src/live_effects/effect.cpp | patch | blob | history | |
src/live_effects/effect.h | patch | blob | history | |
src/live_effects/lpe-constructgrid.cpp | [new file with mode: 0644] | patch | blob |
src/live_effects/lpe-constructgrid.h | [new file with mode: 0644] | patch | blob |
index cee0c0b211943b356d9d79a77048e62bd2a67199..2cd88fd8b0901748889d70c74a455ae28401895e 100644 (file)
#include "live_effects/lpe-circle_with_radius.h"
#include "live_effects/lpe-perspective_path.h"
#include "live_effects/lpe-spiro.h"
+#include "live_effects/lpe-constructgrid.h"
#include "nodepath.h"
{CIRCLE_WITH_RADIUS, N_("Circle (center+radius)"), "circle_with_radius"},
{PERSPECTIVE_PATH, N_("Perspective path"), "perspective_path"},
{SPIRO, N_("Spiro spline"), "spiro"},
+ {CONSTRUCT_GRID, N_("Construct grid"), "construct_grid"},
};
const Util::EnumDataConverter<EffectType> LPETypeConverter(LPETypeData, INVALID_LPE);
case SPIRO:
neweffect = static_cast<Effect*> ( new LPESpiro(lpeobj) );
break;
+ case CONSTRUCT_GRID:
+ neweffect = static_cast<Effect*> ( new LPEConstructGrid(lpeobj) );
+ break;
default:
g_warning("LivePathEffect::Effect::New called with invalid patheffect type (%d)", lpenr);
neweffect = NULL;
index 603b0715e266de72b92d8cd70d62a767aa3e6cf3..58010358fc5bf5447a1b4851497eb8264816a67a 100644 (file)
CIRCLE_WITH_RADIUS,
PERSPECTIVE_PATH,
SPIRO,
+ CONSTRUCT_GRID,
INVALID_LPE // This must be last
};
diff --git a/src/live_effects/lpe-constructgrid.cpp b/src/live_effects/lpe-constructgrid.cpp
--- /dev/null
@@ -0,0 +1,103 @@
+#define INKSCAPE_LPE_CONSTRUCTGRID_CPP\r
+/** \file\r
+ * LPE Construct Grid implementation\r
+ */\r
+/*\r
+ * Authors:\r
+ * Johan Engelen\r
+*\r
+* Copyright (C) Johan Engelen 2008 <j.b.c.engelen@utwente.nl>\r
+ *\r
+ * Released under GNU GPL, read the file 'COPYING' for more information\r
+ */\r
+\r
+#include "live_effects/lpe-constructgrid.h"\r
+\r
+#include <2geom/path.h>\r
+#include <2geom/transforms.h>\r
+\r
+#include "nodepath.h"\r
+\r
+namespace Inkscape {\r
+namespace LivePathEffect {\r
+\r
+using namespace Geom;\r
+\r
+LPEConstructGrid::LPEConstructGrid(LivePathEffectObject *lpeobject) :\r
+ Effect(lpeobject),\r
+ nr_x(_("Size X"), _("The size of the grid in X direction."), "nr_x", &wr, this, 5),\r
+ nr_y(_("Size Y"), _("The size of the grid in Y direction."), "nr_y", &wr, this, 5)\r
+{\r
+ registerParameter( dynamic_cast<Parameter *>(&nr_x) );\r
+ registerParameter( dynamic_cast<Parameter *>(&nr_y) );\r
+\r
+ nr_x.param_make_integer();\r
+ nr_y.param_make_integer();\r
+ nr_x.param_set_range(1, NR_HUGE);\r
+ nr_y.param_set_range(1, NR_HUGE);\r
+}\r
+\r
+LPEConstructGrid::~LPEConstructGrid()\r
+{\r
+\r
+}\r
+\r
+std::vector<Geom::Path>\r
+LPEConstructGrid::doEffect_path (std::vector<Geom::Path> const & path_in)\r
+{\r
+ // Check that the path has at least 3 nodes (i.e. 2 segments), more nodes are ignored\r
+ if (path_in[0].size() >= 2) {\r
+ // read the first 3 nodes:\r
+ Geom::Path::const_iterator it ( path_in[0].begin() );\r
+ Geom::Point first_p = (*it++).initialPoint();\r
+ Geom::Point origin = (*it++).initialPoint();\r
+ Geom::Point second_p = (*it++).initialPoint();\r
+ // make first_p and second_p be the construction *vectors* of the grid:\r
+ first_p -= origin;\r
+ second_p -= origin;\r
+ Geom::Translate first_translation( first_p );\r
+ Geom::Translate second_translation( second_p );\r
+\r
+ // create the gridpaths of the two directions\r
+ Geom::Path first_path( origin );\r
+ first_path.appendNew<LineSegment>( origin + first_p*nr_y );\r
+ Geom::Path second_path( origin );\r
+ second_path.appendNew<LineSegment>( origin + second_p*nr_x );\r
+\r
+ // use the gridpaths and set them in the correct grid\r
+ std::vector<Geom::Path> path_out;\r
+ path_out.push_back(first_path);\r
+ for (int ix = 0; ix < nr_x; ix++) {\r
+ path_out.push_back(path_out.back() * second_translation );\r
+ }\r
+ path_out.push_back(second_path);\r
+ for (int iy = 0; iy < nr_y; iy++) {\r
+ path_out.push_back(path_out.back() * first_translation );\r
+ }\r
+\r
+ return path_out;\r
+ } else {\r
+ return path_in;\r
+ }\r
+}\r
+\r
+void\r
+LPEConstructGrid::setup_nodepath(Inkscape::NodePath::Path *np)\r
+{\r
+ Effect::setup_nodepath(np);\r
+ sp_nodepath_make_straight_path(np);\r
+}\r
+\r
+} //namespace LivePathEffect\r
+} /* namespace Inkscape */\r
+\r
+/*\r
+ Local Variables:\r
+ mode:c++\r
+ c-file-style:"stroustrup"\r
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))\r
+ indent-tabs-mode:nil\r
+ fill-column:99\r
+ End:\r
+*/\r
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :\r
diff --git a/src/live_effects/lpe-constructgrid.h b/src/live_effects/lpe-constructgrid.h
--- /dev/null
@@ -0,0 +1,43 @@
+#ifndef INKSCAPE_LPE_CONSTRUCTGRID_H\r
+#define INKSCAPE_LPE_CONSTRUCTGRID_H\r
+\r
+/** \file\r
+ * Implementation of the construct grid LPE, see lpe-constructgrid.cpp\r
+ */\r
+\r
+/*\r
+ * Authors:\r
+ * Johan Engelen\r
+*\r
+* Copyright (C) Johan Engelen 2008 <j.b.c.engelen@utwente.nl>\r
+ *\r
+ * Released under GNU GPL, read the file 'COPYING' for more information\r
+ */\r
+\r
+#include "live_effects/effect.h"\r
+#include "live_effects/parameter/parameter.h"\r
+\r
+namespace Inkscape {\r
+namespace LivePathEffect {\r
+\r
+class LPEConstructGrid : public Effect {\r
+public:\r
+ LPEConstructGrid(LivePathEffectObject *lpeobject);\r
+ virtual ~LPEConstructGrid();\r
+\r
+ virtual std::vector<Geom::Path> doEffect_path (std::vector<Geom::Path> const & path_in);\r
+\r
+ virtual void setup_nodepath(Inkscape::NodePath::Path *np);\r
+\r
+private:\r
+ ScalarParam nr_x;\r
+ ScalarParam nr_y;\r
+\r
+ LPEConstructGrid(const LPEConstructGrid&);\r
+ LPEConstructGrid& operator=(const LPEConstructGrid&);\r
+};\r
+\r
+} //namespace LivePathEffect\r
+} //namespace Inkscape\r
+\r
+#endif // INKSCAPE_LPE_CONSTRUCTGRID_H\r