1 // SPDX-License-Identifier: GPL-2.0-or-later
2 #ifndef INKSCAPE_LPE_PERSPECTIVE_ENVELOPE_H
3 #define INKSCAPE_LPE_PERSPECTIVE_ENVELOPE_H
4 
5 /** \file
6  * LPE <perspective-envelope> implementation , see lpe-perspective-envelope.cpp.
7 
8  */
9 /*
10  * Authors:
11  *   Jabiertxof Code migration from python extensions envelope and perspective
12  *   Aaron Spike, aaron@ekips.org from envelope and perspective python code
13  *   Dmitry Platonov, shadowjack@mail.ru, 2006 perspective approach & math
14  *   Jose Hevia (freon) Transform algorithm from envelope
15  *
16  * Copyright (C) 2007-2014 Authors
17  *
18  * Released under GNU GPL v2+, read the file 'COPYING' for more information.
19  */
20 
21 #include "live_effects/parameter/enum.h"
22 #include "live_effects/effect.h"
23 #include "live_effects/parameter/point.h"
24 #include "live_effects/lpegroupbbox.h"
25 
26 namespace Inkscape {
27 namespace LivePathEffect {
28 
29 class LPEPerspectiveEnvelope : public Effect, GroupBBoxEffect {
30 public:
31 
32     LPEPerspectiveEnvelope(LivePathEffectObject *lpeobject);
33 
34     ~LPEPerspectiveEnvelope() override;
35 
36     void doEffect(SPCurve *curve) override;
37 
38     virtual Geom::Point projectPoint(Geom::Point p);
39 
40     void transform_multiply(Geom::Affine const &postmul, bool set) override;
41 
42     virtual Geom::Point projectPoint(Geom::Point p,  double m[][3]);
43 
44     virtual Geom::Point pointAtRatio(Geom::Coord ratio,Geom::Point A, Geom::Point B);
45 
46     void resetDefaults(SPItem const* item) override;
47 
48     virtual void vertical(PointParam &paramA,PointParam &paramB, Geom::Line vert);
49 
50     virtual void horizontal(PointParam &paramA,PointParam &paramB,Geom::Line horiz);
51 
52     void doBeforeEffect(SPLPEItem const* lpeitem) override;
53 
54     Gtk::Widget * newWidget() override;
55 
56     virtual void setDefaults();
57 
58     virtual void resetGrid();
59 
60 protected:
61     void addCanvasIndicators(SPLPEItem const */*lpeitem*/, std::vector<Geom::PathVector> &hp_vec) override;
62 private:
63 
64     BoolParam horizontal_mirror;
65     BoolParam vertical_mirror;
66     BoolParam overflow_perspective;
67     EnumParam<unsigned> deform_type;
68     PointParam up_left_point;
69     PointParam up_right_point;
70     PointParam down_left_point;
71     PointParam down_right_point;
72     std::vector<Geom::Point> handles;
73     LPEPerspectiveEnvelope(const LPEPerspectiveEnvelope&) = delete;
74     LPEPerspectiveEnvelope& operator=(const LPEPerspectiveEnvelope&) = delete;
75 };
76 
77 } //namespace LivePathEffect
78 } //namespace Inkscape
79 
80 #endif
81