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 #pragma once
43 
44 #include <QObject>
45 #include <QMenuBar>
46 #include <QGroupBox>
47 #include <QCheckBox>
48 
58 #include "shaderWidget.hh"
59 
60 struct ShaderInfo {
61  QString name;
62  QString description;
63  QString details;
64  QString version;
65  QString example;
66 
67  QString directory;
68 
69  QString vertexShader;
70  QString fragmentShader;
71 
72  QString pickVertexShader;
73  QString pickFragmentShader;
74 
75  bool hasUniforms;
76  QStringList uniforms;
77  QStringList uniformTypes;
78  QStringList uniformsDefault;
79  QStringList uniformsMax;
80  QStringList uniformsMin;
81 };
82 
84 {
85  Q_OBJECT
86  Q_INTERFACES(BaseInterface)
87  Q_INTERFACES(PickingInterface)
88  Q_INTERFACES(LoggingInterface)
89  Q_INTERFACES(ToolbarInterface)
90  Q_INTERFACES(ContextMenuInterface)
91  Q_INTERFACES(PythonInterface)
92 
93  Q_PLUGIN_METADATA(IID "org.OpenFlipper.Plugins.Plugin-ViewControl")
94 
95  signals:
96  //BaseInterface
97  void updateView();
98 
99  //PickingInterface
100  void addHiddenPickMode( const std::string& _mode );
101 
102  //LoggingInterface
103  void log(Logtype _type, QString _message);
104  void log(QString _message);
105 
106  //ToolbarInterface
107  void addToolbar(QToolBar* _toolbar);
108  void getToolBar(QString _name, QToolBar*& _toolbar);
109 
110  // ContextMenuInterface
111  void addContextMenuItem(QAction* _action , ContextMenuType _type);
112  void addContextMenuItem(QAction* _action , DataType _objectType , ContextMenuType _type );
113  void hideContextMenu();
114 
115  void setSlotDescription(QString _slotName, QString _slotDescription,
116  QStringList _parameters, QStringList _descriptions);
117 
118  private slots:
119 
120  void pluginsInitialized();
121 
122  void contextMenuTriggered(QAction* _action);
123 
124  void slotUpdateContextMenu( int _objectId );
125 
126  public :
127 
129  ~ViewControlPlugin() {};
130 
131 
132  QString name() { return (QString("ViewControl")); };
133  QString description( ) { return (QString("Control the current or global visualization settings")); };
134 
135 
136  private:
137  QMenu* viewControlMenu_;
138 
142 
146 
150 
151  ShaderWidget* shaderWidget_;
152 
155  std::vector <ShaderInfo> shaderList_;
156 
157  QToolBar* toolbar_;
158  QActionGroup* toolbarViewingDirections_;
159  QAction* viewTop_;
160  QAction* viewBottom_;
161  QAction* viewLeft_;
162  QAction* viewRight_;
163  QAction* viewFront_;
164  QAction* viewBack_;
165 
166  std::map<QCheckBox*, ACG::SceneGraph::DrawModes::DrawMode> activeCheckboxes;
167 
168  private slots:
169  QString version() { return QString("1.0"); };
170 
171  // This slot is called when a custom draw mode is selected from the context menu
172  void slotDrawModeSelected( QAction * _action );
173 
174  // This slot is called when the user clicks on an item in the shaderWidget
175  void slotShaderClicked( QListWidgetItem * _item );
176 
177  // This slot is called when the user doubleclicks on an item in the shaderWidget
178  void slotShaderDoubleClicked( QListWidgetItem * _item );
179 
180  // slot for setting a shader from the widget
181  void slotSetShader();
182 
183  // slot is called when the data of the uniforms-table changes
184  void itemChanged(QTableWidgetItem* item);
185 
186  // Set the view to one of the six possible look-at directions
187  void setView(int _mode, int _viewer = PluginFunctions::ACTIVE_VIEWER );
188 
189  // Set the view mode using the defined actions
190  void setView(QAction* _action);
191 
192  private:
193  // Update the list of available shaders
194  void updateShaderList();
195 
196  // initialize the shader Widget
197  void initShaderWidget();
198 
199  // Announce local slots
200  void setDescriptions();
201 
208  bool areasVisible( StatusBits _bits, int _id );
209 
216  void showAreas( StatusBits _bits, int _id , bool _state );
217 
218 
219  public slots:
221  bool selectionVisible( int _id );
222 
224  void showSelection( int _id , bool _state );
225 
227  bool modelingAreasVisible( int _id );
228 
230  void showModelingAreas( int _id , bool _state );
231 
239  void disableShader(int _objectId, ACG::SceneGraph::DrawModes::DrawMode _drawMode, ShaderInfo* _shader=0);
240 
246  void setShader(int _id, ACG::SceneGraph::DrawModes::DrawMode _drawMode, ShaderInfo _shader);
247 
258  void setShader(int _id, QString _drawMode, QString _name );
259 
261  QStringList getUniforms(QString _shader);
262 
263  QString getUniformType(QString _shader, QString _uniform );
264  QString getUniformDefault(QString _shader, QString _uniform );
265  QString getUniformMin(QString _shader, QString _uniform );
266  QString getUniformMax(QString _shader, QString _uniform );
267 
269  void setUniform(int _objID, ACG::SceneGraph::DrawModes::DrawMode _drawMode, QString _shader, QString _uniform, QString _value );
270 
271 
273  void setViewingDirection( Vector _direction, Vector _upvector , int _viewer = PluginFunctions::ALL_VIEWERS );
274 
276  void setSceneRadius( double _radius , int _viewer = PluginFunctions::ALL_VIEWERS );
277 
279  void rotate( Vector _axis, double _angle, Vector _center , int _viewer = PluginFunctions::ALL_VIEWERS );
280 
282  void translate( Vector _vec , int _viewer = PluginFunctions::ALL_VIEWERS );
283 
285  void setDrawMode(QString _mode, int _viewer = PluginFunctions::ALL_VIEWERS );
286 
295  void setObjectDrawMode(QString _mode, int _objectID , bool _force = true );
296 
298  Vector viewingDirection( int _viewer = PluginFunctions::ACTIVE_VIEWER );
299 
301  Vector upVector( int _viewer = PluginFunctions::ACTIVE_VIEWER );
302 
304  Vector eyePosition( int _viewer = PluginFunctions::ACTIVE_VIEWER );
305 
307  Vector sceneCenter( int _viewer = PluginFunctions::ACTIVE_VIEWER );
308 
310  void setSceneCenter( Vector _center, int _viewer = PluginFunctions::ALL_VIEWERS );
311 
313  void enableBackfaceCulling( bool _state , int _viewer = PluginFunctions::ALL_VIEWERS );
314 
315 
316  void setEyePosition(Vector _eye);
317 
319  void viewAll();
320 
322  void viewAll(int _viewer);
323 
325  void viewHome();
326 
328  void viewHome(int _viewer);
329 
330 
331 
333  void orthographicProjection();
334 
336  void orthographicProjection(int _viewer);
337 
338 
339 
341  void perspectiveProjection();
342 
344  void perspectiveProjection(int _viewer);
345 
347  void setFOVY( double _fovy );
348 
351  void setCoordsysProjection(bool _orthogonal);
352 
353  void setTwoSidedLighting(bool _enabled);
354 
355 };
356 
357 
Interface class for creating custom context menus.
ACG::SceneGraph::DrawModes::DrawMode activeDrawModes_
std::vector< ShaderInfo > shaderList_
Logtype
Log types for Message Window.
QString description()
Return a description of what the plugin is doing.
ACG::SceneGraph::DrawModes::DrawMode availDrawModes_
Interface for all Plugins which do logging to the logging window of the framework.
Allow access to picking functions.
Interface class from which all plugins have to be created.
Add a toolbox to OpenFlipper.
Predefined datatypes.
Definition: DataTypes.hh:83
QString name()
Return a name for the plugin.
Interface class for exporting functions to python.