summaryrefslogtreecommitdiffstats
path: root/src/live_effects/effect-enum.h
blob: 9e2140d5c52b8347247b854593aae098c0e1ebae (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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
// SPDX-License-Identifier: GPL-2.0-or-later
#ifndef INKSCAPE_LIVEPATHEFFECT_ENUM_H
#define INKSCAPE_LIVEPATHEFFECT_ENUM_H

/*
 * Inkscape::LivePathEffect::EffectType
 *
 * Copyright (C) Johan Engelen 2008 <j.b.c.engelen@utwente.nl>
 *
 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
 */

#include "util/enums.h"

namespace Inkscape {
namespace LivePathEffect {

//Please fill in the same order than in effect.cpp:98
enum EffectType {
    BEND_PATH = 0,
    GEARS,
    PATTERN_ALONG_PATH,
    CURVE_STITCH,
    VONKOCH,
    KNOT,
    CONSTRUCT_GRID,
    SPIRO,
    ENVELOPE,
    INTERPOLATE,
    ROUGH_HATCHES,
    SKETCH,
    RULER,
    POWERSTROKE,
    CLONE_ORIGINAL,
    SIMPLIFY,
    LATTICE2,
    PERSPECTIVE_ENVELOPE,
    INTERPOLATE_POINTS,
    TRANSFORM_2PTS,
    SHOW_HANDLES,
    ROUGHEN,
    BSPLINE,
    JOIN_TYPE,
    TAPER_STROKE,
    MIRROR_SYMMETRY,
    COPY_ROTATE,
    ATTACH_PATH,
    FILL_BETWEEN_STROKES,
    FILL_BETWEEN_MANY,
    ELLIPSE_5PTS,
    BOUNDING_BOX,
    MEASURE_SEGMENTS,
    FILLET_CHAMFER,
    POWERCLIP,
    POWERMASK,
    PTS2ELLIPSE,
    OFFSET,
    DASHED_STROKE,
    BOOL_OP,
    SLICE,
    TILING,
    // PUT NEW LPE BEFORE EXPERIMENTAL IN THE SAME ORDER AS IN effect.cpp
    // Visible Experimental LPE's
    ANGLE_BISECTOR,
    CIRCLE_WITH_RADIUS,
    CIRCLE_3PTS,
    EXTRUDE,
    LINE_SEGMENT,
    PARALLEL,
    PERP_BISECTOR,
    TANGENT_TO_CURVE,
    // Hidden Experimental LPE's
    DOEFFECTSTACK_TEST,
    DYNASTROKE,
    LATTICE,
    PATH_LENGTH,
    RECURSIVE_SKELETON,
    TEXT_LABEL,
    EMBRODERY_STITCH,
    INVALID_LPE // This must be last (I made it such that it is not needed anymore I think..., Don't trust on it being
                // last. - johan)
};
//ALPHABETIC
enum ParamType {
    ARRAY = 0,
    BOOL,
    COLOR_PICKER,
    ENUM,
    FONT_BUTTON,
    HIDDEN,
    MESSAGE,
    NODE_SATELLITE_ARRAY,
    ORIGINAL_PATH,
    ORIGINAL_SATELLITE,
    PATH_REFERENCE,
    PATH,
    PATH_ARRAY,
    POINT,
    POWERSTROKE_POINT_ARRAY,
    RANDOM,
    SATELLITE,
    SATELLITE_ARRAY,
    TEXT,
    TOGGLE_BUTTON,
    TRANSFORMED_POINT,
    UNIT,
    VECTOR,
    INVALID_PARAM // This must be last
};

template <typename E>
struct EnumEffectData {
    E id;
    const Glib::ustring label;
    const Glib::ustring key;
    const Glib::ustring icon;
    const Glib::ustring description;
    const bool on_path;
    const bool on_shape;
    const bool on_group;
    const bool on_image;
    const bool on_text;
    const bool experimental;
};

const Glib::ustring empty_string("");

/**
 * Simplified management of enumerations of LPE items with UI labels.
 *
 * @note that get_id_from_key and get_id_from_label return 0 if it cannot find an entry for that key string.
 * @note that get_label and get_key return an empty string when the requested id is not in the list.
 */
template <typename E>
class EnumEffectDataConverter {
  public:
    typedef EnumEffectData<E> Data;

    EnumEffectDataConverter(const EnumEffectData<E> *cd, const unsigned int length)
        : _length(length)
        , _data(cd)
    {
    }

    E get_id_from_label(const Glib::ustring &label) const
    {
        for (unsigned int i = 0; i < _length; ++i) {
            if (_data[i].label == label)
                return _data[i].id;
        }

        return (E)0;
    }

    E get_id_from_key(const Glib::ustring &key) const
    {
        for (unsigned int i = 0; i < _length; ++i) {
            if (_data[i].key == key)
                return _data[i].id;
        }

        return (E)0;
    }

    bool is_valid_key(const Glib::ustring &key) const
    {
        for (unsigned int i = 0; i < _length; ++i) {
            if (_data[i].key == key)
                return true;
        }

        return false;
    }

    bool is_valid_id(const E id) const
    {
        for (unsigned int i = 0; i < _length; ++i) {
            if (_data[i].id == id)
                return true;
        }
        return false;
    }

    const Glib::ustring &get_label(const E id) const
    {
        for (unsigned int i = 0; i < _length; ++i) {
            if (_data[i].id == id)
                return _data[i].label;
        }

        return empty_string;
    }

    const Glib::ustring &get_key(const E id) const
    {
        for (unsigned int i = 0; i < _length; ++i) {
            if (_data[i].id == id)
                return _data[i].key;
        }

        return empty_string;
    }

    const Glib::ustring &get_icon(const E id) const
    {
        for (unsigned int i = 0; i < _length; ++i) {
            if (_data[i].id == id)
                return _data[i].icon;
        }

        return empty_string;
    }

    const Glib::ustring &get_description(const E id) const
    {
        for (unsigned int i = 0; i < _length; ++i) {
            if (_data[i].id == id)
                return _data[i].description;
        }

        return empty_string;
    }

    bool get_on_path(const E id) const
    {
        for (unsigned int i = 0; i < _length; ++i) {
            if (_data[i].id == id)
                return _data[i].on_path;
        }

        return false;
    }

    bool get_on_shape(const E id) const
    {
        for (unsigned int i = 0; i < _length; ++i) {
            if (_data[i].id == id)
                return _data[i].on_shape;
        }

        return false;
    }

    bool get_on_group(const E id) const
    {
        for (unsigned int i = 0; i < _length; ++i) {
            if (_data[i].id == id)
                return _data[i].on_group;
        }

        return false;
    }

    bool get_on_image(const E id) const
    {
        for (unsigned int i = 0; i < _length; ++i) {
            if (_data[i].id == id)
                return _data[i].on_image;
        }

        return false;
    }

    bool get_on_text(const E id) const
    {
        for (unsigned int i = 0; i < _length; ++i) {
            if (_data[i].id == id)
                return _data[i].on_text;
        }

        return false;
    }

    bool get_experimental(const E id) const
    {
        for (unsigned int i = 0; i < _length; ++i) {
            if (_data[i].id == id)
                return _data[i].experimental;
        }

        return false;
    }

    const EnumEffectData<E> &data(const unsigned int i) const { return _data[i]; }

    const unsigned int _length;

  private:
    const EnumEffectData<E> *_data;
};

extern const EnumEffectData<EffectType> LPETypeData[];             /// defined in effect.cpp
extern const EnumEffectDataConverter<EffectType> LPETypeConverter; /// defined in effect.cpp

} //namespace LivePathEffect
} //namespace Inkscape

#endif

/*
  Local Variables:
  mode:c++
  c-file-style:"stroustrup"
  c-file-offsets:((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 :