]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
bos #26446 Customize study opening; bos #26447 Customize script execution
authorAlexey Kondratyev <alexey.kondratyev@opencascade.com>
Mon, 18 Oct 2021 08:12:43 +0000 (11:12 +0300)
committervsr <vsr@opencascade.com>
Wed, 15 Dec 2021 08:53:25 +0000 (11:53 +0300)
* Add tab "General" in Preferences window.
* Add algorithm to update displaying elements depending of settings.
* Update opening file algorithm to activating parts depending of settings.
* Update activating part algorithm to display elements depending of settings.
* Update activating part algorithm to display elements depending of sub elements.
* Update the documentation.

16 files changed:
doc/gui/General/Introduction.rst
doc/gui/images/general_preferences.png [new file with mode: 0644]
src/ModelHighAPI/CMakeLists.txt
src/ModelHighAPI/ModelHighAPI_Interface.cpp
src/ModelHighAPI/ModelHighAPI_Services.cpp
src/ModuleBase/ModuleBase_Preferences.cpp
src/ModuleBase/ModuleBase_Preferences.h
src/ModuleBase/ModuleBase_Tools.cpp
src/ModuleBase/ModuleBase_Tools.h
src/ModuleBase/ModuleBase_msg_fr.ts
src/PartSet/PartSet_MenuMgr.cpp
src/SHAPERGUI/resources/LightApp.xml.in
src/XGUI/SHAPER.xml
src/XGUI/XGUI_Workshop.cpp
src/XGUI/XGUI_WorkshopListener.cpp
src/XGUI/XGUI_WorkshopListener.h

index 35e17284c3f8df4180ac7fb4ebe704862081b62a..3cb1c45b2098d74de2805449301855a62836a0d1 100644 (file)
@@ -451,6 +451,7 @@ To call **Preferences** dialog box:
 
 SHAPER preferences contains the following tabs:
 
+- :ref:`general_preferences`;
 - :ref:`visualization_preferences`;
 - :ref:`plugins_preferences`;
 - :ref:`shortcuts_preferences`;
@@ -458,10 +459,43 @@ SHAPER preferences contains the following tabs:
 - :ref:`sketch_preferences`.
 - :ref:`viewer_preferences`.
 
-Visualization tab is activated by default when **Preferences** dialog box is opened in the active SHAPER module.
+General tab is activated by default when **Preferences** dialog box is opened in the active SHAPER module.
 
 Other tabs are activated by click on tab header.
 
+.. _general_preferences:
+
+General tab
+^^^^^^^^^^^
+
+This tab defines what parts to be activated and what elements to be visible after opening a study or a script.
+
+.. figure:: /images/general_preferences.png
+   :align: center
+
+   **Preferences**: General tab
+
+**Input fields**:
+
+- **Activate** relates to activation of part when opening a HDF document. Its could be one of the following:
+
+  - "Last part" - activate last part in the document (**default value**);
+  - "All parts" - activate all parts within the document;
+  - "No activation" - do not activate any part.
+
+- **Display** in "Opening a study". It specifies the shapes, which should be visualized when activating a part. It could be one of the following:
+
+  - "As stored in HDF" - display only the shapes visible before the document is saved (**default value**);
+  - "Last item in each folder" - show only the last result in each folder of the part: Constructions, Results, Groups, Fields;
+  - "All items" - show all shapes from each folder;
+  - "No visualization" - do not display any shape.
+
+- **Display** in "Launching a python script". It specifies the shapes, which should be visualized when loading a script using "File -> Load Script..." menu. It could be one of the following:
+
+  - "Last item in each folder" - show only the last result in each folder of the part: Constructions, Results, Groups, Fields;
+  - "All items" - show all shapes from each folder(**default value**);
+  - "No visualization" - do not display any shape.
+
 .. _visualization_preferences:
 
 Visualization tab
diff --git a/doc/gui/images/general_preferences.png b/doc/gui/images/general_preferences.png
new file mode 100644 (file)
index 0000000..e7eee17
Binary files /dev/null and b/doc/gui/images/general_preferences.png differ
index 2d7a4917f409303906b8799b958bb677e1280eaf..07adac9db8d19c84f9c7306795022b79a9b61202 100644 (file)
@@ -58,6 +58,7 @@ SET(PROJECT_LIBRARIES
   Locale
   ModelAPI
   ModelGeomAlgo
+  ModuleBase
 )
 
 ADD_DEFINITIONS(-DMODELHIGHAPI_EXPORTS -DWNT)
