-
Notifications
You must be signed in to change notification settings - Fork 5
/
VisualNodeSystem.cpp
85 lines (73 loc) · 2.19 KB
/
VisualNodeSystem.cpp
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
#include "VisualNodeSystem.h"
using namespace VisNodeSys;
#ifdef VISUAL_NODE_SYSTEM_SHARED
extern "C" __declspec(dllexport) void* GetNodeSystem()
{
return NodeSystem::GetInstancePointer();
}
#endif
NodeSystem::NodeSystem() {}
NodeSystem::~NodeSystem() {}
void NodeSystem::Initialize(bool bTestMode)
{
NODE_CORE.bIsInTestMode = bTestMode;
NODE_CORE.InitializeFonts();
}
NodeArea* NodeSystem::CreateNodeArea()
{
CreatedAreas.push_back(new NodeArea());
return CreatedAreas.back();
}
void NodeSystem::DeleteNodeArea(const NodeArea* NodeArea)
{
for (size_t i = 0; i < CreatedAreas.size(); i++)
{
if (CreatedAreas[i] == NodeArea)
{
delete CreatedAreas[i];
CreatedAreas.erase(CreatedAreas.begin() + i, CreatedAreas.begin() + i + 1);
return;
}
}
}
void NodeSystem::MoveNodesTo(NodeArea* SourceNodeArea, NodeArea* TargetNodeArea, const bool SelectMovedNodes)
{
if (SourceNodeArea == nullptr || TargetNodeArea == nullptr)
return;
for (size_t i = 0; i < SourceNodeArea->Nodes.size(); i++)
{
TargetNodeArea->AddNode(SourceNodeArea->Nodes[i]);
}
const size_t SourceNodeCount = SourceNodeArea->Nodes.size();
SourceNodeArea->Nodes.clear();
for (size_t i = 0; i < SourceNodeArea->Connections.size(); i++)
{
TargetNodeArea->Connections.push_back(SourceNodeArea->Connections[i]);
}
SourceNodeArea->Connections.clear();
SourceNodeArea->Clear();
// Select moved nodes.
if (SelectMovedNodes)
{
TargetNodeArea->SelectedNodes.clear();
for (size_t i = TargetNodeArea->Nodes.size() - SourceNodeCount; i < TargetNodeArea->Nodes.size(); i++)
{
TargetNodeArea->SelectedNodes.push_back(TargetNodeArea->Nodes[i]);
}
}
}
std::vector<std::pair<std::string, ImColor>> NodeSystem::GetAssociationsOfSocketTypeToColor(std::string SocketType, ImColor Color)
{
std::vector<std::pair<std::string, ImColor>> Result;
auto iterator = NodeSocket::SocketTypeToColorAssosiations.begin();
while (iterator != NodeSocket::SocketTypeToColorAssosiations.end())
{
Result.push_back(std::make_pair(iterator->first, iterator->second));
iterator++;
}
return Result;
}
void NodeSystem::AssociateSocketTypeToColor(std::string SocketType, ImColor Color)
{
NodeSocket::SocketTypeToColorAssosiations[SocketType] = Color;
}