logplus/Workflow/WFEngine/Component/WorkflowWidget/include/ModuleMonitorGraphicsItem.h
2026-01-16 17:18:41 +08:00

189 lines
4.5 KiB
C++

/**
* @file ModuleMonitorGraphicsItem.h
* @brief 模块监控item
* @date 2015-01-06
*/
#ifndef PAI_FRAME_WORKFLOWWIDGET_MODULEMONITORGRAPHICSITEM_H
#define PAI_FRAME_WORKFLOWWIDGET_MODULEMONITORGRAPHICSITEM_H
#include <QGraphicsItem>
namespace pai
{
namespace workflow
{
class CModuleInformation;
}
namespace graphics2d
{
class MonitorColorEditor;
class PaiModuleStyle;
}
}
namespace pai
{
namespace graphics2d
{
/**
* @class ModuleMonitorGraphicsItem
* @brief 模块监控item
*/
class ModuleMonitorGraphicsItem : public QGraphicsItem
{
public:
/**
* @brief 模块类型
*/
enum
{
Type = UserType + 1030 ///< 模块item类型
};
/**
* @brief 构造函数
* @param[in] pParent 父亲
*/
ModuleMonitorGraphicsItem(QGraphicsItem *pParent = NULL);
/**
* @brief 构造函数
* @param[in] pModule 模块信息
* @param[in] pStyle 模块风格
* @param[in] readOnly 是否只读
* @param[in] pParent 父亲
*/
ModuleMonitorGraphicsItem(pai::workflow::CModuleInformation *pModule,
pai::graphics2d::PaiModuleStyle *pStyle,
bool readOnly = false,
QGraphicsItem *pParent = NULL);
/**
* @brief 析构函数
*/
virtual ~ModuleMonitorGraphicsItem();
/**
* @brief 获取当前item类型
* @return item类型
*/
virtual int type() const;
/**
* @brief 实现该虚函数,返回模块图元的包围矩形
* @return item外围矩形
*/
virtual QRectF boundingRect() const;
/**
* @brief 为监控item添加调色板
* @param[in] pColorEditor 调色板
*/
void AttachColorEditor(MonitorColorEditor *pColorEditor);
/**
* @brief 移除调色板,但是并没有析构调色板对象
*/
void RemoveColorEditor();
/**
* @brief 根据索引更新眼睛图片
* @param[in] color 图片颜色
*/
void UpdatePixmap(const QString& color);
/**
* @brief 是否为当前操作的监控图元
*/
bool IsCurrentMonitor();
/**
* @brief 设置监控的索引
* @param[in] index 索引
*/
void SetIndex(int index);
/**
* @brief 获取监控的索引
* @return 索引
*/
int GetIndex() const;
/**
* @brief 获取模块信息
* @return 模块信息
*/
pai::workflow::CModuleInformation* GetModule() const;
/**
* @breif 获取模块的风格
* @return 风格
*/
pai::graphics2d::PaiModuleStyle* GetStyle() const;
/**
* @brief 模块只读标志
* @return true 只读,反之可以操作
*/
bool IsReadOnly() const;
/**
* @brief 刷新信息
*/
void Refresh();
protected:
/**
* @brief 重写该虚函数,实现鼠标进入覆盖操作
* @param[in] pEvent 鼠标hoverEnter事件
*/
virtual void hoverEnterEvent (QGraphicsSceneHoverEvent *pEvent);
/**
* @brief 重写该虚函数,实现鼠标覆盖离开操作
* @param[in] pEvent 鼠标hoverLeave事件
*/
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *pEvent);
/**
* @brief 重写该虚函数,实现鼠标释放操作
* @param[in] pEvent 鼠标mousePress事件
*/
virtual void mousePressEvent(QGraphicsSceneMouseEvent *pEvent);
/**
* @brief 重写该虚函数,实现鼠标释放操作
* @param[in] pEvent 鼠标mouseRelease事件
*/
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *pEvent);
/**
* @brief 实现该虚函数,绘制模块工具栏
* @param[in] pPainter 画笔
* @param[in] pOption 模块风格参数
* @param[in] pWidget 画布
*/
virtual void paint(QPainter *pPainter, const QStyleOptionGraphicsItem *pOption, QWidget *pWidget = NULL);
private:
/**
* @brief 初始化图片
*/
void InitPixmaps();
private:
QPixmap m_CurrentPixmap; ///< 当前监控绘制的图片
MonitorColorEditor *m_pColorEditor; ///< 调色板
int m_index; ///< 索引
bool m_hovering; ///< hover标志
QMap<QString, QString> m_pixmaps; ///< 所有图片
pai::workflow::CModuleInformation *m_pModuleInfo; ///< 模块信息
pai::graphics2d::PaiModuleStyle *m_pStyle; ///< 模块风格信息
bool m_ReadOnly; ///< 只读
};
}
}
#endif ///< PAI_FRAME_WORKFLOWWIDGET_MODULEMONITORGRAPHICSITEM_H