@@ -87,6 +88,7 @@ INCLUDE_DIRECTORIES(
   ${PROJECT_SOURCE_DIR}/src/Locale
   ${PROJECT_SOURCE_DIR}/src/ModelAPI
   ${PROJECT_SOURCE_DIR}/src/ModelGeomAlgo
+  ${PROJECT_SOURCE_DIR}/src/ModuleBase
   ${PROJECT_SOURCE_DIR}/src/PartSetPlugin
   ${OpenCASCADE_INCLUDE_DIR}
 )
index 82423fb0b0a73b1a0015897120366c0c0de82c4d..bd87cd0e40ac30231357e3966ce5ba932d4b6f11 100644 (file)
@@ -82,7 +82,7 @@ void ModelHighAPI_Interface::execute(bool isForce)
   Events_Loop* aLoop = Events_Loop::loop();
   aLoop->flush(Events_Loop::eventByName(EVENT_OBJECT_CREATED));
   aLoop->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
-  //aLoop->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
+  aLoop->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
   //aLoop->flush(Events_Loop::eventByName(EVENT_OBJECT_DELETED));
 }
 
index 09dea983c9743077e5e0a2631f7588b8d54b8e49..763798c8b72bb35dcdc2f8b60b64ba5f24112ece 100644 (file)
@@ -26,6 +26,8 @@
 #include <ModelAPI_ResultConstruction.h>
 #include <ModelAPI_Events.h>
 
+#include <ModuleBase_Tools.h>
+
 #include <cmath>
 #include <sstream>
 
@@ -106,8 +108,9 @@ void begin()
     aNbTransactions = aNbUndo;
     ++aTransactionID;
   }
+  static std::string anOperationPrefix(ModuleBase_Tools::translate("", "Operation").toStdString());
   std::ostringstream aTransactionName;
-  aTransactionName << "Operation_" << aTransactionID;
+  aTransactionName << anOperationPrefix << "_" << aTransactionID;
   ModelAPI_Session::get()->startOperation(aTransactionName.str());
 }
 
index c651c7d46f36cc16d515bef47f77f074df6091a6..229603f834503abe506ae7dbab73070b643a1c3c 100644 (file)
@@ -35,6 +35,7 @@
 
 const QString ModuleBase_Preferences::VIEWER_SECTION = "Viewer";
 const QString ModuleBase_Preferences::MENU_SECTION = "Menu";
+const QString ModuleBase_Preferences::GENERAL_SECTION = "General";
 
 SUIT_ResourceMgr* ModuleBase_Preferences::myResourceMgr = 0;
 
@@ -115,6 +116,7 @@ void ModuleBase_Preferences::loadCustomProps()
 void ModuleBase_Preferences::createEditContent(ModuleBase_IPrefMgr* thePref, int thePage)
 {
   thePref->prefMgr()->setItemIcon(thePage, QIcon(":pictures/module.png"));
+  createGeneralTab(thePref, thePage);
   createCustomPage(thePref, thePage);
 }
 
@@ -150,6 +152,64 @@ void ModuleBase_Preferences::resetConfigPropPreferences(SUIT_PreferenceMgr* theP
   }
 }
 
