OpenWalnut  1.5.0dev
WQtGLDockWidget.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 WQTGLDOCKWIDGET_H
26 #define WQTGLDOCKWIDGET_H
27 
28 #include <QDockWidget>
29 #include <QVBoxLayout>
30 #include <QHBoxLayout>
31 #include <QToolButton>
32 #include <QLabel>
33 #include <QResizeEvent>
34 #include <QWidgetAction>
35 
36 #include "core/graphicsEngine/WGECamera.h"
37 
38 #include "guiElements/WScaleLabel.h"
39 #include "guiElements/WQtDockWidget.h"
40 
41 #include "WQtGLWidget.h"
42 
43 /**
44  * Dock widget containing only a GLWidget.
45  */
47 {
48  Q_OBJECT
49 public:
50  /**
51  * default constructor
52  *
53  * \param viewTitle Title will be used as view title
54  * \param dockTitle The title of the dock widget.
55  * \param parent The widget that manages this widget
56  * \param projectionMode The projection mode used in the GL widget.
57  * \param shareWidget this widget will share OpenGL display lists and texture objects with shareWidget
58  */
59  WQtGLDockWidget( QString viewTitle, QString dockTitle, QWidget* parent, WGECamera::ProjectionMode projectionMode = WGECamera::ORTHOGRAPHIC,
60  const QWidget* shareWidget = 0 );
61 
62  /**
63  * destructor.
64  */
65  virtual ~WQtGLDockWidget();
66 
67  /**
68  * Gets the contained GL widget instance.
69  *
70  * \return pointer to GL widget
71  */
72  WQtGLWidget* getGLWidget() const;
73 
74  /**
75  * Adds a screen capture dock using this view's screen capture callback.
76  *
77  * \return the capture dock instance.
78  */
80 
81  /**
82  * Forces the GL widget to have the desired size. This is mainly useful for screenshots and similar.
83  *
84  * \param w width
85  * \param h height
86  */
87  void forceGLWidgetSize( size_t w, size_t h );
88 
89  /**
90  * Restores the GL widget size if it was fixed with forceMainGLWidgetSize() previously.
91  */
92  void restoreGLWidgetSize();
93 
94  /**
95  * Return the title of the view/dock.
96  *
97  * \return the title text
98  */
99  const QString& getDockTitle() const;
100 
101  /**
102  * Save settings.
103  */
104  virtual void saveSettings();
105 
106  /**
107  * Restore settings
108  */
109  virtual void restoreSettings();
110 
111  /**
112  * Allow turning the automatic save and restore of viewer-settings.
113  *
114  * \param enable true to enable
115  */
116  void setSaveViewerSettings( bool enable = true );
117 
118  /**
119  * Check whether the automatic saving of \ref WGEViewer properties is enabled.
120  *
121  * \return true if enabled.
122  */
123  bool getSaveViewerSettings() const;
124 
125  /**
126  * Get the menu used for camera presets
127  *
128  * \return the menu.
129  */
130  QMenu* getCameraPresetMenu() const;
131 
132  /**
133  * Update camera button. Call this when you modify the camera preset menu.
134  */
136 public slots:
137  /**
138  * Open screen capture config options
139  */
141 
142 protected:
143  /**
144  * Layout of this widget. Use this to extend the dock width other widgets (i.e. PropWidgets).
145  */
146  QVBoxLayout* m_layout;
147 
148  /**
149  * The panel widget using m_layout.
150  */
151  QWidget* m_panel;
152 
153  /**
154  * Called whenever a close event is received.
155  *
156  * \param event the event.
157  */
158  virtual void closeEvent( QCloseEvent *event );
159 
160  /**
161  * Called whenever the widget gets opened
162  *
163  * \param event the event
164  */
165  virtual void showEvent( QShowEvent* event );
166 
167 private slots:
168  /**
169  * If the dock widget changes its visibility.
170  *
171  * \param visible if true, the dock is visible
172  */
173  void handleVisibilityChange( bool visible );
174 
175 private:
176  /**
177  * My GL widget.
178  */
180 
181  /**
182  * The view name and dock title.
183  */
184  QString m_dockTitle;
185 
186  /**
187  * Manager for screen capturing of this view
188  */
190 
191  /**
192  * If true, the saveSettings method also saves the WGEViewer properties.
193  */
195 
196  /**
197  * Camera presets.
198  */
199  QToolButton* m_presetBtn;
200 };
201 
202 #endif // WQTGLDOCKWIDGET_H
ProjectionMode
List of possible camera modes.
Definition: WGECamera.h:44
Advanced QDockWidget.
Definition: WQtDockWidget.h:50
Dock widget containing only a GLWidget.
WQtGLWidget * getGLWidget() const
Gets the contained GL widget instance.
WQtGLWidget * m_glWidget
My GL widget.
virtual void saveSettings()
Save settings.
QToolButton * m_presetBtn
Camera presets.
const QString & getDockTitle() const
Return the title of the view/dock.
QWidget * m_panel
The panel widget using m_layout.
QVBoxLayout * m_layout
Layout of this widget.
bool getSaveViewerSettings() const
Check whether the automatic saving of WGEViewer properties is enabled.
WQtGLDockWidget(QString viewTitle, QString dockTitle, QWidget *parent, WGECamera::ProjectionMode projectionMode=WGECamera::ORTHOGRAPHIC, const QWidget *shareWidget=0)
default constructor
WQtGLScreenCapture * getScreenCapture()
Adds a screen capture dock using this view's screen capture callback.
void handleVisibilityChange(bool visible)
If the dock widget changes its visibility.
void setSaveViewerSettings(bool enable=true)
Allow turning the automatic save and restore of viewer-settings.
bool m_saveViewerSettings
If true, the saveSettings method also saves the WGEViewer properties.
virtual void restoreSettings()
Restore settings.
virtual ~WQtGLDockWidget()
destructor.
void openScreenCaptureConfig()
Open screen capture config options.
void updateCameraPresetButton()
Update camera button.
WQtGLScreenCapture * m_screenCapture
Manager for screen capturing of this view.
virtual void closeEvent(QCloseEvent *event)
Called whenever a close event is received.
QString m_dockTitle
The view name and dock title.
void forceGLWidgetSize(size_t w, size_t h)
Forces the GL widget to have the desired size.
QMenu * getCameraPresetMenu() const
Get the menu used for camera presets.
virtual void showEvent(QShowEvent *event)
Called whenever the widget gets opened.
void restoreGLWidgetSize()
Restores the GL widget size if it was fixed with forceMainGLWidgetSize() previously.
This class is a screen recorder adapter in QT.
A widget containing an open gl display area.
Definition: WQtGLWidget.h:54