DGtal 1.3.0
Loading...
Searching...
No Matches
Path.h
1/* -*- mode: c++ -*- */
9/*
10 * \@copyright This File is part of the Board library which is
11 * licensed under the terms of the GNU Lesser General Public Licence.
12 * See the LICENCE file for further details.
13 */
14#ifndef _BOARD_PATH_H_
15#define _BOARD_PATH_H_
16
17#include "Board/Point.h"
18#include "Board/Rect.h"
19#include "Board/Transforms.h"
20#include <vector>
21#include <iostream>
22
23#ifdef WITH_CAIRO
24// cairo
25#if defined(__clang__)
26#pragma clang diagnostic push
27#pragma clang diagnostic ignored "-Wdocumentation"
28#endif
29#include <cairo.h>
30#if defined(__clang__)
31#pragma clang diagnostic pop
32#endif
33#endif
34
35namespace LibBoard {
36
37
38
43struct Path {
44
45 Path() : _closed( false ) { }
46
47 Path( const std::vector<Point> & points, bool closedPath )
48 : _points( points ), _closed( closedPath ) { }
49
50 Path( bool closedPath ) : _closed( closedPath ) { }
51
52 inline void clear();
53
54 inline bool closed() const;
55
56 inline bool empty() const;
57
58 inline unsigned int size() const;
59
60 inline void setClosed( bool closed );
61
66 Point center() const;
67
75 Path & operator<<( const Point & p );
76
83 Path & pop_back();
84
92 Point & operator[]( const unsigned int n ) {
93 return _points[ n ];
94 }
95
103 const Point & operator[]( const unsigned int n ) const {
104 return _points[ n ];
105 }
106
115 Path & rotate( double angle, const Point & center );
116
125 Path rotated( double angle, const Point & center ) const;
126
134 Path & rotate( double angle );
135
143 Path rotated( double angle ) const;
144
153 Path & translate( double dx, double dy );
154
163 Path translated( double dx, double dy ) const;
164
173 Path & scale( double sx, double sy );
174
182 Path & scale( double s );
183
192 Path scaled( double sx, double sy ) const;
193
194 Path scaled( double s ) const;
195
201 void scaleAll( double s );
202
203 void flushPostscript( std::ostream & stream,
204 const TransformEPS & transform ) const;
205
206 void flushFIG( std::ostream & stream,
207 const TransformFIG & transform ) const;
208
209 void flushSVGPoints( std::ostream & stream,
210 const TransformSVG & transform ) const;
211
212 void flushSVGCommands( std::ostream & stream,
213 const TransformSVG & transform ) const;
214
215#ifdef WITH_CAIRO
216 void flushCairoPoints( cairo_t *cr,
217 const TransformCairo & transform ) const;
218#endif
219
220 void flushTikZPoints( std::ostream & stream,
221 const TransformTikZ & transform ) const;
222
223 Rect boundingBox() const;
224
225protected:
226 std::vector<Point> _points;
228};
229
230void
232{
233 _points.clear();
234}
235
236bool
238{
239 return _closed;
240}
241
242bool
244{
245 return _points.empty();
246}
247
248unsigned int
250{
251 return (unsigned int)_points.size();
252}
253
254void
255Path::setClosed( bool closedPath )
256{
257 _closed = closedPath;
258}
259
260} // namespace LibBoard
261
262#endif /* _PATH_H_ */
263
A path, according to Postscript and SVG definition.
Definition: Path.h:43
unsigned int size() const
Definition: Path.h:249
Path translated(double dx, double dy) const
Definition: Path.cpp:94
Point & operator[](const unsigned int n)
Definition: Path.h:92
void flushCairoPoints(cairo_t *cr, const TransformCairo &transform) const
Definition: Path.cpp:235
void clear()
Definition: Path.h:231
Path(const std::vector< Point > &points, bool closedPath)
Definition: Path.h:47
Path & pop_back()
Definition: Path.cpp:22
const Point & operator[](const unsigned int n) const
Definition: Path.h:103
bool _closed
Definition: Path.h:227
std::vector< Point > _points
Definition: Path.h:226
void flushFIG(std::ostream &stream, const TransformFIG &transform) const
Definition: Path.cpp:173
Path & operator<<(const Point &p)
Definition: Path.cpp:29
Point center() const
Definition: Path.cpp:36
void setClosed(bool closed)
Definition: Path.h:255
bool closed() const
Definition: Path.h:237
void flushSVGPoints(std::ostream &stream, const TransformSVG &transform) const
Definition: Path.cpp:215
bool empty() const
Definition: Path.h:243
void scaleAll(double s)
Definition: Path.cpp:143
Path scaled(double sx, double sy) const
Definition: Path.cpp:131
Rect boundingBox() const
Definition: Path.cpp:272
Path rotated(double angle, const Point &center) const
Definition: Path.cpp:55
Path(bool closedPath)
Definition: Path.h:50
Path & translate(double dx, double dy)
Definition: Path.cpp:81
void flushPostscript(std::ostream &stream, const TransformEPS &transform) const
Definition: Path.cpp:154
void flushSVGCommands(std::ostream &stream, const TransformSVG &transform) const
Definition: Path.cpp:193
void flushTikZPoints(std::ostream &stream, const TransformTikZ &transform) const
Definition: Path.cpp:255
Struct representing a 2D point.
Definition: Point.h:27
Struct representing a rectangle on the plane.
Definition: Rect.h:26
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