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
59namespace PluginFunctions {
60
65static BaseObject* objectRoot_ = 0;
66
71static std::vector< glViewer* > examiner_widgets_;
72
77static std::vector< Viewer::ViewerProperties* > viewerProperties_;
78
80static glViewer* examiner_widget_;
81
83static unsigned int activeExaminer_ = 0;
84
85static bool internalLightHandling_ = true;
86
93static SeparatorNode* dataRootNode_ = 0;
94
98static SeparatorNode* dataSeparatorNode_ = 0;
99
102static SeparatorNode* sceneGraphRootNodeGlobal_ = 0;
103
106static SeparatorNode* sceneGraphRootNode_ = 0;
107
111static Viewer::ViewerProperties dummyProperties(-1);
112
113
118static ViewObjectMarker* defaultMarker_ = 0;
119
124static OFGLWidget* shareGLWidget_ = 0;
125
128static int viewerId_ = 0;
129
131static int objectCounter_ = 0;
132
134static int targetCounter_ = 0;
135
137static std::map<int, BaseObject*> objectMap_;
138
140QMap< std::string ,ACG::QtWidgets::SceneGraphWidgetGenerator* > sceneGraphGenerators_;
141
142void setDataRoot( BaseObject* _root ) {
143 objectRoot_ = _root;
144}
145
146int viewers( ) {
147 return examiner_widgets_.size();
148}
149
151 internalLightHandling_ = false;
152}
153
155 return internalLightHandling_;
156}
163static QVector<QPair<QString, QString>> pluginCommandLineOptions_;
164
165int viewerId() {
166 return viewerId_;
167}
168
169void 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
179void setViewerProperties( const std::vector< Viewer::ViewerProperties* >& _viewerProperties ) {
180 PluginFunctions::viewerProperties_ = _viewerProperties;
181}
182
183void setActiveExaminer( const unsigned int _id ) {
184 activeExaminer_ = _id;
185}
186
187glViewer* 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
196unsigned int activeExaminer( ) {
197 return activeExaminer_;
198}
199
202}
203
205QString 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
220void setEncodedExaminerView( const QString& _view ) {
222}
223
224void 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
236void 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
263bool 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
274bool 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
284bool 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
298bool 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
315bool 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
332int 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
342bool 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
353bool 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
365bool 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
382void 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
425QPoint mapToGlobal(const QPoint _point ) {
426 return examiner_widgets_[activeExaminer_]->glMapToGlobal(_point);
427}
428
429QPoint mapToLocal( const QPoint _point ) {
430 return examiner_widgets_[activeExaminer_]->glMapFromGlobal(_point);
431}
432
433void 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
466void 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
473void 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
480bool 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
486bool 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
497bool 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 const QPoint mouse_pos = PluginFunctions::adjustForDevicePixelRatio(_mousePos);
516 double x = mouse_pos.x();
517 double y = examiner_widget_->glHeight() - mouse_pos.y();
518
519 ACG::Vec3d mousePoint3d;
520 ACG::Vec3d direction;
521
522 viewingRay(x,y,mousePoint3d,direction);
523
524 *_hitPointPtr = _object->refinePick(_pickTarget,*_hitPointPtr, mousePoint3d , direction , _targetIdx );
525
526 }
527
528 }
529
530 return ok;
531}
532
533// Pick returning object and calling refine
535 const QPoint & _mousePos,
536 BaseObjectData*& _object,
537 size_t & _targetIdx,
538 const bool _refine,
539 ACG::Vec3d * _hitPointPtr ) {
540
541 return scenegraphPick(activeExaminer_,_pickTarget,_mousePos, _object,_targetIdx,_refine,_hitPointPtr );
542
543}
544
545
546
547
549 const QRegion& _region,
550 QList<QPair<size_t, size_t> >& _list,
551 QVector<float>* _depths,
552 QVector<ACG::Vec3d>* _points)
553{
554 return examiner_widgets_[activeExaminer_]->pick_region( _pickTarget, _region, _list, _depths, _points);
555}
556
557bool scenegraphRegionPick( const unsigned int _examiner,
558 ACG::SceneGraph::PickTarget _pickTarget,
559 const QRegion& _region,
560 QList<QPair<size_t, size_t> >& _list,
561 QVector<float>* _depths,
562 QVector<ACG::Vec3d>* _points)
563{
564 if ( _examiner >= examiner_widgets_.size() ) {
565 std::cerr << "Wrong examiner id" << std::endl;
566 return false;
567 }
568 return examiner_widgets_[_examiner]->pick_region( _pickTarget, _region, _list, _depths, _points);
569}
570
571//Warning : Dont use template function as external static pointer for examiner widget is not resolved correctly!!
573 // Single pass action, as the mouse action will only update the graph.
574 // If its changed, it will be set to dirty and an automatic redraw is triggered.
575 ACG::SceneGraph::traverse(sceneGraphRootNode_, _action );
576}
577
578const std::string pickMode () {
579 // No seperate draw modes available all should have the same so take first
580 return viewerProperties().pickMode();
581}
582
583void pickMode ( const std::string& _mode) {
584 // switch to default marker
586 viewerProperties().pickMode(_mode);
587}
588
590 return viewerProperties().actionMode();
591}
592
594
596}
597
598void shareGLWidget(OFGLWidget *_widget)
599{
600 shareGLWidget_ = _widget;
601}
602
603OFGLWidget *shareGLWidget()
604{
605 return shareGLWidget_;
606}
607
608void getCurrentViewImage(QImage& _image) {
609 viewer( activeExaminer() )->snapshot( _image );
610}
611
613 if ( _id >= (int)viewerProperties_.size() ) {
614 std::cerr << " Error, requested properties for non-existing Viewer!" << std::endl;
615 return dummyProperties;
616 }
617
618 if ( _id == -1 )
619 _id = activeExaminer_;
620
621 return ( *viewerProperties_[_id] );
622
623}
624
625void perspectiveProjection( int _viewer ) {
626 if ( _viewer == ACTIVE_VIEWER ) {
627 examiner_widgets_[activeExaminer_]->perspectiveProjection();
628 } else if ( _viewer == ALL_VIEWERS )
629 for ( uint i = 0 ; i < examiner_widgets_.size(); ++i )
630 examiner_widgets_[i]->perspectiveProjection();
631 else if ( ( _viewer >= 0 ) && _viewer < (int)examiner_widgets_.size() )
632 examiner_widgets_[_viewer]->perspectiveProjection();
633 else
634 std::cerr << "Requested illegal viewer for perspectiveProjection()!!" << std::endl;
635}
636
637void orthographicProjection( int _viewer ) {
638 if ( _viewer == ACTIVE_VIEWER ) {
639 examiner_widgets_[activeExaminer_]->orthographicProjection();
640 } else if ( _viewer == ALL_VIEWERS )
641 for ( uint i = 0 ; i < examiner_widgets_.size(); ++i )
642 examiner_widgets_[i]->orthographicProjection();
643 else if ( ( _viewer >= 0 ) && _viewer < (int)examiner_widgets_.size() )
644 examiner_widgets_[_viewer]->orthographicProjection();
645 else
646 std::cerr << "Requested illegal viewer for orthographicProjection()!!" << std::endl;
647}
648
649void setFOVY( double _fovy) {
650
651 // Set FOVY for all viewers
652 for ( uint i = 0 ; i < examiner_widgets_.size(); ++i )
653 examiner_widgets_[i]->setFOVY(_fovy);
654}
655
656void allowRotation(bool _mode, int _viewer ) {
657 if ( _viewer == ACTIVE_VIEWER ) {
658 examiner_widgets_[activeExaminer_]->allowRotation(_mode);
659 } else if ( _viewer == ALL_VIEWERS )
660 for ( uint i = 0 ; i < examiner_widgets_.size(); ++i )
661 examiner_widgets_[i]->allowRotation(_mode);
662 else if ( ( _viewer >= 0 ) && _viewer < (int)examiner_widgets_.size() )
663 examiner_widgets_[_viewer]->allowRotation(_mode);
664 else {
665 std::cerr << "Requested illegal viewer for allowRotation!!" << std::endl;
666 return;
667 }
668
669 if ( _viewer == ACTIVE_VIEWER )
671 else
672 viewerProperties( _viewer ).rotationLocked( !_mode );
673}
674
675bool allowRotation( int _viewer ) {
676
677 if ( ( _viewer >= 0 ) && _viewer < (int)examiner_widgets_.size() )
678 return examiner_widgets_[_viewer]->allowRotation();
679 else {
680
681 std::cerr << "Requested illegal viewer for isRotationAllowed!!" << std::endl;
682 return false;
683 }
684}
685
687 examiner_widget_->makeCurrent();
688}
689
690void viewingDirection(const ACG::Vec3d &_dir, const ACG::Vec3d &_up , int _viewer ) {
691 if ( _viewer == ACTIVE_VIEWER ) {
692 examiner_widgets_[activeExaminer_]->viewingDirection(_dir,_up);
693 } else if ( _viewer == ALL_VIEWERS )
694 for ( uint i = 0 ; i < examiner_widgets_.size(); ++i )
695 examiner_widgets_[i]->viewingDirection(_dir,_up);
696 else if ( ( _viewer >= 0 ) && _viewer < (int)examiner_widgets_.size() )
697 examiner_widgets_[_viewer]->viewingDirection(_dir,_up);
698 else
699 std::cerr << "Requested illegal viewer for viewingDirection!!" << std::endl;
700}
701
702void lookAt(const ACG::Vec3d& _eye, const ACG::Vec3d& _center, const ACG::Vec3d& _up, int _viewer) {
703
704 if ( _viewer == ACTIVE_VIEWER ) {
705 examiner_widgets_[activeExaminer_]->lookAt(_eye,_center, _up);
706 } else if ( _viewer == ALL_VIEWERS )
707 for ( uint i = 0 ; i < examiner_widgets_.size(); ++i )
708 examiner_widgets_[i]->lookAt(_eye,_center, _up);
709 else if ( ( _viewer >= 0 ) && _viewer < (int)examiner_widgets_.size() )
710 examiner_widgets_[_viewer]->lookAt(_eye,_center, _up);
711 else
712 std::cerr << "Requested illegal viewer for viewingDirection!!" << std::endl;
713}
714
715const ACG::Vec3d trackBallCenter( int _viewer ) {
716 if ( _viewer == ACTIVE_VIEWER ) {
717 return examiner_widgets_[activeExaminer_]->trackBallCenter();
718 } else if ( _viewer == ALL_VIEWERS )
719 for ( uint i = 0 ; i < examiner_widgets_.size(); ++i )
720 return examiner_widgets_[i]->trackBallCenter( );
721 else if ( ( _viewer >= 0 ) && _viewer < (int)examiner_widgets_.size() )
722 return examiner_widgets_[_viewer]->trackBallCenter( );
723 else
724 std::cerr << "Requested illegal viewer for setTrackBallCenter!!" << std::endl;
725
726 return examiner_widgets_[activeExaminer_]->trackBallCenter();
727}
728
729void setTrackBallCenter(const ACG::Vec3d& _center, int _viewer ) {
730 if ( _viewer == ACTIVE_VIEWER ) {
731 examiner_widgets_[activeExaminer_]->setTrackBallCenter( _center );
732 } else if ( _viewer == ALL_VIEWERS )
733 for ( uint i = 0 ; i < examiner_widgets_.size(); ++i )
734 examiner_widgets_[i]->setTrackBallCenter( _center );
735 else if ( ( _viewer >= 0 ) && _viewer < (int)examiner_widgets_.size() )
736 examiner_widgets_[_viewer]->setTrackBallCenter( _center );
737 else
738 std::cerr << "Requested illegal viewer for setTrackBallCenter!!" << std::endl;
739}
740
741void setScenePos(const ACG::Vec3d& _center,const double _radius, int _viewer ) {
742 if ( _viewer == ACTIVE_VIEWER ) {
743 examiner_widgets_[activeExaminer_]->setScenePos( _center, _radius );
744 } else if ( _viewer == ALL_VIEWERS )
745 for ( uint i = 0 ; i < examiner_widgets_.size(); ++i )
746 examiner_widgets_[i]->setScenePos( _center, _radius );
747 else if ( ( _viewer >= 0 ) && _viewer < (int)examiner_widgets_.size() )
748 examiner_widgets_[_viewer]->setScenePos( _center, _radius );
749 else
750 std::cerr << "Requested illegal viewer for setScenePos!!" << std::endl;
751}
752
753void setScenePos(const ACG::Vec3d& _center, int _viewer ) {
754 if ( _viewer == ACTIVE_VIEWER ) {
755 examiner_widgets_[activeExaminer_]->setScenePos( _center, examiner_widgets_[activeExaminer_]->scene_radius() );
756 } else if ( _viewer == ALL_VIEWERS )
757 for ( uint i = 0 ; i < examiner_widgets_.size(); ++i )
758 examiner_widgets_[i]->setScenePos( _center, examiner_widgets_[i]->scene_radius() );
759 else if ( ( _viewer >= 0 ) && _viewer < (int)examiner_widgets_.size() )
760 examiner_widgets_[_viewer]->setScenePos( _center, examiner_widgets_[_viewer]->scene_radius() );
761 else
762 std::cerr << "Requested illegal viewer for setScenePos!!" << std::endl;
763}
764
765void setSceneCenter(const ACG::Vec3d& _center, int _viewer) {
766
767 if (_viewer == ACTIVE_VIEWER) {
768 examiner_widgets_[activeExaminer_]->setSceneCenter(_center);
769 } else if (_viewer == ALL_VIEWERS) {
770
771 for (uint i = 0; i < examiner_widgets_.size(); ++i) {
772 examiner_widgets_[i]->setSceneCenter(_center);
773 }
774 } else if ((_viewer >= 0) && _viewer < (int) examiner_widgets_.size()) {
775 examiner_widgets_[_viewer]->setSceneCenter(_center);
776 } else {
777 std::cerr << "Requested illegal viewer for setSceneCenter!!" << std::endl;
778 }
779}
780
781const ACG::Vec3d sceneCenter(int _viewer) {
782
783 if (_viewer == ACTIVE_VIEWER) {
784 return examiner_widgets_[activeExaminer_]->scene_center();
785 } else if (_viewer == ALL_VIEWERS)
786 std::cerr << "Please select viewer to get sceneCenter!" << std::endl;
787 else if ((_viewer >= 0) && _viewer < (int) examiner_widgets_.size())
788 return examiner_widgets_[_viewer]->scene_center();
789 else
790 std::cerr << "Requested illegal viewer for sceneCenter!!" << std::endl;
791
792 return examiner_widgets_[activeExaminer_]->scene_center();
793}
794
795double sceneRadius() {
796 return examiner_widgets_[activeExaminer_]->scene_radius();
797}
798
799double sceneRadius( int _viewer ) {
800 if ( _viewer == ACTIVE_VIEWER ) {
801 return examiner_widgets_[activeExaminer_]->scene_radius();
802 } else if ( _viewer == ALL_VIEWERS )
803 std::cerr << "Illegal request for scene radius. Please select one viewer!" << std::endl;
804 else if ( ( _viewer >= 0 ) && _viewer < (int)examiner_widgets_.size() )
805 return examiner_widgets_[_viewer]->scene_radius();
806 else
807 std::cerr << "Requested illegal viewer for translate!!" << std::endl;
808
809 return -1;
810}
811
812void setSceneRadius(double _radius, int _viewer ) {
813 if ( _viewer == ACTIVE_VIEWER ) {
814 examiner_widgets_[activeExaminer_]->setSceneRadius(_radius);
815 } else if ( _viewer == ALL_VIEWERS )
816 for ( uint i = 0 ; i < examiner_widgets_.size(); ++i )
817 examiner_widgets_[i]->setSceneRadius(_radius);
818 else if ( ( _viewer >= 0 ) && _viewer < (int)examiner_widgets_.size() )
819 examiner_widgets_[_viewer]->setSceneRadius(_radius);
820 else
821 std::cerr << "Requested illegal viewer for translate!!" << std::endl;
822}
823
824void translate( const ACG::Vec3d &_vector , int _viewer ) {
825 if ( _viewer == ACTIVE_VIEWER ) {
826 examiner_widgets_[activeExaminer_]->translate(_vector);
827 } else if ( _viewer == ALL_VIEWERS )
828 for ( uint i = 0 ; i < examiner_widgets_.size(); ++i )
829 examiner_widgets_[i]->translate(_vector);
830 else if ( ( _viewer >= 0 ) && _viewer < (int)examiner_widgets_.size() )
831 examiner_widgets_[_viewer]->translate(_vector);
832 else
833 std::cerr << "Requested illegal viewer for translate!!" << std::endl;
834}
835
836void rotate(const ACG::Vec3d& _axis,
837 const double _angle,
838 const ACG::Vec3d& _center,
839 int _viewer )
840{
841 if ( _viewer == ACTIVE_VIEWER ) {
842 examiner_widgets_[activeExaminer_]->rotate(_axis,_angle,_center);
843 } else if ( _viewer == ALL_VIEWERS )
844 for ( uint i = 0 ; i < examiner_widgets_.size(); ++i )
845 examiner_widgets_[i]->rotate(_axis,_angle,_center);
846 else if ( ( _viewer >= 0 ) && _viewer < (int)examiner_widgets_.size() )
847 examiner_widgets_[_viewer]->rotate(_axis,_angle,_center);
848 else
849 std::cerr << "Requested illegal viewer for rotate!!" << std::endl;
850}
851
852void viewHome(int _viewer) {
853 if ( _viewer == ACTIVE_VIEWER ) {
854 examiner_widgets_[activeExaminer_]->home();
855 } else if ( _viewer == ALL_VIEWERS )
856 for ( uint i = 0 ; i < examiner_widgets_.size(); ++i )
857 examiner_widgets_[i]->home();
858 else if ( ( _viewer >= 0 ) && _viewer < (int)examiner_widgets_.size() )
859 examiner_widgets_[_viewer]->home();
860 else
861 std::cerr << "Requested illegal viewer for viewHome!!" << std::endl;
862}
863
864void viewAll(int _viewer) {
865 if ( _viewer == ACTIVE_VIEWER ) {
866 examiner_widgets_[activeExaminer_]->viewAll();
867 } else if ( _viewer == ALL_VIEWERS )
868 for ( uint i = 0 ; i < examiner_widgets_.size(); ++i )
869 examiner_widgets_[i]->viewAll();
870 else if ( ( _viewer >= 0 ) && _viewer < (int)examiner_widgets_.size() )
871 examiner_widgets_[_viewer]->viewAll();
872 else
873 std::cerr << "Requested illegal viewer for viewAll!!" << std::endl;
874}
875
877 if ( _viewer == ACTIVE_VIEWER ) {
878 return viewerProperties(activeExaminer_).glState().viewing_direction();
879 } else if ( _viewer == ALL_VIEWERS )
880 std::cerr << "Please select viewer to get viewing direction!" << std::endl;
881 else if ( ( _viewer >= 0 ) && _viewer < (int)examiner_widgets_.size() )
882 return viewerProperties(_viewer).glState().viewing_direction();
883 else
884 std::cerr << "Requested illegal viewer for viewingDirection!!" << std::endl;
885
887}
888
889bool isProjectionOrthographic( int _viewer ) {
890
891 if ( _viewer == ACTIVE_VIEWER) {
892 return (examiner_widgets_[activeExaminer_]->projectionMode() == 0);
893 } else if ( ( _viewer >= 0 ) && _viewer < (int)examiner_widgets_.size() ){
894 return ( examiner_widgets_[_viewer]->projectionMode() == 0); //ORTHOGRAPHIC_PROJECTION ?
895 } else
896 std::cerr << "Requested illegal viewer for isProjectionOrthographic!!" << std::endl;
897
898 return false;
899}
900
901ACG::Vec3d eyePos(int _viewer) {
902 if ( _viewer == ACTIVE_VIEWER ) {
903 return viewerProperties(activeExaminer_).glState().eye();
904 } else if ( _viewer == ALL_VIEWERS )
905 std::cerr << "Please select viewer to get eyePos!" << std::endl;
906 else if ( ( _viewer >= 0 ) && _viewer < (int)examiner_widgets_.size() )
907 return viewerProperties(_viewer).glState().eye();
908 else
909 std::cerr << "Requested illegal viewer for eyePos!!" << std::endl;
910
911 return viewerProperties().glState().eye();
912}
913
914ACG::Vec3d upVector(int _viewer) {
915 if ( _viewer == ACTIVE_VIEWER ) {
916 return viewerProperties(activeExaminer_).glState().up();
917 } else if ( _viewer == ALL_VIEWERS )
918 std::cerr << "Please select viewer to get up vector!" << std::endl;
919 else if ( ( _viewer >= 0 ) && _viewer < (int)examiner_widgets_.size() )
920 return viewerProperties(_viewer).glState().up();
921 else
922 std::cerr << "Requested illegal viewer for up vector!!" << std::endl;
923
924 return viewerProperties().glState().up();
925}
926
930double fovy(int _viewer) {
931 if ( _viewer == ACTIVE_VIEWER ) {
932 return viewerProperties(activeExaminer_).glState().fovy();
933 } else if ( _viewer == ALL_VIEWERS )
934 std::cerr << "Please select viewer to get fovy!" << std::endl;
935 else if ( ( _viewer >= 0 ) && _viewer < (int)examiner_widgets_.size() )
936 return viewerProperties(_viewer).glState().fovy();
937 else
938 std::cerr << "Requested illegal viewer for fovy!!" << std::endl;
939
940 return viewerProperties().glState().fovy();
941}
942
944{
945 for ( uint i = 0 ; i < examiner_widgets_.size(); ++i )
947}
948
950{
951 defaultMarker_ = _marker;
952}
953
955{
956 return defaultMarker_;
957}
958
959QPoint adjustForDevicePixelRatio(const QPoint &point)
960{
962}
963QPointF adjustForDevicePixelRatio(const QPointF &point)
964{
966}
967
968
970 return PluginFunctions::sceneGraphRootNode_;
971}
972
974 return PluginFunctions::dataRootNode_;
975}
976
978 if (PluginFunctions::sceneGraphRootNode_){
979
980 // get the current parent Node
981 ACG::SceneGraph::BaseNode* parent = sceneGraphRootNodeGlobal_->parent();
982
983 // Move the node to the new parent
984 _node->set_parent(parent);
985
986 // move sceneGraphRootNodeGlobal_ to the new parent
987 sceneGraphRootNodeGlobal_->set_parent(_node);
988 }
989}
990
992 if (PluginFunctions::sceneGraphRootNode_)
993 _node->set_parent( PluginFunctions::sceneGraphRootNodeGlobal_ );
994}
995
996
998 if (PluginFunctions::sceneGraphRootNode_){
999
1000 // get the current parent Node
1001 ACG::SceneGraph::BaseNode* parent = dataRootNode_->parent();
1002
1003 // Move the node to the new parent
1004 _node->set_parent(parent);
1005
1006 // move dataRootNode_ to the new parent
1007 dataRootNode_->set_parent(_node);
1008 }
1009
1010}
1011
1013 return(objectCounter_);
1014}
1015
1016
1017
1019 return ( targetCounter_ );
1020}
1021
1023 int count = 0;
1024
1025 // find changed manipulator
1027 ++count;
1028 }
1029
1030 return ( count );
1031}
1032
1034 int count = 0;
1035
1036 // find changed manipulator
1038 if ( o_it->visible() )
1039 ++count;
1040 }
1041
1042 return ( count );
1043
1044}
1045
1046
1051void get_all_objects( std::vector < BaseObjectData*>& _objects ) {
1052
1053 _objects.clear();
1054
1055 // find changed manipulator
1057 _objects.push_back( o_it );
1058 }
1059
1060}
1061
1062
1064void flyTo (const ACG::Vec3d &_position, const ACG::Vec3d &_center, double _time) {
1065 examiner_widgets_[activeExaminer_]->flyTo(_position,_center,_time);
1066}
1067
1068
1070void flyTo (const ACG::Vec3d &_center, bool _move_back, double _time) {
1072 ACG::Vec3d t = _center - eye;
1073 ACG::Vec3d e = eye + t * (_move_back ? -0.5f : 0.5f);
1074 examiner_widgets_[activeExaminer_]->flyTo(e, _center, _time);
1075}
1076
1077
1079void viewerSnapshot(int _viewer, QImage& _image, int _width, int _height, bool _alpha,
1080 bool _hideCoordsys, int _samples) {
1081
1082 if ( _viewer == ACTIVE_VIEWER ) {
1083 examiner_widgets_[activeExaminer_]->snapshot(_image, _width, _height, _alpha, _hideCoordsys, _samples);
1084 } else if ( _viewer == ALL_VIEWERS )
1085 std::cerr << "Please select viewer to get snapshot!" << std::endl;
1086 else if ( ( _viewer >= 0 ) && _viewer < (int)examiner_widgets_.size() )
1087 examiner_widgets_[_viewer]->snapshot(_image, _width, _height, _alpha, _hideCoordsys, _samples);
1088 else
1089 std::cerr << "Requested illegal viewer for snapshot!!" << std::endl;
1090}
1091
1092
1093
1094// ===============================================================================
1095// Getting data from objects and casting between them
1096// ===============================================================================
1097
1099 if ( _object == 0 )
1100 return 0;
1101
1102 return dynamic_cast< BaseObjectData* >(_object);
1103}
1104
1105// ===============================================================================
1106// Get the root of the object structure
1107// ===============================================================================
1109 return (objectRoot_);
1110}
1111
1113 objectCounter_++;
1114}
1115
1116// Increase the number of current Object
1118 objectCounter_--;
1119
1120 if ( objectCounter_ < 0 )
1121 std::cerr << "Deleted more objects than created!!!" << std::endl;
1122}
1123
1125 targetCounter_++;
1126}
1127
1128// Increase the number of current Object
1130 targetCounter_--;
1131
1132 if ( targetCounter_ < 0 )
1133 std::cerr << "target object counter underflow!!!" << std::endl;
1134}
1135
1136// ===============================================================================
1137// Add an object to the internal object map
1138// ===============================================================================
1139void addObjectToMap(int _objectId, BaseObject* _object) {
1140
1141 // Look if object's id already exists in map
1142 std::map<int, BaseObject*>::iterator it;
1143 it = objectMap_.find(_objectId);
1144 // If so return
1145 if(it != objectMap_.end()) return;
1146
1147 // Add new object to map
1148 objectMap_.insert(std::pair<int, BaseObject*>(_objectId, _object));
1149}
1150
1151// ===============================================================================
1152// Remove an object from the internal object map
1153// ===============================================================================
1154void removeObjectFromMap(int _objectId) {
1155
1156 // Look if object exists in map
1157 std::map<int, BaseObject*>::iterator it;
1158 it = objectMap_.find(_objectId);
1159
1160 // Erase entry
1161 if(it != objectMap_.end()) objectMap_.erase(it);
1162}
1163
1164
1166
1167 // Check if we already have a generator for this type.
1168 if ( sceneGraphGenerators_.contains( _generator->handles() ) )
1169 return;
1170
1171 // Store the generator
1172 sceneGraphGenerators_[_generator->handles() ] = _generator;
1173}
1174
1175
1176QMap< std::string ,ACG::QtWidgets::SceneGraphWidgetGenerator* > getSceneGraphGeneratorList(){
1177 return sceneGraphGenerators_;
1178}
1179
1180QString getOpenFileName(const QString &configProperty,
1181 QWidget * parent, const QString & caption,
1182 const QString & defaultDir, const QString & filter,
1183 QString * selectedFilter, QFileDialog::Options options) {
1184
1185 const QString dir = OpenFlipperSettings().value(configProperty, defaultDir).toString();
1186 const QString result = QFileDialog::getOpenFileName(parent, caption, dir,
1187 filter, selectedFilter, options);
1188 if (result.length())
1189 OpenFlipperSettings().setValue(configProperty, result);
1190 return result;
1191}
1192
1193QString getSaveFileName(const QString &configProperty,
1194 QWidget * parent, const QString & caption,
1195 const QString & defaultDir, const QString & filter,
1196 QString * selectedFilter, QFileDialog::Options options,
1197 const QString & defaultSuffix) {
1198
1199 const QString dir = OpenFlipperSettings().value(configProperty, defaultDir).toString();
1200
1201 /*
1202 * We don't use this convenience wrapper any more since it
1203 * prevents us from setting the default suffix.
1204 *
1205 * const QString result = QFileDialog::getSaveFileName(
1206 * parent, caption, dir, filter, selectedFilter, options);
1207 */
1208
1209 QFileDialog dialog(parent, caption, dir, filter);
1210 dialog.setOptions(options);
1211 dialog.setAcceptMode(QFileDialog::AcceptSave);
1212 if (selectedFilter && !selectedFilter->isEmpty())
1213 dialog.selectNameFilter(*selectedFilter);
1214 dialog.setDefaultSuffix(defaultSuffix);
1215 if (dialog.exec() == QDialog::Accepted) {
1216 if (selectedFilter)
1217 *selectedFilter = dialog.selectedNameFilter();
1218 QString result = dialog.selectedFiles().value(0);
1219 OpenFlipperSettings().setValue(configProperty, result);
1220 return result;
1221 }
1222 return QString();
1223}
1224
1225QStringList collectObjectComments(bool visibleOnly, bool targetedOnly) {
1226 QStringList result;
1227 for (auto* o_it : PluginFunctions::objects(targetedOnly ? TARGET_OBJECTS : ALL_OBJECTS, DATA_ALL) ) {
1228 if (visibleOnly && !o_it->visible()) continue;
1229 result.append(o_it->getAllCommentsFlat());
1230 }
1231 return result;
1232}
1233
1234QStringList collectObjectMaterials(bool visibleOnly, bool targetedOnly) {
1235 if (!ACG::SceneGraph::Material::support_json_serialization())
1236 return QStringList();
1237
1238 QStringList result;
1239 for (auto* o_it : PluginFunctions::objects(targetedOnly ? TARGET_OBJECTS : ALL_OBJECTS, DATA_ALL) ) {
1240
1241 if (visibleOnly && !o_it->visible()) continue;
1242
1243 QString materialStr(QObject::tr("<not available>"));
1244 if (!o_it->materialNode())
1245 materialStr = QObject::tr("<not available: materialNode == null>");
1246 else
1247 materialStr = o_it->materialNode()->material().serializeToJson();
1248
1249 if (!result.empty())
1250 result.last().append(QString::fromUtf8(","));
1251 result.append(QString::fromUtf8("\"%1\": %2").arg(o_it->name()).arg(materialStr));
1252 }
1253 return result;
1254}
1255
1256void invalidatePickCaches() {
1257 for(size_t i = 0; i < examiner_widgets_.size(); ++i) {
1258 examiner_widgets_[i]->invalidatePickCache();
1259 }
1260}
1261
1263 return ObjectRange(_restriction, _dataType);
1264}
1265
1267 return ObjectReferenceRange(_restriction, _dataType);
1268}
1269
1270const QVector<QPair<QString, QString> > &pluginCommandLineOptions()
1271{
1272 return pluginCommandLineOptions_;
1273}
1274
1275void setPluginCommandLineOptions(const QVector<QPair<QString, QString> > &_pluginCommandLineOptions)
1276{
1277 pluginCommandLineOptions_ = _pluginCommandLineOptions;
1278}
1279
1280} // End namespace PluginFunctions
DLLEXPORT DataType typeId(QString _name)
Given a dataType Identifier string this function will return the id of the datatype.
Definition: Types.cc:139
const DataType DATA_ALL(UINT_MAX)
Identifier for all available objects.
#define DLLEXPORT
DLLEXPORT OpenFlipperQSettings & OpenFlipperSettings()
QSettings object containing all program settings of OpenFlipper.
ActionMode
Enum listing action modes of the viewers.
Vec3d eye() const
get eye point
Definition: GLState.cc:886
Vec3d viewing_direction() const
get viewing ray
Definition: GLState.hh:873
void viewing_ray(int _x, int _y, Vec3d &_origin, Vec3d &_direction) const
Definition: GLState.cc:930
double fovy() const
get field of view in y direction
Definition: GLState.cc:868
Vec3d up() const
get up-vector w.r.t. camera coordinates
Definition: GLState.cc:906
virtual std::string handles()
return the type this generator handles
ChildIter childrenBegin()
Returns: begin-iterator of children.
Definition: BaseNode.hh:294
BaseNode * parent()
Get the nodes parent node.
Definition: BaseNode.hh:372
void set_parent(BaseNode *_parent)
Set the parent of this node.
Definition: BaseNode.cc:146
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.
BaseObject * childExists(int _objectId)
Check if the element exists in the subtree of this element.
Definition: BaseObject.cc:514
int id() const
Definition: BaseObject.cc:188
Predefined datatypes.
Definition: DataTypes.hh:83
QVariant value(const QString &key, const QVariant &defaultValue=QVariant()) const
void setValue(const QString &key, const QVariant &value)
Wrapper function which makes it possible to enable Debugging output with -DOPENFLIPPER_SETTINGS_DEBUG...
Range adapter for ObjectIterator.
Range adapter for ObjectIterator.
int currentViewingDirection()
Pointer to the glState of the Viewer.
void objectMarker(ViewObjectMarker *_marker)
set object marker for viewer
ACG::Vec4f backgroundColor()
Get current background color.
Viewer::ActionMode actionMode()
get the action mode
void drawMode(ACG::SceneGraph::DrawModes::DrawMode _mode)
set draw mode (No test if this mode is available!)
std::string pickMode()
get active pick mode
QPoint adjustForDevicePixelRatio(QPoint const &point) const
adjust point for DPR
ACG::GLState & glState()
Get the glState of the Viewer.
bool rotationLocked()
Pointer to the glState of the Viewer.
virtual void makeCurrent()
Makes this widget the current widget for OpenGL operations.
virtual void snapshot(int _width=0, int _height=0, bool _alpha=false, bool _hideCoordsys=false, int samples=1)
unsigned int glHeight() const
get height of QGLWidget
void traverse(BaseNode *_node, Action &_action)
Definition: SceneGraph.hh:137
PickTarget
What target to use for picking.
Definition: PickTarget.hh:74
void translate(const ACG::Vec3d &_vector, int _viewer)
Translate viewer pos by given vector.
void getCurrentViewImage(QImage &_image)
Returns a QImage of the current View.
void perspectiveProjection(int _viewer)
Switch to perspective Projection.
void addSceneGraphGenerator(ACG::QtWidgets::SceneGraphWidgetGenerator *_generator)
Add a scenegraph generator ( the handled type will be extracted from the generator)
void setSceneRadius(double _radius, int _viewer)
Set the background color of the examiner widget.
int targetCount()
Get the number of target objects.
void addObjectRenderingNode(ACG::SceneGraph::BaseNode *_node)
Add scenegraph node modifing object rendering.
ACG::Vec3d eyePos(int _viewer)
Get the current viewer position.
void addGlobalNode(ACG::SceneGraph::BaseNode *_node)
Add a global node.
double sceneRadius()
Returns the current scene radius from the active examiner widget.
const QVector< QPair< QString, QString > > & pluginCommandLineOptions()
Get command line plugin settings as key-value pairs.
int viewerId()
Return unique viewer id.
void viewerSnapshot(int _viewer, QImage &_image, int _width, int _height, bool _alpha, bool _hideCoordsys, int _samples)
Take a snapshot of a viewer.
void shareGLWidget(OFGLWidget *_widget)
Sets the main QGLWidget for gl data sharing.
Viewer::ViewerProperties & viewerProperties(int _id)
Get the viewer properties Use this functions to get basic viewer properties such as backgroundcolor o...
int getObjectId(const QString &_name)
void viewingDirection(const ACG::Vec3d &_dir, const ACG::Vec3d &_up, int _viewer)
Set the viewing direction.
void viewHome(int _viewer)
Go to home position.
void setBackColor(OpenMesh::Vec4f _color)
Set the background color of the examiner widget.
bool scenegraphRegionPick(ACG::SceneGraph::PickTarget _pickTarget, const QRegion &_region, QList< QPair< size_t, size_t > > &_list, QVector< float > *_depths, QVector< ACG::Vec3d > *_points)
void setTrackBallCenter(const ACG::Vec3d &_center, int _viewer)
Set the trackball Center.
QStringList collectObjectMaterials(bool visibleOnly, bool targetedOnly)
QPoint adjustForDevicePixelRatio(const QPoint &point)
int sourceCount()
Get the number of source objects.
DLLEXPORT double fovy(int _viewer)
Get field of view angle.
void setSceneGraphRootNode(SeparatorNode *_root_node)
bool getObject(const int _identifier, BaseObject *&_object)
Get the object which has the given identifier.
ACG::SceneGraph::BaseNode * getRootNode()
Get the root node for data objects.
QPoint mapToGlobal(const QPoint _point)
Map coordinates of GL Widget to global coordinates.
void setDataRoot(BaseObject *_root)
glViewer * viewer(int _viewerId)
Get a Viewer.
ObjectReferenceRange objectReferences(IteratorRestriction _restriction, DataType _dataType)
Iterable object range.
int objectCount()
Get the number of available objects.
void orthographicProjection(int _viewer)
Switch to orthographic Projection.
void setDataSeparatorNodes(SeparatorNode *_dataSeparatorNode)
Set the internal data root node pointers ( DO NOT USE!! )
void setScenePos(const ACG::Vec3d &_center, const double _radius, int _viewer)
Set the Scene position.
QString getOpenFileName(const QString &configProperty, QWidget *parent, const QString &caption, const QString &defaultDir, const QString &filter, QString *selectedFilter, QFileDialog::Options options)
const std::string pickMode()
Get the current Picking mode.
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 increaseObjectCount()
Decrease the number of current Object.
void setPluginCommandLineOptions(const QVector< QPair< QString, QString > > &_pluginCommandLineOptions)
void addObjectToMap(int _objectId, BaseObject *_object)
Add object to internal object map.
QStringList collectObjectComments(bool visibleOnly, bool targetedOnly)
QMap< std::string,ACG::QtWidgets::SceneGraphWidgetGenerator * > sceneGraphGenerators_
Map of scenegraph widget generators.
QPoint mapToLocal(const QPoint _point)
Map global coordinates to GL Widget local coordinates.
QString getEncodedExaminerView()
Get the encoded view for the active examiner.
void setSceneCenter(const ACG::Vec3d &_center, int _viewer)
ACG::Vec3d upVector(int _viewer)
Get the current up vector.
void rotate(const ACG::Vec3d &_axis, const double _angle, const ACG::Vec3d &_center, int _viewer)
Rotate Scene around axis.
int viewers()
Get the number of viewers.
bool getAllObjectIdentifiers(std::vector< int > &_identifiers)
Get identifiers of all objects.
bool getPickedObject(const size_t _node_idx, BaseObjectData *&_object)
Get the picked mesh.
BaseObject *& objectRoot()
Get the root of the object structure.
ViewObjectMarker * defaultViewObjectMarker()
Get the default ViewObjectMarker.
void setSceneGraphRootNodeGlobal(SeparatorNode *_root_node)
void setFixedView(int _mode, int _viewer)
Set a fixed View for a viewer.
bool objectExists(const int _identifier)
Check if an object with this identifier exists.
ACG::SceneGraph::DrawModes::DrawMode drawMode(int _viewer)
Get the current draw Mode of a Viewer.
bool examinerLightHandling()
returns if internal light handling is active.
void decreaseTargetCount()
Increase the number of current Object.
void get_all_objects(std::vector< BaseObjectData * > &_objects)
void setFOVY(double _fovy)
Set field of view angle.
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 getSourceIdentifiers(std::vector< int > &_identifiers)
Get the identifiers of all objects marked as a source object.
void traverse(ACG::SceneGraph::MouseEventAction &_action)
const QStringList SOURCE_OBJECTS("source")
Iterable object range.
void removeObjectFromMap(int _objectId)
Remove object from internal object map.
bool isProjectionOrthographic(int _viewer)
Check if the projection is orthographic.
QStringList IteratorRestriction
Iterable object range.
int visibleCount()
Get the number of visible objects.
bool scenegraphPick(ACG::SceneGraph::PickTarget _pickTarget, const QPoint &_mousePos, size_t &_nodeIdx, size_t &_targetIdx, ACG::Vec3d *_hitPointPtr=0)
Execute picking operation on scenegraph.
Viewer::ActionMode actionMode()
Get the current Action mode.
void setDrawMode(const ACG::SceneGraph::DrawModes::DrawMode &_mode, int _viewer)
Set the draw Mode of a Viewer. .
void setViewerProperties(const std::vector< Viewer::ViewerProperties * > &_viewerProperties)
Set the internal viewerProperties pointer ( DO NOT USE!! )
void flyTo(const ACG::Vec3d &_position, const ACG::Vec3d &_center, double _time)
Fly to point and viewing direction (animated).
void setEncodedExaminerView(const QString &_view)
Set the encoded view for the active examiner.
void increaseTargetCount()
Decrease the number of current Object.
void allowRotation(bool _mode, int _viewer)
void setActiveExaminer(const unsigned int _id)
Set the active id of the examiner which got the last mouse events.
bool getTargetIdentifiers(std::vector< int > &_identifiers)
Get the identifiers of all objects marked as a target object.
void disableExaminerLightHandling()
Disable the core light handling.
bool getAllMeshes(std::vector< int > &_identifiers)
Get identifiers of all meshes.
void setMainGLContext()
Set current GL Context to main context.
unsigned int activeExaminer()
Get the id of the examiner which got the last mouse events.
void addGlobalStatusNode(ACG::SceneGraph::BaseNode *_node)
Adds a global status node.
const ACG::Vec3d trackBallCenter(int _viewer)
Get the trackball Center.
void lookAt(const ACG::Vec3d &_eye, const ACG::Vec3d &_center, const ACG::Vec3d &_up, int _viewer)
Set the look at transformation directly.
ACG::SceneGraph::BaseNode * getSceneGraphRootNode()
get scenegraph root node
const QStringList TARGET_OBJECTS("target")
Iterable object range.
void decreaseObjectCount()
Increase the number of current Object.
void setDefaultViewObjectMarker(ViewObjectMarker *_marker)
const ACG::Vec3d sceneCenter(int _viewer)
Get the current scene center.
ObjectRange objects(IteratorRestriction _restriction, DataType _dataType)
Iterable object range.
void viewAll(int _viewer)
View the whole scene.
void setViewObjectMarker(ViewObjectMarker *_marker)
void setViewers(const std::vector< glViewer * > &_viewerWidgets)
Set the internal Viewer pointer ( DO NOT USE!! )
const QStringList ALL_OBJECTS
Iterable object range.
BaseObjectData * baseObjectData(BaseObject *_object)
Cast an BaseObject to a BaseObjectData if possible.