+void ModuleBase_Preferences::createGeneralTab(ModuleBase_IPrefMgr* thePref, int thePageId)
+{
+  int generalTab = thePref->addPreference(QObject::tr("General"), thePageId,
+                                          SUIT_PreferenceMgr::Auto, QString(), QString());
+  thePref->setItemProperty("columns", 2, generalTab);
+
+  QStringList actItemList;
+  actItemList << QObject::tr("Last part")
+              << QObject::tr("All parts")
+              << QObject::tr("No activation");
+
+  QList<QVariant> actIdList;
+  actIdList << 0 << 1 << 2;
+
+  // Group related to opening a study
+  int group = thePref->addPreference(QObject::tr("Opening a study"), generalTab,
+                                     SUIT_PreferenceMgr::Auto, QString(), QString());
+
+  int actId = thePref->addPreference(QObject::tr("Activate"), group, SUIT_PreferenceMgr::Selector,
+                                     ModuleBase_Preferences::GENERAL_SECTION,
+                                     "part_activation_study");
+  thePref->setItemProperty("strings", actItemList, actId);
+  thePref->setItemProperty("indexes", actIdList, actId);
+
+  QStringList visuItemList;
+  visuItemList << QObject::tr("As stored in HDF")
+               << QObject::tr("Last item in each folder")
+               << QObject::tr("All items")
+               << QObject::tr("No visualization");
+
+  QList<QVariant> visuIdList;
+  visuIdList << 0 << 1 << 2 << 3;
+
+  int visuId = thePref->addPreference(QObject::tr("Display"), group, SUIT_PreferenceMgr::Selector,
+                                      ModuleBase_Preferences::GENERAL_SECTION,
+                                      "part_visualization_study");
+  thePref->setItemProperty("strings", visuItemList, visuId);
+  thePref->setItemProperty("indexes", visuIdList, visuId);
+
+  // Group related to running a python script
+  group = thePref->addPreference(QObject::tr("Launching a python script"), generalTab,
+                                 SUIT_PreferenceMgr::Auto, QString(), QString());
+
+  visuItemList.clear();
+  visuItemList << QObject::tr("Last item in each folder")
+               << QObject::tr("All items")
+               << QObject::tr("No visualization");
+
+  visuIdList.clear();
+  visuIdList << 0 << 1 << 2;
+
+  visuId = thePref->addPreference(QObject::tr("Display"), group, SUIT_PreferenceMgr::Selector,
+                                  ModuleBase_Preferences::GENERAL_SECTION,
+                                  "part_visualization_script");
+  thePref->setItemProperty("strings", visuItemList, visuId);
+  thePref->setItemProperty("indexes", visuIdList, visuId);
+}
+
 void ModuleBase_Preferences::createCustomPage(ModuleBase_IPrefMgr* thePref, int thePageId)
 {
   SUIT_ResourceMgr* aResMgr = ModuleBase_Preferences::resourceMgr();
index 9852625692d79526381c222bd0382a0d074d739f..65b2a2d7a748c3428e8fe708514061b9fd919588 100644 (file)
@@ -47,6 +47,9 @@ class MODULEBASE_EXPORT ModuleBase_Preferences
    /// Name of preferences of menu section
   static const QString MENU_SECTION;
 
+  /// Name of preferences of general section
+  static const QString GENERAL_SECTION;
+
   /// Shows a dialog box to edit preferences
   /// \param theModified a list of modified preferences
   static bool editPreferences(ModuleBase_Prefs& theModified);
@@ -83,6 +86,9 @@ private:
   /// Set default values to the Config_PropManager properties
   static void resetConfig();
 
+  /// Creates a content for General tab, which defines behavior of loading parts and displaying shapes
+  static void createGeneralTab(ModuleBase_IPrefMgr* thePref, int thePageId);
+
   /// Creates content of preferences editing widget
   static void createCustomPage(ModuleBase_IPrefMgr* thePref, int thePageId);
 
index b014d60deff7189df0f53bbd2d824ffcc4dd917c..1b5bfc9a30f6b00541daaff55073eff1d0cce123 100644 (file)
@@ -21,6 +21,7 @@
 
 #include <ModuleBase_ParamIntSpinBox.h>
 #include <ModuleBase_ParamSpinBox.h>
+#include <ModuleBase_Preferences.h>
 #include <ModuleBase_WidgetFactory.h>
 #include <ModuleBase_IWorkshop.h>
 #include <ModuleBase_IModule.h>
@@ -36,6 +37,7 @@
 #include <ModelAPI_AttributeSelectionList.h>
 #include <ModelAPI_AttributeRefList.h>
 #include <ModelAPI_AttributeRefAttrList.h>
+#include <ModelAPI_ResultGroup.h>
 #include <ModelAPI_ResultPart.h>
 #include <ModelAPI_ResultConstruction.h>
 #include <ModelAPI_AttributeString.h>
 
 #include <ModelGeomAlgo_Point2D.h>
 
+#ifdef HAVE_SALOME
+#include <SUIT_Application.h>
+#include <SUIT_ResourceMgr.h>
+#include <SUIT_Session.h>
+#endif
+
 #include <StdSelect_BRepOwner.hxx>
 #include <TopoDS_Iterator.hxx>
 #include <AIS_InteractiveContext.hxx>
@@ -108,6 +116,51 @@ namespace ModuleBase_Tools {
 
 //******************************************************************
 
+  //! Waits for REDISPLAY message and set the Visible flag to the entities
+  //! according to Preferences choice.
+  class ModuleBase_RedisplayListener : public Events_Listener
+  {
+  public:
+    static std::shared_ptr<ModuleBase_RedisplayListener> instance()
+    {
+      static std::shared_ptr<ModuleBase_RedisplayListener>
+          anInstance(new ModuleBase_RedisplayListener);
+      return anInstance;
+    }
+
+    void processEvent(const std::shared_ptr<Events_Message>& theMessage)
+    {
+      if (theMessage->eventID() == Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY))
+      {
+#if HAVE_SALOME
+        // If the python script is being loaded now, the preferences should be used
+        // to display the required object
+        SUIT_Application * app = SUIT_Session::session()->activeApplication();
+        QVariant aVar = app->property("IsLoadedScript");
+        if (!aVar.isNull() && aVar.toBool()) {
+          DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument();
+          int aSize = aRootDoc->size(ModelAPI_ResultPart::group());
+          if (aSize > 0) {
+            ObjectPtr anPartObject = aRootDoc->object(ModelAPI_ResultPart::group(), aSize - 1);
+            ResultPartPtr aPart = std::dynamic_pointer_cast<ModelAPI_ResultPart>(anPartObject);
+            ModuleBase_Tools::setDisplaying(aPart, true);
+          }
+        }
+#endif
+      }
+    }
+
+  private:
+    ModuleBase_RedisplayListener()
+    {
+      Events_Loop::loop()->registerListener(this,
+          Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
+    }
+  };
+
+  static std::shared_ptr<ModuleBase_RedisplayListener>
+      RL = ModuleBase_RedisplayListener::instance();
+
 //******************************************************************
 
 void adjustMargins(QWidget* theWidget)
@@ -1342,6 +1395,46 @@ qreal currentPixelRatio()
 }
 
 
+// Set displaying status to every element on group
+static void setDisplayingByLoop(DocumentPtr theDoc, int theSize,
+  std::string theGroup, bool theDisplayFromScript)
+{
+  int aDisplayingId = -1;
+  if (theDisplayFromScript) {
+    aDisplayingId = ModuleBase_Preferences::resourceMgr()->integerValue("General",
+      "part_visualization_script", -1);
+    // Increase ID to prevert using "As stored in HDF"
+    ++aDisplayingId;
+  }
+  else {
+    aDisplayingId = ModuleBase_Preferences::resourceMgr()->integerValue("General",
+      "part_visualization_study", -1);
+
+    // if chosen "As stored in HDF" then don't change displaying
+    if (aDisplayingId == 0)
+      return;
+  }
+
+  for (int anIndex = theSize - 1; anIndex >= 0; --anIndex) {
+    ObjectPtr anObject = theDoc->object(theGroup, anIndex);
+    anObject->setDisplayed((aDisplayingId == 1 && anIndex == theSize - 1) || aDisplayingId == 2);
+  }
+}
+
+void setDisplaying(ResultPartPtr thePart, bool theDisplayFromScript)
+{
+  DocumentPtr aDoc = thePart->partDoc();
+  int aConstructionSize = aDoc->size(ModelAPI_ResultConstruction::group());
+  int aGroupSize = aDoc->size(ModelAPI_ResultGroup::group());
+  int aFieldSize = aDoc->size(ModelAPI_ResultField::group());
+  int aResultSize = aDoc->size(ModelAPI_ResultBody::group());
+  setDisplayingByLoop(aDoc, aConstructionSize,
+    ModelAPI_ResultConstruction::group(), theDisplayFromScript);
+  setDisplayingByLoop(aDoc, aGroupSize, ModelAPI_ResultGroup::group(), theDisplayFromScript);
+  setDisplayingByLoop(aDoc, aFieldSize, ModelAPI_ResultField::group(), theDisplayFromScript);
+  setDisplayingByLoop(aDoc, aResultSize, ModelAPI_ResultBody::group(), theDisplayFromScript);
+}
+
 } // namespace ModuleBase_Tools
 
 
