From 721603fa2456b8e05f247b42ed419b9d352992ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Thu, 24 Jan 2013 14:35:53 +0000 Subject: [PATCH] Significant speedup for the InfoMeshObject Plugin, which kept an additional list of object targets. refs #1375 git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@16191 383ad7c9-94d9-4d36-a494-682f7c89f535 --- MeshObjectInfoPlugin.cc | 62 ++++++----------------------------------- MeshObjectInfoPlugin.hh | 11 +------- 2 files changed, 10 insertions(+), 63 deletions(-) diff --git a/MeshObjectInfoPlugin.cc b/MeshObjectInfoPlugin.cc index d690d2c..da4ea60 100644 --- a/MeshObjectInfoPlugin.cc +++ b/MeshObjectInfoPlugin.cc @@ -811,38 +811,6 @@ bool InfoMeshObjectPlugin::getEdgeLengths(int _id, double &min, double &max, dou return false; } -////------------------------------------------------------------------------------ - -void InfoMeshObjectPlugin::addedEmptyObject(int _id) { - BaseObject* object; - PluginFunctions::getObject(_id,object); - if( object ) { - if ( (object->dataType() == DATA_TRIANGLE_MESH || object->dataType() == DATA_POLY_MESH) && - object->target() - ) - targetMeshes_.insert(_id); - } else { - std::cerr << "MeshObject Info Plugin: Unable to get Object after adding!" << std::endl; - } -} - -//------------------------------------------------------------------------------ - -void InfoMeshObjectPlugin::objectDeleted(int _id) { - BaseObject* object; - PluginFunctions::getObject(_id,object); - if( object ) { - if ( object->dataType() == DATA_TRIANGLE_MESH || object->dataType() == DATA_POLY_MESH) { - QSet::iterator iter = targetMeshes_.find(_id); - if ( iter != targetMeshes_.end() ) { - targetMeshes_.erase(iter); - } - } - } else { - std::cerr << "MeshObject Info Plugin: Unable to get Object after adding!" << std::endl; - } -} - //------------------------------------------------------------------------------ void InfoMeshObjectPlugin::slotObjectUpdated( int _identifier , const UpdateType& _type){ @@ -851,10 +819,15 @@ void InfoMeshObjectPlugin::slotObjectUpdated( int _identifier , const UpdateType return; } - if ( targetMeshes_.count() == 1) { + // We only show the information in the status bar if one target mesh is selected. + if ( PluginFunctions::targetCount() ==1 ) { + BaseObjectData* object; - PluginFunctions::getObject((*targetMeshes_.begin()),object); - if( object ) { + PluginFunctions::getObject(_identifier,object); + + // We only need to update something, if the updated object is the target object + if (object->target() ) { + if (object->dataType(DATA_TRIANGLE_MESH)){ TriMesh* mesh = PluginFunctions::triMesh(object); @@ -881,6 +854,7 @@ void InfoMeshObjectPlugin::slotObjectUpdated( int _identifier , const UpdateType } } + } else { // Display only count information if ( PluginFunctions::targetCount() > 0 ) { @@ -894,30 +868,12 @@ void InfoMeshObjectPlugin::slotObjectUpdated( int _identifier , const UpdateType //------------------------------------------------------------------------------ void InfoMeshObjectPlugin::slotObjectSelectionChanged( int _identifier ){ - BaseObject* object; - PluginFunctions::getObject(_identifier,object); - if( object ) { - if ( object->dataType() == DATA_TRIANGLE_MESH || object->dataType() == DATA_POLY_MESH) { - if ( ! object->target() ) { - - QSet::iterator iter = targetMeshes_.find(_identifier); - if ( iter != targetMeshes_.end() ) - targetMeshes_.erase(iter); - - } else - targetMeshes_.insert(_identifier); - } - } else { - std::cerr << "MeshObject Info Plugin: Unable to get Object after adding!" << std::endl; - } - slotObjectUpdated( _identifier , UPDATE_ALL ); } //------------------------------------------------------------------------------ void InfoMeshObjectPlugin::slotAllCleared(){ - targetMeshes_.clear(); if ( infoBar_ ) infoBar_->hideCounts(); } diff --git a/MeshObjectInfoPlugin.hh b/MeshObjectInfoPlugin.hh index 2a32574..c3b96c8 100644 --- a/MeshObjectInfoPlugin.hh +++ b/MeshObjectInfoPlugin.hh @@ -59,7 +59,6 @@ #include #include -#include #include #include #include @@ -74,14 +73,13 @@ Plugin to visualize information about objects in the scene */ -class InfoMeshObjectPlugin : public QObject, BaseInterface, InformationInterface, LoggingInterface, StatusbarInterface, LoadSaveInterface +class InfoMeshObjectPlugin : public QObject, BaseInterface, InformationInterface, LoggingInterface, StatusbarInterface { Q_OBJECT Q_INTERFACES(BaseInterface) Q_INTERFACES(InformationInterface) Q_INTERFACES(LoggingInterface) Q_INTERFACES(StatusbarInterface) - Q_INTERFACES(LoadSaveInterface) signals: @@ -105,11 +103,6 @@ class InfoMeshObjectPlugin : public QObject, BaseInterface, InformationInterface void slotObjectSelectionChanged( int _identifier ); void slotAllCleared(); - //LoadSaveInterface - void addedEmptyObject(int _id); - void objectDeleted(int _id); - - void noguiSupported( ) {} ; // InformationInterface @@ -135,8 +128,6 @@ class InfoMeshObjectPlugin : public QObject, BaseInterface, InformationInterface InfoBar* infoBar_; - QSet targetMeshes_; - template< class MeshT > void printMeshInfo( MeshT* _mesh, int _id, unsigned int _face, ACG::Vec3d& _hitPoint ); -- GitLab