-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimagewindow.h
145 lines (125 loc) · 3.89 KB
/
imagewindow.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#ifndef IMAGEWINDOW_H
#define IMAGEWINDOW_H
#include <QOpenGLWidget>
#include <QKeySequence>
#include <QPixmap>
#include <ext/random>
#include <QProcess>
class QAction;
class ImageCropping {
public:
ImageCropping();
static ImageCropping fromImage(const QImage &image);
void sourceScaledBy(int powerOf2);
QTransform transform(qreal initialScaling = 1.0);
QString toDisplayString();
QSize image;
qreal scaling;
qreal rotation;
QPointF translation;
};
class ImageWindow : public QWidget {
Q_OBJECT
enum NoiseLevel { NoNoise, SlightNoise, HeavyNoise, ExcessiveNoise };
public:
ImageWindow(QWidget *parent = 0);
~ImageWindow();
ImageCropping getTransform();
void setDisplayScale(qreal factor);
bool setExecutable(const QString &folder = QString());
bool setModelDir(const QString &folder = QString());
void setProcessor(int index);
void setEmulatedSize(QSize size);
QStringList processors();
QSize emulatedSize();
bool isDone();
void stop();
signals:
void exportFile(QString sourceFilename,
QString workingFilename,
ImageCropping transform);
void escape();
void skip();
public slots:
void setExportShortcut(const QKeySequence &shortcut);
void setEscapeShortcut(const QKeySequence &shortcut);
void setSkipShortcut(const QKeySequence &shortcut);
void setDoubleShortcut(const QKeySequence &shortcut);
void setNoiseShortcut(const QKeySequence &shortcut);
void setMultiplyShortcut(const QKeySequence &shortcut);
void setWidthShortcut(const QKeySequence &shortcut);
void setHeightShortcut(const QKeySequence &shortcut);
void setResetZoomShortcut(const QKeySequence &shortcut);
void setResetRotationShortcut(const QKeySequence &shortcut);
void setResetLocationShortcut(const QKeySequence &shortcut);
void setShowRulesShortcut(const QKeySequence &shortcut);
void setSource(const QString &filename);
void setScaledSource(const QString &filename, int powerOf2);
void showMessage(const QString &message);
protected:
void paintEvent(QPaintEvent *ev);
void resizeEvent(QResizeEvent *ev);
void closeEvent(QCloseEvent *event);
void mousePressEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent * event);
private slots:
void actionExport_triggered();
void actionEscape_triggered();
void actionSkip_triggered();
void actionDouble_triggered();
void actionNoise_triggered();
void actionMultiply_triggered();
void actionWidth_triggered();
void actionHeight_triggered();
void actionResetZoom_triggered();
void actionResetRotation_triggered();
void actionResetLocation_triggered();
void actionShowRules_triggered();
void process_finished(int exitCode);
private:
void setupBackground();
void setupActions();
void cleanupActions();
void calculateDrawPoint();
void updateFields();
void removeWorkingCopy();
bool done;
QSize emulatedSize_;
qreal displayScale;
QImage background;
QImage source;
QString executable;
QString modelFolder;
int processor;
QString sourceFilename;
QString workingFilename;
QString doubledFilename;
NoiseLevel noise;
bool multiplying;
bool rulesShown;
ImageCropping transform;
int glWidth;
int glHeight;
QPointF drawPoint;
QPointF mouseLast;
ImageCropping mouseTransform;
Qt::MouseButton mouseCause;
QString fileField;
QString noiseField;
QString message;
qreal opacity;
QAction *actionExport;
QAction *actionEscape;
QAction *actionSkip;
QAction *actionDouble;
QAction *actionNoise;
QAction *actionMultiply;
QAction *actionWidth;
QAction *actionHeight;
QAction *actionResetZoom;
QAction *actionResetRotation;
QAction *actionResetLocation;
QAction *actionShowRules;
QProcess *doubler;
};
#endif // IMAGEWINDOW_H