Salome HOME
#2309 Possibility to hide faces
authornds <nds@opencascade.com>
Wed, 17 Jan 2018 04:54:38 +0000 (07:54 +0300)
committernds <nds@opencascade.com>
Wed, 17 Jan 2018 04:54:38 +0000 (07:54 +0300)
src/ModuleBase/ModuleBase_ResultPrs.cpp
src/ModuleBase/ModuleBase_ResultPrs.h
src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp

index 6dd875f779274996ee88f9b2b3a478d38e76de77..8d2aeb755980b982d440247f7b46082e4e69b6e6 100755 (executable)
@@ -139,6 +139,26 @@ bool ModuleBase_ResultPrs::setSubShapeHidden(const NCollection_List<TopoDS_Shape
   return isModified;
 }
 
+//********************************************************************
+bool ModuleBase_ResultPrs::isSubShapeHidden(const TopoDS_Shape& theShape)
+{
+  if (theShape.IsNull() || theShape.ShapeType() != TopAbs_FACE) // only face shape can be hidden
+    return false;
+
+  if (myHiddenSubShapes.Contains(theShape))
+    return true;
+
+  // orientation of parameter shape(come from selection) may be wrong, check isEqual() to be sure
+  for (NCollection_List<TopoDS_Shape>::Iterator aShapeIt(myHiddenSubShapes); aShapeIt.More();
+    aShapeIt.Next())
+  {
+    if (theShape.IsEqual(aShapeIt.Value()))
+      return true;
+  }
+
+  return true;
+}
+
 //********************************************************************
 bool ModuleBase_ResultPrs::hasSubShapeVisible(
   const NCollection_List<TopoDS_Shape>& theShapesToSkip)
index f3c42bc9e43a007c9c16131cba51b3a8846e9b49..0a1f999b7787b9321a9bebc30d836e9725281ff4 100644 (file)
@@ -93,6 +93,11 @@ public:
   /// \returns true if the presentation is changed, or false (if for example it was hidden)
   Standard_EXPORT bool setSubShapeHidden(const NCollection_List<TopoDS_Shape>& theShapes);
 
+  /// Returns true if parameter shape has been hidden
+  /// \param theShape sub-shape of the presentation shape
+  /// \return boolean value
+  Standard_EXPORT bool isSubShapeHidden(const TopoDS_Shape& theShape);
+
   /// Returns true if there are no hidden sub shapes or original shape has at least one not hidden
   /// \param theShapesToSkip container of shape to be hidden in the presentation (faces)
   /// \return boolean value
index 17c9f5b6c94cb92d17218805d0a6d6e666043b5b..55eaf59eb0c4d80b801ffa34f05a53111d869bed 100755 (executable)
@@ -20,6 +20,8 @@
 
 #include <ModuleBase_WidgetMultiSelector.h>
 
+#include <GeomAPI_AISObject.h>
+
 #include <ModuleBase_ActionIntParameter.h>
 #include <ModuleBase_Definitions.h>
 #include <ModuleBase_Events.h>
@@ -31,6 +33,7 @@
 #include <ModuleBase_IViewer.h>
 #include <ModuleBase_IWorkshop.h>
 #include <ModuleBase_ListView.h>
+#include <ModuleBase_ResultPrs.h>
 #include <ModuleBase_Tools.h>
 #include <ModuleBase_ViewerPrs.h>
 #include <ModuleBase_WidgetShapeSelector.h>
@@ -46,6 +49,8 @@
 
 #include <Config_WidgetAPI.h>
 
+#include <AIS_InteractiveObject.hxx>
+
 #include <QGridLayout>
 #include <QLabel>
 #include <QListWidget>
@@ -924,12 +929,13 @@ bool ModuleBase_WidgetMultiSelector::findInSelection(const ObjectPtr& theObject,
     return true;
 
   bool aFound = false;
-  GeomShapePtr anEmptyShape(new GeomAPI_Shape());
   if (theShape.get()) { // treat shape equal to context as null: 2219, keep order of shapes in list
     const ResultPtr aContext = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
     if (aContext.get() && aContext->shape()->isEqual(theShape))
       theShape.reset();
   }
+
+  GeomShapePtr anEmptyShape(new GeomAPI_Shape());
   GeomShapePtr aShape = theShape.get() ? theShape : anEmptyShape;
   if (theGeomSelection.find(theObject) != theGeomSelection.end()) {// found
     const std::set<GeomShapePtr>& aShapes = theGeomSelection.at(theObject);
@@ -940,6 +946,19 @@ bool ModuleBase_WidgetMultiSelector::findInSelection(const ObjectPtr& theObject,
         aFound = aCShape->isSame(aShape);
     }
   }
+
+  // issue #2903: (Possibility to hide faces) - check whether given shape is a hidden sub-shape
+  if (!aFound && theWorkshop->hasSHIFTPressed() && theObject->isDisplayed()) {
+    AISObjectPtr anAIS = theWorkshop->findPresentation(theObject);
+    if (anAIS.get() != NULL) {
+      Handle(AIS_InteractiveObject) anAISIO = anAIS->impl<Handle(AIS_InteractiveObject)>();
+
+      Handle(ModuleBase_ResultPrs) aResultPrs = Handle(ModuleBase_ResultPrs)::DownCast(anAISIO);
+      if (!aResultPrs.IsNull() && aResultPrs->isSubShapeHidden(theShape->impl<TopoDS_Shape>()))
+        return true;
+    }
+  }
+
   return aFound;
 }