Salome HOME
Issue #2355 hide all faces then show solid problem
authornds <nds@opencascade.com>
Thu, 14 Dec 2017 14:34:00 +0000 (17:34 +0300)
committernds <nds@opencascade.com>
Thu, 14 Dec 2017 14:34:32 +0000 (17:34 +0300)
src/XGUI/XGUI_DataModel.cpp
src/XGUI/XGUI_DataModel.h
src/XGUI/XGUI_FacesPanel.cpp
src/XGUI/XGUI_FacesPanel.h
src/XGUI/XGUI_ObjectsBrowser.cpp
src/XGUI/XGUI_Workshop.cpp

index d428a2c501986816457ec569efff57f10207b880..baf49e20b1b0b40ee3618ac2cb2208b12a1795d1 100644 (file)
@@ -1059,6 +1059,12 @@ QModelIndex XGUI_DataModel::lastHistoryIndex() const
   }
 }
 
+//******************************************************
+bool XGUI_DataModel::hasHiddenState(const QModelIndex& theIndex)
+{
+  return getVisibilityState(theIndex) == Hidden;
+}
+
 //******************************************************
 int XGUI_DataModel::folderId(std::string theType, ModelAPI_Document* theDoc) const
 {
index d20679f7983742f681b4309247321b1331292581..e89546161dda5a6b3a564dcc0fe37741a607a222 100644 (file)
@@ -142,6 +142,11 @@ public:
   /// Do not processing anymore events of model loop
   //bool blockEventsProcessing(const bool theState);
 
+  /// Returns true if the data model item has Hidden visual state
+  /// \param theIndex a tree model item
+  /// \return boolean value
+  bool hasHiddenState(const QModelIndex& theIndex);
+
 signals:
   /// Signal about tree had been rebuilt
   void treeRebuilt();
index a5deb6d141f7e770726b51f39028c4d9c9f5576f..a815c49ec9632cfb4e820515c131ceaa8ed1d9f6 100644 (file)
@@ -96,6 +96,12 @@ void XGUI_FacesPanel::reset(const bool isToFlushRedisplay)
   myLastItemIndex = 0; // it should be after redisplay as flag used in customize
 }
 
+//********************************************************************
+bool XGUI_FacesPanel::isEmpty() const
+{
+  return myItems.size() == 0;
+}
+
 //********************************************************************
 void XGUI_FacesPanel::selectionModes(QIntList& theModes)
 {
index fdb08cc51e777211a7394813c4509d8f3861f142..ad98a4e5526223ded060c44987cc3d443838295b 100644 (file)
@@ -77,6 +77,10 @@ public:
   /// \param isToFlushRedisplay flag if redisplay should be flushed immediatelly
   virtual void reset(const bool isToFlushRedisplay);
 
+  /// Returns whether faces panel contains elements
+  /// \return boolean value
+  bool isEmpty() const;
+
   /// Fills container with the panel selection mode: FACE
   // \param theModes [out] a container of modes
   void selectionModes(QIntList& theModes);
index 983f4c37ea1d035a2624fd5e982d4a9ca27883a2..f3f53962692511480fff8747ed96435ad7370815 100644 (file)
@@ -25,6 +25,7 @@
 #include <ModelAPI_Data.h>
 #include <ModelAPI_Session.h>
 #include <ModelAPI_Document.h>
+#include <ModelAPI_ResultCompSolid.h>
 #include <ModelAPI_Tools.h>
 
 #include <ModuleBase_Tools.h>
@@ -239,10 +240,14 @@ void XGUI_DataTree::processEyeClick(const QModelIndex& theIndex)
     if (aResObj.get()) {
       std::set<ObjectPtr> anObjects;
       anObjects.insert(aResObj);
-      if (aObjBrowser && !aResObj->isDisplayed() &&
-          !aObjBrowser->workshop()->prepareForDisplay(anObjects))
+
+      bool hasHiddenState = aModel->hasHiddenState(theIndex);
+      if (aObjBrowser && hasHiddenState && !aObjBrowser->workshop()->prepareForDisplay(anObjects))
         return;
-      aResObj->setDisplayed(!aResObj->isDisplayed());
+      if (hasHiddenState) // #issue 2335(hide all faces then show solid problem)
+        aResObj->setDisplayed(true);
+      else
+        aResObj->setDisplayed(!aResObj->isDisplayed());
       Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
       update(theIndex);
     }
index 7e9b3a97adead0b5db088a488a12e0a965ffc7b8..94dce62bb9a75bbc8db01977526fc1fffaac9d09 100755 (executable)
@@ -1595,6 +1595,9 @@ void XGUI_Workshop::activateObjectsSelection(const QObjectPtrList& theList)
 //**************************************************************
 bool XGUI_Workshop::prepareForDisplay(const std::set<ObjectPtr>& theObjects) const
 {
+  if (facesPanel()->isEmpty())
+    return true;
+
   // generate container of objects taking into account sub elments of compsolid
   std::set<ObjectPtr> anAllProcessedObjects;
   for (std::set<ObjectPtr>::const_iterator anObjectsIt = theObjects.begin();
@@ -1625,7 +1628,7 @@ bool XGUI_Workshop::prepareForDisplay(const std::set<ObjectPtr>& theObjects) con
     aHiddenObjects.insert(*anObjectsIt);
     aHiddenObjectNames.append((*anObjectsIt)->data()->name().c_str());
   }
-  if (aHiddenObjects.empty())
+  if (aHiddenObjects.empty()) // in parameter objects there are no hidden objects in hide face
     return true;
 
   int anAnswer = QMessageBox::question(