-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMovieRenderer.h
216 lines (175 loc) · 5.49 KB
/
MovieRenderer.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
204
205
206
207
208
209
210
211
212
213
214
215
216
/*
File: MovieRenderer.h
Created on: 11/05/2017
Author: Felix de las Pozas Alvarez
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef VTK_MOVIE_RENDERER_H_
#define VTK_MOVIE_RENDERER_H_
// Project
#include "ScriptExecutor.h"
#include "ResourceLoader.h"
// Qt
#include "ui_MovieRenderer.h"
#include <QMainWindow>
#include <QProcess>
// VTK
#include <vtkSmartPointer.h>
#include <vtkPolyData.h>
#include <vtkRenderer.h>
// C++
#include <memory>
#include <atomic>
class QObject;
class QEvent;
class vtkOrientationMarkerWidget;
/** \class MovieRenderer
* \brief Main application dialog.
*
*/
class MovieRenderer
: public QMainWindow
, private Ui::MovieRenderer
{
Q_OBJECT
public:
/** \brief MovieRenderer class constructor.
*
*/
explicit MovieRenderer();
/** \brief MovieRenderer class virtual destructor.
*
*/
virtual ~MovieRenderer()
{}
protected:
virtual bool eventFilter(QObject *, QEvent *);
virtual void closeEvent(QCloseEvent *event);
private slots:
/** \brief Starts/Stops the script execution.
*
*/
void onRenderPressed();
/** \brief Modifies the UI, enables/disables the frames field for motion blur.
* \param[in] value true to enable the frames field and false to disable it.
*
*/
void onMotionBlurChanged(int value);
/** \brief Modifies the UI, enables/disables the frames field for anti-aliasing.
* \param[in] value true to enable the frames field and false to disable it.
*
*/
void onAntiAliasChanged(int value);
/** \brief Asks the user for an output directory for the frames and the video.
*
*/
void onDirButtonPressed();
/** \brief Asks the user the location of the ffmpeg executable.
*
*/
void onFFMPEGDirButtonPressed();
/** \brief Creates the script executor once the resources have been loaded.
*
*/
void onResourcesLoaded();
/** \brief Saves current frame to disk.
*
*/
void onRenderSignaled();
/** \brief Reloads the resources (to allow resource modification on disk on the fly).
*
*/
void onReloadPressed();
/** \brief Resets the camera position to view all the resources in the renderer.
*
*/
void onCameraResetPressed();
/** \brief Launches the ffmpeg process to create a video.
*
*/
void onScriptFinished();
/** \brief Shows/hides the axis widget.
* \param[in] value true to enable and false to disable the widget.
*
*/
void onAxesValueChanged(int value);
/** \brief Dumps the output of the ffmpeg process to standard output (for debugging).
*
*/
void onDataAvailable();
/** \brief Reports the result of the ffmpeg process.
* \param[in] exitCode process exit code.
* \param[in] exitStatus QProcess exit status code.
*
*/
void onProcessFinished(int exitCode, QProcess::ExitStatus exitStatus);
/** \brief Updates the vtk render window settings with the settings of the UI.
*
*/
void updateRendererSettings();
/** \brief Saves the camera position to the ini file.
*
*/
void saveCameraPosition() const;
private:
/** \brief Runs the script executor and disables part of the UI.
*
*/
void startRender();
/** \brief Stops the script executor and enables part of the UI.
*
*/
void stopRender();
/** \brief Creates the movie using a separate QProcess.
*
*/
void makeMovie();
/** \brief Helper method to disable parts of the UI when rendering.
* \param[in] value true to enable UI and false otherwise.
*
*/
void modifyUI(bool);
/** \brief Helper method to start the script thread.
*
*/
void renderScript();
/** \brief Initializes the vtk render window.
*
*/
void setupVTKView();
/** \brief Helper method to connect the UI signals.
*
*/
void connectSignals();
/** \brief Helper method to show a dialog on error.
* \param[in] title error dialog title.
* \param[in] message error message.
*
*/
void errorDialog(const QString &title, const QString& message);
/** \brief Saves the current settings to a ini file in the same directory as the executable.
*
*/
void saveSettings() const;
/** \brief Restores the application settings from an ini file in the application path.
*
*/
void restoreSettings();
// view, size is 1280x720
vtkSmartPointer<vtkRenderer> m_renderer; /** vtk main renderer. */
vtkSmartPointer<vtkOrientationMarkerWidget> m_axesWidget; /** orientation marker widget. */
std::atomic<unsigned long> m_frameNum; /** current frame number. */
// threads
std::shared_ptr<ResourceLoaderThread> m_loader; /** resource loader thread. */
std::shared_ptr<ScriptExecutor> m_executor; /** script executor thread. */
};
#endif