summaryrefslogtreecommitdiffstats
path: root/src/live_effects/lpe-tiling.h
blob: 761d3d3c2e51a1c0097ee4e429beb60b45b7f6ce (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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
// SPDX-License-Identifier: GPL-2.0-or-later
#ifndef INKSCAPE_LPE_TILING_H
#define INKSCAPE_LPE_TILING_H

/** \file
 * LPE <tiling> implementation, see lpe-tiling.cpp.
 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
 */

#include "live_effects/effect.h"
#include "live_effects/lpegroupbbox.h"
#include "live_effects/parameter/enum.h"
#include "live_effects/parameter/parameter.h"
#include "live_effects/parameter/point.h"
#include "live_effects/parameter/satellitearray.h"
#include "live_effects/parameter/text.h"
#include "live_effects/parameter/unit.h"
#include "live_effects/parameter/random.h"
// this is only to fillrule
#include "livarot/Shape.h"

namespace Inkscape {
namespace LivePathEffect {

namespace CoS {
// we need a separate namespace to avoid clashes with other LPEs
class KnotHolderEntityCopyGapX;
class KnotHolderEntityCopyGapY;
}

typedef FillRule FillRuleBool;

class LPETiling : public Effect, GroupBBoxEffect {
public:
    LPETiling(LivePathEffectObject *lpeobject);
    ~LPETiling() override;
    void doOnApply (SPLPEItem const* lpeitem) override;
    Geom::PathVector doEffect_path (Geom::PathVector const & path_in) override;
    void doBeforeEffect (SPLPEItem const* lpeitem) override;
    void doAfterEffect (SPLPEItem const* lpeitem, SPCurve *curve) override;
    void split(Geom::PathVector &path_in, Geom::Path const &divider);
    void resetDefaults(SPItem const* item) override;
    void doOnRemove(SPLPEItem const* /*lpeitem*/) override;
    bool doOnOpen(SPLPEItem const * /*lpeitem*/) override;
    void doOnVisibilityToggled(SPLPEItem const* /*lpeitem*/) override;
    Gtk::Widget * newWidget() override;
    void cloneStyle(SPObject *orig, SPObject *dest);
    Geom::PathVector doEffect_path_post (Geom::PathVector const & path_in, FillRuleBool fillrule);
    SPItem * toItem(size_t i, bool reset, bool &write);
    void cloneD(SPObject *orig, SPObject *dest);
    Inkscape::XML::Node * createPathBase(SPObject *elemref);
    friend class CoS::KnotHolderEntityCopyGapX;
    friend class CoS::KnotHolderEntityCopyGapY;
    void addKnotHolderEntities(KnotHolder * knotholder, SPItem * item) override;
protected:
    void addCanvasIndicators(SPLPEItem const *lpeitem, std::vector<Geom::PathVector> &hp_vec) override;
    KnotHolder *_knotholder;
    double gapx_unit = 0;
    double gapy_unit = 0;
    double offset_unit = 0;
private:
    void setOffsetCols();
    void setOffsetRows();
    void setScaleInterpolate(bool x, bool y);
    void setRotateInterpolate(bool x, bool y);
    void setScaleRandom();
    void setRotateRandom();
    void setGapXMode(bool random);
    void setGapYMode(bool random);
    bool getActiveMirror(gint index);
    double end_scale(double scale_fix, bool tomax) const;
    bool _updating = false;
    void setMirroring(gint index);
    Glib::ustring getMirrorMap(gint index);
    void generate_buttons(Gtk::Box *container, Gtk::RadioButton::Group &group, gint pos);
    UnitParam unit;
    SatelliteArrayParam lpesatellites;
    ScalarParam gapx;
    ScalarParam gapy;
    ScalarParam num_rows;
    ScalarParam num_cols;
    ScalarParam rotate;
    ScalarParam scale;
    ScalarParam offset;
    BoolParam offset_type;
    BoolParam random_scale;
    BoolParam random_rotate;
    BoolParam random_gap_x;
    BoolParam random_gap_y;
    RandomParam seed;
    BoolParam interpolate_scalex;
    BoolParam interpolate_rotatex;
    BoolParam interpolate_scaley;
    BoolParam interpolate_rotatey;
    BoolParam mirrorrowsx;
    BoolParam mirrorrowsy;
    BoolParam mirrorcolsx;
    BoolParam mirrorcolsy;
    BoolParam mirrortrans;
    BoolParam split_items;
    BoolParam link_styles;
    BoolParam shrink_interp;
    HiddenParam transformorigin;
    double original_width = 0;
    double original_height = 0;
    Geom::OptRect gap_bbox;
    Geom::OptRect originalbbox;
    double prev_num_cols;
    double prev_num_rows;
    bool reset;
    gdouble scaleok = 1.0;
    Glib::ustring prev_unit = "px";
    std::vector<double> random_x;
    std::vector<double> random_y;
    std::vector<double> random_s;
    std::vector<double> random_r;
    Geom::Affine affinebase = Geom::identity();
    Geom::Affine transformoriginal = Geom::identity();
    Geom::Affine hideaffine = Geom::identity();
    Geom::Affine originatrans = Geom::identity();
    bool prev_split = false;
    SPObject *container;
    LPETiling(const LPETiling&) = delete;
    LPETiling& operator=(const LPETiling&) = delete;
};

} //namespace LivePathEffect
} //namespace Inkscape

#endif

/*
  Local Variables:
  mode:c++
  c-file-style:"stroustrup"
  c-file-gaps:((innamespace . 0)(inline-open . 0)(case-label . +))
  indent-tabs-mode:nil
  fill-column:99
  End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :