- Main Page
- Classes
- Files
- Examples

- File List
- File Members

# include/board/Path.h

Go to the documentation of this file.

    00001 /* -*- mode: c++ -*- */
    00010 #ifndef _BOARD_PATH_H_
    00011 #define _BOARD_PATH_H_
    00012
    00013 #include "board/Point.h"
    00014 #include "board/Rect.h"
    00015 #include "board/Transforms.h"
    00016 #include <vector>
    00017 #include <iostream>
    00018
    00019 namespace LibBoard {
    00020
    00021
    00022
    00027 struct Path {
    00028
    00029   Path() : _closed( false ) { }
    00030
    00031   Path( const std::vector<Point> & points, bool closed )
    00032     : _points( points ), _closed( closed ) { }
    00033
    00034   Path( bool closed ) : _closed( closed ) { }
    00035
    00036   inline void clear();
    00037
    00038   inline bool closed() const;
    00039
    00040   inline bool empty() const;
    00041
    00042   inline unsigned int size() const;
    00043
    00044   inline void setClosed( bool closed  );
    00045
    00050   Point center() const;
    00051
    00059   Path & operator<<( const Point & p );
    00060
    00067   Path & pop_back();
    00068
    00076   Point & operator[]( const unsigned int n ) {
    00077     return _points[ n ];
    00078   }
    00079
    00087   const Point & operator[]( const unsigned int n ) const {
    00088     return _points[ n ];
    00089   }
    00090
    00099   Path & rotate( double angle, const Point & center );
    00100
    00109   Path rotated( double angle, const Point & center ) const;
    00110
    00118   Path & rotate( double angle );
    00119
    00127   Path rotated( double angle ) const;
    00128
    00137   Path & translate( double dx, double dy );
    00138
    00147   Path translated( double dx, double dy ) const;
    00148
    00157   Path & scale( double sx, double sy );
    00158
    00166   Path & scale( double s );
    00167
    00176   Path scaled( double sx, double sy )  const;
    00177
    00178   Path scaled( double s )  const;
    00179
    00185   void scaleAll( double s );
    00186
    00187   void flushPostscript( std::ostream & stream,
    00188                         const TransformEPS & transform ) const;
    00189
    00190   void flushFIG( std::ostream & stream,
    00191                  const TransformFIG & transform ) const;
    00192
    00193   void flushSVGPoints( std::ostream & stream,
    00194                        const TransformSVG & transform ) const;
    00195
    00196   void flushSVGCommands( std::ostream & stream,
    00197                          const TransformSVG & transform ) const;
    00198
    00199   Rect boundingBox() const;
    00200
    00201 protected:
    00202   std::vector<Point> _points;
    00203   bool _closed;
    00204 };
    00205
    00206 void
    00207 Path::clear()
    00208 {
    00209   _points.clear();
    00210 }
    00211
    00212 bool
    00213 Path::closed() const
    00214 {
    00215   return _closed;
    00216 }
    00217
    00218 bool
    00219 Path::empty() const
    00220 {
    00221   return _points.empty();
    00222 }
    00223
    00224 unsigned int
    00225 Path::size() const
    00226 {
    00227   return _points.size();
    00228 }
    00229
    00230 void
    00231 Path::setClosed( bool closed )
    00232 {
    00233   _closed = closed;
    00234 }
    00235
    00236 } // namespace LibBoard
    00237
    00238 #endif /* _PATH_H_ */
    00239