logplus/Workflow/WFEngine/Component/WorkflowWidget/include/ModuleMonitorGraphicsItem.h

189 lines
4.5 KiB
C
Raw Normal View History

2026-01-16 17:18:41 +08:00
/**
* @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