-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpaintablecanvas.h
56 lines (44 loc) · 1.48 KB
/
paintablecanvas.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
52
53
54
55
56
#ifndef PAINTABLECANVAS_H
#define PAINTABLECANVAS_H
#include <QWidget>
#include <QImage>
#include <QMouseEvent>
#include <QPainter>
/*
Not related to WinDiffusion Canvas; this is just for simple inpainting.
*/
class PaintableCanvas : public QWidget {
Q_OBJECT
public:
explicit PaintableCanvas(QWidget *parent = nullptr);
void loadImage(const QString &imagePath);
void loadImage(const QImage& Img);
void setPaintingEnabled(bool enabled);
void clearStrokes();
QImage getImage() const;
QImage getMask() const;
protected:
void paintEvent(QPaintEvent *event) override;
void mousePressEvent(QMouseEvent *event) override;
void mouseMoveEvent(QMouseEvent *event) override;
void mouseReleaseEvent(QMouseEvent *event) override;
void enterEvent(QEnterEvent *event) override;
void leaveEvent(QEvent *event) override;
void dragEnterEvent(QDragEnterEvent *event) override;
void dropEvent(QDropEvent *event) override;
// Implementation in PaintableCanvas.cpp
void wheelEvent(QWheelEvent *event) override;
private:
void Initialize();
void setCustomCursor();
int brushSize;
QImage canvasImage;
QImage originalImage; // Stores the original full-resolution image
QImage maskImage; // Stores the mask at full resolution
QImage displayedImage; // Stores the scaled version of the image for display
bool paintingEnabled = false;
QPoint lastPoint;
signals:
void OnImageSet();
};
#endif // PAINTABLECANVAS_H