OpenTwin 0.1
OpenTwin
 
Loading...
Searching...
No Matches
GraphicsConnectionCfg.h
Go to the documentation of this file.
1
4// ###########################################################################################################################################################################################################################################################################################################################
5
6#pragma once
7
8// OpenTwin header
9#include "OTCore/Color.h"
10#include "OTCore/CoreTypes.h"
11#include "OTCore/Serializable.h"
12#include "OTGui/Outline.h"
14
15// std header
16#include <string>
17
18#pragma warning(disable:4251)
19
20namespace ot {
21
23 public:
24 enum class ConnectionShape {
25 DirectLine,
26 SmoothLine,
27 XYLine,
28 YXLine,
29 AutoXYLine
30 };
31
32 static std::string shapeToString(ConnectionShape _shape);
33 static ConnectionShape stringToShape(const std::string _shape);
34
36 GraphicsConnectionCfg(const ot::UID& _originUid, const std::string& _originConnectableName, const ot::UID& _destinationUid, const std::string& _destinationName);
38 virtual ~GraphicsConnectionCfg();
39
40 GraphicsConnectionCfg& operator = (const GraphicsConnectionCfg& _other);
41 bool operator==(const GraphicsConnectionCfg& _other) const;
42
46 virtual void addToJsonObject(JsonValue& _object, JsonAllocator& _allocator) const override;
47
51 virtual void setFromJsonObject(const ConstJsonObject& _object) override;
52
54 GraphicsConnectionCfg getReversedConnection(void) const;
55
56 void setOriginUid(const ot::UID& _uid) { m_originUID = _uid; };
57 const ot::UID& getOriginUid(void) const { return m_originUID; };
58
59 void setOriginConnectable(const std::string& _name) { m_originConnectable = _name; };
60 const std::string& getOriginConnectable(void) const { return m_originConnectable; };
61
62 void setDestUid(const ot::UID& _uid) { m_destUID = _uid; };
63 const ot::UID& getDestinationUid(void) const { return m_destUID; };
64
65 void setDestConnectable(const std::string& _name) { m_destConnectable = _name; };
66 const std::string& getDestConnectable(void) const { return m_destConnectable; };
67
68 void setUid(const ot::UID& _uid) { m_uid = _uid; };
69 const ot::UID& getUid(void) const { return m_uid; };
70
71 void setLineShape(ConnectionShape _shape) { m_lineShape = _shape; };
72 ConnectionShape getLineShape(void) const { return m_lineShape; };
73
74 void setLineWidth(double _width) { m_lineStyle.setWidth(_width); };
75 double getLineWidth(void) const { return m_lineStyle.width(); };
76
77 void setLineColor(const ot::Color& _color) { m_lineStyle.setColor(_color); };
78
81 void setLinePainter(ot::Painter2D* _painter) { m_lineStyle.setPainter(_painter); };
82
85 const ot::Painter2D* getLinePainter(void) const { return m_lineStyle.painter(); };
86
87 void setLineStyle(LineStyle _style) { m_lineStyle.setStyle(_style); };
88 void setLineStyle(const OutlineF& _style) { m_lineStyle = _style; };
89 const OutlineF& getLineStyle(void) const { return m_lineStyle; };
90
91 std::string createConnectionKey(void) const;
92 std::string createConnectionKeyReverse(void) const;
93
94 void setHandlesState(bool _handleState) { m_handlesState = _handleState; };
95 bool getHandleState(void) const { return m_handlesState; };
96
97 private:
98 ot::UID m_originUID;
99 std::string m_originConnectable;
100
101 ot::UID m_destUID;
102 std::string m_destConnectable;
103
104 ot::UID m_uid;
105
106 ConnectionShape m_lineShape;
107 OutlineF m_lineStyle;
108
109 bool m_handlesState;
110 };
111}
bool operator==(const FaceSelection &left, const FaceSelection &right)
Definition Model.cpp:55
#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
Definition GraphicsConnectionCfg.h:22
const ot::UID & getOriginUid(void) const
Definition GraphicsConnectionCfg.h:57
const ot::UID & getUid(void) const
Definition GraphicsConnectionCfg.h:69
void setOriginConnectable(const std::string &_name)
Definition GraphicsConnectionCfg.h:59
void setDestUid(const ot::UID &_uid)
Definition GraphicsConnectionCfg.h:62
void setUid(const ot::UID &_uid)
Definition GraphicsConnectionCfg.h:68
const std::string & getDestConnectable(void) const
Definition GraphicsConnectionCfg.h:66
const OutlineF & getLineStyle(void) const
Definition GraphicsConnectionCfg.h:89
void setLineStyle(const OutlineF &_style)
Definition GraphicsConnectionCfg.h:88
void setOriginUid(const ot::UID &_uid)
Definition GraphicsConnectionCfg.h:56
void setLineStyle(LineStyle _style)
Definition GraphicsConnectionCfg.h:87
bool getHandleState(void) const
Definition GraphicsConnectionCfg.h:95
double getLineWidth(void) const
Definition GraphicsConnectionCfg.h:75
ConnectionShape getLineShape(void) const
Definition GraphicsConnectionCfg.h:72
ConnectionShape
Definition GraphicsConnectionCfg.h:24
void setLineColor(const ot::Color &_color)
Definition GraphicsConnectionCfg.h:77
void setDestConnectable(const std::string &_name)
Definition GraphicsConnectionCfg.h:65
const ot::UID & getDestinationUid(void) const
Definition GraphicsConnectionCfg.h:63
const std::string & getOriginConnectable(void) const
Definition GraphicsConnectionCfg.h:60
const ot::Painter2D * getLinePainter(void) const
Returns the current painter. The item keeps ownership of the painter.
Definition GraphicsConnectionCfg.h:85
void setLineShape(ConnectionShape _shape)
Definition GraphicsConnectionCfg.h:71
void setLineWidth(double _width)
Definition GraphicsConnectionCfg.h:74
void setHandlesState(bool _handleState)
Definition GraphicsConnectionCfg.h:94
void setLinePainter(ot::Painter2D *_painter)
Set the line painter. The item takes ownership of the painter.
Definition GraphicsConnectionCfg.h:81
The OutlineF class is used to describe how a outline should look like.
Definition Outline.h:161
Definition Painter2D.h:17
The Serializable class is the default interface of serializable objects.
Definition Serializable.h:17
Definition Connector.h:8
unsigned long UID
Unique identifier (32 bit unsigned integer)
Definition CoreTypes.h:27
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
rapidjson::MemoryPoolAllocator< rapidjson::CrtAllocator > JsonAllocator
Allocator used for writing to JSON values.
Definition JSON.h:30
LineStyle
Line style.
Definition Outline.h:19