00001
00011 #ifndef _BOARD_SHAPELIST_H_
00012 #define _BOARD_SHAPELIST_H_
00013
00014 #include "board/Shapes.h"
00015 #include "board/Tools.h"
00016
00017 namespace LibBoard {
00018
00023 struct ShapeList : public Shape {
00024
00025 inline ShapeList( int depth = -1 );
00026
00027 ShapeList( const ShapeList & other );
00028
00029 ~ShapeList();
00030
00036 const std::string & name() const;
00037
00038 ShapeList & clear();
00039
00040 Point center() const;
00041
00042 ShapeList & rotate( double angle, const Point & center );
00043
00044 ShapeList rotated( double angle, const Point & center );
00045
00046 ShapeList & rotate( double angle );
00047
00048 ShapeList rotated( double angle );
00049
00050 ShapeList & translate( double dx, double dy );
00051
00052 ShapeList translated( double dx, double dy );
00053
00054 ShapeList & scale( double sx, double sy );
00055
00056 ShapeList & scale( double s );
00057
00058 ShapeList scaled( double sx, double sy );
00059
00060 ShapeList scaled( double s );
00061
00068 void scaleAll( double s );
00069
00070 void flushPostscript( std::ostream & stream,
00071 const TransformEPS & transform ) const;
00072
00073 void flushFIG( std::ostream & stream,
00074 const TransformFIG & transform,
00075 std::map<Color,int> & colormap ) const;
00076
00077 void flushSVG( std::ostream & stream,
00078 const TransformSVG & transform ) const;
00079
00080 Rect boundingBox() const;
00081
00082 virtual int minDepth() const;
00083
00084 virtual int maxDepth() const;
00085
00086 void shiftDepth( int shift );
00087
00088 ShapeList * clone() const;
00089
00090 ShapeList & operator=( const ShapeList & other );
00091
00101 ShapeList & operator<<( const Shape & shape );
00102
00110 ShapeList & operator+=( const Shape & shape );
00111
00121 ShapeList & insert( const Shape & shape, int depth );
00122
00128 ShapeList & dup( unsigned int copies = 1 );
00129
00136 template<typename T>
00137 T & last( const unsigned int position = 0 );
00138
00139 Shape & last( const unsigned int position = 0 );
00140
00148 Shape & top();
00149
00150 private:
00151 static const std::string _name;
00153 protected:
00154
00155 void addShape( const Shape & shape, double scaleFactor );
00156
00157 std::vector<Shape*> _shapes;
00158 int _nextDepth;
00163 void free();
00164 };
00165
00171 struct Group : public ShapeList {
00172
00173 Group( int depth = -1 )
00174 : ShapeList( depth ), _clippingPath( true ) { }
00175
00176 Group( const Group & other )
00177 : ShapeList( other ), _clippingPath( other._clippingPath ) { }
00178
00179 ~Group() { };
00180
00186 const std::string & name() const;
00187
00188 Group & rotate( double angle, const Point & center );
00189
00190 Group & rotate( double angle );
00191
00192 Group rotated( double angle, const Point & center );
00193
00194 Group rotated( double angle );
00195
00196 Group & translate( double dx, double dy );
00197
00198 Group translated( double dx, double dy );
00199
00200 Group & scale( double sx, double sy );
00201
00202 Group & scale( double s );
00203
00204 Group scaled( double sx, double sy );
00205
00206 Group scaled( double s );
00207
00216 void setClippingRectangle( float x, float y,
00217 float width, float height );
00218
00224 void setClippingPath( const std::vector<Point> & points );
00225
00231 void setClippingPath( const Path & path );
00232
00233
00234 void flushPostscript( std::ostream & stream,
00235 const TransformEPS & transform ) const;
00236
00237 void flushFIG( std::ostream & stream,
00238 const TransformFIG & transform,
00239 std::map<Color,int> & colormap ) const;
00240
00241 void flushSVG( std::ostream & stream,
00242 const TransformSVG & transform ) const;
00243
00244 Group & operator=( const Group & other );
00245
00246 Group * clone() const;
00247
00248 Rect boundingBox() const;
00249
00250 private:
00251 static const std::string _name;
00252 Path _clippingPath;
00253 static unsigned int _clippingCount;
00254 };
00255
00256
00257 #include "ShapeList.ih"
00258
00259
00260 }
00261
00262 #endif
00263