2
* LPE knot effect implementation, see lpe-knot.cpp.
5
* Jean-Francois Barraud <jf.barraud@gmail.com>
6
* Johan Engelen <j.b.c.engelen@utwente.nl>
8
* Copyright (C) Johan Engelen 2007
10
* Released under GNU GPL, read the file 'COPYING' for more information
13
#ifndef INKSCAPE_LPE_KNOT_H
14
#define INKSCAPE_LPE_KNOT_H
16
#include "sp-item-group.h"
17
#include "live_effects/effect.h"
18
#include "live_effects/lpegroupbbox.h"
19
#include "live_effects/parameter/parameter.h"
20
#include "live_effects/parameter/array.h"
21
//#include "live_effects/parameter/path.h"
22
#include "live_effects/parameter/bool.h"
23
#include "2geom/crossing.h"
26
namespace LivePathEffect {
28
class KnotHolderEntityCrossingSwitcher;
30
// CrossingPoint, CrossingPoints:
31
// "point oriented" storage of crossing data (needed to find crossing nearest to a click, etc...)
32
//TODO: evaluate how lpeknot-specific that is? Should something like this exist in 2geom?
33
namespace LPEKnotNS {//just in case...
34
struct CrossingPoint {
36
int sign; //+/-1 = positive or neg crossing, 0 = flat.
37
unsigned i, j; //paths components meeting in this point.
38
unsigned ni, nj; //this crossing is the ni-th along i, nj-th along j.
39
double ti, tj; //time along paths.
42
class CrossingPoints : public std::vector<CrossingPoint>{
44
CrossingPoints() : std::vector<CrossingPoint>() {}
45
CrossingPoints(Geom::CrossingSet const &cs, std::vector<Geom::Path> const &path);//for self crossings only!
46
CrossingPoints(std::vector<Geom::Path> const &paths);
47
CrossingPoints(std::vector<double> const &input);
48
std::vector<double> to_vector();
49
CrossingPoint get(unsigned const i, unsigned const ni);
50
void inherit_signs(CrossingPoints const &from_other, int default_value = 1);
54
class LPEKnot : public Effect, GroupBBoxEffect {
56
LPEKnot(LivePathEffectObject *lpeobject);
59
virtual void doBeforeEffect (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;
66
virtual void addCanvasIndicators(SPLPEItem *lpeitem, std::vector<Geom::PathVector> &hp_vec);
69
void updateSwitcher();
71
ScalarParam interruption_width;
72
BoolParam prop_to_stroke_width;
73
BoolParam add_stroke_width;
74
BoolParam add_other_stroke_width;
75
ScalarParam switcher_size;
77
ArrayParam<double> crossing_points_vector;//svg storage of crossing_points
79
LPEKnotNS::CrossingPoints crossing_points;//topology representation of the knot.
81
std::vector<Geom::Path> gpaths;//the collection of all the paths in the object or group.
82
std::vector<double> gstroke_widths;//the collection of all the stroke widths in the object or group.
84
//UI: please, someone, help me to improve this!!
85
unsigned selectedCrossing;//the selected crossing
86
Geom::Point switcher;//where to put the "switcher" helper
88
LPEKnot(const LPEKnot&);
89
LPEKnot& operator=(const LPEKnot&);
93
} //namespace LivePathEffect
94
} //namespace Inkscape