58 lines
2.0 KiB
C++
58 lines
2.0 KiB
C++
#ifndef __WORKFLOW_EDITOR_HPP__
|
||
#define __WORKFLOW_EDITOR_HPP__
|
||
|
||
#include <vector>
|
||
#include <memory>
|
||
#include "imgui.h"
|
||
#include "imnodes.h"
|
||
#include "ID_Generator.hpp"
|
||
#include "Nodes_And_Connectors.hpp"
|
||
|
||
// 节点编辑器类
|
||
class Workflow_Editor
|
||
{
|
||
protected:
|
||
typedef enum
|
||
{
|
||
NODE_TYPE_UNKNOWN, // 未知节点类型
|
||
NODE_TYPE_MSG_LINE_INPUT, // 消息输入节点
|
||
NODE_TYPE_CSV_EXPORTER, // CSV输出节点
|
||
} Node_Type_Enum; // 节点类型枚举
|
||
|
||
// ID 分配器
|
||
Independent_ID_Generator Connector_ID_Generator; // 连接点ID生成器
|
||
Independent_ID_Generator Node_ID_Generator; // 节点ID生成器
|
||
Independent_ID_Generator Edge_ID_Generator; // 边ID生成器
|
||
|
||
// 边定义
|
||
typedef struct
|
||
{
|
||
int id = -1; // 边ID
|
||
int source_connector_id = -1; // 源连接点
|
||
int target_connector_id = -1; // 目标连接点
|
||
} Edge;
|
||
|
||
// 数据池
|
||
std::vector<std::shared_ptr<Abs_Connector>> Connector_Pool; // 连接点池
|
||
std::vector<std::shared_ptr<Abs_Node>> Node_Pool; // 节点池
|
||
std::vector<Edge> Edge_Pool; // 边池
|
||
|
||
/**
|
||
* 顶层索引为启示工作流节点(N个元素即N个处理流程)
|
||
* 次级索引为工作流分层
|
||
* 三级索引为平级工作流节点
|
||
* 不参与工作流节点仅存于散点列表
|
||
*/
|
||
std::vector<std::vector<std::vector<std::shared_ptr<Abs_Node>>>> Process_Route; // 工作层级路由
|
||
std::vector<std::shared_ptr<Abs_Node>> Separate_Node_List; // 散点列表
|
||
|
||
// =====================================函数声明=================================================
|
||
// 新增节点 true -> success / false -> failed
|
||
bool Add_Node(Node_Type_Enum type, ImVec2 initial_position = ImVec2(0, 0));
|
||
|
||
public:
|
||
// 绘制节点编辑器
|
||
void Show(void);
|
||
};
|
||
|
||
#endif |