Board  0.9.5
Dot.h
Go to the documentation of this file.
1 /* -*- mode: c++ -*- */
26 #ifndef BOARD_DOT_H
27 #define BOARD_DOT_H
28 
29 #include "board/ShapeWithStyle.h"
30 
31 namespace LibBoard
32 {
33 
42 struct Dot : public ShapeWithStyle {
43 
44  inline Dot(double x, double y, Color color = Style::defaultPenColor(), double lineWidth = Style::defaultLineWidth());
45 
46  inline Dot(const Point & p, Color color = Style::defaultPenColor(), double lineWidth = Style::defaultLineWidth());
47 
53  const std::string & name() const override;
54 
55  Point center(LineWidthFlag flage = IgnoreLineWidth) const override;
56 
65  Dot & rotate(double angle, const Point & center) override;
66 
75  Dot rotated(double angle, const Point & center) const;
76 
84  Dot & rotate(double angle) override;
85 
93  Dot rotated(double angle) const;
94 
103  Dot & translate(double dx, double dy) override;
104 
113  Dot translated(double dx, double dy) const;
114 
123  Dot & scale(double sx, double sy) override;
124 
132  Dot & scale(double s) override;
133 
144  Dot scaled(double sx, double sy) const;
145 
155  Dot scaled(double s) const;
156 
163  void scaleAll(double s) override;
164 
165  void flushPostscript(std::ostream & stream, const TransformEPS & transform) const override;
166 
167  void flushFIG(std::ostream & stream, const TransformFIG & transform, std::map<Color, int> & colormap) const override;
168 
169  void flushSVG(std::ostream & stream, const TransformSVG & transform) const override;
170 
171  void flushTikZ(std::ostream & stream, const TransformTikZ & transform) const override;
172 
178  virtual void accept(ShapeVisitor & visitor) override;
179 
185  virtual void accept(const ShapeVisitor & visitor) override;
186 
192  virtual void accept(ConstShapeVisitor & visitor) const override;
193 
199  virtual void accept(const ConstShapeVisitor & visitor) const override;
200 
206  virtual Shape * accept(CompositeShapeTransform & transform) const override;
207 
213  virtual Shape * accept(const CompositeShapeTransform & transform) const override;
214 
220  Rect boundingBox(LineWidthFlag) const override;
221 
222  Dot * clone() const override;
223 
224  Dot(const Dot &) = default;
225  Dot(Dot &&) = default;
226  Dot & operator=(Dot &&) = default;
227  Dot & operator=(const Dot &) = default;
228  ~Dot() override = default;
229 
230 private:
231  static const std::string _name;
233 protected:
234  double _x;
235  double _y;
236 };
237 } // namespace LibBoard
238 
239 /*
240  * Inline methods
241  */
242 
243 namespace LibBoard
244 {
245 Dot::Dot(double x, double y, Color color, double lineWidth) //
246  : ShapeWithStyle(color, Color::Null, lineWidth, SolidStyle, RoundCap, MiterJoin), _x(x), _y(y)
247 {
248 }
249 
250 Dot::Dot(const Point & p, Color color, double lineWidth) //
251  : ShapeWithStyle(color, Color::Null, lineWidth, SolidStyle, RoundCap, MiterJoin), _x(p.x), _y(p.y)
252 {
253 }
254 } // namespace LibBoard
255 
256 #endif /* BOARD_DOT_H */
LibBoard::Style::defaultPenColor
static const Color & defaultPenColor()
defaultPenColor
Definition: Style.h:281
LibBoard::Dot::boundingBox
Rect boundingBox(LineWidthFlag) const override
Definition: Dot.cpp:195
ShapeWithStyle.h
@copyright This source code is part of the Board project, a C++ library whose purpose is to allow sim...
LibBoard::Style::defaultLineWidth
static const double & defaultLineWidth()
defaultLineWidth
Definition: Style.h:276
LibBoard::Dot::clone
Dot * clone() const override
Definition: Dot.cpp:206
LibBoard::Dot::flushSVG
void flushSVG(std::ostream &stream, const TransformSVG &transform) const override
Definition: Dot.cpp:150
LibBoard::Dot::flushTikZ
void flushTikZ(std::ostream &stream, const TransformTikZ &transform) const override
Definition: Dot.cpp:158
LibBoard::Rect
Struct representing a rectangle on the plane.
Definition: Rect.h:39
LibBoard::Dot::scale
Dot & scale(double sx, double sy) override
Definition: Dot.cpp:93
LibBoard::CompositeShapeTransform
A CompositeShapeTransform may be used to duplicate/transform a composite shape tree.
Definition: ShapeVisitor.h:103
LibBoard::Dot::scaleAll
void scaleAll(double s) override
Definition: Dot.cpp:113
LibBoard::Dot::flushPostscript
void flushPostscript(std::ostream &stream, const TransformEPS &transform) const override
Definition: Dot.cpp:119
LibBoard::Dot
A line between two points.
Definition: Dot.h:42
LibBoard::Point
Struct representing a 2D point.
Definition: Point.h:42
LibBoard::TransformEPS
Structure representing a scaling and translation suitable for an EPS output.
Definition: Transforms.h:71
LibBoard::Dot::accept
virtual void accept(ShapeVisitor &visitor) override
Accepts a visitor object.
Definition: Dot.cpp:165
LibBoard::Shape
Abstract structure for a 2D shape.
Definition: Shape.h:63
LibBoard::Dot::rotated
Dot rotated(double angle, const Point &center) const
Definition: Dot.cpp:66
LibBoard::ConstShapeVisitor
A ConstShapeVisitor may visit const shapes of a composite shape tree in back-to-front order.
Definition: ShapeVisitor.h:78
LibBoard::Dot::flushFIG
void flushFIG(std::ostream &stream, const TransformFIG &transform, std::map< Color, int > &colormap) const override
Definition: Dot.cpp:128
LibBoard::Dot::scaled
Dot scaled(double sx, double sy) const
Definition: Dot.cpp:103
LibBoard::Dot::center
Point center(LineWidthFlag flage=IgnoreLineWidth) const override
Definition: Dot.cpp:55
LibBoard::Dot::translated
Dot translated(double dx, double dy) const
Definition: Dot.cpp:88
LibBoard::TransformTikZ
Structure representing a scaling and translation suitable for an TikZ output.
Definition: Transforms.h:126
LibBoard::Dot::translate
Dot & translate(double dx, double dy) override
Definition: Dot.cpp:81
LibBoard::TransformFIG
Structure representing a scaling and translation suitable for an XFig output.
Definition: Transforms.h:87
LibBoard::Dot::_x
double _x
Definition: Dot.h:234
LibBoard::Dot::rotate
Dot & rotate(double angle, const Point &center) override
Definition: Dot.cpp:60
LibBoard::Dot::name
const std::string & name() const override
Definition: Dot.cpp:50
LibBoard::Dot::_y
double _y
Definition: Dot.h:235
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::Color
Structure representing an RGB triple.
Definition: Color.h:43
LibBoard::ShapeWithStyle
Abstract structure for a 2D shape.
Definition: ShapeWithStyle.h:38