103 lines
2.9 KiB
C++
103 lines
2.9 KiB
C++
/**
|
|
* @file ModulePortGraphicsItem.h
|
|
* @brief 模块端口的绘制和事件处理类
|
|
* @date 2011-09-19
|
|
*/
|
|
#ifndef PAI_FRAME_WORKFLOWWIDGET_MODULEPORTGRAPHICSITEM_H
|
|
#define PAI_FRAME_WORKFLOWWIDGET_MODULEPORTGRAPHICSITEM_H
|
|
|
|
#include <QSizeF>
|
|
#include <QColor>
|
|
#include <QPainterPath>
|
|
|
|
#include "PaiModuleStyle.h"
|
|
|
|
class QStyleOptionGraphicsItem;
|
|
class QWidget;
|
|
|
|
namespace pai
|
|
{
|
|
|
|
namespace graphics2d
|
|
{
|
|
/**
|
|
* @class ModulePortGraphicsItem
|
|
* @brief 模块端口
|
|
*/
|
|
class ModulePortGraphicsItem
|
|
{
|
|
friend class ModuleGraphicsItem;
|
|
public:
|
|
/**
|
|
* @brief 构造函数
|
|
* @param[in] pStyle 模块风格信息
|
|
* @param[in] center 端口中心点位置
|
|
* @param[in] radius 拐角像素
|
|
* @param[in] portDirection 端口方向
|
|
*/
|
|
ModulePortGraphicsItem(pai::graphics2d::PaiModuleStyle *pStyle,
|
|
const QPointF& center,
|
|
qreal radius,
|
|
PortDirection portDirection);
|
|
|
|
/**
|
|
* @brief 析构函数
|
|
*/
|
|
virtual ~ModulePortGraphicsItem();
|
|
|
|
/**
|
|
* @brief 设置模块端口的选中状态
|
|
* @param[in] selected true 选中
|
|
* false 取消选中
|
|
*/
|
|
void SetPortSelected(bool selected);
|
|
|
|
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 鼠标mouseRelease事件
|
|
*/
|
|
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *pEvent);
|
|
|
|
/**
|
|
* @brief 实现该虚函数,获取模块图元的包围矩形
|
|
* @return 模块的包围矩形区域
|
|
*/
|
|
virtual QRectF boundingRect() const;
|
|
|
|
/**
|
|
* @brief 实现该虚函数,绘制模块图元
|
|
* @param[in] pPainter 画笔
|
|
* @param[in] pOption 模块风格参数
|
|
* @param[in] pWidget 画布
|
|
*/
|
|
virtual void paint(QPainter *pPainter, const QStyleOptionGraphicsItem *pOption, QWidget *pWidget = NULL);
|
|
|
|
private:
|
|
pai::graphics2d::PaiModuleStyle *m_pStyle; ///< 模块的绘图信息
|
|
QPointF m_center; ///< 端口中心的坐标
|
|
qreal m_diameter; ///< 拐角大小
|
|
bool m_selected; ///< 选中状态
|
|
bool m_OnHovering; ///< hover状态
|
|
bool m_light; ///< 高亮状态
|
|
PortDirection m_PortDirection; ///< 端口方向
|
|
QPainterPath m_path; ///< 端口外形
|
|
};
|
|
|
|
}
|
|
}
|
|
|
|
#endif ///< PAI_FRAME_WORKFLOWWIDGET_MODULEPORTGRAPHICSITEM_H
|