]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Hide faces: checking presentation on having any shapes using a whole container of...
authornds <nds@opencascade.com>
Thu, 14 Dec 2017 13:39:43 +0000 (16:39 +0300)
committernds <nds@opencascade.com>
Thu, 14 Dec 2017 13:39:43 +0000 (16:39 +0300)
src/ModuleBase/ModuleBase_ResultPrs.cpp
src/ModuleBase/ModuleBase_ResultPrs.h
src/XGUI/XGUI_FacesPanel.cpp
src/XGUI/XGUI_Workshop.cpp

index 33708cb51f16de8a56b586912d07040e9e63a297..c1ce983e0ff76b86cec30a7a340ff2e678cef265 100755 (executable)
@@ -140,21 +140,13 @@ bool ModuleBase_ResultPrs::setSubShapeHidden(const NCollection_List<TopoDS_Shape
 }
 
 //********************************************************************
-bool ModuleBase_ResultPrs::hasSubShapeVisible(const TopoDS_Shape& theShape)
+bool ModuleBase_ResultPrs::hasSubShapeVisible(
+  const NCollection_List<TopoDS_Shape>& theShapesToSkip)
 {
-  int aNbOfHiddenSubShapes = myHiddenSubShapes.Size();
-
-  if (!myHiddenSubShapes.Contains(theShape))
-    aNbOfHiddenSubShapes++; // the shape to be hidden later
-
-  //const TopoDS_Shape aCurrentShape = Shape();
-  NCollection_List<TopoDS_Shape> aHiddenSubShapes = myHiddenSubShapes;
-  aHiddenSubShapes.Append(theShape);
-
   TopoDS_Compound aCompound;
   BRep_Builder aBuilder;
   aBuilder.MakeCompound (aCompound);
-  collectSubShapes(aBuilder, aCompound, myOriginalShape, aHiddenSubShapes);
+  collectSubShapes(aBuilder, aCompound, myOriginalShape, theShapesToSkip);
   return !BOPTools_AlgoTools3D::IsEmptyShape(aCompound);
 }
 
index 3fb1e1906b2e3a8fde1645e035e1068caed99301..f3c42bc9e43a007c9c16131cba51b3a8846e9b49 100644 (file)
@@ -94,9 +94,9 @@ public:
   Standard_EXPORT bool setSubShapeHidden(const NCollection_List<TopoDS_Shape>& theShapes);
 
   /// Returns true if there are no hidden sub shapes or original shape has at least one not hidden
-  /// \param theShapeToSkip the shape should be interpreted as additional hidden in the presentation
+  /// \param theShapesToSkip container of shape to be hidden in the presentation (faces)
   /// \return boolean value
-  Standard_EXPORT bool hasSubShapeVisible(const TopoDS_Shape& theShapeToSkip);
+  Standard_EXPORT bool hasSubShapeVisible(const NCollection_List<TopoDS_Shape>& theShapesToSkip);
 
   /// Set transparency of hidden sub shapes: if value is 1, shapes are entirely hidden
   /// \param theTransparency transparency value
index dcdeaa5972c62cb9009fb17e64b14d8a21e383bf..c3ab2ec0b096d65e5088c121624f2a552c7b32bc 100644 (file)
@@ -210,6 +210,9 @@ void XGUI_FacesPanel::processSelection()
                                                        ModuleBase_ISelection::Viewer);
   bool isModified = false;
   static Events_ID aDispEvent = Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY);
