From: rnv Date: Fri, 5 Jun 2020 13:18:34 +0000 (+0300) Subject: bos #19209 EDF 21531 - General problem of dumping a 9.4.0 study X-Git-Tag: V9_5_0rc1^0 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c08eee33a31083b8e86f79af5729ebfa99b35359;p=modules%2Fgui.git bos #19209 EDF 21531 - General problem of dumping a 9.4.0 study --- diff --git a/src/CAM/CAM_Application.cxx b/src/CAM/CAM_Application.cxx index 9612c4e4d..ae731cee5 100644 --- a/src/CAM/CAM_Application.cxx +++ b/src/CAM/CAM_Application.cxx @@ -417,6 +417,7 @@ bool CAM_Application::activateModule( const QString& modName ) bool res = false; if ( !modName.isEmpty() ) { + setProperty("activateModule", true); CAM_Module* mod = module( modName ); if ( !mod ) mod = loadModule( modName ); @@ -424,6 +425,7 @@ bool CAM_Application::activateModule( const QString& modName ) if ( mod ) res = activateModule( mod ); + setProperty("activateModule", QVariant()); } else res = activateModule( 0 ); diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index 8dfa333b0..983648dcf 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -4956,6 +4956,34 @@ void LightApp_Application::onDesktopMessage( const QString& message ) if ( !vtype.isEmpty() ) getViewManager( vtype, true ); } + else if ( message.toLower().startsWith("register_module_in_study" ) ) { + QString moduleName = message.split( sectionSeparator ).last(); + // Check name of current activating module name in order to avoid ciclik + // call because of messages + if (!property("activateModule").toBool()) { + CAM_Module* mod = module(moduleName); + if (!mod) + mod = module(moduleTitle(moduleName)); + if (!mod) { + mod = loadModule(moduleName); + if (!mod) + mod = loadModule(moduleTitle(moduleName)); + if (mod) { + addModule(mod); + } + } + if (mod) { + CAM_Study* anActiveStudy = dynamic_cast(activeStudy()); + if (anActiveStudy) { + mod->connectToStudy(anActiveStudy); + LightApp_DataModel* aDM = dynamic_cast(mod->dataModel()); + if(aDM) { + aDM->initRootObject(); + } + } + } + } + } else { QStringList data = message.split( sectionSeparator ); if ( data.count() > 1 ) { diff --git a/src/LightApp/LightApp_DataModel.h b/src/LightApp/LightApp_DataModel.h index aec64368b..74016ab3e 100644 --- a/src/LightApp/LightApp_DataModel.h +++ b/src/LightApp/LightApp_DataModel.h @@ -70,6 +70,9 @@ public: int groupId() const; void registerColumn( SUIT_DataBrowser*, const QString&, const int ); void unregisterColumn( SUIT_DataBrowser*, const QString& ); + //! For initialization of the data model and registration of SComponent when study is created + //! but module was not activated. + virtual void initRootObject() {}; signals: void opened(); diff --git a/src/SalomeApp/SalomeApp_Application.cxx b/src/SalomeApp/SalomeApp_Application.cxx index 94c952df3..7204f3f74 100644 --- a/src/SalomeApp/SalomeApp_Application.cxx +++ b/src/SalomeApp/SalomeApp_Application.cxx @@ -966,6 +966,7 @@ void SalomeApp_Application::onDumpStudy( ) bool res; { SUIT_OverrideCursor wc; + ensureShaperIsActivated(); res = appStudy->dump( aFileName, toPublish, isMultiFile, toSaveGUI ); } if ( !res ) @@ -2113,3 +2114,21 @@ PyConsole_Interp* SalomeApp_Application::createPyInterp() } #endif // DISABLE_PYCONSOLE + +void SalomeApp_Application::ensureShaperIsActivated() +{ + SalomeApp_Study* study = dynamic_cast(activeStudy()); + _PTR(Study) studyDS = getStudy(); + if ( study && studyDS ) + { + _PTR(SObject) shaper = studyDS->FindObjectByPath("/Shaper"); // non null result if shaper data is present in the study + bool shaperIsActive = false; + QList models; + study->dataModels( models ); + for( int i = 0; i < models.count() && !shaperIsActive; i++ ) + shaperIsActive = models[i]->module()->moduleName() == "Shaper"; + + if (shaper && !shaperIsActive) + onDesktopMessage("register_module_in_study/Shaper"); + } +} diff --git a/src/SalomeApp/SalomeApp_Application.h b/src/SalomeApp/SalomeApp_Application.h index 3919ba3f8..5f4da65f0 100644 --- a/src/SalomeApp/SalomeApp_Application.h +++ b/src/SalomeApp/SalomeApp_Application.h @@ -193,6 +193,7 @@ private slots: private: void createExtraActions(); + void ensureShaperIsActivated(); private: #ifndef DISABLE_PYCONSOLE