From fa13cad2bf12d8f7f63f7ff6aab07dd2eaf6ec6d Mon Sep 17 00:00:00 2001 From: rtk0c Date: Fri, 14 May 2021 20:52:00 -0700 Subject: Node graph editor basic functionality --- core/src/Model/Workflow/Workflow.hpp | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) (limited to 'core/src/Model/Workflow/Workflow.hpp') 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 #include #include #include @@ -14,6 +15,8 @@ #include #include +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 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>& 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>& GetDepthGroups() const; bool DoesDepthNeedsUpdate() const; -- cgit v1.2.3-70-g09d2