Developer Documentation

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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
57 #include <OpenFlipper/BasePlugin/BaseInterface.hh>
58 #include <OpenFlipper/BasePlugin/LoggingInterface.hh>
59 #include <OpenFlipper/BasePlugin/PickingInterface.hh>
60 #include <OpenFlipper/BasePlugin/ToolbarInterface.hh>
61 #include <OpenFlipper/BasePlugin/ContextMenuInterface.hh>
62 #include <OpenFlipper/common/Types.hh>
63 #include <ObjectTypes/PolyMesh/PolyMesh.hh>
64 #include <ObjectTypes/TriangleMesh/TriangleMesh.hh>
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
90 class ViewControlPlugin : public QObject, BaseInterface , PickingInterface, LoggingInterface, ToolbarInterface, ContextMenuInterface
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
136 ViewControlPlugin();
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
149 int lastObjectId_;
150
153 ACG::SceneGraph::DrawModes::DrawMode activeDrawModes_;
154
157 ACG::SceneGraph::DrawModes::DrawMode availDrawModes_;
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
ViewControlPlugin::activeDrawModes_
ACG::SceneGraph::DrawModes::DrawMode activeDrawModes_
Definition: ViewControlPlugin.hh:153
BaseInterface
Interface class from which all plugins have to be created.
Definition: BaseInterface.hh:76
ViewControlPlugin::sceneCenter
Vector sceneCenter(int _viewer=PluginFunctions::ACTIVE_VIEWER)
Get the scene center.
Definition: ViewControlPlugin.cc:1326
ViewControlPlugin::enableBackfaceCulling
void enableBackfaceCulling(bool _state, int _viewer=PluginFunctions::ALL_VIEWERS)
Enable or disable Backface culling.
Definition: ViewControlPlugin.cc:1251
ViewControlPlugin::setFOVY
void setFOVY(double _fovy)
Set fovy angle of projection.
Definition: ViewControlPlugin.cc:1417
ViewControlPlugin::modelingAreasVisible
bool modelingAreasVisible(int _id)
For meshes returns if the modeling areas for this object is visible.
Definition: ViewControlPlugin.cc:452
ViewControlPlugin::upVector
Vector upVector(int _viewer=PluginFunctions::ACTIVE_VIEWER)
get a viewers up vector
Definition: ViewControlPlugin.cc:1314
ViewControlPlugin::areasVisible
bool areasVisible(StatusBits _bits, int _id)
Return of all of the given modeling areas are visible.
Definition: ViewControlPlugin.cc:426
ViewControlPlugin::showSelection
void showSelection(int _id, bool _state)
Allows to enable/disable visualization of the objects selection for meshes.
Definition: ViewControlPlugin.cc:484
ShaderWidget
Definition: shaderWidget.hh:59
ViewControlPlugin::viewAll
void viewAll()
Change View on all viewers to view whole scene.
Definition: ViewControlPlugin.cc:1384
ViewControlPlugin::viewingDirection
Vector viewingDirection(int _viewer=PluginFunctions::ACTIVE_VIEWER)
Get a viewers viewing direction.
Definition: ViewControlPlugin.cc:1310
Logtype
Logtype
Log types for Message Window.
Definition: LoggingInterface.hh:103
ViewControlPlugin::disableShader
void disableShader(int _objectId, ACG::SceneGraph::DrawModes::DrawMode _drawMode, ShaderInfo *_shader=0)
Definition: ViewControlPlugin.cc:983
ToolbarInterface.hh
TriangleMesh.hh
ViewControlPlugin::setSceneCenter
void setSceneCenter(Vector _center, int _viewer=PluginFunctions::ALL_VIEWERS)
Set the scene center.
Definition: ViewControlPlugin.cc:1322
LoggingInterface.hh
ViewControlPlugin::eyePosition
Vector eyePosition(int _viewer=PluginFunctions::ACTIVE_VIEWER)
get a viewers eye Position
Definition: ViewControlPlugin.cc:1318
ViewControlPlugin::setSceneRadius
void setSceneRadius(double _radius, int _viewer=PluginFunctions::ALL_VIEWERS)
Set scene radius.
Definition: ViewControlPlugin.cc:1234
LoggingInterface
Interface for all Plugins which do logging to the logging window of the framework.
Definition: LoggingInterface.hh:123
ViewControlPlugin::orthographicProjection
void orthographicProjection()
Change Viewer to orthographicProjection.
Definition: ViewControlPlugin.cc:1400
ViewControlPlugin::lastObjectId_
int lastObjectId_
Definition: ViewControlPlugin.hh:149
ViewControlPlugin
Definition: ViewControlPlugin.hh:90
ViewControlPlugin::getUniforms
QStringList getUniforms(QString _shader)
get information about available uniforms for a given shader
Definition: ViewControlPlugin.cc:1117
ACG::SceneGraph::DrawModes::DrawMode
Specifies a DrawMode.
Definition: DrawModes.hh:294
ViewControlPlugin::setObjectDrawMode
void setObjectDrawMode(QString _mode, int _objectID, bool _force=true)
Set the draw mode for an object.
Definition: ViewControlPlugin.cc:1287
ContextMenuType
ContextMenuType
Definition: ContextMenuInterface.hh:72
ViewControlPlugin::translate
void translate(Vector _vec, int _viewer=PluginFunctions::ALL_VIEWERS)
translate Scene
Definition: ViewControlPlugin.cc:1246
OpenMesh::VectorT
Definition: Vector11T.hh:83
ToolbarInterface
Add a toolbox to OpenFlipper.
Definition: ToolbarInterface.hh:79
ViewControlPlugin::setUniform
void setUniform(int _objID, ACG::SceneGraph::DrawModes::DrawMode _drawMode, QString _shader, QString _uniform, QString _value)
set the value of a uniform in a shader for a specific drawMode
Definition: ViewControlPlugin.cc:1180
ShaderInfo
Definition: ViewControlPlugin.hh:67
ViewControlPlugin::viewHome
void viewHome()
Change View on given Viewer to view home position.
Definition: ViewControlPlugin.cc:1392
ContextMenuInterface.hh
ViewControlPlugin::setViewingDirection
void setViewingDirection(Vector _direction, Vector _upvector, int _viewer=PluginFunctions::ALL_VIEWERS)
Set the viewing direction.
Definition: ViewControlPlugin.cc:1228
ViewControlPlugin::description
QString description()
Return a description of what the plugin is doing.
Definition: ViewControlPlugin.hh:141
ViewControlPlugin::setDrawMode
void setDrawMode(QString _mode, int _viewer=PluginFunctions::ALL_VIEWERS)
Set the draw mode for a viewer.
Definition: ViewControlPlugin.cc:1268
PolyMesh.hh
ViewControlPlugin::availDrawModes_
ACG::SceneGraph::DrawModes::DrawMode availDrawModes_
Definition: ViewControlPlugin.hh:157
ViewControlPlugin::selectionVisible
bool selectionVisible(int _id)
For meshes returns if the selection for this object is visible.
Definition: ViewControlPlugin.cc:403
PickingInterface
Allow access to picking functions.
Definition: PickingInterface.hh:81
ViewControlPlugin::name
QString name()
Return a name for the plugin.
Definition: ViewControlPlugin.hh:140
PickingInterface.hh
BaseInterface.hh
ContextMenuInterface
Interface class for creating custom context menus.
Definition: ContextMenuInterface.hh:101
ViewControlPlugin::rotate
void rotate(Vector _axis, double _angle, Vector _center, int _viewer=PluginFunctions::ALL_VIEWERS)
Rotate Scene.
Definition: ViewControlPlugin.cc:1240
DataType
Predefined datatypes.
Definition: DataTypes.hh:96
ViewControlPlugin::perspectiveProjection
void perspectiveProjection()
Change Viewer to perspectiveProjection.
Definition: ViewControlPlugin.cc:1409
Types.hh
ViewControlPlugin::setCoordsysProjection
void setCoordsysProjection(bool _orthogonal)
Definition: ViewControlPlugin.cc:1423
ViewControlPlugin::showAreas
void showAreas(StatusBits _bits, int _id, bool _state)
Show or hide modeling areas.
Definition: ViewControlPlugin.cc:456
ViewControlPlugin::showModelingAreas
void showModelingAreas(int _id, bool _state)
Allows to enable/disable visualization of the objects modeling area for meshes.
Definition: ViewControlPlugin.cc:479
ViewControlPlugin::shaderList_
std::vector< ShaderInfo > shaderList_
Definition: ViewControlPlugin.hh:163
ViewControlPlugin::setShader
void setShader(int _id, ACG::SceneGraph::DrawModes::DrawMode _drawMode, ShaderInfo _shader)
Definition: ViewControlPlugin.cc:1007