Developer Documentation

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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