Board  0.9.5
Image.h
Go to the documentation of this file.
1 /* -*- mode: c++ -*- */
25 #ifndef BOARD_IMAGE_H
26 #define BOARD_IMAGE_H
27 
28 #include <string>
29 #include "board/Polyline.h"
30 #include "board/Shape.h"
31 #include "board/TransformMatrix.h"
32 
33 namespace LibBoard
34 {
35 
41 struct Image : public Shape {
42 
57  Image(const char * filename, double left, double top, double width, double height = 0.0);
58 
66  Image(const char * filename, const Rect & rect);
67 
73  const std::string & name() const override;
74 
80  Image * clone() const override;
81 
90  Shape & rotate(double angle, const Point & center) override;
91 
99  Shape & rotate(double angle) override;
100 
108  Image rotated(double angle) const;
109 
118  Image rotated(double angle, const Point &) const;
119 
128  Shape & translate(double dx, double dy) override;
129 
138  Image translated(double dx, double dy) const;
139 
148  Shape & scale(double sx, double sy) override;
149 
157  Shape & scale(double s) override;
158 
167  Image scaled(double sx, double sy);
168 
175  Rect boundingBox(LineWidthFlag lineWidthFlag) const override;
176 
183  void scaleAll(double s) override;
184 
192  void flushPostscript(std::ostream & stream, const TransformEPS & transform) const override;
193 
202  void flushFIG(std::ostream & stream, const TransformFIG & transform, std::map<Color, int> & colormap) const override;
203 
211  void flushSVG(std::ostream & stream, const TransformSVG & transform) const override;
212 
220  void flushTikZ(std::ostream & stream, const TransformTikZ & transform) const override;
221 
227  virtual void accept(ShapeVisitor & visitor) override;
228 
234  virtual void accept(const ShapeVisitor & visitor) override;
235 
241  virtual void accept(ConstShapeVisitor & visitor) const override;
242 
248  virtual void accept(const ConstShapeVisitor & visitor) const override;
249 
255  virtual Shape * accept(CompositeShapeTransform & transform) const override;
256 
262  virtual Shape * accept(const CompositeShapeTransform & transform) const override;
263 
264  Image(const Image &) = default;
265  Image(Image &&) = default;
266  Image & operator=(Image &&) = default;
267  ~Image() override = default;
268 
269 private:
270  static const std::string _name;
271  Polyline _rectangle;
272  Polyline _originalRectangle;
273  TransformMatrix _transformMatrixSVG;
274  TransformMatrix _transformMatrixEPS;
275  std::string _filename;
276 };
277 
278 } // namespace LibBoard
279 
280 #endif /* SHAPE_H */
Shape.h
@copyright This source code is part of the Board project, a C++ library whose purpose is to allow sim...
LibBoard::Polyline
A polygonal line described by a series of 2D points.
Definition: Polyline.h:38
LibBoard::Image::Image
Image(const char *filename, double left, double top, double width, double height=0.0)
Definition: Image.cpp:45
LibBoard::Image::scaleAll
void scaleAll(double s) override
Definition: Image.cpp:156
LibBoard::Rect
Struct representing a rectangle on the plane.
Definition: Rect.h:39
LibBoard::Image::translate
Shape & translate(double dx, double dy) override
Definition: Image.cpp:111
LibBoard::Image::flushTikZ
void flushTikZ(std::ostream &stream, const TransformTikZ &transform) const override
Definition: Image.cpp:240
TransformMatrix.h
@copyright This source code is part of the Board project, a C++ library whose purpose is to allow sim...
LibBoard::CompositeShapeTransform
A CompositeShapeTransform may be used to duplicate/transform a composite shape tree.
Definition: ShapeVisitor.h:103
LibBoard::Image::scale
Shape & scale(double sx, double sy) override
Definition: Image.cpp:124
LibBoard::Point
Struct representing a 2D point.
Definition: Point.h:42
LibBoard::Image::flushSVG
void flushSVG(std::ostream &stream, const TransformSVG &transform) const override
Definition: Image.cpp:215
LibBoard::TransformEPS
Structure representing a scaling and translation suitable for an EPS output.
Definition: Transforms.h:71
LibBoard::Image::translated
Image translated(double dx, double dy) const
Definition: Image.cpp:119
LibBoard::Image::accept
virtual void accept(ShapeVisitor &visitor) override
Accepts a visitor object.
Definition: Image.cpp:246
LibBoard::Shape
Abstract structure for a 2D shape.
Definition: Shape.h:63
LibBoard::Image::clone
Image * clone() const override
Definition: Image.cpp:78
LibBoard::ConstShapeVisitor
A ConstShapeVisitor may visit const shapes of a composite shape tree in back-to-front order.
Definition: ShapeVisitor.h:78
LibBoard::Image::flushPostscript
void flushPostscript(std::ostream &stream, const TransformEPS &transform) const override
Definition: Image.cpp:163
LibBoard::TransformTikZ
Structure representing a scaling and translation suitable for an TikZ output.
Definition: Transforms.h:126
LibBoard::Image::name
const std::string & name() const override
Definition: Image.cpp:73
LibBoard::Image::rotate
Shape & rotate(double angle, const Point &center) override
Definition: Image.cpp:83
LibBoard::TransformFIG
Structure representing a scaling and translation suitable for an XFig output.
Definition: Transforms.h:87
LibBoard::Image::flushFIG
void flushFIG(std::ostream &stream, const TransformFIG &transform, std::map< Color, int > &colormap) const override
Definition: Image.cpp:201
LibBoard::Shape::center
virtual Point center(LineWidthFlag lineWidthFlag=IgnoreLineWidth) const
Definition: Shape.cpp:59
LibBoard::Image::rotated
Image rotated(double angle) const
Definition: Image.cpp:101
LibBoard::Image::scaled
Image scaled(double sx, double sy)
Definition: Image.cpp:146
LibBoard::Image::boundingBox
Rect boundingBox(LineWidthFlag lineWidthFlag) const override
Definition: Image.cpp:151
LibBoard::TransformMatrix
Definition: TransformMatrix.h:36
Polyline.h
@copyright This source code is part of the Board project, a C++ library whose purpose is to allow sim...
LibBoard::ShapeVisitor
A ShapeVisitor visits all shapes in a composite shape tree in back-to-front order.
Definition: ShapeVisitor.h:53
LibBoard::TransformSVG
Structure representing a scaling and translation suitable for an SVG output.
Definition: Transforms.h:109
LibBoard::Image
Structure for a bitmap image shape.
Definition: Image.h:41