logplus/ModuleConsole/command/include/AddLineCmd.h

134 lines
4.5 KiB
C
Raw Normal View History

2026-01-16 17:18:41 +08:00
/*
* @file AddLineCmd.h
* @brief AddLineCmd是为工作流编辑界面模块添加连线的命令
* @date: 2012-10-10
* @author: limengzhuo
*/
#ifndef PAI_FRAME_WORKFLOWVIEW_ADDLINECMD_H
#define PAI_FRAME_WORKFLOWVIEW_ADDLINECMD_H
#include <QGraphicsItem>
#include <QUndoCommand>
#include "ModuleConnection.h"
namespace pai
{
namespace objectmodel
{
class PaiWorkflowDataModel;
}
namespace graphics2d
{
class ModuleGraphicsItem;
class WorkflowSceneManager;
}
/**
* @class AddLineCmd
* @brief AddLineCmd是为工作流编辑界面模块添加连线的命令
*/
class AddLineCmd :public QUndoCommand
{
public:
/**
* @brief
* @param[in] pSceneManager
* @param[in] pWorkflow
* @param[in] pStartItem Item
* @param[in] pEndItem Item
* @param[in] parent
*/
AddLineCmd(pai::graphics2d::WorkflowSceneManager *pSceneManager,
pai::objectmodel::PaiWorkflowDataModel *pWorkflow,
pai::graphics2d::ModuleGraphicsItem *pStartItem,
pai::graphics2d::ModuleGraphicsItem *pEndItem,
QUndoCommand *pParent = 0);
/**
* @brief
* @param[in] pSceneManager
* @param[in] pWorkflow
* @param[in] pStartItem Item
* @param[in] pEndItem Item
* @param[in] nStartPortIndex
* @param[in] nEndPortIndex
* @param[in] parent
*/
AddLineCmd(pai::graphics2d::WorkflowSceneManager *pSceneManager,
pai::objectmodel::PaiWorkflowDataModel *pWorkflow,
pai::graphics2d::ModuleGraphicsItem *pStartItem,
pai::graphics2d::ModuleGraphicsItem *pEndItem,
int nStartPortIndex,
int nEndPortIndex,
QUndoCommand *pParent = 0);
/**
* @biref
*/
virtual ~AddLineCmd();
/**
* @brief
*/
void undo();
/**
* @brief 线
*/
void redo();
/**
*@brief 线
*/
bool GetPortHasbeenLined();
/**
* @brief 线stepID
* @param[in] first stepID
*/
void SetFirstStepID(int first);
/**
* @brief 线stepID
* @param[in] second stepID
*/
void SetSecondStepID(int second);
private:
/**
* @brief 线
*/
void RemoveLine();
/**
* @brief 线
*/
void AddLine();
/**
* @brief
* @param[in] pStartItem 线
* @param[in] pEndItem 线
*/
bool DetectCircle(pai::graphics2d::ModuleGraphicsItem *pStartItem,
pai::graphics2d::ModuleGraphicsItem *pEndItem);
private:
enum AddLineType
{
AddLineType_General = 0, //只选定了两个模块添加连线
AddLineType_Destinated = 1, //选定了两个模块,并明确了起点和终点端口,添加连线的情况
};
pai::graphics2d::WorkflowSceneManager *m_pSceneManager; //场景
pai::objectmodel::PaiWorkflowDataModel* m_pWorkflow; //工作流模型
workflow::CModuleConnection* m_pConnection; //被添加连线指针
int m_nStepIdFirst; //开始Item的stepID
int m_nStepIdSecond; //结束Item的stepID
int m_nStartPortIndex; //连线起点的端口
int m_nEndPortIndex; //连线终点的端口
AddLineType m_type; //连线添加的类型见AddLineType
bool m_bPortBeenLined; //端口是否被连线
};
}
#endif /* PAI_FRAME_WORKFLOWVIEW_ADDLINECMD_H */