aboutsummaryrefslogtreecommitdiff
path: root/core/src/Model/Workflow/Workflow.hpp
diff options
context:
space:
mode:
authorrtk0c <[email protected]>2021-05-14 20:52:00 -0700
committerrtk0c <[email protected]>2021-05-14 20:52:00 -0700
commitfa13cad2bf12d8f7f63f7ff6aab07dd2eaf6ec6d (patch)
tree994198f3636030b3974f73170fc59b04a794681d /core/src/Model/Workflow/Workflow.hpp
parent765df313e065f8401319c68ba70cd41b0bc34c9d (diff)
Node graph editor basic functionality
Diffstat (limited to 'core/src/Model/Workflow/Workflow.hpp')
-rw-r--r--core/src/Model/Workflow/Workflow.hpp29
1 files changed, 20 insertions, 9 deletions
diff --git a/core/src/Model/Workflow/Workflow.hpp b/core/src/Model/Workflow/Workflow.hpp
index 79c2b2f..847aa72 100644
--- a/core/src/Model/Workflow/Workflow.hpp
+++ b/core/src/Model/Workflow/Workflow.hpp
@@ -4,6 +4,7 @@
#include "Utils/Vector.hpp"
#include "cplt_fwd.hpp"
+#include <imgui_node_editor.h>
#include <cstddef>
#include <cstdint>
#include <iosfwd>
@@ -14,6 +15,8 @@
#include <variant>
#include <vector>
+namespace ImNodes = ax::NodeEditor;
+
class WorkflowConnection
{
public:
@@ -31,7 +34,7 @@ public:
bool IsValid() const;
/// Used for `LinkId` when interfacing with imgui node editor. Runtime only (not saved to disk and generated when loading).
- size_t GetLinkId() const;
+ ImNodes::LinkId GetLinkId() const;
void DrawDebugInfo() const;
void ReadFrom(std::istream& stream);
@@ -99,13 +102,14 @@ protected:
uint32_t mId;
Kind mKind;
int mDepth;
+ bool mLocked;
public:
static const char* FormatKind(Kind kind);
static const char* FormatType(Type type);
static std::unique_ptr<WorkflowNode> CreateByKind(Kind kind);
- WorkflowNode(Kind kind);
+ WorkflowNode(Kind kind, bool locked);
virtual ~WorkflowNode() = default;
WorkflowNode(const WorkflowNode&) = delete;
@@ -118,23 +122,28 @@ public:
uint32_t GetId() const;
/// Used for `NodeId` when interfacing with imgui node editor. Runtime only (not saved to disk and generated when loading).
- size_t GetNodeId() const;
+ ImNodes::NodeId GetNodeId() const;
Kind GetKind() const;
int GetDepth() const;
+ bool IsLocked() const;
Type GetType() const;
bool IsInputNode() const;
bool IsOutputNode() const;
- void ConnectInput(uint32_t pinId, WorkflowNode& output, uint32_t outputNodeId);
+ void ConnectInput(uint32_t pinId, WorkflowNode& srcNode, uint32_t srcPinId);
void DisconnectInput(uint32_t pinId);
+
+ void DrawInputPinDebugInfo(uint32_t pinId) const;
const InputPin& GetInputPin(uint32_t pinId)const ;
- size_t GetInputPinUniqueId(uint32_t pinId) const;
+ ImNodes::PinId GetInputPinUniqueId(uint32_t pinId) const;
- void ConnectOutput(uint32_t pinId, WorkflowNode& input, uint32_t inputNodeId);
+ void ConnectOutput(uint32_t pinId, WorkflowNode& dstNode, uint32_t dstPinId);
void DisconnectOutput(uint32_t pinId);
+
+ void DrawOutputPinDebugInfo(uint32_t pinId)const;
const OutputPin& GetOutputPin(uint32_t pinId)const ;
- size_t GetOutputPinUniqueId(uint32_t pinId) const;
+ ImNodes::PinId GetOutputPinUniqueId(uint32_t pinId) const;
virtual void Evaluate(WorkflowEvaluationContext& ctx) = 0;
@@ -187,7 +196,9 @@ public:
std::vector<std::unique_ptr<BaseValue>>& GetConstants();
WorkflowConnection* GetConnectionById(uint32_t id);
+ WorkflowConnection* GetConnectionByLinkId(ImNodes::LinkId linkId);
WorkflowNode* GetNodeById(uint32_t id);
+ WorkflowNode* GetNodeByNodeId(ImNodes::NodeId nodeId);
BaseValue* GetConstantById(uint32_t id);
struct GlobalPinId
@@ -200,8 +211,8 @@ public:
};
/// `pinId` should be the `UniqueId` of a pin from a node that's within this workflow.
- GlobalPinId DisassembleGlobalPinId(size_t id);
- size_t FabricateGlobalPinId(const WorkflowNode& node, uint32_t pinId, bool isOutput) const;
+ GlobalPinId DisassembleGlobalPinId(ImNodes::PinId id);
+ ImNodes::PinId FabricateGlobalPinId(const WorkflowNode& node, uint32_t pinId, bool isOutput) const;
const std::vector<std::vector<uint32_t>>& GetDepthGroups() const;
bool DoesDepthNeedsUpdate() const;