From 6b39e6feec503218899829e9061ecb5530fc4972 Mon Sep 17 00:00:00 2001 From: rnv Date: Thu, 11 Aug 2011 11:43:20 +0000 Subject: [PATCH] Fix for the bug 'IPAL22705 Wrong behavior of "visibility" icons'. --- src/CAM/CAM_Module.cxx | 8 +++++ src/CAM/CAM_Module.h | 2 ++ src/LightApp/LightApp_Displayer.cxx | 7 +++- src/SalomeApp/SalomeApp_Module.cxx | 54 ++++++++++++++++------------- src/SalomeApp/SalomeApp_Module.h | 2 ++ 5 files changed, 47 insertions(+), 26 deletions(-) diff --git a/src/CAM/CAM_Module.cxx b/src/CAM/CAM_Module.cxx index 01560f0b0..f1ea619be 100755 --- a/src/CAM/CAM_Module.cxx +++ b/src/CAM/CAM_Module.cxx @@ -1015,6 +1015,14 @@ QAction* CAM_Module::separator() return QtxActionMgr::separator(); } +/*! + \brief Update visibility state of the module objects. +*/ +void CAM_Module::updateModuleVisibilityState() { + +} + + /*! \brief Connect data model of the module to the active study \param camStudy CAM study object diff --git a/src/CAM/CAM_Module.h b/src/CAM/CAM_Module.h index ee865d9ff..e464e876f 100755 --- a/src/CAM/CAM_Module.h +++ b/src/CAM/CAM_Module.h @@ -80,6 +80,8 @@ public: void setToolShown( QAction*, const bool ); void setToolShown( const int, const bool ); + virtual void updateModuleVisibilityState(); + public slots: virtual bool activateModule( SUIT_Study* ); virtual bool deactivateModule( SUIT_Study* ); diff --git a/src/LightApp/LightApp_Displayer.cxx b/src/LightApp/LightApp_Displayer.cxx index d5d8ffd46..81f935e78 100644 --- a/src/LightApp/LightApp_Displayer.cxx +++ b/src/LightApp/LightApp_Displayer.cxx @@ -311,16 +311,21 @@ LightApp_Displayer* LightApp_Displayer::FindDisplayer( const QString& mod_name, return 0; LightApp_Module* m = dynamic_cast( app ? app->module( mod_name ) : 0 ); + bool wasLoaded = false; if( !m && load ) { m = dynamic_cast( app->loadModule( mod_name, false ) ); - if( m ) + if( m ) { app->addModule( m ); + wasLoaded = true; + } } if( m ) { m->connectToStudy( dynamic_cast( app->activeStudy() ) ); + if( wasLoaded ) + m->updateModuleVisibilityState(); } return m ? m->displayer() : 0; } diff --git a/src/SalomeApp/SalomeApp_Module.cxx b/src/SalomeApp/SalomeApp_Module.cxx index 68203ee31..cd88200d8 100644 --- a/src/SalomeApp/SalomeApp_Module.cxx +++ b/src/SalomeApp/SalomeApp_Module.cxx @@ -150,32 +150,9 @@ bool SalomeApp_Module::activateModule( SUIT_Study* theStudy ) if (!myIsFirstActivate) return state; - myIsFirstActivate = false; - - // update visibility state of objects - SalomeApp_Application* app = dynamic_cast(application()); - if (!app) - return false; - - SUIT_DataBrowser* ob = app->objectBrowser(); - if (!ob || !ob->model()) - return false; - - // connect to click on item - connect( ob->model(), SIGNAL( clicked( SUIT_DataObject*, int ) ), - this, SLOT( onObjectClicked( SUIT_DataObject*, int ) ), Qt::UniqueConnection ); - + updateModuleVisibilityState(); - SUIT_DataObject* rootObj = ob->root(); - if( !rootObj ) - return false; - - DataObjectList listObj = rootObj->children( true ); - - SUIT_ViewModel* vmod = 0; - if ( SUIT_ViewManager* vman = app->activeViewManager() ) - vmod = vman->getViewModel(); - app->updateVisibilityState( listObj, vmod ); + myIsFirstActivate = false; return state; } @@ -291,3 +268,30 @@ bool SalomeApp_Module::renameObject( const QString& /*entry*/, const QString& /* } return true; } + +void SalomeApp_Module::updateModuleVisibilityState() { + + // update visibility state of objects + SalomeApp_Application* app = dynamic_cast(SUIT_Session::session()->activeApplication()); + if (!app) + return; + + SUIT_DataBrowser* ob = app->objectBrowser(); + if (!ob || !ob->model()) + return; + + // connect to click on item + connect( ob->model(), SIGNAL( clicked( SUIT_DataObject*, int ) ), + this, SLOT( onObjectClicked( SUIT_DataObject*, int ) ), Qt::UniqueConnection ); + + SUIT_DataObject* rootObj = ob->root(); + if( !rootObj ) + return; + + DataObjectList listObj = rootObj->children( true ); + + SUIT_ViewModel* vmod = 0; + if ( SUIT_ViewManager* vman = app->activeViewManager() ) + vmod = vman->getViewModel(); + app->updateVisibilityState( listObj, vmod ); +} \ No newline at end of file diff --git a/src/SalomeApp/SalomeApp_Module.h b/src/SalomeApp/SalomeApp_Module.h index b3161a0e2..cfe8f0933 100644 --- a/src/SalomeApp/SalomeApp_Module.h +++ b/src/SalomeApp/SalomeApp_Module.h @@ -72,6 +72,8 @@ public: virtual void studyClosed( SUIT_Study* ); virtual void onObjectClicked( SUIT_DataObject*, int ); + virtual void updateModuleVisibilityState(); + protected: virtual CAM_DataModel* createDataModel(); virtual void extractContainers( const SALOME_ListIO&, SALOME_ListIO& ) const; -- 2.39.2