-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathVisualNode.cpp
More file actions
716 lines (583 loc) · 18.4 KB
/
Copy pathVisualNode.cpp
File metadata and controls
716 lines (583 loc) · 18.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
#include "VisualNode.h"
#include "VisualNodeFactory.h"
#include "VisualNodeSystem.h"
using namespace VisNodeSys;
Node::Node(const std::string ID)
{
this->ID = ID;
if (ID.empty())
this->ID = NODE_CORE.GetUniqueHexID();
SetSize(ImVec2(200, 80));
SetName("VisualNode");
Type = "VisualNode";
}
Node::Node(const Node& Other)
{
ParentArea = nullptr;
ID = NODE_CORE.GetUniqueHexID();
Position = Other.Position;
Size = Other.Size;
ClientRegionMin = Other.ClientRegionMin;
ClientRegionMax = Other.ClientRegionMax;
Name = Other.Name;
Type = Other.Type;
Style = Other.Style;
bRenderTitleBar = Other.bRenderTitleBar;
TitleBarAvailableWidth = Other.TitleBarAvailableWidth;
TitleBarHeight = Other.TitleBarHeight;
MaxInputLabelWidth = Other.MaxInputLabelWidth;
MaxOutputLabelWidth = Other.MaxOutputLabelWidth;
bCouldBeDestroyedByUser = Other.bCouldBeDestroyedByUser;
bCouldBeCopiedByUser = Other.bCouldBeCopiedByUser;
bCouldBeMovedByUser = Other.bCouldBeMovedByUser;
LeftTop = Other.LeftTop;
RightBottom = Other.RightBottom;
TitleBackgroundColor = Other.TitleBackgroundColor;
TitleBackgroundColorHovered = Other.TitleBackgroundColorHovered;
// Data getters are not copied, they usually capture the source node.
// Each node type's copy constructor must install its own getters.
for (size_t i = 0; i < Other.Input.size(); i++)
{
Input.push_back(new NodeSocket(this, Other.Input[i]->GetAllowedTypes(), Other.Input[i]->GetName(), NodeSocket::SocketFlow::Input));
Input.back()->SetCanBeDeletedByUser(Other.Input[i]->CanBeDeletedByUser());
}
for (size_t i = 0; i < Other.Output.size(); i++)
{
Output.push_back(new NodeSocket(this, Other.Output[i]->GetAllowedTypes(), Other.Output[i]->GetName(), NodeSocket::SocketFlow::Output));
Output.back()->SetCanBeDeletedByUser(Other.Output[i]->CanBeDeletedByUser());
}
bShouldBeDestroyed = false;
}
Node::~Node()
{
for (int i = 0; i < static_cast<int>(Input.size()); i++)
{
delete Input[i];
Input.erase(Input.begin() + i, Input.begin() + i + 1);
i--;
}
for (int i = 0; i < static_cast<int>(Output.size()); i++)
{
delete Output[i];
Output.erase(Output.begin() + i, Output.begin() + i + 1);
i--;
}
}
std::string Node::GetID() const
{
return ID;
}
ImVec2 Node::GetPosition() const
{
return Position;
}
void Node::SetPosition(const ImVec2 NewValue)
{
Position = NewValue;
}
ImVec2 Node::GetSize() const
{
if (GetStyle() == CIRCLE)
return ImVec2(NODE_DIAMETER, NODE_DIAMETER);
return Size;
}
void Node::SetSize(const ImVec2 NewValue)
{
Size = NewValue;
}
std::string Node::GetName() const
{
return Name;
}
void Node::SetName(std::string NewValue)
{
if (NewValue.length() > NODE_NAME_MAX_LENGTH)
NewValue = NewValue.substr(0, NODE_NAME_MAX_LENGTH);
Name = NewValue;
}
bool Node::AddSocket(NodeSocket* Socket)
{
if (Socket == nullptr)
return false;
if (Socket->GetParent() != this)
return false;
if (GetSocketByID(Socket->GetID()))
return false;
Socket->GetFlowDirection() == NodeSocket::SocketFlow::Output ? Output.push_back(Socket) : Input.push_back(Socket);
return true;
}
bool Node::DeleteSocket(std::string SocketID)
{
return DeleteSocket(GetSocketByID(SocketID));
}
bool Node::DeleteSocket(NodeSocket* Socket)
{
if (Socket == nullptr)
return false;
if (!Socket->CanBeDeletedByUser())
return false;
if (Socket->GetParent() == this && GetParentArea() != nullptr)
return NODE_SYSTEM.DeleteSocket(GetID(), Socket->GetID());
std::vector<NodeSocket*>& SocketList = Socket->GetFlowDirection() == NodeSocket::SocketFlow::Output ? Output : Input;
for (size_t i = 0; i < SocketList.size(); i++)
{
if (SocketList[i]->GetID() == Socket->GetID())
{
delete SocketList[i];
SocketList.erase(SocketList.begin() + i, SocketList.begin() + i + 1);
return true;
}
}
return false;
}
void Node::Draw()
{
}
void Node::SocketEvent(NodeSocket* OwnSocket, NodeSocket* ConnectedSocket, NODE_SOCKET_EVENT EventType)
{
}
bool Node::IsValidAsNewConnection(NodeSocket* OwnSocket, NodeSocket* CandidateSocket)
{
// Socket can't connect to itself.
if (OwnSocket == CandidateSocket)
return false;
// Nodes can't connect to themselves.
if (CandidateSocket->GetParent() == this)
return false;
// Sockets must have different flow directions (input vs output).
if (OwnSocket->GetFlowDirection() == CandidateSocket->GetFlowDirection())
return false;
// Iterate through all allowed types of the candidate socket and check if the type of the own socket is in the list.
bool bFound = false;
for (size_t i = 0; i < CandidateSocket->GetAllowedTypes().size(); i++)
{
for (size_t j = 0; j < OwnSocket->GetAllowedTypes().size(); j++)
{
if (CandidateSocket->GetAllowedTypes()[i] == OwnSocket->GetAllowedTypes()[j])
{
bFound = true;
break;
}
}
if (bFound)
break;
}
if (!bFound)
return false;
return true;
}
bool Node::CanConnect(NodeSocket* OwnSocket, NodeSocket* CandidateSocket, char** MsgToUser)
{
if (!IsValidAsNewConnection(OwnSocket, CandidateSocket))
return false;
// Check if the candidate socket is already connected to the own socket.
for (size_t i = 0; i < OwnSocket->ConnectedSockets.size(); i++)
{
if (OwnSocket->ConnectedSockets[i]->GetID() == CandidateSocket->GetID())
return false;
}
return true;
}
std::string Node::GetType() const
{
return Type;
}
bool Node::GetRenderTitleBar() const
{
return bRenderTitleBar;
}
void Node::SetRenderTitleBar(bool bNewValue)
{
bRenderTitleBar = bNewValue;
}
Json::Value Node::ToJson()
{
Json::Value Result;
Result["ID"] = ID;
Result["NodeType"] = Type;
Result["NodeStyle"] = Style;
Result["Position"]["X"] = Position.x;
Result["Position"]["Y"] = Position.y;
Result["Size"]["X"] = Size.x;
Result["Size"]["Y"] = Size.y;
Result["Name"] = Name;
Result["bCouldBeDestroyedByUser"] = bCouldBeDestroyedByUser;
Result["bCouldBeCopiedByUser"] = bCouldBeCopiedByUser;
Result["bCouldBeMovedByUser"] = bCouldBeMovedByUser;
Result["bRenderTitleBar"] = bRenderTitleBar;
Result["TitleBarAvailableWidth"] = TitleBarAvailableWidth;
Result["TitleBarHeight"] = TitleBarHeight;
Result["MaxInputLabelWidth"] = MaxInputLabelWidth;
Result["MaxOutputLabelWidth"] = MaxOutputLabelWidth;
for (size_t i = 0; i < Input.size(); i++)
{
Result["Input"][std::to_string(i)]["ID"] = Input[i]->GetID();
Result["Input"][std::to_string(i)]["Name"] = Input[i]->GetName();
Result["Input"][std::to_string(i)]["CanBeDeletedByUser"] = Input[i]->CanBeDeletedByUser();
for (size_t j = 0; j < Input[i]->GetAllowedTypes().size(); j++)
Result["Input"][std::to_string(i)]["AllowedTypes"].append(Input[i]->GetAllowedTypes()[j]);
}
for (size_t i = 0; i < Output.size(); i++)
{
Result["Output"][std::to_string(i)]["ID"] = Output[i]->GetID();
Result["Output"][std::to_string(i)]["Name"] = Output[i]->GetName();
Result["Output"][std::to_string(i)]["CanBeDeletedByUser"] = Output[i]->CanBeDeletedByUser();
for (size_t j = 0; j < Output[i]->GetAllowedTypes().size(); j++)
Result["Output"][std::to_string(i)]["AllowedTypes"].append(Output[i]->GetAllowedTypes()[j]);
}
return Result;
}
void Node::SetToDefaultState()
{
for (NodeSocket* Socket : Input)
delete Socket;
Input.clear();
for (NodeSocket* Socket : Output)
delete Socket;
Output.clear();
Node* NewNode = new Node();
std::string CurrentID = ID;
*this = *NewNode;
delete NewNode;
// To preserve the ID of the node, we set it back after copying.
ID = CurrentID;
}
bool Node::FromJson(Json::Value Json)
{
if (!Json.isObject())
{
SetToDefaultState();
return false;
}
if (!Json.isMember("ID") || !Json["ID"].isString() ||
!Json.isMember("NodeType") || !Json["NodeType"].isString() ||
!Json.isMember("Position") || !Json["Position"].isObject() ||
!Json["Position"].isMember("X") || !Json["Position"]["X"].isNumeric() ||
!Json["Position"].isMember("Y") || !Json["Position"]["Y"].isNumeric() ||
!Json.isMember("Size") || !Json["Size"].isObject() ||
!Json["Size"].isMember("X") || !Json["Size"]["X"].isNumeric() ||
!Json["Size"].isMember("Y") || !Json["Size"]["Y"].isNumeric() ||
!Json.isMember("Name") || !Json["Name"].isString())
{
// FE_TO_DO: Implement a more robust user notification system (e.g., logging, UI warning).
SetToDefaultState();
return false;
}
ID = Json["ID"].asCString();
Type = Json["NodeType"].asCString();
if (Json.isMember("NodeStyle") && Json["NodeStyle"].isNumeric())
Style = NODE_STYLE(Json["NodeStyle"].asInt());
Position.x = Json["Position"]["X"].asFloat();
Position.y = Json["Position"]["Y"].asFloat();
Size.x = Json["Size"]["X"].asFloat();
Size.y = Json["Size"]["Y"].asFloat();
Name = Json["Name"].asCString();
if (Json.isMember("bCouldBeDestroyedByUser") && Json["bCouldBeDestroyedByUser"].isBool())
bCouldBeDestroyedByUser = Json["bCouldBeDestroyedByUser"].asBool();
if (Json.isMember("bCouldBeCopiedByUser") && Json["bCouldBeCopiedByUser"].isBool())
bCouldBeCopiedByUser = Json["bCouldBeCopiedByUser"].asBool();
if (Json.isMember("bCouldBeMovedByUser") && Json["bCouldBeMovedByUser"].isBool())
bCouldBeMovedByUser = Json["bCouldBeMovedByUser"].asBool();
if (Json.isMember("bRenderTitleBar") && Json["bRenderTitleBar"].isBool())
bRenderTitleBar = Json["bRenderTitleBar"].asBool();
if (Json.isMember("TitleBarAvailableWidth") && Json["TitleBarAvailableWidth"].isNumeric())
TitleBarAvailableWidth = Json["TitleBarAvailableWidth"].asFloat();
if (Json.isMember("TitleBarHeight") && Json["TitleBarHeight"].isNumeric())
TitleBarHeight = Json["TitleBarHeight"].asFloat();
if (Json.isMember("MaxInputLabelWidth") && Json["MaxInputLabelWidth"].isNumeric())
MaxInputLabelWidth = Json["MaxInputLabelWidth"].asFloat();
if (Json.isMember("MaxOutputLabelWidth") && Json["MaxOutputLabelWidth"].isNumeric())
MaxOutputLabelWidth = Json["MaxOutputLabelWidth"].asFloat();
if (!Json["Input"].isNull() && !Json["Input"].isObject())
{
SetToDefaultState();
return false;
}
const std::vector<Json::String> InputsList = Json["Input"].getMemberNames();
for (size_t i = 0; i < Input.size(); i++)
{
delete Input[i];
Input[i] = nullptr;
}
std::pair<size_t, size_t> SocketCountInClassDefinition = NODE_FACTORY.GetSocketCount(Type);
Input.resize(InputsList.size());
for (size_t i = 0; i < Input.size(); i++)
{
const std::string Key = std::to_string(i);
if (!Json["Input"].isMember(Key) || !Json["Input"][Key].isObject() ||
!Json["Input"][Key].isMember("ID") || !Json["Input"][Key]["ID"].isString() ||
!Json["Input"][Key].isMember("Name") || !Json["Input"][Key]["Name"].isString() ||
!Json["Input"][Key].isMember("AllowedTypes") || !Json["Input"][Key]["AllowedTypes"].isArray())
{
// TO-DO: Implement a more robust user notification system (e.g., logging, UI warning).
// Safest recovery strategy: Reset the node to a default state.
// This avoids potential crashes or undefined behavior from mismatched data.
SetToDefaultState();
return false;
}
const std::string ID = Json["Input"][Key]["ID"].asCString();
const std::string Name = Json["Input"][Key]["Name"].asCString();
Json::Value AllowedTypesArray = Json["Input"][Key]["AllowedTypes"];
std::vector<std::string> AllowedTypes;
for (unsigned int j = 0; j < AllowedTypesArray.size(); j++)
{
if (!AllowedTypesArray[j].isString())
{
SetToDefaultState();
return false;
}
AllowedTypes.push_back(AllowedTypesArray[j].asString());
}
Input[i] = new NodeSocket(this, AllowedTypes, Name, NodeSocket::SocketFlow::Input);
Input[i]->ID = ID;
if (Json["Input"][Key].isMember("CanBeDeletedByUser") && Json["Input"][Key]["CanBeDeletedByUser"].isBool())
Input[i]->SetCanBeDeletedByUser(Json["Input"][Key]["CanBeDeletedByUser"].asBool());
}
if (!Json["Output"].isNull() && !Json["Output"].isObject())
{
SetToDefaultState();
return false;
}
const std::vector<Json::String> OutputsList = Json["Output"].getMemberNames();
for (size_t i = 0; i < Output.size(); i++)
{
delete Output[i];
Output[i] = nullptr;
}
Output.resize(OutputsList.size());
for (size_t i = 0; i < Output.size(); i++)
{
const std::string Key = std::to_string(i);
if (!Json["Output"].isMember(Key) || !Json["Output"][Key].isObject() ||
!Json["Output"][Key].isMember("ID") || !Json["Output"][Key]["ID"].isString() ||
!Json["Output"][Key].isMember("Name") || !Json["Output"][Key]["Name"].isString() ||
!Json["Output"][Key].isMember("AllowedTypes") || !Json["Output"][Key]["AllowedTypes"].isArray())
{
// FE_TO_DO: Implement a more robust user notification system (e.g., logging, UI warning).
// Safest recovery strategy: Reset the node to a default state.
// This avoids potential crashes or undefined behavior from mismatched data.
SetToDefaultState();
return false;
}
const std::string ID = Json["Output"][Key]["ID"].asCString();
const std::string Name = Json["Output"][Key]["Name"].asCString();
Json::Value AllowedTypesArray = Json["Output"][Key]["AllowedTypes"];
std::vector<std::string> AllowedTypes;
for (unsigned int j = 0; j < AllowedTypesArray.size(); j++)
{
if (!AllowedTypesArray[j].isString())
{
SetToDefaultState();
return false;
}
AllowedTypes.push_back(AllowedTypesArray[j].asString());
}
Output[i] = new NodeSocket(this, AllowedTypes, Name, NodeSocket::SocketFlow::Output);
Output[i]->ID = ID;
if (Json["Output"][Key].isMember("CanBeDeletedByUser") && Json["Output"][Key]["CanBeDeletedByUser"].isBool())
Output[i]->SetCanBeDeletedByUser(Json["Output"][Key]["CanBeDeletedByUser"].asBool());
}
return true;
}
void Node::UpdateClientRegion()
{
float LongestInputSocketTextW = 0.0f;
for (size_t i = 0; i < Input.size(); i++)
{
const ImVec2 TextSize = ImGui::CalcTextSize(Input[i]->GetName().c_str());
if (TextSize.x > LongestInputSocketTextW)
LongestInputSocketTextW = TextSize.x;
}
float LongestOutputSocketTextW = 0.0f;
for (size_t i = 0; i < Output.size(); i++)
{
const ImVec2 TextSize = ImGui::CalcTextSize(Output[i]->GetName().c_str());
if (TextSize.x > LongestOutputSocketTextW)
LongestOutputSocketTextW = TextSize.x;
}
ClientRegionMin.x = LeftTop.x + NODE_SOCKET_SIZE * 5.0f + LongestInputSocketTextW + 2.0f;
ClientRegionMax.x = RightBottom.x - NODE_SOCKET_SIZE * 5.0f - LongestOutputSocketTextW - 2.0f;
ClientRegionMin.y = LeftTop.y + NODE_TITLE_HEIGHT + 2.0f;
ClientRegionMax.y = RightBottom.y - 2.0f;
}
ImVec2 Node::GetClientRegionSize()
{
UpdateClientRegion();
return ClientRegionMax - ClientRegionMin;
}
ImVec2 Node::GetClientRegionPosition()
{
UpdateClientRegion();
return ClientRegionMin;
}
size_t Node::GetInputSocketCount() const
{
return Input.size();
}
std::vector<std::pair<size_t, std::vector<std::string>>> Node::GetInputSocketTypes() const
{
std::vector<std::pair<size_t, std::vector<std::string>>> Result;
for (size_t i = 0; i < Input.size(); i++)
Result.push_back(std::make_pair(i, Input[i]->GetAllowedTypes()));
return Result;
}
size_t Node::GetOutputSocketCount() const
{
return Output.size();
}
std::vector<std::pair<size_t, std::vector<std::string>>> Node::GetOutputSocketTypes() const
{
std::vector<std::pair<size_t, std::vector<std::string>>> Result;
for (size_t i = 0; i < Output.size(); i++)
Result.push_back(std::make_pair(i, Output[i]->GetAllowedTypes()));
return Result;
}
std::vector<Node*> Node::GetNodesConnectedToInput() const
{
std::vector<Node*> Result;
for (size_t i = 0; i < Input.size(); i++)
{
for (size_t j = 0; j < Input[i]->ConnectedSockets.size(); j++)
{
if (IsNodeWithIDInList(Input[i]->ConnectedSockets[j]->GetParent()->GetID(), Result))
continue;
Result.push_back(Input[i]->ConnectedSockets[j]->GetParent());
}
}
return Result;
}
std::vector<Node*> Node::GetNodesConnectedToOutput() const
{
std::vector<Node*> Result;
for (size_t i = 0; i < Output.size(); i++)
{
for (size_t j = 0; j < Output[i]->ConnectedSockets.size(); j++)
{
if (IsNodeWithIDInList(Output[i]->ConnectedSockets[j]->GetParent()->GetID(), Result))
continue;
Result.push_back(Output[i]->ConnectedSockets[j]->GetParent());
}
}
return Result;
}
bool Node::OpenContextMenu()
{
return false;
}
NODE_STYLE Node::GetStyle() const
{
return Style;
}
void Node::SetStyle(const NODE_STYLE NewValue)
{
if (static_cast<int>(NewValue) < 0 || static_cast<int>(NewValue) >= 2)
return;
Style = NewValue;
}
bool Node::IsHovered() const
{
return bHovered;
}
void Node::SetIsHovered(const bool bNewValue)
{
bHovered = bNewValue;
}
bool Node::CouldBeMoved() const
{
return bCouldBeMovedByUser;
}
void Node::SetCouldBeMoved(bool bNewValue)
{
bCouldBeMovedByUser = bNewValue;
}
NodeArea* Node::GetParentArea() const
{
return ParentArea;
}
bool Node::CouldBeDestroyed() const
{
return bCouldBeDestroyedByUser;
}
bool Node::IsNodeWithIDInList(const std::string ID, const std::vector<Node*> List)
{
for (size_t i = 0; i < List.size(); i++)
{
if (List[i] != nullptr && List[i]->GetID() == ID)
return true;
}
return false;
}
NodeSocket* Node::GetSocketByID(std::string SocketID) const
{
for (size_t i = 0; i < Input.size(); i++)
{
if (Input[i]->GetID() == SocketID)
return Input[i];
}
for (size_t i = 0; i < Output.size(); i++)
{
if (Output[i]->GetID() == SocketID)
return Output[i];
}
return nullptr;
}
size_t Node::GetSocketIndexByID(std::string SocketID) const
{
for (size_t i = 0; i < Input.size(); i++)
{
if (Input[i]->GetID() == SocketID)
return i;
}
for (size_t i = 0; i < Output.size(); i++)
{
if (Output[i]->GetID() == SocketID)
return i;
}
return -1;
}
NodeSocket* Node::GetSocketByIndex(size_t SocketIndex, NodeSocket::SocketFlow FlowDirection) const
{
std::vector<NodeSocket*> SocketList = FlowDirection == NodeSocket::SocketFlow::Output ? Output : Input;
if (SocketIndex >= SocketList.size())
return nullptr;
return SocketList[SocketIndex];
}
std::string Node::GetSocketIDByIndex(size_t SocketIndex, NodeSocket::SocketFlow FlowDirection) const
{
const NodeSocket* Socket = GetSocketByIndex(SocketIndex, FlowDirection);
if (!Socket)
return "";
return Socket->GetID();
}
float Node::GetMaxInputLabelWidth() const
{
return MaxInputLabelWidth;
}
void Node::SetMaxInputLabelWidth(float NewValue)
{
MaxInputLabelWidth = NewValue;
}
float Node::GetMaxOutputLabelWidth() const
{
return MaxOutputLabelWidth;
}
void Node::SetMaxOutputLabelWidth(float NewValue)
{
MaxOutputLabelWidth = NewValue;
}
float Node::GetTitleBarHeight() const
{
return TitleBarHeight;
}
void Node::SetTitleBarHeight(float NewValue)
{
TitleBarHeight = NewValue;
}
float Node::GetTitleBarAvailableWidth() const
{
return TitleBarAvailableWidth;
}
void Node::SetTitleBarAvailableWidth(float NewValue)
{
TitleBarAvailableWidth = NewValue;
}