From: johanengelen Date: Wed, 16 Jul 2008 21:42:46 +0000 (+0000) Subject: add lpe-Boolops X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=add2ffae3c4686b50d888775bbdf083a4726a210;p=inkscape.git add lpe-Boolops --- 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 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 LPETypeConverter(LPETypeData, INVALID_LPE); @@ -178,6 +180,9 @@ Effect::New(EffectType lpenr, LivePathEffectObject *lpeobj) case RULER: neweffect = static_cast ( new LPERuler(lpeobj) ); break; + case BOOLOPS: + neweffect = static_cast ( 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 + * + * 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 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 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(&boolop_type) ); + registerParameter( dynamic_cast(&bool_path) ); +} + +LPEBoolops::~LPEBoolops() +{ + +} + + +Geom::PathVector +LPEBoolops::doEffect_path (Geom::PathVector const & path_in) +{ + std::vector 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 + * + * 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 doEffect_path (std::vector const & path_in); + +private: + PathParam bool_path; + EnumParam 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 :