Fixed a bug in the Del_Link method where node connection deletion failed when source id and target id were swapped. && Added a Get_Socket_Str method to the base connector class, allowing external code to query the socket to determine whether a connection is allowed. && Added a boolean-type connector. && Input connectors can now be initialized to exclusive input mode, meaning that an input connector of this type allows only one input at a time, establishing a new connection will disconnect the existing one. && Added a message filter node that allows incoming messages to pass through when the input conditions are met.
This commit is contained in:
parent
68fba7efd5
commit
35636fd438
@ -16,10 +16,11 @@ class Abs_Connector // 抽象接口类
|
||||
public:
|
||||
typedef enum
|
||||
{
|
||||
CONNECTOR_TYPE_UNKNOWN, // 未知连接点类型
|
||||
CONNECTOR_TYPE_OUTPUT, // 输出
|
||||
CONNECTOR_TYPE_INPUT, // 输入
|
||||
} Connector_Type_Enum; // 接口类型枚举
|
||||
CONNECTOR_TYPE_UNKNOWN, // 未知连接点类型
|
||||
CONNECTOR_TYPE_OUTPUT, // 输出
|
||||
CONNECTOR_TYPE_INPUT, // 输入
|
||||
CONNECTOR_TYPE_INPUT_EXCLUSIVE, // 独占输入,新连接必须断开旧连接
|
||||
} Connector_Type_Enum; // 接口类型枚举
|
||||
|
||||
typedef struct
|
||||
{
|
||||
@ -80,6 +81,9 @@ public:
|
||||
// 获取接口类型
|
||||
virtual Connector_Type_Enum Get_Type(void);
|
||||
|
||||
// 获取套接字字符串
|
||||
virtual const char *Get_Socket_Str(void);
|
||||
|
||||
// 绘制连接点
|
||||
virtual void Show(void) = 0;
|
||||
};
|
||||
@ -94,6 +98,7 @@ public:
|
||||
NODE_TYPE_UNKNOWN, // 未知节点类型
|
||||
NODE_TYPE_CONNECTOR_TEST, // 接口测试节点
|
||||
NODE_TYPE_MSG_LINE_INPUT, // 消息输入节点
|
||||
NODE_TYPE_FILTER, // 筛选器节点
|
||||
NODE_TYPE_CSV_EXPORTER, // CSV输出节点
|
||||
} Node_Type_Enum; // 节点类型枚举
|
||||
|
||||
@ -151,6 +156,34 @@ public:
|
||||
|
||||
// ====================================接口类声明================================================
|
||||
|
||||
// Boolean 状态输出接口
|
||||
class Boolean_OutPut_Connector : public Abs_Connector
|
||||
{
|
||||
public:
|
||||
// 显式禁用默认构造
|
||||
Boolean_OutPut_Connector() = delete;
|
||||
|
||||
// 必要构造
|
||||
explicit Boolean_OutPut_Connector(Independent_ID_Generator *ID_Generator);
|
||||
|
||||
// 绘制接口
|
||||
virtual void Show(void);
|
||||
};
|
||||
|
||||
// Boolean 状态输入接口
|
||||
class Boolean_InPut_Connector : public Abs_Connector
|
||||
{
|
||||
public:
|
||||
// 显式禁用默认构造
|
||||
Boolean_InPut_Connector() = delete;
|
||||
|
||||
// 必要构造
|
||||
explicit Boolean_InPut_Connector(Independent_ID_Generator *ID_Generator, bool exclusive_flag = false);
|
||||
|
||||
// 绘制接口
|
||||
virtual void Show(void);
|
||||
};
|
||||
|
||||
// DLT信息输出接口
|
||||
class MSG_OutPut_Connector : public Abs_Connector
|
||||
{
|
||||
@ -173,7 +206,7 @@ public:
|
||||
MSG_InPut_Connector() = delete;
|
||||
|
||||
// 必要构造
|
||||
explicit MSG_InPut_Connector(Independent_ID_Generator *ID_Generator);
|
||||
explicit MSG_InPut_Connector(Independent_ID_Generator *ID_Generator, bool exclusive_flag = false);
|
||||
|
||||
// 绘制接口
|
||||
virtual void Show(void);
|
||||
@ -187,7 +220,7 @@ public:
|
||||
CSV_Column_Input_Connector() = delete;
|
||||
|
||||
// 必要构造
|
||||
explicit CSV_Column_Input_Connector(Independent_ID_Generator *ID_Generator);
|
||||
explicit CSV_Column_Input_Connector(Independent_ID_Generator *ID_Generator, bool exclusive_flag = false);
|
||||
|
||||
// 绘制接口
|
||||
virtual void Show(void);
|
||||
@ -266,4 +299,26 @@ public:
|
||||
virtual bool Execute_Process(void);
|
||||
};
|
||||
|
||||
// 筛选器节点
|
||||
class Filter_Node : public Abs_Node
|
||||
{
|
||||
private:
|
||||
float node_width = 0;
|
||||
|
||||
public:
|
||||
// 显式禁用默认构造
|
||||
Filter_Node() = delete;
|
||||
|
||||
// 必要构造
|
||||
Filter_Node(Independent_ID_Generator *Node_ID_Generator,
|
||||
Independent_ID_Generator *Connector_ID_Generator,
|
||||
ImVec2 initial_position = ImVec2(0, 0));
|
||||
|
||||
// 绘制节点
|
||||
virtual void Show(void);
|
||||
|
||||
// 执行处理流程
|
||||
virtual bool Execute_Process(void);
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -98,7 +98,11 @@ bool Abs_Connector::Connect_To(Abs_Connector *target)
|
||||
if (strcmp(target->socket_str, this->socket_str) == 0)
|
||||
{
|
||||
// 写连接关系 必须是一收一发
|
||||
if (((this->type == CONNECTOR_TYPE_OUTPUT) && (target->type == CONNECTOR_TYPE_INPUT)) || ((this->type == CONNECTOR_TYPE_INPUT) && (target->type == CONNECTOR_TYPE_OUTPUT)))
|
||||
if (((this->type == CONNECTOR_TYPE_OUTPUT) && (target->type == CONNECTOR_TYPE_INPUT)) || //
|
||||
((this->type == CONNECTOR_TYPE_INPUT) && (target->type == CONNECTOR_TYPE_OUTPUT)) || //
|
||||
((this->type == CONNECTOR_TYPE_INPUT_EXCLUSIVE) && (target->type == CONNECTOR_TYPE_OUTPUT) && this->related_connector_list.empty()) || //
|
||||
((this->type == CONNECTOR_TYPE_OUTPUT) && (target->type == CONNECTOR_TYPE_INPUT_EXCLUSIVE) && target->related_connector_list.empty())) //
|
||||
|
||||
{
|
||||
// 向双方写入关联信息
|
||||
target->related_connector_list.push_back(this);
|
||||
@ -221,6 +225,11 @@ Abs_Connector::Connector_Type_Enum Abs_Connector::Get_Type(void)
|
||||
return this->type;
|
||||
}
|
||||
|
||||
// 获取套接字字符串
|
||||
const char *Abs_Connector::Get_Socket_Str(void)
|
||||
{
|
||||
return this->socket_str;
|
||||
}
|
||||
// =================================================================================================
|
||||
|
||||
// 必要构造
|
||||
@ -293,7 +302,33 @@ std::vector<std::shared_ptr<Abs_Connector>> &Abs_Node::Get_Connector_List(void)
|
||||
// =================================================================================================
|
||||
|
||||
// 必要构造
|
||||
MSG_InPut_Connector::MSG_InPut_Connector(Independent_ID_Generator *ID_Generator) : Abs_Connector(ID_Generator, CONNECTOR_TYPE_INPUT, "DLT MSG") {}
|
||||
Boolean_InPut_Connector::Boolean_InPut_Connector(Independent_ID_Generator *ID_Generator, bool exclusive_flag) : Abs_Connector(ID_Generator, exclusive_flag ? CONNECTOR_TYPE_INPUT_EXCLUSIVE : CONNECTOR_TYPE_INPUT, "Boolean") {}
|
||||
|
||||
// 绘制接口
|
||||
void Boolean_InPut_Connector::Show(void)
|
||||
{
|
||||
// 输出接口点
|
||||
ImNodes::BeginInputAttribute(this->id, ImNodesPinShape_CircleFilled);
|
||||
// 填充占位
|
||||
ImGui::Dummy(ImVec2(0.0f, ImGui::GetTextLineHeight()));
|
||||
ImNodes::EndInputAttribute();
|
||||
}
|
||||
|
||||
// 必要构造
|
||||
Boolean_OutPut_Connector::Boolean_OutPut_Connector(Independent_ID_Generator *ID_Generator) : Abs_Connector(ID_Generator, CONNECTOR_TYPE_OUTPUT, "Boolean") {}
|
||||
|
||||
// 绘制接口
|
||||
void Boolean_OutPut_Connector::Show(void)
|
||||
{
|
||||
// 输出接口点
|
||||
ImNodes::BeginOutputAttribute(this->id, ImNodesPinShape_CircleFilled);
|
||||
// 填充占位
|
||||
ImGui::Dummy(ImVec2(0.0f, ImGui::GetTextLineHeight()));
|
||||
ImNodes::EndOutputAttribute();
|
||||
}
|
||||
|
||||
// 必要构造
|
||||
MSG_InPut_Connector::MSG_InPut_Connector(Independent_ID_Generator *ID_Generator, bool exclusive_flag) : Abs_Connector(ID_Generator, exclusive_flag ? CONNECTOR_TYPE_INPUT_EXCLUSIVE : CONNECTOR_TYPE_INPUT, "DLT MSG") {}
|
||||
|
||||
// 绘制接口
|
||||
void MSG_InPut_Connector::Show(void)
|
||||
@ -319,7 +354,7 @@ void MSG_OutPut_Connector::Show(void)
|
||||
}
|
||||
|
||||
// 必要构造
|
||||
CSV_Column_Input_Connector::CSV_Column_Input_Connector(Independent_ID_Generator *ID_Generator) : Abs_Connector(ID_Generator, CONNECTOR_TYPE_INPUT, "CSV Column") {}
|
||||
CSV_Column_Input_Connector::CSV_Column_Input_Connector(Independent_ID_Generator *ID_Generator, bool exclusive_flag) : Abs_Connector(ID_Generator, exclusive_flag ? CONNECTOR_TYPE_INPUT_EXCLUSIVE : CONNECTOR_TYPE_INPUT, "CSV Column") {}
|
||||
|
||||
// 绘制接口
|
||||
void CSV_Column_Input_Connector::Show()
|
||||
@ -343,6 +378,7 @@ void CSV_Column_Output_Connector::Show()
|
||||
ImGui::Dummy(ImVec2(0.0f, ImGui::GetTextLineHeight()));
|
||||
ImNodes::EndOutputAttribute();
|
||||
}
|
||||
|
||||
// =================================================================================================
|
||||
|
||||
// 必要构造
|
||||
@ -361,9 +397,13 @@ Connector_Test_Node::Connector_Test_Node(Independent_ID_Generator *Node_ID_Gener
|
||||
this->Connector_List.push_back(std::make_shared<MSG_InPut_Connector>(Connector_ID_Generator)); // [0] -> MSG
|
||||
this->Connector_List.push_back(std::make_shared<MSG_OutPut_Connector>(Connector_ID_Generator)); // [1] MSG ->
|
||||
|
||||
// Boolean 相关接口
|
||||
this->Connector_List.push_back(std::make_shared<Boolean_InPut_Connector>(Connector_ID_Generator)); // [2] -> Boolean
|
||||
this->Connector_List.push_back(std::make_shared<Boolean_OutPut_Connector>(Connector_ID_Generator)); // [3] Boolean ->
|
||||
|
||||
// CSV 相关接口
|
||||
this->Connector_List.push_back(std::make_shared<CSV_Column_Input_Connector>(Connector_ID_Generator)); // [2] -> Column
|
||||
this->Connector_List.push_back(std::make_shared<CSV_Column_Output_Connector>(Connector_ID_Generator)); // [3] Column ->
|
||||
this->Connector_List.push_back(std::make_shared<CSV_Column_Input_Connector>(Connector_ID_Generator)); // [4] -> Column
|
||||
this->Connector_List.push_back(std::make_shared<CSV_Column_Output_Connector>(Connector_ID_Generator)); // [5] Column ->
|
||||
}
|
||||
}
|
||||
|
||||
@ -406,7 +446,7 @@ void Connector_Test_Node::Show(void)
|
||||
{
|
||||
ImGui::Text("Node ID : %d\n", this->id);
|
||||
ImGui::Separator();
|
||||
ImGui::Text(u8"注意!仅供接口测试使用!\n该节点不会进行任何处理操作,且不会生成任何产物");
|
||||
ImGui::Text(u8"注意!仅供接口测试使用!\n该节点不会进行任何处理操作\n有成对接口时会将输入接口连接的首个接口输入包转发到对应的出口");
|
||||
ImGui::EndTooltip();
|
||||
}
|
||||
|
||||
@ -454,6 +494,24 @@ void Connector_Test_Node::Show(void)
|
||||
this->Connector_List[1]->Show();
|
||||
}
|
||||
|
||||
// 绘制Boolean相关接口
|
||||
{
|
||||
// 宽度判定
|
||||
auto text_width = ImGui::CalcTextSize("-> Boolean-In").x + ImGui::CalcTextSize("Boolean-Out ->").x;
|
||||
if (dimension.x < text_width + ImNodes::GetStyle().NodePadding.x * 2)
|
||||
all_width_fit = false;
|
||||
|
||||
this->Connector_List[2]->Show();
|
||||
ImGui::SameLine();
|
||||
ImGui::Text("-> Boolean-In");
|
||||
ImGui::SameLine();
|
||||
ImGui::Dummy(ImVec2(this->node_width - text_width - ImNodes::GetStyle().NodePadding.x * 2, 0.0f));
|
||||
ImGui::SameLine();
|
||||
ImGui::Text("Boolean-Out ->");
|
||||
ImGui::SameLine();
|
||||
this->Connector_List[3]->Show();
|
||||
}
|
||||
|
||||
// 绘制CSV列相关接口组
|
||||
{
|
||||
// 宽度判定
|
||||
@ -463,7 +521,7 @@ void Connector_Test_Node::Show(void)
|
||||
if (this->node_width == 0)
|
||||
this->node_width = text_width + ImNodes::GetStyle().NodePadding.x * 2 + ImGui::CalcTextSize("A").x;
|
||||
|
||||
this->Connector_List[2]->Show();
|
||||
this->Connector_List[4]->Show();
|
||||
ImGui::SameLine();
|
||||
ImGui::Text("-> CSV-Column-In");
|
||||
ImGui::SameLine();
|
||||
@ -471,7 +529,7 @@ void Connector_Test_Node::Show(void)
|
||||
ImGui::SameLine();
|
||||
ImGui::Text("CSV-Column-Out ->");
|
||||
ImGui::SameLine();
|
||||
this->Connector_List[3]->Show();
|
||||
this->Connector_List[5]->Show();
|
||||
}
|
||||
|
||||
ImGui::PopStyleVar();
|
||||
@ -487,6 +545,33 @@ void Connector_Test_Node::Show(void)
|
||||
// 执行处理流程
|
||||
bool Connector_Test_Node::Execute_Process(void)
|
||||
{
|
||||
// DLT MSG 相关接口
|
||||
if (!this->Connector_List[0]->Get_Related_List().empty())
|
||||
{
|
||||
// [0] -> MSG
|
||||
// [1] MSG ->
|
||||
auto pkg = this->Connector_List[0]->Get_Related_List()[0]->Get_Package();
|
||||
this->Connector_List[1]->Register_Package(pkg.p_content_mem, pkg.content_size, pkg.package_count, pkg.total_count);
|
||||
}
|
||||
|
||||
// Boolean 相关接口
|
||||
if (!this->Connector_List[2]->Get_Related_List().empty())
|
||||
{
|
||||
// [2] -> Boolean
|
||||
// [3] Boolean ->
|
||||
auto pkg = this->Connector_List[2]->Get_Related_List()[0]->Get_Package();
|
||||
this->Connector_List[3]->Register_Package(pkg.p_content_mem, pkg.content_size, pkg.package_count, pkg.total_count);
|
||||
}
|
||||
|
||||
// CSV 相关接口
|
||||
if (!this->Connector_List[4]->Get_Related_List().empty())
|
||||
{
|
||||
// [4] -> Column
|
||||
// [5] Column ->
|
||||
auto pkg = this->Connector_List[4]->Get_Related_List()[0]->Get_Package();
|
||||
this->Connector_List[5]->Register_Package(pkg.p_content_mem, pkg.content_size, pkg.package_count, pkg.total_count);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -650,29 +735,195 @@ bool MSG_Input_Node::Execute_Process(void)
|
||||
// 排序后消息处理
|
||||
this->log.Sort();
|
||||
this->excute_flag = true;
|
||||
this->private_excute_count = 0;
|
||||
this->private_excute_end_count = this->log.msg_list.size();
|
||||
}
|
||||
|
||||
// 注册接口包,执行期间不可以释放log,否则传入的产物中vector会虚空索引
|
||||
if (this->private_excute_count < this->private_excute_end_count)
|
||||
{
|
||||
// [0] -> MSG
|
||||
this->Connector_List[0]->Register_Package((void *)&(this->log.msg_list[this->private_excute_count]),
|
||||
sizeof(this->log.msg_list[0]),
|
||||
this->private_excute_count + 1,
|
||||
this->excute_end_count);
|
||||
this->private_excute_count++;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 注册接口包,执行期间不可以释放log,否则传入的产物中vector会虚空索引
|
||||
if (this->private_excute_count < this->private_excute_end_count)
|
||||
{
|
||||
// [0] -> MSG
|
||||
this->Connector_List[0]->Register_Package((void *)&(this->log.msg_list[this->private_excute_count]),
|
||||
sizeof(this->log.msg_list[0]),
|
||||
this->private_excute_count + 1,
|
||||
this->excute_end_count);
|
||||
this->private_excute_count++;
|
||||
}
|
||||
else
|
||||
{
|
||||
this->log.Clear();
|
||||
this->excute_flag = false;
|
||||
this->private_excute_count = 0;
|
||||
this->private_excute_end_count = 0;
|
||||
this->private_finish_flag = true;
|
||||
}
|
||||
this->log.Clear();
|
||||
this->excute_flag = false;
|
||||
this->private_excute_count = 0;
|
||||
this->private_excute_end_count = 0;
|
||||
this->private_finish_flag = true;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
};
|
||||
|
||||
// 必要构造
|
||||
Filter_Node::Filter_Node(Independent_ID_Generator *Node_ID_Generator,
|
||||
Independent_ID_Generator *Connector_ID_Generator,
|
||||
ImVec2 initial_position)
|
||||
: Abs_Node(Node_ID_Generator,
|
||||
Connector_ID_Generator,
|
||||
NODE_TYPE_FILTER,
|
||||
initial_position)
|
||||
{
|
||||
// 判定是否成功申请ID
|
||||
if (this->id != -1)
|
||||
{
|
||||
// Boolean 输入节点
|
||||
this->Connector_List.push_back(std::make_shared<Boolean_InPut_Connector>(Connector_ID_Generator, true)); // [0] -> Boolean
|
||||
|
||||
// 消息输出节点
|
||||
this->Connector_List.push_back(std::make_shared<MSG_InPut_Connector>(Connector_ID_Generator, true)); // [1] -> MSG
|
||||
this->Connector_List.push_back(std::make_shared<MSG_OutPut_Connector>(Connector_ID_Generator)); // [2] MSG ->
|
||||
}
|
||||
}
|
||||
|
||||
// 绘制节点
|
||||
void Filter_Node::Show(void)
|
||||
{
|
||||
if (this->close_flag == true)
|
||||
return;
|
||||
|
||||
// 初始化位置设定
|
||||
if ((this->initial_position.x != 0) || (this->initial_position.y != 0))
|
||||
{
|
||||
ImNodes::SetNodeScreenSpacePos(this->id, this->initial_position);
|
||||
this->initial_position = ImVec2(0, 0);
|
||||
}
|
||||
|
||||
// 全宽适配
|
||||
bool all_width_fit = true;
|
||||
|
||||
// 绘制节点
|
||||
ImNodes::BeginNode(this->id);
|
||||
{
|
||||
|
||||
// 获取节点当前长宽维度
|
||||
ImVec2 dimension = ImNodes::GetNodeDimensions(this->id);
|
||||
|
||||
// 标题部分
|
||||
ImNodes::BeginNodeTitleBar();
|
||||
{
|
||||
const char *title_str = u8"消息筛选器";
|
||||
|
||||
ImGui::Text(title_str);
|
||||
ImGui::SameLine();
|
||||
{
|
||||
ImGui::TextDisabled(u8"(?)");
|
||||
// 上下边距为调整
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(8.f, 8.f));
|
||||
|
||||
if (ImGui::BeginItemTooltip())
|
||||
{
|
||||
ImGui::Text("Node ID : %d\n", this->id);
|
||||
ImGui::Separator();
|
||||
ImGui::Text(u8"对传入的MSG进行筛选\n不满足条件时将输出一个空包\n任意Boolean传入为真都会放行传入的MSG");
|
||||
ImGui::EndTooltip();
|
||||
}
|
||||
|
||||
ImGui::PopStyleVar();
|
||||
}
|
||||
ImGui::SameLine();
|
||||
|
||||
// 节点宽度调整
|
||||
ImVec2 dimension = ImNodes::GetNodeDimensions(this->id);
|
||||
auto button_diameter = ImGui::GetTextLineHeight();
|
||||
auto text_width = ImGui::CalcTextSize(title_str).x + ImGui::CalcTextSize(u8"(?)").x;
|
||||
// auto Tittle_Str_Width = text_width + ImNodes::GetStyle().NodePadding.x * 2 + ImGui::GetStyle().ItemSpacing.x * 2;
|
||||
auto Tittle_Str_Width = text_width + ImGui::GetStyle().ItemSpacing.x * 2; // 不知道为什么这里加上 NodePadding.x * 2 反而不对了
|
||||
|
||||
// 宽度判定
|
||||
if (dimension.x < Tittle_Str_Width + button_diameter + ImGui::GetStyle().ItemSpacing.x)
|
||||
all_width_fit = false;
|
||||
|
||||
ImGui::Dummy(ImVec2(this->node_width - Tittle_Str_Width - button_diameter - ImGui::GetStyle().ItemSpacing.x, 0.0f));
|
||||
ImGui::SameLine();
|
||||
|
||||
// 绘制关闭按钮
|
||||
if (CircleButtonWithX("#X", button_diameter / 2))
|
||||
this->close_flag = true;
|
||||
}
|
||||
ImNodes::EndNodeTitleBar();
|
||||
|
||||
// 节点主体部分
|
||||
{
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0.0f, ImGui::GetStyle().ItemSpacing.y));
|
||||
|
||||
// 绘制Boolean 输入接口
|
||||
{
|
||||
auto text_width = ImGui::CalcTextSize("-> Boolean [Pass allow]").x;
|
||||
|
||||
// 宽度初始化
|
||||
if (this->node_width == 0)
|
||||
this->node_width = text_width;
|
||||
|
||||
if (dimension.x < text_width + ImNodes::GetStyle().NodePadding.x * 2)
|
||||
all_width_fit = false;
|
||||
this->Connector_List[0]->Show();
|
||||
ImGui::SameLine();
|
||||
ImGui::Text("-> Boolean ");
|
||||
ImGui::SameLine();
|
||||
ImGui::TextDisabled(u8"[Pass allow]");
|
||||
}
|
||||
|
||||
// 绘制DLT相关接口组
|
||||
{
|
||||
// 宽度判定
|
||||
auto text_width = ImGui::CalcTextSize("-> DLT-In").x + ImGui::CalcTextSize("DLT-Out ->").x;
|
||||
if (dimension.x < text_width + ImNodes::GetStyle().NodePadding.x * 2 + ImGui::CalcTextSize("A").x)
|
||||
all_width_fit = false;
|
||||
|
||||
this->Connector_List[1]->Show();
|
||||
ImGui::SameLine();
|
||||
ImGui::Text("-> DLT-In");
|
||||
ImGui::SameLine();
|
||||
// ImGui::Dummy(ImVec2(this->node_width - text_width - ImNodes::GetStyle().NodePadding.x * 2, 0.0f));
|
||||
ImGui::Dummy(ImVec2(this->node_width - text_width, 0.0f)); // 不知道为什么这里加上 NodePadding.x * 2 反而不对了
|
||||
ImGui::SameLine();
|
||||
ImGui::Text("DLT-Out ->");
|
||||
ImGui::SameLine();
|
||||
this->Connector_List[2]->Show();
|
||||
}
|
||||
|
||||
ImGui::PopStyleVar();
|
||||
}
|
||||
|
||||
// 使用递进的方式自适应宽度
|
||||
if (all_width_fit == false)
|
||||
this->node_width += 1.0f;
|
||||
}
|
||||
ImNodes::EndNode();
|
||||
}
|
||||
|
||||
// 执行处理流程
|
||||
bool Filter_Node::Execute_Process(void)
|
||||
{
|
||||
|
||||
bool pass_allow = false;
|
||||
for (auto input : this->Connector_List[0]->Get_Related_List())
|
||||
if (*((bool *)input->Get_Package().p_content_mem) == true)
|
||||
{
|
||||
pass_allow = true;
|
||||
break;
|
||||
}
|
||||
|
||||
auto pkg = this->Connector_List[1]->Get_Package();
|
||||
|
||||
if (pass_allow)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
|
||||
// 注册产物
|
||||
this->Connector_List[2]->Register_Package(pkg.p_content_mem, pkg.content_size, pkg.package_count, pkg.total_count);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// END
|
||||
@ -63,6 +63,8 @@ void Workflow_Editor::Show(void)
|
||||
this->Add_Node(Abs_Node::NODE_TYPE_CONNECTOR_TEST, click_pos);
|
||||
if (ImGui::MenuItem(u8"DLT信息输入节点"))
|
||||
this->Add_Node(Abs_Node::NODE_TYPE_MSG_LINE_INPUT, click_pos);
|
||||
if (ImGui::MenuItem(u8"消息筛选器"))
|
||||
this->Add_Node(Abs_Node::NODE_TYPE_FILTER, click_pos);
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
|
||||
@ -257,6 +259,13 @@ bool Workflow_Editor::Add_Node(Abs_Node::Node_Type_Enum type, ImVec2 initial_pos
|
||||
&this->Connector_ID_Generator,
|
||||
initial_position);
|
||||
break;
|
||||
case Abs_Node::NODE_TYPE_FILTER: // 消息筛选器
|
||||
|
||||
// 创建节点
|
||||
p_New_Node = std::make_shared<Filter_Node>(&this->Node_ID_Generator,
|
||||
&this->Connector_ID_Generator,
|
||||
initial_position);
|
||||
break;
|
||||
|
||||
case Abs_Node::NODE_TYPE_CSV_EXPORTER: // CSV输出器
|
||||
break;
|
||||
@ -350,6 +359,10 @@ bool Workflow_Editor::Add_Link(int source_connector_id, int target_connector_id)
|
||||
// 判定查找结果
|
||||
if (find)
|
||||
{
|
||||
// 判定套接字是否一致
|
||||
if (strcmp(p_source_connector->Get_Socket_Str(), p_target_connector->Get_Socket_Str()))
|
||||
return false;
|
||||
|
||||
// 检查下一步的连接是否会出现回环
|
||||
{
|
||||
// 工具Lambda表达式,查找接口id的所属节点
|
||||
@ -420,13 +433,28 @@ bool Workflow_Editor::Add_Link(int source_connector_id, int target_connector_id)
|
||||
}
|
||||
}
|
||||
|
||||
// 先尝试连接,成功后再进行边池操作
|
||||
if (p_source_connector->Connect_To(p_target_connector.get()) == true)
|
||||
// 独占输入类型,清除所有其它的连接
|
||||
if (p_source_connector->Get_Type() == Abs_Connector::CONNECTOR_TYPE_INPUT_EXCLUSIVE)
|
||||
{
|
||||
// 记录到边池
|
||||
this->Edge_Pool.push_back({this->Edge_ID_Generator.Request_ID(), source_connector_id, target_connector_id});
|
||||
auto source_id = p_source_connector->Get_ID();
|
||||
auto List = p_source_connector->Get_Related_List();
|
||||
for (auto connector : List)
|
||||
this->Del_Link(source_id, connector->Get_ID());
|
||||
}
|
||||
|
||||
// 独占输入类型,清除所有其它的连接
|
||||
if (p_target_connector->Get_Type() == Abs_Connector::CONNECTOR_TYPE_INPUT_EXCLUSIVE)
|
||||
{
|
||||
auto target_id = p_target_connector->Get_ID();
|
||||
auto List = p_target_connector->Get_Related_List();
|
||||
for (auto connector : List)
|
||||
this->Del_Link(target_id, connector->Get_ID());
|
||||
}
|
||||
|
||||
// 先尝试连接,成功后再记录到边池
|
||||
if (p_source_connector->Connect_To(p_target_connector.get()) == true)
|
||||
this->Edge_Pool.push_back({this->Edge_ID_Generator.Request_ID(), source_connector_id, target_connector_id});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -479,7 +507,8 @@ bool Workflow_Editor::Del_Link(int source_connector_id, int target_connector_id)
|
||||
{
|
||||
// 遍历边池,删除对应的边
|
||||
for (auto iterator = this->Edge_Pool.begin(); iterator != this->Edge_Pool.end(); iterator++)
|
||||
if ((iterator->source_connector_id == source_connector_id) && (iterator->target_connector_id == target_connector_id))
|
||||
if (((iterator->source_connector_id == source_connector_id) && (iterator->target_connector_id == target_connector_id)) ||
|
||||
((iterator->source_connector_id == target_connector_id) && (iterator->target_connector_id == source_connector_id)))
|
||||
{
|
||||
this->Del_Link(iterator);
|
||||
return true;
|
||||
@ -581,7 +610,7 @@ bool Workflow_Editor::Build_Process_Route(void)
|
||||
std::vector<std::shared_ptr<Abs_Node>> Dependency_NodeList;
|
||||
for (auto pConnector : pTargetNode->Get_Connector_List())
|
||||
{
|
||||
if (pConnector->Get_Type() == Abs_Connector::CONNECTOR_TYPE_INPUT)
|
||||
if ((pConnector->Get_Type() == Abs_Connector::CONNECTOR_TYPE_INPUT) || (pConnector->Get_Type() == Abs_Connector::CONNECTOR_TYPE_INPUT_EXCLUSIVE))
|
||||
{
|
||||
for (auto pPreConnector : pConnector->Get_Related_List())
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user