+
+  std::map<ObjectPtr, NCollection_List<TopoDS_Shape> > anObjectToShapes;
+  std::map<ObjectPtr, Handle(ModuleBase_ResultPrs) > anObjectToPrs;
   for (int i = 0; i < aSelected.size(); i++) {
     ModuleBase_ViewerPrsPtr aPrs = aSelected[i];
     ObjectPtr anObject = aPrs->object();
@@ -228,8 +231,23 @@ void XGUI_FacesPanel::processSelection()
     myLastItemIndex++;
     isModified = true;
 
-    if (aResultPrs->hasSubShapeVisible(ModuleBase_Tools::getSelectedShape(aPrs)) ||
-        useTransparency()) // redisplay
+    if (anObjectToShapes.find(anObject) != anObjectToShapes.end())
+      anObjectToShapes.at(anObject).Append(ModuleBase_Tools::getSelectedShape(aPrs));
+    else {
+      NCollection_List<TopoDS_Shape> aListOfShapes;
+      aListOfShapes.Append(ModuleBase_Tools::getSelectedShape(aPrs));
+      anObjectToShapes[anObject] = aListOfShapes;
+      anObjectToPrs[anObject] = aResultPrs;
+    }
+  }
+  for (std::map<ObjectPtr, NCollection_List<TopoDS_Shape> >::const_iterator anIt = anObjectToShapes.begin();
+    anIt != anObjectToShapes.end(); anIt++) {
+    ObjectPtr anObject = anIt->first;
+    if (!anObject.get() || anObjectToPrs.find(anObject) == anObjectToPrs.end())
+      continue;
+    Handle(ModuleBase_ResultPrs) aResultPrs = anObjectToPrs.at(anObject);
+
+    if (aResultPrs->hasSubShapeVisible(anIt->second) || useTransparency()) // redisplay
       ModelAPI_EventCreator::get()->sendUpdated(anObject, aDispEvent);
     else { // erase object because it is entirely hidden
       anObject->setDisplayed(false);
@@ -341,6 +359,9 @@ bool XGUI_FacesPanel::hideEmptyObjects()
 {
   bool isModified = false;
   static Events_ID aDispEvent = Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY);
+  std::map<ObjectPtr, NCollection_List<TopoDS_Shape> > anObjectToShapes;
+  std::map<ObjectPtr, Handle(ModuleBase_ResultPrs) > anObjectToPrs;
+
   for (QMap<int, ModuleBase_ViewerPrsPtr>::const_iterator anIt = myItems.begin();
        anIt != myItems.end(); anIt++) {
     ModuleBase_ViewerPrsPtr aPrs = anIt.value();
@@ -353,7 +374,23 @@ bool XGUI_FacesPanel::hideEmptyObjects()
     if (aResultPrs.IsNull())
       continue;
 
-    if (!aResultPrs->hasSubShapeVisible(ModuleBase_Tools::getSelectedShape(aPrs))) {
+    if (anObjectToShapes.find(anObject) != anObjectToShapes.end())
+      anObjectToShapes.at(anObject).Append(ModuleBase_Tools::getSelectedShape(aPrs));
+    else {
+      NCollection_List<TopoDS_Shape> aListOfShapes;
+      aListOfShapes.Append(ModuleBase_Tools::getSelectedShape(aPrs));
+      anObjectToShapes[anObject] = aListOfShapes;
+      anObjectToPrs[anObject] = aResultPrs;
+    }
+  }
+  for (std::map<ObjectPtr, NCollection_List<TopoDS_Shape> >::const_iterator anIt = anObjectToShapes.begin();
+    anIt != anObjectToShapes.end(); anIt++) {
+    ObjectPtr anObject = anIt->first;
+    if (!anObject.get() || anObjectToPrs.find(anObject) == anObjectToPrs.end())
+      continue;
+    Handle(ModuleBase_ResultPrs) aResultPrs = anObjectToPrs.at(anObject);
+
+    if (!aResultPrs->hasSubShapeVisible(anIt->second)) {
       // erase object because it is entirely hidden
       anObject->setDisplayed(false);
       myHiddenObjects.insert(anObject);
index 89c21c6cfe26ddbed9b829863cef65b342147768..7e9b3a97adead0b5db088a488a12e0a965ffc7b8 100755 (executable)
@@ -1631,8 +1631,8 @@ bool XGUI_Workshop::prepareForDisplay(const std::set<ObjectPtr>& theObjects) con
   int anAnswer = QMessageBox::question(
         desktop(), tr("Show object"),
         tr("'%1'\n are hidden by %2:\nRemove objects from the panel to be displayed?")
-        .arg(aHiddenObjectNames.join(',')).arg(facesPanel()->windowTitle(),
-        QMessageBox::Yes | QMessageBox::No, QMessageBox::No));
+        .arg(aHiddenObjectNames.join(',')).arg(facesPanel()->windowTitle()),
+        QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
 
   bool aToBeDisplayed = anAnswer == QMessageBox::Yes;
   if (aToBeDisplayed)