168 lines
6.1 KiB
C++
168 lines
6.1 KiB
C++
/*
|
||
* @file LayoutModuleCmd.h
|
||
* @brief LayoutModuleCmd是对工作流编辑界面模块进行排列的命令
|
||
* @date: 2012-10-10
|
||
* @author: limengzhuo
|
||
*/
|
||
#ifndef PAI_FRAME_WORKFLOWVIEW_LAYOUTMODULECMD_H
|
||
#define PAI_FRAME_WORKFLOWVIEW_LAYOUTMODULECMD_H
|
||
|
||
#include <QGraphicsItem>
|
||
#include <QMap>
|
||
#include <QUndoCommand>
|
||
#include "ModuleConnection.h"
|
||
|
||
namespace pai
|
||
{
|
||
namespace objectmodel
|
||
{
|
||
class PaiWorkflowDataModel;
|
||
}
|
||
namespace graphics2d
|
||
{
|
||
class ModuleGraphicsItem;
|
||
class WorkflowSceneManager;
|
||
}
|
||
/**
|
||
* @class LayoutModuleCmd
|
||
* @brief LayoutModuleCmd是对工作流编辑界面模块进行排列的命令
|
||
*/
|
||
class LayoutModuleCmd :public QUndoCommand
|
||
{
|
||
public:
|
||
LayoutModuleCmd(pai::graphics2d::WorkflowSceneManager *pSceneManager,
|
||
pai::objectmodel::PaiWorkflowDataModel *pWorkflow, QList<QGraphicsItem*> list, QUndoCommand *parent = 0);
|
||
virtual ~LayoutModuleCmd();
|
||
/**
|
||
* @brief undo
|
||
*/
|
||
void undo();
|
||
/**
|
||
* @brief redo
|
||
*/
|
||
void redo();
|
||
|
||
private:
|
||
/**
|
||
* @brief 取消排列模块
|
||
*/
|
||
void recoveryLayout();
|
||
|
||
/**
|
||
* @brief 更新连接线
|
||
*/
|
||
void updateConnectionLine();
|
||
|
||
/**
|
||
* @brief 打印图元层次关系列表
|
||
*/
|
||
void PrintMap();
|
||
/**
|
||
* @brief 获取图元层次关系列表
|
||
*/
|
||
void GetModuleRelationMap(QList<int> &stepIdList);
|
||
/**
|
||
* @brief 根据模块的StepId列表从工作流场景获取模块图元列表
|
||
* @param stepIdList 模块StepId列表
|
||
*/
|
||
QList<pai::graphics2d::ModuleGraphicsItem*> GetModuleGraphicsItems(QList<int> stepIdList);
|
||
/**
|
||
* @brief 根据模块的图元列表获取StepId列表
|
||
* @param moduleList 模块图元列表
|
||
*/
|
||
QList<int> GetModuleStepIdList(QList<pai::graphics2d::ModuleGraphicsItem*> moduleList);
|
||
/**
|
||
* @brief 获取StepId为stepId的图元的所有直接输出图元的StepId
|
||
* @param stepId 图元的 StepId
|
||
* @param stepIdList 所选模块的StepId列表
|
||
*/
|
||
QList<int> GetDestModules(int stepId, QList<int> stepIdList);
|
||
/**
|
||
* @brief 递归获取StepId为stepId的图元的最大深度的所有输出图元的StepId
|
||
* @param stepId 图元的 StepId
|
||
* @param stepIdListAdjusted 最大深度的所有输出图元的StepId列表
|
||
* @param stepIdList 所选模块的StepId列表
|
||
*/
|
||
void GetDestModulesRecursive(int stepId, QList<int> &stepIdListAdjusted, QList<int> stepIdList);
|
||
/**
|
||
* @brief 获取StepId为destStepId的图元的所有直接输入图元的StepId列表
|
||
* @param destStepId 图元的 StepId
|
||
* @param stepIdListSameLevel 同一层上的所有模块的StepId列表
|
||
*/
|
||
QList<int> GetSourceModules(int destStepId, QList<int> stepIdListSameLevel);
|
||
/**
|
||
* @brief 获取和StepId为stepId的图元在一个层上的所有图元的StepId列表 (该层上所有图元有相同的Destination)。
|
||
* @param sameDestList 一个层上的所有图元的StepId列表
|
||
* @param stepIdList 所选模块的StepId列表
|
||
*/
|
||
void FindModulesWithSameDest(int stepId, QList<int> &sameDestList, QList<int> stepIdList);
|
||
/**
|
||
* @brief 获取和StepId为stepId的图元在一个层上的所有图元的StepId列表 (该层上所有图元有相同的Source)。
|
||
* @param sameSourceList 一个层上的所有图元的StepId列表
|
||
* @param stepIdList 所选模块的StepId列表
|
||
*/
|
||
void FindModulesWithSameSource(int stepId, QList<int> &sameSourceList, QList<int> stepIdList);
|
||
/**
|
||
* @brief 从图元列表中查找模块图元
|
||
* @param stepId 要查找模块的StepId
|
||
* @param itemList 模块图元列表
|
||
*/
|
||
pai::graphics2d::ModuleGraphicsItem* FindModule(int stepId, QList<pai::graphics2d::ModuleGraphicsItem*> itemList);
|
||
|
||
/**
|
||
* @brief 从模块的StepId列表获取模块图元列表
|
||
* @param stepIdList 模块StepId列表
|
||
*/
|
||
QList<pai::graphics2d::ModuleGraphicsItem*> GetModuleGraphicsItemsFromStepId(QList<int> stepIdList);
|
||
|
||
/**
|
||
* @brief 获取同一层上模块的最大个数
|
||
*/
|
||
int GetMaxWidth();
|
||
|
||
/**
|
||
* @brief分类存储module,目前只有2类,线和模块
|
||
*/
|
||
void CategorizedModule();
|
||
|
||
/**
|
||
* @brief 获取根item的stepID
|
||
* @return 返回最顶层的所有item的step
|
||
*/
|
||
QList<int> GetRootModule();
|
||
|
||
/**
|
||
* @brief 设置模块分层信息map
|
||
* @param[in] topID 顶层item的stepID链表
|
||
*/
|
||
void SetRelationMap(QList<int> topID);
|
||
|
||
/**
|
||
* @brief 布局所有item
|
||
*/
|
||
void LayoutModule();
|
||
|
||
/**
|
||
* @brief 合理布局场景中的工作流树
|
||
*/
|
||
void LayoutWorkflow();
|
||
|
||
public:
|
||
static const int nDefaultIntervalY = 28; //模块间的高度距离
|
||
static const int nDefaultIntervalX = 10; //模块间的宽度距离
|
||
private:
|
||
QList<QGraphicsItem*> m_list;//被选图元指针列表
|
||
QList<int> m_stepIdList; //被选模块的StepId
|
||
QList<pai::graphics2d::ModuleGraphicsItem*> m_moduleList;//被选模块列表
|
||
QList<workflow::CModuleConnection*> m_connectionList;//被选模块连线列表
|
||
pai::graphics2d::WorkflowSceneManager *m_pSceneManager;//工作流场景
|
||
pai::objectmodel::PaiWorkflowDataModel* m_pWorkflow;//工作流模型
|
||
QList<QPointF> m_ModuleItemPosList;//存放所有module item在layout之前的坐标
|
||
QMap<int, QList<int> > m_moduleRelationMap;//模块的分层信息表
|
||
qreal m_moduleSceneRectHeight;//模块的高度
|
||
qreal m_moduleSceneRectWidth;//模块的宽度
|
||
int m_maxWidth; //同一层上模块的最大个数
|
||
};
|
||
}
|
||
#endif /* PAI_FRAME_WORKFLOWVIEW_LAYOUTMODULECMD_H */
|