OpenWalnut  1.5.0dev
WQtGLScreenCapture.h
1 //---------------------------------------------------------------------------
2 //
3 // Project: OpenWalnut ( http://www.openwalnut.org )
4 //
5 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6 // For more information see http://www.openwalnut.org/copying
7 //
8 // This file is part of OpenWalnut.
9 //
10 // OpenWalnut is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // OpenWalnut is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public License
21 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
22 //
23 //---------------------------------------------------------------------------
24 
25 #ifndef WQTGLSCREENCAPTURE_H
26 #define WQTGLSCREENCAPTURE_H
27 
28 #include <limits>
29 
30 #include <boost/signals2.hpp>
31 
32 #include <QWidget>
33 #include <QToolBox>
34 #include <QPushButton>
35 #include <QLabel>
36 #include <QLineEdit>
37 #include <QComboBox>
38 
39 #include <osg/Camera>
40 #include <osg/Image>
41 #include <osg/RenderInfo>
42 
43 #include "core/graphicsEngine/WGEViewer.h"
44 
45 #include "WIconManager.h"
46 
47 class WQtGLDockWidget;
48 
49 /**
50  * This class is a screen recorder adapter in QT. It uses WGEScreenCapture and provides a nice widget around it.
51  */
52 class WQtGLScreenCapture: public QWidget
53 {
54  Q_OBJECT
55 public:
56  /**
57  * Creates screen capture gui for the specified capture callback of a certain view.
58  *
59  * \param parent the parent
60  */
61  explicit WQtGLScreenCapture( WQtGLDockWidget* parent );
62 
63  /**
64  * Destructor. Cleans up.
65  */
66  virtual ~WQtGLScreenCapture();
67 
68  /**
69  * Returns the trigger used for screenshotting.
70  *
71  * \return the action.
72  */
74 
75  /**
76  * Save settings.
77  */
78  virtual void saveSettings();
79 
80  /**
81  * Restore settings
82  */
83  virtual void restoreSettings();
84 
85 protected:
86  /**
87  * Custom event dispatcher. Gets called by QT's Event system every time an event got sent to this widget. This event handler
88  * processes several custom events, like WModuleAssocEvent.
89  *
90  * \note QT Doc says: use event() for custom events.
91  * \param event the event that got transmitted.
92  *
93  * \return true if the event got handled properly.
94  */
95  virtual bool event( QEvent* event );
96 
97 private slots:
98 
99  /**
100  * Initiates taking a screenshot
101  */
102  void screenShot();
103 
104  /**
105  * Slot triggered by m_moveRecButton
106  */
107  void startRec();
108 
109  /**
110  * Slot triggered by m_moveStopButton
111  */
112  void stopRec();
113 
114  /**
115  * Slot triggered by m_configFrameResetButton
116  */
117  void resetFrames();
118 
119  /**
120  * Someone changed the open tab in the toolbox.
121  *
122  * \param index the new index
123  */
124  void toolBoxChanged( int index );
125 
126  /**
127  * Changes resolution of gl widget.
128  *
129  * \param force if true, the resolution is set. If not, it gets restored.
130  */
131  void resolutionChange( bool force );
132 
133 private:
134  /**
135  * My parent.
136  */
138 
139  /**
140  * The actual screen capture instance.
141  */
143 
144  /**
145  * Called by the screencapture callback to notify this widget about recording
146  */
147  void recCallback();
148 
149  /**
150  * The function handles new images. Implement it.
151  *
152  * \param framesLeft how much frames to come
153  * \param totalFrames the total number of frames until now
154  * \param image the image
155  */
156  void handleImage( size_t framesLeft, size_t totalFrames, osg::ref_ptr< osg::Image > image ) const;
157 
158  /**
159  * Recording - callback connection
160  */
161  boost::signals2::connection m_recordConnection;
162 
163  /**
164  * New image incoming - callback connection to handleImage.
165  */
166  boost::signals2::connection m_imageConnection;
167 
168  /**
169  * The toolbox containing all the stuff
170  */
171  QToolBox* m_toolbox;
172 
173  /**
174  * The configuration widget. It contains the common config stuff
175  */
176  QWidget* m_configWidget;
177 
178  /**
179  * The filename for the screenshot
180  */
181  QLineEdit* m_configFileEdit;
182 
183  /**
184  * Shows recorded frames.
185  */
187 
188  /**
189  * Triggers frame counter reset.
190  */
192 
193  /**
194  * Widget containing all the widgets to control movie recording
195  */
197 
198  /**
199  * The trigger which triggers the screenshot.
200  */
201  QPushButton* m_screenshotButton;
202 
203  /**
204  * This action triggers a screenshot.
205  */
207 
208  /**
209  * Shows recorded time in movie-time.
210  */
212 
213  /**
214  * Widget containing all the widgets to control movie recording
215  */
216  QWidget* m_movieWidget;
217 
218  QPushButton* m_movieRecButton; //!< record button
219  QPushButton* m_movieStopButton; //!< stop button
220 
221  /**
222  * Stores the resolution the user wants to have.
223  */
224  QComboBox* m_resolutionCombo;
225 
226  /**
227  * Widget for entering a custom resolution width
228  */
229  QLineEdit* m_customWidth;
230 
231  /**
232  * Widget for entering a custom resolution height
233  */
234  QLineEdit* m_customHeight;
235 };
236 
237 #endif // WQTGLSCREENCAPTURE_H
std::shared_ptr< WGEViewer > SPtr
Convenience typedef.
Definition: WGEViewer.h:76
Dock widget containing only a GLWidget.
This class is a screen recorder adapter in QT.
QLineEdit * m_customHeight
Widget for entering a custom resolution height.
void resetFrames()
Slot triggered by m_configFrameResetButton.
void screenShot()
Initiates taking a screenshot.
virtual ~WQtGLScreenCapture()
Destructor.
boost::signals2::connection m_recordConnection
Recording - callback connection.
QPushButton * m_screenshotButton
The trigger which triggers the screenshot.
QWidget * m_screenshotWidget
Widget containing all the widgets to control movie recording.
QLabel * m_configFrameLabel
Shows recorded frames.
QWidget * m_configWidget
The configuration widget.
QPushButton * m_movieRecButton
record button
boost::signals2::connection m_imageConnection
New image incoming - callback connection to handleImage.
void handleImage(size_t framesLeft, size_t totalFrames, osg::ref_ptr< osg::Image > image) const
The function handles new images.
QPushButton * m_configFrameResetButton
Triggers frame counter reset.
WGEViewer::SPtr m_viewer
The actual screen capture instance.
QToolBox * m_toolbox
The toolbox containing all the stuff.
void toolBoxChanged(int index)
Someone changed the open tab in the toolbox.
virtual void saveSettings()
Save settings.
virtual void restoreSettings()
Restore settings.
QAction * m_screenshotAction
This action triggers a screenshot.
void resolutionChange(bool force)
Changes resolution of gl widget.
void stopRec()
Slot triggered by m_moveStopButton.
void startRec()
Slot triggered by m_moveRecButton.
QPushButton * m_movieStopButton
stop button
QWidget * m_movieWidget
Widget containing all the widgets to control movie recording.
QAction * getScreenshotTrigger() const
Returns the trigger used for screenshotting.
QLabel * m_movieTimeLabel
Shows recorded time in movie-time.
QComboBox * m_resolutionCombo
Stores the resolution the user wants to have.
void recCallback()
Called by the screencapture callback to notify this widget about recording.
WQtGLScreenCapture(WQtGLDockWidget *parent)
Creates screen capture gui for the specified capture callback of a certain view.
QLineEdit * m_customWidth
Widget for entering a custom resolution width.
QLineEdit * m_configFileEdit
The filename for the screenshot.
WQtGLDockWidget * m_glDockWidget
My parent.
virtual bool event(QEvent *event)
Custom event dispatcher.