Board  0.6.devel
 All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Macros
Shapes.h
Go to the documentation of this file.
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_SHAPES_H_
15 #define _BOARD_SHAPES_H_
16 
17 #include "Board/Point.h"
18 #include "Board/Rect.h"
19 #include "Board/Path.h"
20 #include "Board/Transforms.h"
21 #include "Board/PSFonts.h"
22 #include "Board/Tools.h"
23 #include <string>
24 #include <vector>
25 #include <iostream>
26 #include <map>
27 #include <cmath>
28 
29 #include "DGtal/io/Color.h"
30 
31 #ifdef WITH_CAIRO
32 // cairo
33 #include <cairo.h>
34 #endif
35 
36 #ifndef M_PI
37 #define M_PI 3.14159265358979323846
38 #endif
39 
40 #ifndef M_PI_2
41 #define M_PI_2 1.57079632679489661923
42 #endif
43 
44 namespace LibBoard {
45 
46 
51 struct Shape {
52 
55  enum LineStyle { SolidStyle = 0,
61 
70  inline Shape( DGtal::Color penColor, DGtal::Color fillColor,
71  double lineWidth,
72  LineStyle style,
73  const LineCap cap,
74  const LineJoin join,
75  int depth );
76 
80  virtual ~Shape() { }
81 
87  virtual const std::string & name() const;
88 
94  virtual Shape * clone() const = 0;
95 
101  inline bool filled() const { return _fillColor != DGtal::Color::None; }
102 
108  virtual Point center() const = 0;
109 
118  virtual Shape & rotate( double angle, const Point & center ) = 0;
119 
127  virtual Shape & rotate( double angle ) = 0;
128 
137  inline Shape & rotateDeg( double angle, const Point & center );
138 
147  inline Shape & rotateDeg( double angle );
148 
157  virtual Shape & translate( double dx, double dy ) = 0;
158 
167  virtual Shape & scale( double sx, double sy ) = 0;
168 
176  virtual Shape & scale( double s ) = 0;
177 
183  virtual Rect boundingBox() const = 0;
184 
185 
190  inline Rect bbox();
191 
192 
198  inline Shape & operator--();
199 
205  inline Shape & operator++();
206 
207 
214  virtual void scaleAll( double s ) = 0;
215 
216 
224  virtual void flushPostscript( std::ostream & stream,
225  const TransformEPS & transform ) const = 0;
226 
234  virtual void flushFIG( std::ostream & stream,
235  const TransformFIG & transform,
236  std::map<DGtal::Color,int> & colormap ) const = 0;
237 
245  virtual void flushSVG( std::ostream & stream,
246  const TransformSVG & transform ) const = 0;
247 
248 #ifdef WITH_CAIRO
249 
256  virtual void flushCairo( cairo_t *cr,
257  const TransformCairo & transform ) const = 0;
258 #endif
259 
267  virtual void flushTikZ( std::ostream & stream,
268  const TransformTikZ & transform ) const = 0;
269 
270  inline int depth() const;
271 
272  virtual void depth( int );
273 
274  virtual void shiftDepth( int shift );
275 
276  inline const DGtal::Color & penColor() const;
277 
278  inline const DGtal::Color & fillColor() const;
279 
280 private:
281  static const std::string _name;
283 protected:
284 
285  int _depth;
286  DGtal::Color _penColor;
287  DGtal::Color _fillColor;
288  double _lineWidth;
299  std::string svgProperties( const TransformSVG & transform ) const;
300 
301 
307  std::string postscriptProperties() const;
308 
309 #ifdef WITH_CAIRO
310  // cairo
316  void setCairoDashStyle(cairo_t *cr, LineStyle type) const;
317 #endif
318 
324  std::string tikzProperties( const TransformTikZ & transform ) const;
325 };
326 
327 
328 inline Rect
330 {
331  return this->boundingBox();
332 }
333 
334 
335 inline Shape &
337 {
338  ++_depth;
339  return *this;
340 }
341 
342 inline Shape &
344 {
345  --_depth;
346  return *this;
347 }
348 
349 
350 inline int
352 {
353  return _depth;
354 }
355 
356 inline const DGtal::Color &
358 {
359  return _penColor;
360 }
361 
362 const DGtal::Color &
364 {
365  return _fillColor;
366 }
367 
368 Shape &
369 Shape::rotateDeg( double angle, const Point & aCenter )
370 {
371  return rotate( angle * ( M_PI / 180.0 ), aCenter );
372 }
373 
374 Shape &
375 Shape::rotateDeg( double angle )
376 {
377  return rotate( angle * ( M_PI / 180.0 ), center() );
378 }
379 
388 struct Dot : public Shape {
389 
390  inline Dot( double x, double y,
391  DGtal::Color color,
392  double lineWidth,
393  int depth = -1 );
394 
400  const std::string & name() const;
401 
402  Point center() const;
403 
412  Dot & rotate( double angle, const Point & center );
413 
422  Dot rotated( double angle, const Point & center ) const;
423 
431  Dot & rotate( double angle );
432 
440  Dot rotated( double angle ) const;
441 
450  Dot & translate( double dx, double dy );
451 
460  Dot translated( double dx, double dy ) const;
461 
462  Shape & scale( double sx, double sy );
463 
464  Shape & scale( double s );
465 
476  Dot scaled( double sx, double sy ) const;
477 
478  Dot scaled( double s ) const;
479 
486  void scaleAll( double s );
487 
488  void flushPostscript( std::ostream & stream,
489  const TransformEPS & transform ) const;
490 
491  void flushFIG( std::ostream & stream,
492  const TransformFIG & transform,
493  std::map<DGtal::Color,int> & colormap ) const;
494 
495  void flushSVG( std::ostream & stream,
496  const TransformSVG & transform ) const;
497 
498 #ifdef WITH_CAIRO
499  void flushCairo( cairo_t *cr,
500  const TransformCairo & transform ) const;
501 #endif
502 
503  void flushTikZ( std::ostream & stream,
504  const TransformTikZ & transform ) const;
505 
506  Rect boundingBox() const;
507 
508  Dot * clone() const;
509 
510 private:
511  static const std::string _name;
513 protected:
514  double _x;
515  double _y;
516 };
517 
522 struct Line : public Shape {
523 
535  inline Line( double x1, double y1, double x2, double y2,
536  DGtal::Color color,
537  double lineWidth,
538  const LineStyle style = SolidStyle,
539  const LineCap cap = ButtCap,
540  const LineJoin join = MiterJoin,
541  int depth = -1 );
542 
548  const std::string & name() const;
549 
550  Point center() const;
551 
552  Line & rotate( double angle, const Point & center );
553 
562  Line rotated( double angle, const Point & center ) const;
563 
564  Line & rotate( double angle );
565 
573  Line rotated( double angle ) const;
574 
575  Line & translate( double dx, double dy );
576 
585  Line translated( double dx, double dy ) const;
586 
587  Shape & scale( double sx, double sy );
588 
589  Shape & scale( double s );
590 
599  Line scaled( double sx, double sy ) const;
600 
601  Line scaled( double s ) const;
602 
609  void scaleAll( double s );
610 
611  void flushPostscript( std::ostream & stream,
612  const TransformEPS & transform ) const;
613 
614  void flushFIG( std::ostream & stream,
615  const TransformFIG & transform,
616  std::map<DGtal::Color,int> & colormap ) const;
617 
618  void flushSVG( std::ostream & stream,
619  const TransformSVG & transform ) const;
620 
621 #ifdef WITH_CAIRO
622  void flushCairo( cairo_t *cr,
623  const TransformCairo & transform ) const;
624 #endif
625 
626  void flushTikZ( std::ostream & stream,
627  const TransformTikZ & transform ) const;
628 
629  Rect boundingBox() const;
630 
631  Line * clone() const;
632 
633 private:
634  static const std::string _name;
636 protected:
637  double _x1;
638  double _y1;
639  double _x2;
640  double _y2;
641 };
642 
643 
644 
645 
650 struct Arrow : public Line {
651 
664  inline Arrow( double x1, double y1, double x2, double y2,
665  DGtal::Color penColor, DGtal::Color fillColor,
666  double lineWidth,
667  const LineStyle style = SolidStyle,
668  const LineCap cap = ButtCap,
669  const LineJoin join = MiterJoin,
670  int depth = -1 );
671 
677  const std::string & name() const;
678 
687  Arrow rotated( double angle, const Point & center ) const;
688 
696  Arrow rotated( double angle ) const;
697 
706  Arrow translated( double dx, double dy ) const;
707 
716  Arrow scaled( double sx, double sy ) const;
717 
718  Arrow scaled( double s ) const;
719 
720  void flushPostscript( std::ostream & stream,
721  const TransformEPS & transform ) const;
722 
723  void flushFIG( std::ostream & stream,
724  const TransformFIG & transform,
725  std::map<DGtal::Color,int> & colormap ) const;
726  void flushSVG( std::ostream & stream,
727  const TransformSVG & transform ) const;
728 
729 #ifdef WITH_CAIRO
730  void flushCairo( cairo_t *cr,
731  const TransformCairo & transform ) const;
732 #endif
733 
734  void flushTikZ( std::ostream & stream,
735  const TransformTikZ & transform ) const;
736 
737  Arrow * clone() const;
738 
739 private:
740  static const std::string _name;
741 };
742 
747 struct Polyline : public Shape {
748  inline Polyline( const std::vector<Point> & points,
749  bool closed,
750  DGtal::Color penColor, DGtal::Color fillColor,
751  double lineWidth,
752  const LineStyle lineStyle = SolidStyle,
753  const LineCap cap = ButtCap,
754  const LineJoin join = MiterJoin,
755  int depth = -1 );
756 
757  inline Polyline( const Path & path,
758  DGtal::Color penColor, DGtal::Color fillColor,
759  double lineWidth,
760  const LineStyle lineStyle = SolidStyle,
761  const LineCap cap = ButtCap,
762  const LineJoin join = MiterJoin,
763  int depth = -1 );
764 
765  inline Polyline( bool closed, DGtal::Color penColor, DGtal::Color fillColor,
766  double lineWidth,
767  const LineStyle lineStyle = SolidStyle,
768  const LineCap cap = ButtCap,
769  const LineJoin join = MiterJoin,
770  int depth = -1 );
771 
777  const std::string & name() const;
778 
779  Point center() const;
780 
788  Polyline & operator<<( const Point & p );
789 
797  Point & operator[]( const unsigned int n ) {
798  return _path[ n ];
799  }
800 
801 
802  Polyline & rotate( double angle, const Point & center );
803 
812  Polyline rotated( double angle, const Point & center ) const;
813 
814  Polyline & rotate( double angle );
815 
823  Polyline rotated( double angle ) const;
824 
825  Polyline & translate( double dx, double dy );
826 
835  Polyline translated( double dx, double dy ) const;
836 
837  Shape & scale( double sx, double sy );
838 
839  Shape & scale( double s );
840 
849  Polyline scaled( double sx, double sy ) const;
850 
851  Polyline scaled( double s ) const;
852 
859  void scaleAll( double s );
860 
861  void flushPostscript( std::ostream & stream,
862  const TransformEPS & transform ) const;
863 
864  void flushFIG( std::ostream & stream,
865  const TransformFIG & transform,
866  std::map<DGtal::Color,int> & colormap ) const;
867 
868  void flushSVG( std::ostream & stream,
869  const TransformSVG & transform ) const;
870 
871 #ifdef WITH_CAIRO
872  void flushCairo( cairo_t *cr,
873  const TransformCairo & transform ) const;
874 #endif
875 
876  void flushTikZ( std::ostream & stream,
877  const TransformTikZ & transform ) const;
878 
879  Rect boundingBox() const;
880 
881  Polyline * clone() const;
882 
883 private:
884  static const std::string _name;
886 protected:
888 };
889 
894 struct Rectangle : public Polyline {
895 
896  inline Rectangle( double x, double y, double width, double height,
897  DGtal::Color penColor, DGtal::Color fillColor,
898  double lineWidth,
899  const LineStyle style = SolidStyle,
900  const LineCap cap = ButtCap,
901  const LineJoin join = MiterJoin,
902  int depth = -1 );
903 
904  inline Rectangle( const Rect & rect,
905  DGtal::Color penColor, DGtal::Color fillColor,
906  double lineWidth,
907  const LineStyle style = SolidStyle,
908  const LineCap cap = ButtCap,
909  const LineJoin join = MiterJoin,
910  int depth = -1 );
911 
917  const std::string & name() const;
918 
919  double x() const { return _path[0].x; }
920  double y() const { return _path[0].y; }
921  double width() { return (_path[1] - _path[0]).norm(); }
922  double height() { return (_path[0] - _path[3]).norm(); }
923  Point topLeft() { return Point( _path[0].x, _path[0].y ); }
924  Point topRight() { return Point( _path[1].x, _path[1].y ); }
925  Point bottomLeft() { return Point( _path[3].x, _path[3].y ); }
926  Point bottomRight() { return Point( _path[2].x, _path[2].y ); }
927 
928 
937  Rectangle rotated( double angle, const Point & center ) const;
938 
946  Rectangle rotated( double angle ) const;
947 
956  Rectangle translated( double dx, double dy ) const;
957 
966  Rectangle scaled( double sx, double sy ) const;
967 
968  Rectangle scaled( double s ) const;
969 
976  void scaleAll( double s );
977 
978  void flushFIG( std::ostream & stream,
979  const TransformFIG & transform,
980  std::map<DGtal::Color,int> & colormap ) const;
981 
982  void flushSVG( std::ostream & stream,
983  const TransformSVG & transform ) const;
984 
985 #ifdef WITH_CAIRO
986  void flushCairo( cairo_t *cr,
987  const TransformCairo & transform ) const;
988 #endif
989 
990  void flushTikZ( std::ostream & stream,
991  const TransformTikZ & transform ) const;
992 
993  Rectangle * clone() const;
994 
995 private:
996  static const std::string _name;
998 protected:
1000 };
1001 
1002 
1003 
1008 struct Image : public Rectangle {
1009 
1022  inline Image( double x0, double y0, double width, double height,
1023  std::string fileName, int depthValue, double alpha=1.0 );
1029  const std::string & name() const;
1030 
1031  Image * clone() const;
1032 
1033  void flushFIG( std::ostream & stream,
1034  const TransformFIG & transform,
1035  std::map<DGtal::Color,int> & colormap ) const;
1036 
1037  void flushSVG( std::ostream & stream,
1038  const TransformSVG & transform ) const;
1039 
1040 #ifdef WITH_CAIRO
1041  void flushCairo( cairo_t *cr,
1042  const TransformCairo & transform ) const;
1043 #endif
1044 
1045  void flushTikZ( std::ostream & stream,
1046  const TransformTikZ & transform ) const;
1047 
1048 
1049 private:
1050  static const std::string _name;
1052 protected:
1053  double _x0;
1054  double _y0;
1055  double _width;
1056  double _height;
1057  std::string _filename;
1058  double _alpha;
1059 };
1060 
1061 
1062 
1067 struct Triangle : public Polyline {
1068 
1069  Triangle( const Point & p1, const Point & p2, const Point & p3,
1070  DGtal::Color pen,
1071  DGtal::Color fill,
1072  double lineWidth,
1073  const LineStyle style = SolidStyle,
1074  const LineCap cap = ButtCap,
1075  const LineJoin join = MiterJoin,
1076  int depthValue = -1 )
1077  : Polyline( std::vector<Point>(), true, pen, fill, lineWidth, style, cap, join, depthValue ) {
1078  _path << p1;
1079  _path << p2;
1080  _path << p3;
1081  }
1082 
1083  Triangle( const double x1, const double y1,
1084  const double x2, const double y2,
1085  const double x3, const double y3,
1086  DGtal::Color pen,
1087  DGtal::Color fill,
1088  double lineWidth,
1089  const LineStyle style = SolidStyle,
1090  const LineCap cap = ButtCap,
1091  const LineJoin join = MiterJoin,
1092  int depthValue = -1 )
1093  : Polyline( std::vector<Point>(), true, pen, fill, lineWidth, style, cap, join, depthValue ) {
1094  _path << Point( x1, y1 );
1095  _path << Point( x2, y2 );
1096  _path << Point( x3, y3 );
1097  }
1098 
1104  const std::string & name() const;
1105 
1106  Triangle rotated( double angle ) const;
1107 
1116  Triangle translated( double dx, double dy ) const;
1117 
1126  Triangle scaled( double sx, double sy ) const;
1127 
1128  Triangle scaled( double s ) const;
1129 
1130  Triangle * clone() const;
1131 
1132 private:
1133  static const std::string _name;
1135 protected:
1136 };
1137 
1138 
1143 struct GouraudTriangle : public Polyline {
1144 
1145 
1146  GouraudTriangle( const Point & p0, const DGtal::Color & color0,
1147  const Point & p1, const DGtal::Color & color1,
1148  const Point & p2, const DGtal::Color & color2,
1149  int subdivisions,
1150  int depth = -1 );
1151 
1152  GouraudTriangle( const Point & p0, float brightness0,
1153  const Point & p1, float brightness1,
1154  const Point & p2, float brightness2,
1155  const DGtal::Color & fillColor,
1156  int subdivisions,
1157  int depth = -1 );
1158 
1164  const std::string & name() const;
1165 
1166  Point center() const;
1167 
1168  GouraudTriangle & rotate( double angle, const Point & center );
1169 
1170  GouraudTriangle rotated( double angle, const Point & center ) const;
1171 
1172  GouraudTriangle & rotate( double angle );
1173 
1174  GouraudTriangle rotated( double angle ) const;
1175 
1184  GouraudTriangle translated( double dx, double dy ) const;
1185 
1194  GouraudTriangle scaled( double sx, double sy ) const;
1195 
1196  GouraudTriangle scaled( double s ) const;
1197 
1198 
1205  void scaleAll( double s );
1206 
1213  void flushPostscript( std::ostream & stream,
1214  const TransformEPS & transform ) const;
1215 
1228  void flushFIG( std::ostream & stream,
1229  const TransformFIG & transform,
1230  std::map<DGtal::Color,int> & colormap ) const;
1231 
1232  void flushSVG( std::ostream & stream,
1233  const TransformSVG & transform ) const;
1234 
1235 #ifdef WITH_CAIRO
1236  void flushCairo( cairo_t *cr,
1237  const TransformCairo & transform ) const;
1238 #endif
1239 
1240  void flushTikZ( std::ostream & stream,
1241  const TransformTikZ & transform ) const;
1242 
1243  GouraudTriangle * clone() const;
1244 
1245 private:
1246  static const std::string _name;
1248 protected:
1249  DGtal::Color _color0;
1250  DGtal::Color _color1;
1251  DGtal::Color _color2;
1253 };
1254 
1259 struct Ellipse : public Shape {
1260 
1261  Ellipse( double x, double y,
1262  double xRadius, double yRadius,
1263  DGtal::Color pen, DGtal::Color fill,
1264  double lineWidth,
1265  const LineStyle lineStyle = SolidStyle,
1266  int depthValue = -1 )
1267  : Shape( pen, fill,
1268  lineWidth, lineStyle, ButtCap, MiterJoin, depthValue ),
1269  _center( x, y ), _xRadius( xRadius ), _yRadius( yRadius ),
1270  _angle( 0.0 ),
1271  _circle( false ) {
1272  while ( _angle > M_PI_2 ) _angle -= M_PI;
1273  while ( _angle < -M_PI_2 ) _angle += M_PI;
1274  }
1275 
1281  const std::string & name() const;
1282 
1283  Point center() const;
1284 
1285  Ellipse & rotate( double angle, const Point & center );
1286 
1295  Ellipse rotated( double angle, const Point & center ) const;
1296 
1297  Ellipse & rotate( double angle );
1298 
1306  Ellipse rotated( double angle ) const;
1307 
1308  Ellipse & translate( double dx, double dy );
1309 
1318  Ellipse translated( double dx, double dy ) const;
1319 
1320  Shape & scale( double sx, double sy );
1321 
1322  Shape & scale( double s );
1323 
1332  Ellipse scaled( double sx, double sy ) const;
1333 
1334  Ellipse scaled( double s ) const;
1335 
1342  void scaleAll( double s );
1343 
1344  void flushPostscript( std::ostream & stream,
1345  const TransformEPS & transform ) const;
1346 
1347  void flushFIG( std::ostream & stream,
1348  const TransformFIG & transform,
1349  std::map<DGtal::Color,int> & colormap ) const;
1350 
1351  void flushSVG( std::ostream & stream,
1352  const TransformSVG & transform ) const;
1353 
1354 #ifdef WITH_CAIRO
1355  void flushCairo( cairo_t *cr,
1356  const TransformCairo & transform ) const;
1357 #endif
1358 
1359  void flushTikZ( std::ostream & stream,
1360  const TransformTikZ & transform ) const;
1361 
1362  Rect boundingBox() const;
1363 
1364  Ellipse * clone() const;
1365 
1366 private:
1367  static const std::string _name;
1369 protected:
1371  double _xRadius;
1372  double _yRadius;
1373  double _angle;
1374  bool _circle;
1375 };
1376 
1381 struct Circle : public Ellipse {
1382 
1383  Circle( double x, double y, double radius,
1384  DGtal::Color pen, DGtal::Color fill,
1385  double lineWidth,
1386  const LineStyle style = SolidStyle,
1387  int depthValue = -1 )
1388  : Ellipse( x, y, radius, radius, pen, fill, lineWidth, style, depthValue )
1389  { _circle = true; }
1390 
1396  const std::string & name() const;
1397 
1398  Point center() const;
1399 
1400  Circle & rotate( double angle, const Point & center );
1401 
1402  Circle rotated( double angle, const Point & center ) const;
1403 
1404  Circle & rotate( double angle );
1405 
1406  Circle rotated( double angle ) const;
1407 
1408  Circle & translate( double dx, double dy );
1409 
1410  Circle translated( double dx, double dy ) const;
1411 
1412  Shape & scale( double sx, double sy );
1413 
1414  Shape & scale( double s );
1415 
1416  Circle scaled( double sx, double sy ) const;
1417 
1418  Circle scaled( double s ) const;
1419 
1426  void scaleAll( double s );
1427 
1428  void flushSVG( std::ostream & stream,
1429  const TransformSVG & transform ) const;
1430 
1431 #ifdef WITH_CAIRO
1432  void flushCairo( cairo_t *cr,
1433  const TransformCairo & transform ) const;
1434 #endif
1435 
1436  void flushTikZ( std::ostream & stream,
1437  const TransformTikZ & transform ) const;
1438 
1439  Circle * clone() const;
1440 
1441 private:
1442  static const std::string _name;
1443 };
1444 
1449 struct Arc : public Circle {
1450 
1451  Arc( double x, double y, double radius, double angle1, double angle2, bool negative,
1452  DGtal::Color pen, DGtal::Color fill,
1453  double lineWidth,
1454  const LineStyle style = SolidStyle,
1455  int depthValue = -1 )
1456  : Circle( x, y, radius, pen, fill, lineWidth, style, depthValue )
1457  { _angle1 = angle1; _angle2 = angle2; _negative = negative; }
1458 
1464  const std::string & name() const;
1465  void
1466  flushPostscript( std::ostream & stream,
1467  const TransformEPS & transform ) const;
1468  void
1469  flushSVG( std::ostream & stream,
1470  const TransformSVG & transform ) const;
1471 
1472 #ifdef WITH_CAIRO
1473  void flushCairo( cairo_t *cr,
1474  const TransformCairo & transform ) const;
1475 #endif
1476 
1477  void
1478  flushTikZ( std::ostream & stream,
1479  const TransformTikZ & transform ) const;
1480 
1481 private:
1482  static const std::string _name;
1484 protected:
1485  double _angle1;
1486  double _angle2;
1488 };
1489 
1490 
1495 struct Text : public Shape {
1496 
1510  Text( double x, double y,
1511  const std::string & text,
1512  const Fonts::Font font,
1513  double size,
1514  DGtal::Color color = DGtal::Color::Black,
1515  int depthValue = -1 )
1516  : Shape( color, DGtal::Color::None, 1.0, SolidStyle, ButtCap, MiterJoin, depthValue ),
1517  _position( x, y ), _text( text ), _font( font ),
1518  _angle( 0.0 ), _size( size ),
1519  _xScale( 1.0 ), _yScale( 1.0 ) { }
1520 
1521 
1536  Text( double x, double y,
1537  const std::string & text,
1538  const Fonts::Font font,
1539  const std::string & svgFont,
1540  double size,
1541  DGtal::Color color = DGtal::Color::Black,
1542  int depthValue = -1 )
1543  : Shape( color, DGtal::Color::None, 1.0, SolidStyle, ButtCap, MiterJoin, depthValue ),
1544  _position( x, y ),
1545  _text( text ), _font( font ), _svgFont( svgFont ),
1546  _angle( 0.0 ),
1547  _size( size ),
1548  _xScale( 1.0 ), _yScale( 1.0 ) { }
1549 
1555  const std::string & name() const;
1556 
1557  Point center() const;
1558 
1559  Text & rotate( double angle, const Point & center );
1560 
1561  Text rotated( double angle, const Point & center ) const;
1562 
1563  Text & rotate( double angle );
1564 
1565  Text rotated( double angle ) const;
1566 
1567  Text & translate( double dx, double dy );
1568 
1569  Text translated( double dx, double dy ) const;
1570 
1571  Shape & scale( double sx, double sy );
1572 
1573  Shape & scale( double s );
1574 
1575  Text scaled( double sx, double sy ) const;
1576 
1577  Text scaled( double s ) const;
1578 
1585  void scaleAll( double s );
1586 
1587  void flushPostscript( std::ostream & stream,
1588  const TransformEPS & transform ) const;
1589 
1590  void flushFIG( std::ostream & stream,
1591  const TransformFIG & transform,
1592  std::map<DGtal::Color,int> & colormap ) const;
1593 
1594  void flushSVG( std::ostream & stream,
1595  const TransformSVG & transform ) const;
1596 
1597 #ifdef WITH_CAIRO
1598  void flushCairo( cairo_t *cr,
1599  const TransformCairo & transform ) const;
1600 #endif
1601 
1602  void flushTikZ( std::ostream & stream,
1603  const TransformTikZ & transform ) const;
1604 
1605  Rect boundingBox() const;
1606 
1607  Text * clone() const;
1608 
1609 private:
1610  static const std::string _name;
1612 protected:
1614  std::string _text;
1616  std::string _svgFont;
1617  double _angle;
1618  double _size;
1619  double _xScale;
1620  double _yScale;
1621 };
1622 
1631 bool shapeGreaterDepth( const Shape *s1, const Shape *s2 );
1632 
1633 
1634 } // namespace LibBoard
1635 
1636 /*
1637  * Inline methods
1638  */
1639 #include "Shapes.ih"
1640 
1641 
1642 #endif /* _SHAPE_H_ */
1643 
1644