Salome HOME
bos #19209 EDF 21531 - General problem of dumping a 9.4.0 study V9_5_0rc1 V9_5_0rc2
authorrnv <rnv@opencascade.com>
Fri, 5 Jun 2020 13:18:34 +0000 (16:18 +0300)
committervsr <vsr@opencascade.com>
Mon, 15 Jun 2020 16:45:27 +0000 (19:45 +0300)
src/CAM/CAM_Application.cxx
src/LightApp/LightApp_Application.cxx
src/LightApp/LightApp_DataModel.h
src/SalomeApp/SalomeApp_Application.cxx
src/SalomeApp/SalomeApp_Application.h

index 9612c4e4db8b6aefd932a38e3000daa99d0744d1..ae731cee51f48a1906f062719fbea145e5af7cf3 100644 (file)
@@ -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 );
index 8dfa333b09f5a110a7e2673bafa4855b7fe86efc..983648dcf511b45151cb0381458a9fcb0a07aa66 100644 (file)
@@ -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<CAM_Study*>(activeStudy());
+        if (anActiveStudy) {
+          mod->connectToStudy(anActiveStudy);
+          LightApp_DataModel* aDM = dynamic_cast<LightApp_DataModel*>(mod->dataModel());
+          if(aDM) {
+            aDM->initRootObject();
+          }
+        }
+      }
+    }
+  }
   else {
     QStringList data = message.split( sectionSeparator );
     if ( data.count() > 1 ) {
index aec64368bb9efc9af8f449ca26f34b87a154bc01..74016ab3e3085594d7b8867916dfbdffa5b04db8 100644 (file)
@@ -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();
index 94c952df3e7413eedde851f35d3b500877a8ad03..7204f3f740f73868f2f35b0936aa5dfae8d60781 100644 (file)
@@ -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<SalomeApp_Study*>(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<CAM_DataModel*> 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");
+  }
+}
index 3919ba3f8b487a0f7f81157f84935e5de9d20fad..5f4da65f06bd9b21f1a77be96a8107dc6b64948d 100644 (file)
@@ -193,6 +193,7 @@ private slots:
 
 private:
   void                                createExtraActions();
+  void                                ensureShaperIsActivated();
 
 private:
 #ifndef DISABLE_PYCONSOLE