Board  0.9.4
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  explicit 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 
82  Path & operator<<( const std::vector<Point> & v );
83 
89  Path & pop_back();
90 
98  inline Point & operator[]( const std::size_t n );
99 
107  inline const Point & operator[]( const std::size_t n ) const;
108 
117  Path & rotate( double angle, const Point & center );
118 
128  Path & rotateDeg( double angle, const Point & center );
129 
139  Path rotated( double angle, const Point & center ) const;
140 
150  Path rotatedDeg( double angle, const Point & center ) const;
151 
159  Path & rotate( double angle );
160 
168  Path & rotateDeg( double angle );
169 
177  Path rotated( double angle ) const;
178 
186  Path rotatedDeg( double angle ) const;
187 
196  Path & translate( double dx, double dy );
197 
206  Path translated( double dx, double dy ) const;
207 
216  Path & scale( double sx, double sy );
217 
225  Path & scale( double s );
226 
227 
236  Path scaled( double sx, double sy ) const;
237 
238 
246  Path scaled( double s ) const;
247 
253  void scaleAll( double s );
254 
255  void flushPostscript( std::ostream & stream,
256  const TransformEPS & transform ) const;
257 
258  void flushFIG( std::ostream & stream,
259  const TransformFIG & transform ) const;
260 
261  void flushSVGPoints( std::ostream & stream,
262  const TransformSVG & transform ) const;
263 
264  void flushSVGCommands( std::ostream & stream,
265  const TransformSVG & transform ) const;
266 
267  void flushTikZPoints( std::ostream & stream,
268  const TransformTikZ & transform ) const;
269 
275  Rect boundingBox() const;
276 
277  const std::vector<Point> points() const;
278 
279  std::ostream & flush( std::ostream & ) const;
280 
281 protected:
282  std::vector<Point> _points;
283  bool _closed;
284 };
285 
286 void
287 Path::clear()
288 {
289  _points.clear();
290 }
291 
292 Point &
293 Path::operator[]( const std::size_t n )
294 {
295  return _points[ n ];
296 }
297 
298 const Point &
299 Path::operator[]( const std::size_t n ) const {
300  return _points[ n ];
301 }
302 
303 bool
304 Path::closed() const
305 {
306  return _closed;
307 }
308 
309 bool
310 Path::empty() const
311 {
312  return _points.empty();
313 }
314 
315 std::size_t
316 Path::size() const
317 {
318  return _points.size();
319 }
320 
321 void
322 Path::setClosed( bool closed )
323 {
324  _closed = closed;
325 }
326 
327 } // namespace LibBoard
328 
329 
330 std::ostream & operator<<( std::ostream & out, const LibBoard::Path & path );
331 
332 #endif /* _PATH_H_ */
333 
Path & scale(double sx, double sy)
Definition: Path.cpp:149
Path & operator<<(const Point &p)
Definition: Path.cpp:42
Structure representing a scaling and translation suitable for an TikZ output.
Definition: Transforms.h:137
Rect boundingBox() const
Definition: Path.cpp:292
Path & translate(double dx, double dy)
Definition: Path.cpp:122
Definition: Board.h:41
The Point structure. @copyright This source code is part of the Board project, a C++ library whose pu...
Point center() const
Definition: Path.cpp:56
A path, according to Postscript and SVG definition.
Definition: Path.h:41
Path scaled(double sx, double sy) const
Definition: Path.cpp:172
Struct representing a 2D point.
Definition: Point.h:39
Path rotated(double angle, const Point &center) const
Definition: Path.cpp:79
Path & pop_back()
Definition: Path.cpp:35
Structure representing a scaling and translation suitable for an XFig output.
Definition: Transforms.h:93
Path & rotate(double angle, const Point &center)
Definition: Path.cpp:61
@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:116
@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:184
Path translated(double dx, double dy) const
Definition: Path.cpp:135
Path rotatedDeg(double angle, const Point &center) const
Definition: Path.cpp:92
Point & operator[](const std::size_t n)
Definition: Path.h:293
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
Path & rotateDeg(double angle, const Point &center)
Definition: Path.cpp:73