1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  *  Embroidery stitch live path effect
4  *
5  * Copyright (C) 2016 Michael Soegtrop
6  *
7  * Released under GNU GPL v2+, read the file 'COPYING' for more information.
8  */
9 
10 #ifndef INKSCAPE_LPE_EMBRODERY_STITCH_H
11 #define INKSCAPE_LPE_EMBRODERY_STITCH_H
12 
13 #include "live_effects/effect.h"
14 #include "live_effects/parameter/parameter.h"
15 #include "live_effects/parameter/bool.h"
16 #include "live_effects/parameter/enum.h"
17 #include "live_effects/lpe-embrodery-stitch-ordering.h"
18 
19 namespace Inkscape {
20 namespace LivePathEffect {
21 
22 using namespace LPEEmbroderyStitchOrdering;
23 
24 class LPEEmbroderyStitch : public Effect {
25 public:
26 
27     LPEEmbroderyStitch(LivePathEffectObject *lpeobject);
28     ~LPEEmbroderyStitch() override;
29 
30     Geom::PathVector doEffect_path(Geom::PathVector const &path_in) override;
31 
32     void resetDefaults(SPItem const *item) override;
33 
34     enum order_method {
35         order_method_no_reorder,
36         order_method_zigzag,
37         order_method_zigzag_rev_first,
38         order_method_closest,
39         order_method_closest_rev_first,
40         order_method_tsp_kopt_2,
41         order_method_tsp_kopt_3,
42         order_method_tsp_kopt_4,
43         order_method_tsp_kopt_5,
44         order_method_count
45     };
46     enum connect_method {
47         connect_method_line,
48         connect_method_move_point_from,
49         connect_method_move_point_mid,
50         connect_method_move_point_to,
51         connect_method_count
52     };
53 
54 private:
55     EnumParam<order_method> ordering;
56     EnumParam<connect_method> connection;
57     ScalarParam stitch_length;
58     ScalarParam stitch_min_length;
59     ScalarParam stitch_pattern;
60     BoolParam show_stitches;
61     ScalarParam show_stitch_gap;
62     ScalarParam jump_if_longer;
63 
64     LPEEmbroderyStitch(const LPEEmbroderyStitch &) = delete;
65     LPEEmbroderyStitch &operator=(const LPEEmbroderyStitch &) = delete;
66 
67     double GetPatternInitialStep(int pattern, int line);
68     Geom::Point GetStartPointInterpolAfterRev(std::vector<OrderingInfo> const &info, unsigned i);
69     Geom::Point GetEndPointInterpolAfterRev(std::vector<OrderingInfo> const &info, unsigned i);
70     Geom::Point GetStartPointInterpolBeforeRev(std::vector<OrderingInfo> const &info, unsigned i);
71     Geom::Point GetEndPointInterpolBeforeRev(std::vector<OrderingInfo> const &info, unsigned i);
72 };
73 
74 } //namespace LivePathEffect
75 } //namespace Inkscape
76 
77 #endif
78