DiagramDesigner/diagramCavas/include/graphicsItem/itemControlHandle.h

95 lines
2.0 KiB
C
Raw Normal View History

2024-12-03 20:07:25 +08:00
#ifndef ITEMCONTROLHANDLE_H
#define ITEMCONTROLHANDLE_H
#include <QGraphicsRectItem>
enum HandleType
{
2024-12-07 17:24:36 +08:00
T_none = 0,
2024-12-03 20:07:25 +08:00
T_resize, //调整大小
T_rotate, //旋转
T_editShape, //编辑形状
T_text, //文本
2024-12-03 20:07:25 +08:00
T_lineIn, //入线口
2024-12-07 17:24:36 +08:00
T_lineOut, //出线口
T_lineInOut //双端线
2024-12-03 20:07:25 +08:00
};
enum HandleTag
{
H_none = 0,
H_leftTop,
H_top,
H_rightTop,
H_right,
H_rightBottom,
H_bottom,
H_leftBottom,
H_left, //8
H_rotate_leftTop,
H_rotate_rightTop,
H_rotate_rightBottom,
H_rotate_leftBottom, //12
H_edit,
H_textCaption = 40, //标题文本
2025-02-06 16:36:50 +08:00
H_textCurrent, //电流
h_textVoltage, //电压
2024-12-03 20:07:25 +08:00
H_connect = 50 //连接操作点从50开始前面预留
};
2024-12-07 17:24:36 +08:00
enum PortPos
{
P_top = 0,
P_down,
P_left,
P_right
};
const int HNDLE_SIZE = 8;
2024-12-03 20:07:25 +08:00
class GraphicsBaseItem;
class ItemControlHandle : public QObject,public QGraphicsItem
2024-12-03 20:07:25 +08:00
{
Q_OBJECT
2025-02-06 16:36:50 +08:00
Q_INTERFACES(QGraphicsItem)
2024-12-03 20:07:25 +08:00
public:
ItemControlHandle(QGraphicsItem *parent);
virtual ~ItemControlHandle();
public:
virtual int getSize();
virtual void move(double, double);
2025-02-06 16:36:50 +08:00
virtual void setText(QString);
virtual QString getText() const;
2024-12-03 20:07:25 +08:00
void setType(HandleType ht) { m_type = ht; }
HandleType getType() { return m_type; }
void setTag(int ht) { m_tag = ht; }
int getTag() { return m_tag; }
2024-12-07 17:24:36 +08:00
void setEnable(bool b){m_enable = b;}
bool enable(){return m_enable;}
void setIfShow(bool b){m_ifShow = b;}
bool ifShow(){return m_ifShow;}
GraphicsBaseItem* getParentPtr() const {return _parent;}
void setParent(GraphicsBaseItem* p) {_parent = p;}
2024-12-03 20:07:25 +08:00
protected:
2025-02-06 16:36:50 +08:00
2024-12-03 20:07:25 +08:00
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent*) override;
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent*) override;
virtual void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*) override;
2024-12-07 17:24:36 +08:00
protected:
2024-12-03 20:07:25 +08:00
HandleType m_type;
int m_tag;
2024-12-07 17:24:36 +08:00
bool m_enable;
bool m_ifShow;
GraphicsBaseItem* _parent;
2024-12-03 20:07:25 +08:00
};
#endif