262 lines
9.3 KiB
C++
262 lines
9.3 KiB
C++
/*
|
||
* ParameterEditorModule.h
|
||
*
|
||
* Created on: 2011-9-16
|
||
* Author: dev
|
||
*/
|
||
|
||
#ifndef PAI_FRAME_WORKFLOWVIEW_PARAMETEREDITORMODEL_H
|
||
#define PAI_FRAME_WORKFLOWVIEW_PARAMETEREDITORMODEL_H
|
||
|
||
#include <QAbstractItemModel>
|
||
#include <QUuid>
|
||
#include "Module.h"
|
||
#include "ModuleCheckResult.h"
|
||
#include "WorkflowSpecialTypes.h"
|
||
#include "ModuleInformation.h"
|
||
#include "ParameterValidateThread.h"
|
||
class QString;
|
||
class QAbstractButton;
|
||
|
||
namespace pai
|
||
{
|
||
namespace workflow
|
||
{
|
||
class CModuleInformation;
|
||
}
|
||
}
|
||
namespace pai {
|
||
namespace graphics2d {
|
||
|
||
//class CParameterItem;
|
||
class ParameterProperty;
|
||
/**
|
||
* @class ParameterEditorModel
|
||
* @brief 参数编辑面板的模型类,用来将一个模块参数列表转化为QTreeView所能接受的模型,从而能通过QTreeView界面加载及修改模块参数
|
||
*/
|
||
class ParameterEditorModel :public QAbstractItemModel
|
||
{
|
||
Q_OBJECT
|
||
public:
|
||
bool GetCurrentZone(float &sdep,float &edep);
|
||
/**
|
||
* @brief 自定义数据树项的数据的角色
|
||
*/
|
||
enum ItemDataRole
|
||
{
|
||
ErrorRole = Qt::UserRole + 1, //错误信息
|
||
HDFSFileRole = Qt::UserRole + 2 //HDFSFILEBROWSER或者HDFSFILEEDITOR类型的参数值
|
||
};
|
||
|
||
ParameterEditorModel(QObject *parent=0);
|
||
virtual ~ParameterEditorModel();
|
||
void FreshDepth(QString strArrayItemID);
|
||
|
||
/**
|
||
* @brief 设置当前选中工作流ID
|
||
* @param workflowID 添加的工作流ID
|
||
*/
|
||
void SetCurrentWorkflowID(const QUuid &workflowID);
|
||
//用于判断是否是组合方法,从而不显示参数区
|
||
bool m_CompositeMethod;
|
||
void AddCompositeItemp(ParameterProperty* pPP1,pai::module::CParameterItem* pItem,int pos=-1);
|
||
// CParameterItem* CreateItem(CModule *current_module,CCompositeParameterItem* pArrayItem,float sdep,float edep);
|
||
|
||
/**
|
||
* @brief 重载函数,用来根据给定父亲节点索引和在父节点布局中的行列值,返回正确的携带参数项数据的子节点索引
|
||
* @param row 在父节点布局中的行值
|
||
* @param column 在父节点布局中的行值
|
||
* @param parent 父亲节点索引
|
||
*/
|
||
QModelIndex index(int row,int column,const QModelIndex & parent = QModelIndex()) const;
|
||
|
||
/**
|
||
* @brief 重载函数,用来根据给定子节点索引,返回正确的携带参数项数据的父节点索引
|
||
* @param index 子节点索引
|
||
*/
|
||
QModelIndex parent(const QModelIndex & index) const;
|
||
/**
|
||
* @brief 重载函数,用来回答给定父节点索引的父节点拥有的行数
|
||
* @param index 父节点索引
|
||
*/
|
||
int rowCount(const QModelIndex & parent = QModelIndex()) const;
|
||
/**
|
||
* @brief 重载函数,用来回答给定父节点索引的父节点拥有的列数
|
||
* @param index 父节点索引
|
||
*/
|
||
int columnCount(const QModelIndex & parent = QModelIndex()) const;
|
||
/**
|
||
* @brief 重载函数,用来根据角色回答给定节点索引所携带的参数项数据
|
||
* @param index 给定节点索引
|
||
* @param role 节点数据的角色分类
|
||
*/
|
||
QVariant data(const QModelIndex & index,int role=Qt::DisplayRole) const;
|
||
|
||
/**
|
||
* @brief 重载函数,用来根据角色和QTreeView传来的界面数据设置给定节点索引所携带的参数项数据
|
||
* @param index 给定节点索引
|
||
* @param value QTreeView传来的界面数据
|
||
* @param role 节点数据的角色分类
|
||
*/
|
||
virtual bool setData(const QModelIndex & index, const QVariant & value, int role = Qt::EditRole);
|
||
|
||
/**
|
||
* @brief 重载函数 回答用来控制QTreeView表现的一些标志位
|
||
* @param index 给定节点索引
|
||
*/
|
||
Qt::ItemFlags flags ( const QModelIndex & index ) const;
|
||
/**
|
||
* @brief 重载函数 用来给列头设置文本为空文本
|
||
* @param section 列索引
|
||
* @param orientation 表头的方向,这里只考虑水平方向
|
||
* @param role 数据的角色,也即数据的分类。
|
||
*/
|
||
QVariant headerData ( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;
|
||
public:
|
||
void OnZoneValueChanged(QString str);
|
||
void ChangeCurrentParam(float depth,float minX,QString ID);
|
||
void ChangeMXParam(float depth,float minX,float maxX,QString curvename,int zoneno,int changetype,QString ID);
|
||
QModelIndex ChangeExpand(float depth,int zoneno,QString ID);
|
||
void AddDepth(float depth,QString ID);
|
||
void DeleteDepth(float depth,QString ID);
|
||
/**
|
||
* @brief 根据给定的参数数据匹配出相应的节点索引
|
||
* @param pParameterProperty 给定的参数数据
|
||
*/
|
||
QModelIndex IndexFromParameterProperty(ParameterProperty * pParameterProperty) const;
|
||
QModelIndex GetIndexByParameterItemID(const QModelIndex& parentIndex,const QString& strItemID);
|
||
/**
|
||
* @brief 根据给定模块信息提取所有参数信息到m_rootItem为根节点的树形数据结构,QTreeView根据这些数据自动形成节点。
|
||
* @param pModuleInfo 给定模块信息
|
||
*/
|
||
void BuildItems(pai::workflow::CModuleInformation* pModuleInfo);
|
||
CParameterValidateThread * GetValidateThread();
|
||
/**
|
||
* @brief 清空m_rootItem为根节点的树形数据结构
|
||
*/
|
||
void clear();
|
||
|
||
/**
|
||
* @brief 得到当前的模块信息对象句柄
|
||
*/
|
||
workflow::CModuleInformation *GetModuleInformation();
|
||
/**
|
||
* @brief 更新删除按钮的显示或隐藏,对于含有"KeepOneRow"属性的Array节点
|
||
* 处理删除按钮的出现与消失,如果孩子只剩一个就隐藏删除按钮,如果孩子变为两个则使第一个孩子出现删除按钮
|
||
*/
|
||
void HandleDeleteButtons();
|
||
/**
|
||
* @brief 启动参数校验线程
|
||
* @param eventSource启动验证的事件源,默认是参数改变启动
|
||
*/
|
||
void StartValidation(ValidateEventSource eventSource = ValidateEventSource_FromParameterItemChanged);
|
||
/**
|
||
* @brief 处理类别的显示
|
||
* @param categoryIndex 类别
|
||
*/
|
||
void HandleCategoryVisible(const QModelIndex &categoryIndex);
|
||
|
||
/**
|
||
* @brief 设置 Output模块Overwrite 参数的 Enable 和 Disable 状态。
|
||
*/
|
||
void EnableOverwriteItem();
|
||
/**
|
||
* @brief 根据给定的节点索引匹配出响应的参数数据
|
||
* @param index 给定的节点索引
|
||
*/
|
||
ParameterProperty * ParameterPropertyFromIndex(const QModelIndex &index) const;
|
||
void SetModuleInfo(pai::workflow::CModuleInformation *pModuleInfo);
|
||
signals:
|
||
/**
|
||
* @brief 保证某项被看到的信号
|
||
* @param 索引项
|
||
*/
|
||
void signalMakeIndexVisible(const QModelIndex &);
|
||
//增加或者减少井段参数时触发
|
||
void signalZoneValueChanged(QString zone);
|
||
void signalOpenModuleParam(pai::workflow::CModuleInformation*);
|
||
public slots:
|
||
/**
|
||
* @brief 当参数检查结束时,给树形数据结构所携带的每个参数项赋错误信息并向外发送信号通知
|
||
*/
|
||
void slotOnParameterValidated();
|
||
/**
|
||
* @brief 当用户点击Add按钮时,给模块参数和树形数据结构添加新的数组元素项
|
||
* @param pButton Add按钮
|
||
*/
|
||
void slotOnArrayItemButtonClicked(QAbstractButton * pButton);
|
||
/**
|
||
* @brief 当用户点击行删除按钮时,从模块参数和树形数据结构中移去数组元素项
|
||
* @param strDeleteItemID 待删除的参数项ID
|
||
*/
|
||
bool slotOnDeleteItem(const QString& strDeleteItemID);
|
||
/**
|
||
* @brief 当用户点击行隐藏、显示按钮时,从模块参数和树形数据结构中隐藏、显示数组元素项
|
||
* @param strHideShowItemID 待隐藏、显示的参数项ID
|
||
*/
|
||
void slotOnHideShowItem(const QString& strHideShowItemID,bool hide);
|
||
|
||
/**
|
||
* @brief 当用户点击行隐藏、显示按钮时,从模块参数和树形数据结构中隐藏、显示数组元素项
|
||
* @param strHideShowItemID 待隐藏、显示的参数项ID
|
||
*/
|
||
void slotOnHideShowOptionalItem(const QString& strHideShowItemID,bool hide);
|
||
//更新井段参数区的下拉框
|
||
void slotZoneChanged(int changedtoindex);
|
||
public slots:
|
||
/**
|
||
* @brief 设置 MaxEnergy模块层位面的ID。
|
||
*/
|
||
// void slotBuildMaxEnergySurfaceIDs(const QString &layerPickFile);
|
||
|
||
private:
|
||
/**
|
||
* @brief 等待结束校验线程
|
||
*/
|
||
// void StopValidation();
|
||
|
||
public:
|
||
|
||
/**
|
||
* @brief 根据给定的父亲ModelIndex及参数项ID,给出该参数项ID对应的参数项的ModelIndex.
|
||
* @param parentIndex 父亲ModelIndex
|
||
* @param strItemID 参数项ID
|
||
* @return 参数项ID对应的参数项的ModelIndex
|
||
*/
|
||
void EvaluateInputData(const QModelIndex& index);
|
||
|
||
|
||
|
||
signals:
|
||
/**
|
||
* @brief 错误信息改变发送
|
||
* @param[in] pModuleInfo 模块信息
|
||
* @param[in] errorInfo 校验结果
|
||
* @param[in] checkResult 總校驗結果
|
||
* @param[in] eventSource 事件源
|
||
*/
|
||
void signalExclieChanged(const QString& id);
|
||
void signalErrorInfoChanged(pai::workflow::CModuleInformation * pModuleInfo,
|
||
bool checkResult,
|
||
const pai::module::CModuleCheckResult errorInfo,
|
||
ValidateEventSource eventSource);
|
||
void signalDataPropertyChanged(const QModelIndex& dataIndex,const QString& strPropertyName,const QVariant& varPropertyValue);
|
||
/**
|
||
* @brief 发送恢复模块信息
|
||
* @param backModule 恢复的模块信息
|
||
*/
|
||
void signalBackModule(pai::workflow::CModuleInformation *backModule);
|
||
private:
|
||
ParameterProperty *m_rootItem;//树形数据结构根节点,它携带了所有的参数信息并且与界面的树形相对应。
|
||
pai::workflow::CModuleInformation *m_pModuleInfo;
|
||
QUuid m_workflowID;
|
||
public:
|
||
QString m_SelectedCompositeMethod;
|
||
CParameterValidateThread *m_pValidateThread;
|
||
QModelIndex m_currentindex;
|
||
};
|
||
|
||
}
|
||
}
|
||
#endif
|