summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJohan B. C. Engelen <jbc.engelen@swissonline.ch>2008-07-16 21:42:46 +0000
committerjohanengelen <johanengelen@users.sourceforge.net>2008-07-16 21:42:46 +0000
commit72f6706daefad31dd0a93b315e03269dac18e2ad (patch)
tree3a4af45cf44cf7b11594dd293d433673d185b84e /src
parentfix combo enum, to handle enums of all types (not only the ones that range fr... (diff)
downloadinkscape-72f6706daefad31dd0a93b315e03269dac18e2ad.tar.gz
inkscape-72f6706daefad31dd0a93b315e03269dac18e2ad.zip
add lpe-Boolops
(bzr r6334)
Diffstat (limited to 'src')
-rw-r--r--src/live_effects/CMakeLists.txt1
-rw-r--r--src/live_effects/Makefile_insert2
-rw-r--r--src/live_effects/effect.cpp5
-rw-r--r--src/live_effects/effect.h1
-rw-r--r--src/live_effects/lpe-boolops.cpp80
-rw-r--r--src/live_effects/lpe-boolops.h53
6 files changed, 142 insertions, 0 deletions
diff --git a/src/live_effects/CMakeLists.txt b/src/live_effects/CMakeLists.txt
index c50c10357..79d403601 100644
--- a/src/live_effects/CMakeLists.txt
+++ b/src/live_effects/CMakeLists.txt
@@ -2,6 +2,7 @@ SET(live_effects_SRC
bezctx.cpp
effect.cpp
lpe-bendpath.cpp
+lpe-boolops.cpp
lpe-circle_with_radius.cpp
lpe-constructgrid.cpp
lpe-curvestitch.cpp
diff --git a/src/live_effects/Makefile_insert b/src/live_effects/Makefile_insert
index d3f50cd9a..e651418d3 100644
--- a/src/live_effects/Makefile_insert
+++ b/src/live_effects/Makefile_insert
@@ -18,6 +18,8 @@ live_effects_liblive_effects_a_SOURCES = \
live_effects/lpe-patternalongpath.h \
live_effects/lpe-bendpath.cpp \
live_effects/lpe-bendpath.h \
+ live_effects/lpe-boolops.cpp \
+ live_effects/lpe-boolops.h \
live_effects/lpe-sketch.cpp \
live_effects/lpe-sketch.h \
live_effects/lpe-knot.cpp \
diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp
index 4c74d56a6..ad9024772 100644
--- a/src/live_effects/effect.cpp
+++ b/src/live_effects/effect.cpp
@@ -62,6 +62,7 @@
#include "live_effects/lpe-copy_rotate.h"
#include "live_effects/lpe-offset.h"
#include "live_effects/lpe-ruler.h"
+#include "live_effects/lpe-boolops.h"
// end of includes
namespace Inkscape {
@@ -96,6 +97,7 @@ const Util::EnumData<EffectType> LPETypeData[INVALID_LPE] = {
{COPY_ROTATE, N_("Rotate copies"), "copy_rotate"},
{OFFSET, N_("Offset"), "offset"},
{RULER, N_("Ruler"), "ruler"},
+ {BOOLOPS, N_("Boolops"), "boolops"},
};
const Util::EnumDataConverter<EffectType> LPETypeConverter(LPETypeData, INVALID_LPE);
@@ -178,6 +180,9 @@ Effect::New(EffectType lpenr, LivePathEffectObject *lpeobj)
case RULER:
neweffect = static_cast<Effect*> ( new LPERuler(lpeobj) );
break;
+ case BOOLOPS:
+ neweffect = static_cast<Effect*> ( new LPEBoolops(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 fbaf8f867..c72f659f7 100644
--- a/src/live_effects/effect.h
+++ b/src/live_effects/effect.h
@@ -77,6 +77,7 @@ enum EffectType {
COPY_ROTATE,
OFFSET,
RULER,
+ BOOLOPS,
INVALID_LPE // This must be last
};
diff --git a/src/live_effects/lpe-boolops.cpp b/src/live_effects/lpe-boolops.cpp
new file mode 100644
index 000000000..1198df6c9
--- /dev/null
+++ b/src/live_effects/lpe-boolops.cpp
@@ -0,0 +1,80 @@
+#define INKSCAPE_LPE_BOOLOPS_CPP
+/** \file
+ * LPE boolops implementation
+ */
+/*
+ * Authors:
+ * Johan Engelen
+ *
+ * Copyright (C) Johan Engelen 2007-2008 <j.b.c.engelen@utwente.nl>
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "live_effects/lpe-boolops.h"
+
+#include <2geom/path.h>
+#include <2geom/shape.h>
+
+namespace Inkscape {
+namespace LivePathEffect {
+
+static const Util::EnumData<unsigned> BoolopTypeData[] = {
+ {Geom::BOOLOP_NULL , N_("Null"), "null"},
+ {Geom::BOOLOP_INTERSECT , N_("Intersect"), "intersect"},
+ {Geom::BOOLOP_SUBTRACT_A_B , N_("Subtract A-B"), "subtract_a_b"},
+ {Geom::BOOLOP_IDENTITY_A , N_("Identity A"), "identity_a"},
+ {Geom::BOOLOP_SUBTRACT_B_A , N_("Subtract B-A"), "subtract_b_a"},
+ {Geom::BOOLOP_IDENTITY_B , N_("Identity B"), "identity_b"},
+ {Geom::BOOLOP_EXCLUSION , N_("Exclusion"), "Exclusion"},
+ {Geom::BOOLOP_UNION , N_("Union"), "Union"}
+};
+static const Util::EnumDataConverter<unsigned> BoolopTypeConverter(BoolopTypeData, sizeof(BoolopTypeData)/sizeof(*BoolopTypeData));
+
+LPEBoolops::LPEBoolops(LivePathEffectObject *lpeobject) :
+ Effect(lpeobject),
+ bool_path(_("2nd path"), _("Path to which the original path will be boolop'ed."), "path_2nd", &wr, this, "M0,0 L1,0"),
+ boolop_type(_("Boolop type"), _("Determines which kind of boolop will be performed."), "boolop_type", BoolopTypeConverter, &wr, this, Geom::BOOLOP_UNION)
+{
+ show_orig_path = true;
+
+ registerParameter( dynamic_cast<Parameter *>(&boolop_type) );
+ registerParameter( dynamic_cast<Parameter *>(&bool_path) );
+}
+
+LPEBoolops::~LPEBoolops()
+{
+
+}
+
+
+Geom::PathVector
+LPEBoolops::doEffect_path (Geom::PathVector const & path_in)
+{
+ std::vector<Geom::Path> path_out;
+
+ Geom::Shape shape_in = Geom::sanitize(path_in);
+
+ Geom::Shape shape_param = Geom::sanitize(bool_path.get_pathvector());
+
+ Geom::Shape shape_out = Geom::boolop(shape_in, shape_param, boolop_type.get_value());
+
+ path_out = Geom::desanitize(shape_out);
+
+ return path_out;
+}
+
+
+} //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-boolops.h b/src/live_effects/lpe-boolops.h
new file mode 100644
index 000000000..8040c1df6
--- /dev/null
+++ b/src/live_effects/lpe-boolops.h
@@ -0,0 +1,53 @@
+#ifndef INKSCAPE_LPE_BOOLOPS_H
+#define INKSCAPE_LPE_BOOLOPS_H
+
+/** \file
+ * LPE boolops implementation, see lpe-boolops.cpp.
+ */
+
+/*
+ * Authors:
+ * Johan Engelen
+ *
+ * Copyright (C) Johan Engelen 2007-2008 <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/enum.h"
+#include "live_effects/parameter/path.h"
+
+namespace Inkscape {
+namespace LivePathEffect {
+
+class LPEBoolops : public Effect {
+public:
+ LPEBoolops(LivePathEffectObject *lpeobject);
+ virtual ~LPEBoolops();
+
+ virtual std::vector<Geom::Path> doEffect_path (std::vector<Geom::Path> const & path_in);
+
+private:
+ PathParam bool_path;
+ EnumParam<unsigned> boolop_type;
+
+ LPEBoolops(const LPEBoolops&);
+ LPEBoolops& operator=(const LPEBoolops&);
+};
+
+} //namespace LivePathEffect
+} //namespace Inkscape
+
+#endif // INKSCAPE_LPE_BOOLOPS_H
+
+/*
+ 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 :