Developer Documentation
PluginFunctions.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 * $Revision$ *
45 * $LastChangedBy$ *
46 * $Date$ *
47 * *
48 \*===========================================================================*/
49 
50 
51 
52 
53 //=============================================================================
54 //
55 // Plugin Functions
56 //
57 //=============================================================================
58 
61 //#include <QGLWidget>
62 
63 #include <../ObjectTypes/TriangleMesh/TriangleMesh.hh>
64 #include <../ObjectTypes/PolyMesh/PolyMesh.hh>
65 
66 #include "PluginFunctionsCore.hh"
67 
68 namespace PluginFunctions {
69 
74 static BaseObject* objectRoot_ = 0;
75 
80 static std::vector< glViewer* > examiner_widgets_;
81 
86 static std::vector< Viewer::ViewerProperties* > viewerProperties_;
87 
89 static glViewer* examiner_widget_;
90 
92 static unsigned int activeExaminer_ = 0;
93 
94 static bool internalLightHandling_ = true;
95 
102 static SeparatorNode* dataRootNode_ = 0;
103 
107 static SeparatorNode* dataSeparatorNode_ = 0;
108 
111 static SeparatorNode* sceneGraphRootNodeGlobal_ = 0;
112 
115 static SeparatorNode* sceneGraphRootNode_ = 0;
116 
120 static Viewer::ViewerProperties dummyProperties(-1);
121 
122 
127 static ViewObjectMarker* defaultMarker_ = 0;
128 
133 static QGLWidget* shareGLWidget_ = 0;
134 
137 static int viewerId_ = 0;
138 
140 static int objectCounter_ = 0;
141 
143 static int targetCounter_ = 0;
144 
146 static std::map<int, BaseObject*> objectMap_;
147 
149 QMap< std::string ,ACG::QtWidgets::SceneGraphWidgetGenerator* > sceneGraphGenerators_;
150 
151 void setDataRoot( BaseObject* _root ) {
152  objectRoot_ = _root;
153 }
154 
155 int viewers( ) {
156  return examiner_widgets_.size();
157 }
158 
160  internalLightHandling_ = false;
161 }
162 
164  return internalLightHandling_;
165 }
166 
167 int viewerId() {
168  return viewerId_;
169 }
170 
171 void setViewers( std::vector< glViewer* > _viewerWidgets ) {
172  PluginFunctions::examiner_widgets_ = _viewerWidgets;
173  PluginFunctions::examiner_widget_ = examiner_widgets_[0];
174 
175  // Generate a (hopefully) unique viewer id
176  QTime time = QTime::currentTime();
177  qsrand( time.hour() * 10 + time.minute() * 100 + time.second() * 1000 + time.msec() * 10000 );
178  viewerId_ = qrand();
179 }
180 
181 void setViewerProperties( std::vector< Viewer::ViewerProperties* > _viewerProperties ) {
182  PluginFunctions::viewerProperties_ = _viewerProperties;
183 }
184 
185 void setActiveExaminer( const unsigned int _id ) {
186  activeExaminer_ = _id;
187 }
188 
189 glViewer* viewer(int _viewerId ) {
190  if ( _viewerId < 0 || _viewerId >= (int)examiner_widgets_.size() ) {
191  std::cerr << "Requested unknown viewer with id : " << _viewerId << std::endl;
192  return examiner_widgets_[activeExaminer()];
193  }
194 
195  return( examiner_widgets_[_viewerId] );
196 }
197 
198 unsigned int activeExaminer( ) {
199  return activeExaminer_;
200 }
201 
204 }
205 
207 QString getEncodedExaminerView(int _viewerId) {
208 
209  QString view;
210 
211  if ( _viewerId < 0 || _viewerId >= (int)examiner_widgets_.size() ) {
212  std::cerr << "Requested unknown viewer with id : " << _viewerId << std::endl;
213  examiner_widgets_[activeExaminer()]->encodeView ( view );
214  return view;
215  }
216 
217  examiner_widgets_[_viewerId]->encodeView ( view );
218  return view;
219 
220 }
221 
222 void setEncodedExaminerView( QString _view ) {
224 }
225 
226 void setEncodedExaminerView(int _viewerId , QString _view ) {
227 
228  if ( _viewerId < 0 || _viewerId >= (int)examiner_widgets_.size() ) {
229  std::cerr << "Requested unknown viewer with id : " << _viewerId << std::endl;
230  examiner_widgets_[activeExaminer()]->decodeView ( _view );
231  }
232 
233  examiner_widgets_[_viewerId]->decodeView ( _view );
234 }
235 
236 void setDataSeparatorNodes( SeparatorNode* _dataSeparatorNode ) {
237 
238  // The function should only be called once by the core.
239 
240  // Set the separatorNode
241  PluginFunctions::dataSeparatorNode_ = _dataSeparatorNode;
242 
243 
244  if ( PluginFunctions::dataSeparatorNode_->nChildren() != 1 ){
245  std::cerr << "Only one child allowed for dataSeparatorNode on initialization!" << std::endl;
246  std::cerr << "The Core has initialized the scenegraph in a strange way!" << std::endl;
247  }
248 
249  // Set the root node for the data objects
250  // which has to be a child of the dataSeparatorNode_
251  PluginFunctions::dataRootNode_ = dynamic_cast<ACG::SceneGraph::SeparatorNode*> (*(PluginFunctions::dataSeparatorNode_->childrenBegin()) );
252 
253 }
254 
256  PluginFunctions::sceneGraphRootNode_ = _root_node;
257 }
258 
260  PluginFunctions::sceneGraphRootNodeGlobal_ = _root_node;
261 }
262 
263 bool getPickedObject(const unsigned int _node_idx , BaseObjectData*& _object) {
265  if ( o_it->picked( _node_idx ) ) {
266  _object = *o_it;
267  return true;
268  }
269  }
270  return false;
271 }
272 
273 
274 bool getSourceIdentifiers( std::vector<int>& _identifiers ) {
275  _identifiers.clear();
276 
278  if ( o_it->source() )
279  _identifiers.push_back ( o_it->id() );
280  }
281  return ( ! _identifiers.empty() );
282 }
283 
284 bool getTargetIdentifiers( std::vector<int>& _identifiers ) {
285  _identifiers.clear();
286 
288  if ( o_it->target() )
289  _identifiers.push_back ( o_it->id() );
290  }
291  return ( !_identifiers.empty() );
292 }
293 
294 // ===============================================================================
295 // Get objects
296 // ===============================================================================
297 
298 bool getObject( const int _identifier , BaseObject*& _object ) {
299 
300  if ( _identifier == -1 )
301  return false;
302 
303  // Obsolete:
304  //_object = objectRoot_->childExists( _identifier );
305 
306  // Search for specified object in object map:
307  std::map<int, BaseObject*>::iterator it;
308  it = objectMap_.find(_identifier);
309  // Get object
310  _object = (it != objectMap_.end() ? it->second : 0);
311 
312  return ( _object != 0 );
313 }
314 
315 bool getObject( const int _identifier , BaseObjectData*& _object ) {
316 
317  if ( _identifier == -1 )
318  return false;
319 
320  // Obsolete: BaseObject* object = objectRoot_->childExists( _identifier );
321 
322  // Search for specified object in object map:
323  std::map<int, BaseObject*>::iterator it;
324  it = objectMap_.find(_identifier);
325  // Get object
326  BaseObject* object = (it != objectMap_.end() ? it->second : 0);
327 
328  _object = dynamic_cast< BaseObjectData* >(object);
329  return ( _object != 0 );
330 }
331 
332 int getObjectId( const QString& _name ) {
333  if(_name.isEmpty()) return -1;
334 
335  BaseObject* object = objectRoot_->childExists( _name );
336  return object ? object->id() : -1;
337 }
338 
339 // ===============================================================================
340 // ===============================================================================
341 
342 bool objectExists( const int _identifier ) {
343 
344  if ( _identifier == -1 )
345  return false;
346 
347  BaseObject* object = objectRoot_->childExists( _identifier );
348  return ( object != 0 );
349 }
350 
351 //===============================================================================
352 
353 bool getAllMeshes( std::vector<int>& _identifiers ) {
354 
355  _identifiers.clear();
356 
357  // find changed manipulator
359  o_it != PluginFunctions::objectsEnd(); ++o_it) {
360  _identifiers.push_back( o_it->id() );
361  }
362 
363  return (!_identifiers.empty());
364 }
365 
366 bool getAllObjectIdentifiers( std::vector<int>& _identifiers ) {
367 
368  _identifiers.clear();
369 
370  // find changed manipulator
372  o_it != PluginFunctions::objectsEnd(); ++o_it) {
373  _identifiers.push_back( o_it->id() );
374  }
375 
376  return ( !_identifiers.empty() );
377 }
378 
380  for ( uint i = 0 ; i < examiner_widgets_.size(); ++i )
382 }
383 
384 void setFixedView(int _mode, int _viewer ) {
385 
386  if ( (_viewer != ACTIVE_VIEWER ) && ( ( _viewer < 0 ) || _viewer >= (int)examiner_widgets_.size()) ){
387  std::cerr << "Unable to set fixed view. Wrong viewer id (" << _viewer << ")" << std::endl;
388  return;
389  }
390 
391  switch ( _mode ){
392  case VIEW_TOP : //TOP
393  PluginFunctions::viewingDirection( ACG::Vec3d(0.0, -1.0, 0.0), ACG::Vec3d(0.0, 0.0, -1.0), _viewer );
395  break;
396  case VIEW_BOTTOM : //BOTTOM
397  PluginFunctions::viewingDirection( ACG::Vec3d(0.0, 1.0, 0.0), ACG::Vec3d(0.0, 0.0, -1.0), _viewer );
399  break;
400  case VIEW_LEFT : //LEFT
401  PluginFunctions::viewingDirection( ACG::Vec3d(1.0, 0.0, 0.0), ACG::Vec3d(0.0, 1.0, 0.0), _viewer );
403  break;
404  case VIEW_RIGHT : //RIGHT
405  PluginFunctions::viewingDirection( ACG::Vec3d(-1.0, 0.0, 0.0), ACG::Vec3d(0.0, 1.0, 0.0), _viewer );
407  break;
408  case VIEW_FRONT : //FRONT
409  PluginFunctions::viewingDirection( ACG::Vec3d(0.0, 0.0, -1.0), ACG::Vec3d(0.0, 1.0, 0.0), _viewer );
411  break;
412  case VIEW_BACK : //BACK
413  PluginFunctions::viewingDirection( ACG::Vec3d(0.0, 0.0, 1.0), ACG::Vec3d(0.0, 1.0, 0.0), _viewer );
415  break;
416  default : //Free View
417  PluginFunctions::allowRotation(true, _viewer);
418  break;
419  }
420 
421  if ( _viewer == ACTIVE_VIEWER )
423  else
424  viewerProperties( _viewer ).currentViewingDirection( _mode );
425 }
426 
427 QPoint mapToGlobal(const QPoint _point ) {
428  return examiner_widgets_[activeExaminer_]->glMapToGlobal(_point);
429 }
430 
431 QPoint mapToLocal( const QPoint _point ) {
432  return examiner_widgets_[activeExaminer_]->glMapFromGlobal(_point);
433 }
434 
435 void setDrawMode( const ACG::SceneGraph::DrawModes::DrawMode& _mode , int _viewer) {
436 
437  if ( _viewer == ACTIVE_VIEWER )
439  else if ( _viewer == ALL_VIEWERS )
440  for ( uint i = 0 ; i < examiner_widgets_.size(); ++i )
441  viewerProperties(i).drawMode(_mode);
442  else if ( ( _viewer >= 0 ) && _viewer < (int)examiner_widgets_.size() )
443  viewerProperties(_viewer).drawMode(_mode);
444  else
445  std::cerr << "Requested illegal viewer for setting DrawMode!!" << std::endl;
446 
447 }
448 
455  if ( _viewer == ACTIVE_VIEWER ) {
457  } else if ( _viewer == ALL_VIEWERS )
458  std::cerr << "Please select viewer to get viewing direction!" << std::endl;
459  else if ( ( _viewer >= 0 ) && _viewer < (int)examiner_widgets_.size() )
460  return viewerProperties(_viewer).drawMode();
461  else
462  std::cerr << "Requested illegal viewer for viewingDirection!!" << std::endl;
463 
465 }
466 
467 //get a viewing ray for the active examiner x and y are in widgetspace
468 void viewingRay(int _x, int _y,
469  ACG::Vec3d& _outOrigin, ACG::Vec3d& _outDirection)
470 {
471  viewingRay(_x,_y,_outOrigin,_outDirection,activeExaminer_);
472 }
473 
474 //get a viewing ray for the specified examiner x and y are in widgetspace
475 void viewingRay(int _x, int _y,
476  ACG::Vec3d& _outOrigin, ACG::Vec3d& _outDirection, int _viewerIndex)
477 {
478  viewerProperties(_viewerIndex).glState().viewing_ray(_x,_y,_outOrigin,_outDirection);
479 }
480 
481 // Pick returning node index
482 bool scenegraphPick( ACG::SceneGraph::PickTarget _pickTarget, const QPoint &_mousePos, unsigned int &_nodeIdx, unsigned int &_targetIdx, ACG::Vec3d *_hitPointPtr=0 ) {
483 
484  return examiner_widgets_[activeExaminer_]->pick( _pickTarget,_mousePos,_nodeIdx,_targetIdx,_hitPointPtr );
485 }
486 
487 // Pick returning node index
488 bool scenegraphPick( const unsigned int _examiner, ACG::SceneGraph::PickTarget _pickTarget, const QPoint &_mousePos, unsigned int &_nodeIdx, unsigned int &_targetIdx, ACG::Vec3d *_hitPointPtr=0 ) {
489 
490  if ( _examiner >= examiner_widgets_.size() ) {
491  std::cerr << "Wrong examiner id" << std::endl;
492  return false;
493  }
494  return examiner_widgets_[_examiner]->pick( _pickTarget,_mousePos,_nodeIdx,_targetIdx,_hitPointPtr );
495 }
496 
497 
498 // Pick returning object and calling refine
499 bool scenegraphPick( const unsigned int _examiner ,
500  ACG::SceneGraph::PickTarget _pickTarget,
501  const QPoint & _mousePos,
502  BaseObjectData*& _object,
503  unsigned int & _targetIdx,
504  const bool _refine,
505  ACG::Vec3d * _hitPointPtr ) {
506 
507  unsigned int nodeIdx = 0;
508 
509  bool ok = scenegraphPick(_examiner,_pickTarget,_mousePos,nodeIdx,_targetIdx,_hitPointPtr);
510 
511  // If successfully picked and object is found
512  if ( ok && PluginFunctions::getPickedObject(nodeIdx, _object) ) {
513 
514  if ( _refine && (_hitPointPtr != 0) ) {
515 
516  // Map to correct coordinates in OpenGL
517  double x = _mousePos.x();
518  double y = examiner_widget_->glHeight() - _mousePos.y();
519 
520  ACG::Vec3d mousePoint3d;
521  ACG::Vec3d direction;
522 
523  viewingRay(x,y,mousePoint3d,direction);
524 
525  *_hitPointPtr = _object->refinePick(_pickTarget,*_hitPointPtr, mousePoint3d , direction , _targetIdx );
526 
527  }
528 
529  }
530 
531  return ok;
532 }
533 
534 // Pick returning object and calling refine
536  const QPoint & _mousePos,
537  BaseObjectData*& _object,
538  unsigned int & _targetIdx,
539  const bool _refine,
540  ACG::Vec3d * _hitPointPtr ) {
541 
542  return scenegraphPick(activeExaminer_,_pickTarget,_mousePos, _object,_targetIdx,_refine,_hitPointPtr );
543 
544 }
545 
546 
547 
548 
550  const QRegion& _region,
551  QList<QPair<unsigned int, unsigned int> >& _list,
552  QVector<float>* _depths,
553  QVector<ACG::Vec3d>* _points)
554 {
555  return examiner_widgets_[activeExaminer_]->pick_region( _pickTarget, _region, _list, _depths, _points);
556 }
557 
558 bool scenegraphRegionPick( const unsigned int _examiner,
559  ACG::SceneGraph::PickTarget _pickTarget,
560  const QRegion& _region,
561  QList<QPair<unsigned int, unsigned int> >& _list,
562  QVector<float>* _depths,
563  QVector<ACG::Vec3d>* _points)
564 {
565  if ( _examiner >= examiner_widgets_.size() ) {
566  std::cerr << "Wrong examiner id" << std::endl;
567  return false;
568  }
569  return examiner_widgets_[_examiner]->pick_region( _pickTarget, _region, _list, _depths, _points);
570 }
571 
572 //Warning : Dont use template function as external static pointer for examiner widget is not resolved correctly!!
574  // Single pass action, as the mouse action will only update the graph.
575  // If its changed, it will be set to dirty and an automatic redraw is triggered.
576  ACG::SceneGraph::traverse(sceneGraphRootNode_, _action );
577 }
578 
579 const std::string pickMode () {
580  // No seperate draw modes available all should have the same so take first
581  return viewerProperties().pickMode();
582 }
583 
584 void pickMode ( const std::string& _mode) {
585  // switch to default marker
587  viewerProperties().pickMode(_mode);
588 }
589 
591  return viewerProperties().actionMode();
592 }
593 
595 
596  viewerProperties().actionMode(_mode);
597 }
598 
599 void shareGLWidget (QGLWidget *_widget)
600 {
601  shareGLWidget_ = _widget;
602 }
603 
604 QGLWidget *shareGLWidget ()
605 {
606  return shareGLWidget_;
607 }
608 
609 void getCurrentViewImage(QImage& _image) {
610  viewer( activeExaminer() )->snapshot( _image );
611 }
612 
614  if ( _id >= (int)viewerProperties_.size() ) {
615  std::cerr << " Error, requested properties for non-existing Viewer!" << std::endl;
616  return dummyProperties;
617  }
618 
619  if ( _id == -1 )
620  _id = activeExaminer_;
621 
622  return ( *viewerProperties_[_id] );
623 
624 }
625 
626 void perspectiveProjection( int _viewer ) {
627  if ( _viewer == ACTIVE_VIEWER ) {
628  examiner_widgets_[activeExaminer_]->perspectiveProjection();
629  } else if ( _viewer == ALL_VIEWERS )
630  for ( uint i = 0 ; i < examiner_widgets_.size(); ++i )
631  examiner_widgets_[i]->perspectiveProjection();
632  else if ( ( _viewer >= 0 ) && _viewer < (int)examiner_widgets_.size() )
633  examiner_widgets_[_viewer]->perspectiveProjection();
634  else
635  std::cerr << "Requested illegal viewer for perspectiveProjection()!!" << std::endl;
636 }
637 
638 void orthographicProjection( int _viewer ) {
639  if ( _viewer == ACTIVE_VIEWER ) {
640  examiner_widgets_[activeExaminer_]->orthographicProjection();
641  } else if ( _viewer == ALL_VIEWERS )
642  for ( uint i = 0 ; i < examiner_widgets_.size(); ++i )
643  examiner_widgets_[i]->orthographicProjection();
644  else if ( ( _viewer >= 0 ) && _viewer < (int)examiner_widgets_.size() )
645  examiner_widgets_[_viewer]->orthographicProjection();
646  else
647  std::cerr << "Requested illegal viewer for orthographicProjection()!!" << std::endl;
648 }
649 
650 void setFOVY( double _fovy) {
651 
652  // Set FOVY for all viewers
653  for ( uint i = 0 ; i < examiner_widgets_.size(); ++i )
654  examiner_widgets_[i]->setFOVY(_fovy);
655 }
656 
657 void allowRotation(bool _mode, int _viewer ) {
658  if ( _viewer == ACTIVE_VIEWER ) {
659  examiner_widgets_[activeExaminer_]->allowRotation(_mode);
660  } else if ( _viewer == ALL_VIEWERS )
661  for ( uint i = 0 ; i < examiner_widgets_.size(); ++i )
662  examiner_widgets_[i]->allowRotation(_mode);
663  else if ( ( _viewer >= 0 ) && _viewer < (int)examiner_widgets_.size() )
664  examiner_widgets_[_viewer]->allowRotation(_mode);
665  else {
666  std::cerr << "Requested illegal viewer for allowRotation!!" << std::endl;
667  return;
668  }
669 
670  if ( _viewer == ACTIVE_VIEWER )
672  else
673  viewerProperties( _viewer ).rotationLocked( !_mode );
674 }
675 
676 bool allowRotation( int _viewer ) {
677 
678  if ( ( _viewer >= 0 ) && _viewer < (int)examiner_widgets_.size() )
679  return examiner_widgets_[_viewer]->allowRotation();
680  else {
681 
682  std::cerr << "Requested illegal viewer for isRotationAllowed!!" << std::endl;
683  return false;
684  }
685 }
686 
688  examiner_widget_->makeCurrent();
689 }
690 
691 void viewingDirection(const ACG::Vec3d &_dir, const ACG::Vec3d &_up , int _viewer ) {
692  if ( _viewer == ACTIVE_VIEWER ) {
693  examiner_widgets_[activeExaminer_]->viewingDirection(_dir,_up);
694  } else if ( _viewer == ALL_VIEWERS )
695  for ( uint i = 0 ; i < examiner_widgets_.size(); ++i )
696  examiner_widgets_[i]->viewingDirection(_dir,_up);
697  else if ( ( _viewer >= 0 ) && _viewer < (int)examiner_widgets_.size() )
698  examiner_widgets_[_viewer]->viewingDirection(_dir,_up);
699  else
700  std::cerr << "Requested illegal viewer for viewingDirection!!" << std::endl;
701 }
702 
703 void lookAt(const ACG::Vec3d& _eye, const ACG::Vec3d& _center, const ACG::Vec3d& _up, int _viewer) {
704 
705  if ( _viewer == ACTIVE_VIEWER ) {
706  examiner_widgets_[activeExaminer_]->lookAt(_eye,_center, _up);
707  } else if ( _viewer == ALL_VIEWERS )
708  for ( uint i = 0 ; i < examiner_widgets_.size(); ++i )
709  examiner_widgets_[i]->lookAt(_eye,_center, _up);
710  else if ( ( _viewer >= 0 ) && _viewer < (int)examiner_widgets_.size() )
711  examiner_widgets_[_viewer]->lookAt(_eye,_center, _up);
712  else
713  std::cerr << "Requested illegal viewer for viewingDirection!!" << std::endl;
714 }
715 
716 const ACG::Vec3d trackBallCenter( int _viewer ) {
717  if ( _viewer == ACTIVE_VIEWER ) {
718  return examiner_widgets_[activeExaminer_]->trackBallCenter();
719  } else if ( _viewer == ALL_VIEWERS )
720  for ( uint i = 0 ; i < examiner_widgets_.size(); ++i )
721  return examiner_widgets_[i]->trackBallCenter( );
722  else if ( ( _viewer >= 0 ) && _viewer < (int)examiner_widgets_.size() )
723  return examiner_widgets_[_viewer]->trackBallCenter( );
724  else
725  std::cerr << "Requested illegal viewer for setTrackBallCenter!!" << std::endl;
726 
727  return examiner_widgets_[activeExaminer_]->trackBallCenter();
728 }
729 
730 void setTrackBallCenter(const ACG::Vec3d& _center, int _viewer ) {
731  if ( _viewer == ACTIVE_VIEWER ) {
732  examiner_widgets_[activeExaminer_]->setTrackBallCenter( _center );
733  } else if ( _viewer == ALL_VIEWERS )
734  for ( uint i = 0 ; i < examiner_widgets_.size(); ++i )
735  examiner_widgets_[i]->setTrackBallCenter( _center );
736  else if ( ( _viewer >= 0 ) && _viewer < (int)examiner_widgets_.size() )
737  examiner_widgets_[_viewer]->setTrackBallCenter( _center );
738  else
739  std::cerr << "Requested illegal viewer for setTrackBallCenter!!" << std::endl;
740 }
741 
742 void setScenePos(const ACG::Vec3d& _center,const double _radius, int _viewer ) {
743  if ( _viewer == ACTIVE_VIEWER ) {
744  examiner_widgets_[activeExaminer_]->setScenePos( _center, _radius );
745  } else if ( _viewer == ALL_VIEWERS )
746  for ( uint i = 0 ; i < examiner_widgets_.size(); ++i )
747  examiner_widgets_[i]->setScenePos( _center, _radius );
748  else if ( ( _viewer >= 0 ) && _viewer < (int)examiner_widgets_.size() )
749  examiner_widgets_[_viewer]->setScenePos( _center, _radius );
750  else
751  std::cerr << "Requested illegal viewer for setScenePos!!" << std::endl;
752 }
753 
754 void setScenePos(const ACG::Vec3d& _center, int _viewer ) {
755  if ( _viewer == ACTIVE_VIEWER ) {
756  examiner_widgets_[activeExaminer_]->setScenePos( _center, examiner_widgets_[activeExaminer_]->scene_radius() );
757  } else if ( _viewer == ALL_VIEWERS )
758  for ( uint i = 0 ; i < examiner_widgets_.size(); ++i )
759  examiner_widgets_[i]->setScenePos( _center, examiner_widgets_[i]->scene_radius() );
760  else if ( ( _viewer >= 0 ) && _viewer < (int)examiner_widgets_.size() )
761  examiner_widgets_[_viewer]->setScenePos( _center, examiner_widgets_[_viewer]->scene_radius() );
762  else
763  std::cerr << "Requested illegal viewer for setScenePos!!" << std::endl;
764 }
765 
766 void setSceneCenter(const ACG::Vec3d& _center, int _viewer) {
767 
768  if (_viewer == ACTIVE_VIEWER) {
769  examiner_widgets_[activeExaminer_]->setSceneCenter(_center);
770  } else if (_viewer == ALL_VIEWERS) {
771 
772  for (uint i = 0; i < examiner_widgets_.size(); ++i) {
773  examiner_widgets_[i]->setSceneCenter(_center);
774  }
775  } else if ((_viewer >= 0) && _viewer < (int) examiner_widgets_.size()) {
776  examiner_widgets_[_viewer]->setSceneCenter(_center);
777  } else {
778  std::cerr << "Requested illegal viewer for setSceneCenter!!" << std::endl;
779  }
780 }
781 
782 const ACG::Vec3d sceneCenter(int _viewer) {
783 
784  if (_viewer == ACTIVE_VIEWER) {
785  return examiner_widgets_[activeExaminer_]->scene_center();
786  } else if (_viewer == ALL_VIEWERS)
787  std::cerr << "Please select viewer to get sceneCenter!" << std::endl;
788  else if ((_viewer >= 0) && _viewer < (int) examiner_widgets_.size())
789  return examiner_widgets_[_viewer]->scene_center();
790  else
791  std::cerr << "Requested illegal viewer for sceneCenter!!" << std::endl;
792 
793  return examiner_widgets_[activeExaminer_]->scene_center();
794 }
795 
796 double sceneRadius() {
797  return examiner_widgets_[activeExaminer_]->scene_radius();
798 }
799 
800 double sceneRadius( int _viewer ) {
801  if ( _viewer == ACTIVE_VIEWER ) {
802  return examiner_widgets_[activeExaminer_]->scene_radius();
803  } else if ( _viewer == ALL_VIEWERS )
804  std::cerr << "Illegal request for scene radius. Please select one viewer!" << std::endl;
805  else if ( ( _viewer >= 0 ) && _viewer < (int)examiner_widgets_.size() )
806  return examiner_widgets_[_viewer]->scene_radius();
807  else
808  std::cerr << "Requested illegal viewer for translate!!" << std::endl;
809 
810  return -1;
811 }
812 
813 void setSceneRadius(double _radius, int _viewer ) {
814  if ( _viewer == ACTIVE_VIEWER ) {
815  examiner_widgets_[activeExaminer_]->setSceneRadius(_radius);
816  } else if ( _viewer == ALL_VIEWERS )
817  for ( uint i = 0 ; i < examiner_widgets_.size(); ++i )
818  examiner_widgets_[i]->setSceneRadius(_radius);
819  else if ( ( _viewer >= 0 ) && _viewer < (int)examiner_widgets_.size() )
820  examiner_widgets_[_viewer]->setSceneRadius(_radius);
821  else
822  std::cerr << "Requested illegal viewer for translate!!" << std::endl;
823 }
824 
825 void translate( const ACG::Vec3d &_vector , int _viewer ) {
826  if ( _viewer == ACTIVE_VIEWER ) {
827  examiner_widgets_[activeExaminer_]->translate(_vector);
828  } else if ( _viewer == ALL_VIEWERS )
829  for ( uint i = 0 ; i < examiner_widgets_.size(); ++i )
830  examiner_widgets_[i]->translate(_vector);
831  else if ( ( _viewer >= 0 ) && _viewer < (int)examiner_widgets_.size() )
832  examiner_widgets_[_viewer]->translate(_vector);
833  else
834  std::cerr << "Requested illegal viewer for translate!!" << std::endl;
835 }
836 
837 void rotate(const ACG::Vec3d& _axis,
838  const double _angle,
839  const ACG::Vec3d& _center,
840  int _viewer )
841 {
842  if ( _viewer == ACTIVE_VIEWER ) {
843  examiner_widgets_[activeExaminer_]->rotate(_axis,_angle,_center);
844  } else if ( _viewer == ALL_VIEWERS )
845  for ( uint i = 0 ; i < examiner_widgets_.size(); ++i )
846  examiner_widgets_[i]->rotate(_axis,_angle,_center);
847  else if ( ( _viewer >= 0 ) && _viewer < (int)examiner_widgets_.size() )
848  examiner_widgets_[_viewer]->rotate(_axis,_angle,_center);
849  else
850  std::cerr << "Requested illegal viewer for rotate!!" << std::endl;
851 }
852 
853 void viewHome(int _viewer) {
854  if ( _viewer == ACTIVE_VIEWER ) {
855  examiner_widgets_[activeExaminer_]->home();
856  } else if ( _viewer == ALL_VIEWERS )
857  for ( uint i = 0 ; i < examiner_widgets_.size(); ++i )
858  examiner_widgets_[i]->home();
859  else if ( ( _viewer >= 0 ) && _viewer < (int)examiner_widgets_.size() )
860  examiner_widgets_[_viewer]->home();
861  else
862  std::cerr << "Requested illegal viewer for viewHome!!" << std::endl;
863 }
864 
865 void viewAll(int _viewer) {
866  if ( _viewer == ACTIVE_VIEWER ) {
867  examiner_widgets_[activeExaminer_]->viewAll();
868  } else if ( _viewer == ALL_VIEWERS )
869  for ( uint i = 0 ; i < examiner_widgets_.size(); ++i )
870  examiner_widgets_[i]->viewAll();
871  else if ( ( _viewer >= 0 ) && _viewer < (int)examiner_widgets_.size() )
872  examiner_widgets_[_viewer]->viewAll();
873  else
874  std::cerr << "Requested illegal viewer for viewAll!!" << std::endl;
875 }
876 
878  if ( _viewer == ACTIVE_VIEWER ) {
879  return viewerProperties(activeExaminer_).glState().viewing_direction();
880  } else if ( _viewer == ALL_VIEWERS )
881  std::cerr << "Please select viewer to get viewing direction!" << std::endl;
882  else if ( ( _viewer >= 0 ) && _viewer < (int)examiner_widgets_.size() )
883  return viewerProperties(_viewer).glState().viewing_direction();
884  else
885  std::cerr << "Requested illegal viewer for viewingDirection!!" << std::endl;
886 
888 }
889 
890 bool isProjectionOrthographic( int _viewer ) {
891 
892  if ( _viewer == ACTIVE_VIEWER) {
893  return (examiner_widgets_[activeExaminer_]->projectionMode() == 0);
894  } else if ( ( _viewer >= 0 ) && _viewer < (int)examiner_widgets_.size() ){
895  return ( examiner_widgets_[_viewer]->projectionMode() == 0); //ORTHOGRAPHIC_PROJECTION ?
896  } else
897  std::cerr << "Requested illegal viewer for isProjectionOrthographic!!" << std::endl;
898 
899  return false;
900 }
901 
902 ACG::Vec3d eyePos(int _viewer) {
903  if ( _viewer == ACTIVE_VIEWER ) {
904  return viewerProperties(activeExaminer_).glState().eye();
905  } else if ( _viewer == ALL_VIEWERS )
906  std::cerr << "Please select viewer to get eyePos!" << std::endl;
907  else if ( ( _viewer >= 0 ) && _viewer < (int)examiner_widgets_.size() )
908  return viewerProperties(_viewer).glState().eye();
909  else
910  std::cerr << "Requested illegal viewer for eyePos!!" << std::endl;
911 
912  return viewerProperties().glState().eye();
913 }
914 
915 ACG::Vec3d upVector(int _viewer) {
916  if ( _viewer == ACTIVE_VIEWER ) {
917  return viewerProperties(activeExaminer_).glState().up();
918  } else if ( _viewer == ALL_VIEWERS )
919  std::cerr << "Please select viewer to get up vector!" << std::endl;
920  else if ( ( _viewer >= 0 ) && _viewer < (int)examiner_widgets_.size() )
921  return viewerProperties(_viewer).glState().up();
922  else
923  std::cerr << "Requested illegal viewer for up vector!!" << std::endl;
924 
925  return viewerProperties().glState().up();
926 }
927 
930 DLLEXPORT
931 double fovy(int _viewer) {
932  if ( _viewer == ACTIVE_VIEWER ) {
933  return viewerProperties(activeExaminer_).glState().fovy();
934  } else if ( _viewer == ALL_VIEWERS )
935  std::cerr << "Please select viewer to get fovy!" << std::endl;
936  else if ( ( _viewer >= 0 ) && _viewer < (int)examiner_widgets_.size() )
937  return viewerProperties(_viewer).glState().fovy();
938  else
939  std::cerr << "Requested illegal viewer for fovy!!" << std::endl;
940 
941  return viewerProperties().glState().fovy();
942 }
943 
945 {
946  for ( uint i = 0 ; i < examiner_widgets_.size(); ++i )
948 }
949 
951 {
952  defaultMarker_ = _marker;
953 }
954 
956 {
957  return defaultMarker_;
958 }
959 
960 
962  return PluginFunctions::sceneGraphRootNode_;
963 }
964 
966  return PluginFunctions::dataRootNode_;
967 }
968 
970  if (PluginFunctions::sceneGraphRootNode_){
971 
972  // get the current parent Node
973  ACG::SceneGraph::BaseNode* parent = sceneGraphRootNodeGlobal_->parent();
974 
975  // Move the node to the new parent
976  _node->set_parent(parent);
977 
978  // move sceneGraphRootNodeGlobal_ to the new parent
979  sceneGraphRootNodeGlobal_->set_parent(_node);
980  }
981 }
982 
984  if (PluginFunctions::sceneGraphRootNode_)
985  _node->set_parent( PluginFunctions::sceneGraphRootNodeGlobal_ );
986 }
987 
988 
990  if (PluginFunctions::sceneGraphRootNode_){
991 
992  // get the current parent Node
993  ACG::SceneGraph::BaseNode* parent = dataRootNode_->parent();
994 
995  // Move the node to the new parent
996  _node->set_parent(parent);
997 
998  // move dataRootNode_ to the new parent
999  dataRootNode_->set_parent(_node);
1000  }
1001 
1002 }
1003 
1005  return(objectCounter_);
1006 }
1007 
1008 
1009 
1011  return ( targetCounter_ );
1012 }
1013 
1015  int count = 0;
1016 
1017  // find changed manipulator
1019  o_it != PluginFunctions::objectsEnd(); ++o_it) {
1020  ++count;
1021  }
1022 
1023  return ( count );
1024 }
1025 
1027  int count = 0;
1028 
1029  // find changed manipulator
1031  o_it != PluginFunctions::objectsEnd(); ++o_it) {
1032  if ( o_it->visible() )
1033  ++count;
1034  }
1035 
1036  return ( count );
1037 
1038 }
1039 
1040 
1045 void get_all_objects( std::vector < BaseObjectData*>& _objects ) {
1046 
1047  _objects.clear();
1048 
1049  // find changed manipulator
1051  o_it != PluginFunctions::objectsEnd(); ++o_it) {
1052  _objects.push_back( *o_it );
1053  }
1054 
1055 }
1056 
1057 
1059 void flyTo (const ACG::Vec3d &_position, const ACG::Vec3d &_center, double _time) {
1060  examiner_widgets_[activeExaminer_]->flyTo(_position,_center,_time);
1061 }
1062 
1063 
1065 void flyTo (const ACG::Vec3d &_center, bool _move_back, double _time) {
1067  ACG::Vec3d t = _center - eye;
1068  ACG::Vec3d e = eye + t * (_move_back ? -0.5f : 0.5f);
1069  examiner_widgets_[activeExaminer_]->flyTo(e, _center, _time);
1070 }
1071 
1072 
1074 void viewerSnapshot(int _viewer, QImage& _image, int _width, int _height, bool _alpha,
1075  bool _hideCoordsys, int _samples) {
1076 
1077  if ( _viewer == ACTIVE_VIEWER ) {
1078  examiner_widgets_[activeExaminer_]->snapshot(_image, _width, _height, _alpha, _hideCoordsys, _samples);
1079  } else if ( _viewer == ALL_VIEWERS )
1080  std::cerr << "Please select viewer to get snapshot!" << std::endl;
1081  else if ( ( _viewer >= 0 ) && _viewer < (int)examiner_widgets_.size() )
1082  examiner_widgets_[_viewer]->snapshot(_image, _width, _height, _alpha, _hideCoordsys, _samples);
1083  else
1084  std::cerr << "Requested illegal viewer for snapshot!!" << std::endl;
1085 }
1086 
1087 
1088 
1089 // ===============================================================================
1090 // Getting data from objects and casting between them
1091 // ===============================================================================
1092 
1094  if ( _object == 0 )
1095  return 0;
1096 
1097  return dynamic_cast< BaseObjectData* >(_object);
1098 }
1099 
1100 // ===============================================================================
1101 // Get the root of the object structure
1102 // ===============================================================================
1104  return (objectRoot_);
1105 }
1106 
1108  objectCounter_++;
1109 }
1110 
1111 // Increase the number of current Object
1113  objectCounter_--;
1114 
1115  if ( objectCounter_ < 0 )
1116  std::cerr << "Deleted more objects than created!!!" << std::endl;
1117 }
1118 
1120  targetCounter_++;
1121 }
1122 
1123 // Increase the number of current Object
1125  targetCounter_--;
1126 
1127  if ( targetCounter_ < 0 )
1128  std::cerr << "target object counter underflow!!!" << std::endl;
1129 }
1130 
1131 // ===============================================================================
1132 // Add an object to the internal object map
1133 // ===============================================================================
1134 void addObjectToMap(int _objectId, BaseObject* _object) {
1135 
1136  // Look if object's id already exists in map
1137  std::map<int, BaseObject*>::iterator it;
1138  it = objectMap_.find(_objectId);
1139  // If so return
1140  if(it != objectMap_.end()) return;
1141 
1142  // Add new object to map
1143  objectMap_.insert(std::pair<int, BaseObject*>(_objectId, _object));
1144 }
1145 
1146 // ===============================================================================
1147 // Remove an object from the internal object map
1148 // ===============================================================================
1149 void removeObjectFromMap(int _objectId) {
1150 
1151  // Look if object exists in map
1152  std::map<int, BaseObject*>::iterator it;
1153  it = objectMap_.find(_objectId);
1154 
1155  // Erase entry
1156  if(it != objectMap_.end()) objectMap_.erase(it);
1157 }
1158 
1159 
1161 
1162  // Check if we already have a generator for this type.
1163  if ( sceneGraphGenerators_.contains( _generator->handles() ) )
1164  return;
1165 
1166  // Store the generator
1167  sceneGraphGenerators_[_generator->handles() ] = _generator;
1168 }
1169 
1170 
1171 QMap< std::string ,ACG::QtWidgets::SceneGraphWidgetGenerator* > getSceneGraphGeneratorList(){
1172  return sceneGraphGenerators_;
1173 }
1174 
1175 QString getOpenFileName(const QString &configProperty,
1176  QWidget * parent, const QString & caption,
1177  const QString & defaultDir, const QString & filter,
1178  QString * selectedFilter, QFileDialog::Options options) {
1179 
1180  const QString dir = OpenFlipperSettings().value(configProperty, defaultDir).toString();
1181  const QString result = QFileDialog::getOpenFileName(parent, caption, dir,
1182  filter, selectedFilter, options);
1183  if (result.length())
1184  OpenFlipperSettings().setValue(configProperty, result);
1185  return result;
1186 }
1187 
1188 QString getSaveFileName(const QString &configProperty,
1189  QWidget * parent, const QString & caption,
1190  const QString & defaultDir, const QString & filter,
1191  QString * selectedFilter, QFileDialog::Options options,
1192  const QString & defaultSuffix) {
1193 
1194  const QString dir = OpenFlipperSettings().value(configProperty, defaultDir).toString();
1195 
1196  /*
1197  * We don't use this convenience wrapper any more since it
1198  * prevents us from setting the default suffix.
1199  *
1200  * const QString result = QFileDialog::getSaveFileName(
1201  * parent, caption, dir, filter, selectedFilter, options);
1202  */
1203 
1204  QFileDialog dialog(parent, caption, dir, filter);
1205  dialog.setOptions(options);
1206  dialog.setAcceptMode(QFileDialog::AcceptSave);
1207  if (selectedFilter && !selectedFilter->isEmpty())
1208  dialog.selectNameFilter(*selectedFilter);
1209  dialog.setDefaultSuffix(defaultSuffix);
1210  if (dialog.exec() == QDialog::Accepted) {
1211  if (selectedFilter)
1212  *selectedFilter = dialog.selectedNameFilter();
1213  QString result = dialog.selectedFiles().value(0);
1214  OpenFlipperSettings().setValue(configProperty, result);
1215  return result;
1216  }
1217  return QString();
1218 }
1219 
1220 QStringList collectObjectComments(bool visibleOnly, bool targetedOnly) {
1221  QStringList result;
1222  for (ObjectIterator o_it(targetedOnly ? TARGET_OBJECTS : ALL_OBJECTS, DATA_ALL) ; o_it != objectsEnd(); ++o_it) {
1223 
1224  if (visibleOnly && !o_it->visible()) continue;
1225 
1226  result.append(o_it->getAllCommentsFlat());
1227  }
1228  return result;
1229 }
1230 
1231 QStringList collectObjectMaterials(bool visibleOnly, bool targetedOnly) {
1232  if (!ACG::SceneGraph::Material::support_json_serialization())
1233  return QStringList();
1234 
1235  QStringList result;
1236  for (ObjectIterator o_it(targetedOnly ? TARGET_OBJECTS : ALL_OBJECTS, DATA_ALL) ; o_it != objectsEnd(); ++o_it) {
1237 
1238  if (visibleOnly && !o_it->visible()) continue;
1239 
1240  QString materialStr(QObject::tr("<not available>"));
1241  if (!o_it->materialNode())
1242  materialStr = QObject::tr("<not available: materialNode == null>");
1243  else
1244  materialStr = o_it->materialNode()->material().serializeToJson();
1245 
1246  if (!result.empty())
1247  result.last().append(QString::fromUtf8(","));
1248  result.append(QString::fromUtf8("\"%1\": %2").arg(o_it->name()).arg(materialStr));
1249  }
1250  return result;
1251 }
1252 
1253 void invalidatePickCaches() {
1254  for(size_t i = 0; i < examiner_widgets_.size(); ++i) {
1255  examiner_widgets_[i]->invalidatePickCache();
1256  }
1257 }
1258 
1260  return ObjectRange(_restriction, _dataType);
1261 }
1262 
1264  return ObjectReferenceRange(_restriction, _dataType);
1265 }
1266 
1267 } // End namespace PluginFunctions
void traverse(ACG::SceneGraph::MouseEventAction &_action)
BaseObject *& objectRoot()
Get the root of the object structure.
void setMainGLContext()
Set current GL Context to main context.
const ACG::Vec3d trackBallCenter(int _viewer)
Get the trackball Center.
ViewObjectMarker * defaultViewObjectMarker()
Get the default ViewObjectMarker.
void setViewerProperties(std::vector< Viewer::ViewerProperties * > _viewerProperties)
Set the internal viewerProperties pointer ( DO NOT USE!! )
void viewingRay(int _x, int _y, ACG::Vec3d &_outOrigin, ACG::Vec3d &_outDirection)
Retrieve a viewing ray from the active examiner that can be used for raycasting.
QPoint mapToLocal(const QPoint _point)
Map global coordinates to GL Widget local coordinates.
Vec3d eye() const
get eye point
Definition: GLState.cc:882
bool scenegraphPick(ACG::SceneGraph::PickTarget _pickTarget, const QPoint &_mousePos, unsigned int &_nodeIdx, unsigned int &_targetIdx, ACG::Vec3d *_hitPointPtr=0)
Execute picking operation on scenegraph.
QStringList IteratorRestriction
Iterable object range.
ACG::Vec3d upVector(int _viewer)
Get the current up vector.
bool getSourceIdentifiers(std::vector< int > &_identifiers)
Get the identifiers of all objects marked as a source object.
void setSceneCenter(const ACG::Vec3d &_center, int _viewer)
Predefined datatypes.
Definition: DataTypes.hh:96
DLLEXPORT DataType typeId(QString _name)
Given a dataType Identifier string this function will return the id of the datatype.
Definition: Types.cc:150
ACG::GLState & glState()
Get the glState of the Viewer.
void viewHome(int _viewer)
Go to home position.
void addObjectToMap(int _objectId, BaseObject *_object)
Add object to internal object map.
QPoint mapToGlobal(const QPoint _point)
Map coordinates of GL Widget to global coordinates.
bool getAllMeshes(std::vector< int > &_identifiers)
Get identifiers of all meshes.
void setEncodedExaminerView(QString _view)
Set the encoded view for the active examiner.
const ACG::Vec3d sceneCenter(int _viewer)
Get the current scene center.
void decreaseTargetCount()
Increase the number of current Object.
int viewerId()
Return unique viewer id.
bool getObject(int _identifier, BSplineCurveObject *&_object)
void viewing_ray(int _x, int _y, Vec3d &_origin, Vec3d &_direction) const
Definition: GLState.cc:926
const QStringList SOURCE_OBJECTS("source")
Iterable object range.
ACG::Vec3d eyePos(int _viewer)
Get the current viewer position.
void setActiveExaminer(const unsigned int _id)
Set the active id of the examiner which got the last mouse events.
const QStringList TARGET_OBJECTS("target")
Iterable object range.
BaseObjectData * baseObjectData(BaseObject *_object)
Cast an BaseObject to a BaseObjectData if possible.
#define DLLEXPORT
ACG::SceneGraph::BaseNode * getRootNode()
Get the root node for data objects.
Range adapter for ObjectIterator.
int viewers()
Get the number of viewers.
void objectMarker(ViewObjectMarker *_marker)
set object marker for viewer
void increaseTargetCount()
Decrease the number of current Object.
DLLEXPORT OpenFlipperQSettings & OpenFlipperSettings()
QSettings object containing all program settings of OpenFlipper.
int getObjectId(const QString &_name)
double sceneRadius()
Returns the current scene radius from the active examiner widget.
void get_all_objects(std::vector< BaseObjectData * > &_objects)
void translate(const ACG::Vec3d &_vector, int _viewer)
Translate viewer pos by given vector.
Viewer::ActionMode actionMode()
get the action mode
int id() const
Definition: BaseObject.cc:201
void shareGLWidget(QGLWidget *_widget)
Sets the main QGLWidget for gl data sharing.
ObjectRange objects(IteratorRestriction _restriction, DataType _dataType)
Iterable object range.
const QStringList ALL_OBJECTS
Iterable object range.
bool getPickedObject(const unsigned int _node_idx, BaseObjectData *&_object)
Get the picked mesh.
bool rotationLocked()
Pointer to the glState of the Viewer.
void setFOVY(double _fovy)
Set field of view angle.
QString getOpenFileName(const QString &configProperty, QWidget *parent, const QString &caption, const QString &defaultDir, const QString &filter, QString *selectedFilter, QFileDialog::Options options)
void set_parent(BaseNode *_parent)
Set the parent of this node.
Definition: BaseNode.cc:152
void viewAll(int _viewer)
View the whole scene.
PickTarget
What target to use for picking.
Definition: BaseNode.hh:99
Vec3d up() const
get up-vector w.r.t. camera coordinates
Definition: GLState.cc:902
QMap< std::string,ACG::QtWidgets::SceneGraphWidgetGenerator * > sceneGraphGenerators_
Map of scenegraph widget generators.
bool objectExists(const int _identifier)
Check if an object with this identifier exists.
const std::string pickMode()
Get the current Picking mode.
void flyTo(const ACG::Vec3d &_position, const ACG::Vec3d &_center, double _time)
Fly to point and viewing direction (animated).
glViewer * viewer(int _viewerId)
Get a Viewer.
int sourceCount()
Get the number of source objects.
void removeObjectFromMap(int _objectId)
Remove object from internal object map.
bool isProjectionOrthographic(int _viewer)
Check if the projection is orthographic.
void setValue(const QString &key, const QVariant &value)
Wrapper function which makes it possible to enable Debugging output with -DOPENFLIPPER_SETTINGS_DEBUG...
void viewingDirection(const ACG::Vec3d &_dir, const ACG::Vec3d &_up, int _viewer)
Set the viewing direction.
QString getSaveFileName(const QString &configProperty, QWidget *parent, const QString &caption, const QString &defaultDir, const QString &filter, QString *selectedFilter, QFileDialog::Options options, const QString &defaultSuffix)
Viewer::ViewerProperties & viewerProperties(int _id)
Get the viewer properties Use this functions to get basic viewer properties such as backgroundcolor o...
void setTrackBallCenter(const ACG::Vec3d &_center, int _viewer)
Set the trackball Center.
unsigned int glHeight() const
get height of QGLWidget
int objectCount()
Get the number of available objects.
void increaseObjectCount()
Decrease the number of current Object.
void set_parent(BaseNode *_parent)
Set the parent of this node.
const DataType DATA_ALL(UINT_MAX)
Identifier for all available objects.
void setFixedView(int _mode, int _viewer)
Set a fixed View for a viewer.
Range adapter for ObjectIterator.
void orthographicProjection(int _viewer)
Switch to orthographic Projection.
void setBackColor(OpenMesh::Vec4f _color)
Set the background color of the examiner widget.
QVariant value(const QString &key, const QVariant &defaultValue=QVariant()) const
void setViewObjectMarker(ViewObjectMarker *_marker)
bool examinerLightHandling()
returns if internal light handling is active.
ChildIter childrenBegin()
Returns: begin-iterator of children.
Definition: MeshNode2T.cc:325
virtual void makeCurrent()
Makes this widget the current widget for OpenGL operations.
void rotate(const ACG::Vec3d &_axis, const double _angle, const ACG::Vec3d &_center, int _viewer)
Rotate Scene around axis.
void traverse(BaseNode *_node, Action &_action)
Definition: SceneGraph.hh:143
unsigned int activeExaminer()
Get the id of the examiner which got the last mouse events.
std::string pickMode()
get active pick mode
QString getEncodedExaminerView()
Get the encoded view for the active examiner.
Viewer::ActionMode actionMode()
Get the current Action mode.
void setViewers(std::vector< glViewer * > _viewerWidgets)
Set the internal Viewer pointer ( DO NOT USE!! )
void setSceneGraphRootNodeGlobal(SeparatorNode *_root_node)
void setDefaultViewObjectMarker(ViewObjectMarker *_marker)
ActionMode
Enum listing action modes of the viewers.
ObjectReferenceRange objectReferences(IteratorRestriction _restriction, DataType _dataType)
Iterable object range.
int targetCount()
Get the number of target objects.
virtual ACG::Vec3d refinePick(ACG::SceneGraph::PickTarget _pickTarget, const ACG::Vec3d _hitPoint, const ACG::Vec3d _start, const ACG::Vec3d _dir, const unsigned int _targetIdx)
Refine picking.
bool getAllObjectIdentifiers(std::vector< int > &_identifiers)
Get identifiers of all objects.
void decreaseObjectCount()
Increase the number of current Object.
virtual std::string handles()
return the type this generator handles
void perspectiveProjection(int _viewer)
Switch to perspective Projection.
DLLEXPORT double fovy(int _viewer)
Get field of view angle.
ACG::SceneGraph::DrawModes::DrawMode drawMode(int _viewer)
Get the current draw Mode of a Viewer.
void setDataRoot(BaseObject *_root)
void lookAt(const ACG::Vec3d &_eye, const ACG::Vec3d &_center, const ACG::Vec3d &_up, int _viewer)
Set the look at transformation directly.
void drawMode(ACG::SceneGraph::DrawModes::DrawMode _mode)
set draw mode (No test if this mode is available!)
void viewerSnapshot(int _viewer, QImage &_image, int _width, int _height, bool _alpha, bool _hideCoordsys, int _samples)
Take a snapshot of a viewer.
void addGlobalStatusNode(ACG::SceneGraph::BaseNode *_node)
Adds a global status node.
void setScenePos(const ACG::Vec3d &_center, const double _radius, int _viewer)
Set the Scene position.
bool scenegraphRegionPick(ACG::SceneGraph::PickTarget _pickTarget, const QRegion &_region, QList< QPair< unsigned int, unsigned int > > &_list, QVector< float > *_depths, QVector< ACG::Vec3d > *_points)
double fovy() const
get field of view in y direction
Definition: GLState.cc:864
void allowRotation(bool _mode, int _viewer)
void addGlobalNode(ACG::SceneGraph::BaseNode *_node)
Add a global node.
void setDataSeparatorNodes(SeparatorNode *_dataSeparatorNode)
Set the internal data root node pointers ( DO NOT USE!! )
ACG::SceneGraph::BaseNode * getSceneGraphRootNode()
get scenegraph root node
BaseObject * childExists(int _objectId)
Check if the element exists in the subtree of this element.
Definition: BaseObject.cc:527
QMap< std::string,ACG::QtWidgets::SceneGraphWidgetGenerator * > getSceneGraphGeneratorList()
Add a scenegraph generator ( the handled type will be extracted from the generator) ...
void disableExaminerLightHandling()
Disable the core light handling.
int currentViewingDirection()
Pointer to the glState of the Viewer.
void addObjectRenderingNode(ACG::SceneGraph::BaseNode *_node)
Add scenegraph node modifing object rendering.
BaseNode * parent()
Get the nodes parent node.
Definition: MeshNode2T.cc:403
QStringList collectObjectComments(bool visibleOnly, bool targetedOnly)
void setSceneRadius(double _radius, int _viewer)
Set the background color of the examiner widget.
int visibleCount()
Get the number of visible objects.
QStringList collectObjectMaterials(bool visibleOnly, bool targetedOnly)
ACG::Vec4f backgroundColor()
Get current background color.
DLLEXPORT ObjectIterator objectsEnd()
Return Iterator to Object End.
void getCurrentViewImage(QImage &_image)
Returns a QImage of the current View.
void setSceneGraphRootNode(SeparatorNode *_root_node)
void setDrawMode(const ACG::SceneGraph::DrawModes::DrawMode &_mode, int _viewer)
Set the draw Mode of a Viewer. .
void addSceneGraphGenerator(ACG::QtWidgets::SceneGraphWidgetGenerator *_generator)
Add a scenegraph generator ( the handled type will be extracted from the generator) ...
virtual void snapshot(int _width=0, int _height=0, bool _alpha=false, bool _hideCoordsys=false, int samples=1)
bool getTargetIdentifiers(std::vector< int > &_identifiers)
Get the identifiers of all objects marked as a target object.
Vec3d viewing_direction() const
get viewing ray
Definition: GLState.hh:851