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.
55 lines
1.6 KiB
C++
55 lines
1.6 KiB
C++
#pragma once
|
|
|
|
#include <QObject>
|
|
#include <QGraphicsRectItem>
|
|
#include <QGraphicsSceneMouseEvent>
|
|
#include <QBrush>
|
|
#include <QPainter>
|
|
#include <vector>
|
|
#include "global.h"
|
|
|
|
class MyQGraphicsRectItem : public QObject, public QGraphicsRectItem
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
MyQGraphicsRectItem(qreal x, qreal y, qreal width, qreal height, QGraphicsItem *parent = nullptr)
|
|
: QGraphicsRectItem(x, y, width, height, parent) {
|
|
}
|
|
bool Base() const { return m_isBase; }
|
|
void Base(bool val) { m_isBase = val; }
|
|
bool Mark() const { return m_isMark; }
|
|
void Mark(bool val) { m_isMark = val; }
|
|
double xCoord() const { return m_xCoord; }
|
|
void xCoord(double val) { m_xCoord = val; }
|
|
double yCoord() const { return m_yCoord; }
|
|
void yCoord(double val) { m_yCoord = val; }
|
|
bool Select() const { return m_isSelect; }
|
|
void Select(bool val) { m_isSelect = val; }
|
|
bool NeedSelect() const { return m_isNeedSelect; }
|
|
void NeedSelect(bool val) { m_isNeedSelect = val; }
|
|
|
|
int AreaIdX() { return m_areaIdX; }
|
|
void AreaIdX(int val) { m_areaIdX = val; }
|
|
int AreaIdY() { return m_areaIdY; }
|
|
void AreaIdY(int val) { m_areaIdY = val; }
|
|
protected:
|
|
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
|
|
//virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr) override;
|
|
signals:
|
|
void signal_select(double xCoord, double yCoord);
|
|
private:
|
|
bool m_isNeedSelect = true;
|
|
private:
|
|
bool m_isBase;
|
|
bool m_isMark;
|
|
bool m_isSelect;
|
|
double m_xCoord;
|
|
double m_yCoord;
|
|
|
|
int m_areaIdX;
|
|
int m_areaIdY;
|
|
|
|
public:
|
|
std::vector<MarkChar> m_markChar;
|
|
};
|