-
Notifications
You must be signed in to change notification settings - Fork 1
/
rsview.h
88 lines (69 loc) · 2.14 KB
/
rsview.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#pragma once
// Qt
#include <QWidget>
#include <QImage>
#include <QSharedPointer>
#include <QPaintEvent>
#include <QPainterPath>
class SnapAssistant;
class AccentPainter;
class RegionContext;
class Selector;
class UserSelection;
// UI control enabling region selection on a given image
class RsView : public QWidget
{
Q_OBJECT
public:
enum ShadeMode {
Enabled,
EnabledWhenSelected,
Disabled
};
RsView(QWidget *parent);
void setImage(const QImage& image);
void setSelectionAccentPainter(const QSharedPointer<AccentPainter>& accentPainter);
void setSelectionRenderer(const QSharedPointer<Selector>& selectionRenderer);
void setShadeMode(ShadeMode shadeMode);
void setCustomSelectionDrawings(const QList<QPainterPath>& drawings);
const UserSelection* userSelection() const {
return _userSelection;
}
QRect preferredSelection() const {
return _preferredSelection;
}
QPainterPath selectionDrawing() const {
return _selectionDrawing;
}
void clearSelection();
QPixmap renderToPixmap();
signals:
void signalMouseMove(const QPoint& point);
void signalSelectionChanged();
void signalSelectionCancelled();
void signalSelectionFinished();
protected:
bool eventFilter(QObject *obj, QEvent *ev);
void paintEvent(QPaintEvent *event);
void mousePressEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
bool processingKeyPressEvents(QKeyEvent* keyEvent);
bool processingKeyReleaseEvents(QKeyEvent* keyEvent);
private slots:
void slotUserSelectionChanged();
private:
QImage _image;
UserSelection* _userSelection;
ShadeMode _shadeMode;
QRect _preferredSelection;
bool _addMargins;
QPainterPath _customDrawings;
QPainterPath _cinemaDrawing;
QPainterPath _selectionDrawing;
QSharedPointer<Selector> _selector;
QSharedPointer<Selector> _cinemaSelector;
QSharedPointer<AccentPainter> _selectionAccentPainter;
QSharedPointer<AccentPainter> _customDrawingsAccentPainter;
QSharedPointer<AccentPainter> _cinemaAccentPainter;
};