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