]> OCCT Git - occt-copy.git/commitdiff
0030641: Visualization - possibility to select in predefined ZLayers only
authornds <nds@opencascade.com>
Tue, 9 Apr 2019 09:00:28 +0000 (12:00 +0300)
committernds <nds@opencascade.com>
Tue, 9 Apr 2019 09:05:44 +0000 (12:05 +0300)
(cherry picked from commit 6e940e66ffe4746f50d088289c0104a2724e89ea)

src/SelectMgr/SelectMgr_SelectableObjectSet.cxx
src/SelectMgr/SelectMgr_SelectableObjectSet.hxx
src/SelectMgr/SelectMgr_ViewerSelector.cxx
src/SelectMgr/SelectMgr_ViewerSelector.hxx

index 68c8060da943739f3c1aa9499297b27a8a9d6910..58aa8895d012aabee64ceb3bb7787501cc7552b4 100644 (file)
@@ -36,12 +36,16 @@ namespace
   public:
 
     //! Construct adaptor.
-    BVHBuilderAdaptorRegular (ObjectsMap& theObjects) : myObjects (theObjects) {};
+    BVHBuilderAdaptorRegular (ObjectsMap& theObjects, const NCollection_Map<Graphic3d_ZLayerId>& theDisabledZLayers)
+      : myObjects (theObjects), myDisabledZLayers (theDisabledZLayers) {};
 
     //! Returns bounding box of object with index theIndex
     virtual Select3D_BndBox3d Box (const Standard_Integer theIndex) const Standard_OVERRIDE
     {
       const Handle(SelectMgr_SelectableObject)& anObject = myObjects.FindKey (theIndex + 1);
+      if (!anObject.IsNull() && myDisabledZLayers.Contains (anObject->ZLayer()))
+        return Select3D_BndBox3d();
+
       Bnd_Box aBox;
       anObject->BoundingBox (aBox);
       if (aBox.IsVoid())
@@ -92,6 +96,7 @@ namespace
 
   private:
     ObjectsMap& myObjects;
+    NCollection_Map<Graphic3d_ZLayerId> myDisabledZLayers;
     mutable Select3D_BndBox3d myBox;
   };
 
@@ -111,17 +116,23 @@ namespace
     //!        theWidth, theHeight [in] view properties used for computation of
     //!        bounding boxes within the world view camera space.
     BVHBuilderAdaptorPersistent (ObjectsMap& theObjects,
+                                 const NCollection_Map<Graphic3d_ZLayerId>& theDisabledZLayers,
                                  const Handle(Graphic3d_Camera)& theCamera,
                                  const Graphic3d_Mat4d& theProjectionMat,
                                  const Graphic3d_Mat4d& theWorldViewMat,
                                  const Standard_Integer theWidth,
                                  const Standard_Integer theHeight)
