-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathROI.h
50 lines (46 loc) · 1.09 KB
/
ROI.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#pragma once
#include<QGraphicsItem>
#include<QPoint>
#include<QGraphicsSceneMouseEvent>
#include<QPainter>
#include<QPaintEvent>
#include<qDebug>
class ROI :
public QGraphicsItem
{
public:
explicit ROI(QGraphicsItem *parent = Q_NULLPTR);
//需要初始化画布的大小
explicit ROI(qreal width, qreal height,
QGraphicsItem *parent = Q_NULLPTR);
~ROI();
//设置自定义类型枚举
enum {Type=UserType};
int type() const
{ return Type; }
//重载边界
QRectF boundingRect() const;
//根据ui的按钮控制是否绘图
void setROI(bool checkBoxROI);
//提供roi的坐标信息
double getX();
double getY();
double getWidth();
double getHeight();
private:
qreal boundingW=2000;
qreal boundingH=2000;
QRectF ROIRect;
int brushSize = 5;
//绘图过程控制变量
bool checkBoxROI = false;
bool drawing = false;
bool lastDraw = false;
protected:
//重载绘图与鼠标消息
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget);
void mousePressEvent(QGraphicsSceneMouseEvent *event);
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
};