PeriDyno 1.2.1
Loading...
Searching...
No Matches
WtConnection.h
Go to the documentation of this file.
1#pragma once
2
3#include <Wt/WPointF.h>
4#include <Wt/WRectF.h>
5
6#include "guid.hpp"
7
8#include "WtNodeData.hpp"
9
10//#include "QtSerializable.hpp"
11#include "WtDataModelRegistry.h"
12#include "Export.hpp"
13
14class WtNode;
15class WtNodeData;
17class WtNode;
19
21{
22public:
23
25
26public:
27
28 Wt::WPointF const& getEndPoint(PortType portType) const;
29
30 void setEndPoint(PortType portType, Wt::WPointF const& point);
31
32 void moveEndPoint(PortType portType, Wt::WPointF const& offset);
33
34 Wt::WRectF boundingRect() const;
35
36 std::pair<Wt::WPointF, Wt::WPointF> pointsC1C2() const;
37
38 Wt::WPointF source() const { return _out; }
39 Wt::WPointF sink() const { return _in; }
40
41 double lineWidth() const { return _lineWidth; }
42
43 bool hovered() const { return _hovered; }
45
46 Wt::WPointF out()
47 {
48 return _out;
49 }
50
51 Wt::WPointF in()
52 {
53 return _in;
54 }
55
56private:
57 // local object coordinates
58 Wt::WPointF _in;
59 Wt::WPointF _out;
60
61 //int _animationPhase;
62
63 double _lineWidth;
64
66};
67
68
72{
73public:
74
77
80
82
83public:
84
86 {
87 _requiredPort = end;
88 }
89
91 {
92 return _requiredPort;
93 }
94
95 bool requiresPort() const
96 {
98 }
99
104
105public:
106
107 void interactWithNode(WtNode* node);
108
109 void setLastHoveredNode(WtNode* node);
110
112 {
113 return _lastHoveredNode;
114 }
115
117
118private:
119
121
123};
124
126{
127public:
128
133 PortType portType,
134 WtNode& node,
135 PortIndex portIndex);
136
138 WtNode& nodeIn,
139 PortIndex portIndexIn,
140 WtNode& nodeOut,
141 PortIndex portIndexOut,
142 TypeConverter converter =
143 TypeConverter{});
144
146 WtNode& nodeIn,
147 PortIndex portIndexIn,
148 WtNode& nodeOut,
149 PortIndex portIndexOut);
150
151 WtConnection(const WtConnection&) = delete;
153
155
156 //public:
157 //
158 // QJsonObject
159 // save() const override;
160
161public:
162
163 Wt::Guid id() const;
164
168 void setRequiredPort(PortType portType);
169
170 PortType requiredPort() const;
171
172 void setGraphicsObject(std::unique_ptr<WtConnectionGraphicsObject>&& graphics);
173
176 void setNodeToPort(WtNode& node,
177 PortType portType,
178 PortIndex portIndex);
179
180 void removeFromNodes() const;
181
182public:
183
185
186 WtConnectionState const& connectionState() const;
187
189
191
193
194 WtNode* getNode(PortType portType) const;
195
196 WtNode*& getNode(PortType portType);
197
198 PortIndex getPortIndex(PortType portType) const;
199
200 void clearNode(PortType portType);
201
202 NodeDataType dataType(PortType portType) const;
203
204 void setTypeConverter(TypeConverter converter);
205
206 bool complete() const;
207
208public: // data propagation
209
210 void propagateData(std::shared_ptr<WtNodeData> nodeData) const;
211
212 void propagateEmptyData() const;
213
214 void propagateDisconnectedData() const;
215
216 //Q_SIGNALS:
217 //
218 // void
219 // connectionCompleted(WtConnection const&) const;
220 //
221 // void
222 // connectionMadeIncomplete(WtConnection const&) const;
223
224private:
225
227
228private:
229
230 WtNode* _outNode = nullptr;
231 WtNode* _inNode = nullptr;
232
235
236private:
237
240
241 std::unique_ptr<WtConnectionGraphicsObject>_connectionGraphicsObject;
242
244
245 //Q_SIGNALS:
246 //
247 // void
248 // updated(WtConnection& conn) const;
249};
std::function< SharedNodeData(SharedNodeData)> TypeConverter
int PortIndex
PortType
Wt::WPointF sink() const
Wt::WRectF boundingRect() const
Wt::WPointF source() const
double lineWidth() const
void moveEndPoint(PortType portType, Wt::WPointF const &offset)
void setEndPoint(PortType portType, Wt::WPointF const &point)
Wt::WPointF const & getEndPoint(PortType portType) const
bool hovered() const
Wt::WPointF out()
std::pair< Wt::WPointF, Wt::WPointF > pointsC1C2() const
void setHovered(bool hovered)
Graphic Object for connection. Adds itself to scene.
WtConnectionState _connectionState
WtNode * _outNode
void propagateData(std::shared_ptr< WtNodeData > nodeData) const
WtNode * getNode(PortType portType) const
WtConnectionGeometry _connectionGeometry
NodeDataType dataType(PortType portType) const
WtConnectionGraphicsObject & getConnectionGraphicsObject() const
void setTypeConverter(TypeConverter converter)
void clearNode(PortType portType)
void propagateDisconnectedData() const
PortIndex _outPortIndex
WtConnection(const WtConnection &)=delete
PortType requiredPort() const
void setRequiredPort(PortType portType)
bool complete() const
PortIndex getPortIndex(PortType portType) const
WtConnection(PortType portType, WtNode &node, PortIndex portIndex)
PortIndex _inPortIndex
Wt::Guid id() const
WtNode * _inNode
void propagateEmptyData() const
Wt::Guid _uid
WtConnectionState const & connectionState() const
WtConnectionGeometry & connectionGeometry()
std::unique_ptr< WtConnectionGraphicsObject > _connectionGraphicsObject
void setGraphicsObject(std::unique_ptr< WtConnectionGraphicsObject > &&graphics)
void setNodeToPort(WtNode &node, PortType portType, PortIndex portIndex)
void removeFromNodes() const
TypeConverter _converter
WtConnection operator=(const WtConnection &)=delete
WtNode * _lastHoveredNode
PortType requiredPort() const
WtConnectionState(const WtConnectionState &)=delete
WtConnectionState operator=(const WtConnectionState &)=delete
void setLastHoveredNode(WtNode *node)
void interactWithNode(WtNode *node)
WtConnectionState(PortType port=PortType::None)
bool requiresPort() const
WtNode * lastHoveredNode() const
void setRequiredPort(PortType end)