-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathtvsegwindow.h
187 lines (138 loc) · 5.48 KB
/
tvsegwindow.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
#ifndef TVSEG_UI_TVSEGWINDOW_H
#define TVSEG_UI_TVSEGWINDOW_H
#include "tvseg/segmentation.h"
#include "tvseg/settings/backend.h"
#include "tvseg/settings/serializer.h"
#include "tvseg/settings/settings.h"
#include "tvseg/settings/entrybase.h"
#include "tvseg/settingsdef/inputsettings.h"
#include "tvseg/settingsdef/outputsettings.h"
#include "tvseg/settingsdef/segmentationsettings.h"
#include "tvseg/scribbles.h"
#include "uisettings.h"
#include "settingseditor.h"
#include "consoledockwidget.h"
#include "feedbackdockwidget.h"
#include "feedbackwidget.h"
#include "algorithmwidget.h"
#include <QMainWindow>
namespace tvseg_ui {
namespace Ui {
class TVSegWindow;
}
class TVSegWindow : public QMainWindow
{
Q_OBJECT
Q_PROPERTY(bool algorithmRunning READ algorithmRunning WRITE setAlgorithmRunning NOTIFY algorithmRunningChanged)
Q_PROPERTY(bool cancelRequested READ cancelRequested WRITE setCancelRequested NOTIFY cancelRequestedChanged)
public:
class WindowSettings : public tvseg::settings::Settings
{
public:
typedef boost::shared_ptr<WindowSettings> Ptr;
typedef boost::shared_ptr<const WindowSettings> ConstPtr;
typedef tvseg::settings::ByteArrayEntry ByteArray;
typedef tvseg::settings::byte_array_t byte_array_t;
WindowSettings(tvseg::settings::BackendPtr backend) :
tvseg::settings::Settings(backend, "main_window"),
geometry_(addEntry("geometry", ByteArray::make())),
windowState_(addEntry("windowState", ByteArray::make()))
{}
const byte_array_t & geometry() const { return geometry_->get(); }
void setGeometry(const byte_array_t &value) { geometry_->set(value); }
const byte_array_t & windowState() const { return windowState_->get(); }
void setWindowState(const byte_array_t &value) { windowState_->set(value); }
private:
ByteArray::Ptr geometry_;
ByteArray::Ptr windowState_;
};
public:
explicit TVSegWindow(QWidget *parent = 0, std::string settingsFilename = "tvseg.ini");
~TVSegWindow();
// void setSettings(tvseg::settings::BackendPtr value, std::string filename = "tvseg.ini");
void initFromSettings();
/// Add a message to the console, using a queued connection.
void addConsoleMessageAsync(uint level, const std::string &msg);
bool algorithmRunning();
bool cancelRequested();
signals:
void algorithmRunningChanged(bool value);
void cancelRequestedChanged(bool value);
public slots:
void displayKMeans();
void displayLabels();
void setAlgorithmRunning(bool value);
void setCancelRequested(bool value = true);
void algorithmStarted();
void algorithmStopped();
void settingsValueChanged(QtProperty* property, QVariant value);
void runAllAlgorithms();
void saveResult();
void computeMetrics();
private slots: // private helper slots
void invokeNextAlgorithm();
void setPreset(QString name);
private slots:
void on_saveSettingsButton_clicked();
void on_loadImageButton_clicked();
void on_displayLabelsButton_clicked();
void on_actionQuit_triggered();
void on_computeKMeansButton_clicked();
void on_pickImageButton_clicked();
void on_showColorButton_clicked();
void on_showDepthButton_clicked();
void on_showGroundTruthButton_clicked();
void on_mainTabWidget_currentChanged(int index);
void on_saveScribblesButton_clicked();
void on_saveLabelMappingButton_clicked();
protected: // inherited
void closeEvent(QCloseEvent *event);
private: // private types
typedef QQueue<boost::function<void ()> > algorithm_queue_t;
private: // private helpers
void updateGUIFromSettings();
void updateSettingsEditors();
void windowStateToSettings();
void windowStateFromSettings();
FeedbackWidget* getFeedbackWidget();
void addPresets();
void invokeAlgorithmsSequentially(algorithm_queue_t queue);
tvseg::Scribbles getScribblesFromDisplayWidget();
void setScribblesToDisplayWidget(const tvseg::Scribbles &scribbles);
void setAndSaveScribbles();
void maybeLoadScribbles();
private: // private member accessors
tvseg::InputSettings::Ptr inputSettings();
tvseg::InputSettings::ConstPtr inputSettings() const;
tvseg::OutputSettings::Ptr outputSettings();
tvseg::OutputSettings::ConstPtr outputSettings() const;
UiSettings::Ptr uiSettings();
UiSettings::ConstPtr uiSettings() const;
tvseg::SegmentationSettings::Ptr segmentationSettings();
tvseg::SegmentationSettings::ConstPtr segmentationSettings() const;
WindowSettings::Ptr windowSettings();
WindowSettings::ConstPtr windowSettings() const;
tvseg::SegmentationPtr seg();
tvseg::SegmentationConstPtr seg() const;
private: // members
Ui::TVSegWindow *ui_;
std::string settingsFilename_;
tvseg::settings::BackendPtr settingsBackend_;
tvseg::settings::SerializerPtr settingsSerializer_;
UiSettings::Ptr uiSettings_;
tvseg::InputSettings::Ptr inputSettings_;
tvseg::OutputSettings::Ptr outputSettings_;
tvseg::SegmentationSettings::Ptr segmentationSettings_;
WindowSettings::Ptr windowSettings_;
tvseg::SegmentationPtr segmentation_;
ConsoleDockWidget *consoleDock_;
FeedbackDockWidget *feedbackDock_;
SettingsEditor *mainSettingsEditor_;
AlgorithmWidget *solverWidget_;
QStateMachine *stateMachine_;
bool algorithmRunning_;
bool cancelRequested_;
algorithm_queue_t algorithmQueue_;
};
} // namespace tvseg_ui
#endif // TVSEG_UI_TVSEGWINDOW_H