Salome HOME
[CEA] Automatically expand tree in Object Browser
[modules/gui.git] / src / LightApp / LightApp_Application.cxx
index 89fb8ec1278723b21a344ea4783e00963e0672e2..d72e414f5a293eca0416426cc5a2a28f8b0bf946 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2023  CEA, EDF, OPEN CASCADE
+// Copyright (C) 2007-2024  CEA, EDF, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -599,6 +599,25 @@ bool LightApp_Application::activateModule( const QString& modName )
     if ( objectBrowser()->root() != activeStudy()->root() )
       objectBrowser()->setRoot( activeStudy()->root() );
     updateObjectBrowser( true );
+
+    // expand SHAPERSTUDY data after leaving Shaper module
+    // bos #40645 [CEA] Automatically expand tree in Object Browser
+    if (actName == "Shaper") {
+      SUIT_AbstractModel* aModel = dynamic_cast<SUIT_AbstractModel*>(objectBrowser()->model());
+      LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( activeStudy() );
+      if (aModel && aStudy) {
+        DataObjectList aComps;
+        aStudy->root()->children(aComps);
+        for(auto aCompSUIT : aComps){
+          LightApp_DataObject* aComp = dynamic_cast<LightApp_DataObject*>( aCompSUIT );
+          if ( aComp && aComp->componentDataType() == "SHAPERSTUDY") {
+            QModelIndex anIndex = aModel->index(aComp);
+            objectBrowser()->treeView()->expand(anIndex);
+            break;
+          }
+        }
+      }
+    }
   }
 
   if ( activeModule() ) activeModule()->updateModuleVisibilityState();
@@ -899,14 +918,14 @@ void LightApp_Application::customize()
   LightApp_ModuleAction* moduleAction = qobject_cast<LightApp_ModuleAction*>( action( ModulesListId ) );
   // a. regular modules were added in createActions() method
   // b. here we add custom modules (manually added by the user)
-  if ( HAS_SALOME_ON_DEMAND )
+  if ( HAS_SALOME_ON_DEMAND && QString::compare(getenv("SALOME_ON_DEMAND"),"HIDE", Qt::CaseInsensitive) != 0)
   {
     // Update rc file
     updateSalomeApprc();
 
     QStringList modList = resourceMgr()->stringValue( "launch", "user_modules" ).split( ";", QString::SkipEmptyParts );
     foreach ( QString aModule, modList )
-      addUserModule(  aModule, resourceMgr()->stringValue( "user_modules", aModule ) );
+      addUserModule(  aModule, resourceMgr()->stringValue( "user_modules", aModule ), true );
   }
   else
   {
@@ -924,9 +943,9 @@ void LightApp_Application::updateSalomeApprc()
 
     QString salomemodules(getenv("SALOME_MODULES"));
     if(salomemodules.isEmpty())
-        AddComponents_from_salomeappdir(  QDir(extRootDir), resMgr );
+        UpdateCompInfo_with_salomeappdir(  QDir(extRootDir), resMgr );
     else
-        AddComponents_from_salomemodules(salomemodules, QDir(extRootDir), resMgr);
+        UpdateCompInfo_with_salomemodules(salomemodules, QDir(extRootDir), resMgr);
 }
 
 /*!On module activation action.*/
@@ -1049,6 +1068,9 @@ void LightApp_Application::onExtAdding()
 /*Add user module.*/
 bool LightApp_Application::addUserModule( const QString& name, const QString& root, bool interactive )
 {
+  if ( name == "KERNEL" || name == "GUI" )
+    return false; // skip KERNEL and GUI modules
+
   if ( name.isEmpty() || root.isEmpty() )
     return false;
 
@@ -1099,7 +1121,7 @@ bool LightApp_Application::addUserModule( const QString& name, const QString& ro
   // need to do that again.
   // TODO: Maybe it's better to return ModuleInfo from appendModuleInfo() and check status.
   const QString title = resMgr->stringValue(name, "name", QString()).trimmed();
-  if (resMgr->booleanValue(name, "gui", false) || !title.isEmpty())
+  if (resMgr->booleanValue(name, "gui", false) || !title.isEmpty() && interactive)
   {
     // Append module to the menu / toolbar
     LightApp_ModuleAction* moduleAction = qobject_cast<LightApp_ModuleAction*>(action(ModulesListId));