From: nds Date: Tue, 9 Apr 2019 09:00:28 +0000 (+0300) Subject: 0030641: Visualization - possibility to select in predefined ZLayers only X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=d1cf356f84555e1b217a0658a1ddca58eab4ee51;p=occt-copy.git 0030641: Visualization - possibility to select in predefined ZLayers only (cherry picked from commit 6e940e66ffe4746f50d088289c0104a2724e89ea) --- diff --git a/src/SelectMgr/SelectMgr_SelectableObjectSet.cxx b/src/SelectMgr/SelectMgr_SelectableObjectSet.cxx index 68c8060da9..58aa8895d0 100644 --- a/src/SelectMgr/SelectMgr_SelectableObjectSet.cxx +++ b/src/SelectMgr/SelectMgr_SelectableObjectSet.cxx @@ -36,12 +36,16 @@ namespace public: //! Construct adaptor. - BVHBuilderAdaptorRegular (ObjectsMap& theObjects) : myObjects (theObjects) {}; + BVHBuilderAdaptorRegular (ObjectsMap& theObjects, const NCollection_Map& 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 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& 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 myDisabledZLayers; mutable Select3D_BndBox3d myBox; typedef NCollection_Shared Select3D_HBndBox3d; NCollection_IndexedMap 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 diff --git a/src/SelectMgr/SelectMgr_SelectableObjectSet.hxx b/src/SelectMgr/SelectMgr_SelectableObjectSet.hxx index 242abdc7e3..8f40f6089b 100644 --- a/src/SelectMgr/SelectMgr_SelectableObjectSet.hxx +++ b/src/SelectMgr/SelectMgr_SelectableObjectSet.hxx @@ -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& theLayers) + { myDisabledZLayers = theLayers; } + private: //! Returns an appropriate subset of theObject given depending on its persistence type. @@ -215,6 +219,7 @@ private: private: NCollection_IndexedMap myObjects[BVHSubsetNb]; //!< Map of objects for each subset + NCollection_Map myDisabledZLayers; //!< layers of not processed objects opencascade::handle > 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 diff --git a/src/SelectMgr/SelectMgr_ViewerSelector.cxx b/src/SelectMgr/SelectMgr_ViewerSelector.cxx index 0476e7fd6b..f6d0ea3df7 100644 --- a/src/SelectMgr/SelectMgr_ViewerSelector.cxx +++ b/src/SelectMgr/SelectMgr_ViewerSelector.cxx @@ -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& theLayers) +{ + myDisabledZLayers = theLayers; + mySelectableObjects.SetDisabledZLayers (theLayers); +} diff --git a/src/SelectMgr/SelectMgr_ViewerSelector.hxx b/src/SelectMgr/SelectMgr_ViewerSelector.hxx index 953665ec8f..68f1bcf3fb 100644 --- a/src/SelectMgr/SelectMgr_ViewerSelector.hxx +++ b/src/SelectMgr/SelectMgr_ViewerSelector.hxx @@ -19,6 +19,7 @@ #include #include +#include #include #include #include @@ -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& 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 myDisabledZLayers; + private: Handle(TColStd_HArray1OfInteger) myIndexes;