Developer Documentation
ViewControlPlugin.hh
1 /*===========================================================================*\
2 * *
3 * OpenFlipper *
4  * Copyright (c) 2001-2015, RWTH-Aachen University *
5  * Department of Computer Graphics and Multimedia *
6  * All rights reserved. *
7  * www.openflipper.org *
8  * *
9  *---------------------------------------------------------------------------*
10  * This file is part of OpenFlipper. *
11  *---------------------------------------------------------------------------*
12  * *
13  * Redistribution and use in source and binary forms, with or without *
14  * modification, are permitted provided that the following conditions *
15  * are met: *
16  * *
17  * 1. Redistributions of source code must retain the above copyright notice, *
18  * this list of conditions and the following disclaimer. *
19  * *
20  * 2. Redistributions in binary form must reproduce the above copyright *
21  * notice, this list of conditions and the following disclaimer in the *
22  * documentation and/or other materials provided with the distribution. *
23  * *
24  * 3. Neither the name of the copyright holder nor the names of its *
25  * contributors may be used to endorse or promote products derived from *
26  * this software without specific prior written permission. *
27  * *
28  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
29  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
30  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
31  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
32  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
33  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
34  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
35  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
36  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
37  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
38  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
39 * *
40 \*===========================================================================*/
41 
42 /*===========================================================================*\
43 * *
44 * $Revision$ *
45 * $LastChangedBy$ *
46 * $Date$ *
47 * *
48 \*===========================================================================*/
49 
50 #ifndef ViewControlPlugin_HH
51 #define ViewControlPlugin_HH
52 
53 #include <QObject>
54 #include <QMenuBar>
55 #include <QGroupBox>
56 
65 #include "shaderWidget.hh"
66 
67 struct ShaderInfo {
68  QString name;
69  QString description;
70  QString details;
71  QString version;
72  QString example;
73 
74  QString directory;
75 
76  QString vertexShader;
77  QString fragmentShader;
78 
79  QString pickVertexShader;
80  QString pickFragmentShader;
81 
82  bool hasUniforms;
83  QStringList uniforms;
84  QStringList uniformTypes;
85  QStringList uniformsDefault;
86  QStringList uniformsMax;
87  QStringList uniformsMin;
88 };
89 
91 {
92  Q_OBJECT
93  Q_INTERFACES(BaseInterface)
94  Q_INTERFACES(PickingInterface)
95  Q_INTERFACES(LoggingInterface)
96  Q_INTERFACES(ToolbarInterface)
97  Q_INTERFACES(ContextMenuInterface)
98 
99 #if QT_VERSION >= 0x050000
100  Q_PLUGIN_METADATA(IID "org.OpenFlipper.Plugins.Plugin-ViewControl")
101 #endif
102 
103  signals:
104  //BaseInterface
105  void updateView();
106 
107  //PickingInterface
108  void addHiddenPickMode( const std::string& _mode );
109 
110  //LoggingInterface
111  void log(Logtype _type, QString _message);
112  void log(QString _message);
113 
114  //ToolbarInterface
115  void addToolbar(QToolBar* _toolbar);
116  void getToolBar(QString _name, QToolBar*& _toolbar);
117 
118  // ContextMenuInterface
119  void addContextMenuItem(QAction* _action , ContextMenuType _type);
120  void addContextMenuItem(QAction* _action , DataType _objectType , ContextMenuType _type );
121  void hideContextMenu();
122 
123  void setSlotDescription(QString _slotName, QString _slotDescription,
124  QStringList _parameters, QStringList _descriptions);
125 
126  private slots:
127 
128  void pluginsInitialized();
129 
130  void contextMenuTriggered(QAction* _action);
131 
132  void slotUpdateContextMenu( int _objectId );
133 
134  public :
135 
137  ~ViewControlPlugin() {};
138 
139 
140  QString name() { return (QString("ViewControl")); };
141  QString description( ) { return (QString("Control the current or global visualization settings")); };
142 
143 
144  private:
145  QMenu* viewControlMenu_;
146 
150 
154 
158 
159  ShaderWidget* shaderWidget_;
160 
163  std::vector <ShaderInfo> shaderList_;
164 
165  QToolBar* toolbar_;
166  QActionGroup* toolbarViewingDirections_;
167  QAction* viewTop_;
168  QAction* viewBottom_;
169  QAction* viewLeft_;
170  QAction* viewRight_;
171  QAction* viewFront_;
172  QAction* viewBack_;
173 
174  std::map<QCheckBox*, ACG::SceneGraph::DrawModes::DrawMode> activeCheckboxes;
175 
176  private slots:
177  QString version() { return QString("1.0"); };
178 
179  // This slot is called when a custom draw mode is selected from the context menu
180  void slotDrawModeSelected( QAction * _action );
181 
182  // This slot is called when the user clicks on an item in the shaderWidget
183  void slotShaderClicked( QListWidgetItem * _item );
184 
185  // This slot is called when the user doubleclicks on an item in the shaderWidget
186  void slotShaderDoubleClicked( QListWidgetItem * _item );
187 
188  // slot for setting a shader from the widget
189  void slotSetShader();
190 
191  // slot is called when the data of the uniforms-table changes
192  void itemChanged(QTableWidgetItem* item);
193 
194  // Set the view to one of the six possible look-at directions
195  void setView(int _mode, int _viewer = PluginFunctions::ACTIVE_VIEWER );
196 
197  // Set the view mode using the defined actions
198  void setView(QAction* _action);
199 
200  private:
201  // Update the list of available shaders
202  void updateShaderList();
203 
204  // initialize the shader Widget
205  void initShaderWidget();
206 
207  // Announce local slots
208  void setDescriptions();
209 
216  bool areasVisible( StatusBits _bits, int _id );
217 
224  void showAreas( StatusBits _bits, int _id , bool _state );
225 
226 
227  public slots:
229  bool selectionVisible( int _id );
230 
232  void showSelection( int _id , bool _state );
233 
235  bool modelingAreasVisible( int _id );
236 
238  void showModelingAreas( int _id , bool _state );
239 
247  void disableShader(int _objectId, ACG::SceneGraph::DrawModes::DrawMode _drawMode, ShaderInfo* _shader=0);
248 
254  void setShader(int _id, ACG::SceneGraph::DrawModes::DrawMode _drawMode, ShaderInfo _shader);
255 
266  void setShader(int _id, QString _drawMode, QString _name );
267 
269  QStringList getUniforms(QString _shader);
270 
271  QString getUniformType(QString _shader, QString _uniform );
272  QString getUniformDefault(QString _shader, QString _uniform );
273  QString getUniformMin(QString _shader, QString _uniform );
274  QString getUniformMax(QString _shader, QString _uniform );
275 
277  void setUniform(int _objID, ACG::SceneGraph::DrawModes::DrawMode _drawMode, QString _shader, QString _uniform, QString _value );
278 
279 
281  void setViewingDirection( Vector _direction, Vector _upvector , int _viewer = PluginFunctions::ALL_VIEWERS );
282 
284  void setSceneRadius( double _radius , int _viewer = PluginFunctions::ALL_VIEWERS );
285 
287  void rotate( Vector _axis, double _angle, Vector _center , int _viewer = PluginFunctions::ALL_VIEWERS );
288 
290  void translate( Vector _vec , int _viewer = PluginFunctions::ALL_VIEWERS );
291 
293  void setDrawMode(QString _mode, int _viewer = PluginFunctions::ALL_VIEWERS );
294 
303  void setObjectDrawMode(QString _mode, int _objectID , bool _force = true );
304 
306  Vector viewingDirection( int _viewer = PluginFunctions::ACTIVE_VIEWER );
307 
309  Vector upVector( int _viewer = PluginFunctions::ACTIVE_VIEWER );
310 
312  Vector eyePosition( int _viewer = PluginFunctions::ACTIVE_VIEWER );
313 
315  Vector sceneCenter( int _viewer = PluginFunctions::ACTIVE_VIEWER );
316 
318  void setSceneCenter( Vector _center, int _viewer = PluginFunctions::ALL_VIEWERS );
319 
321  void enableBackfaceCulling( bool _state , int _viewer = PluginFunctions::ALL_VIEWERS );
322 
323 
324  void setEyePosition(Vector _eye);
325 
327  void viewAll();
328 
330  void viewAll(int _viewer);
331 
333  void viewHome();
334 
336  void viewHome(int _viewer);
337 
338 
339 
341  void orthographicProjection();
342 
344  void orthographicProjection(int _viewer);
345 
346 
347 
349  void perspectiveProjection();
350 
352  void perspectiveProjection(int _viewer);
353 
355  void setFOVY( double _fovy );
356 
359  void setCoordsysProjection(bool _orthogonal);
360 
361  void setTwoSidedLighting(bool _enabled);
362 
363 };
364 
365 #endif //ViewControlPlugin_HH
ACG::SceneGraph::DrawModes::DrawMode activeDrawModes_
std::vector< ShaderInfo > shaderList_
Interface class for creating custom context menus.
Predefined datatypes.
Definition: DataTypes.hh:96
Logtype
Log types for Message Window.
QString name()
Return a name for the plugin.
Interface class from which all plugins have to be created.
Interface for all Plugins which do logging to the logging window of the framework.
ACG::SceneGraph::DrawModes::DrawMode availDrawModes_
QString description()
Return a description of what the plugin is doing.
Add a toolbox to OpenFlipper.
Allow access to picking functions.