Board  0.9.4
Transforms.h
Go to the documentation of this file.
1 /* -*- mode: c++ -*- */
26 #ifndef _BOARD_TRANSFORMS_H_
27 #define _BOARD_TRANSFORMS_H_
28 
29 #include <limits>
30 #include <vector>
31 #include <cmath>
32 #include "TransformMatrix.h"
33 
34 namespace LibBoard {
35 
36 struct Rect;
37 struct Shape;
38 struct ShapeList;
39 
44 struct Transform {
45 public:
46  inline Transform();
47  virtual ~Transform() { }
48  virtual double mapX( double x ) const;
49  virtual double mapY( double y ) const = 0;
50  virtual Point map( const Point & ) const;
51  virtual void apply( double & x, double & y ) const;
52  virtual double scale( double x ) const;
53  virtual Point scale( const Point & ) const;
54  virtual double rounded( double x ) const;
55  virtual void setBoundingBox( const Rect & rect,
56  const double pageWidth,
57  const double pageHeight,
58  const double margin ) = 0;
59  static inline double round( const double & x );
60 
61 protected:
62  double _scale;
63  double _deltaX;
64  double _deltaY;
65  double _height;
66 };
67 
73 struct TransformEPS : public Transform {
74 public:
75  double mapWidth( double w ) const;
76  double mapY( double y ) const;
77  void setBoundingBox( const Rect & rect,
78  const double pageWidth,
79  const double pageHeight,
80  const double margin );
81  double scaleBackMM(double);
82  Rect pageBoundingBox() const;
83 
84 private:
85  Rect _pageBoundingBox;
86 };
87 
93 struct TransformFIG : public Transform {
94 public:
95  inline TransformFIG();
96  double rounded( double x ) const;
97  double mapY( double y ) const;
98  int mapWidth( double width ) const;
99  void setBoundingBox( const Rect & rect,
100  const double pageWidth,
101  const double pageHeight,
102  const double margin );
103  void setDepthRange( const ShapeList & shapes );
104  int mapDepth( int depth ) const;
105 private:
106  int _maxDepth;
107  int _minDepth;
108  double _postscriptScale;
109 };
110 
116 struct TransformSVG : public Transform {
117 public:
118  double rounded( double x ) const;
119  double mapY( double y ) const;
120  double mapWidth( double width ) const;
121  void setBoundingBox( const Rect & rect,
122  const double pageWidth,
123  const double pageHeight,
124  const double margin );
125  double scaleBackMM(double);
126  TransformMatrix matrix() const;
127  Point translation() const;
128  double deltaX() const;
129  double deltaY() const;
130 };
131 
137 struct TransformTikZ : public TransformSVG {
138 };
139 
140 
141 #include "Transforms.ih"
142 
143 } // namespace LibBoard
144 
145 #endif /* _TRANSFORMS_H_ */
Definition: TransformMatrix.h:35
Definition: Transforms.h:44
Structure representing a scaling and translation suitable for an TikZ output.
Definition: Transforms.h:137
Definition: Board.h:41
Struct representing a 2D point.
Definition: Point.h:39
Structure representing a scaling and translation suitable for an XFig output.
Definition: Transforms.h:93
Structure representing a scaling and translation suitable for an SVG output.
Definition: Transforms.h:116
A group of shapes.
Definition: ShapeList.h:45
Structure representing a scaling and translation suitable for an EPS output.
Definition: Transforms.h:73
@copyright This source code is part of the Board project, a C++ library whose purpose is to allow sim...
Struct representing a rectangle on the plane.
Definition: Rect.h:38