HMI/include/graphicsItem/itemControlHandle.h

62 lines
1.2 KiB
C
Raw Normal View History

2026-07-03 11:29:21 +08:00
#ifndef ITEMCONTROLHANDLE_H
#define ITEMCONTROLHANDLE_H
2026-07-06 18:17:10 +08:00
#include <QtWidgets/QGraphicsRectItem>
2026-07-03 11:29:21 +08:00
enum HandleType
{
2026-07-06 18:17:10 +08:00
T_resize=50, //调整大小
2026-07-03 11:29:21 +08:00
T_rotate, //旋转
T_editShape //编辑形状
};
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
};
class ItemControlHandle : public QObject,public QGraphicsRectItem
{
Q_OBJECT
public:
ItemControlHandle(QGraphicsItem *parent);
virtual ~ItemControlHandle();
public:
void setType(HandleType ht) { m_type = ht; }
HandleType getType() { return m_type; }
void setTag(int ht) { m_tag = ht; }
int getTag() { return m_tag; }
int getSize();
void move(double, double);
protected:
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent*) override;
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent*) override;
virtual void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*) override;
private:
HandleType m_type;
int m_tag;
};
#endif