DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Transforms.h
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_TRANSFORMS_H_
15 #define _BOARD_TRANSFORMS_H_
16 
17 #include <limits>
18 #include <vector>
19 #include <cmath>
20 
21 namespace LibBoard {
22 
23 struct Rect;
24 struct Shape;
25 struct ShapeList;
26 
31 struct Transform {
32 public:
33  inline Transform();
34  virtual ~Transform() { };
35  virtual double mapX( double x ) const;
36  virtual double mapY( double y ) const = 0;
37  virtual void apply( double & x, double & y ) const;
38  virtual double scale( double x ) const;
39  virtual double rounded( double x ) const;
40  virtual void setBoundingBox( const Rect & rect,
41  const double pageWidth,
42  const double pageHeight,
43  const double margin ) = 0;
44 
45  static inline double round( const double & x );
46 
47 protected:
48  double _scale;
49  double _deltaX;
50  double _deltaY;
51  double _height;
52 };
53 
59 struct TransformEPS : public Transform {
60 public:
61  double mapY( double y ) const;
62  void setBoundingBox( const Rect & rect,
63  const double pageWidth,
64  const double pageHeight,
65  const double margin );
66 };
67 
73 struct TransformFIG : public Transform {
74 public:
75  inline TransformFIG();
76  double rounded( double x ) const;
77  double mapY( double y ) const;
78  int mapWidth( double width ) const;
79  void setBoundingBox( const Rect & rect,
80  const double pageWidth,
81  const double pageHeight,
82  const double margin );
83  void setDepthRange( const ShapeList & shapes );
84  int mapDepth( int depth ) const;
85 private:
86  int _maxDepth;
87  int _minDepth;
88 };
89 
95 struct TransformSVG : public Transform {
96 public:
97  double rounded( double x ) const;
98  double mapY( double y ) const;
99  double mapWidth( double width ) const;
100  void setBoundingBox( const Rect & rect,
101  const double pageWidth,
102  const double pageHeight,
103  const double margin );
104 };
105 
106 #ifdef WITH_CAIRO
107 
112 struct TransformCairo : public Transform {
113 public:
114  double rounded( double x ) const;
115  double mapY( double y ) const;
116  double mapWidth( double width ) const;
117  void setBoundingBox( const Rect & rect,
118  const double pageWidth,
119  const double pageHeight,
120  const double margin );
121 };
122 #endif
123 
129 struct TransformTikZ : public TransformSVG {
130 };
131 
132 #include "Transforms.ih"
133 
134 } // namespace LibBoard
135 
136 #endif /* _TRANSFORMS_H_ */