Developer Documentation
ViewControlPlugin.cc
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 
45 #include "ViewControlPlugin.hh"
46 #include <OpenFlipper/INIFile/INIFile.hh>
47 
48 #include <OpenFlipper/ACGHelper/DrawModeConverter.hh>
49 #include <ACG/Scenegraph/CoordsysNode.hh>
50 
51 #include <QWidgetAction>
52 #include <QInputDialog>
53 
54 #define SHOW_SELECTION "Show/Hide Selections"
55 #define SHOW_AREAS "Show/Hide All Modeling Areas"
56 #define SHOW_AREA "Show/Hide Modeling Area"
57 #define SHOW_HANDLE "Show/Hide Handle Area"
58 #define SHOW_FEATURES "Show/Hide Feature Selection"
59 #define SIZE_SELECTION "Set Selection Width"
60 #define SIZE_FEATURES "Set Feature Width"
61 #define USEGLOBALDRAWMODE "Use Global DrawMode"
62 #define SETSHADERS "Set Shader"
63 
64 ViewControlPlugin::ViewControlPlugin():
65 viewControlMenu_(0),
66 lastObjectId_(0),
67 shaderWidget_(0),
68 toolbar_(0),
69 toolbarViewingDirections_(0),
70 viewTop_(0),
71 viewBottom_(0),
72 viewLeft_(0),
73 viewRight_(0),
74 viewFront_(0),
75 viewBack_(0)
76 {
77 
78 }
79 
80 void ViewControlPlugin::pluginsInitialized() {
81 
82  // Disable Context Menu for draw Modes
83  OpenFlipper::Options::drawModesInContextMenu(false);
84 
85  // Create a new visualization context menu
86  viewControlMenu_ = new QMenu("Visualization");
87 
88  // Set an icon for the menu
89  QIcon icon = QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"drawModes.png");
90  viewControlMenu_->setIcon(icon);
91 
92  // Add it as context menu for all registered data types
93  for(std::vector<TypeInfo>::const_iterator it = typesBegin(); it != typesEnd(); ++it) {
94  if(it->name == "Unknown" || it->name == "Group" || it->name == "All") continue;
95  emit addContextMenuItem(viewControlMenu_->menuAction(), it->type, CONTEXTOBJECTMENU );
96  }
97 
98  connect( viewControlMenu_, SIGNAL( triggered(QAction*) ), this, SLOT( contextMenuTriggered(QAction*) ));
99 
100  setDescriptions();
101 
102  // Create toolbar
103  toolbar_ = new QToolBar(tr("Viewing Directions"));
104 
105  // Action group for toolbar
106  toolbarViewingDirections_ = new QActionGroup(toolbar_);
107  QString iconPath = OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator();
108 
109  // different viewing direction buttons for toolbar
110  viewTop_ = new QAction( QIcon(iconPath + "viewcontrol_top.png"), tr("View from top") , toolbarViewingDirections_);
111  toolbar_->addAction( viewTop_ );
112  viewBottom_ = new QAction( QIcon(iconPath + "viewcontrol_bottom.png"), tr("View from bottom") , toolbarViewingDirections_);
113  toolbar_->addAction( viewBottom_ );
114  viewLeft_ = new QAction( QIcon(iconPath + "viewcontrol_left.png"), tr("View from left") , toolbarViewingDirections_);
115  toolbar_->addAction( viewLeft_ );
116  viewRight_ = new QAction( QIcon(iconPath + "viewcontrol_right.png"), tr("View from right") , toolbarViewingDirections_);
117  toolbar_->addAction( viewRight_ );
118  viewFront_ = new QAction( QIcon(iconPath + "viewcontrol_front.png"), tr("View from front") , toolbarViewingDirections_);
119  toolbar_->addAction( viewFront_ );
120  viewBack_ = new QAction( QIcon(iconPath + "viewcontrol_back.png"), tr("View from back") , toolbarViewingDirections_);
121  toolbar_->addAction( viewBack_ );
122 
123  connect( toolbarViewingDirections_, SIGNAL( triggered(QAction*) ), this, SLOT(setView(QAction*)) );
124 
125  // Add the generated toolbar to the core
126  emit addToolbar(toolbar_);
127 
128 
129 }
130 
131 void ViewControlPlugin::updateShaderList() {
132 
133  //=======================================================================================
134  // Get Shaders
135  //=======================================================================================
136  shaderList_.clear();
137  QStringList shadersDirs = OpenFlipper::Options::shaderDir().entryList( QDir::Dirs| QDir::NoDotAndDotDot ,QDir::Name);
138 
139  for ( int i = 0 ; i < shadersDirs.size(); ++i ) {
140  ShaderInfo info;
141 
142  QFileInfo descriptionFile(OpenFlipper::Options::shaderDirStr() +
143  OpenFlipper::Options::dirSeparator() +
144  shadersDirs[i] + OpenFlipper::Options::dirSeparator() + "shader.ini" );
145 
146  INIFile ini;
147  if ( !descriptionFile.exists() || !ini.connect( descriptionFile.filePath() ,false ) ) {
148  emit log( LOGWARN, "Unable to open description file for shader " + shadersDirs[i] + " at " + descriptionFile.filePath() );
149 
150  info.description = "Unknown";
151  info.version = "Unknown";
152  info.name = shadersDirs[i];
153  info.details = "----------";
154  info.example = "";
155 
156  } else {
157 
158  QString tmp;
159  if ( ini.get_entry(tmp,"Info","name") )
160  info.name = tmp;
161  else {
162  info.name = shadersDirs[i];
163  emit log( LOGWARN, "Unable to get name from description file for shader " + shadersDirs[i] );
164  }
165 
166  if ( ini.get_entry(tmp,"Info","description") )
167  info.description = tmp;
168  else {
169  info.description = "Unknown";
170  emit log( LOGWARN, "Unable to get shader description from description file for shader " + shadersDirs[i] );
171  }
172 
173  if ( ini.get_entry(tmp,"Info","details") )
174  info.details = tmp;
175  else {
176  info.details = "----------";
177  emit log( LOGWARN, "Unable to get shader details from description file for shader " + shadersDirs[i] );
178  }
179 
180  if ( ini.get_entry(tmp,"Info","version") )
181  info.version = tmp;
182  else {
183  info.version = "Unknown";
184  emit log( LOGWARN, "Unable to get shader version from description file for shader " + shadersDirs[i] );
185  }
186 
187  if ( ini.get_entry(tmp,"Info","example") )
188  info.example = OpenFlipper::Options::shaderDirStr() + OpenFlipper::Options::dirSeparator() +
189  shadersDirs[i] + OpenFlipper::Options::dirSeparator() + tmp;
190  else {
191  info.example = "";
192  emit log( LOGWARN, "Unable to get example image from Description file for shader " + shadersDirs[i] );
193  }
194 
195  if ( ini.get_entry(tmp,"FragmentShader","file") )
196  info.fragmentShader = tmp;
197  else {
198  info.fragmentShader = "Fragment.glsl";
199  emit log( LOGWARN, "Unable to get fragment shader filename from Description file for shader " + shadersDirs[i] );
200  }
201 
202  if ( ini.get_entry(tmp,"VertexShader","file") )
203  info.vertexShader = tmp;
204  else {
205  info.vertexShader = "Vertex.glsl";
206  emit log( LOGWARN, "Unable to get vertex shader filename from Description file for shader " + shadersDirs[i] );
207  }
208 
209  if ( ini.get_entry(tmp,"PickVertexShader","file") )
210  info.pickVertexShader = tmp;
211  else
212  info.pickVertexShader = "";
213 
214  if ( ini.get_entry(tmp,"PickFragmentShader","file") )
215  info.pickFragmentShader = tmp;
216  else
217  info.pickFragmentShader = "";
218 
219  //uniform names
220  std::vector<QString> uniforms;
221  if ( ini.get_entry(uniforms,"Info","uniforms") ) {
222  info.hasUniforms = true;
223  for ( uint uniform = 0 ; uniform < uniforms.size() ; ++uniform)
224  info.uniforms << uniforms[uniform];
225  } else {
226  info.hasUniforms = false;
227  info.uniforms.clear();
228  }
229 
230  //unform types
231  uniforms.clear();
232  if ( info.hasUniforms && ini.get_entry(uniforms,"Info","uniformTypes") ) {
233  for ( uint uniform = 0 ; uniform < uniforms.size() ; ++uniform)
234  info.uniformTypes << uniforms[uniform];
235  } else if ( info.hasUniforms ) {
236  info.hasUniforms = false;
237  info.uniforms.clear();
238  info.uniformTypes.clear();
239  emit log( LOGERR, "Uniforms for shader " + shadersDirs[i] + " defined but no type available, disabled uniforms." );
240  }
241 
242  //uniform default values
243  uniforms.clear();
244  if ( info.hasUniforms && ini.get_entry(uniforms,"Info","uniformsDefault" ) ) {
245  for ( uint uniform = 0 ; uniform < uniforms.size() ; ++uniform)
246  info.uniformsDefault << uniforms[uniform];
247  } else if ( info.hasUniforms ) {
248  info.hasUniforms = false;
249  info.uniforms.clear();
250  info.uniformTypes.clear();
251  emit log( LOGERR, "Uniforms for shader " + shadersDirs[i] + " defined but no defaults available, disabled uniforms." );
252  }
253  //uniform min values
254  uniforms.clear();
255  if ( info.hasUniforms && ini.get_entry(uniforms,"Info","uniformsMin" ) ) {
256  for ( uint uniform = 0 ; uniform < uniforms.size() ; ++uniform)
257  info.uniformsMin << uniforms[uniform];
258  } else if ( info.hasUniforms )
259  info.uniformsMin = info.uniformsDefault;
260 
261  //uniform max values
262  uniforms.clear();
263  if ( info.hasUniforms && ini.get_entry(uniforms,"Info","uniformsMax" ) ) {
264  for ( uint uniform = 0 ; uniform < uniforms.size() ; ++uniform)
265  info.uniformsMax << uniforms[uniform];
266  } else if ( info.hasUniforms )
267  info.uniformsMax = info.uniformsDefault;
268 
269  ini.disconnect();
270  }
271 
272  info.directory = descriptionFile.path();
273 
274  QFileInfo vertexShaderFile( info.directory + OpenFlipper::Options::dirSeparator() + info.vertexShader );
275  if ( !vertexShaderFile.exists() ) {
276  emit log( LOGERR, "Unable to find vertex shader file " + vertexShaderFile.filePath() );
277  continue;
278  }
279 
280  QFileInfo fragmentShaderFile( info.directory + OpenFlipper::Options::dirSeparator() + info.fragmentShader );
281  if ( !fragmentShaderFile.exists() ) {
282  emit log( LOGERR, "Unable to find fragment shader file " + fragmentShaderFile.filePath() );
283  continue;
284  }
285 
286  shaderList_.push_back(info);
287  }
288 
289 }
290 
291 
292 void ViewControlPlugin::contextMenuTriggered(QAction* _action){
293  if ( _action->text() == SHOW_SELECTION) {
294 
295  QVariant contextObject = _action->data();
296  int objectId = contextObject.toInt();
297 
298  if ( objectId == -1)
299  return;
300 
301  showSelection( objectId , !selectionVisible( objectId) );
302 
303  emit updateView();
304  }
305 
306  if ( _action->text() == SIZE_SELECTION) {
307 
308  QVariant contextObject = _action->data();
309  int objectId = contextObject.toInt();
310 
311  if ( objectId == -1)
312  return;
313 
314  BaseObjectData* object = 0;
315  if ( ! PluginFunctions::getObject(objectId,object) )
316  return;
317 
318  if ( object->dataType( DATA_TRIANGLE_MESH ) ) {
319  bool ok = true;
320 
321  double d = QInputDialog::getDouble(0, tr("Line width for features"),
322  tr("Size:"), 2.0, 1.0, 50.0, 2, &ok,
323  Qt::WindowFlags(), 1);
324  setSelectionLineWidth(objectId,d);
325 
326  }
327 
328  if ( object->dataType( DATA_POLY_MESH ) ) {
329  bool ok = true;
330  double d = QInputDialog::getDouble(0, tr("Line width for features"),
331  tr("Size:"), 2.0, 1.0, 50.0, 2, &ok,
332  Qt::WindowFlags(), 1);
333  setSelectionLineWidth(objectId,d);
334  }
335 
336  emit updateView();
337 
338  }
339 
340  if ( _action->text() == SHOW_AREAS) {
341 
342  QVariant contextObject = _action->data();
343  int objectId = contextObject.toInt();
344 
345  if ( objectId == -1)
346  return;
347 
348  showModelingAreas( objectId, !modelingAreasVisible(objectId) );
349 
350  emit updateView();
351  }
352 
353  if ( _action->text() == SHOW_AREA) {
354 
355  QVariant contextObject = _action->data();
356  int objectId = contextObject.toInt();
357 
358  if ( objectId == -1)
359  return;
360 
361  showAreas( AREA, objectId, !areasVisible(AREA,objectId) );
362 
363  emit updateView();
364  }
365 
366  if ( _action->text() == SHOW_HANDLE) {
367 
368  QVariant contextObject = _action->data();
369  int objectId = contextObject.toInt();
370 
371  if ( objectId == -1)
372  return;
373 
374  showAreas( HANDLEAREA, objectId, !areasVisible(HANDLEAREA,objectId) );
375 
376  emit updateView();
377  }
378 
379  if ( _action->text() == SHOW_FEATURES) {
380 
381  QVariant contextObject = _action->data();
382  int objectId = contextObject.toInt();
383 
384  if ( objectId == -1)
385  return;
386 
387  BaseObjectData* object = 0;
388  if ( ! PluginFunctions::getObject(objectId,object) )
389  return;
390 
391  if ( object->dataType( DATA_TRIANGLE_MESH ) ) {
393  if ( triMeshObject )
394  triMeshObject->hideFeatures( triMeshObject->featuresVisible() );
395  }
396 
397  if ( object->dataType( DATA_POLY_MESH ) ) {
399  if ( polyMeshObject )
400  polyMeshObject->hideFeatures( polyMeshObject->featuresVisible() );
401  }
402 
403  emit updateView();
404 
405  }
406 
407  if ( _action->text() == SIZE_FEATURES) {
408 
409  QVariant contextObject = _action->data();
410  int objectId = contextObject.toInt();
411 
412  if ( objectId == -1)
413  return;
414 
415  BaseObjectData* object = 0;
416  if ( ! PluginFunctions::getObject(objectId,object) )
417  return;
418 
419  if ( object->dataType( DATA_TRIANGLE_MESH ) ) {
420  bool ok = true;
421 
422  double d = QInputDialog::getDouble(0, tr("Line width for features"),
423  tr("Size:"), 2.0, 1.0, 50.0, 2, &ok,
424  Qt::WindowFlags(), 1);
425  setFeatureLineWidth(objectId,d);
426 
427  }
428 
429  if ( object->dataType( DATA_POLY_MESH ) ) {
430  bool ok = true;
431  double d = QInputDialog::getDouble(0, tr("Line width for features"),
432  tr("Size:"), 2.0, 1.0, 50.0, 2, &ok,
433  Qt::WindowFlags(), 1);
434  setFeatureLineWidth(objectId,d);
435  }
436 
437  emit updateView();
438 
439  }
440 
441 
442 
443  if ( _action->text() == SETSHADERS ) {
444  if ( shaderWidget_ == 0 ) {
445  shaderWidget_ = new ShaderWidget(0);
446  connect(shaderWidget_->availableShaders,SIGNAL(itemClicked(QListWidgetItem*)),
447  this ,SLOT(slotShaderClicked(QListWidgetItem*)));
448  connect(shaderWidget_->availableShaders,SIGNAL(itemDoubleClicked(QListWidgetItem*)),
449  this ,SLOT(slotShaderDoubleClicked(QListWidgetItem*)));
450 
451  connect(shaderWidget_->setShaderButton,SIGNAL(clicked()),this, SLOT(slotSetShader()));
452  connect(shaderWidget_->closeButton,SIGNAL(clicked()),shaderWidget_, SLOT(close()));
453 
454  connect(shaderWidget_->uniforms, SIGNAL(itemChanged(QTableWidgetItem*)),
455  this, SLOT(itemChanged(QTableWidgetItem*)) );
456  }
457 
458  initShaderWidget();
459 
460  shaderWidget_->show();
461 
462  emit updateView();
463  }
464 
465 }
466 
468  if ( _id == -1)
469  return false;
470 
471  BaseObjectData* object = 0;
472  if ( ! PluginFunctions::getObject(_id,object) )
473  return false;
474 
475  if ( object->dataType( DATA_TRIANGLE_MESH ) ) {
476  TriMeshObject* triMeshObject = PluginFunctions::triMeshObject( object );
477  if ( triMeshObject )
478  return triMeshObject->selectionVisible();
479  }
480 
481  if ( object->dataType( DATA_POLY_MESH ) ) {
482  PolyMeshObject* polyMeshObject = PluginFunctions::polyMeshObject( object );
483  if ( polyMeshObject )
484  return polyMeshObject->selectionVisible();
485  }
486 
487  return false;
488 }
489 
490 bool ViewControlPlugin::areasVisible( StatusBits _bits, int _id ) {
491 
492  if ( _id == -1)
493  return false;
494 
495  BaseObjectData* object = 0;
496  if ( ! PluginFunctions::getObject(_id,object) )
497  return false;
498 
499  if ( object->dataType( DATA_TRIANGLE_MESH ) ) {
500  TriMeshObject* triMeshObject = PluginFunctions::triMeshObject( object );
501  if ( triMeshObject ) {
502  return triMeshObject->areaVisible( _bits );
503  }
504  }
505 
506  if ( object->dataType( DATA_POLY_MESH ) ) {
507  PolyMeshObject* polyMeshObject = PluginFunctions::polyMeshObject( object );
508  if ( polyMeshObject )
509  return( polyMeshObject->areaVisible( _bits ) );
510  }
511 
512  return false;
513 
514 }
515 
517  return areasVisible(StatusBits(HANDLEAREA | AREA), _id);
518 }
519 
520 void ViewControlPlugin::showAreas( StatusBits _bits, int _id , bool _state ) {
521 
522  if ( _id == -1)
523  return;
524 
525  BaseObjectData* object = 0;
526  if ( ! PluginFunctions::getObject(_id,object) )
527  return;
528 
529  if ( object->dataType( DATA_TRIANGLE_MESH ) ) {
530  TriMeshObject* triMeshObject = PluginFunctions::triMeshObject( object );
531  if ( triMeshObject )
532  triMeshObject->hideArea( _bits, !_state);
533  }
534 
535  if ( object->dataType( DATA_POLY_MESH ) ) {
536  PolyMeshObject* polyMeshObject = PluginFunctions::polyMeshObject( object );
537  if ( polyMeshObject )
538  polyMeshObject->hideArea( _bits, !_state);
539  }
540 
541 }
542 
543 void ViewControlPlugin::showModelingAreas( int _id , bool _state ) {
544  showAreas(StatusBits(HANDLEAREA | AREA) , _id, _state );
545 }
546 
547 void ViewControlPlugin::setSelectionLineWidth( int _id , double _width ) {
548 
549  if ( _id == -1)
550  return;
551 
552  BaseObjectData* object = 0;
553  if ( ! PluginFunctions::getObject(_id,object) )
554  return;
555 
556  //statusNode()
557  if ( object->dataType( DATA_TRIANGLE_MESH ) ) {
558  TriMeshObject* triMeshObject = PluginFunctions::triMeshObject( object );
559  if ( triMeshObject )
560  triMeshObject->statusNode()->material().lineWidth(_width );
561  }
562 
563  if ( object->dataType( DATA_POLY_MESH ) ) {
564  PolyMeshObject* polyMeshObject = PluginFunctions::polyMeshObject( object );
565  if ( polyMeshObject )
566  polyMeshObject->statusNode()->material().lineWidth(_width );
567  }
568 
569 }
570 
571 void ViewControlPlugin::setFeatureLineWidth( int _id , double _width ) {
572 
573  if ( _id == -1)
574  return;
575 
576  BaseObjectData* object = 0;
577  if ( ! PluginFunctions::getObject(_id,object) )
578  return;
579 
580  //statusNode()
581  if ( object->dataType( DATA_TRIANGLE_MESH ) ) {
582  TriMeshObject* triMeshObject = PluginFunctions::triMeshObject( object );
583  if ( triMeshObject )
584  triMeshObject->featureNode()->material().lineWidth(_width );
585  }
586 
587  if ( object->dataType( DATA_POLY_MESH ) ) {
588  PolyMeshObject* polyMeshObject = PluginFunctions::polyMeshObject( object );
589  if ( polyMeshObject )
590  polyMeshObject->featureNode()->material().lineWidth(_width );
591  }
592 
593 }
594 
595 
596 void ViewControlPlugin::showSelection( int _id , bool _state ) {
597 
598  if ( _id == -1)
599  return;
600 
601  BaseObjectData* object = 0;
602  if ( ! PluginFunctions::getObject(_id,object) )
603  return;
604 
605  if ( object->dataType( DATA_TRIANGLE_MESH ) ) {
606  TriMeshObject* triMeshObject = PluginFunctions::triMeshObject( object );
607  if ( triMeshObject )
608  triMeshObject->hideSelection( !_state );
609  }
610 
611  if ( object->dataType( DATA_POLY_MESH ) ) {
612  PolyMeshObject* polyMeshObject = PluginFunctions::polyMeshObject( object );
613  if ( polyMeshObject )
614  polyMeshObject->hideSelection( !_state );
615  }
616 
617 }
618 
619 void ViewControlPlugin::slotUpdateContextMenu( int _objectId ){
620 
621  viewControlMenu_->clear();
622 
623  lastObjectId_ = _objectId;
624 
625  BaseObjectData* object = 0;
626  if ( !PluginFunctions::getObject( _objectId, object ) ) {
627  emit log(LOGERR,"Unable to create Context Menu ... Unable to get Object");
628  return;
629  }
630 
631  if (object->dataType( DATA_TRIANGLE_MESH ) || object->dataType( DATA_POLY_MESH ) ) {
632 
633  QAction* act;
634  act = viewControlMenu_->addAction( SHOW_SELECTION );
635  act->setCheckable(true);
636 
637  act->setStatusTip( "Switch visualization for selection on/off" );
638  act->setToolTip( "Switch visualization for selection on/off" );
639  act->setWhatsThis( "Switch the visualization of your current selections on and off." );
640 
641  act->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"selections.png"));
642 
643  if ( object->dataType( DATA_TRIANGLE_MESH ) ) {
644  TriMeshObject* triMeshObject = PluginFunctions::triMeshObject( object );
645  if ( triMeshObject )
646  act->setChecked( triMeshObject->selectionVisible() );
647  }
648 
649  if ( object->dataType( DATA_POLY_MESH ) ) {
650  PolyMeshObject* polyMeshObject = PluginFunctions::polyMeshObject( object );
651  if ( polyMeshObject )
652  act->setChecked( polyMeshObject->selectionVisible() );
653  }
654 
655  // ============================================
656  // Action for all modeling areas
657  // ============================================
658  act = viewControlMenu_->addAction( SHOW_AREAS );
659  act->setCheckable(true);
660 
661  act->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"areaSelections.png"));
662 
663  if ( object->dataType( DATA_TRIANGLE_MESH ) ) {
664  TriMeshObject* triMeshObject = PluginFunctions::triMeshObject( object );
665  if ( triMeshObject )
666  act->setChecked( triMeshObject->areaVisible( StatusBits(HANDLEAREA | AREA) ) );
667  }
668 
669  if ( object->dataType( DATA_POLY_MESH ) ) {
670  PolyMeshObject* polyMeshObject = PluginFunctions::polyMeshObject( object );
671  if ( polyMeshObject )
672  act->setChecked( polyMeshObject->areaVisible( StatusBits(HANDLEAREA | AREA) ) );
673  }
674 
675 
676  // ============================================
677  // Action for handle areas
678  // ============================================
679  act = viewControlMenu_->addAction( SHOW_HANDLE );
680  act->setCheckable(true);
681 
682  act->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"viewcontrol_handleSelection.png"));
683 
684  if ( object->dataType( DATA_TRIANGLE_MESH ) ) {
685  TriMeshObject* triMeshObject = PluginFunctions::triMeshObject( object );
686  if ( triMeshObject )
687  act->setChecked( triMeshObject->areaVisible( HANDLEAREA ) );
688  }
689 
690  if ( object->dataType( DATA_POLY_MESH ) ) {
691  PolyMeshObject* polyMeshObject = PluginFunctions::polyMeshObject( object );
692  if ( polyMeshObject )
693  act->setChecked( polyMeshObject->areaVisible( HANDLEAREA ) );
694  }
695 
696  // ============================================
697  // Action for modeling areas
698  // ============================================
699  act = viewControlMenu_->addAction( SHOW_AREA );
700  act->setCheckable(true);
701 
702  act->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"viewcontrol_modelingSelection.png"));
703 
704  if ( object->dataType( DATA_TRIANGLE_MESH ) ) {
705  TriMeshObject* triMeshObject = PluginFunctions::triMeshObject( object );
706  if ( triMeshObject )
707  act->setChecked( triMeshObject->areaVisible( AREA ) );
708  }
709 
710  if ( object->dataType( DATA_POLY_MESH ) ) {
711  PolyMeshObject* polyMeshObject = PluginFunctions::polyMeshObject( object );
712  if ( polyMeshObject )
713  act->setChecked( polyMeshObject->areaVisible( AREA ) );
714  }
715 
716  // ============================================
717  // Actions for feature visibility
718  // ============================================
719 
720 
721  act = viewControlMenu_->addAction( SHOW_FEATURES );
722  act->setCheckable(true);
723 
724  act->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"viewcontrol_featureSelections.png"));
725 
726  if ( object->dataType( DATA_TRIANGLE_MESH ) ) {
727  TriMeshObject* triMeshObject = PluginFunctions::triMeshObject( object );
728  if ( triMeshObject )
729  act->setChecked( triMeshObject->featuresVisible() );
730  }
731 
732  if ( object->dataType( DATA_POLY_MESH ) ) {
733  PolyMeshObject* polyMeshObject = PluginFunctions::polyMeshObject( object );
734  if ( polyMeshObject )
735  act->setChecked( polyMeshObject->featuresVisible() );
736  }
737 
738  // ============================================
739  // Action for features size
740  // ============================================
741  act = viewControlMenu_->addAction( SIZE_FEATURES );
742 
743  act->setCheckable(true);
744 
745  act->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"viewcontrol_featureSize.png"));
746 
747  // ============================================
748  // Action for selection size
749  // ============================================
750  act = viewControlMenu_->addAction( SIZE_SELECTION );
751 
752  act->setCheckable(true);
753 
754  act->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"viewcontrol_selectionSize.png"));
755 
756  }
757 
758  // If this Object has a shader Node, allow settings for the shader
759  if ( object->shaderNode() ) {
760  viewControlMenu_->addSeparator();
761 
762  QAction* act = viewControlMenu_->addAction( SETSHADERS );
763  act->setCheckable( false );
764  }
765 
766  viewControlMenu_->addSeparator();
767 
768  QActionGroup * globalDrawActionsGroup = new QActionGroup( this );
769 
770  QAction * action = new QAction( USEGLOBALDRAWMODE , globalDrawActionsGroup );
771  action->setCheckable( false );
772 
773  viewControlMenu_->addActions(globalDrawActionsGroup->actions());
774 
775  connect( globalDrawActionsGroup, SIGNAL( triggered( QAction * ) ),
776  this , SLOT( slotDrawModeSelected( QAction * ) ) );
777 
778  QActionGroup * drawGroup = new QActionGroup( this );
779  drawGroup->setExclusive( false );
780 
781  // Collect available draw Modes for this object
783  ACG::SceneGraph::traverse( object->primaryNode() , actionAvailable);
784  availDrawModes_ = actionAvailable.drawModes();
785 
786  // Collect available draw Modes for this object
788  ACG::SceneGraph::traverse( object->primaryNode() , actionActive);
789  activeDrawModes_ = actionActive.drawMode();
790 
791  std::vector< ACG::SceneGraph::DrawModes::DrawMode > availDrawModeIds;
792  availDrawModeIds = availDrawModes_.getAtomicDrawModes();
793 
795 
796  const bool containsGlobalDM = activeDrawModes_ == ACG::SceneGraph::DrawModes::DEFAULT;
797 
798  activeCheckboxes.clear();
799  for ( unsigned int i = 0; i < availDrawModeIds.size(); ++i )
800  {
801  ACG::SceneGraph::DrawModes::DrawMode id = availDrawModeIds[i];
802  std::string descr = id.description();
803 
804  QCheckBox *checkBox = new QCheckBox(QString(descr.c_str()), viewControlMenu_);
805  activeCheckboxes[checkBox] = id;
806  if (activeDrawModes_.containsAtomicDrawMode(id))
807  checkBox->setCheckState(Qt::Checked);
808  else if (containsGlobalDM && globalDrawModes.containsAtomicDrawMode(id))
809  checkBox->setCheckState(Qt::PartiallyChecked);
810  else
811  checkBox->setCheckState(Qt::Unchecked);
812  QWidgetAction *checkableAction = new QWidgetAction(drawGroup);
813  checkableAction->setText(descr.c_str());
814  checkableAction->setDefaultWidget(checkBox);
815  connect(checkBox, SIGNAL( stateChanged(int) ), checkableAction, SLOT(trigger() ) );
816  }
817 
818  viewControlMenu_->addActions( drawGroup->actions() );
819 
820  connect( drawGroup, SIGNAL( triggered( QAction * ) ),
821  this, SLOT( slotDrawModeSelected( QAction * ) ) );
822 
823 }
824 
825 void ViewControlPlugin::slotDrawModeSelected( QAction * _action) {
826 
827  QWidgetAction * const wdgtAction = dynamic_cast<QWidgetAction*>(_action);
828  QCheckBox * const checkbox = wdgtAction ? dynamic_cast<QCheckBox*>(wdgtAction->defaultWidget()) : 0;
829  const bool activateDrawMode = checkbox ? (checkbox->checkState() != Qt::Unchecked) : false;
830 
831  //======================================================================================
832  // Get the mode toggled
833  //======================================================================================
835  std::vector< ACG::SceneGraph::DrawModes::DrawMode > availDrawModeIds;
836  availDrawModeIds = availDrawModes_.getAtomicDrawModes();
837  for ( unsigned int i = 0; i < availDrawModeIds.size(); ++i )
838  {
839  QString descr = QString( availDrawModeIds[i].description().c_str() );
840 
841  if ( descr == _action->text() ) {
842  mode = availDrawModeIds[i];
843  break;
844  }
845  }
846 
847  //======================================================================================
848  // possibly combine draw modes
849  //======================================================================================
850  bool useGlobalDrawMode = false;
851  bool contextMenuStaysOpen = false;
852  if ( _action->text() != USEGLOBALDRAWMODE ) {
853 
854  // extract global draw mode in case we want to combine it with another draw mode
855  if(activeDrawModes_ == ACG::SceneGraph::DrawModes::DEFAULT) {
857  activeDrawModes_.combine(widgetDrawMode);
858  }
859 
860  // As this is not the global draw mode, filter out default as draw mode or it will interfere with the other modes!
861  activeDrawModes_.filter(ACG::SceneGraph::DrawModes::DEFAULT);
862 
863  // If shift is pressed, we combine the modes (and toggle therefore xor)
864  // Otherwise we directly take the new mode
865  if ( qApp->keyboardModifiers() & Qt::ShiftModifier ) {
866  if (activateDrawMode) {
867  activeDrawModes_.combine(mode); // explicit call to combine() states intent more clearly
868  } else {
869  if (activeDrawModes_ == mode) {
870  activeDrawModes_ = ACG::SceneGraph::DrawModes::DEFAULT;
871  useGlobalDrawMode = true;
872  } else {
873  activeDrawModes_.filter(mode);
874  }
875  }
876  contextMenuStaysOpen = true;
877  } else {
878  if (activateDrawMode) {
879  activeDrawModes_ = mode ;
880  } else {
881  activeDrawModes_ = ACG::SceneGraph::DrawModes::DEFAULT;
882  useGlobalDrawMode = true;
883  }
884  emit hideContextMenu();
885  }
886 
887  if (activeDrawModes_ == ACG::SceneGraph::DrawModes::DEFAULT) {
888  useGlobalDrawMode = true;
889  }
890 
891  } else {
892  // Switch back to global drawmode-> default
893  activeDrawModes_ = ACG::SceneGraph::DrawModes::DEFAULT;
894  useGlobalDrawMode = true;
895  }
896 
897  if (contextMenuStaysOpen) {
898  typedef std::map<QCheckBox*, ACG::SceneGraph::DrawModes::DrawMode> CBM;
900  for (CBM::iterator it = activeCheckboxes.begin(), it_end = activeCheckboxes.end(); it != it_end; ++it) {
901  it->first->blockSignals(true);
902  if (activeDrawModes_.containsAtomicDrawMode(it->second)) {
903  it->first->setCheckState(Qt::Checked);
904  } else if (useGlobalDrawMode && globalDrawModes.containsAtomicDrawMode(it->second)) {
905  it->first->setCheckState(Qt::PartiallyChecked);
906  } else {
907  it->first->setCheckState(Qt::Unchecked);
908  }
909  it->first->blockSignals(false);
910  }
911  }
912 
913  //======================================================================================
914  // Now do the update in the sceneGraph
915  //======================================================================================
916 
917  // Get the associated object
918  BaseObjectData* object = 0;
919  PluginFunctions::getObject( lastObjectId_, object );
920 
921  // Set draw Modes for this object ( force it when we do not set the global draw mode, to override global draw mode and force the modes on the nodes )
922  ACG::SceneGraph::SetDrawModesAction actionActive( activeDrawModes_ , !useGlobalDrawMode );
923 
924 
925  if ( object )
926  ACG::SceneGraph::traverse( object->primaryNode() , actionActive);
927  else
929 
930  emit updateView();
931 }
932 
933 void ViewControlPlugin::initShaderWidget(){
934 
935  //update the shader list
936 
937  updateShaderList();
938 
939  shaderWidget_->availableShaders->clear();
940 
941  for ( uint i = 0 ; i < shaderList_.size(); ++i ) {
942  shaderWidget_->availableShaders->addItem( shaderList_[i].name );
943  }
944 
945  shaderWidget_->availableShaders->setCurrentRow(0);
946  slotShaderClicked(shaderWidget_->availableShaders->currentItem());
947 
948 }
949 
950 void ViewControlPlugin::slotShaderClicked( QListWidgetItem * _item ){
951  int index = -1;
952  for ( int i = 0 ; i < (int)shaderList_.size(); ++i) {
953  if ( shaderList_[i].name == _item->text() ) {
954  index = i;
955  break;
956  }
957  }
958 
959  if ( index == -1 ) {
960  std::cerr << "Strange index Error! " << std::endl;
961  return;
962  }
963 
964  shaderWidget_->shaderName->setText( shaderList_[index].name );
965  shaderWidget_->description->setText( shaderList_[index].description );
966  shaderWidget_->details->setText( shaderList_[index].details );
967  shaderWidget_->version->setText( shaderList_[index].version );
968  shaderWidget_->vertexShader->setText( shaderList_[index].vertexShader );
969  shaderWidget_->fragmentShader->setText( shaderList_[index].fragmentShader );
970  shaderWidget_->pickVertexShader->setText( shaderList_[index].pickVertexShader );
971  shaderWidget_->pickFragmentShader->setText( shaderList_[index].pickFragmentShader );
972  shaderWidget_->example->setPixmap( QPixmap(shaderList_[index].example) );
973 
974  //get shader paths
975  QStringList shadersDirs = OpenFlipper::Options::shaderDir().entryList( QDir::Dirs| QDir::NoDotAndDotDot ,QDir::Name);
976  QString shaderDir = OpenFlipper::Options::shaderDirStr() + OpenFlipper::Options::dirSeparator();
977 
978  QString vertexFile = shaderDir + shadersDirs[ shaderWidget_->availableShaders->currentRow() ] +
979  OpenFlipper::Options::dirSeparator() + shaderWidget_->vertexShader->text();
980  QString fragmentFile = shaderDir + shadersDirs[ shaderWidget_->availableShaders->currentRow() ] +
981  OpenFlipper::Options::dirSeparator() + shaderWidget_->fragmentShader->text();
982 
983  //update drawMode checkStates
984  shaderWidget_->drawModes->clear();
985 
986  std::vector< ACG::SceneGraph::DrawModes::DrawMode > availDrawModeIds;
987  availDrawModeIds = availDrawModes_.getAtomicDrawModes( );
988 
989  for ( unsigned int i = 0; i < availDrawModeIds.size(); ++i )
990  {
991  ACG::SceneGraph::DrawModes::DrawMode id = availDrawModeIds[i];
992 
993 
994  std::vector< QString > dm = drawModeToDescriptions( id );
995 
996  if ( !dm.empty() && dm[0].trimmed() != ""){
997  QListWidgetItem* item = new QListWidgetItem(dm[0]);
998 
999  item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsUserCheckable | Qt::ItemIsSelectable);
1000 
1001  BaseObjectData* object = 0;
1002 
1003  PluginFunctions::getObject( lastObjectId_, object );
1004  if ( object && object->shaderNode() ){
1005  if ( object->shaderNode()->vertexShaderName( id ) == vertexFile.toStdString() &&
1006  object->shaderNode()->fragmentShaderName( id ) == fragmentFile.toStdString() )
1007  item->setCheckState( Qt::Checked );
1008  else
1009  {
1010  //std::cerr << "vertex:" << object->shaderNode()->vertexShaderName( id ) << ", this: " << vertexFile.toStdString() << std::endl;
1011  //std::cerr << "fragment:" << object->shaderNode()->fragmentShaderName( id ) << ", this: " << fragmentFile.toStdString() << std::endl;
1012  item->setCheckState( Qt::Unchecked );
1013  }
1014  }
1015  shaderWidget_->drawModes->addItem(item);
1016  }
1017  }
1018 
1019  if ( shaderList_[index].hasUniforms ) {
1020  //set up uniform table
1021  shaderWidget_->uniforms->clear();
1022  shaderWidget_->uniforms->setColumnCount ( 1 );
1023  shaderWidget_->uniforms->setRowCount ( shaderList_[index].uniforms.count() );
1024 
1025  shaderWidget_->uniforms->setHorizontalHeaderLabels( QStringList("Value") );
1026  shaderWidget_->uniforms->setVerticalHeaderLabels( shaderList_[index].uniforms );
1027 
1028  for (int i=0; i < shaderList_[index].uniforms.count(); i++){
1029  QTableWidgetItem* item = new QTableWidgetItem( shaderList_[index].uniformsDefault[i] );
1030  item->setFlags( Qt::ItemIsEditable | Qt::ItemIsSelectable | Qt::ItemIsEnabled);
1031  shaderWidget_->uniforms->setItem(i,0,item );
1032  }
1033 
1034  shaderWidget_->uniformBox->setVisible( true );
1035 
1036  }else
1037  shaderWidget_->uniformBox->setVisible( false );
1038 
1039  emit updateView();
1040 }
1041 
1042 void ViewControlPlugin::slotShaderDoubleClicked( QListWidgetItem * /*_item*/ ){
1043 // slotSetShader();
1044 }
1045 
1046 void ViewControlPlugin::itemChanged(QTableWidgetItem* item){
1047 
1048  //get current shader index
1049  int index = -1;
1050  for ( int i = 0 ; i < (int)shaderList_.size(); ++i) {
1051  if ( shaderList_[i].name == shaderWidget_->availableShaders->currentItem()->text() ) {
1052  index = i;
1053  break;
1054  }
1055  }
1056 
1057  if ( index == -1 ) {
1058  std::cerr << "Error: Shader Index not found! " << std::endl;
1059  return;
1060  }
1061 
1062 
1063  int row = item->row();
1064 
1065  if ( row > shaderList_[index].uniforms.count() ){
1066  std::cerr << "Error: uniform index out of bounds" << std::endl;
1067  return;
1068  }
1069 
1070  //handle different datatypes
1071  if (shaderList_[index].uniformTypes[row] == "float"){
1072  bool ok;
1073 
1074  float value = item->text().toFloat(&ok);
1075 
1076  if (!ok)
1077  item->setText( shaderList_[index].uniformsDefault[row] );
1078  else if (shaderList_[index].uniformsDefault[row] != shaderList_[index].uniformsMin[row]
1079  && value < shaderList_[index].uniformsMin[row].toFloat())
1080  item->setText( shaderList_[index].uniformsMin[row] );
1081  else if (shaderList_[index].uniformsDefault[row] != shaderList_[index].uniformsMin[row]
1082  && value > shaderList_[index].uniformsMax[row].toFloat())
1083  item->setText( shaderList_[index].uniformsMax[row] );
1084  }
1085 
1086 }
1087 
1088 void ViewControlPlugin::slotSetShader()
1089 {
1090 
1091  //get current shader index
1092  int index = -1;
1093  for (int i = 0; i < (int) shaderList_.size(); ++i) {
1094  if (shaderList_[i].name == shaderWidget_->availableShaders->currentItem()->text()) {
1095  index = i;
1096  break;
1097  }
1098  }
1099 
1100  if (index == -1) {
1101  std::cerr << "Error: Shader Index not found! " << std::endl;
1102  return;
1103  }
1104 
1105  std::vector<QString> mode;
1106  for (int i = 0; i < shaderWidget_->drawModes->count(); i++) {
1107  if (shaderWidget_->drawModes->item(i)->checkState() == Qt::Checked) {
1108  mode.push_back(shaderWidget_->drawModes->item(i)->text());
1109  setShader(lastObjectId_, descriptionsToDrawMode(mode), shaderList_[index]);
1110  mode.clear();
1111  } else {
1112  mode.push_back(shaderWidget_->drawModes->item(i)->text());
1113  disableShader(lastObjectId_, descriptionsToDrawMode(mode), &shaderList_[index]);
1114  mode.clear();
1115  }
1116  }
1117 }
1118 
1120  int _objectId,
1122  ShaderInfo* _shader)
1123 {
1124 
1125  BaseObjectData* object = 0;
1126  PluginFunctions::getObject(_objectId, object);
1127 
1128  if (object) {
1129  if (!_shader)
1130  object->shaderNode()->disableShader(_drawMode);
1131  else {
1132  std::string shadeDir = _shader->directory.toStdString() + OpenFlipper::Options::dirSeparator().toStdString();
1133 
1134  if (object->shaderNode()->vertexShaderName(_drawMode) == shadeDir + _shader->vertexShader.toStdString()
1135  && object->shaderNode()->fragmentShaderName(_drawMode) == shadeDir + _shader->fragmentShader.toStdString())
1136  object->shaderNode()->disableShader(_drawMode);
1137  }
1138  }
1139 
1140  emit updateView();
1141 }
1142 
1144 
1145  if ( OpenFlipper::Options::nogui() )
1146  return;
1147 
1148  BaseObjectData* object = 0;
1149  PluginFunctions::getObject( _id, object );
1150 
1151  //get shader paths
1152  QFileInfo vertexFile (_shader.name + OpenFlipper::Options::dirSeparator() + _shader.vertexShader);
1153  QFileInfo fragmentFile (_shader.name + OpenFlipper::Options::dirSeparator() + _shader.fragmentShader);
1154  QFileInfo pickVertexFile (_shader.name + OpenFlipper::Options::dirSeparator() + _shader.pickVertexShader);
1155  QFileInfo pickFragmentFile (_shader.name + OpenFlipper::Options::dirSeparator() + _shader.pickFragmentShader);
1156 
1157  if ( object && object->shaderNode()
1158  && _shader.vertexShader.length() && _shader.fragmentShader.length()) {
1159 
1160  if (vertexFile.absolutePath() != fragmentFile.absolutePath()) {
1161  emit log(LOGERR, "Cannot set shader. Currently shader files have to be in the same folder.");
1162  return;
1163  }
1164 
1165  if (_shader.pickVertexShader.length() && _shader.pickFragmentShader.length())
1166  {
1167  if (vertexFile.absolutePath() != pickVertexFile.absolutePath() ||
1168  vertexFile.absolutePath() != pickFragmentFile.absolutePath()) {
1169  emit log(LOGERR, "Cannot set picking shader. Currently shader files have to be in the same folder.");
1170  return;
1171  }
1172 
1173  object->shaderNode()->setShaderDir( (_shader.directory + OpenFlipper::Options::dirSeparator()).toStdString() );
1174 
1175  object->shaderNode()->setShader(_drawMode,
1176  vertexFile.fileName().toStdString(),
1177  fragmentFile.fileName().toStdString(),
1178  pickVertexFile.fileName().toStdString(),
1179  pickFragmentFile.fileName().toStdString());
1180  }
1181  else
1182  {
1183  object->shaderNode()->setShaderDir( (_shader.directory + OpenFlipper::Options::dirSeparator()).toStdString() );
1184  object->shaderNode()->setShader(_drawMode, vertexFile.fileName().toStdString(), fragmentFile.fileName().toStdString());
1185  }
1186  }
1187 
1188 
1189  // set uniforms if available
1190  if (_shader.hasUniforms) {
1191  GLSL::PtrProgram shader = object->shaderNode()->getShader( _drawMode );
1192  if ( shader == 0 ) {
1193  std::cerr << "Error: Unable to get shader for shader mode" << std::endl;
1194  } else {
1195  shader->use();
1196 
1197  for (int u=0; u < _shader.uniforms.count(); u++) {
1198  //float uniforms
1199  if (_shader.uniformTypes[u] == "float" ) {
1200  shaderWidget_->uniforms->setCurrentCell(u,0);
1201  float value = shaderWidget_->uniforms->currentItem()->text().toFloat();
1202  shader->setUniform(_shader.uniforms[u].toUtf8(), value);
1203  } else
1204  //vec3 uniforms
1205  if (_shader.uniformTypes[u] == "vec3" ) {
1206  shaderWidget_->uniforms->setCurrentCell(u,0);
1207  QStringList vecStr = shaderWidget_->uniforms->currentItem()->text().split(",");
1208  if (vecStr.count() == 3) {
1209  ACG::Vec3f value( vecStr[0].toFloat(), vecStr[1].toFloat(), vecStr[2].toFloat() );
1210  shader->setUniform(_shader.uniforms[u].toUtf8(), value);
1211  }
1212  } else
1213  std::cerr << "Error: handling of uniformType '" << _shader.uniformTypes[u].toStdString() << "' not yet implemented" << std::endl;
1214 
1215  }
1216 
1217  shader->disable();
1218  }
1219  }
1220 
1221  emit updateView();
1222 }
1223 
1224 void ViewControlPlugin::setShader(int _id, QString _drawMode, QString _name ){
1225 
1226  if ( OpenFlipper::Options::nogui() )
1227  return;
1228 
1229  updateShaderList();
1230 
1231  //get current shader index
1232  int index = -1;
1233  for ( int i = 0 ; i < (int)shaderList_.size(); ++i) {
1234  if ( shaderList_[i].name == _name ) {
1235  index = i;
1236  break;
1237  }
1238  }
1239 
1240  if ( index == -1 ) {
1241  std::cerr << "Error: Shader not found! " << std::endl;
1242  return;
1243  }
1244 
1245  std::vector <QString> mode;
1246  mode.push_back(_drawMode);
1247 
1248  setShader(_id, listToDrawMode(mode), shaderList_[index]);
1249 }
1250 
1251 //-----------------------------------------------------------------------------
1252 
1253 QStringList ViewControlPlugin::getUniforms(QString _shader){
1254  for (uint i=0; i < shaderList_.size(); i++)
1255  if ( shaderList_[i].name == _shader)
1256  return shaderList_[i].uniforms;
1257 
1258  return QStringList();
1259 }
1260 
1261 QString ViewControlPlugin::getUniformType(QString _shader, QString _uniform ){
1262 
1263  for (uint i=0; i < shaderList_.size(); i++)
1264  if ( shaderList_[i].name == _shader){
1265 
1266  for (int u=0; u < shaderList_[i].uniforms.count(); u++)
1267  if ( shaderList_[i].uniforms[u] == _uniform )
1268  return shaderList_[i].uniformTypes[u];
1269  }
1270 
1271  return QString();
1272 }
1273 
1274 QString ViewControlPlugin::getUniformDefault(QString _shader, QString _uniform ){
1275 
1276  for (uint i=0; i < shaderList_.size(); i++)
1277  if ( shaderList_[i].name == _shader){
1278 
1279  for (int u=0; u < shaderList_[i].uniforms.count(); u++)
1280  if ( shaderList_[i].uniforms[u] == _uniform )
1281  return shaderList_[i].uniformsDefault[u];
1282  }
1283 
1284  return QString();
1285 }
1286 
1287 QString ViewControlPlugin::getUniformMin(QString _shader, QString _uniform ){
1288 
1289  for (uint i=0; i < shaderList_.size(); i++)
1290  if ( shaderList_[i].name == _shader){
1291 
1292  for (int u=0; u < shaderList_[i].uniforms.count(); u++)
1293  if ( shaderList_[i].uniforms[u] == _uniform )
1294  return shaderList_[i].uniformsMin[u];
1295  }
1296 
1297  return QString();
1298 }
1299 
1300 QString ViewControlPlugin::getUniformMax(QString _shader, QString _uniform ){
1301 
1302  for (uint i=0; i < shaderList_.size(); i++)
1303  if ( shaderList_[i].name == _shader){
1304 
1305  for (int u=0; u < shaderList_[i].uniforms.count(); u++)
1306  if ( shaderList_[i].uniforms[u] == _uniform )
1307  return shaderList_[i].uniformsMax[u];
1308  }
1309 
1310  return QString();
1311 }
1312 
1313 //-----------------------------------------------------------------------------
1314 
1316 void ViewControlPlugin::setUniform(int _objID, ACG::SceneGraph::DrawModes::DrawMode _drawMode, QString _shader, QString _uniform, QString _value ){
1317 
1318  BaseObjectData* object = 0;
1319 
1320  PluginFunctions::getObject( _objID, object );
1321  if ( object && object->shaderNode() ){
1322 
1323  for (uint i=0; i < shaderList_.size(); i++)
1324  if ( shaderList_[i].name == _shader){
1325 
1326  // set uniforms if available
1327  if (shaderList_[i].hasUniforms){
1328  GLSL::PtrProgram shader = object->shaderNode()->getShader( _drawMode );
1329  if ( shader == 0 ) {
1330  std::cerr << "Error: Unable to get shader for shader mode" << std::endl;
1331  } else {
1332  shader->use();
1333 
1334  for (int u=0; u < shaderList_[i].uniforms.count(); u++){
1335 
1336  //only apply to uniform which was given as param
1337  if ( shaderList_[i].uniforms[u] != _uniform )
1338  continue;
1339 
1340  //float uniforms
1341  if (shaderList_[i].uniformTypes[u] == "float" )
1342  shader->setUniform(shaderList_[i].uniforms[u].toUtf8(), _value.toFloat() );
1343 
1344  //vec3 uniforms
1345  else if (shaderList_[i].uniformTypes[u] == "vec3" ){
1346  QStringList vecStr = _value.split(",");
1347  if (vecStr.count() == 3){
1348  ACG::Vec3f value( vecStr[0].toFloat(), vecStr[1].toFloat(), vecStr[2].toFloat() );
1349  shader->setUniform(shaderList_[i].uniforms[u].toUtf8(), value);
1350  }
1351  }else
1352  std::cerr << "Error: handling of uniformType '" << shaderList_[i].uniformTypes[u].toStdString() << "' not yet implemented" << std::endl;
1353  }
1354 
1355  shader->disable();
1356  }
1357  }
1358  }
1359  }
1360 }
1361 
1362 //-----------------------------------------------------------------------------
1363 
1364 void ViewControlPlugin::setViewingDirection( Vector _direction, Vector _upvector , int _viewer){
1365  PluginFunctions::viewingDirection(_direction, _upvector, _viewer);
1366 }
1367 
1368 //-----------------------------------------------------------------------------
1369 
1370 void ViewControlPlugin::setSceneRadius( double _radius , int _viewer){
1371  PluginFunctions::setSceneRadius(_radius, _viewer);
1372 }
1373 
1374 //-----------------------------------------------------------------------------
1375 
1376 void ViewControlPlugin::rotate( Vector _axis, double _angle, Vector _center , int _viewer) {
1377  PluginFunctions::rotate( _axis, _angle, _center ,_viewer);
1378 }
1379 
1380 //-----------------------------------------------------------------------------
1381 
1382 void ViewControlPlugin::translate( Vector _vec , int _viewer) {
1383  PluginFunctions::translate( _vec ,_viewer);
1384 }
1385 
1386 
1387 void ViewControlPlugin::enableBackfaceCulling( bool _state , int _viewer ) {
1388  if ( _viewer == PluginFunctions::ALL_VIEWERS )
1389  for ( int i = 0 ; i < PluginFunctions::viewers( ); ++i )
1391  else if ( _viewer == PluginFunctions::ACTIVE_VIEWER )
1393  else if ( _viewer >= 0 && _viewer < PluginFunctions::viewers( ) )
1395  else
1396  std::cerr << "Illegal viewer requested! " << std::endl;
1397 
1398 }
1399 
1400 
1401 //-----------------------------------------------------------------------------
1402 
1403 void
1404 ViewControlPlugin::setDrawMode(QString _mode, int _viewer)
1405 {
1406 
1407  QStringList list = _mode.split(';');
1408 
1409  std::vector< QString > drawModeList;
1410 
1411  for ( int i = 0 ; i < list.size() ; ++i )
1412  drawModeList.push_back(list[i]);
1413 
1414  ACG::SceneGraph::DrawModes::DrawMode mode = listToDrawMode(drawModeList);
1415 
1416  PluginFunctions::setDrawMode( mode , _viewer );
1417  emit updateView();
1418 }
1419 
1420 //-----------------------------------------------------------------------------
1421 
1422 void
1423 ViewControlPlugin::setObjectDrawMode(QString _mode, int _objectID, bool _force)
1424 {
1425  BaseObjectData* object = 0;
1426  PluginFunctions::getObject( _objectID, object );
1427 
1428  QStringList list = _mode.split(';');
1429 
1430  std::vector< QString > drawModeList;
1431 
1432  for ( int i = 0 ; i < list.size() ; ++i )
1433  drawModeList.push_back(list[i]);
1434 
1435  ACG::SceneGraph::DrawModes::DrawMode mode = listToDrawMode(drawModeList);
1436 
1437  // Set draw Modes for this object ( force it when we do not set the global draw mode, to override global draw mode and force the modes on the nodes )
1438  ACG::SceneGraph::SetDrawModesAction actionActive( mode , _force );
1439 
1440  if ( object )
1441  ACG::SceneGraph::traverse( object->primaryNode() , actionActive);
1442 }
1443 
1444 //-----------------------------------------------------------------------------
1445 
1447  return PluginFunctions::viewingDirection(_viewer);
1448 }
1449 
1451  return PluginFunctions::upVector(_viewer);
1452 }
1453 
1455  return PluginFunctions::eyePos(_viewer);
1456 }
1457 
1458 void ViewControlPlugin::setSceneCenter( Vector _center, int _viewer ) {
1459  PluginFunctions::setScenePos(_center, _viewer);
1460 }
1461 
1463  return PluginFunctions::sceneCenter(_viewer);
1464 }
1465 
1466 //-----------------------------------------------------------------------------
1467 
1468 void ViewControlPlugin::setView(int _mode, int _viewer ) {
1469 
1470  switch ( _mode ){
1471  case PluginFunctions::VIEW_TOP : //TOP
1472  setViewingDirection( ACG::Vec3d(0.0, -1.0, 0.0), ACG::Vec3d(0.0, 0.0, -1.0), _viewer );
1473  break;
1474  case PluginFunctions::VIEW_BOTTOM : //BOTTOM
1475  setViewingDirection( ACG::Vec3d(0.0, 1.0, 0.0), ACG::Vec3d(0.0, 0.0, -1.0), _viewer );
1476  break;
1477  case PluginFunctions::VIEW_LEFT : //LEFT
1478  setViewingDirection( ACG::Vec3d(1.0, 0.0, 0.0), ACG::Vec3d(0.0, 1.0, 0.0), _viewer );
1479  break;
1480  case PluginFunctions::VIEW_RIGHT : //RIGHT
1481  setViewingDirection( ACG::Vec3d(-1.0, 0.0, 0.0), ACG::Vec3d(0.0, 1.0, 0.0), _viewer );
1482  break;
1483  case PluginFunctions::VIEW_FRONT : //FRONT
1484  setViewingDirection( ACG::Vec3d(0.0, 0.0, -1.0), ACG::Vec3d(0.0, 1.0, 0.0), _viewer );
1485  break;
1486  case PluginFunctions::VIEW_BACK : //BACK
1487  setViewingDirection( ACG::Vec3d(0.0, 0.0, 1.0), ACG::Vec3d(0.0, 1.0, 0.0), _viewer );
1488  break;
1489  default :
1490  emit log(LOGERR, "ViewControl: Unknown view mode: " + QString::number(_mode));
1491  break;
1492  }
1493 
1494  updateView();
1495 }
1496 
1497 //-----------------------------------------------------------------------------
1498 
1499 void ViewControlPlugin::setView(QAction* _action) {
1500 
1501  if ( _action == viewTop_) setView (PluginFunctions::VIEW_TOP, PluginFunctions::ACTIVE_VIEWER);
1502  else if ( _action == viewBottom_) setView (PluginFunctions::VIEW_BOTTOM, PluginFunctions::ACTIVE_VIEWER);
1503  else if ( _action == viewLeft_) setView (PluginFunctions::VIEW_LEFT, PluginFunctions::ACTIVE_VIEWER);
1504  else if ( _action == viewRight_) setView (PluginFunctions::VIEW_RIGHT, PluginFunctions::ACTIVE_VIEWER);
1505  else if ( _action == viewFront_) setView (PluginFunctions::VIEW_FRONT, PluginFunctions::ACTIVE_VIEWER);
1506  else if ( _action == viewBack_) setView (PluginFunctions::VIEW_BACK, PluginFunctions::ACTIVE_VIEWER);
1507  else emit log(LOGERR, "ViewControl: Unknown view mode action!");
1508 }
1509 
1510 //-----------------------------------------------------------------------------
1511 
1512 void ViewControlPlugin::setEyePosition(Vector _eye){
1514  PluginFunctions::sceneCenter(PluginFunctions::ACTIVE_VIEWER),
1515  PluginFunctions::upVector(PluginFunctions::ACTIVE_VIEWER),
1516  PluginFunctions::ACTIVE_VIEWER);
1517 }
1518 
1519 
1522 }
1523 
1524 void ViewControlPlugin::viewAll(int _viewer) {
1525  PluginFunctions::viewAll(_viewer);
1526 }
1527 
1530 }
1531 
1532 void ViewControlPlugin::viewHome(int _viewer) {
1533  PluginFunctions::viewHome(_viewer);
1534 }
1535 
1538 }
1539 
1542 }
1543 
1544 
1547 }
1548 
1551 }
1552 
1553 void ViewControlPlugin::setFOVY( double _fovy ) {
1554  PluginFunctions::setFOVY(_fovy);
1555 
1556  emit updateView();
1557 }
1558 
1560 
1561  // Find coordsys node
1562  ACG::SceneGraph::BaseNode* node = 0;
1563  node = PluginFunctions::getSceneGraphRootNode()->find("Core Coordsys Node");
1564  if (node != 0) {
1565  ACG::SceneGraph::CoordsysNode* cnode = dynamic_cast<ACG::SceneGraph::CoordsysNode*> (node);
1567  if ( _orthogonal) {
1569  emit updateView();
1570  }
1571  } else {
1572  if ( !_orthogonal) {
1574  emit updateView();
1575  }
1576  }
1577 
1578  } else {
1579  emit log(LOGERR,tr("setCoordsysProjection(): Could not find coordsys node, thus its projection mode will not be toggled."));
1580  }
1581 
1582 }
1583 
1584 void ViewControlPlugin::setTwoSidedLighting(bool _enabled) {
1586 }
1587 
1590  return state.project(_point);
1591 }
1592 
1593 void ViewControlPlugin::setDescriptions() {
1594  emit setSlotDescription("translate(Vector,int)", "Translate Scene",
1595  QString("TranslationVector,Viewer").split(","),
1596  QString("vector for the translation.,Viewer id (default is all)").split(","));
1597  emit setSlotDescription("translate(Vector)", "Translate Scene in all Viewers",
1598  QString("TranslationVector").split(","),
1599  QString("vector for the translation.").split(","));
1600  emit setSlotDescription("rotate(Vector,double,Vector,int)", "Rotate Scene",
1601  QString("Axis,Angle,Center,Viewer").split(","),
1602  QString("Rotation axis., Rotation Angle., Rotation Center.").split(","));
1603  emit setSlotDescription("rotate(Vector,double,Vector)", "Rotate Scene in all viewers",
1604  QString("Axis,Angle,Center").split(","),
1605  QString("Rotation axis., Rotation Angle., Rotation Center.").split(","));
1606  emit setSlotDescription("setViewingDirection(Vector,Vector,int)", "Set the viewing direction",
1607  QString("direction,upVector,Viewer").split(","),
1608  QString("Viewing direction., Up-Vector.,Viewer id (default is all)").split(","));
1609  emit setSlotDescription("setViewingDirection(Vector,Vector)", "Set the viewing direction in all viewers",
1610  QString("direction,upVector").split(","),
1611  QString("Viewing direction., Up-Vector.").split(","));
1612  emit setSlotDescription("setDrawMode(QString,int)", "Set the drawMode",
1613  QString("DrawMode,Viewer").split(","),
1614  QString("the drawMode ( ; separated list ),Viewer id (default is all)").split(","));
1615  emit setSlotDescription("setDrawMode(QString)", "Set the drawMode for all viewers",
1616 
1617  QStringList("DrawMode"), QStringList("the drawMode ( ; separated list )"));
1618 
1619  emit setSlotDescription("setObjectDrawMode(QString,int,bool)", "Set the drawMode for an object",
1620  QString("DrawMode,ObjectID,Force").split(","),
1621  QString("the drawMode ( ; separated list ),Object id,Apply without checking support(default is true)").split(","));
1622 
1623  emit setSlotDescription("viewAll()", "Change View on all viewers to view whole scene",
1624  QStringList(), QStringList());
1625  emit setSlotDescription("viewAll(int)", "Change View on given viewer to view whole scene",
1626  QStringList("Viewer"), QStringList("Id of the viewer to change"));
1627 
1628  emit setSlotDescription("viewHome()", "Change View on all viewers to view home position",
1629  QStringList(), QStringList());
1630  emit setSlotDescription("viewHome(int)", "Change View on given viewer to view home position",
1631  QStringList("Viewer"), QStringList("Id of the viewer to change"));
1632 
1633 
1634  emit setSlotDescription("orthographicProjection()", "Change Viewer to orthographic projection",
1635  QStringList(), QStringList());
1636  emit setSlotDescription("orthographicProjection(int)", "Change all Viewers to orthographic projection",
1637  QStringList("Viewer"), QStringList("Id of the viewer to change"));
1638 
1639 
1640  emit setSlotDescription("perspectiveProjection()", "Change Viewer to perspective projection",
1641  QStringList(), QStringList());
1642  emit setSlotDescription("perspectiveProjection(int)", "Change all Viewers to perspective projection",
1643  QStringList("Viewer"), QStringList("Id of the viewer to change"));
1644 
1645  emit setSlotDescription("setFOVY(double)", "Set fovy angle of projection for all viewers.",
1646  QStringList("fovy"), QStringList("FOVY angle"));
1647 
1648  emit setSlotDescription("setCoordsysProjection(bool)", "Set the projection mode of the coordinate system.",
1649  QStringList("orthogonal"), QStringList("If true, orthogonal projection otherwise perspective projection"));
1650 
1651  emit setSlotDescription("upVector()", "Get the current upVector.",
1652  QStringList(), QStringList());
1653 
1654  emit setSlotDescription("upVector(int)", "Get the current upVector of a specific viewer.",
1655  QStringList("ViewerId"), QStringList("Id of the viewer"));
1656 
1657  emit setSlotDescription("eyePosition()", "Get the current eyePosition.",
1658  QStringList(), QStringList());
1659 
1660  emit setSlotDescription("eyePosition(int)", "Get the current eyePosition of a specific viewer.",
1661  QStringList("ViewerId"), QStringList("Id of the viewer"));
1662 
1663  emit setSlotDescription("sceneCenter()", "Get the current sceneCenter.",
1664  QStringList(), QStringList());
1665 
1666  emit setSlotDescription("sceneCenter(int)", "Get the current sceneCenter of a specific viewer.",
1667  QStringList("ViewerId"), QStringList("Id of the viewer"));
1668 
1669  emit setSlotDescription("viewingDirection()", "Get the current viewingDirection.",
1670  QStringList(), QStringList());
1671 
1672  emit setSlotDescription("viewingDirection(int)", "Get the current viewingDirection of a specific viewer.",
1673  QStringList("ViewerId"), QStringList("Id of the viewer"));
1674 
1675  emit setSlotDescription("setTwoSidedLighting(bool)", "Enable or disable two sided lighting.",
1676  QStringList("enabled"), QStringList("Specifies whether to enable or disable two sided lighting."));
1677 
1678 }
1679 
1680 
1681 
DLLEXPORT std::vector< TypeInfo >::const_iterator typesEnd()
Get iterator pointing to the last element in the types list.
Definition: Types.cc:185
DrawModes::DrawMode drawModes() const
Get the collected draw modes.
Definition: SceneGraph.hh:582
void viewHome(int _viewer)
Go to home position.
bool areaVisible(StatusBits _bit)
Return if the selected areas are currently visible.
void setScenePos(const ACG::Vec3d &_center, const double _radius, int _viewer)
Set the Scene position.
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
void orthographicProjection()
Change Viewer to orthographicProjection.
#define DATA_TRIANGLE_MESH
Definition: TriangleMesh.hh:60
void showModelingAreas(int _id, bool _state)
Allows to enable/disable visualization of the objects modeling area for meshes.
Vector viewingDirection(int _viewer=PluginFunctions::ACTIVE_VIEWER)
Get a viewers viewing direction.
void hideSelection(bool _hide)
Hide or show the selection Node of the object.
#define DATA_POLY_MESH
Definition: PolyMesh.hh:59
void viewingDirection(const ACG::Vec3d &_dir, const ACG::Vec3d &_up, int _viewer)
Set the viewing direction.
Vector sceneCenter(int _viewer=PluginFunctions::ACTIVE_VIEWER)
Get the scene center.
void twoSidedLighting(bool _state)
set 2-sided lighting on/off
void use()
Enables the program object for using.
Definition: GLSLShader.cc:345
void disconnect()
Remove connection of this object to a file.
Definition: INIFile.cc:122
Type for a Meshobject containing a poly mesh.
Definition: PolyMesh.hh:65
Vector eyePosition(int _viewer=PluginFunctions::ACTIVE_VIEWER)
get a viewers eye Position
void hideFeatures(bool _hide)
Hide or show the feature Node of the object.
void setDrawMode(QString _mode, int _viewer=PluginFunctions::ALL_VIEWERS)
Set the draw mode for a viewer.
bool containsAtomicDrawMode(const DrawMode &_atomicDrawMode) const
Check whether an Atomic DrawMode is active in this draw Mode.
Definition: DrawModes.cc:512
Vec3d project(const Vec3d &_point) const
project point in world coordinates to window coordinates
Definition: GLState.cc:640
ACG::Vec3d upVector(int _viewer)
Get the current up vector.
void viewAll()
Change View on all viewers to view whole scene.
bool getObject(const int _identifier, BaseObject *&_object)
Get the object which has the given identifier.
DrawModes::DrawMode drawMode() const
Get the collected draw modes.
Definition: SceneGraph.hh:613
const ACG::Vec3d sceneCenter(int _viewer)
Get the current scene center.
void showAreas(StatusBits _bits, int _id, bool _state)
Show or hide modeling areas.
void disableShader(DrawModes::DrawMode _drawmode)
Definition: ShaderNode.cc:262
void viewHome()
Change View on given Viewer to view home position.
ACG::SceneGraph::BaseNode * getSceneGraphRootNode()
get scenegraph root node
void setProjectionMode(const ProjectionMode _mode)
set mode to either ORTHOGRAPHIC_PROJECTION or PERSPECTIVE_PROJECTION
void enableBackfaceCulling(bool _state, int _viewer=PluginFunctions::ALL_VIEWERS)
Enable or disable Backface culling.
ACG::SceneGraph::DrawModes::DrawMode drawMode(int _viewer)
Get the current draw Mode of a Viewer.
bool get_entry(QString &_val, const QString &_section, const QString &_key) const
Access to a string entry.
Definition: INIFile.cc:433
void setFeatureLineWidth(int _id, double _width)
Set the line width of the features.
void hideArea(StatusBits _bit, bool _hide)
Hide or show the area Nodes of the object.
unsigned int activeExaminer()
Get the id of the examiner which got the last mouse events.
void setFOVY(double _fovy)
Set fovy angle of projection.
ACG::SceneGraph::StatusNodeT< MeshT, FeatureNodeMod< MeshT > > * featureNode()
Returns the feature selection node if available, nullptr otherwise.
Definition: MeshObjectT.hh:278
bool backFaceCulling()
Get current state of backface culling.
QStringList getUniforms(QString _shader)
get information about available uniforms for a given shader
bool dataType(DataType _type) const
Definition: BaseObject.cc:221
void setSelectionLineWidth(int _id, double _width)
Set the line width of the selections.
void disableShader(int _objectId, ACG::SceneGraph::DrawModes::DrawMode _drawMode, ShaderInfo *_shader=0)
virtual BaseNode * primaryNode()
void setObjectDrawMode(QString _mode, int _objectID, bool _force=true)
Set the draw mode for an object.
bool selectionVisible(int _id)
For meshes returns if the selection for this object is visible.
DrawMode DEFAULT
use the default (global) draw mode and not the node&#39;s own.
Definition: DrawModes.cc:72
GLSL program class.
Definition: GLSLShader.hh:211
void rotate(const ACG::Vec3d &_axis, const double _angle, const ACG::Vec3d &_center, int _viewer)
Rotate Scene around axis.
int viewers()
Get the number of viewers.
bool selectionVisible()
return if the selections are currently visible
void perspectiveProjection(int _viewer)
Switch to perspective Projection.
bool featuresVisible()
return if the feature Node of the object is currently visible
PolyMeshObject * polyMeshObject(BaseObjectData *_object)
Cast an BaseObject to a PolyMeshObject if possible.
ACG::Vec3d eyePos(int _viewer)
Get the current viewer position.
void setUniform(const char *_name, GLint _value)
Set int uniform to specified value.
Definition: GLSLShader.cc:385
ACG::Vec3d project(ACG::Vec3d _point, int _viewerId=0)
Use the projection matrix of the given viewer to project the point.
void disable()
Resets to standard rendering pipeline.
Definition: GLSLShader.cc:355
TriMeshObject * triMeshObject(BaseObjectData *_object)
Cast an BaseObject to a TriMeshObject if possible.
Type for a MeshObject containing a triangle mesh.
Definition: TriangleMesh.hh:67
void filter(DrawMode _filter)
filter out one drawmode
Definition: DrawModes.cc:455
void showSelection(int _id, bool _state)
Allows to enable/disable visualization of the objects selection for meshes.
void rotate(Vector _axis, double _angle, Vector _center, int _viewer=PluginFunctions::ALL_VIEWERS)
Rotate Scene.
bool areasVisible(StatusBits _bits, int _id)
Return of all of the given modeling areas are visible.
void setShader(int _id, ACG::SceneGraph::DrawModes::DrawMode _drawMode, ShaderInfo _shader)
bool modelingAreasVisible(int _id)
For meshes returns if the modeling areas for this object is visible.
void setCoordsysProjection(bool _orthogonal)
void lookAt(const ACG::Vec3d &_eye, const ACG::Vec3d &_center, const ACG::Vec3d &_up, int _viewer)
Set the look at transformation directly.
void setSceneCenter(Vector _center, int _viewer=PluginFunctions::ALL_VIEWERS)
Set the scene center.
void perspectiveProjection()
Change Viewer to perspectiveProjection.
void setDrawMode(const ACG::SceneGraph::DrawModes::DrawMode &_mode, int _viewer)
Set the draw Mode of a Viewer. .
void setViewingDirection(Vector _direction, Vector _upvector, int _viewer=PluginFunctions::ALL_VIEWERS)
Set the viewing direction.
void setSceneRadius(double _radius, int _viewer)
Set the background color of the examiner widget.
Class for the handling of simple configuration files.
Definition: INIFile.hh:99
bool connect(const QString &name, const bool create)
Connect INIFile object with given filename.
Definition: INIFile.cc:70
Viewer::ViewerProperties & viewerProperties(int _id)
Get the viewer properties Use this functions to get basic viewer properties such as backgroundcolor o...
void setSceneRadius(double _radius, int _viewer=PluginFunctions::ALL_VIEWERS)
Set scene radius.
void setFOVY(double _fovy)
Set field of view angle.
virtual ACG::SceneGraph::ShaderNode * shaderNode()
ChildIter find(BaseNode *_node)
Definition: BaseNode.hh:346
void translate(const ACG::Vec3d &_vector, int _viewer)
Translate viewer pos by given vector.
void translate(Vector _vec, int _viewer=PluginFunctions::ALL_VIEWERS)
translate Scene
DLLEXPORT std::vector< TypeInfo >::const_iterator typesBegin()
Get iterator pointing to the first element in the types list.
Definition: Types.cc:180
Vector upVector(int _viewer=PluginFunctions::ACTIVE_VIEWER)
get a viewers up vector
void orthographicProjection(int _viewer)
Switch to orthographic Projection.
The Menu will be shown when an object was picked.
ProjectionMode getProjectionMode() const
get current projection mode
void traverse(BaseNode *_node, Action &_action)
Definition: SceneGraph.hh:137
ACG::SceneGraph::SelectionNodeT< MeshT > * statusNode()
Definition: MeshObjectT.hh:266
ACG::GLState & glState()
Get the glState of the Viewer.
void viewAll(int _viewer)
View the whole scene.