1 // SPDX-License-Identifier: GPL-2.0-or-later
2 #ifndef INKSCAPE_LPE_MIRROR_SYMMETRY_H
3 #define INKSCAPE_LPE_MIRROR_SYMMETRY_H
4 
5 /** \file
6  * LPE <mirror_symmetry> implementation: mirrors a path with respect to a given line.
7  */
8 /*
9  * Authors:
10  *   Maximilian Albert
11  *   Johan Engelen
12  *   Jabiertxof
13  *
14  * Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl>
15  * Copyright (C) Maximilin Albert 2008 <maximilian.albert@gmail.com>
16  *
17  * Released under GNU GPL v2+, read the file 'COPYING' for more information.
18  */
19 
20 #include "live_effects/effect.h"
21 #include "live_effects/lpeobject.h"
22 #include "live_effects/lpeobject-reference.h"
23 #include "live_effects/parameter/parameter.h"
24 #include "live_effects/parameter/text.h"
25 #include "live_effects/parameter/point.h"
26 #include "live_effects/parameter/enum.h"
27 #include "live_effects/lpegroupbbox.h"
28 
29 namespace Inkscape {
30 namespace LivePathEffect {
31 
32 enum ModeType {
33     MT_V,
34     MT_H,
35     MT_FREE,
36     MT_X,
37     MT_Y,
38     MT_END
39 };
40 
41 class LPEMirrorSymmetry : public Effect, GroupBBoxEffect {
42 public:
43     LPEMirrorSymmetry(LivePathEffectObject *lpeobject);
44     ~LPEMirrorSymmetry() override;
45     void doOnApply (SPLPEItem const* lpeitem) override;
46     void doBeforeEffect (SPLPEItem const* lpeitem) override;
47     void doAfterEffect (SPLPEItem const* lpeitem, SPCurve *curve) override;
48     Geom::PathVector doEffect_path (Geom::PathVector const & path_in) override;
49     void doOnRemove (SPLPEItem const* /*lpeitem*/) override;
50     void doOnVisibilityToggled(SPLPEItem const* /*lpeitem*/) override;
51     Gtk::Widget * newWidget() override;
52     void cloneStyle(SPObject *orig, SPObject *dest);
53     void toMirror(Geom::Affine transform);
54     void cloneD(SPObject *orig, SPObject *dest);
55     Inkscape::XML::Node * createPathBase(SPObject *elemref);
56     void resetStyles();
57     void centerVert();
58     void centerHoriz();
59     BoolParam split_items;
60 
61 protected:
62     void addCanvasIndicators(SPLPEItem const *lpeitem, std::vector<Geom::PathVector> &hp_vec) override;
63 
64 private:
65     EnumParam<ModeType> mode;
66     BoolParam discard_orig_path;
67     BoolParam fuse_paths;
68     BoolParam oposite_fuse;
69     BoolParam split_open;
70     PointParam start_point;
71     PointParam end_point;
72     PointParam center_point;
73     Geom::Point previous_center;
74     SPObject * container;
75     bool reset;
76     bool center_vert;
77     bool center_horiz;
78     LPEMirrorSymmetry(const LPEMirrorSymmetry&) = delete;
79     LPEMirrorSymmetry& operator=(const LPEMirrorSymmetry&) = delete;
80 };
81 
82 } //namespace LivePathEffect
83 } //namespace Inkscape
84 
85 #endif
86