1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

0027797: Visualization - consider ZLayer properties while sorting list of picked entities

OpenGl_GraphicDriver::ZLayers() / V3d_Viewer::GetAllZLayers() now return
the layers sequence following rendering order (taking into account IsImmediate flag).

StdSelect_ViewerSelector3d::Pick() now sort result taking into account ZLayers flags.
This commit is contained in:
kgv
2016-08-23 17:26:22 +03:00
committed by bugmaster
parent 94afca11a0
commit 1593b4eeab
11 changed files with 252 additions and 222 deletions

View File

@@ -113,6 +113,7 @@ void StdSelect_ViewerSelector3d::Pick (const Standard_Integer theXPix,
const Standard_Integer theYPix,
const Handle(V3d_View)& theView)
{
updateZLayers (theView);
if(myToUpdateTolerance)
{
mySelectingVolumeMgr.SetPixelTolerance (myTolerances.Tolerance());
@@ -142,6 +143,7 @@ void StdSelect_ViewerSelector3d::Pick (const Standard_Integer theXPMin,
const Standard_Integer theYPMax,
const Handle(V3d_View)& theView)
{
updateZLayers (theView);
mySelectingVolumeMgr.SetCamera (theView->Camera());
mySelectingVolumeMgr.SetActiveSelectionType (SelectMgr_SelectingVolumeManager::Box);
Standard_Integer aWidth = 0, aHeight = 0;
@@ -164,6 +166,7 @@ void StdSelect_ViewerSelector3d::Pick (const Standard_Integer theXPMin,
void StdSelect_ViewerSelector3d::Pick (const TColgp_Array1OfPnt2d& thePolyline,
const Handle(V3d_View)& theView)
{
updateZLayers (theView);
mySelectingVolumeMgr.SetCamera (theView->Camera());
mySelectingVolumeMgr.SetActiveSelectionType (SelectMgr_SelectingVolumeManager::Polyline);
Standard_Integer aWidth = 0, aHeight = 0;
@@ -190,7 +193,7 @@ void StdSelect_ViewerSelector3d::DisplaySensitive (const Handle(V3d_View)& theVi
{
if (anObj->CurrentSelection()->GetSelectionState() == SelectMgr_SOS_Activated)
{
ComputeSensitivePrs (aStruct, anObj->CurrentSelection(), anObj->Transformation(), Graphic3d_TransformPers());
computeSensitivePrs (aStruct, anObj->CurrentSelection(), anObj->Transformation(), Graphic3d_TransformPers());
}
}
@@ -212,7 +215,7 @@ void StdSelect_ViewerSelector3d::DisplaySensitive (const Handle(V3d_View)& theVi
{
if (anObj->CurrentSelection()->GetSelectionState() == SelectMgr_SOS_Activated)
{
ComputeSensitivePrs (aStruct, anObj->CurrentSelection(), anObj->Transformation(), anObj->TransformPersistence());
computeSensitivePrs (aStruct, anObj->CurrentSelection(), anObj->Transformation(), anObj->TransformPersistence());
}
}
@@ -264,7 +267,7 @@ void StdSelect_ViewerSelector3d::DisplaySensitive (const Handle(SelectMgr_Select
Handle(Graphic3d_Structure) aStruct = new Graphic3d_Structure (theView->Viewer()->StructureManager());
ComputeSensitivePrs (aStruct, theSel, theTrsf, Graphic3d_TransformPers());
computeSensitivePrs (aStruct, theSel, theTrsf, Graphic3d_TransformPers());
myStructs.Append (aStruct);
myStructs.Last()->SetDisplayPriority (10);
@@ -274,10 +277,10 @@ void StdSelect_ViewerSelector3d::DisplaySensitive (const Handle(SelectMgr_Select
}
//=======================================================================
//function : ComputeSensitivePrs
//function : computeSensitivePrs
//purpose :
//=======================================================================
void StdSelect_ViewerSelector3d::ComputeSensitivePrs (const Handle(Graphic3d_Structure)& theStructure,
void StdSelect_ViewerSelector3d::computeSensitivePrs (const Handle(Graphic3d_Structure)& theStructure,
const Handle(SelectMgr_Selection)& theSel,
const gp_Trsf& theLoc,
const Graphic3d_TransformPers& theTransPers)
@@ -663,3 +666,27 @@ Standard_Boolean StdSelect_ViewerSelector3d::HasDepthClipping (const Handle(Sele
const Handle(SelectMgr_SelectableObject)& aSelectable = theOwner->Selectable();
return (aSelectable->GetClipPlanes().Size() > 0);
}
//=======================================================================
// Function: updateZLayers
// Purpose :
//=======================================================================
void StdSelect_ViewerSelector3d::updateZLayers (const Handle(V3d_View)& theView)
{
myZLayerOrderMap.Clear();
TColStd_SequenceOfInteger aZLayers;
theView->Viewer()->GetAllZLayers (aZLayers);
Standard_Integer aPos = 0;
Standard_Boolean isPrevDepthWrite = true;
for (TColStd_SequenceOfInteger::Iterator aLayerIter (aZLayers); aLayerIter.More(); aLayerIter.Next())
{
Graphic3d_ZLayerSettings aSettings = theView->Viewer()->ZLayerSettings (aLayerIter.Value());
if (aSettings.IsSettingEnabled (Graphic3d_ZLayerDepthClear)
|| isPrevDepthWrite != aSettings.IsSettingEnabled (Graphic3d_ZLayerDepthWrite))
{
++aPos;
}
isPrevDepthWrite = aSettings.IsSettingEnabled (Graphic3d_ZLayerDepthWrite);
myZLayerOrderMap.Bind (aLayerIter.Value(), aPos);
}
}