summaryrefslogtreecommitdiffstats
path: root/src/live_effects/lpe-perspective-envelope.h
blob: 7aa32ecc1a2756fc6fd0fc5a7f19cfc5dee240e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// SPDX-License-Identifier: GPL-2.0-or-later
#ifndef INKSCAPE_LPE_PERSPECTIVE_ENVELOPE_H
#define INKSCAPE_LPE_PERSPECTIVE_ENVELOPE_H

/** \file
 * LPE <perspective-envelope> implementation , see lpe-perspective-envelope.cpp.

 */
/*
 * Authors:
 *   Jabiertxof Code migration from python extensions envelope and perspective
 *   Aaron Spike, aaron@ekips.org from envelope and perspective python code
 *   Dmitry Platonov, shadowjack@mail.ru, 2006 perspective approach & math
 *   Jose Hevia (freon) Transform algorithm from envelope
 *
 * Copyright (C) 2007-2014 Authors
 *
 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
 */

#include "live_effects/parameter/enum.h"
#include "live_effects/effect.h"
#include "live_effects/parameter/point.h"
#include "live_effects/lpegroupbbox.h"

namespace Inkscape {
namespace LivePathEffect {

class LPEPerspectiveEnvelope : public Effect, GroupBBoxEffect {
public:

    LPEPerspectiveEnvelope(LivePathEffectObject *lpeobject);

    ~LPEPerspectiveEnvelope() override;

    void doEffect(SPCurve *curve) override;

    virtual Geom::Point projectPoint(Geom::Point p);

    void transform_multiply(Geom::Affine const &postmul, bool set) override;

    virtual Geom::Point projectPoint(Geom::Point p,  double m[][3]);

    virtual Geom::Point pointAtRatio(Geom::Coord ratio,Geom::Point A, Geom::Point B);

    void resetDefaults(SPItem const* item) override;

    virtual void vertical(PointParam &paramA,PointParam &paramB, Geom::Line vert);

    virtual void horizontal(PointParam &paramA,PointParam &paramB,Geom::Line horiz);

    void doBeforeEffect(SPLPEItem const* lpeitem) override;

    Gtk::Widget * newWidget() override;

    virtual void setDefaults();

    virtual void resetGrid();

protected:
    void addCanvasIndicators(SPLPEItem const */*lpeitem*/, std::vector<Geom::PathVector> &hp_vec) override;
private:

    BoolParam horizontal_mirror;
    BoolParam vertical_mirror;
    BoolParam overflow_perspective;
    EnumParam<unsigned> deform_type;
    PointParam up_left_point;
    PointParam up_right_point;
    PointParam down_left_point;
    PointParam down_right_point;
    std::vector<Geom::Point> handles;
    LPEPerspectiveEnvelope(const LPEPerspectiveEnvelope&) = delete;
    LPEPerspectiveEnvelope& operator=(const LPEPerspectiveEnvelope&) = delete;
};

} //namespace LivePathEffect
} //namespace Inkscape

#endif