Board 0.9.6
ShapeWithStyle.h
Go to the documentation of this file.
1/* -*- mode: c++ -*- */
26#ifndef BOARD_SHAPE_WITH_STYLE_H
27#define BOARD_SHAPE_WITH_STYLE_H
28
29#include <board/Shape.h>
30
31namespace LibBoard
32{
33
38struct ShapeWithStyle : public Shape {
39
50 inline ShapeWithStyle(Color penColor, Color fillColor, double lineWidth, LineStyle style, const LineCap cap, const LineJoin join);
51
57 inline ShapeWithStyle(const Style & style);
58
59 ShapeWithStyle(const ShapeWithStyle & other);
60
62
67
71 const std::string & name() const;
72
73 Shape * clone() const = 0;
74
75 inline const Color & penColor() const;
76
77 inline ShapeWithStyle & setPenColor(const Color &);
78
79 inline const Color & fillColor() const;
80
81 inline ShapeWithStyle & setFillColor(const Color &);
82
83 inline double lineWidth() const;
84
85 inline ShapeWithStyle & setLineWidth(double);
86
87 inline LineStyle lineStyle() const;
88
90
91 inline LineCap lineCap() const;
92
94
95 inline LineJoin lineJoin() const;
96
98
99 inline Style style() const;
100
101 inline ShapeWithStyle & setStyle(const Style &);
102
106 static void setLineWidthScaling(bool);
107
113 inline bool filled() const;
114
115private:
116 static const std::string _name;
117 static bool _lineWidthScaling;
118
119protected:
120 inline void updateLineWidth(double s);
121
123};
124
125} // namespace LibBoard
126
127/*
128 * Inline methods
129 */
130
131namespace LibBoard
132{
133ShapeWithStyle::ShapeWithStyle(Color penColor, Color fillColor, double lineWidth, LineStyle lineStyle, const LineCap lineCap, const LineJoin lineJoin)
134 : _style{penColor, fillColor, lineWidth, lineStyle, lineCap, lineJoin}
135{
136}
137
139 : _style(style)
140{
141}
142
144{
145 return _style.penColor;
146}
147
149{
150 _style.penColor = color;
151 return *this;
152}
153
155{
156 return _style.fillColor;
157}
158
160{
161 _style.fillColor = color;
162 return *this;
163}
164
166{
167 return _style.lineWidth;
168}
169
171{
172 _style.lineWidth = width;
173 return *this;
174}
175
177{
178 return _style.lineStyle;
179}
180
182{
184 return *this;
185}
186
188{
189 return _style.lineCap;
190}
191
193{
194 _style.lineCap = cap;
195 return *this;
196}
197
199{
200 return _style.lineJoin;
201}
202
204{
205 _style.lineJoin = join;
206 return *this;
207}
208
210{
211 _style = style;
212 return *this;
213}
214
216{
217 return _style;
218}
219
221{
222 return fillColor() != Color::Null;
223}
224
226{
227 if (_lineWidthScaling) {
228 _style.lineWidth *= s;
229 }
230}
231
232} // namespace LibBoard
233
234#endif /* BOARD_SHAPE_WITH_STYLE_H */
@copyright This source code is part of the Board project, a C++ library whose purpose is to allow sim...
Structure representing an RGB triple.
Definition Color.h:43
static const Color Null
Definition Color.h:155
Definition Board.h:55
LineStyle
Definition Style.h:47
LineCap
Definition Style.h:35
LineJoin
Definition Style.h:41
Abstract structure for a 2D shape.
Definition ShapeWithStyle.h:38
Shape * clone() const =0
ShapeWithStyle & setStyle(const Style &)
Definition ShapeWithStyle.h:209
Style _style
Definition ShapeWithStyle.h:122
ShapeWithStyle & setLineCap(LineCap)
Definition ShapeWithStyle.h:192
ShapeWithStyle & setLineWidth(double)
Definition ShapeWithStyle.h:170
const Color & penColor() const
Definition ShapeWithStyle.h:143
ShapeWithStyle & setLineJoin(LineJoin)
Definition ShapeWithStyle.h:203
bool filled() const
Definition ShapeWithStyle.h:220
LineJoin lineJoin() const
Definition ShapeWithStyle.h:198
ShapeWithStyle & setLineStyle(LineStyle)
Definition ShapeWithStyle.h:181
ShapeWithStyle & setPenColor(const Color &)
Definition ShapeWithStyle.h:148
Style style() const
Definition ShapeWithStyle.h:215
const std::string & name() const
Definition ShapeWithStyle.cpp:37
void updateLineWidth(double s)
Definition ShapeWithStyle.h:225
ShapeWithStyle & operator=(const ShapeWithStyle &other)
Definition ShapeWithStyle.cpp:47
ShapeWithStyle(Color penColor, Color fillColor, double lineWidth, LineStyle style, const LineCap cap, const LineJoin join)
Definition ShapeWithStyle.h:133
static void setLineWidthScaling(bool)
Definition ShapeWithStyle.cpp:42
double lineWidth() const
Definition ShapeWithStyle.h:165
ShapeWithStyle & setFillColor(const Color &)
Definition ShapeWithStyle.h:159
LineCap lineCap() const
Definition ShapeWithStyle.h:187
const Color & fillColor() const
Definition ShapeWithStyle.h:154
LineStyle lineStyle() const
Definition ShapeWithStyle.h:176
~ShapeWithStyle()
Definition ShapeWithStyle.cpp:35
Abstract structure for a 2D shape.
Definition Shape.h:64
Definition Style.h:69
LineJoin lineJoin
Definition Style.h:75
Color fillColor
Definition Style.h:71
LineStyle lineStyle
Definition Style.h:73
Color penColor
Definition Style.h:70
double lineWidth
Definition Style.h:72
LineCap lineCap
Definition Style.h:74