mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-09-18 14:27:39 +03:00
0030641: Visualization - possibility to select in predefined ZLayers only
(cherry picked from commit 6e940e66ffe4746f50d088289c0104a2724e89ea)
This commit is contained in:
@@ -36,12 +36,16 @@ namespace
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
//! Construct adaptor.
|
//! 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
|
//! Returns bounding box of object with index theIndex
|
||||||
virtual Select3D_BndBox3d Box (const Standard_Integer theIndex) const Standard_OVERRIDE
|
virtual Select3D_BndBox3d Box (const Standard_Integer theIndex) const Standard_OVERRIDE
|
||||||
{
|
{
|
||||||
const Handle(SelectMgr_SelectableObject)& anObject = myObjects.FindKey (theIndex + 1);
|
const Handle(SelectMgr_SelectableObject)& anObject = myObjects.FindKey (theIndex + 1);
|
||||||
|
if (!anObject.IsNull() && myDisabledZLayers.Contains (anObject->ZLayer()))
|
||||||
|
return Select3D_BndBox3d();
|
||||||
|
|
||||||
Bnd_Box aBox;
|
Bnd_Box aBox;
|
||||||
anObject->BoundingBox (aBox);
|
anObject->BoundingBox (aBox);
|
||||||
if (aBox.IsVoid())
|
if (aBox.IsVoid())
|
||||||
@@ -92,6 +96,7 @@ namespace
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
ObjectsMap& myObjects;
|
ObjectsMap& myObjects;
|
||||||
|
NCollection_Map<Graphic3d_ZLayerId> myDisabledZLayers;
|
||||||
mutable Select3D_BndBox3d myBox;
|
mutable Select3D_BndBox3d myBox;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -111,17 +116,23 @@ namespace
|
|||||||
//! theWidth, theHeight [in] view properties used for computation of
|
//! theWidth, theHeight [in] view properties used for computation of
|
||||||
//! bounding boxes within the world view camera space.
|
//! bounding boxes within the world view camera space.
|
||||||
BVHBuilderAdaptorPersistent (ObjectsMap& theObjects,
|
BVHBuilderAdaptorPersistent (ObjectsMap& theObjects,
|
||||||
|
const NCollection_Map<Graphic3d_ZLayerId>& theDisabledZLayers,
|
||||||
const Handle(Graphic3d_Camera)& theCamera,
|
const Handle(Graphic3d_Camera)& theCamera,
|
||||||
const Graphic3d_Mat4d& theProjectionMat,
|
const Graphic3d_Mat4d& theProjectionMat,
|
||||||
const Graphic3d_Mat4d& theWorldViewMat,
|
const Graphic3d_Mat4d& theWorldViewMat,
|
||||||
const Standard_Integer theWidth,
|
const Standard_Integer theWidth,
|
||||||
const Standard_Integer theHeight)
|
const Standard_Integer theHeight)
|
||||||
: myObjects (theObjects)
|
: myObjects (theObjects), myDisabledZLayers (theDisabledZLayers)
|
||||||
{
|
{
|
||||||
myBoundings.ReSize (myObjects.Size());
|
myBoundings.ReSize (myObjects.Size());
|
||||||
for (Standard_Integer anI = 1; anI <= myObjects.Size(); ++anI)
|
for (Standard_Integer anI = 1; anI <= myObjects.Size(); ++anI)
|
||||||
{
|
{
|
||||||
const Handle(SelectMgr_SelectableObject)& anObject = myObjects (anI);
|
const Handle(SelectMgr_SelectableObject)& anObject = myObjects (anI);
|
||||||
|
if (!anObject.IsNull() && myDisabledZLayers.Contains (anObject->ZLayer()))
|
||||||
|
{
|
||||||
|
myBoundings.Add (new Select3D_HBndBox3d());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
Bnd_Box aBoundingBox;
|
Bnd_Box aBoundingBox;
|
||||||
anObject->BoundingBox (aBoundingBox);
|
anObject->BoundingBox (aBoundingBox);
|
||||||
@@ -192,6 +203,7 @@ namespace
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
ObjectsMap& myObjects;
|
ObjectsMap& myObjects;
|
||||||
|
NCollection_Map<Graphic3d_ZLayerId> myDisabledZLayers;
|
||||||
mutable Select3D_BndBox3d myBox;
|
mutable Select3D_BndBox3d myBox;
|
||||||
typedef NCollection_Shared<Select3D_BndBox3d> Select3D_HBndBox3d;
|
typedef NCollection_Shared<Select3D_BndBox3d> Select3D_HBndBox3d;
|
||||||
NCollection_IndexedMap<Handle(Select3D_HBndBox3d)> myBoundings;
|
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])
|
if (!IsEmpty (BVHSubset_3d) && myIsDirty[BVHSubset_3d])
|
||||||
{
|
{
|
||||||
// construct adaptor over private fields to provide direct access for the BVH builder
|
// 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
|
// update corresponding BVH tree data structure
|
||||||
myBuilder[BVHSubset_3d]->Build (&anAdaptor, myBVH[BVHSubset_3d].get(), anAdaptor.Box());
|
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))
|
(myIsDirty[BVHSubset_3dPersistent] || myLastViewState.IsChanged (theViewState) || isWindowSizeChanged))
|
||||||
{
|
{
|
||||||
// construct adaptor over private fields to provide direct access for the BVH builder
|
// 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);
|
theCamera, theProjectionMat, theWorldViewMat, theViewportWidth, theViewportHeight);
|
||||||
|
|
||||||
// update corresponding BVH tree data structure
|
// 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))
|
(myIsDirty[BVHSubset_2dPersistent] || myLastViewState.IsProjectionChanged (theViewState) || isWindowSizeChanged))
|
||||||
{
|
{
|
||||||
// construct adaptor over private fields to provide direct access for the BVH builder
|
// 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);
|
theCamera, theProjectionMat, SelectMgr_SelectableObjectSet_THE_IDENTITY_MAT, theViewportWidth, theViewportHeight);
|
||||||
|
|
||||||
// update corresponding BVH tree data structure
|
// update corresponding BVH tree data structure
|
||||||
|
@@ -180,6 +180,10 @@ public:
|
|||||||
return myBVH[theSubset];
|
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:
|
private:
|
||||||
|
|
||||||
//! Returns an appropriate subset of theObject given depending on its persistence type.
|
//! Returns an appropriate subset of theObject given depending on its persistence type.
|
||||||
@@ -215,6 +219,7 @@ private:
|
|||||||
private:
|
private:
|
||||||
|
|
||||||
NCollection_IndexedMap<Handle(SelectMgr_SelectableObject)> myObjects[BVHSubsetNb]; //!< Map of objects for each subset
|
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
|
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
|
Handle(Select3D_BVHBuilder3d) myBuilder[BVHSubsetNb]; //!< Builder allocated for each subset
|
||||||
Standard_Boolean myIsDirty[BVHSubsetNb]; //!< Dirty flag for each subset
|
Standard_Boolean myIsDirty[BVHSubsetNb]; //!< Dirty flag for each subset
|
||||||
|
@@ -368,6 +368,9 @@ void SelectMgr_ViewerSelector::traverseObject (const Handle(SelectMgr_Selectable
|
|||||||
const Standard_Integer theViewportWidth,
|
const Standard_Integer theViewportWidth,
|
||||||
const Standard_Integer theViewportHeight)
|
const Standard_Integer theViewportHeight)
|
||||||
{
|
{
|
||||||
|
if (!theObject.IsNull() && myDisabledZLayers.Contains (theObject->ZLayer()))
|
||||||
|
return;
|
||||||
|
|
||||||
Handle(SelectMgr_SensitiveEntitySet)& anEntitySet = myMapOfObjectSensitives.ChangeFind (theObject);
|
Handle(SelectMgr_SensitiveEntitySet)& anEntitySet = myMapOfObjectSensitives.ChangeFind (theObject);
|
||||||
if (anEntitySet->Size() == 0)
|
if (anEntitySet->Size() == 0)
|
||||||
{
|
{
|
||||||
@@ -1060,3 +1063,13 @@ void SelectMgr_ViewerSelector::AllowOverlapDetection (const Standard_Boolean the
|
|||||||
{
|
{
|
||||||
mySelectingVolumeMgr.AllowOverlapDetection (theIsToAllow);
|
mySelectingVolumeMgr.AllowOverlapDetection (theIsToAllow);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : SetDisabledZLayers
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void SelectMgr_ViewerSelector::SetDisabledZLayers (const NCollection_Map<Graphic3d_ZLayerId>& theLayers)
|
||||||
|
{
|
||||||
|
myDisabledZLayers = theLayers;
|
||||||
|
mySelectableObjects.SetDisabledZLayers (theLayers);
|
||||||
|
}
|
||||||
|
@@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#include <Standard_Transient.hxx>
|
#include <Standard_Transient.hxx>
|
||||||
#include <NCollection_DataMap.hxx>
|
#include <NCollection_DataMap.hxx>
|
||||||
|
#include <NCollection_Map.hxx>
|
||||||
#include <OSD_Chronometer.hxx>
|
#include <OSD_Chronometer.hxx>
|
||||||
#include <TColStd_SequenceOfInteger.hxx>
|
#include <TColStd_SequenceOfInteger.hxx>
|
||||||
#include <TColStd_HArray1OfInteger.hxx>
|
#include <TColStd_HArray1OfInteger.hxx>
|
||||||
@@ -212,6 +213,9 @@ public:
|
|||||||
//! mark both included and overlapped entities as matched
|
//! mark both included and overlapped entities as matched
|
||||||
Standard_EXPORT void AllowOverlapDetection (const Standard_Boolean theIsToAllow);
|
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:
|
public:
|
||||||
|
|
||||||
//! Begins an iteration scanning for the owners detected at a position in the view.
|
//! Begins an iteration scanning for the owners detected at a position in the view.
|
||||||
@@ -348,6 +352,8 @@ protected:
|
|||||||
gp_Dir myCameraDir;
|
gp_Dir myCameraDir;
|
||||||
Standard_Real myCameraScale;
|
Standard_Real myCameraScale;
|
||||||
|
|
||||||
|
NCollection_Map<Graphic3d_ZLayerId> myDisabledZLayers;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
Handle(TColStd_HArray1OfInteger) myIndexes;
|
Handle(TColStd_HArray1OfInteger) myIndexes;
|
||||||
|
Reference in New Issue
Block a user