DGtal 1.4.0
Loading...
Searching...
No Matches
ShapeList.h
1/* -*- mode: c++ -*- */
10/*
11 * \@copyright This File is part of the Board library which is
12 * licensed under the terms of the GNU Lesser General Public Licence.
13 * See the LICENCE file for further details.
14 */
15#ifndef _BOARD_SHAPELIST_H_
16#define _BOARD_SHAPELIST_H_
17
18#include "Board/Shapes.h"
19#include "Board/Tools.h"
20
21namespace LibBoard {
22
23
28struct ShapeList : public Shape {
29
30
31 inline ShapeList( int depth = -1 );
32
33 ShapeList( const ShapeList & other );
34
35 ~ShapeList();
36
42 const std::string & name() const;
43
44 ShapeList & clear();
45
46 Point center() const;
47
48 Shape & rotate( double angle, const Point & center );
49
50 ShapeList rotated( double angle, const Point & center );
51
52 Shape & rotate( double angle );
53
54 ShapeList rotated( double angle );
55
56 Shape & translate( double dx, double dy );
57
58 ShapeList translated( double dx, double dy );
59
60 Shape & scale( double sx, double sy );
61
62 Shape & scale( double s );
63
64 ShapeList scaled( double sx, double sy );
65
66 ShapeList scaled( double s );
67
74 void scaleAll( double s );
75
76 void flushPostscript( std::ostream & stream,
77 const TransformEPS & transform ) const;
78
79 void flushFIG( std::ostream & stream,
80 const TransformFIG & transform,
81 std::map<DGtal::Color,int> & colormap ) const;
82
83 void flushSVG( std::ostream & stream,
84 const TransformSVG & transform ) const;
85
86#ifdef WITH_CAIRO
87 void flushCairo( cairo_t *cr,
88 const TransformCairo & transform ) const;
89#endif
90
91 void flushTikZ( std::ostream & stream,
92 const TransformTikZ & transform ) const;
93
94 Rect boundingBox() const;
95
96 virtual int minDepth() const;
97
98 virtual int maxDepth() const;
99
100 void shiftDepth( int shift );
101
102 Shape * clone() const;
103
104 ShapeList & operator=( const ShapeList & other );
105
115 ShapeList & operator<<( const Shape & shape );
116
124 ShapeList & operator+=( const Shape & shape );
125
135 ShapeList & insert( const Shape & shape, int depth );
136
142 ShapeList & dup( unsigned int copies = 1 );
143
150 template<typename T>
151 T & last( const unsigned int position = 0 );
152
153 Shape & last( const unsigned int position = 0 );
154
160 Shape & top();
161
162private:
163 static const std::string _name;
165protected:
166
167 void addShape( const Shape & shape, double scaleFactor );
168
169 std::vector<Shape*> _shapes;
175 void free();
176};
177
183struct Group : public ShapeList {
184
185 Group( int depthValue = -1 )
186 : ShapeList( depthValue ), _clippingPath( true /* closed path */ ) { }
187
188 Group( const Group & other )
189 : ShapeList( other ), _clippingPath( other._clippingPath ) { }
190
191 ~Group() { };
192
198 const std::string & name() const;
199
200 Shape & rotate( double angle, const Point & center );
201
202 Shape & rotate( double angle );
203
204 Group rotated( double angle, const Point & center );
205
206 Group rotated( double angle );
207
208 Shape & translate( double dx, double dy );
209
210 Group translated( double dx, double dy );
211
212 Shape & scale( double sx, double sy );
213
214 Shape & scale( double s );
215
216 Group scaled( double sx, double sy );
217
218 Group scaled( double s );
219
228 void setClippingRectangle( float x, float y,
229 float width, float height );
230
236 void setClippingPath( const std::vector<Point> & points );
237
243 void setClippingPath( const Path & path );
244
245
246 void flushPostscript( std::ostream & stream,
247 const TransformEPS & transform ) const;
248
249 void flushFIG( std::ostream & stream,
250 const TransformFIG & transform,
251 std::map<DGtal::Color,int> & colormap ) const;
252
253 void flushSVG( std::ostream & stream,
254 const TransformSVG & transform ) const;
255
256#ifdef WITH_CAIRO
257 void flushCairo( cairo_t *cr,
258 const TransformCairo & transform ) const;
259#endif
260
261 void flushTikZ( std::ostream & stream,
262 const TransformTikZ & transform ) const;
263
264 Group & operator=( const Group & other );
265
266 Shape * clone() const;
267
268 Rect boundingBox() const;
269
270private:
271 static const std::string _name;
273 static unsigned int _clippingCount;
274};
275
276
277#include "ShapeList.ih"
278
279
280} // namespace LibBoard
281
282#endif /* _SHAPELIST_H_ */
283
A group of shapes. A group is basically a ShapeList except that when rendered in either an SVG of a F...
Definition ShapeList.h:183
static unsigned int _clippingCount
Definition ShapeList.h:273
void flushSVG(std::ostream &stream, const TransformSVG &transform) const
Group(const Group &other)
Definition ShapeList.h:188
Group rotated(double angle, const Point &center)
static const std::string _name
Definition ShapeList.h:271
const std::string & name() const
void flushFIG(std::ostream &stream, const TransformFIG &transform, std::map< DGtal::Color, int > &colormap) const
Shape * clone() const
void flushCairo(cairo_t *cr, const TransformCairo &transform) const
Rect boundingBox() const
Group(int depthValue=-1)
Definition ShapeList.h:185
Group scaled(double sx, double sy)
void flushPostscript(std::ostream &stream, const TransformEPS &transform) const
Group & operator=(const Group &other)
Group translated(double dx, double dy)
Shape & translate(double dx, double dy)
void setClippingPath(const std::vector< Point > &points)
void setClippingRectangle(float x, float y, float width, float height)
void flushTikZ(std::ostream &stream, const TransformTikZ &transform) const
A path, according to Postscript and SVG definition.
Definition Path.h:43
Struct representing a 2D point.
Definition Point.h:27
Struct representing a rectangle on the plane.
Definition Rect.h:26
A group of shapes.
Definition ShapeList.h:28
void addShape(const Shape &shape, double scaleFactor)
ShapeList scaled(double sx, double sy)
void flushCairo(cairo_t *cr, const TransformCairo &transform) const
const std::string & name() const
Definition ShapeList.cpp:32
void flushPostscript(std::ostream &stream, const TransformEPS &transform) const
void flushFIG(std::ostream &stream, const TransformFIG &transform, std::map< DGtal::Color, int > &colormap) const
Shape & rotate(double angle, const Point &center)
void flushSVG(std::ostream &stream, const TransformSVG &transform) const
virtual int minDepth() const
std::vector< Shape * > _shapes
Definition ShapeList.h:169
ShapeList(int depth=-1)
void flushTikZ(std::ostream &stream, const TransformTikZ &transform) const
Shape & translate(double dx, double dy)
void shiftDepth(int shift)
ShapeList & insert(const Shape &shape, int depth)
ShapeList & dup(unsigned int copies=1)
T & last(const unsigned int position=0)
ShapeList translated(double dx, double dy)
static const std::string _name
Definition ShapeList.h:163
Point center() const
ShapeList rotated(double angle, const Point &center)
Rect boundingBox() const
virtual int maxDepth() const
ShapeList & operator<<(const Shape &shape)
Definition ShapeList.cpp:94
ShapeList & operator+=(const Shape &shape)
ShapeList & operator=(const ShapeList &other)
Definition ShapeList.cpp:77
Shape * clone() const
void scaleAll(double s)
ShapeList & clear()
Definition ShapeList.cpp:43
Abstract structure for a 2D shape.
Structure representing a scaling and translation suitable for an Cairo output.
Definition Transforms.h:112
Structure representing a scaling and translation suitable for an EPS output.
Definition Transforms.h:59
Structure representing a scaling and translation suitable for an XFig output.
Definition Transforms.h:73
Structure representing a scaling and translation suitable for an SVG output.
Definition Transforms.h:95
Structure representing a scaling and translation suitable for an TikZ output.
Definition Transforms.h:129