-    : myObjects (theObjects)
+    : myObjects (theObjects), myDisabledZLayers (theDisabledZLayers)
     {
       myBoundings.ReSize (myObjects.Size());
       for (Standard_Integer anI = 1; anI <= myObjects.Size(); ++anI)
       {
         const Handle(SelectMgr_SelectableObject)& anObject = myObjects (anI);
+        if (!anObject.IsNull() && myDisabledZLayers.Contains (anObject->ZLayer()))
+        {
+          myBoundings.Add (new Select3D_HBndBox3d());
+          continue;
+        }
 
         Bnd_Box aBoundingBox;
         anObject->BoundingBox (aBoundingBox);
@@ -192,6 +203,7 @@ namespace
 
   private:
     ObjectsMap& myObjects;
+    NCollection_Map<Graphic3d_ZLayerId> myDisabledZLayers;
     mutable Select3D_BndBox3d myBox;
     typedef NCollection_Shared<Select3D_BndBox3d> Select3D_HBndBox3d;
     NCollection_IndexedMap<Handle(Select3D_HBndBox3d)> myBoundings;
@@ -324,7 +336,7 @@ void SelectMgr_SelectableObjectSet::UpdateBVH (const Handle(Graphic3d_Camera)& t
   if (!IsEmpty (BVHSubset_3d) && myIsDirty[BVHSubset_3d])
   {
     // construct adaptor over private fields to provide direct access for the BVH builder
-    BVHBuilderAdaptorRegular anAdaptor (myObjects[BVHSubset_3d]);
+    BVHBuilderAdaptorRegular anAdaptor (myObjects[BVHSubset_3d], myDisabledZLayers);
 
     // update corresponding BVH tree data structure
     myBuilder[BVHSubset_3d]->Build (&anAdaptor, myBVH[BVHSubset_3d].get(), anAdaptor.Box());
@@ -345,7 +357,7 @@ void SelectMgr_SelectableObjectSet::UpdateBVH (const Handle(Graphic3d_Camera)& t
          (myIsDirty[BVHSubset_3dPersistent] || myLastViewState.IsChanged (theViewState) || isWindowSizeChanged))
     {
       // construct adaptor over private fields to provide direct access for the BVH builder
-      BVHBuilderAdaptorPersistent anAdaptor (myObjects[BVHSubset_3dPersistent],
+      BVHBuilderAdaptorPersistent anAdaptor (myObjects[BVHSubset_3dPersistent], myDisabledZLayers,
         theCamera, theProjectionMat, theWorldViewMat, theViewportWidth, theViewportHeight);
 
       // update corresponding BVH tree data structure
@@ -359,7 +371,7 @@ void SelectMgr_SelectableObjectSet::UpdateBVH (const Handle(Graphic3d_Camera)& t
          (myIsDirty[BVHSubset_2dPersistent] || myLastViewState.IsProjectionChanged (theViewState) || isWindowSizeChanged))
     {
       // construct adaptor over private fields to provide direct access for the BVH builder
-      BVHBuilderAdaptorPersistent anAdaptor (myObjects[BVHSubset_2dPersistent],
+      BVHBuilderAdaptorPersistent anAdaptor (myObjects[BVHSubset_2dPersistent], myDisabledZLayers,
         theCamera, theProjectionMat, SelectMgr_SelectableObjectSet_THE_IDENTITY_MAT, theViewportWidth, theViewportHeight);
 
       // update corresponding BVH tree data structure
index 242abdc7e3950dd357ef86d55f7d5abeb526d778..8f40f6089bb8bdccb8d4124033fed9885097aa2d 100644 (file)
@@ -180,6 +180,10 @@ public:
     return myBVH[theSubset];
   }
 
+  //! Sets container of Z layers, that should not be processed by selection
+  void SetDisabledZLayers (const NCollection_Map<Graphic3d_ZLayerId>& theLayers)
+  { myDisabledZLayers = theLayers; }
+
 private:
 
   //! Returns an appropriate subset of theObject given depending on its persistence type.
@@ -215,6 +219,7 @@ private:
 private:
 
   NCollection_IndexedMap<Handle(SelectMgr_SelectableObject)> myObjects[BVHSubsetNb]; //!< Map of objects for each subset
+  NCollection_Map<Graphic3d_ZLayerId>                        myDisabledZLayers; //!< layers of not processed objects
   opencascade::handle<BVH_Tree<Standard_Real, 3> >           myBVH[BVHSubsetNb];     //!< BVH tree computed for each subset
   Handle(Select3D_BVHBuilder3d)                              myBuilder[BVHSubsetNb]; //!< Builder allocated for each subset
   Standard_Boolean                                           myIsDirty[BVHSubsetNb]; //!< Dirty flag for each subset
index 0476e7fd6bf45d5e4032780d020c298b774548ed..f6d0ea3df79c86e7018db94ea6f351f7d42132f0 100644 (file)
@@ -368,6 +368,9 @@ void SelectMgr_ViewerSelector::traverseObject (const Handle(SelectMgr_Selectable
                                                const Standard_Integer theViewportWidth,
                                                const Standard_Integer theViewportHeight)
 {
+  if (!theObject.IsNull() && myDisabledZLayers.Contains (theObject->ZLayer()))
+    return;
+
   Handle(SelectMgr_SensitiveEntitySet)& anEntitySet = myMapOfObjectSensitives.ChangeFind (theObject);
   if (anEntitySet->Size() == 0)
   {
@@ -1060,3 +1063,13 @@ void SelectMgr_ViewerSelector::AllowOverlapDetection (const Standard_Boolean the
 {
   mySelectingVolumeMgr.AllowOverlapDetection (theIsToAllow);
 }
+
+//=======================================================================
+//function : SetDisabledZLayers
+//purpose  : 
+//=======================================================================
+void SelectMgr_ViewerSelector::SetDisabledZLayers (const NCollection_Map<Graphic3d_ZLayerId>& theLayers)
+{
+  myDisabledZLayers = theLayers;
+  mySelectableObjects.SetDisabledZLayers (theLayers);
+}
index 953665ec8faf8a71da501e95a4a601a5ab0a440d..68f1bcf3fb27e3142ad2a49b5d400d1850f07015 100644 (file)
@@ -19,6 +19,7 @@
 
 #include <Standard_Transient.hxx>
 #include <NCollection_DataMap.hxx>
+#include <NCollection_Map.hxx>
 #include <OSD_Chronometer.hxx>
 #include <TColStd_SequenceOfInteger.hxx>
 #include <TColStd_HArray1OfInteger.hxx>
@@ -212,6 +213,9 @@ public:
   //! mark both included and overlapped entities as matched
   Standard_EXPORT void AllowOverlapDetection (const Standard_Boolean theIsToAllow);
 
+  //! Sets container of Z layers, that should not be processed by selection
+  Standard_EXPORT void SetDisabledZLayers (const NCollection_Map<Graphic3d_ZLayerId>& theLayers);
+
 public:
 
   //! Begins an iteration scanning for the owners detected at a position in the view.
@@ -348,6 +352,8 @@ protected:
   gp_Dir                                        myCameraDir;
   Standard_Real                                 myCameraScale;
 
+  NCollection_Map<Graphic3d_ZLayerId>           myDisabledZLayers;
+
 private:
 
   Handle(TColStd_HArray1OfInteger)             myIndexes;