index a68f2ee9e7f645360400b15ad5a2c7cb545b1135..cae27a1d92115896c1f223a498b840234e95a1fa 100644 (file)
@@ -406,6 +406,11 @@ std::wstring MODULEBASE_EXPORT generateName(const AttributePtr& theAttribute,
 
 /// Returns pixel ratio of a screen where main window is displayed
 qreal MODULEBASE_EXPORT currentPixelRatio();
+
+/// Set displaying status for elements from part depending on the settings
+/// \param thePart a pointer of part
+void MODULEBASE_EXPORT setDisplaying(std::shared_ptr<ModelAPI_ResultPart> thePart,
+                                     bool theDisplayFromScript = false);
 }
 
 #endif
index 050f6abb6e3cc9c6e43c98bf4061b56abd1a208b..39de141b138820c2ccda7a1cc011e7fa68faed32 100644 (file)
         <source>Replace</source>
         <translation>Remplacer</translation>
     </message>
-  <message>
-    <source>Trihedron arrows constant size</source>
-    <translation>Flèche trièdre de taille constante</translation>
-  </message>
+    <message>
+        <source>Trihedron arrows constant size</source>
+        <translation>Flèche trièdre de taille constante</translation>
+    </message>
     <message>
         <source>Keep trihedron arrows view size constant</source>
         <translation>Maintenir la taille de la vue des flèches trièdres constante</translation>
     </message>
