From 71c4f9c655fb77f84a436a88b336c17b7764c1be Mon Sep 17 00:00:00 2001 From: apl Date: Thu, 15 Mar 2012 15:56:58 +0400 Subject: [PATCH] 0022795: Make possible to display some presentable objects in overlay of others, groupped by display priority --- src/AIS/AIS_InteractiveContext.cxx | 8 +++++++- src/Visual3d/Visual3d_View.cxx | 3 +++ src/Visual3d/Visual3d_ViewManager.cdl | 7 +++++++ src/Visual3d/Visual3d_ViewManager.cxx | 23 +++++++++++++++++++++++ 4 files changed, 40 insertions(+), 1 deletion(-) diff --git a/src/AIS/AIS_InteractiveContext.cxx b/src/AIS/AIS_InteractiveContext.cxx index 8372528d85..e0ca6dc432 100755 --- a/src/AIS/AIS_InteractiveContext.cxx +++ b/src/AIS/AIS_InteractiveContext.cxx @@ -3194,7 +3194,13 @@ Standard_Integer AIS_InteractiveContext::GetZLayer (const Handle(AIS_Interactive return -1; if (myObjects.IsBound (theIObj)) + { return theIObj->GetZLayer (myMainPM); + } + else if (HasOpenedContext ()) + { + return myLocalContexts (myCurLocalIndex)->GetZLayer (theIObj); + } - return myLocalContexts (myCurLocalIndex)->GetZLayer (theIObj); + return -1; } diff --git a/src/Visual3d/Visual3d_View.cxx b/src/Visual3d/Visual3d_View.cxx index a1e308df5e..d765c3a4af 100755 --- a/src/Visual3d/Visual3d_View.cxx +++ b/src/Visual3d/Visual3d_View.cxx @@ -509,6 +509,9 @@ const Handle(WNT_Window) theWindow = *(Handle(WNT_Window) *) &AWindow; MyGraphicDriver->ClipLimit (MyCView, AWait); MyGraphicDriver->Environment(MyCView); + // Make view manager z layer list consistent with the view's list. + MyViewManager->InstallZLayers (this); + // Update planses of model clipping UpdatePlanes (); diff --git a/src/Visual3d/Visual3d_ViewManager.cdl b/src/Visual3d/Visual3d_ViewManager.cdl index 1cf9a89925..cd1cd9cc29 100755 --- a/src/Visual3d/Visual3d_ViewManager.cdl +++ b/src/Visual3d/Visual3d_ViewManager.cdl @@ -302,6 +302,13 @@ is -- from lowest layer to highest ( foreground ). The first layer ID -- in sequence is the default layer that can't be removed. + InstallZLayers ( me; + theView : View from Visual3d ) + is private; + ---Purpose: Install z layers managed by the view manager into the + -- controlled view. This method used on the view initialization to + -- make the layer lists consistent. + getZLayerGenId ( myclass ) ---Purpose: Returns global instance of z layer ids generator. ---C++: return & diff --git a/src/Visual3d/Visual3d_ViewManager.cxx b/src/Visual3d/Visual3d_ViewManager.cxx index 0279b0976c..faaa34b38a 100755 --- a/src/Visual3d/Visual3d_ViewManager.cxx +++ b/src/Visual3d/Visual3d_ViewManager.cxx @@ -1248,3 +1248,26 @@ Aspect_GenId& Visual3d_ViewManager::getZLayerGenId () static Aspect_GenId aGenId (1, IntegerLast()); return aGenId; } + +//======================================================================= +//function : InstallZLayers +//purpose : +//======================================================================= + +void Visual3d_ViewManager::InstallZLayers(const Handle(Visual3d_View)& theView) const +{ + if (!MyDefinedView.Contains (theView)) + return; + + // erase and insert layers iteratively to provide the same layer order as + // in the view manager's sequence. This approach bases on the layer insertion + // order: the new layers are always appended to the end of the list + // inside of view, while layer remove operation doesn't affect the order. + // Starting from second layer : no need to change the default z layer. + for (Standard_Integer aSeqIdx = 2; aSeqIdx <= myLayerSeq.Length (); aSeqIdx++) + { + Standard_Integer aLayerID = myLayerSeq.Value (aSeqIdx); + theView->RemoveZLayer (aLayerID); + theView->AddZLayer (aLayerID); + } +} -- 2.20.1