Board 0.9.6
Text.h
Go to the documentation of this file.
1/* -*- mode: c++ -*- */
26#ifndef BOARD_TEXT_H
27#define BOARD_TEXT_H
28
30
31// TODO : Add a sketchy line text font
32
33namespace LibBoard
34{
35
40struct Text : public ShapeWithStyle {
41
52 Text(double x, double y, const std::string & text, const Fonts::Font font, double size, Color color = Color::Black);
53
63 Text(Point p, const std::string & text, const Fonts::Font font, double size, Color color = Color::Black);
64
76 Text(double x, double y, const std::string & text, const Fonts::Font font, const std::string & svgFont, double size, Color color = Color::Black);
77
88 Text(Point p, const std::string & text, const Fonts::Font font, const std::string & svgFont, double size, Color color = Color::Black);
89
95 const std::string & name() const override;
96
97 Point center(LineWidthFlag lineWidthFlag = IgnoreLineWidth) const override;
98
99 Text & rotate(double angle, const Point & center) override;
100
101 Text rotated(double angle, const Point & center) const;
102
103 Text & rotate(double angle) override;
104
105 Text rotated(double angle) const;
106
115 Text & translate(double dx, double dy) override;
116
125 Text translated(double dx, double dy) const;
126
135 Text & scale(double sx, double sy) override;
136
144 Text & scale(double s) override;
145
154 Text scaled(double sx, double sy) const;
155
163 Text scaled(double s) const;
164
171 void scaleAll(double s) override;
172
173 void flushPostscript(std::ostream & stream, const TransformEPS & transform) const override;
174
175 void flushFIG(std::ostream & stream, const TransformFIG & transform, std::map<Color, int> & colormap) const override;
176
177 void flushSVG(std::ostream & stream, const TransformSVG & transform) const override;
178
179 void flushTikZ(std::ostream & stream, const TransformTikZ & transform) const override;
180
186 virtual void accept(ShapeVisitor & visitor) override;
187
193 virtual void accept(const ShapeVisitor & visitor) override;
194
200 virtual void accept(ConstShapeVisitor & visitor) const override;
201
207 virtual void accept(const ConstShapeVisitor & visitor) const override;
208
213 virtual Shape * accept(CompositeShapeTransform & transform) const override;
214
220 virtual Shape * accept(const CompositeShapeTransform & transform) const override;
221
222 Rect boundingBox(LineWidthFlag) const override;
223
224 Text * clone() const override;
225
226 Text(const Text &) = default;
227 Text(Text &&) = default;
228 Text & operator=(Text &&) = default;
229 Text & operator=(const Text &) = default;
230 ~Text() override = default;
231
232private:
233 static const std::string _name;
235 double boxHeight(const Transform &) const;
236 double boxLength(const Transform &) const;
237
238 double angle() const;
239
240 Point position() const;
241
242protected:
243 std::string _text;
245 std::string _svgFont;
246 double _size;
247 double _xScale;
248 double _yScale;
249 Path _box; // Rectangle around the text
250};
251
252} // namespace LibBoard
253
254#endif /* BOARD_TEXT_H */
@copyright This source code is part of the Board project, a C++ library whose purpose is to allow sim...
Group text()
Definition board_font_text.cpp:17
Structure representing an RGB triple.
Definition Color.h:43
static const Color Black
Definition Color.h:156
Font
Definition PSFonts.h:51
Definition Board.h:55
LineWidthFlag
Definition Style.h:57
@ IgnoreLineWidth
Definition Style.h:58
A CompositeShapeTransform may be used to duplicate/transform a composite shape tree.
Definition ShapeVisitor.h:104
A ConstShapeVisitor may visit const shapes of a composite shape tree in back-to-front order.
Definition ShapeVisitor.h:79
A path, according to Postscript and SVG definition.
Definition Path.h:45
Struct representing a 2D point.
Definition Point.h:42
Struct representing a rectangle on the plane.
Definition Rect.h:40
A ShapeVisitor visits all shapes in a composite shape tree in back-to-front order.
Definition ShapeVisitor.h:54
Abstract structure for a 2D shape.
Definition ShapeWithStyle.h:38
Abstract structure for a 2D shape.
Definition Shape.h:64
A piece of text.
Definition Text.h:40
void flushSVG(std::ostream &stream, const TransformSVG &transform) const override
Definition Text.cpp:256
double _yScale
Definition Text.h:248
double _size
Definition Text.h:246
Text scaled(double sx, double sy) const
Definition Text.cpp:175
Path _box
Definition Text.h:249
Text & rotate(double angle, const Point &center) override
Definition Text.cpp:110
virtual void accept(ShapeVisitor &visitor) override
Accepts a visitor object.
Definition Text.cpp:325
Text translated(double dx, double dy) const
Definition Text.cpp:153
~Text() override=default
Text(Text &&)=default
void scaleAll(double s) override
Definition Text.cpp:185
const std::string & name() const override
Definition Text.cpp:100
void flushPostscript(std::ostream &stream, const TransformEPS &transform) const override
Definition Text.cpp:224
Text & operator=(const Text &)=default
std::string _text
Definition Text.h:243
std::string _svgFont
Definition Text.h:245
Text rotated(double angle, const Point &center) const
Definition Text.cpp:124
Text & scale(double sx, double sy) override
Definition Text.cpp:158
Text(const Text &)=default
Fonts::Font _font
Definition Text.h:244
double _xScale
Definition Text.h:247
Point center(LineWidthFlag lineWidthFlag=IgnoreLineWidth) const override
Definition Text.cpp:105
void flushTikZ(std::ostream &stream, const TransformTikZ &transform) const override
Definition Text.cpp:275
Text * clone() const override
Definition Text.cpp:190
Rect boundingBox(LineWidthFlag) const override
Definition Text.cpp:355
Text & operator=(Text &&)=default
void flushFIG(std::ostream &stream, const TransformFIG &transform, std::map< Color, int > &colormap) const override
Definition Text.cpp:237
Text & translate(double dx, double dy) override
Definition Text.cpp:147
Structure representing a scaling and translation suitable for an EPS output.
Definition Transforms.h:71
Structure representing a scaling and translation suitable for an XFig output.
Definition Transforms.h:87
Structure representing a scaling and translation suitable for an SVG output.
Definition Transforms.h:109
Structure representing a scaling and translation suitable for an TikZ output.
Definition Transforms.h:126
Definition Transforms.h:46