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 #include <QRandomGenerator>
58 
59 namespace PluginFunctions {
60 
65 static BaseObject* objectRoot_ = 0;
66 
71 static std::vector< glViewer* > examiner_widgets_;
72 
77 static std::vector< Viewer::ViewerProperties* > viewerProperties_;
78 
80 static glViewer* examiner_widget_;
81 
83 static unsigned int activeExaminer_ = 0;
84 
85 static bool internalLightHandling_ = true;
86 
93 static SeparatorNode* dataRootNode_ = 0;
94 
98 static SeparatorNode* dataSeparatorNode_ = 0;
99 
102 static SeparatorNode* sceneGraphRootNodeGlobal_ = 0;
103 
106 static SeparatorNode* sceneGraphRootNode_ = 0;
107 
111 static Viewer::ViewerProperties dummyProperties(-1);
112 
113 
118 static ViewObjectMarker* defaultMarker_ = 0;
119 
124 static OFGLWidget* shareGLWidget_ = 0;
125 
128 static int viewerId_ = 0;
129 
131 static int objectCounter_ = 0;
132 
134 static int targetCounter_ = 0;
135 
137 static std::map<int, BaseObject*> objectMap_;
138 
140 QMap< std::string ,ACG::QtWidgets::SceneGraphWidgetGenerator* > sceneGraphGenerators_;
141 
142 void setDataRoot( BaseObject* _root ) {
143  objectRoot_ = _root;
144 }
145 
146 int viewers( ) {
147  return examiner_widgets_.size();
148 }
149 
151  internalLightHandling_ = false;
152 }
153 
155  return internalLightHandling_;
156 }
163 static QVector<QPair<QString, QString>> pluginCommandLineOptions_;
164 
165 int viewerId() {
166  return viewerId_;
167 }
168 
169 void setViewers( const std::vector< glViewer* >& _viewerWidgets ) {
170  PluginFunctions::examiner_widgets_ = _viewerWidgets;
171  PluginFunctions::examiner_widget_ = examiner_widgets_[0];
172 
173  // Generate a (hopefully) unique viewer id
174  QTime time = QTime::currentTime();
175  QRandomGenerator randi(time.hour() * 10 + time.minute() * 100 + time.second() * 1000 + time.msec() * 10000);
176  viewerId_ = static_cast<int>(randi.generate());
177 }
178 
179 void setViewerProperties( const std::vector< Viewer::ViewerProperties* >& _viewerProperties ) {
180  PluginFunctions::viewerProperties_ = _viewerProperties;
181 }
182 
183 void setActiveExaminer( const unsigned int _id ) {
184  activeExaminer_ = _id;
185 }
186 
187 glViewer* viewer(int _viewerId ) {
188  if ( _viewerId < 0 || _viewerId >= (int)examiner_widgets_.size() ) {
189  std::cerr << "Requested unknown viewer with id : " << _viewerId << std::endl;
190  return examiner_widgets_[activeExaminer()];
191  }
192 
193  return( examiner_widgets_[_viewerId] );
194 }
195 
196 unsigned int activeExaminer( ) {
197  return activeExaminer_;
198 }
199 
202 }
203 
205 QString getEncodedExaminerView(int _viewerId) {
206 
207  QString view;
208 
209  if ( _viewerId < 0 || _viewerId >= (int)examiner_widgets_.size() ) {
210  std::cerr << "Requested unknown viewer with id : " << _viewerId << std::endl;
211  examiner_widgets_[activeExaminer()]->encodeView ( view );
212  return view;
213  }
214 
215  examiner_widgets_[_viewerId]->encodeView ( view );
216  return view;
217 
218 }
219 
220 void setEncodedExaminerView( QString _view ) {
222 }
223 
224 void setEncodedExaminerView(int _viewerId , QString _view ) {
225 
226  // Consistency check. If viewer id is wrong, we set the currently active viewer.
227  if ( _viewerId < 0 || _viewerId >= (int)examiner_widgets_.size() ) {
228  std::cerr << "Requested unknown viewer with id : " << _viewerId << std::endl;
229  examiner_widgets_[activeExaminer()]->decodeView ( _view );
230  return;
231  }
232 
233  examiner_widgets_[_viewerId]->decodeView ( _view );
234 }
235 
236 void setDataSeparatorNodes( SeparatorNode* _dataSeparatorNode ) {
237 
238  // The function should only be called once by the core.
239 
240  // Set the separatorNode
241  PluginFunctions::dataSeparatorNode_ = _dataSeparatorNode;
242 
243 
244  if ( PluginFunctions::dataSeparatorNode_->nChildren() != 1 ){
245  std::cerr << "Only one child allowed for dataSeparatorNode on initialization!" << std::endl;
246  std::cerr << "The Core has initialized the scenegraph in a strange way!" << std::endl;
247  }
248 
249  // Set the root node for the data objects
250  // which has to be a child of the dataSeparatorNode_
251  PluginFunctions::dataRootNode_ = dynamic_cast<ACG::SceneGraph::SeparatorNode*> (*(PluginFunctions::dataSeparatorNode_->childrenBegin()) );
252 
253 }
254 
256  PluginFunctions::sceneGraphRootNode_ = _root_node;
257 }
258 
260  PluginFunctions::sceneGraphRootNodeGlobal_ = _root_node;
261 }
262 
263 bool getPickedObject(const size_t _node_idx , BaseObjectData*& _object) {
265  if ( o_it->picked( _node_idx ) ) {
266  _object = o_it;
267  return true;
268  }
269  }
270  return false;
271 }
272 
273 
274 bool getSourceIdentifiers( std::vector<int>& _identifiers ) {
275  _identifiers.clear();
276 
278  if ( o_it->source() )
279  _identifiers.push_back ( o_it->id() );
280  }
281  return ( ! _identifiers.empty() );
282 }
283 
284 bool getTargetIdentifiers( std::vector<int>& _identifiers ) {
285  _identifiers.clear();
286 
288  if ( o_it->target() )
289  _identifiers.push_back ( o_it->id() );
290  }
291  return ( !_identifiers.empty() );
292 }
293 
294 // ===============================================================================
295 // Get objects
296 // ===============================================================================
297 
298 bool getObject( const int _identifier , BaseObject*& _object ) {
299 
300  if ( _identifier == -1 )
301  return false;
302 
303  // Obsolete:
304  //_object = objectRoot_->childExists( _identifier );
305 
306  // Search for specified object in object map:
307  std::map<int, BaseObject*>::iterator it;
308  it = objectMap_.find(_identifier);
309  // Get object
310  _object = (it != objectMap_.end() ? it->second : 0);
311 
312  return ( _object != 0 );
313 }
314 
315 bool getObject( const int _identifier , BaseObjectData*& _object ) {
316 
317  if ( _identifier == -1 )
318  return false;
319 
320  // Obsolete: BaseObject* object = objectRoot_->childExists( _identifier );
321 
322  // Search for specified object in object map:
323  std::map<int, BaseObject*>::iterator it;
324  it = objectMap_.find(_identifier);
325  // Get object
326  BaseObject* object = (it != objectMap_.end() ? it->second : 0);
327 
328  _object = dynamic_cast< BaseObjectData* >(object);
329  return ( _object != 0 );
330 }
331 
332 int getObjectId( const QString& _name ) {
333  if(_name.isEmpty()) return -1;
334 
335  BaseObject* object = objectRoot_->childExists( _name );
336  return object ? object->id() : -1;
337 }
338 
339 // ===============================================================================
340 // ===============================================================================
341 
342 bool objectExists( const int _identifier ) {
343 
344  if ( _identifier == -1 )
345  return false;
346 
347  BaseObject* object = objectRoot_->childExists( _identifier );
348  return ( object != 0 );
349 }
350 
351 //===============================================================================
352 
353 bool getAllMeshes( std::vector<int>& _identifiers ) {
354 
355  _identifiers.clear();
356 
357  // find changed manipulator
358  for (auto* o_it : PluginFunctions::objects(PluginFunctions::ALL_OBJECTS,typeId("TriangleMesh")) ) {
359  _identifiers.push_back( o_it->id() );
360  }
361 
362  return (!_identifiers.empty());
363 }
364 
365 bool getAllObjectIdentifiers( std::vector<int>& _identifiers ) {
366 
367  _identifiers.clear();
368 
369  // find changed manipulator
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  ++count;
1018  }
1019 
1020  return ( count );
1021 }
1022 
1024  int count = 0;
1025 
1026  // find changed manipulator
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  _objects.push_back( o_it );
1048  }
1049 
1050 }
1051 
1052 
1054 void flyTo (const ACG::Vec3d &_position, const ACG::Vec3d &_center, double _time) {
1055  examiner_widgets_[activeExaminer_]->flyTo(_position,_center,_time);
1056 }
1057 
1058 
1060 void flyTo (const ACG::Vec3d &_center, bool _move_back, double _time) {
1062  ACG::Vec3d t = _center - eye;
1063  ACG::Vec3d e = eye + t * (_move_back ? -0.5f : 0.5f);
1064  examiner_widgets_[activeExaminer_]->flyTo(e, _center, _time);
1065 }
1066 
1067 
1069 void viewerSnapshot(int _viewer, QImage& _image, int _width, int _height, bool _alpha,
1070  bool _hideCoordsys, int _samples) {
1071 
1072  if ( _viewer == ACTIVE_VIEWER ) {
1073  examiner_widgets_[activeExaminer_]->snapshot(_image, _width, _height, _alpha, _hideCoordsys, _samples);
1074  } else if ( _viewer == ALL_VIEWERS )
1075  std::cerr << "Please select viewer to get snapshot!" << std::endl;
1076  else if ( ( _viewer >= 0 ) && _viewer < (int)examiner_widgets_.size() )
1077  examiner_widgets_[_viewer]->snapshot(_image, _width, _height, _alpha, _hideCoordsys, _samples);
1078  else
1079  std::cerr << "Requested illegal viewer for snapshot!!" << std::endl;
1080 }
1081 
1082 
1083 
1084 // ===============================================================================
1085 // Getting data from objects and casting between them
1086 // ===============================================================================
1087 
1089  if ( _object == 0 )
1090  return 0;
1091 
1092  return dynamic_cast< BaseObjectData* >(_object);
1093 }
1094 
1095 // ===============================================================================
1096 // Get the root of the object structure
1097 // ===============================================================================
1099  return (objectRoot_);
1100 }
1101 
1103  objectCounter_++;
1104 }
1105 
1106 // Increase the number of current Object
1108  objectCounter_--;
1109 
1110  if ( objectCounter_ < 0 )
1111  std::cerr << "Deleted more objects than created!!!" << std::endl;
1112 }
1113 
1115  targetCounter_++;
1116 }
1117 
1118 // Increase the number of current Object
1120  targetCounter_--;
1121 
1122  if ( targetCounter_ < 0 )
1123  std::cerr << "target object counter underflow!!!" << std::endl;
1124 }
1125 
1126 // ===============================================================================
1127 // Add an object to the internal object map
1128 // ===============================================================================
1129 void addObjectToMap(int _objectId, BaseObject* _object) {
1130 
1131  // Look if object's id already exists in map
1132  std::map<int, BaseObject*>::iterator it;
1133  it = objectMap_.find(_objectId);
1134  // If so return
1135  if(it != objectMap_.end()) return;
1136 
1137  // Add new object to map
1138  objectMap_.insert(std::pair<int, BaseObject*>(_objectId, _object));
1139 }
1140 
1141 // ===============================================================================
1142 // Remove an object from the internal object map
1143 // ===============================================================================
1144 void removeObjectFromMap(int _objectId) {
1145 
1146  // Look if object exists in map
1147  std::map<int, BaseObject*>::iterator it;
1148  it = objectMap_.find(_objectId);
1149 
1150  // Erase entry
1151  if(it != objectMap_.end()) objectMap_.erase(it);
1152 }
1153 
1154 
1156 
1157  // Check if we already have a generator for this type.
1158  if ( sceneGraphGenerators_.contains( _generator->handles() ) )
1159  return;
1160 
1161  // Store the generator
1162  sceneGraphGenerators_[_generator->handles() ] = _generator;
1163 }
1164 
1165 
1166 QMap< std::string ,ACG::QtWidgets::SceneGraphWidgetGenerator* > getSceneGraphGeneratorList(){
1167  return sceneGraphGenerators_;
1168 }
1169 
1170 QString getOpenFileName(const QString &configProperty,
1171  QWidget * parent, const QString & caption,
1172  const QString & defaultDir, const QString & filter,
1173  QString * selectedFilter, QFileDialog::Options options) {
1174 
1175  const QString dir = OpenFlipperSettings().value(configProperty, defaultDir).toString();
1176  const QString result = QFileDialog::getOpenFileName(parent, caption, dir,
1177  filter, selectedFilter, options);
1178  if (result.length())
1179  OpenFlipperSettings().setValue(configProperty, result);
1180  return result;
1181 }
1182 
1183 QString getSaveFileName(const QString &configProperty,
1184  QWidget * parent, const QString & caption,
1185  const QString & defaultDir, const QString & filter,
1186  QString * selectedFilter, QFileDialog::Options options,
1187  const QString & defaultSuffix) {
1188 
1189  const QString dir = OpenFlipperSettings().value(configProperty, defaultDir).toString();
1190 
1191  /*
1192  * We don't use this convenience wrapper any more since it
1193  * prevents us from setting the default suffix.
1194  *
1195  * const QString result = QFileDialog::getSaveFileName(
1196  * parent, caption, dir, filter, selectedFilter, options);
1197  */
1198 
1199  QFileDialog dialog(parent, caption, dir, filter);
1200  dialog.setOptions(options);
1201  dialog.setAcceptMode(QFileDialog::AcceptSave);
1202  if (selectedFilter && !selectedFilter->isEmpty())
1203  dialog.selectNameFilter(*selectedFilter);
1204  dialog.setDefaultSuffix(defaultSuffix);
1205  if (dialog.exec() == QDialog::Accepted) {
1206  if (selectedFilter)
1207  *selectedFilter = dialog.selectedNameFilter();
1208  QString result = dialog.selectedFiles().value(0);
1209  OpenFlipperSettings().setValue(configProperty, result);
1210  return result;
1211  }
1212  return QString();
1213 }
1214 
1215 QStringList collectObjectComments(bool visibleOnly, bool targetedOnly) {
1216  QStringList result;
1217  for (auto* o_it : PluginFunctions::objects(targetedOnly ? TARGET_OBJECTS : ALL_OBJECTS, DATA_ALL) ) {
1218  if (visibleOnly && !o_it->visible()) continue;
1219  result.append(o_it->getAllCommentsFlat());
1220  }
1221  return result;
1222 }
1223 
1224 QStringList collectObjectMaterials(bool visibleOnly, bool targetedOnly) {
1225  if (!ACG::SceneGraph::Material::support_json_serialization())
1226  return QStringList();
1227 
1228  QStringList result;
1229  for (auto* o_it : PluginFunctions::objects(targetedOnly ? TARGET_OBJECTS : ALL_OBJECTS, DATA_ALL) ) {
1230 
1231  if (visibleOnly && !o_it->visible()) continue;
1232 
1233  QString materialStr(QObject::tr("<not available>"));
1234  if (!o_it->materialNode())
1235  materialStr = QObject::tr("<not available: materialNode == null>");
1236  else
1237  materialStr = o_it->materialNode()->material().serializeToJson();
1238 
1239  if (!result.empty())
1240  result.last().append(QString::fromUtf8(","));
1241  result.append(QString::fromUtf8("\"%1\": %2").arg(o_it->name()).arg(materialStr));
1242  }
1243  return result;
1244 }
1245 
1246 void invalidatePickCaches() {
1247  for(size_t i = 0; i < examiner_widgets_.size(); ++i) {
1248  examiner_widgets_[i]->invalidatePickCache();
1249  }
1250 }
1251 
1253  return ObjectRange(_restriction, _dataType);
1254 }
1255 
1257  return ObjectReferenceRange(_restriction, _dataType);
1258 }
1259 
1260 const QVector<QPair<QString, QString> > &pluginCommandLineOptions()
1261 {
1262  return pluginCommandLineOptions_;
1263 }
1264 
1265 void setPluginCommandLineOptions(const QVector<QPair<QString, QString> > &_pluginCommandLineOptions)
1266 {
1267  pluginCommandLineOptions_ = _pluginCommandLineOptions;
1268 }
1269 
1270 } // 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.
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:873
void set_parent(BaseNode *_parent)
Set the parent of this node.
Definition: BaseNode.cc:146
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)
PickTarget
What target to use for picking.
Definition: PickTarget.hh:73
ChildIter childrenBegin()
Returns: begin-iterator of children.
Definition: BaseNode.hh:294
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.
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.
BaseNode * parent()
Get the nodes parent node.
Definition: BaseNode.hh:372
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 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).