1 // SPDX-License-Identifier: GPL-2.0-or-later
2 #ifndef INKSCAPE_LPE_PERP_BISECTOR_H
3 #define INKSCAPE_LPE_PERP_BISECTOR_H
4 
5 /** \file
6  * LPE <perp_bisector> implementation, see lpe-perp_bisector.cpp.
7  */
8 /*
9  * Authors:
10  *   Maximilian Albert
11  *   Johan Engelen
12  *
13  * Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl>
14  * Copyright (C) Maximilin Albert 2008 <maximilian.albert@gmail.com>
15  *
16  * Released under GNU GPL v2+, read the file 'COPYING' for more information.
17  */
18 
19 #include "live_effects/effect.h"
20 #include "live_effects/parameter/parameter.h"
21 #include "live_effects/parameter/point.h"
22 
23 namespace Inkscape {
24 namespace LivePathEffect {
25 
26 namespace PB {
27   // we need a separate namespace to avoid clashes with LPETangentToCurve
28   class KnotHolderEntityEnd;
29   class KnotHolderEntityLeftEnd;
30   class KnotHolderEntityRightEnd;
31   void bisector_end_set(SPItem *item, Geom::Point const &p, guint state, bool left = true);
32 }
33 
34 class LPEPerpBisector : public Effect {
35 public:
36     LPEPerpBisector(LivePathEffectObject *lpeobject);
37     ~LPEPerpBisector() override;
38 
effectType()39     virtual EffectType effectType () { return PERP_BISECTOR; }
40 
41     void doOnApply (SPLPEItem const* lpeitem) override;
42 
43     Geom::Piecewise<Geom::D2<Geom::SBasis> >
44       doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_in) override;
45 
46     /* the knotholder entity functions must be declared friends */
47     friend class PB::KnotHolderEntityEnd;
48     friend class PB::KnotHolderEntityLeftEnd;
49     friend class PB::KnotHolderEntityRightEnd;
50     friend void PB::bisector_end_set(SPItem *item, Geom::Point const &p, guint state, bool left);
51     void addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item);
52 
53 private:
54     ScalarParam length_left;
55     ScalarParam length_right;
56 
57     Geom::Point A; // start of path
58     Geom::Point B; // end of path
59     Geom::Point M; // midpoint
60     Geom::Point C; // left end of bisector
61     Geom::Point D; // right end of bisector
62     Geom::Point perp_dir;
63 
64     LPEPerpBisector(const LPEPerpBisector&) = delete;
65     LPEPerpBisector& operator=(const LPEPerpBisector&) = delete;
66 };
67 
68 } //namespace LivePathEffect
69 } //namespace Inkscape
70 
71 #endif
72