-
Notifications
You must be signed in to change notification settings - Fork 6
/
mainwindow.h
203 lines (157 loc) · 6.16 KB
/
mainwindow.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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
namespace Ui {
class MainWindow;
}
class QListWidget;
class QListWidgetItem;
class QSpinBox;
class QCheckBox;
class QRadioButton;
class QPushButton;
class QProgressDialog;
#include "QResultImageView/QResultImageView.h"
#include <deque>
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
protected:
void closeEvent(QCloseEvent *event) override;
void keyPressEvent(QKeyEvent *event) override;
private slots:
void init();
void initImageIO();
void onOpenFolder();
void onOpenRecentFolder();
void onExport();
void onFileClicked(QListWidgetItem* item);
void onFileActivated(const QModelIndex& index);
void onFileItemChanged(QListWidgetItem* current, QListWidgetItem* previous);
void onAnnotateStuff(bool toggled);
void onAnnotateThings(bool toggled);
void onPanButtonToggled(bool toggled);
void onAnnotateButtonToggled(bool toggled);
void onBucketFillToggled(bool toggled);
void onEraseAnnotationsButtonToggled(bool toggled);
void onAnnotationClassClicked(QListWidgetItem* item);
void onMarkingRadiusChanged(int i);
void onMarkingsVisible(bool toggled);
void onRightMousePanButtonToggled(bool toggled);
void onRightMouseEraseAnnotationsButtonToggled(bool toggled);
void onRightMouseResetViewButtonToggled(bool toggled);
void onResultsVisible(bool toggled);
void onYardstickVisible(bool toggled);
void onChannelSelectionToggled(bool toggled);
void onAnnotationUpdated();
void saveCurrentThingAnnotations();
void onPostponeMaskUpdate();
void onSaveMask();
void onAddClass();
void onRenameClass();
void onRemoveClass();
void onUndo();
void onRedo();
void onNewMarkingRadius(int newMarkingRadius);
void onAnnotationsVisible(bool visible);
void onHideUnannotatedFilesToggled(bool toggled);
void onRestoreDefaultWindowPositions();
void onAbout();
private:
void createFileList();
void createToolList();
void createImageView();
void openFolder(const QString& dir);
void addRecentFolderMenuItem(const QString& dir);
void saveRecentFolders();
void saveMaskIfDirty();
void saveMask();
void loadFile(QListWidgetItem* item);
void initCurrentImage(QResultImageView::DelayedRedrawToken* delayedRedrawToken = nullptr);
static QString getMaskFilenameSuffix();
static QString getMaskFilename(const QString& baseImageFilename);
static QString getThingAnnotationsPathFilenameSuffix();
static QString getThingAnnotationsPathFilename(const QString& baseImageFilename);
static QString getInferenceResultFilenameSuffix();
static QString getInferenceResultPathFilename(const QString& baseImageFilename);
QListWidgetItem* addNewClass(const QString& className, QColor color);
void loadClassList();
void saveClassList() const;
void resetUndoBuffers();
void updateUndoRedoMenuItemStatus();
void limitUndoOrRedoBufferSize(std::deque<QPixmap>& buffer);
void limitUndoOrRedoBufferSize(std::deque<std::vector<QResultImageView::Result>>& buffer);
void updateBucketFillCheckboxState();
bool conditionallyChangeFirstClass(const QString& oldName, QColor oldColor, const QString& newName, QColor newColor);
static void setClassItemColor(QListWidgetItem* listWidgetItem, QColor color);
bool hasAnnotations(const QListWidgetItem* item) const;
void updateTextColor(QListWidgetItem* item, const QString& baseImageFilename);
bool cleanFileList(QProgressDialog* progress);
struct InferenceResults
{
std::vector<QResultImageView::Result> results;
QString error;
};
InferenceResults readResultsJSON(const QString& filename);
Ui::MainWindow* ui;
QCheckBox* hideUnannotatedFiles = nullptr;
QListWidget* files = nullptr;
QResultImageView* image = nullptr;
struct ClassItem {
QString className;
QColor color;
QListWidgetItem* listWidgetItem = nullptr;
};
QRadioButton* panButton = nullptr;
QRadioButton* annotateButton = nullptr;
QCheckBox* bucketFillCheckbox = nullptr;
QRadioButton* eraseAnnotationsButton = nullptr;
QListWidget* annotationClasses = nullptr;
QListWidgetItem* currentlySelectedAnnotationClassItem = nullptr;
QColor currentAnnotationColor = Qt::transparent;
std::vector<ClassItem> annotationClassItems;
QSpinBox* markingRadius = nullptr;
QCheckBox* markingsVisible = nullptr;
QRadioButton* annotateStuff = nullptr;
QRadioButton* annotateThings = nullptr;
QPushButton* addClassButton = nullptr;
QPushButton* renameClassButton = nullptr;
QPushButton* removeClassButton = nullptr;
QRadioButton* rightMousePanButton = nullptr;
QRadioButton* rightMouseEraseAnnotationsButton = nullptr;
QRadioButton* rightMouseResetViewButton = nullptr;
QCheckBox* resultsVisible = nullptr;
QCheckBox* yardstickVisible = nullptr;
QRadioButton* allImageChannelsButton = nullptr;
QRadioButton* redChannelButton = nullptr;
QRadioButton* greenChannelButton = nullptr;
QRadioButton* blueChannelButton = nullptr;
QRadioButton* alphaChannelButton = nullptr;
QRadioButton* rgbChannelsButton = nullptr;
QString currentWorkingFolder;
QListWidgetItem* currentImageFileItem = nullptr;
QString currentImageFile;
InferenceResults currentResults;
InferenceResults currentThingAnnotations;
std::vector<QResultImageView::Result> currentlyShownPaths;
bool maskDirty = false;
int saveMaskPendingCounter = 0;
QMenu* recentFoldersMenu;
QPixmap currentMask;
std::deque<QPixmap> maskUndoBuffer;
std::deque<QPixmap> maskRedoBuffer;
std::deque<std::vector<QResultImageView::Result>> annotationUndoBuffer;
std::deque<std::vector<QResultImageView::Result>> annotationRedoBuffer;
QWidget* aboutDialog = nullptr;
bool reverseFileOrder = false;
QByteArray defaultGeometry;
QByteArray defaultState;
const QString cleanClassLabel = tr("Clean");
const QString ignoreClassLabel = tr("Ignore");
QImage originalImage;
QImage currentlyShownImage;
};
#endif // MAINWINDOW_H