-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcustomgraphicsview.h
51 lines (38 loc) · 1.14 KB
/
customgraphicsview.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
50
51
#ifndef CUSTOMGRAPHICSVIEW_H
#define CUSTOMGRAPHICSVIEW_H
#include <QGraphicsView>
#include <QGraphicsScene>
#include <QImage>
#include <vector>
class CustomGraphicsView : public QGraphicsView
{
Q_OBJECT
public:
CustomGraphicsView(QWidget* parent = nullptr);
void loadImage(QImage& image);
void drawValidityRect(int x, int y, int w, int h, bool t);
bool getEnableLine() const;
void setEnableLine(bool value);
int LineSampler(int x0, int y0, int x1, int y1);
void DrawMaxLine(int x0, int y0, int x1, int y1);
public slots:
void mousePressEvent(QMouseEvent* e);
void mouseReleaseEvent(QMouseEvent* e);
void mouseMoveEvent(QMouseEvent* e);
void wheelEvent(QWheelEvent* event);
signals:
void RIP(int);
private:
void LineSampler();
std::vector<int> bhm_line(int x1, int y1, int x2, int y2);
QGraphicsScene scene;
QPointF begin;
QPointF end;
QGraphicsLineItem* line = nullptr;
QGraphicsPixmapItem* img = nullptr;
int originX;
int originY;
bool pan;
bool enableLine = false;
};
#endif // CUSTOMGRAPHICSVIEW_H