You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
997 B
C
42 lines
997 B
C
3 months ago
|
#pragma once
|
||
|
|
||
|
#include <QObject>
|
||
|
#include <QGraphicsRectItem>
|
||
|
#include <QGraphicsSceneMouseEvent>
|
||
|
#include <QBrush>
|
||
|
#include "global.h"
|
||
|
|
||
|
class MyDieRectItem : public QObject, public QGraphicsRectItem
|
||
|
{
|
||
|
Q_OBJECT
|
||
|
public:
|
||
|
typedef enum DrawTypeEnum {
|
||
|
NONE,
|
||
|
LINE,
|
||
|
RECT,
|
||
|
CIRCLE,
|
||
|
TEXT
|
||
|
}DrawTypeEnum;
|
||
|
|
||
|
public:
|
||
|
MyDieRectItem(qreal x, qreal y, qreal width, qreal height, QGraphicsItem *parent = nullptr)
|
||
|
: QGraphicsRectItem(x, y, width, height, parent) {
|
||
|
}
|
||
|
MyDieRectItem(QObject *parent);
|
||
|
~MyDieRectItem();
|
||
|
QPointF StartPos() const { return m_startPos; }
|
||
|
void StartPos(QPointF val) { m_startPos = val; }
|
||
|
DrawTypeEnum DrawType() const { return m_drawType; }
|
||
|
void DrawType(DrawTypeEnum val) { m_drawType = val; }
|
||
|
|
||
|
protected:
|
||
|
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
|
||
|
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
|
||
|
|
||
|
signals:
|
||
|
void signal_mouse(QPointF p1, QPointF p2);
|
||
|
private:
|
||
|
QPointF m_startPos;
|
||
|
DrawTypeEnum m_drawType;
|
||
|
};
|