OpenTwin 0.1
OpenTwin
 
Loading...
Searching...
No Matches
Outline.h
Go to the documentation of this file.
1
5// ###########################################################################################################################################################################################################################################################################################################################
6
7#pragma once
8
9// OpenTwin header
10#include "OTCore/Serializable.h"
11#include "OTGui/Painter2D.h"
13
14namespace ot {
15
16 class OutlineF;
17
27
34
42
43 OT_GUI_API_EXPORT std::string toString(LineStyle _style);
44 OT_GUI_API_EXPORT LineStyle stringToLineStyle(const std::string& _style);
45
46 OT_GUI_API_EXPORT std::string toString(LineCapStyle _cap);
47 OT_GUI_API_EXPORT LineCapStyle stringToCapStyle(const std::string& _cap);
48
49 OT_GUI_API_EXPORT std::string toString(LineJoinStyle _join);
50 OT_GUI_API_EXPORT LineJoinStyle stringToJoinStyle(const std::string& _join);
51
55 public:
58 Outline();
59
62 Outline(const Color& _color);
63
66 Outline(Painter2D* _painter);
67
71 Outline(int _width, const Color& _color);
72
76 Outline(int _width, Painter2D* _painter);
77
80 Outline(const Outline& _other);
81
83 ~Outline();
84
87 Outline& operator = (const Outline& _other);
88
92 virtual void addToJsonObject(ot::JsonValue& _object, ot::JsonAllocator& _allocator) const override;
93
97 virtual void setFromJsonObject(const ot::ConstJsonObject& _object) override;
98
101 void setColor(const Color& _color);
102
106 void setPainter(Painter2D* _painter);
107
109 constexpr inline const Painter2D* painter(void) const { return m_painter; };
110
113 Painter2D* takePainter(void);
114
117 constexpr inline void setWidth(int _w) { m_width = _w; };
118
120 constexpr inline int width(void) const { return m_width; };
121
124 constexpr inline void setStyle(LineStyle _style) { m_style = _style; };
125
127 constexpr inline LineStyle style(void) const { return m_style; };
128
131 constexpr inline void setCap(LineCapStyle _cap) { m_cap = _cap; };
132
134 constexpr inline LineCapStyle cap(void) const { return m_cap; };
135
138 constexpr inline void setJoinStyle(LineJoinStyle _join) { m_join = _join; };
139
141 constexpr inline LineJoinStyle joinStyle(void) const { return m_join; };
142
143 OutlineF toOutlineF(void) const;
144
145 private:
146 Painter2D* m_painter;
147 int m_width;
148 LineStyle m_style;
149 LineCapStyle m_cap;
150 LineJoinStyle m_join;
151 };
152
153 // ###########################################################################################################################################################################################################################################################################################################################
154
155 // ###########################################################################################################################################################################################################################################################################################################################
156
157 // ###########################################################################################################################################################################################################################################################################################################################
158
162 public:
165 OutlineF();
166
169 OutlineF(const Color& _color);
170
173 OutlineF(Painter2D* _painter);
174
178 OutlineF(double _width, const Color& _color);
179
183 OutlineF(double _width, Painter2D* _painter);
184
187 OutlineF(const OutlineF& _other);
188
190 ~OutlineF();
191
194 OutlineF& operator = (const OutlineF& _other);
195
199 virtual void addToJsonObject(ot::JsonValue& _object, ot::JsonAllocator& _allocator) const override;
200
204 virtual void setFromJsonObject(const ot::ConstJsonObject& _object) override;
205
208 void setColor(const Color& _color);
209
213 void setPainter(Painter2D* _painter);
214
216 constexpr inline const Painter2D* painter(void) const { return m_painter; };
217
220 Painter2D* takePainter(void);
221
224 constexpr inline void setWidth(double _w) { m_width = _w; };
225
227 constexpr inline double width(void) const { return m_width; };
228
231 constexpr inline void setStyle(LineStyle _style) { m_style = _style; };
232
234 constexpr inline LineStyle style(void) const { return m_style; };
235
238 constexpr inline void setCap(LineCapStyle _cap) { m_cap = _cap; };
239
241 constexpr inline LineCapStyle cap(void) const { return m_cap; };
242
245 constexpr inline void setJoinStyle(LineJoinStyle _join) { m_join = _join; };
246
248 constexpr inline LineJoinStyle joinStyle(void) const { return m_join; };
249
250 Outline toOutline(void) const;
251
252 private:
253 Painter2D* m_painter;
254 double m_width;
255 LineStyle m_style;
256 LineCapStyle m_cap;
257 LineJoinStyle m_join;
258 };
259
260}
#define OT_GUI_API_EXPORT
Definition OTGuiAPIExport.h:9
The Color class is used to represent RGBA colors with integer values.
Definition Color.h:72
The OutlineF class is used to describe how a outline should look like.
Definition Outline.h:161
constexpr LineCapStyle cap(void) const
Cap style.
Definition Outline.h:241
constexpr const Painter2D * painter(void) const
Painter.
Definition Outline.h:216
constexpr LineStyle style(void) const
Line style.
Definition Outline.h:234
constexpr void setStyle(LineStyle _style)
Set the line style.
Definition Outline.h:231
constexpr double width(void) const
Line width.
Definition Outline.h:227
constexpr void setCap(LineCapStyle _cap)
Set the line cap style.
Definition Outline.h:238
constexpr void setJoinStyle(LineJoinStyle _join)
Set the line join style.
Definition Outline.h:245
constexpr LineJoinStyle joinStyle(void) const
Line join style.
Definition Outline.h:248
constexpr void setWidth(double _w)
Set the line width.
Definition Outline.h:224
The Outline class is used to describe how a outline should look like.
Definition Outline.h:54
constexpr const Painter2D * painter(void) const
Painter.
Definition Outline.h:109
constexpr LineJoinStyle joinStyle(void) const
Line join style.
Definition Outline.h:141
constexpr LineStyle style(void) const
Line style.
Definition Outline.h:127
constexpr void setStyle(LineStyle _style)
Set the line style.
Definition Outline.h:124
constexpr void setWidth(int _w)
Set the line width.
Definition Outline.h:117
constexpr LineCapStyle cap(void) const
Cap style.
Definition Outline.h:134
constexpr void setJoinStyle(LineJoinStyle _join)
Set the line join style.
Definition Outline.h:138
constexpr void setCap(LineCapStyle _cap)
Set the line cap style.
Definition Outline.h:131
constexpr int width(void) const
Line width.
Definition Outline.h:120
Definition Painter2D.h:17
The Serializable class is the default interface of serializable objects.
Definition Serializable.h:17
Definition Connector.h:8
LineCapStyle
Line cap style.
Definition Outline.h:29
@ SquareCap
Definition Outline.h:31
@ FlatCap
Definition Outline.h:30
@ RoundCap
Definition Outline.h:32
rapidjson::Value JsonValue
Writable JSON value.
Definition JSON.h:27
rapidjson::GenericObject< true, rapidjson::GenericValue< rapidjson::UTF8<>, rapidjson::MemoryPoolAllocator< rapidjson::CrtAllocator > > > ConstJsonObject
Read only JSON Object.
Definition JSON.h:35
OT_GUI_API_EXPORT std::string toString(ColorStyleName _colorStyleName)
Definition ColorStyleTypes.cpp:10
OT_GUI_API_EXPORT LineStyle stringToLineStyle(const std::string &_style)
Definition Outline.cpp:28
rapidjson::MemoryPoolAllocator< rapidjson::CrtAllocator > JsonAllocator
Allocator used for writing to JSON values.
Definition JSON.h:30
LineJoinStyle
Line join style.
Definition Outline.h:36
@ BevelJoin
Definition Outline.h:38
@ MiterJoin
Definition Outline.h:37
@ RoundJoin
Definition Outline.h:39
@ SvgMiterJoin
Definition Outline.h:40
OT_GUI_API_EXPORT LineCapStyle stringToCapStyle(const std::string &_cap)
Definition Outline.cpp:53
OT_GUI_API_EXPORT LineJoinStyle stringToJoinStyle(const std::string &_join)
Definition Outline.cpp:76
LineStyle
Line style.
Definition Outline.h:19
@ DashLine
Definition Outline.h:22
@ DotLine
Definition Outline.h:23
@ DashDotDotLine
Definition Outline.h:25
@ NoLine
Definition Outline.h:20
@ DashDotLine
Definition Outline.h:24
@ SolidLine
Definition Outline.h:21