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