52 #include "PluginFunctionsCore.hh" 54 #include <ACG/Scenegraph/SeparatorNode.hh> 55 #include <ACG/Scenegraph/MaterialNode.hh> 57 #include <QRandomGenerator> 71 static std::vector< glViewer* > examiner_widgets_;
77 static std::vector< Viewer::ViewerProperties* > viewerProperties_;
83 static unsigned int activeExaminer_ = 0;
85 static bool internalLightHandling_ =
true;
124 static OFGLWidget* shareGLWidget_ = 0;
128 static int viewerId_ = 0;
131 static int objectCounter_ = 0;
134 static int targetCounter_ = 0;
137 static std::map<int, BaseObject*> objectMap_;
147 return examiner_widgets_.size();
151 internalLightHandling_ =
false;
155 return internalLightHandling_;
163 static QVector<QPair<QString, QString>> pluginCommandLineOptions_;
169 void setViewers(
const std::vector< glViewer* >& _viewerWidgets ) {
170 PluginFunctions::examiner_widgets_ = _viewerWidgets;
171 PluginFunctions::examiner_widget_ = examiner_widgets_[0];
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());
180 PluginFunctions::viewerProperties_ = _viewerProperties;
184 activeExaminer_ = _id;
188 if ( _viewerId < 0 || _viewerId >= (
int)examiner_widgets_.size() ) {
189 std::cerr <<
"Requested unknown viewer with id : " << _viewerId << std::endl;
193 return( examiner_widgets_[_viewerId] );
197 return activeExaminer_;
209 if ( _viewerId < 0 || _viewerId >= (
int)examiner_widgets_.size() ) {
210 std::cerr <<
"Requested unknown viewer with id : " << _viewerId << std::endl;
215 examiner_widgets_[_viewerId]->encodeView ( view );
227 if ( _viewerId < 0 || _viewerId >= (
int)examiner_widgets_.size() ) {
228 std::cerr <<
"Requested unknown viewer with id : " << _viewerId << std::endl;
233 examiner_widgets_[_viewerId]->decodeView ( _view );
241 PluginFunctions::dataSeparatorNode_ = _dataSeparatorNode;
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;
256 PluginFunctions::sceneGraphRootNode_ = _root_node;
260 PluginFunctions::sceneGraphRootNodeGlobal_ = _root_node;
265 if ( o_it->picked( _node_idx ) ) {
275 _identifiers.clear();
278 if ( o_it->source() )
279 _identifiers.push_back ( o_it->id() );
281 return ( ! _identifiers.empty() );
285 _identifiers.clear();
288 if ( o_it->target() )
289 _identifiers.push_back ( o_it->id() );
291 return ( !_identifiers.empty() );
300 if ( _identifier == -1 )
307 std::map<int, BaseObject*>::iterator it;
308 it = objectMap_.find(_identifier);
310 _object = (it != objectMap_.end() ? it->second : 0);
312 return ( _object != 0 );
317 if ( _identifier == -1 )
323 std::map<int, BaseObject*>::iterator it;
324 it = objectMap_.find(_identifier);
326 BaseObject*
object = (it != objectMap_.end() ? it->second : 0);
329 return ( _object != 0 );
333 if(_name.isEmpty())
return -1;
336 return object ?
object->
id() : -1;
344 if ( _identifier == -1 )
348 return (
object != 0 );
355 _identifiers.clear();
359 _identifiers.push_back( o_it->id() );
362 return (!_identifiers.empty());
367 _identifiers.clear();
371 _identifiers.push_back( o_it->id() );
374 return ( !_identifiers.empty() );
378 for ( uint i = 0 ; i < examiner_widgets_.size(); ++i )
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;
419 if ( _viewer == ACTIVE_VIEWER )
426 return examiner_widgets_[activeExaminer_]->glMapToGlobal(_point);
430 return examiner_widgets_[activeExaminer_]->glMapFromGlobal(_point);
435 if ( _viewer == ACTIVE_VIEWER )
437 else if ( _viewer == ALL_VIEWERS )
438 for ( uint i = 0 ; i < examiner_widgets_.size(); ++i )
440 else if ( ( _viewer >= 0 ) && _viewer < (
int)examiner_widgets_.size() )
443 std::cerr <<
"Requested illegal viewer for setting DrawMode!!" << std::endl;
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() )
460 std::cerr <<
"Requested illegal viewer for viewingDirection!!" << std::endl;
469 viewingRay(_x,_y,_outOrigin,_outDirection,activeExaminer_);
482 return examiner_widgets_[activeExaminer_]->pick( _pickTarget,_mousePos,_nodeIdx,_targetIdx,_hitPointPtr );
488 if ( _examiner >= examiner_widgets_.size() ) {
489 std::cerr <<
"Wrong examiner id" << std::endl;
492 return examiner_widgets_[_examiner]->pick( _pickTarget,_mousePos,_nodeIdx,_targetIdx,_hitPointPtr );
499 const QPoint & _mousePos,
507 bool ok =
scenegraphPick(_examiner,_pickTarget,_mousePos, nodeIdx,_targetIdx,_hitPointPtr);
512 if ( _refine && (_hitPointPtr != 0) ) {
515 double x = _mousePos.x();
516 double y = examiner_widget_->
glHeight() - _mousePos.y();
523 *_hitPointPtr = _object->
refinePick(_pickTarget,*_hitPointPtr, mousePoint3d , direction , _targetIdx );
534 const QPoint & _mousePos,
540 return scenegraphPick(activeExaminer_,_pickTarget,_mousePos, _object,_targetIdx,_refine,_hitPointPtr );
548 const QRegion& _region,
549 QList<QPair<size_t, size_t> >& _list,
550 QVector<float>* _depths,
551 QVector<ACG::Vec3d>* _points)
553 return examiner_widgets_[activeExaminer_]->pick_region( _pickTarget, _region, _list, _depths, _points);
558 const QRegion& _region,
559 QList<QPair<size_t, size_t> >& _list,
560 QVector<float>* _depths,
561 QVector<ACG::Vec3d>* _points)
563 if ( _examiner >= examiner_widgets_.size() ) {
564 std::cerr <<
"Wrong examiner id" << std::endl;
567 return examiner_widgets_[_examiner]->pick_region( _pickTarget, _region, _list, _depths, _points);
599 shareGLWidget_ = _widget;
604 return shareGLWidget_;
612 if ( _id >= (
int)viewerProperties_.size() ) {
613 std::cerr <<
" Error, requested properties for non-existing Viewer!" << std::endl;
614 return dummyProperties;
618 _id = activeExaminer_;
620 return ( *viewerProperties_[_id] );
625 if ( _viewer == ACTIVE_VIEWER ) {
626 examiner_widgets_[activeExaminer_]->perspectiveProjection();
627 }
else if ( _viewer == ALL_VIEWERS )
628 for ( uint i = 0 ; i < examiner_widgets_.size(); ++i )
630 else if ( ( _viewer >= 0 ) && _viewer < (int)examiner_widgets_.size() )
633 std::cerr <<
"Requested illegal viewer for perspectiveProjection()!!" << std::endl;
637 if ( _viewer == ACTIVE_VIEWER ) {
638 examiner_widgets_[activeExaminer_]->orthographicProjection();
639 }
else if ( _viewer == ALL_VIEWERS )
640 for ( uint i = 0 ; i < examiner_widgets_.size(); ++i )
642 else if ( ( _viewer >= 0 ) && _viewer < (int)examiner_widgets_.size() )
645 std::cerr <<
"Requested illegal viewer for orthographicProjection()!!" << std::endl;
651 for ( uint i = 0 ; i < examiner_widgets_.size(); ++i )
652 examiner_widgets_[i]->
setFOVY(_fovy);
656 if ( _viewer == ACTIVE_VIEWER ) {
657 examiner_widgets_[activeExaminer_]->allowRotation(_mode);
658 }
else if ( _viewer == ALL_VIEWERS )
659 for ( uint i = 0 ; i < examiner_widgets_.size(); ++i )
661 else if ( ( _viewer >= 0 ) && _viewer < (int)examiner_widgets_.size() )
664 std::cerr <<
"Requested illegal viewer for allowRotation!!" << std::endl;
668 if ( _viewer == ACTIVE_VIEWER )
676 if ( ( _viewer >= 0 ) && _viewer < (
int)examiner_widgets_.size() )
680 std::cerr <<
"Requested illegal viewer for isRotationAllowed!!" << std::endl;
690 if ( _viewer == ACTIVE_VIEWER ) {
691 examiner_widgets_[activeExaminer_]->viewingDirection(_dir,_up);
692 }
else if ( _viewer == ALL_VIEWERS )
693 for ( uint i = 0 ; i < examiner_widgets_.size(); ++i )
695 else if ( ( _viewer >= 0 ) && _viewer < (int)examiner_widgets_.size() )
698 std::cerr <<
"Requested illegal viewer for viewingDirection!!" << std::endl;
703 if ( _viewer == ACTIVE_VIEWER ) {
704 examiner_widgets_[activeExaminer_]->lookAt(_eye,_center, _up);
705 }
else if ( _viewer == ALL_VIEWERS )
706 for ( uint i = 0 ; i < examiner_widgets_.size(); ++i )
707 examiner_widgets_[i]->
lookAt(_eye,_center, _up);
708 else if ( ( _viewer >= 0 ) && _viewer < (int)examiner_widgets_.size() )
709 examiner_widgets_[_viewer]->
lookAt(_eye,_center, _up);
711 std::cerr <<
"Requested illegal viewer for viewingDirection!!" << std::endl;
715 if ( _viewer == ACTIVE_VIEWER ) {
716 return examiner_widgets_[activeExaminer_]->trackBallCenter();
717 }
else if ( _viewer == ALL_VIEWERS )
718 for ( uint i = 0 ; i < examiner_widgets_.size(); ++i )
720 else if ( ( _viewer >= 0 ) && _viewer < (int)examiner_widgets_.size() )
723 std::cerr <<
"Requested illegal viewer for setTrackBallCenter!!" << std::endl;
725 return examiner_widgets_[activeExaminer_]->trackBallCenter();
729 if ( _viewer == ACTIVE_VIEWER ) {
730 examiner_widgets_[activeExaminer_]->setTrackBallCenter( _center );
731 }
else if ( _viewer == ALL_VIEWERS )
732 for ( uint i = 0 ; i < examiner_widgets_.size(); ++i )
734 else if ( ( _viewer >= 0 ) && _viewer < (int)examiner_widgets_.size() )
737 std::cerr <<
"Requested illegal viewer for setTrackBallCenter!!" << std::endl;
741 if ( _viewer == ACTIVE_VIEWER ) {
742 examiner_widgets_[activeExaminer_]->setScenePos( _center, _radius );
743 }
else if ( _viewer == ALL_VIEWERS )
744 for ( uint i = 0 ; i < examiner_widgets_.size(); ++i )
745 examiner_widgets_[i]->
setScenePos( _center, _radius );
746 else if ( ( _viewer >= 0 ) && _viewer < (int)examiner_widgets_.size() )
747 examiner_widgets_[_viewer]->
setScenePos( _center, _radius );
749 std::cerr <<
"Requested illegal viewer for setScenePos!!" << std::endl;
753 if ( _viewer == ACTIVE_VIEWER ) {
754 examiner_widgets_[activeExaminer_]->setScenePos( _center, examiner_widgets_[activeExaminer_]->scene_radius() );
755 }
else if ( _viewer == ALL_VIEWERS )
756 for ( uint i = 0 ; i < examiner_widgets_.size(); ++i )
757 examiner_widgets_[i]->
setScenePos( _center, examiner_widgets_[i]->scene_radius() );
758 else if ( ( _viewer >= 0 ) && _viewer < (int)examiner_widgets_.size() )
759 examiner_widgets_[_viewer]->
setScenePos( _center, examiner_widgets_[_viewer]->scene_radius() );
761 std::cerr <<
"Requested illegal viewer for setScenePos!!" << std::endl;
766 if (_viewer == ACTIVE_VIEWER) {
767 examiner_widgets_[activeExaminer_]->setSceneCenter(_center);
768 }
else if (_viewer == ALL_VIEWERS) {
770 for (uint i = 0; i < examiner_widgets_.size(); ++i) {
771 examiner_widgets_[i]->setSceneCenter(_center);
773 }
else if ((_viewer >= 0) && _viewer < (
int) examiner_widgets_.size()) {
774 examiner_widgets_[_viewer]->setSceneCenter(_center);
776 std::cerr <<
"Requested illegal viewer for setSceneCenter!!" << std::endl;
782 if (_viewer == ACTIVE_VIEWER) {
783 return examiner_widgets_[activeExaminer_]->scene_center();
784 }
else if (_viewer == ALL_VIEWERS)
785 std::cerr <<
"Please select viewer to get sceneCenter!" << std::endl;
786 else if ((_viewer >= 0) && _viewer < (
int) examiner_widgets_.size())
787 return examiner_widgets_[_viewer]->scene_center();
789 std::cerr <<
"Requested illegal viewer for sceneCenter!!" << std::endl;
791 return examiner_widgets_[activeExaminer_]->scene_center();
795 return examiner_widgets_[activeExaminer_]->scene_radius();
799 if ( _viewer == ACTIVE_VIEWER ) {
800 return examiner_widgets_[activeExaminer_]->scene_radius();
801 }
else if ( _viewer == ALL_VIEWERS )
802 std::cerr <<
"Illegal request for scene radius. Please select one viewer!" << std::endl;
803 else if ( ( _viewer >= 0 ) && _viewer < (
int)examiner_widgets_.size() )
804 return examiner_widgets_[_viewer]->scene_radius();
806 std::cerr <<
"Requested illegal viewer for translate!!" << std::endl;
812 if ( _viewer == ACTIVE_VIEWER ) {
813 examiner_widgets_[activeExaminer_]->setSceneRadius(_radius);
814 }
else if ( _viewer == ALL_VIEWERS )
815 for ( uint i = 0 ; i < examiner_widgets_.size(); ++i )
817 else if ( ( _viewer >= 0 ) && _viewer < (int)examiner_widgets_.size() )
820 std::cerr <<
"Requested illegal viewer for translate!!" << std::endl;
824 if ( _viewer == ACTIVE_VIEWER ) {
825 examiner_widgets_[activeExaminer_]->translate(_vector);
826 }
else if ( _viewer == ALL_VIEWERS )
827 for ( uint i = 0 ; i < examiner_widgets_.size(); ++i )
828 examiner_widgets_[i]->
translate(_vector);
829 else if ( ( _viewer >= 0 ) && _viewer < (int)examiner_widgets_.size() )
830 examiner_widgets_[_viewer]->
translate(_vector);
832 std::cerr <<
"Requested illegal viewer for translate!!" << std::endl;
840 if ( _viewer == ACTIVE_VIEWER ) {
841 examiner_widgets_[activeExaminer_]->rotate(_axis,_angle,_center);
842 }
else if ( _viewer == ALL_VIEWERS )
843 for ( uint i = 0 ; i < examiner_widgets_.size(); ++i )
844 examiner_widgets_[i]->
rotate(_axis,_angle,_center);
845 else if ( ( _viewer >= 0 ) && _viewer < (int)examiner_widgets_.size() )
846 examiner_widgets_[_viewer]->
rotate(_axis,_angle,_center);
848 std::cerr <<
"Requested illegal viewer for rotate!!" << std::endl;
852 if ( _viewer == ACTIVE_VIEWER ) {
853 examiner_widgets_[activeExaminer_]->home();
854 }
else if ( _viewer == ALL_VIEWERS )
855 for ( uint i = 0 ; i < examiner_widgets_.size(); ++i )
856 examiner_widgets_[i]->home();
857 else if ( ( _viewer >= 0 ) && _viewer < (int)examiner_widgets_.size() )
858 examiner_widgets_[_viewer]->home();
860 std::cerr <<
"Requested illegal viewer for viewHome!!" << std::endl;
864 if ( _viewer == ACTIVE_VIEWER ) {
865 examiner_widgets_[activeExaminer_]->viewAll();
866 }
else if ( _viewer == ALL_VIEWERS )
867 for ( uint i = 0 ; i < examiner_widgets_.size(); ++i )
868 examiner_widgets_[i]->
viewAll();
869 else if ( ( _viewer >= 0 ) && _viewer < (int)examiner_widgets_.size() )
870 examiner_widgets_[_viewer]->
viewAll();
872 std::cerr <<
"Requested illegal viewer for viewAll!!" << std::endl;
876 if ( _viewer == ACTIVE_VIEWER ) {
878 }
else if ( _viewer == ALL_VIEWERS )
879 std::cerr <<
"Please select viewer to get viewing direction!" << std::endl;
880 else if ( ( _viewer >= 0 ) && _viewer < (
int)examiner_widgets_.size() )
883 std::cerr <<
"Requested illegal viewer for viewingDirection!!" << std::endl;
890 if ( _viewer == ACTIVE_VIEWER) {
891 return (examiner_widgets_[activeExaminer_]->projectionMode() == 0);
892 }
else if ( ( _viewer >= 0 ) && _viewer < (
int)examiner_widgets_.size() ){
893 return ( examiner_widgets_[_viewer]->projectionMode() == 0);
895 std::cerr <<
"Requested illegal viewer for isProjectionOrthographic!!" << std::endl;
901 if ( _viewer == ACTIVE_VIEWER ) {
903 }
else if ( _viewer == ALL_VIEWERS )
904 std::cerr <<
"Please select viewer to get eyePos!" << std::endl;
905 else if ( ( _viewer >= 0 ) && _viewer < (
int)examiner_widgets_.size() )
908 std::cerr <<
"Requested illegal viewer for eyePos!!" << std::endl;
914 if ( _viewer == ACTIVE_VIEWER ) {
916 }
else if ( _viewer == ALL_VIEWERS )
917 std::cerr <<
"Please select viewer to get up vector!" << std::endl;
918 else if ( ( _viewer >= 0 ) && _viewer < (
int)examiner_widgets_.size() )
921 std::cerr <<
"Requested illegal viewer for up vector!!" << std::endl;
930 if ( _viewer == ACTIVE_VIEWER ) {
932 }
else if ( _viewer == ALL_VIEWERS )
933 std::cerr <<
"Please select viewer to get fovy!" << std::endl;
934 else if ( ( _viewer >= 0 ) && _viewer < (
int)examiner_widgets_.size() )
937 std::cerr <<
"Requested illegal viewer for fovy!!" << std::endl;
944 for ( uint i = 0 ; i < examiner_widgets_.size(); ++i )
950 defaultMarker_ = _marker;
955 return defaultMarker_;
960 return PluginFunctions::sceneGraphRootNode_;
964 return PluginFunctions::dataRootNode_;
968 if (PluginFunctions::sceneGraphRootNode_){
982 if (PluginFunctions::sceneGraphRootNode_)
983 _node->
set_parent( PluginFunctions::sceneGraphRootNodeGlobal_ );
988 if (PluginFunctions::sceneGraphRootNode_){
1003 return(objectCounter_);
1009 return ( targetCounter_ );
1028 if ( o_it->visible() )
1047 _objects.push_back( o_it );
1055 examiner_widgets_[activeExaminer_]->flyTo(_position,_center,_time);
1063 ACG::Vec3d e = eye + t * (_move_back ? -0.5f : 0.5f);
1064 examiner_widgets_[activeExaminer_]->flyTo(e, _center, _time);
1069 void viewerSnapshot(
int _viewer, QImage& _image,
int _width,
int _height,
bool _alpha,
1070 bool _hideCoordsys,
int _samples) {
1072 if ( _viewer == ACTIVE_VIEWER ) {
1073 examiner_widgets_[activeExaminer_]->snapshot(_image, _width, _height, _alpha, _hideCoordsys, _samples);
1074 }
else if ( _viewer == ALL_VIEWERS )
1075 std::cerr <<
"Please select viewer to get snapshot!" << std::endl;
1076 else if ( ( _viewer >= 0 ) && _viewer < (
int)examiner_widgets_.size() )
1077 examiner_widgets_[_viewer]->snapshot(_image, _width, _height, _alpha, _hideCoordsys, _samples);
1079 std::cerr <<
"Requested illegal viewer for snapshot!!" << std::endl;
1099 return (objectRoot_);
1110 if ( objectCounter_ < 0 )
1111 std::cerr <<
"Deleted more objects than created!!!" << std::endl;
1122 if ( targetCounter_ < 0 )
1123 std::cerr <<
"target object counter underflow!!!" << std::endl;
1132 std::map<int, BaseObject*>::iterator it;
1133 it = objectMap_.find(_objectId);
1135 if(it != objectMap_.end())
return;
1138 objectMap_.insert(std::pair<int, BaseObject*>(_objectId, _object));
1147 std::map<int, BaseObject*>::iterator it;
1148 it = objectMap_.find(_objectId);
1151 if(it != objectMap_.end()) objectMap_.erase(it);
1158 if ( sceneGraphGenerators_.contains( _generator->
handles() ) )
1162 sceneGraphGenerators_[_generator->
handles() ] = _generator;
1166 QMap< std::string ,ACG::QtWidgets::SceneGraphWidgetGenerator* > getSceneGraphGeneratorList(){
1171 QWidget * parent,
const QString & caption,
1172 const QString & defaultDir,
const QString & filter,
1173 QString * selectedFilter, QFileDialog::Options options) {
1176 const QString result = QFileDialog::getOpenFileName(parent, caption, dir,
1177 filter, selectedFilter, options);
1178 if (result.length())
1184 QWidget * parent,
const QString & caption,
1185 const QString & defaultDir,
const QString & filter,
1186 QString * selectedFilter, QFileDialog::Options options,
1187 const QString & defaultSuffix) {
1199 QFileDialog dialog(parent, caption, dir, filter);
1200 dialog.setOptions(options);
1201 dialog.setAcceptMode(QFileDialog::AcceptSave);
1202 if (selectedFilter && !selectedFilter->isEmpty())
1203 dialog.selectNameFilter(*selectedFilter);
1204 dialog.setDefaultSuffix(defaultSuffix);
1205 if (dialog.exec() == QDialog::Accepted) {
1207 *selectedFilter = dialog.selectedNameFilter();
1208 QString result = dialog.selectedFiles().value(0);
1218 if (visibleOnly && !o_it->visible())
continue;
1219 result.append(o_it->getAllCommentsFlat());
1225 if (!ACG::SceneGraph::Material::support_json_serialization())
1226 return QStringList();
1231 if (visibleOnly && !o_it->visible())
continue;
1233 QString materialStr(QObject::tr(
"<not available>"));
1234 if (!o_it->materialNode())
1235 materialStr = QObject::tr(
"<not available: materialNode == null>");
1237 materialStr = o_it->materialNode()->material().serializeToJson();
1239 if (!result.empty())
1240 result.last().append(QString::fromUtf8(
","));
1241 result.append(QString::fromUtf8(
"\"%1\": %2").arg(o_it->name()).arg(materialStr));
1246 void invalidatePickCaches() {
1247 for(
size_t i = 0; i < examiner_widgets_.size(); ++i) {
1248 examiner_widgets_[i]->invalidatePickCache();
1262 return pluginCommandLineOptions_;
1265 void setPluginCommandLineOptions(
const QVector<QPair<QString, QString> > &_pluginCommandLineOptions)
1267 pluginCommandLineOptions_ = _pluginCommandLineOptions;
const QVector< QPair< QString, QString > > & pluginCommandLineOptions()
Get command line plugin settings as key-value pairs.
bool scenegraphPick(ACG::SceneGraph::PickTarget _pickTarget, const QPoint &_mousePos, size_t &_nodeIdx, size_t &_targetIdx, ACG::Vec3d *_hitPointPtr=0)
Execute picking operation on scenegraph.
double fovy() const
get field of view in y direction
void viewHome(int _viewer)
Go to home position.
void shareGLWidget(OFGLWidget *_widget)
Sets the main QGLWidget for gl data sharing.
DLLEXPORT double fovy(int _viewer)
Get field of view angle.
void decreaseObjectCount()
Increase the number of current Object.
void setScenePos(const ACG::Vec3d &_center, const double _radius, int _viewer)
Set the Scene position.
void removeObjectFromMap(int _objectId)
Remove object from internal object map.
void setDataRoot(BaseObject *_root)
Vec3d viewing_direction() const
get viewing ray
void set_parent(BaseNode *_parent)
Set the parent of this node.
int visibleCount()
Get the number of visible objects.
void viewingDirection(const ACG::Vec3d &_dir, const ACG::Vec3d &_up, int _viewer)
Set the viewing direction.
void decreaseTargetCount()
Increase the number of current Object.
Vec3d up() const
get up-vector w.r.t. camera coordinates
const ACG::Vec3d trackBallCenter(int _viewer)
Get the trackball Center.
virtual void makeCurrent()
Makes this widget the current widget for OpenGL operations.
ACG::SceneGraph::BaseNode * getRootNode()
Get the root node for data objects.
ActionMode
Enum listing action modes of the viewers.
void getCurrentViewImage(QImage &_image)
Returns a QImage of the current View.
Range adapter for ObjectIterator.
int objectCount()
Get the number of available objects.
ACG::Vec3d upVector(int _viewer)
Get the current up vector.
unsigned int glHeight() const
get height of QGLWidget
bool getObject(const int _identifier, BaseObject *&_object)
Get the object which has the given identifier.
BaseObject *& objectRoot()
Get the root of the object structure.
const ACG::Vec3d sceneCenter(int _viewer)
Get the current scene center.
int getObjectId(const QString &_name)
ACG::SceneGraph::BaseNode * getSceneGraphRootNode()
get scenegraph root node
bool scenegraphRegionPick(ACG::SceneGraph::PickTarget _pickTarget, const QRegion &_region, QList< QPair< size_t, size_t > > &_list, QVector< float > *_depths, QVector< ACG::Vec3d > *_points)
void drawMode(ACG::SceneGraph::DrawModes::DrawMode _mode)
set draw mode (No test if this mode is available!)
Viewer::ActionMode actionMode()
get the action mode
ACG::SceneGraph::DrawModes::DrawMode drawMode(int _viewer)
Get the current draw Mode of a Viewer.
QStringList collectObjectComments(bool visibleOnly, bool targetedOnly)
const QStringList SOURCE_OBJECTS("source")
Iterable object range.
void setEncodedExaminerView(QString _view)
Set the encoded view for the active examiner.
QMap< std::string,ACG::QtWidgets::SceneGraphWidgetGenerator *> sceneGraphGenerators_
Map of scenegraph widget generators.
const QStringList ALL_OBJECTS
Iterable object range.
QStringList collectObjectMaterials(bool visibleOnly, bool targetedOnly)
unsigned int activeExaminer()
Get the id of the examiner which got the last mouse events.
void setFixedView(int _mode, int _viewer)
Set a fixed View for a viewer.
virtual ACG::Vec3d refinePick(ACG::SceneGraph::PickTarget _pickTarget, const ACG::Vec3d _hitPoint, const ACG::Vec3d _start, const ACG::Vec3d _dir, const unsigned int _targetIdx)
Refine picking.
BaseObjectData * baseObjectData(BaseObject *_object)
Cast an BaseObject to a BaseObjectData if possible.
bool getAllMeshes(std::vector< int > &_identifiers)
Get identifiers of all meshes.
BaseObject * childExists(int _objectId)
Check if the element exists in the subtree of this element.
void setDataSeparatorNodes(SeparatorNode *_dataSeparatorNode)
Set the internal data root node pointers ( DO NOT USE!! )
void objectMarker(ViewObjectMarker *_marker)
set object marker for viewer
void setDefaultViewObjectMarker(ViewObjectMarker *_marker)
PickTarget
What target to use for picking.
ChildIter childrenBegin()
Returns: begin-iterator of children.
QString getOpenFileName(const QString &configProperty, QWidget *parent, const QString &caption, const QString &defaultDir, const QString &filter, QString *selectedFilter, QFileDialog::Options options)
bool rotationLocked()
Pointer to the glState of the Viewer.
void rotate(const ACG::Vec3d &_axis, const double _angle, const ACG::Vec3d &_center, int _viewer)
Rotate Scene around axis.
void setSceneGraphRootNode(SeparatorNode *_root_node)
int viewers()
Get the number of viewers.
void perspectiveProjection(int _viewer)
Switch to perspective Projection.
Viewer::ActionMode actionMode()
Get the current Action mode.
void setViewObjectMarker(ViewObjectMarker *_marker)
QVariant value(const QString &key, const QVariant &defaultValue=QVariant()) const
void viewerSnapshot(int _viewer, QImage &_image, int _width, int _height, bool _alpha, bool _hideCoordsys, int _samples)
Take a snapshot of a viewer.
double sceneRadius()
Returns the current scene radius from the active examiner widget.
bool objectExists(const int _identifier)
Check if an object with this identifier exists.
int viewerId()
Return unique viewer id.
QPoint mapToLocal(const QPoint _point)
Map global coordinates to GL Widget local coordinates.
BaseNode * parent()
Get the nodes parent node.
ACG::Vec3d eyePos(int _viewer)
Get the current viewer position.
int targetCount()
Get the number of target objects.
ACG::Vec4f backgroundColor()
Get current background color.
void get_all_objects(std::vector< BaseObjectData *> &_objects)
QStringList IteratorRestriction
Iterable object range.
void traverse(ACG::SceneGraph::MouseEventAction &_action)
const std::string pickMode()
Get the current Picking mode.
void setViewers(const std::vector< glViewer * > &_viewerWidgets)
Set the internal Viewer pointer ( DO NOT USE!! )
void increaseTargetCount()
Decrease the number of current Object.
const QStringList TARGET_OBJECTS("target")
Iterable object range.
void disableExaminerLightHandling()
Disable the core light handling.
void setTrackBallCenter(const ACG::Vec3d &_center, int _viewer)
Set the trackball Center.
ObjectRange objects(IteratorRestriction _restriction, DataType _dataType)
Iterable object range.
void setActiveExaminer(const unsigned int _id)
Set the active id of the examiner which got the last mouse events.
bool getSourceIdentifiers(std::vector< int > &_identifiers)
Get the identifiers of all objects marked as a source object.
void addObjectRenderingNode(ACG::SceneGraph::BaseNode *_node)
Add scenegraph node modifing object rendering.
void lookAt(const ACG::Vec3d &_eye, const ACG::Vec3d &_center, const ACG::Vec3d &_up, int _viewer)
Set the look at transformation directly.
virtual void snapshot(int _width=0, int _height=0, bool _alpha=false, bool _hideCoordsys=false, int samples=1)
ObjectReferenceRange objectReferences(IteratorRestriction _restriction, DataType _dataType)
Iterable object range.
QPoint mapToGlobal(const QPoint _point)
Map coordinates of GL Widget to global coordinates.
void setDrawMode(const ACG::SceneGraph::DrawModes::DrawMode &_mode, int _viewer)
Set the draw Mode of a Viewer. .
void viewing_ray(int _x, int _y, Vec3d &_origin, Vec3d &_direction) const
void setBackColor(OpenMesh::Vec4f _color)
Set the background color of the examiner widget.
void setSceneRadius(double _radius, int _viewer)
Set the background color of the examiner widget.
void addGlobalNode(ACG::SceneGraph::BaseNode *_node)
Add a global node.
ViewObjectMarker * defaultViewObjectMarker()
Get the default ViewObjectMarker.
void addSceneGraphGenerator(ACG::QtWidgets::SceneGraphWidgetGenerator *_generator)
Add a scenegraph generator ( the handled type will be extracted from the generator) ...
int currentViewingDirection()
Pointer to the glState of the Viewer.
std::string pickMode()
get active pick mode
Viewer::ViewerProperties & viewerProperties(int _id)
Get the viewer properties Use this functions to get basic viewer properties such as backgroundcolor o...
void setFOVY(double _fovy)
Set field of view angle.
void allowRotation(bool _mode, int _viewer)
QString getSaveFileName(const QString &configProperty, QWidget *parent, const QString &caption, const QString &defaultDir, const QString &filter, QString *selectedFilter, QFileDialog::Options options, const QString &defaultSuffix)
bool examinerLightHandling()
returns if internal light handling is active.
void translate(const ACG::Vec3d &_vector, int _viewer)
Translate viewer pos by given vector.
void setValue(const QString &key, const QVariant &value)
Wrapper function which makes it possible to enable Debugging output with -DOPENFLIPPER_SETTINGS_DEBUG...
void setViewerProperties(const std::vector< Viewer::ViewerProperties * > &_viewerProperties)
Set the internal viewerProperties pointer ( DO NOT USE!! )
void setMainGLContext()
Set current GL Context to main context.
DLLEXPORT OpenFlipperQSettings & OpenFlipperSettings()
QSettings object containing all program settings of OpenFlipper.
Range adapter for ObjectIterator.
int sourceCount()
Get the number of source objects.
bool getAllObjectIdentifiers(std::vector< int > &_identifiers)
Get identifiers of all objects.
void increaseObjectCount()
Decrease the number of current Object.
QString getEncodedExaminerView()
Get the encoded view for the active examiner.
void orthographicProjection(int _viewer)
Switch to orthographic Projection.
void addObjectToMap(int _objectId, BaseObject *_object)
Add object to internal object map.
bool getPickedObject(const size_t _node_idx, BaseObjectData *&_object)
Get the picked mesh.
glViewer * viewer(int _viewerId)
Get a Viewer.
bool getTargetIdentifiers(std::vector< int > &_identifiers)
Get the identifiers of all objects marked as a target object.
void addGlobalStatusNode(ACG::SceneGraph::BaseNode *_node)
Adds a global status node.
const DataType DATA_ALL(UINT_MAX)
Identifier for all available objects.
bool isProjectionOrthographic(int _viewer)
Check if the projection is orthographic.
Vec3d eye() const
get eye point
void setSceneCenter(const ACG::Vec3d &_center, int _viewer)
void traverse(BaseNode *_node, Action &_action)
DLLEXPORT DataType typeId(QString _name)
Given a dataType Identifier string this function will return the id of the datatype.
ACG::GLState & glState()
Get the glState of the Viewer.
void viewAll(int _viewer)
View the whole scene.
void setSceneGraphRootNodeGlobal(SeparatorNode *_root_node)
void viewingRay(int _x, int _y, ACG::Vec3d &_outOrigin, ACG::Vec3d &_outDirection)
Retrieve a viewing ray from the active examiner that can be used for raycasting.
void flyTo(const ACG::Vec3d &_position, const ACG::Vec3d &_center, double _time)
Fly to point and viewing direction (animated).