cherish
Stroke.h
1 /* Stroke
2  * Ctor creates an empty stroke and initializes the initial
3  * parameters.
4  * appendPoint() adds a point to the stroke.
5  * getLength() is called to check if the stroke is long enough
6  * to display and keep it in memory.
7  *
8  * This class is rather low-level API. It must be used with the
9  * defined logic from upper-level class, e.g. from Canvas, or
10  * addGeometryCommand(), or from EventHanlder (when changing color)
11  * from normal mode to `selected` or `edit`.
12  *
13  */
14 
15 #ifndef STROKE
16 #define STROKE
17 
18 #include "Settings.h"
19 #include "Entity2D.h"
20 #include <osg/Geometry>
21 #include <osg/MatrixTransform>
22 #include <osgDB/ObjectWrapper>
23 
24 #include "libSGControls/ProgramStroke.h"
25 #include "ShaderedEntity2D.h"
26 
27 namespace entity {
28 
63 public:
65  Stroke();
66 
68  Stroke(const Stroke& copy, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);
69 
70  META_Node(entity, Stroke)
71 
72 #ifndef DOXYGEN_SHOULD_SKIP_THIS
73  /* functions to be used by OSG serialization only */
74  void setIsCurved(bool curved);
75  bool getIsCurved() const;
76 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
77 
78  virtual bool copyFrom(const entity::ShaderedEntity2D* copy);
79 
84  virtual bool redefineToShape(osg::MatrixTransform* t = 0);
85 
88  osg::Node* getMeshRepresentation() const;
89 
90 protected:
93  virtual bool redefineToShader(osg::MatrixTransform* t);
94 
95 public:
97  float getLength() const;
98 
100  bool isLengthy() const;
101 
104  cher::ENTITY_TYPE getEntityType() const;
105 
106  virtual ProgramStroke* getProgram() const;
107 
110  virtual void appendPoint(const float u, const float v);
111 
112 protected:
113 
115  osg::Vec3Array* getCurvePoints(const osg::Vec3Array* bezierPts) const;
116 
128  double normalize(osg::Vec3Array* path, const osg::Vec3f& center);
129 
132  void denormalize(osg::Vec3Array* path, const osg::Vec3f& center, double scale);
133 
134 private:
135  bool m_isCurved; // saved to file
136 };
137 }
138 
139 #endif // STROKE
140 
double normalize(osg::Vec3Array *path, const osg::Vec3f &center)
Definition: Stroke.cpp:254
osg::Node * getMeshRepresentation() const
Definition: Stroke.cpp:140
Scene graph entities.
Definition: AddEntityCommand.h:17
cher::ENTITY_TYPE getEntityType() const
Definition: Stroke.cpp:213
bool isLengthy() const
Definition: Stroke.cpp:208
Geometry class that defined strokes entered by a user. The creation and usage of this class must be f...
Definition: Stroke.h:62
virtual void scale(double scaleX, double scaleY, osg::Vec3f center)
Definition: ShaderedEntity2D.cpp:172
An interface class that deals with entity::Stroke shader&#39;s state.
Definition: ProgramStroke.h:19
Stroke()
Definition: Stroke.cpp:17
virtual bool redefineToShape(osg::MatrixTransform *t=0)
Definition: Stroke.cpp:60
void denormalize(osg::Vec3Array *path, const osg::Vec3f &center, double scale)
Definition: Stroke.cpp:272
virtual bool redefineToShader(osg::MatrixTransform *t)
Definition: Stroke.cpp:167
Settings is a configuration variables file for Cherish: enums, consts, defaults. Contains settings su...
virtual void appendPoint(const float u, const float v)
Definition: Stroke.cpp:223
virtual bool copyFrom(const entity::ShaderedEntity2D *copy)
Definition: Stroke.cpp:45
Abstract class for all the shaderized entities, i.e., strokes, polygons and line segments.
Definition: ShaderedEntity2D.h:18
float getLength() const
Definition: Stroke.cpp:196
osg::Vec3Array * getCurvePoints(const osg::Vec3Array *bezierPts) const
Definition: Stroke.cpp:228