iVS3D v2.0.0
Loading...
Searching...
No Matches
algorithmcontroller.h
1#ifndef ALGORITHMCONTROLLER_H
2#define ALGORITHMCONTROLLER_H
3
4#include <QObject>
5#include <QtConcurrent/QtConcurrent>
6#include <QFutureWatcher>
7#include <QTimer>
8#include <QElapsedTimer>
9
10#include "DataManager.h"
11#include "algorithmexecutor.h"
12
13#include "view/progressdialog.h"
14#include "view/samplingwidget.h"
15
16#include "plugin/algorithmmanager.h"
17#include "plugin/transformmanager.h"
18
19#define NO_IMAGE -1
20#define NO_TRANSFORM -1
21
22// wait the specified amount of milliseconds before displaying the progress dialog when running an algorithm.
23// This is done to avoid popup and immediate closing of the dialog on very fast algorithms such as NthFrame.
24// If the algorithm is faster than the PROGRESS_DIALOG_DELAY_MS, then the dialog is not shown at all.
25#define PROGRESS_DIALOG_DELAY_MS 500
26
39class AlgorithmController: public QObject
40{
41 Q_OBJECT
42public:
49 explicit AlgorithmController(DataManager* dataManager, SamplingWidget* samplingWidget);
51
52public slots:
58 void slot_selectAlgorithm(int idx);
64 void slot_selectTransform(int idx);
82 void slot_algorithmFinished(int idx);
88
89signals:
95 void sig_hasStatusMessage(QString message);
101
102
103 void sig_algorithmFinished(int index);
104
105 void sig_keyframesChangedByPlugin(QString name);
106
107public slots:
108 void slot_updateKeyframes(QString pluginName, std::vector<uint> keyframes);
109 void slot_updateBuffer(QString pluginName, QMap<QString, QVariant> buffer);
110
111private slots:
112 void slot_previewStateChanged(bool enabled);
113
114
115private:
116 enum PluginType{
117 Transform,
118 Algorithm
119 };
120 DataManager* m_dataManager;
121 SamplingWidget *m_samplingWidget;
122 AlgorithmExecutor* m_algExec;
123 ProgressDialog* m_algorithmProgressDialog;
124
125 // used to compute transformation in separate thread using QtConcurrent
126 QFutureWatcher<std::vector<cv::Mat*>> m_fWatcher; // QFutureWatcher waiting for transformation to finish
127 // <image, image_id, transform_idx>
128 std::tuple<cv::Mat*,int, int> m_future; // image currently in transformation
129 std::tuple<cv::Mat*,int, int> m_fQueue; // Queue for next transformation to perform
130 void startNextTransform(); // starts transformation of m_fQueue
131
132 // selected plugin
133 int m_pluginIdx;
134 PluginType m_pluginType;
135
136 // plugin runtime
137 QElapsedTimer m_timer;
138
139 bool m_processRunning = false;
140 bool m_progressDialogActivated = false;
141};
142#endif // ALGORITHMCONTROLLER_H
The AlgorithmController class is responsible for controlling the user input regarding algorithm selec...
Definition algorithmcontroller.h:40
void sig_hasStatusMessage(QString message)
[signal] sig_hasStatusMessage() is emitted when the status message is updated.
void slot_selectAlgorithm(int idx)
Slot which is called, when the selected Algorithm is changed to a IAlgorithm. The slot will show the ...
Definition algorithmcontroller.cpp:37
void slot_selectTransform(int idx)
Slot which is called, when the selected Algorithm is changed to a Transform algortihm....
Definition algorithmcontroller.cpp:55
void sig_stopPlay()
[signal] sig_stopPlay() is emitted when an algorithm is started to stop the VideoPlayer.
void slot_startGenerateSettings()
Slot which is called, when 'Generate settings' is clicked. The slot will start the algorithm by calli...
Definition algorithmcontroller.cpp:112
void slot_startAlgorithm()
Slot which is called, when 'Sample images' is clicked. The slot will start the algorithm by calling t...
Definition algorithmcontroller.cpp:70
void slot_showProgessDialog()
Slot which is called after a sampling process of settings generation process is started....
Definition algorithmcontroller.cpp:103
void slot_algorithmFinished(int idx)
Slot which is called, when the algorithm finished. This will close the ProgressDialog.
Definition algorithmcontroller.cpp:193
void slot_algorithmAborted()
Slot which is called, when the 'Abort' on the ProgressDialog is clicked. This will close the Progress...
Definition algorithmcontroller.cpp:147
The AlgorithmExecutor class is used to start the execution of a plugin(algorithm) and to provide sign...
Definition algorithmexecutor.h:36
The DataManager class is a Facade for the data holding classes in the model. It delegates most of it'...
Definition DataManager.h:29
The ProgressDialog class is the ui dialog holding the progress bar and abort/cancel button.
Definition progressdialog.h:22
The SamplingWidget class is a graphical user interface to select and edit sampling algorithms and tra...
Definition samplingwidget.h:37