~valavanisalex/ubuntu/precise/inkscape/fix-943984

« back to all changes in this revision

Viewing changes to inkscape-0.47pre1/src/live_effects/lpe-knot.h

  • Committer: Bazaar Package Importer
  • Author(s): Bryce Harrington
  • Date: 2009-07-02 17:09:45 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20090702170945-nn6d6zswovbwju1t
Tags: 0.47~pre1-0ubuntu1
* New upstream release.
  - Don't constrain maximization on small resolution devices (pre0)
    (LP: #348842)
  - Fixes segfault on startup (pre0)
    (LP: #391149)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/** \file
 
2
 * LPE knot effect implementation, see lpe-knot.cpp.
 
3
 */
 
4
/* Authors:
 
5
 *   Jean-Francois Barraud <jf.barraud@gmail.com>
 
6
 *   Johan Engelen <j.b.c.engelen@utwente.nl>
 
7
 *
 
8
 * Copyright (C) Johan Engelen 2007
 
9
 *
 
10
 * Released under GNU GPL, read the file 'COPYING' for more information
 
11
 */
 
12
 
 
13
#ifndef INKSCAPE_LPE_KNOT_H
 
14
#define INKSCAPE_LPE_KNOT_H
 
15
 
 
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"
 
24
 
 
25
namespace Inkscape {
 
26
namespace LivePathEffect {
 
27
 
 
28
class KnotHolderEntityCrossingSwitcher;
 
29
 
 
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 {
 
35
  Geom::Point pt;
 
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.
 
40
};
 
41
 
 
42
class CrossingPoints : public  std::vector<CrossingPoint>{
 
43
public:
 
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);
 
51
};
 
52
 
53
 
 
54
class LPEKnot : public Effect, GroupBBoxEffect {
 
55
public:
 
56
  LPEKnot(LivePathEffectObject *lpeobject);
 
57
  virtual ~LPEKnot();
 
58
  
 
59
  virtual void doBeforeEffect (SPLPEItem *lpeitem);
 
60
  virtual std::vector<Geom::Path> doEffect_path (std::vector<Geom::Path> const & input_path);
 
61
  
 
62
  /* the knotholder entity classes must be declared friends */
 
63
  friend class KnotHolderEntityCrossingSwitcher;
 
64
 
 
65
protected:
 
66
    virtual void addCanvasIndicators(SPLPEItem *lpeitem, std::vector<Geom::PathVector> &hp_vec);
 
67
  
 
68
private:
 
69
  void updateSwitcher();
 
70
 
 
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;
 
76
  double stroke_width;
 
77
  ArrayParam<double> crossing_points_vector;//svg storage of crossing_points
 
78
  
 
79
  LPEKnotNS::CrossingPoints crossing_points;//topology representation of the knot.
 
80
  
 
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.
 
83
 
 
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
 
87
  
 
88
  LPEKnot(const LPEKnot&);
 
89
  LPEKnot& operator=(const LPEKnot&);
 
90
  
 
91
};
 
92
  
 
93
} //namespace LivePathEffect
 
94
} //namespace Inkscape
 
95
 
 
96
#endif