+    <message>
+        <source>General</source>
+        <translation>Général</translation>
+    </message>
+    <message>
+        <source>Opening a study</source>
+        <translation>Ouverture d&apos;une étude</translation>
+    </message>
+    <message>
+        <source>Launching a python script</source>
+        <translation>Lancement d&apos;un script python</translation>
+    </message>
+    <message>
+        <source>Activate</source>
+        <translation>Activation</translation>
+    </message>
+    <message>
+        <source>Display</source>
+        <translation>Visualisation</translation>
+    </message>
+    <message>
+        <source>Last part</source>
+        <translation>Dernière pièce</translation>
+    </message>
+    <message>
+        <source>All parts</source>
+        <translation>Toutes les pièces</translation>
+    </message>
+    <message>
+        <source>No activation</source>
+        <translation>Aucune</translation>
+    </message>
+    <message>
+        <source>As stored in HDF</source>
+        <translation>Comme dans le HDF</translation>
+    </message>
+    <message>
+        <source>Last item in each folder</source>
+        <translation>Le dernier élément de chaque dossier</translation>
+    </message>
+    <message>
+        <source>All items</source>
+        <translation>Tous les éléments</translation>
+    </message>
+    <message>
+        <source>No visualization</source>
+        <translation>Aucune visualisation</translation>
+    </message>
 </context>
 </TS>
index ce5f478a3d2568c9c1c740897ec72f592193c65e..b0cf3a6dc6369eb8dd15b4ed6b5ee3fe171dc09e 100644 (file)
@@ -46,6 +46,7 @@
 #include <XGUI_DataModel.h>
 #include <XGUI_OperationMgr.h>
 #include <XGUI_ObjectsBrowser.h>
+#include <XGUI_Tools.h>
 #include <XGUI_ViewerProxy.h>
 
 #include <Events_Loop.h>
@@ -495,15 +496,20 @@ void PartSet_MenuMgr::onActivatePart(bool)
 void PartSet_MenuMgr::activatePart(ResultPartPtr thePart) const
 {
   bool isFirstLoad = !thePart->partDoc().get();
+  ModuleBase_Tools::blockUpdateViewer(true);
   thePart->activate();
   if (isFirstLoad) {
     XGUI_Workshop* aWorkshop = myModule->getWorkshop();
     XGUI_ObjectsBrowser* aObjBrowser = aWorkshop->objectBrowser();
+    ModuleBase_Tools::setDisplaying(thePart);
+    Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
+    aObjBrowser->onSelectionChanged();
     DocumentPtr aDoc = thePart->partDoc();
     std::list<bool> aStates;
     aDoc->restoreNodesState(aStates);
     aObjBrowser->setStateForDoc(aDoc, aStates);
   }
+  ModuleBase_Tools::blockUpdateViewer(false);
 }
 
 void PartSet_MenuMgr::onActivateAllParts()
