From: asl Date: Thu, 6 Oct 2005 09:18:36 +0000 (+0000) Subject: Part of code inserting data model of new loaded module now is described as method... X-Git-Tag: BR-D5-38-2003_D2005-12-19~14 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=9489e3db64052f2e730443877462cff5472867a9;p=modules%2Fgui.git Part of code inserting data model of new loaded module now is described as method of CAM_Module --- diff --git a/src/CAM/CAM_Application.cxx b/src/CAM/CAM_Application.cxx index 4f276dfa8..171a2cb1b 100755 --- a/src/CAM/CAM_Application.cxx +++ b/src/CAM/CAM_Application.cxx @@ -290,20 +290,7 @@ bool CAM_Application::activateModule( CAM_Module* mod ) if ( myModule ){ // Connect the module to the active study - CAM_Study* camStudy = dynamic_cast( activeStudy() ); - if ( camStudy ){ - CAM_DataModel* prev = 0; - for ( ModuleListIterator it( myModules ); it.current(); ++it ) { - CAM_DataModel* dm = it.current()->dataModel(); - if ( it.current() == myModule && !camStudy->containsDataModel( dm ) ){ - if ( prev ) - camStudy->insertDataModel( it.current()->dataModel(), prev ); - else - camStudy->insertDataModel( it.current()->dataModel(), 0 ); - } - prev = dm; - } - } + myModule->connectToStudy( dynamic_cast( activeStudy() ) ); if ( !myModule->activateModule( activeStudy() ) ) { myModule->setMenuShown( false ); diff --git a/src/CAM/CAM_Module.cxx b/src/CAM/CAM_Module.cxx index 46ac007ee..733afa4dc 100755 --- a/src/CAM/CAM_Module.cxx +++ b/src/CAM/CAM_Module.cxx @@ -550,3 +550,25 @@ QAction* CAM_Module::separator() { return QtxActionMgr::separator(); } + +/*! Connect data model of module with active study */ +void CAM_Module::connectToStudy( CAM_Study* camStudy ) +{ + CAM_Application* app = camStudy ? dynamic_cast( camStudy->application() ) : 0; + if( !app ) + return; + + CAM_DataModel* prev = 0; + for( CAM_Application::ModuleListIterator it = app->modules(); it.current(); ++it ) + { + CAM_DataModel* dm = it.current()->dataModel(); + if( it.current() == this && !camStudy->containsDataModel( dm ) ) + { + if( prev ) + camStudy->insertDataModel( it.current()->dataModel(), prev ); + else + camStudy->insertDataModel( it.current()->dataModel(), 0 ); + } + prev = dm; + } +} diff --git a/src/CAM/CAM_Module.h b/src/CAM/CAM_Module.h index b0fcfc7cd..328d2500a 100755 --- a/src/CAM/CAM_Module.h +++ b/src/CAM/CAM_Module.h @@ -9,6 +9,7 @@ class QAction; class SUIT_Study; +class CAM_Study; class CAM_DataModel; class CAM_Application; class QtxActionMenuMgr; @@ -59,6 +60,8 @@ public slots: virtual bool activateModule( SUIT_Study* ); virtual bool deactivateModule( SUIT_Study* ); + virtual void connectToStudy( CAM_Study* ); + virtual void studyClosed( SUIT_Study* ); virtual void studyChanged( SUIT_Study*, SUIT_Study* );