]> SALOME platform Git repositories - modules/shaper.git/blobdiff - src/XGUI/XGUI_Workshop.cpp
Salome HOME
Copyright update 2022
[modules/shaper.git] / src / XGUI / XGUI_Workshop.cpp
index 1be4d47c68280b3e8e377cc9de773722531e24ce..d5b78f0e0f312c0dc52ce5ab72268cf6426abb07 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2021  CEA/DEN, EDF R&D
+// Copyright (C) 2014-2022  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 #include <iterator>
 
 #ifdef TINSPECTOR
-#include <CDF_Session.hxx>
-#include <CDF_Application.hxx>
+#include <TDocStd_Application.hxx>
 #include <inspector/TInspector_Communicator.hxx>
 #include <inspector/VInspector_CallBack.hxx>
 static TInspector_Communicator* MyTCommunicator;
 static Handle(VInspector_CallBack) MyVCallBack;
-
 #endif
 
 #ifdef _DEBUG
@@ -174,6 +172,8 @@ static Handle(VInspector_CallBack) MyVCallBack;
 
 #ifdef WIN32
 #include <windows.h>
+#pragma warning(disable : 4456) // for nested foreach
+#pragma warning(disable : 4189) // for declaration of unused variables (MAYBE_UNUSED)
 #else
 #include <dlfcn.h>
 #endif
@@ -681,6 +681,7 @@ void XGUI_Workshop::showHelpPage(const QString& thePage) const
 #endif
     QString aFileName = aDocDir + aSep + thePage;
     if (QFile::exists(aFileName)) {
+#ifdef HAVE_SALOME
       SUIT_Application* app = SUIT_Session::session()->activeApplication();
       if (app)
         app->onHelpContextModule("SHAPER", aFileName);
@@ -688,6 +689,10 @@ void XGUI_Workshop::showHelpPage(const QString& thePage) const
         QUrl aUrl = QUrl::fromLocalFile(aFileName);
         QDesktopServices::openUrl(aUrl);
       }
+#else
+      QUrl aUrl = QUrl::fromLocalFile(aFileName);
+      QDesktopServices::openUrl(aUrl);
+#endif
     }
   }
 }
@@ -1064,6 +1069,37 @@ void XGUI_Workshop::openFile(const QString& theDirectory)
   }
 #endif
 
+  int anActivationId =
+    ModuleBase_Preferences::resourceMgr()->integerValue("General", "part_activation_study", -1);
+  int aSize = aRootDoc->size(ModelAPI_ResultPart::group());
+
+  if (anActivationId == 0 && aSize > 0) {
+    ObjectPtr anObject = aRootDoc->object(ModelAPI_ResultPart::group(), aSize - 1);
+    ResultPartPtr aPart = std::dynamic_pointer_cast<ModelAPI_ResultPart>(anObject);
+    if (aPart.get()) {
+      aPart->activate();
+      ModuleBase_Tools::setDisplaying(aPart);
+    }
+  }
+  else if (anActivationId == 1) {
+    for (int anIndex = 0; anIndex < aSize; ++anIndex) {
+      ObjectPtr anObject = aRootDoc->object(ModelAPI_ResultPart::group(), anIndex);
+      ResultPartPtr aPart = std::dynamic_pointer_cast<ModelAPI_ResultPart>(anObject);
+      if (aPart.get()) {
+        aPart->activate();
+        ModuleBase_Tools::setDisplaying(aPart);
+
+        if (anIndex < aSize - 1) {
+          SessionPtr aMgr = ModelAPI_Session::get();
+          aMgr->startOperation("Activation");
+          aMgr->setActiveDocument(aMgr->moduleDocument());
+          aMgr->finishOperation();
+          updateCommandStatus();
+          viewer()->update();
+        }
+      }
+    }
+  }
   QApplication::restoreOverrideCursor();
 }
 
@@ -1822,7 +1858,7 @@ void XGUI_Workshop::onContextMenuCommand(const QString& theId, bool isChecked)
   }
 #ifdef TINSPECTOR
   else if (theId == "TINSPECTOR_VIEW") {
-    Handle(CDF_Application) anApplication = CDF_Session::CurrentSession()->CurrentApplication();
+    Handle(TDocStd_Application) anApplication = ModelAPI_Session::get()->application();
     if (!anApplication.IsNull())
     {
       if (!MyTCommunicator)
@@ -2547,14 +2583,9 @@ void XGUI_Workshop::changeAutoColor(const QObjectPtrList& theObjects)
   QString aDescription = contextMenuMgr()->action("AUTOCOLOR_CMD")->text();
   aMgr->startOperation(aDescription.toStdString());
 
-  Config_Prop* aProp = Config_PropManager::findProp("Visualization", "result_group_auto_color");
-
-  if (aProp) {
-    bool anIsAutoColor = Config_PropManager::boolean("Visualization", "result_group_auto_color");
-
-    if (anIsAutoColor) {
+    if (Config_PropManager::getAutoColorStatus()) {
       contextMenuMgr()->action("AUTOCOLOR_CMD")->setText(tr("Auto color"));
-      aProp->setValue("false");
+      Config_PropManager::setAutoColorStatus(false);
       ModelAPI_Tools::findRandomColor(aColor, true);
     } else {
       // set the value to all results
@@ -2585,9 +2616,8 @@ void XGUI_Workshop::changeAutoColor(const QObjectPtrList& theObjects)
       updateCommandStatus();
       myViewerProxy->update();
       contextMenuMgr()->action("AUTOCOLOR_CMD")->setText(tr("Disable auto color"));
-      aProp->setValue("true");
+      Config_PropManager::setAutoColorStatus(true);
     }
-  }
 }
 
 //**************************************************************