index 33908724f1de83403969f09bfd6e7ce62a43e555..0a0028ab87e15d8f8f2664b16057aba2e44caabc 100644 (file)
     <parameter name="PartSet" value="%SHAPER_ROOT_DIR%/share/salome/resources/shaper"/>
     <parameter name="XGUI" value="%SHAPER_ROOT_DIR%/share/salome/resources/shaper"/>
   </section>
+  <section name="General">
+    <!-- Common settings of part's activation and visualization -->
+    <parameter name="part_activation_study" value="0"/>
+    <parameter name="part_visualization_study" value="0"/>
+    <parameter name="part_visualization_script" value="1"/>
+  </section>
   <section name="Viewer" >
     <!-- Viewer preferences -->
     <parameter name="face-selection" value="true" />
index 879498824de975c3d7122204266dd0ccf6031883..94ff4fcc67ccd25b3ed3aab3eee02339243ac1aa 100644 (file)
@@ -4,6 +4,12 @@
     <parameter name="language"    value="en"/>
     <parameter name="locale"      value="true"/>
   </section>
+  <section name="General">
+    <!-- Common settings of part's activation and visualization -->
+    <parameter name="part_activation_study" value="0"/>
+    <parameter name="part_visualization_study" value="0"/>
+    <parameter name="part_visualization_script" value="1"/>
+  </section>
   <section name="Viewer" >
     <!-- Viewer preferences -->
     <parameter name="background" value="bt=2;fn=;tm=0;ts=false;c1=#cddbff;c2=#698fff;gt=1;gr=" />
index 4342023ae4653ec085b1b1636606393714314c04..f95053cbdbb8ae9961f31c07d4303b22433c2432 100644 (file)
@@ -1067,6 +1067,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();
 }
 
index b1092af83136403d6777998c1cffde2e88b4909a..34b87d99a97e4603d1f51e05ce7e9634158eb341 100644 (file)
 #include <ModuleBase_Tools.h>
 #include <ModuleBase_WidgetSelector.h>
 
+#ifdef HAVE_SALOME
+#include <SUIT_Application.h>
+#include <SUIT_Session.h>
+#endif
+
 #include "XGUI_ActionsMgr.h"
 #include "XGUI_Displayer.h"
 #include "XGUI_ErrorMgr.h"
@@ -57,7 +62,6 @@
 #include "XGUI_OperationMgr.h"
 #include "XGUI_ModuleConnector.h"
 #include "XGUI_PropertyPanel.h"
-
 #include "XGUI_QtEvents.h"
 #include "XGUI_SalomeConnector.h"
 #include "XGUI_SelectionMgr.h"
@@ -373,6 +377,7 @@ void XGUI_WorkshopListener::
       }
     }
   }
+
   // this processing should be moved in another place in order to do not cause problems in
   // flush messages chain
   //if (aHiddenObjects.size() > 0)
