4c98ccd55736d1681d97052c3463092b910ee96e
1 #ifndef INKSCAPE_LPE_KNOT_H
2 #define INKSCAPE_LPE_KNOT_H
4 /** \file
5 * LPE <knot> implementation, see lpe-knot.cpp.
6 */
8 /*
9 * Authors:
10 * JFB, but derived from Johan Engelen!
11 *
12 * Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl>
13 *
14 * Released under GNU GPL, read the file 'COPYING' for more information
15 */
17 #include "live_effects/effect.h"
18 #include "live_effects/parameter/parameter.h"
19 #include "live_effects/parameter/vector.h"
20 #include "live_effects/parameter/path.h"
21 #include "2geom/crossing.h"
23 namespace Inkscape {
24 namespace LivePathEffect {
26 class KnotHolderEntityCrossingSwitcher;
28 // CrossingPoint, CrossingData:
29 // "point oriented" storage of crossing data (needed to find crossing nearest to a click, etc...)
30 //TODO: evaluate how lpeknot-specific that is? Should something like this exist in 2geom?
32 namespace LPEKnotNS {//just in case...
33 struct CrossingPoint {
34 Geom::Point pt;
35 int sign; //+/-1 = positive or neg crossing, 0 = flat.
36 unsigned i, j; //paths components meeting in this point.
37 unsigned ni, nj; //this crossing is the ni-th along i, nj-th along j.
38 };
40 class CrossingPoints : public std::vector<CrossingPoint>{
41 public:
42 CrossingPoints() : std::vector<CrossingPoint>() {}
43 CrossingPoints(Geom::CrossingSet const &cs, std::vector<Geom::Path> const &path);//for self crossings only!
44 //TODO: define a constructor for intersections of 2 different paths.
45 CrossingPoints(std::vector<double> const &input);
46 std::vector<double> to_vector();
47 CrossingPoint get(unsigned const i, unsigned const ni);
48 void inherit_signs(CrossingPoints const &from_other, int default_value = 1);
49 };
51 }
54 class LPEKnot : public Effect {
55 public:
56 LPEKnot(LivePathEffectObject *lpeobject);
57 virtual ~LPEKnot();
59 virtual void doOnApply (SPLPEItem *lpeitem);
60 virtual std::vector<Geom::Path> doEffect_path (std::vector<Geom::Path> const & input_path);
62 /* the knotholder entity classes must be declared friends */
63 friend class KnotHolderEntityCrossingSwitcher;
65 protected:
66 virtual void addCanvasIndicators(SPLPEItem *lpeitem, std::vector<Geom::PathVector> &hp_vec);
68 private:
69 void updateSwitcher();
70 // add the parameters for your effect here:
71 ScalarParam interruption_width;
72 ScalarParam switcher_size;
73 VectorParam<double> crossing_points_vector;
74 LPEKnotNS::CrossingPoints crossing_points;
77 LPEKnot(const LPEKnot&);
78 LPEKnot& operator=(const LPEKnot&);
79 unsigned selectedCrossing;
80 Geom::Point switcher;
82 };
84 } //namespace LivePathEffect
85 } //namespace Inkscape
87 #endif