Board  0.9.2
Path.h
Go to the documentation of this file.
1 /* -*- mode: c++ -*- */
26 #ifndef _BOARD_PATH_H_
27 #define _BOARD_PATH_H_
28 
29 #include "board/Point.h"
30 #include "board/Rect.h"
31 #include "board/Transforms.h"
32 #include <vector>
33 #include <iostream>
34 
35 namespace LibBoard {
36 
41 struct Path {
42 
43  Path() : _closed( false ) { }
44 
45  Path( const std::vector<Point> & points, bool closed )
46  : _points( points ), _closed( closed ) { }
47 
48  Path( bool closed ) : _closed( closed ) { }
49 
50  inline void clear();
51 
52  inline bool closed() const;
53 
54  inline bool empty() const;
55 
56  inline std::size_t size() const;
57 
58  inline void setClosed( bool closed );
59 
64  Point center() const;
65 
73  Path & operator<<( const Point & p );
74 
80  Path & pop_back();
81 
89  inline Point & operator[]( const std::size_t n );
90 
98  inline const Point & operator[]( const std::size_t n ) const;
99 
108  Path & rotate( double angle, const Point & center );
109 
119  Path rotated( double angle, const Point & center ) const;
120 
128  Path & rotate( double angle );
129 
137  Path rotated( double angle ) const;
138 
147  Path & translate( double dx, double dy );
148 
157  Path translated( double dx, double dy ) const;
158 
167  Path & scale( double sx, double sy );
168 
176  Path & scale( double s );
177 
178 
187  Path scaled( double sx, double sy ) const;
188 
189 
197  Path scaled( double s ) const;
198 
204  void scaleAll( double s );
205 
206  void flushPostscript( std::ostream & stream,
207  const TransformEPS & transform ) const;
208 
209  void flushFIG( std::ostream & stream,
210  const TransformFIG & transform ) const;
211 
212  void flushSVGPoints( std::ostream & stream,
213  const TransformSVG & transform ) const;
214 
215  void flushSVGCommands( std::ostream & stream,
216  const TransformSVG & transform ) const;
217 
218  void flushTikZPoints( std::ostream & stream,
219  const TransformTikZ & transform ) const;
220 
226  Rect boundingBox() const;
227 
228 protected:
229  std::vector<Point> _points;
230  bool _closed;
231 };
232 
233 void
234 Path::clear()
235 {
236  _points.clear();
237 }
238 
239 Point &
240 Path::operator[]( const std::size_t n )
241 {
242  return _points[ n ];
243 }
244 
245 const Point &
246 Path::operator[]( const std::size_t n ) const {
247  return _points[ n ];
248 }
249 
250 bool
251 Path::closed() const
252 {
253  return _closed;
254 }
255 
256 bool
257 Path::empty() const
258 {
259  return _points.empty();
260 }
261 
262 std::size_t
263 Path::size() const
264 {
265  return _points.size();
266 }
267 
268 void
269 Path::setClosed( bool closed )
270 {
271  _closed = closed;
272 }
273 
274 } // namespace LibBoard
275 
276 #endif /* _PATH_H_ */
277 
Path & scale(double sx, double sy)
Definition: Path.cpp:117
Path & operator<<(const Point &p)
Definition: Path.cpp:40
Structure representing a scaling and translation suitable for an TikZ output.
Definition: Transforms.h:130
Rect boundingBox() const
Definition: Path.cpp:260
Path & translate(double dx, double dy)
Definition: Path.cpp:90
Definition: Board.h:40
The Point structure. @copyright This source code is part of the Board project, a C++ library whose pu...
Point center() const
Definition: Path.cpp:47
A path, according to Postscript and SVG definition.
Definition: Path.h:41
Path scaled(double sx, double sy) const
Definition: Path.cpp:140
Struct representing a 2D point.
Definition: Point.h:38
Path rotated(double angle, const Point &center) const
Definition: Path.cpp:64
Path & pop_back()
Definition: Path.cpp:33
Structure representing a scaling and translation suitable for an XFig output.
Definition: Transforms.h:87
Path & rotate(double angle, const Point &center)
Definition: Path.cpp:52
@copyright This source code is part of the Board project, a C++ library whose purpose is to allow sim...
Structure representing a scaling and translation suitable for an SVG output.
Definition: Transforms.h:109
@copyright This source code is part of the Board project, a C++ library whose purpose is to allow sim...
void scaleAll(double s)
Definition: Path.cpp:152
Path translated(double dx, double dy) const
Definition: Path.cpp:103
Point & operator[](const std::size_t n)
Definition: Path.h:240
Structure representing a scaling and translation suitable for an EPS output.
Definition: Transforms.h:73
Struct representing a rectangle on the plane.
Definition: Rect.h:38