@@ -392,6 +397,10 @@ void XGUI_WorkshopListener::
 void XGUI_WorkshopListener::
   onFeatureCreatedMsg(const std::shared_ptr<ModelAPI_ObjectUpdatedMessage>& theMsg)
 {
+  SUIT_Application * app = SUIT_Session::session()->activeApplication();
+
+  QVariant aVar = app->property("IsLoadedScript");
+
   std::set<ObjectPtr> anObjects = theMsg->objects();
   std::set<ObjectPtr>::const_iterator aIt;
 #ifdef DEBUG_FEATURE_CREATED
@@ -406,46 +415,32 @@ void XGUI_WorkshopListener::
 
   //bool aHasPart = false;
   bool aDisplayed = false;
-  for (aIt = anObjects.begin(); aIt != anObjects.end(); ++aIt) {
-    ObjectPtr anObject = *aIt;
+  if (aVar.isNull() || !aVar.toBool()) {
+    for (aIt = anObjects.begin(); aIt != anObjects.end(); ++aIt) {
+      ObjectPtr anObject = *aIt;
 
 #ifdef DEBUG_RESULT_COMPSOLID
-    ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(anObject);
-    if (aRes.get()) {
-      ResultCompSolidPtr aCompSolidRes = std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(aRes);
-      if (aCompSolidRes.get()) {
-          qDebug(QString("COMPSOLID, numberOfSubs = %1")
-            .arg(aCompSolidRes->numberOfSubs()).toStdString().c_str());
+      ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(anObject);
+      if (aRes.get()) {
+        ResultCompSolidPtr aCompSolidRes = std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(aRes);
+        if (aCompSolidRes.get()) {
+            qDebug(QString("COMPSOLID, numberOfSubs = %1")
+              .arg(aCompSolidRes->numberOfSubs()).toStdString().c_str());
+        }
+        if (ModelAPI_Tools::compSolidOwner(aRes))
+          qDebug("COMPSOLID sub-object");
       }
-      if (ModelAPI_Tools::compSolidOwner(aRes))
-        qDebug("COMPSOLID sub-object");
-    }
 #endif
-    // the validity of the data should be checked here in order to avoid display of the objects,
-    // which were created, then deleted, but flush for the creation event happens after that
-    // we should not display disabled objects
-    bool aHide = !anObject->data()->isValid() ||
-                 anObject->isDisabled() ||
-                 !anObject->isDisplayed();
-    if (!aHide) { // check that this is not hidden result
-      ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(anObject);
-      aHide = aRes && aRes->isConcealed();
-      // Hide the presentation with an empty shape. But isDisplayed state of the object should not
-      // be changed to the object becomes visible when the shape becomes not empty
-      if (!aHide && aRes.get())
-        aHide = !aRes->shape().get() || aRes->shape()->isNull();
-    }
-    if (!aHide) {
-      // setDisplayed has to be called in order to synchronize internal state of the object
-      // with list of displayed objects
-      if (myWorkshop->module()->canDisplayObject(anObject)) {
-        anObject->setDisplayed(true);
-        aDisplayed = displayObject(anObject);
-      } else
-        anObject->setDisplayed(false);
+
+      ResultBodyPtr aRes = std::dynamic_pointer_cast<ModelAPI_ResultBody>(anObject);
+
+      if (aRes.get() && aRes->numberOfSubs() > 0)
+        for (int anIndex = 0; anIndex < aRes->numberOfSubs(); ++anIndex)
+          setDisplayed(aRes->subResult(anIndex), aDisplayed);
+      else
+        setDisplayed(anObject, aDisplayed);
     }
   }
-
   MAYBE_UNUSED bool isCustomized = customizeFeature(anObjects, aDisplayed);
 
   //if (myObjectBrowser)
@@ -558,3 +553,32 @@ XGUI_Workshop* XGUI_WorkshopListener::workshop() const
 {
   return myWorkshop;
 }
+
+
+void XGUI_WorkshopListener::setDisplayed(ObjectPtr theObject, bool& theDisplayed)
+{
+  // the validity of the data should be checked here in order to avoid display of the objects,
+  // which were created, then deleted, but flush for the creation event happens after that
+  // we should not display disabled objects
+  bool aHide = !theObject->data()->isValid() ||
+                theObject->isDisabled() ||
+               !theObject->isDisplayed();
+  if (!aHide) { // check that this is not hidden result
+    ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
+    aHide = aRes && aRes->isConcealed();
+    // Hide the presentation with an empty shape. But isDisplayed state of the object should not
+    // be changed to the object becomes visible when the shape becomes not empty
+    if (!aHide && aRes.get())
+      aHide = !aRes->shape().get() || aRes->shape()->isNull();
+  }
+  if (!aHide) {
+    // setDisplayed has to be called in order to synchronize internal state of the object
+    // with list of displayed objects
+    if (myWorkshop->module()->canDisplayObject(theObject)) {
+      theObject->setDisplayed(true);
+      theDisplayed = displayObject(theObject);
+    }
+    else
+      theObject->setDisplayed(false);
+  }
+}
index d8827d57b05f9778d333547576b13afa3b0ff36f..dcedeb713f8ab6c12a8755e602547b7db090c0a8 100644 (file)
@@ -103,6 +103,9 @@ protected:
   XGUI_Workshop* workshop() const;
 
 private:
+
+  void setDisplayed(ObjectPtr theObject, bool& theDisplayed);
+
   XGUI_Workshop* myWorkshop; // the current workshop
 
   bool myUpdatePrefs;