Code

Translations. POTFILES.in, inkcape.pot and fr.po updated.
[inkscape.git] / src / live_effects / lpe-boolops.cpp
1 #define INKSCAPE_LPE_BOOLOPS_CPP
2 /** \file
3  * LPE boolops implementation
4  */
5 /*
6  * Authors:
7  *   Johan Engelen
8  *
9  * Copyright (C) Johan Engelen 2007-2008 <j.b.c.engelen@utwente.nl>
10  *
11  * Released under GNU GPL, read the file 'COPYING' for more information
12  */
14 #include "live_effects/lpe-boolops.h"
16 #include <2geom/path.h>
17 #include <2geom/shape.h>
19 namespace Inkscape {
20 namespace LivePathEffect {
22 static const Util::EnumData<unsigned> BoolopTypeData[] = {
23     {Geom::BOOLOP_NULL          , N_("Null"), "null"},
24     {Geom::BOOLOP_INTERSECT     , N_("Intersect"), "intersect"},
25     {Geom::BOOLOP_SUBTRACT_A_B  , N_("Subtract A-B"), "subtract_a_b"},
26     {Geom::BOOLOP_IDENTITY_A    , N_("Identity A"), "identity_a"},
27     {Geom::BOOLOP_SUBTRACT_B_A  , N_("Subtract B-A"), "subtract_b_a"},
28     {Geom::BOOLOP_IDENTITY_B    , N_("Identity B"), "identity_b"},
29     {Geom::BOOLOP_EXCLUSION     , N_("Exclusion"), "Exclusion"},
30     {Geom::BOOLOP_UNION         , N_("Union"), "Union"}
31 };
32 static const Util::EnumDataConverter<unsigned> BoolopTypeConverter(BoolopTypeData, sizeof(BoolopTypeData)/sizeof(*BoolopTypeData));
34 LPEBoolops::LPEBoolops(LivePathEffectObject *lpeobject) :
35     Effect(lpeobject),
36     bool_path(_("2nd path"), _("Path to which the original path will be boolop'ed."), "path_2nd", &wr, this, "M0,0 L1,0"),
37     boolop_type(_("Boolop type"), _("Determines which kind of boolop will be performed."), "boolop_type", BoolopTypeConverter, &wr, this, Geom::BOOLOP_UNION)
38 {
39     show_orig_path = true;
41     registerParameter( dynamic_cast<Parameter *>(&boolop_type) );
42     registerParameter( dynamic_cast<Parameter *>(&bool_path) );
43 }
45 LPEBoolops::~LPEBoolops()
46 {
48 }
51 Geom::PathVector
52 LPEBoolops::doEffect_path (Geom::PathVector const & path_in)
53 {
54     std::vector<Geom::Path> path_out;
56     Geom::Shape shape_in = Geom::sanitize(path_in);
58     Geom::Shape shape_param = Geom::sanitize(bool_path.get_pathvector());
60     Geom::Shape shape_out = Geom::boolop(shape_in, shape_param, boolop_type.get_value());
62     path_out = Geom::desanitize(shape_out);
64     return path_out;
65 }
68 } //namespace LivePathEffect
69 } /* namespace Inkscape */
71 /*
72   Local Variables:
73   mode:c++
74   c-file-style:"stroustrup"
75   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
76   indent-tabs-mode:nil
77   fill-column:99
78   End:
79 */
80 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :