Commit 3d11893e authored by Jan Möbius's avatar Jan Möbius
Browse files

Second fix version, now handling deleted objects separatly.

Problem was that the object gets deleted after the function got called.

closes #2443



git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@20608 383ad7c9-94d9-4d36-a494-682f7c89f535
parent e35d88a1
...@@ -823,74 +823,98 @@ bool InfoMeshObjectPlugin::getEdgeLengths(int _id, double &min, double &max, dou ...@@ -823,74 +823,98 @@ bool InfoMeshObjectPlugin::getEdgeLengths(int _id, double &min, double &max, dou
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void InfoMeshObjectPlugin::slotObjectUpdated( int _identifier , const UpdateType& _type){ void InfoMeshObjectPlugin::updateData( int _identifier , const UpdateType& _type, const bool _deleted){
if ( !infoBar_ ) { if ( !infoBar_ ) {
return; return;
} }
// We only show the information in the status bar if one target mesh is selected. BaseObjectData* object;
if ( PluginFunctions::targetCount() == 1 ) { PluginFunctions::getObject(_identifier,object);
BaseObjectData* object; // We only show the information in the status bar if one target mesh is selected or
PluginFunctions::getObject(_identifier,object); // If 2 targets where selected, where one is deleted which was target
if ( PluginFunctions::targetCount() == 1 || ( _deleted && (PluginFunctions::targetCount() == 2) && object && object->target() ) ) {
// The object that caused the update is not a target anymore. // The object that caused the update is not a target anymore.
// Therefore we need to get the remaining target by iteration. // Therefore we need to get the remaining target by iteration.
if ( object && !object->target() ) { // If something was deleted, we might see this object here, so make sure, to not take the one with the same id as the deleted one
for ( PluginFunctions::ObjectIterator o_it = PluginFunctions::ObjectIterator(PluginFunctions::TARGET_OBJECTS); o_it != PluginFunctions::objectsEnd(); ++o_it ) { if ( object && !object->target() ) {
object = *o_it; for ( PluginFunctions::ObjectIterator o_it = PluginFunctions::ObjectIterator(PluginFunctions::TARGET_OBJECTS); o_it != PluginFunctions::objectsEnd(); ++o_it ) {
} if ( !_deleted || ( o_it->id() != _identifier ) ) {
} object = *o_it;
break;
}
}
}
// We only need to update something, if the updated object is the target object // We only need to update something, if the updated object is the target object
if (object && object->target() ) { if (object && object->target() ) {
if (object->dataType(DATA_TRIANGLE_MESH)){ if (object->dataType(DATA_TRIANGLE_MESH)){
TriMesh* mesh = PluginFunctions::triMesh(object); TriMesh* mesh = PluginFunctions::triMesh(object);
infoBar_->vertices->setText( QLocale::system().toString( qulonglong(mesh->n_vertices()) ) ); infoBar_->vertices->setText( QLocale::system().toString( qulonglong(mesh->n_vertices()) ) );
infoBar_->edges->setText( QLocale::system().toString( qulonglong(mesh->n_edges()) ) ); infoBar_->edges->setText( QLocale::system().toString( qulonglong(mesh->n_edges()) ) );
infoBar_->faces->setText( QLocale::system().toString( qulonglong(mesh->n_faces()) ) ); infoBar_->faces->setText( QLocale::system().toString( qulonglong(mesh->n_faces()) ) );
infoBar_->showCounts(); infoBar_->showCounts();
return; return;
} }
if (object->dataType(DATA_POLY_MESH)){ if (object->dataType(DATA_POLY_MESH)){
PolyMesh* mesh = PluginFunctions::polyMesh(object); PolyMesh* mesh = PluginFunctions::polyMesh(object);
infoBar_->vertices->setText( QLocale::system().toString( qulonglong(mesh->n_vertices()) ) ); infoBar_->vertices->setText( QLocale::system().toString( qulonglong(mesh->n_vertices()) ) );
infoBar_->edges->setText( QLocale::system().toString( qulonglong(mesh->n_edges()) ) ); infoBar_->edges->setText( QLocale::system().toString( qulonglong(mesh->n_edges()) ) );
infoBar_->faces->setText( QLocale::system().toString( qulonglong(mesh->n_faces()) ) ); infoBar_->faces->setText( QLocale::system().toString( qulonglong(mesh->n_faces()) ) );
infoBar_->showCounts(); infoBar_->showCounts();
return; return;
} }
} }
//infoBar_->hideCounts(); infoBar_->hideCounts();
} else { } else {
// Display only count information // Display only count information
if ( PluginFunctions::targetCount() > 1 ) { if ( (PluginFunctions::targetCount() > 1) && object ) {
infoBar_->showTargetCount( PluginFunctions::targetCount() ); if ( _deleted && object->target() ) {
} else infoBar_->showTargetCount( PluginFunctions::targetCount() - 1);
infoBar_->hideCounts(); } else {
} infoBar_->showTargetCount( PluginFunctions::targetCount() );
}
} else
infoBar_->hideCounts();
}
}
//------------------------------------------------------------------------------
void InfoMeshObjectPlugin::slotObjectUpdated( int _identifier , const UpdateType& _type){
updateData(_identifier,_type,false);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void InfoMeshObjectPlugin::slotObjectSelectionChanged( int _identifier ){ void InfoMeshObjectPlugin::slotObjectSelectionChanged( int _identifier ){
slotObjectUpdated( _identifier , UPDATE_ALL ); updateData(_identifier,UPDATE_ALL,false);
}
//------------------------------------------------------------------------------
void InfoMeshObjectPlugin::objectDeleted( int _identifier ){
updateData(_identifier,UPDATE_ALL,true);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void InfoMeshObjectPlugin::slotAllCleared(){ void InfoMeshObjectPlugin::slotAllCleared(){
......
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
#include <OpenFlipper/BasePlugin/BaseInterface.hh> #include <OpenFlipper/BasePlugin/BaseInterface.hh>
#include <OpenFlipper/BasePlugin/InformationInterface.hh> #include <OpenFlipper/BasePlugin/InformationInterface.hh>
#include <OpenFlipper/BasePlugin/LoadSaveInterface.hh>
#include <OpenFlipper/BasePlugin/StatusbarInterface.hh> #include <OpenFlipper/BasePlugin/StatusbarInterface.hh>
#include <OpenFlipper/BasePlugin/LoggingInterface.hh> #include <OpenFlipper/BasePlugin/LoggingInterface.hh>
#include <OpenFlipper/common/Types.hh> #include <OpenFlipper/common/Types.hh>
...@@ -73,13 +73,14 @@ ...@@ -73,13 +73,14 @@
Plugin to visualize information about objects in the scene Plugin to visualize information about objects in the scene
*/ */
class InfoMeshObjectPlugin : public QObject, BaseInterface, InformationInterface, LoggingInterface, StatusbarInterface class InfoMeshObjectPlugin : public QObject, BaseInterface, InformationInterface, LoggingInterface, StatusbarInterface, LoadSaveInterface
{ {
Q_OBJECT Q_OBJECT
Q_INTERFACES(BaseInterface) Q_INTERFACES(BaseInterface)
Q_INTERFACES(InformationInterface) Q_INTERFACES(InformationInterface)
Q_INTERFACES(LoggingInterface) Q_INTERFACES(LoggingInterface)
Q_INTERFACES(StatusbarInterface) Q_INTERFACES(StatusbarInterface)
Q_INTERFACES(LoadSaveInterface)
#if QT_VERSION >= 0x050000 #if QT_VERSION >= 0x050000
Q_PLUGIN_METADATA(IID "org.OpenFlipper.Plugins.Plugin-MeshObjectInfo") Q_PLUGIN_METADATA(IID "org.OpenFlipper.Plugins.Plugin-MeshObjectInfo")
...@@ -106,6 +107,9 @@ class InfoMeshObjectPlugin : public QObject, BaseInterface, InformationInterface ...@@ -106,6 +107,9 @@ class InfoMeshObjectPlugin : public QObject, BaseInterface, InformationInterface
void slotObjectSelectionChanged( int _identifier ); void slotObjectSelectionChanged( int _identifier );
void slotAllCleared(); void slotAllCleared();
// LoadSaveInterface
void objectDeleted( int _identifier );
void noguiSupported( ) {} ; void noguiSupported( ) {} ;
// InformationInterface // InformationInterface
...@@ -134,6 +138,9 @@ class InfoMeshObjectPlugin : public QObject, BaseInterface, InformationInterface ...@@ -134,6 +138,9 @@ class InfoMeshObjectPlugin : public QObject, BaseInterface, InformationInterface
template< class MeshT > template< class MeshT >
void printMeshInfo( MeshT* _mesh, int _id, unsigned int _face, ACG::Vec3d& _hitPoint ); void printMeshInfo( MeshT* _mesh, int _id, unsigned int _face, ACG::Vec3d& _hitPoint );
/// Slot that updates the visualization
void updateData( int _identifier , const UpdateType& _type, const bool deleted);
//=========================================================================== //===========================================================================
/** @name Scripting Functions /** @name Scripting Functions
* @{ */ * @{ */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment