---Purpose: Sets the display priority aPriority of the seen parts
-- presentation of the entity anIobj.
+ SetZLayer( me : mutable;
+ theIObj : InteractiveObject from AIS;
+ theLayerId : Integer from Standard );
+ ---Purpose: Set Z layer id for interactive object. The layer can be
+ -- specified for displayed object only. The Z layers can be used to display
+ -- temporarily presentations of some object in front of the other objects
+ -- in the scene. The ids for Z layers are generated by V3d_Viewer.
+ -- Note that Z layers differ from under-/overlayer in V3d_View:
+ -- under-/overlayer are intended for specific 2D drawings that appear
+ -- behind/in front of all 3D presentations, while SetZLayer() method
+ -- applies to regular 3D presentations and does not imply any specific
+ -- drawing methods.
+
+ GetZLayer( me;
+ theIObj : InteractiveObject from AIS )
+ returns Integer from Standard;
+ ---Purpose: Get Z layer id set for displayed interactive object.
+ -- If the object doesn't exists in context or has no computed presentations,
+ -- the method returns -1.
+
Redisplay(me : mutable;
aniobj : InteractiveObject from AIS;
updateviewer : Boolean from Standard = Standard_True;
{
return myIsAutoActivateSelMode;
}
+
+//=======================================================================
+//function : SetZLayer
+//purpose :
+//=======================================================================
+
+void AIS_InteractiveContext::SetZLayer (const Handle(AIS_InteractiveObject)& theIObj,
+ const Standard_Integer theLayerId)
+{
+ if (theIObj.IsNull ())
+ return;
+
+ if (myObjects.IsBound (theIObj))
+ {
+ switch (myObjects (theIObj)->GraphicStatus ())
+ {
+ case AIS_DS_Displayed:
+ {
+ theIObj->SetZLayer (myMainPM, theLayerId);
+ break;
+ }
+ case AIS_DS_Erased:
+ {
+ theIObj->SetZLayer (myCollectorPM, theLayerId);
+ break;
+ }
+ default:
+ break;
+ }
+ }
+ else if (HasOpenedContext ())
+ {
+ myLocalContexts (myCurLocalIndex)->SetZLayer (theIObj, theLayerId);
+ }
+}
+
+//=======================================================================
+//function : GetZLayer
+//purpose :
+//=======================================================================
+
+Standard_Integer AIS_InteractiveContext::GetZLayer (const Handle(AIS_InteractiveObject)& theIObj) const
+{
+ if (theIObj.IsNull ())
+ return -1;
+
+ if (myObjects.IsBound (theIObj))
+ return theIObj->GetZLayer (myMainPM);
+
+ return myLocalContexts (myCurLocalIndex)->GetZLayer (theIObj);
+}
anObject: InteractiveObject from AIS;
Prior : Integer from Standard);
+ SetZLayer( me : mutable;
+ theIObj : InteractiveObject from AIS;
+ theLayerId : Integer from Standard );
+ ---Purpose: Set Z layer id for interactive object. The layer can be
+ -- specified for displayed object only. The Z layers can be used to display
+ -- temporarily presentations of some object in front of the other objects
+ -- in the scene. The ids for Z layers are generated by V3d_Viewer.
+ -- Note that Z layers differ from under-/overlayer in V3d_View:
+ -- under-/overlayer are intended for specific 2D drawings that appear
+ -- behind/in front of all 3D presentations, while SetZLayer() method
+ -- applies to regular 3D presentations and does not imply any specific
+ -- drawing methods.
+
+ GetZLayer( me;
+ theIObj : InteractiveObject from AIS )
+ returns Integer from Standard;
+ ---Purpose: Get Z layer id set for displayed interactive object.
+ -- If the object doesn't exists in context or has no computed presentations,
+ -- the method returns -1.
+
DisplayedObjects(me;theMapToFill : in out MapOfTransient from TColStd)
returns Integer from Standard;
}
-
//=======================================================================
//function : DisplayedObjects
//purpose :
myMainVS->Set(aPrecision);
}
#endif
+
+//=======================================================================
+//function : SetZLayer
+//purpose :
+//=======================================================================
+
+void AIS_LocalContext::SetZLayer (const Handle(AIS_InteractiveObject)& theIObj,
+ const Standard_Integer theLayerId)
+{
+ if (!myActiveObjects.IsBound (theIObj))
+ return;
+
+ const Handle(AIS_LocalStatus)& aStatus = myActiveObjects (theIObj);
+ if (aStatus->DisplayMode () == -1)
+ return;
+
+ theIObj->SetZLayer (myMainPM, theLayerId);
+}
+
+//=======================================================================
+//function : GetZLayer
+//purpose :
+//=======================================================================
+
+Standard_Integer AIS_LocalContext::GetZLayer (const Handle(AIS_InteractiveObject)& theIObj) const
+{
+ if (!myActiveObjects.IsBound (theIObj))
+ return -1;
+
+ return theIObj->GetZLayer (myMainPM);
+}
-- <theCGroup>. This method is internal and should be used
-- by Graphic3d_Group only.
+ AddZLayer( me : mutable;
+ theCView : CView from Graphic3d;
+ theLayerId : Integer from Standard )
+ is deferred;
+ ---Purpose: Add a new top-level z layer with ID <theLayerId> for
+ -- the view. Z layers allow drawing structures in higher layers
+ -- in foreground of structures in lower layers. To add a structure
+ -- to desired layer on display it is necessary to set the layer
+ -- ID for the structure.
+
+ RemoveZLayer( me : mutable;
+ theCView : CView from Graphic3d;
+ theLayerId : Integer from Standard )
+ is deferred;
+ ---Purpose: Remove Z layer from the specified view. All structures
+ -- displayed at the moment in layer will be displayed in default layer
+ -- ( the bottom-level z layer ). To unset layer ID from associated
+ -- structures use method UnsetZLayer (...).
+
+ UnsetZLayer( me : mutable;
+ theLayerId : Integer from Standard )
+ is deferred;
+ ---Purpose: Unset Z layer ID for all structures. The structure
+ -- indexes will be set to default layer ( the bottom-level z layer
+ -- with ID = 0 ).
+
+ ChangeZLayer( me : mutable;
+ theCStructure : CStructure from Graphic3d;
+ theLayerId : Integer from Standard )
+ is deferred;
+ ---Purpose: Change Z layer of a structure. The new z layer ID will
+ -- be used to define the associated layer for structure on display.
+
+ ChangeZLayer( me : mutable;
+ theCStructure : CStructure from Graphic3d;
+ theCView : CView from Graphic3d;
+ theNewLayerId : Integer from Standard )
+ is deferred;
+ ---Purpose: Change Z layer of a structure already presented in view.
+
+ GetZLayer( me;
+ theCStructure : CStructure from Graphic3d )
+ returns Integer from Standard is deferred;
+ ---Purpose: Get Z layer ID of structure. If the structure doesn't
+ -- exists in graphic driver, the method returns -1.
+
--------------------------
-- Category: Class methods
--------------------------
-- Warning: If <me> is displayed then the SetDisplayPriority
-- method erase <me> and display <me> with the
-- previous priority.
+
+ SetZLayer ( me : mutable;
+ theLayerId : Integer from Standard )
+ is static;
+ ---Purpose: Set Z layer ID for the structure. The Z layer mechanism
+ -- allows to display structures presented in higher layers in overlay
+ -- of structures in lower layers by switching off z buffer depth
+ -- test between layers
+
+ GetZLayer ( me )
+ returns Integer from Standard is static;
+ ---Purpose: Get Z layer ID of displayed structure. The method
+ -- returns -1 if the structure has no ID (deleted from graphic driver).
SetPick ( me : mutable;
AValue : Boolean from Standard )
return Standard_Address (&MyCStructure);
}
+
+//=======================================================================
+//function : SetZLayer
+//purpose :
+//=======================================================================
+
+void Graphic3d_Structure::SetZLayer (const Standard_Integer theLayerId)
+{
+ // if the structure is not displayed, unable to change its display layer
+ if (IsDeleted ())
+ return;
+
+ MyStructureManager->ChangeZLayer (this, theLayerId);
+}
+
+//=======================================================================
+//function : GetZLayer
+//purpose :
+//=======================================================================
+
+Standard_Integer Graphic3d_Structure::GetZLayer () const
+{
+ return MyStructureManager->GetZLayer (this);
+}
uses
Array2OfReal from TColStd,
+ SequenceOfInteger from TColStd,
GenId from Aspect,
GraphicDevice from Aspect,
---Purpose: Changes the display priority of the structure <AStructure>.
---Category: Private methods
+ ChangeZLayer ( me : mutable;
+ theStructure : Structure from Graphic3d;
+ theLayerId : Integer from Standard )
+ is deferred;
+ ---Purpose: Change Z layer for structure. The z layer mechanism allows
+ -- to display structures in higher layers in overlay of structures in
+ -- lower layers.
+
+ GetZLayer ( me;
+ theStructure : Structure from Graphic3d )
+ returns Integer from Standard is deferred;
+ ---Purpose: Get Z layer ID assigned to structure. If the structure
+ -- has no layer ID (deleted from graphic driver), the method returns -1.
+
+ AddZLayer ( me : mutable;
+ theLayerId : in out Integer from Standard )
+ returns Boolean from Standard is deferred;
+ ---Purpose: Add a new top-level Z layer and get its ID as
+ -- <theLayerId> value. The method returns Standard_False if the layer
+ -- can not be created. The z layer mechanism allows to display
+ -- structures in higher layers in overlay of structures in lower layers.
+
+ RemoveZLayer ( me : mutable;
+ theLayerId : Integer from Standard )
+ returns Boolean from Standard is deferred;
+ ---Purpose: Remove Z layer with ID <theLayerId>. Method returns
+ -- Standard_False if the layer can not be removed or doesn't exists.
+ -- By default, there is always a default bottom-level layer that can't
+ -- be removed.
+
+ GetAllZLayers ( me;
+ theLayerSeq : out SequenceOfInteger from TColStd )
+ is deferred;
+ ---Purpose: Return all Z layer ids in sequence ordered by level
+ -- from lowest layer to highest. The first layer ID in sequence is
+ -- the default layer that can't be removed.
+
CurrentId ( myclass )
returns Integer from Standard;
---Level: Internal
OpenGl_Context.hxx
OpenGl_Context.cxx
OpenGl_ArbVBO.hxx
-OpenGl_ExtFBO.hxx
\ No newline at end of file
+OpenGl_ExtFBO.hxx
+OpenGl_LayerList.cxx
+OpenGl_LayerList.hxx
\ No newline at end of file
Standard_EXPORT void FBOGetDimensions(const Graphic3d_CView& view,const Graphic3d_PtrFrameBuffer fboPtr,Standard_Integer& width,Standard_Integer& height,Standard_Integer& widthMax,Standard_Integer& heightMax);
Standard_EXPORT void FBOChangeViewport(const Graphic3d_CView& view,Graphic3d_PtrFrameBuffer& fboPtr,const Standard_Integer width,const Standard_Integer height);
Standard_EXPORT Standard_Boolean Export(const Standard_CString theFileName,const Graphic3d_ExportFormat theFormat,const Graphic3d_SortType theSortType,const Standard_Integer theWidth,const Standard_Integer theHeight,const Graphic3d_CView& theView,const Aspect_CLayer2d& theLayerUnder,const Aspect_CLayer2d& theLayerOver,const Standard_Real thePrecision = 0.005,const Standard_Address theProgressBarFunc = NULL,const Standard_Address theProgressObject = NULL);
+
+ //! Add a new top-level z layer with ID <theLayerId> for <br>
+ //! the view. Z layers allow drawing structures in higher layers <br>
+ //! in foreground of structures in lower layers. To add a structure <br>
+ //! to desired layer on display it is necessary to set the layer <br>
+ //! index for the structure. <br>
+ Standard_EXPORT void AddZLayer(const Graphic3d_CView& theCView,
+ const Standard_Integer theLayerId);
+
+ //! Remove Z layer from the specified view. All structures <br>
+ //! displayed at the moment in layer will be displayed in default layer <br>
+ //! ( the bottom-level z layer ). To unset layer index from associated <br>
+ //! structures use method UnsetZLayer (...). <br>
+ Standard_EXPORT void RemoveZLayer(const Graphic3d_CView& theCView,
+ const Standard_Integer theLayerId);
+
+ //! Unset Z layer ID for all structures. The structure <br>
+ //! indexes will be set to default layer ( the bottom-level z layer with <br>
+ //! ID = 0 ). <br>
+ Standard_EXPORT void UnsetZLayer(const Standard_Integer theLayerId);
+
+ //! Change Z layer of a structure. The new z layer ID will <br>
+ //! be used to define the associated layer for structure on display. <br>
+ //! It is recommended to take care of redisplaying the structures already <br>
+ //! presented in view with previously set layer index. This is usually <br>
+ //! done by viewer manager. Z layers allow drawing structures in <br>
+ //! higher layers in foreground of structures in lower layers. <br>
+ Standard_EXPORT void ChangeZLayer(const Graphic3d_CStructure& theCStructure,
+ const Standard_Integer theLayerId);
+
+ //! Change Z layer of a structure already presented in view. <br>
+ //! It is recommended to update z layer of already <br>
+ //! displayed structures with this method before setting new z layer <br>
+ //! index to the structure. This is usually done by viewer manager. <br>
+ Standard_EXPORT void ChangeZLayer(const Graphic3d_CStructure& theCStructure,
+ const Graphic3d_CView& theCView,
+ const Standard_Integer theNewLayerId);
+
+ //! Get Z layer ID of the structure. If the structure doesn't exists in <br>
+ //! graphic driver, the method returns -1. <br>
+ Standard_EXPORT Standard_Integer GetZLayer(const Graphic3d_CStructure& theCStructure) const;
public:
OpenGl_GraphicDriver::GetMapOfStructures().Bind (theCStructure.Id, aStructure);
InvalidateAllWorkspaces();
}
+
+//=======================================================================
+//function : ChangeZLayer
+//purpose :
+//=======================================================================
+
+void OpenGl_GraphicDriver::ChangeZLayer (const Graphic3d_CStructure& theCStructure,
+ const Standard_Integer theLayer)
+{
+ if (!GetMapOfStructures().IsBound (theCStructure.Id))
+ return;
+
+ OpenGl_Structure* aStructure =
+ OpenGl_GraphicDriver::GetMapOfStructures().Find (theCStructure.Id);
+
+ aStructure->SetZLayer (theLayer);
+}
+
+//=======================================================================
+//function : ChangeZLayer
+//purpose :
+//=======================================================================
+
+void OpenGl_GraphicDriver::ChangeZLayer (const Graphic3d_CStructure& theCStructure,
+ const Graphic3d_CView& theCView,
+ const Standard_Integer theNewLayerId)
+{
+ const OpenGl_CView *aCView = (const OpenGl_CView *)theCView.ptrView;
+
+ if (!GetMapOfStructures().IsBound (theCStructure.Id) || !aCView)
+ return;
+
+ OpenGl_Structure* aStructure =
+ OpenGl_GraphicDriver::GetMapOfStructures().Find (theCStructure.Id);
+
+ aCView->View->ChangeZLayer (aStructure, theNewLayerId);
+}
+
+//=======================================================================
+//function : GetZLayer
+//purpose :
+//=======================================================================
+
+Standard_Integer OpenGl_GraphicDriver::GetZLayer (const Graphic3d_CStructure& theCStructure) const
+{
+ if (!GetMapOfStructures().IsBound (theCStructure.Id))
+ return -1;
+
+ OpenGl_Structure* aStructure =
+ OpenGl_GraphicDriver::GetMapOfStructures().Find (theCStructure.Id);
+
+ return aStructure->GetZLayer();
+}
+
+//=======================================================================
+//function : UnsetZLayer
+//purpose :
+//=======================================================================
+
+void OpenGl_GraphicDriver::UnsetZLayer (const Standard_Integer theLayerId)
+{
+ NCollection_DataMap<Standard_Integer, OpenGl_Structure*>::Iterator
+ aStructIt (GetMapOfStructures ());
+
+ for( ; aStructIt.More (); aStructIt.Next ())
+ {
+ OpenGl_Structure* aStruct = aStructIt.ChangeValue ();
+ if (aStruct->GetZLayer () == theLayerId)
+ aStruct->SetZLayer (0);
+ }
+}
if (aCView)
aCView->View->SetBackfacing(ACView.Backfacing);
}
+
+//=======================================================================
+//function : AddZLayer
+//purpose :
+//=======================================================================
+
+void OpenGl_GraphicDriver::AddZLayer (const Graphic3d_CView& theCView,
+ const Standard_Integer theLayerId)
+{
+ const OpenGl_CView *aCView = (const OpenGl_CView *)theCView.ptrView;
+ if (aCView)
+ aCView->View->AddZLayer (theLayerId);
+}
+
+//=======================================================================
+//function : RemoveZLayer
+//purpose :
+//=======================================================================
+
+void OpenGl_GraphicDriver::RemoveZLayer (const Graphic3d_CView& theCView,
+ const Standard_Integer theLayerId)
+{
+ const OpenGl_CView* aCView = (const OpenGl_CView *)theCView.ptrView;
+ if (aCView)
+ aCView->View->RemoveZLayer (theLayerId);
+}
--- /dev/null
+// File: OpenGl_LayerList.hxx
+// Created: 2 February 2012
+// Author: Anton POLETAEV
+// Copyright: OPEN CASCADE 2012
+
+#include <OpenGl_LayerList.hxx>
+#include <OpenGl_tgl_all.hxx>
+#include <OpenGl_Structure.hxx>
+
+#include <InterfaceGraphic_Graphic3d.hxx>
+#include <InterfaceGraphic.hxx>
+
+//=======================================================================
+//function : OpenGl_LayerList
+//purpose : Constructor
+//=======================================================================
+
+OpenGl_LayerList::OpenGl_LayerList (const Standard_Integer theNbPriorities)
+ : myNbPriorities (theNbPriorities),
+ myNbStructures (0)
+{
+ // insert default priority layer
+ myLayers.Append (OpenGl_PriorityList (myNbPriorities));
+ myLayerIds.Bind (0, myLayers.Length());
+}
+
+//=======================================================================
+//function : ~OpenGl_LayerList
+//purpose : Destructor
+//=======================================================================
+
+OpenGl_LayerList::~OpenGl_LayerList ()
+{
+}
+
+//=======================================================================
+//function : defaultLayer
+//purpose :
+//=======================================================================
+
+OpenGl_PriorityList& OpenGl_LayerList::defaultLayer()
+{
+ return myLayers.ChangeValue (1);
+}
+
+//=======================================================================
+//function : NbPriorities
+//purpose : Method returns the number of available priorities
+//=======================================================================
+
+Standard_Integer OpenGl_LayerList::NbPriorities () const
+{
+ return myNbPriorities;
+}
+
+//=======================================================================
+//function : NbStructures
+//purpose : Method returns the number of available structures
+//=======================================================================
+
+Standard_Integer OpenGl_LayerList::NbStructures () const
+{
+ return myNbStructures;
+}
+
+//=======================================================================
+//function : AddLayer
+//purpose :
+//=======================================================================
+
+void OpenGl_LayerList::AddLayer (const Standard_Integer theLayerId)
+{
+ if (HasLayer (theLayerId))
+ return;
+
+ // add the new layer
+ myLayers.Append (OpenGl_PriorityList (myNbPriorities));
+ myLayerIds.Bind (theLayerId, myLayers.Length());
+}
+
+//=======================================================================
+//function : HasLayer
+//purpose :
+//=======================================================================
+
+Standard_Boolean OpenGl_LayerList::HasLayer
+ (const Standard_Integer theLayerId) const
+{
+ return myLayerIds.IsBound (theLayerId);
+}
+
+//=======================================================================
+//function : RemoveLayer
+//purpose :
+//=======================================================================
+
+void OpenGl_LayerList::RemoveLayer (const Standard_Integer theLayerId)
+{
+ if (!HasLayer (theLayerId) || theLayerId == 0)
+ return;
+
+ Standard_Integer aRemovePos = myLayerIds.Find (theLayerId);
+
+ // move all displayed structures to first layer
+ const OpenGl_PriorityList& aList = myLayers.Value (aRemovePos);
+ defaultLayer ().Append (aList);
+
+ // remove layer
+ myLayers.Remove (aRemovePos);
+ myLayerIds.UnBind (theLayerId);
+
+ // updated sequence indexes in map
+ OpenGl_LayerSeqIds::Iterator aMapIt (myLayerIds);
+ for ( ; aMapIt.More (); aMapIt.Next ())
+ {
+ Standard_Integer& aSeqIdx = aMapIt.ChangeValue ();
+ if (aSeqIdx > aRemovePos)
+ aSeqIdx--;
+ }
+}
+
+//=======================================================================
+//function : AddStructure
+//purpose :
+//=======================================================================
+
+void OpenGl_LayerList::AddStructure (const OpenGl_Structure *theStructure,
+ const Standard_Integer theLayerId,
+ const Standard_Integer thePriority)
+{
+ // add structure to associated layer,
+ // if layer doesn't exists, display structure in default layer
+ OpenGl_PriorityList& aList = !HasLayer (theLayerId) ? defaultLayer () :
+ myLayers.ChangeValue (myLayerIds.Find (theLayerId));
+
+ aList.Add (theStructure, thePriority);
+ myNbStructures++;
+}
+
+//=======================================================================
+//function : RemoveStructure
+//purpose :
+//=======================================================================
+
+void OpenGl_LayerList::RemoveStructure (const OpenGl_Structure *theStructure,
+ const Standard_Integer theLayerId)
+{
+ Standard_Integer aSeqPos = !HasLayer (theLayerId) ?
+ 1 : myLayerIds.Find (theLayerId);
+
+ OpenGl_PriorityList& aList = myLayers.ChangeValue (aSeqPos);
+
+ // remove structure from associated list
+ // if the structure is not found there,
+ // scan through layers and remove it
+ if (aList.Remove (theStructure) >= 0)
+ {
+ myNbStructures--;
+ return;
+ }
+
+ // scan through layers and remove it
+ Standard_Integer aSeqId = 1;
+ OpenGl_SequenceOfLayers::Iterator anIts;
+ for (anIts.Init (myLayers); anIts.More (); anIts.Next (), aSeqId++)
+ {
+ OpenGl_PriorityList& aScanList = anIts.ChangeValue ();
+ if (aSeqPos == aSeqId)
+ continue;
+
+ if (aScanList.Remove (theStructure) >= 0)
+ {
+ myNbStructures--;
+ return;
+ }
+ }
+}
+
+//=======================================================================
+//function : ChangeLayer
+//purpose :
+//=======================================================================
+
+void OpenGl_LayerList::ChangeLayer (const OpenGl_Structure *theStructure,
+ const Standard_Integer theOldLayerId,
+ const Standard_Integer theNewLayerId)
+{
+ Standard_Integer aSeqPos = !HasLayer (theOldLayerId) ?
+ 1 : myLayerIds.Find (theOldLayerId);
+
+ OpenGl_PriorityList& aList = myLayers.ChangeValue (aSeqPos);
+ Standard_Integer aPriority;
+
+ // take priority and remove structure from list found by <theOldLayerId>
+ // if the structure is not found there, scan through all other layers
+ if ((aPriority = aList.Remove (theStructure)) >= 0)
+ {
+ myNbStructures--;
+ AddStructure (theStructure, theNewLayerId, aPriority);
+ }
+ else
+ {
+ // scan through layers and remove it
+ Standard_Integer aSeqId = 1;
+ OpenGl_SequenceOfLayers::Iterator anIts;
+ for (anIts.Init (myLayers); anIts.More (); anIts.Next (), aSeqId++)
+ {
+ OpenGl_PriorityList& aScanList = anIts.ChangeValue ();
+ if (aSeqPos == aSeqId)
+ continue;
+
+ // try to remove structure and get priority value from this layer
+ if ((aPriority = aList.Remove (theStructure)) >= 0)
+ {
+ myNbStructures--;
+ AddStructure (theStructure, theNewLayerId, aPriority);
+ break;
+ }
+ }
+ }
+}
+
+//=======================================================================
+//function : Render
+//purpose : Render this element
+//=======================================================================
+
+void OpenGl_LayerList::Render (const Handle(OpenGl_Workspace) &theWorkspace) const
+{
+ OpenGl_SequenceOfLayers::Iterator anIts;
+ for(anIts.Init (myLayers); anIts.More (); anIts.Next ())
+ {
+ const OpenGl_PriorityList& aList = anIts.Value ();
+ if (aList.NbStructures () > 0)
+ {
+ // separate depth buffers
+ glClear (GL_DEPTH_BUFFER_BIT);
+
+ // render priority list
+ aList.Render (theWorkspace);
+ }
+ }
+}
--- /dev/null
+// File: OpenGl_LayerList.hxx
+// Created: 2 February 2012
+// Author: Anton POLETAEV
+// Copyright: OPEN CASCADE 2012
+
+#ifndef _OpenGl_LayerList_Header
+#define _OpenGl_LayerList_Header
+
+#include <OpenGl_PriorityList.hxx>
+
+#include <InterfaceGraphic_telem.hxx>
+
+#include <NCollection_Sequence.hxx>
+#include <NCollection_DataMap.hxx>
+
+class OpenGl_Structure;
+class Handle(OpenGl_Workspace);
+
+typedef NCollection_Sequence<OpenGl_PriorityList> OpenGl_SequenceOfLayers;
+typedef NCollection_DataMap<int, int> OpenGl_LayerSeqIds;
+
+class OpenGl_LayerList
+{
+ public:
+
+ //! Constructor
+ OpenGl_LayerList (const Standard_Integer theNbPriorities = 11);
+
+ //! Destructor
+ virtual ~OpenGl_LayerList ();
+
+ //! Method returns the number of available priorities
+ Standard_Integer NbPriorities () const;
+
+ //! Number of displayed structures
+ Standard_Integer NbStructures () const;
+
+ //! Insert a new layer with id.
+ void AddLayer (const Standard_Integer theLayerId);
+
+ //! Check whether the layer with given id is already created.
+ Standard_Boolean HasLayer (const Standard_Integer theLayerId) const;
+
+ //! Remove layer by its id.
+ void RemoveLayer (const Standard_Integer theLayerId);
+
+ //! Add structure to list with given priority. The structure will be inserted
+ //! to specified layer. If the layer isn't found, the structure will be put
+ //! to default bottom-level layer.
+ void AddStructure (const OpenGl_Structure *theStructure,
+ const Standard_Integer theLayerId,
+ const Standard_Integer thePriority);
+
+ //! Remove structure from structure list and return its previous priority
+ void RemoveStructure (const OpenGl_Structure *theStructure,
+ const Standard_Integer theZLayerId);
+
+ //! Change structure z layer
+ //! If the new layer is not presented, the structure will be displayed
+ //! in default z layer
+ void ChangeLayer (const OpenGl_Structure *theStructure,
+ const Standard_Integer theOldLayerId,
+ const Standard_Integer theNewLayerId);
+
+ //! Render this element
+ void Render (const Handle(OpenGl_Workspace) &theWorkspace) const;
+
+ private:
+
+ //! Get default layer
+ OpenGl_PriorityList& defaultLayer ();
+
+ protected:
+
+ // number of structures temporary put to default layer
+ OpenGl_SequenceOfLayers myLayers;
+ OpenGl_LayerSeqIds myLayerIds;
+ Standard_Integer myNbPriorities;
+ Standard_Integer myNbStructures;
+
+ public:
+ IMPLEMENT_MEMORY_OPERATORS
+};
+
+#endif //_OpenGl_LayerList_Header
/*----------------------------------------------------------------------*/
-void OpenGl_PriorityList::Remove (const OpenGl_Structure *AStructure)
+Standard_Integer OpenGl_PriorityList::Remove (const OpenGl_Structure *AStructure)
{
const Standard_Integer aNbPr = myArray.Length();
Standard_Integer i = 0;
{
aSeq.Remove(its);
myNbStructures--;
- return;
+ return i;
}
}
}
+
+ return -1;
}
/*----------------------------------------------------------------------*/
}
}
-/*----------------------------------------------------------------------*/
+//=======================================================================
+//function : Append
+//purpose :
+//=======================================================================
+
+Standard_Boolean OpenGl_PriorityList::Append (const OpenGl_PriorityList& theOther)
+{
+ // the source priority list shouldn't have more priorities
+ const Standard_Integer aNbPriorities = theOther.NbPriorities ();
+ if (aNbPriorities > NbPriorities ())
+ return Standard_False;
+
+ // add all structures to destination priority list
+ Standard_Integer aIdx = 0;
+ OpenGl_SequenceOfStructure::Iterator anIts;
+ for (; aIdx < aNbPriorities; aIdx++)
+ {
+ const OpenGl_SequenceOfStructure& aSeq = theOther.myArray (aIdx);
+ for (anIts.Init (aSeq); anIts.More (); anIts.Next ())
+ Add (anIts.Value (), aIdx);
+ }
+
+ return Standard_True;
+}
+
+//=======================================================================
+//function : NbPriorities
+//purpose :
+//=======================================================================
+
+Standard_Integer OpenGl_PriorityList::NbPriorities() const
+{
+ return myArray.Length();
+}
public:
OpenGl_PriorityList (const Standard_Integer ANbPriorities = 11) : myArray(0,(ANbPriorities-1)), myNbStructures(0) {}
+
virtual ~OpenGl_PriorityList () {}
void Add (const OpenGl_Structure *AStructure, const Standard_Integer APriority);
- void Remove (const OpenGl_Structure *AStructure);
+
+ //! Remove structure and returns its priority, if the structure is not found,
+ //! method returns negative value
+ Standard_Integer Remove (const OpenGl_Structure *AStructure);
Standard_Integer NbStructures () const { return myNbStructures; }
void Render (const Handle(OpenGl_Workspace) &AWorkspace) const;
+ //! Returns the number of available priority levels
+ Standard_Integer NbPriorities() const;
+
+ //! Append priority list of acceptable type (with similar number of priorities
+ //! or less). Returns Standard_False if the list can not be accepted.
+ Standard_Boolean Append (const OpenGl_PriorityList& theOther);
+
protected:
OpenGl_ArrayOfStructure myArray;
- Standard_Integer myNbStructures;
+ Standard_Integer myNbStructures;
public:
IMPLEMENT_MEMORY_OPERATORS
myAspectText(NULL),
myHighlightBox(NULL),
myHighlightColor(NULL),
- myNamedStatus(0)
+ myNamedStatus(0),
+ myZLayer(0)
{
}
AWorkspace->NamedStatus = named_status;
}
-/*----------------------------------------------------------------------*/
+//=======================================================================
+//function : SetZLayer
+//purpose :
+//=======================================================================
+
+void OpenGl_Structure::SetZLayer (const Standard_Integer theLayerIndex)
+{
+ myZLayer = theLayerIndex;
+}
+
+//=======================================================================
+//function : GetZLayer
+//purpose :
+//=======================================================================
+
+Standard_Integer OpenGl_Structure::GetZLayer () const
+{
+ return myZLayer;
+}
void RemoveGroup (const OpenGl_Group *);
void Clear ();
- virtual void Render (const Handle(OpenGl_Workspace) &AWorkspace) const;
+ //! Set z layer ID to display the structure in specified layer
+ void SetZLayer (const Standard_Integer theLayerIndex);
+
+ //! Get z layer ID
+ Standard_Integer GetZLayer () const;
+ virtual void Render (const Handle(OpenGl_Workspace) &AWorkspace) const;
+
protected:
//Structure_LABBegin
//Structure_LABVisibility
//Structure_LABPick
int myNamedStatus; //Structure_LABNameSet
+ int myZLayer;
OpenGl_ListOfStructure myConnected;
#include <Visual3d_TypeOfSurfaceDetail.hxx>
#include <OpenGl_telem_view.hxx>
-
+#include <OpenGl_LayerList.hxx>
#include <OpenGl_Light.hxx>
-#include <OpenGl_PriorityList.hxx>
#include <Handle_OpenGl_Trihedron.hxx>
#include <Handle_OpenGl_GraduatedTrihedron.hxx>
const TEL_TRANSFORM_PERSISTENCE * BeginTransformPersistence ( const TEL_TRANSFORM_PERSISTENCE *ATransPers );
void EndTransformPersistence ();
- void DisplayStructure (const OpenGl_Structure *AStructure, const Standard_Integer APriority) { myStructures.Add(AStructure,APriority); }
- void EraseStructure (const OpenGl_Structure *AStructure) { myStructures.Remove(AStructure); }
+ //! Add structure to display list with specified priority.
+ //! The structure will be added to associated with it z layer.
+ //! If the z layer is not presented in the view, the structure will
+ //! be displayed in default bottom-level z layer.
+ void DisplayStructure (const OpenGl_Structure *theStructure,
+ const Standard_Integer thePriority);
+
+ //! Erase structure from display list.
+ void EraseStructure (const OpenGl_Structure *theStructure);
+
+ //! Insert a new top-level z layer with ID <theLayerId>
+ void AddZLayer (const Standard_Integer theLayerId);
+
+ //! Remove a z layer with ID <theLayerId>
+ void RemoveZLayer (const Standard_Integer theLayerId);
+
+ //! Display structure in z layer with ID <theNewLayerId>
+ //! If the layer with ID <theNewLayerId> is not presented in the view,
+ //! the structure will be displayed in default bottom-level layer.
+ void ChangeZLayer (const OpenGl_Structure *theStructure,
+ const Standard_Integer theNewLayerId);
void CreateBackgroundTexture (const Standard_CString AFileName, const Aspect_FillMethod AFillStyle);
void SetBackgroundTextureStyle (const Aspect_FillMethod FillStyle);
//View_LABDepthCueing - fixed index used
- OpenGl_PriorityList myStructures;
+ OpenGl_LayerList myZLayers;
int myAnimationListIndex;
Standard_Boolean myAnimationListReady;
#include <OpenGl_Trihedron.hxx>
#include <OpenGl_GraduatedTrihedron.hxx>
#include <OpenGl_PrinterContext.hxx>
+#include <OpenGl_Structure.hxx>
/*----------------------------------------------------------------------*/
/*
//ExecuteViewDisplay
void OpenGl_View::RenderStructs (const Handle(OpenGl_Workspace) &AWorkspace)
{
- if ( myStructures.NbStructures() <= 0 ) return;
+ if ( myZLayers.NbStructures() <= 0 )
+ return;
glPushAttrib ( GL_DEPTH_BUFFER_BIT );
}
}
- myStructures.Render(AWorkspace);
+ myZLayers.Render (AWorkspace);
//TsmPopAttri(); /* restore previous graphics context; before update lights */
myBgGradient.type = AType;
}
-/*----------------------------------------------------------------------*/
+//=======================================================================
+//function : AddZLayer
+//purpose :
+//=======================================================================
+
+void OpenGl_View::AddZLayer (const Standard_Integer theLayerId)
+{
+ myZLayers.AddLayer (theLayerId);
+}
+
+//=======================================================================
+//function : RemoveZLayer
+//purpose :
+//=======================================================================
+
+void OpenGl_View::RemoveZLayer (const Standard_Integer theLayerId)
+{
+ myZLayers.RemoveLayer (theLayerId);
+}
+
+//=======================================================================
+//function : DisplayStructure
+//purpose :
+//=======================================================================
+
+void OpenGl_View::DisplayStructure (const OpenGl_Structure *theStructure,
+ const Standard_Integer thePriority)
+{
+ Standard_Integer aZLayer = theStructure->GetZLayer ();
+ myZLayers.AddStructure (theStructure, aZLayer, thePriority);
+}
+
+//=======================================================================
+//function : EraseStructure
+//purpose :
+//=======================================================================
+
+void OpenGl_View::EraseStructure (const OpenGl_Structure *theStructure)
+{
+ Standard_Integer aZLayer = theStructure->GetZLayer ();
+ myZLayers.RemoveStructure (theStructure, aZLayer);
+}
+
+//=======================================================================
+//function : ChangeZLayer
+//purpose :
+//=======================================================================
+
+void OpenGl_View::ChangeZLayer (const OpenGl_Structure *theStructure,
+ const Standard_Integer theNewLayerId)
+{
+ Standard_Integer anOldLayer = theStructure->GetZLayer ();
+ myZLayers.ChangeLayer (theStructure, anOldLayer, theNewLayerId);
+}
UpdateLocation(me:mutable;P : mutable Presentation from Prs3d) is virtual;
+ SetZLayer ( me : mutable;
+ thePrsMgr : PresentationManager from PrsMgr;
+ theLayerId : Integer from Standard )
+ is virtual;
+ ---Purpose: Set Z layer ID and update all presentations of
+ -- the presentable object. The layer can be set only for displayed object.
+ -- If all object presentations are removed, the layer ID will be set to
+ -- default value when computing presentation. The layers mechanism allows
+ -- drawing objects in higher layers in overlay of objects in lower layers.
-
+ GetZLayer ( me;
+ thePrsMgr : PresentationManager from PrsMgr )
+ returns Integer from Standard is static;
+ ---Purpose: Get ID of Z layer. If no presentations of object is displayed,
+ -- and layer ID is unavailable, the -1 value is returned.
+
fields
myPresentations: Presentations from PrsMgr is protected;
myTypeOfPresentation3d: TypeOfPresentation3d from PrsMgr is protected;
{
return gp_Pnt( myTransformPersistence.Point.x, myTransformPersistence.Point.y, myTransformPersistence.Point.z );
}
+
+//=======================================================================
+//function : SetZLayer
+//purpose :
+//=======================================================================
+void PrsMgr_PresentableObject::SetZLayer
+ (const Handle(PrsMgr_PresentationManager)& thePrsMgr,
+ const Standard_Integer theLayerId)
+{
+ if (!thePrsMgr.IsNull())
+ thePrsMgr->SetZLayer (this, theLayerId);
+}
+
+//=======================================================================
+//function : GetZLayer
+//purpose :
+//=======================================================================
+Standard_Integer PrsMgr_PresentableObject::GetZLayer
+ (const Handle(PrsMgr_PresentationManager)& thePrsMgr) const
+{
+ if (!thePrsMgr.IsNull())
+ return thePrsMgr->GetZLayer (this);
+
+ return -1;
+}
SetDisplayPriority(me:mutable;aNewPrior:Integer from Standard)
is deferred private;
+ SetZLayer ( me : mutable;
+ theLayerId : Integer from Standard )
+ is deferred private;
+ ---Purpose: Set Z layer ID for the presentation
+
+ GetZLayer ( me )
+ returns Integer from Standard is deferred private;
+ ---Purpose: Get Z layer ID for the presentation
+
Clear(me: mutable)
is deferred private;
SetDisplayPriority(me:mutable;aNewPrior:Integer from Standard)
is redefined static private;
+ SetZLayer ( me : mutable;
+ theLayerId : Integer from Standard )
+ is redefined static private;
+ ---Purpose: Set Z layer ID for the presentation
+
+ GetZLayer ( me )
+ returns Integer from Standard is redefined static private;
+ ---Purpose: Get Z layer ID for the presentation
Clear(me:mutable)
---Purpose: removes the whole content of the presentation.
void PrsMgr_Presentation2d::Destroy () {
}
+
+//=======================================================================
+//function : SetZLayer
+//purpose :
+//=======================================================================
+
+void PrsMgr_Presentation2d::SetZLayer (Standard_Integer theLayer)
+{
+}
+
+//=======================================================================
+//function : GetZLayer
+//purpose :
+//=======================================================================
+
+Standard_Integer PrsMgr_Presentation2d::GetZLayer () const
+{
+ return 0;
+}
SetDisplayPriority(me:mutable;aNewPrior:Integer from Standard)
is redefined static private;
+ SetZLayer ( me : mutable;
+ theLayerId : Integer from Standard )
+ is redefined static private;
+ ---Purpose: Set Z layer ID for the presentation
+
+ GetZLayer ( me )
+ returns Integer from Standard is redefined static private;
+ ---Purpose: Get Z layer ID for the presentation
+
Clear(me:mutable)
---Purpose: removes the whole content of the presentation.
-- Does not remove the other connected presentations.
myStructure->Clear();
myStructure.Nullify();
}
+
+//=======================================================================
+//function : SetZLayer
+//purpose :
+//=======================================================================
+
+void PrsMgr_Presentation3d::SetZLayer (Standard_Integer theLayerId)
+{
+ myStructure->SetZLayer (theLayerId);
+}
+
+//=======================================================================
+//function : GetZLayer
+//purpose :
+//=======================================================================
+
+Standard_Integer PrsMgr_Presentation3d::GetZLayer () const
+{
+ return myStructure->GetZLayer ();
+}
-- aPresentableObject in this framework with the
-- display mode aMode.
+ SetZLayer ( me : mutable;
+ thePresentableObject : PresentableObject from PrsMgr;
+ theLayerId : Integer from Standard )
+ is static;
+ ---Purpose: Set Z layer ID for all presentations of the object.
+
+ GetZLayer ( me;
+ thePresentableObject : PresentableObject from PrsMgr )
+ returns Integer from Standard is static;
+ ---Purpose: Get Z layer ID assigned to all presentations of the object.
+ -- Method returns -1 value if object has no presentations and is
+ -- impossible to get layer index.
+
IsDisplayed(me;aPresentableObject: PresentableObject from PrsMgr;
aMode: Integer from Standard = 0)
---Purpose: Returns true if the presentation of the presentable
Handle(PrsMgr_Presentation) P = newPresentation(aPresentableObject);
aPresentableObject->Presentations().Append(PrsMgr_ModedPresentation(P,aMode));
aPresentableObject->Fill(this,P,aMode);
+
+ // set layer index accordingly to object's presentations
+ Standard_Integer aZLayerId = GetZLayer (aPresentableObject);
+ if (aZLayerId >= 0)
+ P->SetZLayer (aZLayerId);
+
P->SetUpdateStatus(Standard_False);
}
}
}
+//=======================================================================
+//function : SetZLayer
+//purpose :
+//=======================================================================
+
+void PrsMgr_PresentationManager::SetZLayer
+ (const Handle(PrsMgr_PresentableObject)& thePresentableObject,
+ const Standard_Integer theLayerId)
+{
+ PrsMgr_Presentations& aPresentations = thePresentableObject->Presentations();
+ for (Standard_Integer aIdx = 1; aIdx <= aPresentations.Length (); aIdx++)
+ {
+ Handle(PrsMgr_Presentation) aPrs = aPresentations (aIdx).Presentation ();
+ if (aPrs->PresentationManager () == this)
+ aPrs->SetZLayer (theLayerId);
+ }
+}
+
+//=======================================================================
+//function : GetZLayer
+//purpose :
+//=======================================================================
+
+Standard_Integer PrsMgr_PresentationManager::GetZLayer
+ (const Handle(PrsMgr_PresentableObject)& thePresentableObject) const
+{
+ PrsMgr_Presentations& aPresentations = thePresentableObject->Presentations();
+ for (Standard_Integer aIdx = 1; aIdx <= aPresentations.Length (); aIdx++)
+ {
+ Handle(PrsMgr_Presentation) aPrs = aPresentations (aIdx).Presentation ();
+ if (aPrs->PresentationManager () == this)
+ return aPrs->GetZLayer ();
+ }
+
+ return -1;
+}
-- Hilight for SelectableObject when the owner is detected. By default
-- it always return FALSE.
+ SetZLayer ( me : mutable;
+ thePrsMgr : PresentationManager from PrsMgr;
+ theLayerId : Integer from Standard )
+ is virtual;
+ ---Purpose: Set Z layer ID and update all presentations.
+
fields
mySelectable : SOPtr;
{
return Standard_False;
}
+
+//=======================================================================
+//function : SetZLayer
+//purpose :
+//=======================================================================
+void SelectMgr_EntityOwner::SetZLayer
+ (const Handle(PrsMgr_PresentationManager)& thePrsMgr,
+ const Standard_Integer theLayerId)
+{
+}
SequenceOfSelection from SelectMgr,
TypeOfPresentation3d from PrsMgr,
Presentation from Prs3d,
+ PresentationManager from PrsMgr,
PresentationManager3d from PrsMgr,
SequenceOfOwner from SelectMgr,
NameOfColor from Quantity,
GetSelectPresentation( me: mutable;
TheMgr: PresentationManager3d from PrsMgr ) returns Presentation from Prs3d is static;
-
+
+ SetZLayer ( me : mutable;
+ thePrsMgr : PresentationManager from PrsMgr;
+ theLayerId : Integer from Standard )
+ is redefined virtual;
+ ---Purpose: Set Z layer ID and update all presentations of
+ -- the selectable object. The layer can be set only for displayed object.
+ -- If all object presentations are removed, the layer ID will be set to
+ -- default value when computing presentation. The layers mechanism allows
+ -- drawing objects in higher layers in overlay of objects in lower layers.
+
fields
myselections : SequenceOfSelection is protected;
return mySelectionPrs;
}
+//=======================================================================
+//function : SetZLayer
+//purpose :
+//=======================================================================
+void SelectMgr_SelectableObject::SetZLayer
+ (const Handle(PrsMgr_PresentationManager)& thePrsMgr,
+ const Standard_Integer theLayerId)
+{
+ if (thePrsMgr.IsNull())
+ return;
+
+ // update own presentations
+ PrsMgr_PresentableObject::SetZLayer (thePrsMgr, theLayerId);
+
+ // update selection presentations
+ if (!mySelectionPrs.IsNull())
+ mySelectionPrs->SetZLayer (theLayerId);
+
+ if (!myHilightPrs.IsNull())
+ myHilightPrs->SetZLayer (theLayerId);
+
+ // update all entity owner presentations
+ for (Init (); More () ;Next ())
+ {
+ const Handle(SelectMgr_Selection)& aSel = CurrentSelection();
+ for (aSel->Init (); aSel->More (); aSel->Next ())
+ {
+ Handle(Select3D_SensitiveEntity) aEntity =
+ Handle(Select3D_SensitiveEntity)::DownCast (aSel->Sensitive());
+ if (!aEntity.IsNull())
+ {
+ Handle(SelectMgr_EntityOwner) aOwner =
+ Handle(SelectMgr_EntityOwner)::DownCast (aEntity->OwnerId());
+ if (!aOwner.IsNull())
+ aOwner->SetZLayer (thePrsMgr, theLayerId);
+ }
+ }
+ }
+}
SetLocation(me:mutable; aLoc : Location from TopLoc) is redefined;
ResetLocation(me:mutable) is redefined;
+ SetZLayer ( me : mutable;
+ thePrsMgr : PresentationManager from PrsMgr;
+ theLayerId : Integer from Standard )
+ is redefined virtual;
+ ---Purpose: Set Z layer ID and update all presentations.
+
fields
myPrsSh : Shape from StdSelect;
myCurMode : Integer from Standard;
myPrsSh.Nullify();
}
+ // generate new presentable shape
if(myPrsSh.IsNull())
myPrsSh = new StdSelect_Shape (myShape);
- }
- if(myPrsSh.IsNull())
- PM->Highlight(Selectable(),M);
+ // highlight and set layer
+ PM->Highlight (myPrsSh, M);
+ Handle(SelectMgr_SelectableObject) aSel = Selectable();
+ if (!aSel.IsNull())
+ {
+ Standard_Integer aLayer = aSel->GetZLayer (PM);
+ if (aLayer >= 0)
+ PM->SetZLayer (myPrsSh, aLayer);
+ }
+ }
else
- PM->Highlight(myPrsSh,M);
+ {
+ if(myPrsSh.IsNull())
+ PM->Highlight(Selectable(),M);
+ else
+ PM->Highlight(myPrsSh,M);
+ }
}
void StdSelect_BRepOwner::Hilight()
myPrsSh.Nullify();
}
- if(myPrsSh.IsNull()){
- if(HasLocation()){
- TopLoc_Location lbid = Location() * myShape.Location();
- TopoDS_Shape ShBis = myShape.Located(lbid);
- myPrsSh = new StdSelect_Shape(ShBis);
+ // generate new presentable shape
+ if(myPrsSh.IsNull())
+ {
+ if(HasLocation())
+ {
+ TopLoc_Location lbid = Location() * myShape.Location();
+ TopoDS_Shape ShBis = myShape.Located(lbid);
+ myPrsSh = new StdSelect_Shape(ShBis);
}
else
- myPrsSh = new StdSelect_Shape(myShape);
+ myPrsSh = new StdSelect_Shape(myShape);
+ }
+
+ // highlight with color and set layer
+ PM->Color (myPrsSh, aCol, M);
+ Handle(SelectMgr_SelectableObject) aSel = Selectable();
+ if (!aSel.IsNull())
+ {
+ Standard_Integer aLayer = aSel->GetZLayer (PM);
+ if (aLayer >= 0)
+ PM->SetZLayer (myPrsSh, aLayer);
}
}
- if(myPrsSh.IsNull())
- PM->Color(Selectable(),aCol,M);
else
- PM->Color(myPrsSh,aCol,M);
+ {
+ if(myPrsSh.IsNull())
+ PM->Color(Selectable(),aCol,M);
+ else
+ PM->Color(myPrsSh,aCol,M);
+ }
}
void StdSelect_BRepOwner::Unhilight(const Handle(PrsMgr_PresentationManager)& PM,
// set the update flag and then recompute myPrsSh on hilighting
if (!myPrsSh.IsNull())
myPrsSh->SetToUpdate();
-
}
+
void StdSelect_BRepOwner::ResetLocation()
{
SelectMgr_EntityOwner::ResetLocation();
// set the update flag and then recompute myPrsSh on hilighting
if (!myPrsSh.IsNull())
myPrsSh->SetToUpdate();
+}
+//=======================================================================
+//function : SetZLayer
+//purpose :
+//=======================================================================
+void StdSelect_BRepOwner::SetZLayer
+ (const Handle(PrsMgr_PresentationManager)& thePrsMgr,
+ const Standard_Integer theLayerId)
+{
+ if (!myPrsSh.IsNull())
+ thePrsMgr->SetZLayer (myPrsSh, theLayerId);
}
Plane from V3d,
ListOfTransient from V3d,
ListIteratorOfListOfTransient from TColStd,
+ SequenceOfInteger from TColStd,
TypeOfView from V3d,
Vector from Graphic3d,
ViewManager from Visual3d,
---Purpose:
-- Display grid echo at requested point in the view.
+ AddZLayer ( me : mutable;
+ theLayerId : in out Integer from Standard )
+ returns Boolean from Standard is static;
+ ---Purpose: Add a new top-level Z layer to all managed views and get
+ -- its ID as <theLayerId> value. The Z layers are controlled entirely
+ -- by viewer, it is not possible to add a layer to a
+ -- particular view. The method returns Standard_False if the layer can
+ -- not be created. The layer mechanism allows to display structures
+ -- in higher layers in overlay of structures in lower layers.
+
+ RemoveZLayer ( me : mutable;
+ theLayerId : Integer from Standard )
+ returns Boolean from Standard is static;
+ ---Purpose: Remove Z layer with ID <theLayerId>. Method returns
+ -- Standard_False if the layer can not be removed or doesn't exists.
+ -- By default, there are always default bottom-level layer that can't
+ -- be removed.
+
+ GetAllZLayers ( me;
+ theLayerSeq : out SequenceOfInteger from TColStd )
+ is static;
+ ---Purpose: Return all Z layer ids in sequence ordered by overlay level
+ -- from lowest layer to highest ( foreground ). The first layer ID
+ -- in sequence is the default layer that can't be removed.
+
fields
MyViewer: ViewManager from Visual3d ;
MyDefinedPlanes.Remove(ThePlane);
}
+
+//=======================================================================
+//function : AddZLayer
+//purpose :
+//=======================================================================
+
+Standard_Boolean V3d_Viewer::AddZLayer (Standard_Integer& theLayerId)
+{
+ return MyViewer->AddZLayer (theLayerId);
+}
+
+//=======================================================================
+//function : RemoveZLayer
+//purpose :
+//=======================================================================
+
+Standard_Boolean V3d_Viewer::RemoveZLayer (const Standard_Integer theLayerId)
+{
+ return MyViewer->RemoveZLayer (theLayerId);
+}
+
+//=======================================================================
+//function : GetAllZLayers
+//purpose :
+//=======================================================================
+
+void V3d_Viewer::GetAllZLayers (TColStd_SequenceOfInteger& theLayerSeq) const
+{
+ MyViewer->GetAllZLayers (theLayerSeq);
+}
return 0;
}
+//=======================================================================
+//function : VObjZLayer
+//purpose : Set or get z layer id for presentable object
+//=======================================================================
+
+static Standard_Integer VObjZLayer (Draw_Interpretor& di,
+ Standard_Integer argc,
+ const char ** argv)
+{
+ Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
+ if (aContext.IsNull())
+ {
+ di << argv[0] << "Call 'vinit' before!\n";
+ return 1;
+ }
+
+ // get operation
+ TCollection_AsciiString aOperation;
+ if (argc >= 2)
+ aOperation = TCollection_AsciiString (argv [1]);
+
+ // check for correct arguments
+ if (!(argc == 4 && aOperation.IsEqual ("set")) &&
+ !(argc == 3 && aOperation.IsEqual ("get")))
+ {
+ di << "Usage : " << argv[0] << " set/get object [layerid]\n";
+ di << " set - set layer id for interactive object, layerid - z layer id\n";
+ di << " get - get layer id of interactive object\n";
+ di << " argument layerid should be passed for set operation only\n";
+ return 1;
+ }
+
+ // find object
+ TCollection_AsciiString aName (argv[2]);
+ ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS();
+ if (!aMap.IsBound2 (aName))
+ {
+ di << "Use 'vdisplay' before" << "\n";
+ return 1;
+ }
+
+ // find interactive object
+ Handle(Standard_Transient) anObj = GetMapOfAIS().Find2 (aName);
+ Handle(AIS_InteractiveObject) anInterObj =
+ Handle(AIS_InteractiveObject)::DownCast (anObj);
+ if (anInterObj.IsNull())
+ {
+ di << "Not an AIS interactive object!\n";
+ return 1;
+ }
+
+ // process operation
+ if (aOperation.IsEqual ("set"))
+ {
+ Standard_Integer aLayerId = atoi (argv [3]);
+ aContext->SetZLayer (anInterObj, aLayerId);
+ }
+ else if (aOperation.IsEqual ("get"))
+ {
+ di << "Z layer id: " << aContext->GetZLayer (anInterObj);
+ }
+
+ return 0;
+}
+
//=======================================================================
//function : ObjectsCommands
//purpose :
theCommands.Add("vsegment",
"vsegment Name PointName PointName",
__FILE__, VSegment,group);
+
+ theCommands.Add("vobjzlayer",
+ "vobjzlayer : set/get object [layerid] - set or get z layer id for the interactive object",
+ __FILE__, VObjZLayer, group);
}
#include <Draw_Appli.hxx>
#include <Aspect_PrintAlgo.hxx>
#include <Image_PixMap.hxx>
+#include <TColStd_SequenceOfInteger.hxx>
#ifndef WNT
#include <Graphic3d_GraphicDevice.hxx>
#endif
}
+//==============================================================================
+//function : VZLayer
+//purpose : Test z layer operations for v3d viewer
+//==============================================================================
+static int VZLayer (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+{
+ Handle(AIS_InteractiveContext) aContextAIS = ViewerTest::GetAISContext ();
+ if (aContextAIS.IsNull())
+ {
+ di << "Call vinit before!\n";
+ return 1;
+ }
+ else if (argc < 2)
+ {
+ di << "Use: vzlayer " << argv[0];
+ di << " add/del/get [id]\n";
+ di << " add - add new z layer to viewer and print its id\n";
+ di << " del - del z layer by its id\n";
+ di << " get - print sequence of z layers in increasing order of their overlay level\n";
+ di << "id - the layer identificator value defined when removing z layer\n";
+ return 1;
+ }
+
+ const Handle(V3d_Viewer)& aViewer = aContextAIS->CurrentViewer();
+ if (aViewer.IsNull())
+ {
+ di << "No active viewer!\n";
+ return 1;
+ }
+
+ // perform operation
+ TCollection_AsciiString anOp = TCollection_AsciiString (argv[1]);
+ if (anOp == "add")
+ {
+ Standard_Integer aNewId;
+ if (!aViewer->AddZLayer (aNewId))
+ {
+ di << "Impossible to add new z layer!\n";
+ return 1;
+ }
+
+ di << "New z layer added with index: " << aNewId << "\n";
+ }
+ else if (anOp == "del")
+ {
+ if (argc < 3)
+ {
+ di << "Please also provide as argument id of z layer to remove\n";
+ return 1;
+ }
+
+ Standard_Integer aDelId = atoi (argv[2]);
+ if (!aViewer->RemoveZLayer (aDelId))
+ {
+ di << "Impossible to remove the z layer or invalid id!\n";
+ return 1;
+ }
+
+ di << "Z layer " << aDelId << " has been removed\n";
+ }
+ else if (anOp == "get")
+ {
+ TColStd_SequenceOfInteger anIds;
+ aViewer->GetAllZLayers (anIds);
+ for (Standard_Integer aSeqIdx = 1; aSeqIdx <= anIds.Length(); aSeqIdx++)
+ {
+ di << anIds.Value (aSeqIdx) << " ";
+ }
+
+ di << "\n";
+ }
+ else
+ {
+ di << "Invalid operation, please use { add / del / get }\n";
+ return 1;
+ }
+
+ return 0;
+}
+
//=======================================================================
//function : ViewerCommands
//purpose :
theCommands.Add("vprintview" ,
"vprintview : width height filename [algo=0] : Test print algorithm: algo = 0 - stretch, algo = 1 - tile",
__FILE__,VPrintView,group);
-
+ theCommands.Add("vzlayer",
+ "vzlayer : add/del/get [id] : Z layer operations in v3d viewer: add new z layer, delete z layer, get z layer ids",
+ __FILE__,VZLayer,group);
}
---Purpose: Changes the display priority of the structure <AStructure>.
---Category: Private methods
+ AddZLayer ( me : mutable;
+ theLayerId : Integer from Standard )
+ is static private;
+ ---Purpose: Add a new top-level Z layer to the view with ID
+ -- <theLayerId>. The z layer mechanism allows to display
+ -- structures in higher layers in overlay of structures in lower layers.
+ -- The layers in a particular view should be managed centrally
+ -- by its view manager so to avoid IDs mismatching and provide correct
+ -- display of graphics in all views.
+
+ RemoveZLayer ( me : mutable;
+ theLayerId : Integer from Standard )
+ is static private;
+ ---Purpose: Remove z layer from the view by its ID.
+
+ ChangeZLayer ( me : mutable;
+ theStructure : Structure from Graphic3d;
+ theLayerId : Integer from Standard )
+ is static private;
+ ---Purpose: Change Z layer of already displayed structure in the view.
+
Clear ( me : mutable;
AStructure : Structure from Graphic3d;
WithDestruction : Boolean from Standard )
aWidth, aHeight, MyCView, anUnderCLayer, anOverCLayer,
thePrecision, theProgressBarFunc, theProgressObject);
}
+
+//=======================================================================
+//function : AddZLayer
+//purpose :
+//=======================================================================
+
+void Visual3d_View::AddZLayer (const Standard_Integer theLayerId)
+{
+ MyGraphicDriver->AddZLayer (MyCView, theLayerId);
+}
+
+//=======================================================================
+//function : RemoveZLayer
+//purpose :
+//=======================================================================
+
+void Visual3d_View::RemoveZLayer (const Standard_Integer theLayerId)
+{
+ MyGraphicDriver->RemoveZLayer (MyCView, theLayerId);
+}
+
+//=======================================================================
+//function : ChangeZLayer
+//purpose :
+//=======================================================================
+
+void Visual3d_View::ChangeZLayer (const Handle(Graphic3d_Structure)& theStructure,
+ const Standard_Integer theLayerId)
+{
+ MyGraphicDriver->ChangeZLayer (
+ (*(Graphic3d_CStructure*)theStructure->CStructure()), MyCView, theLayerId);
+}
uses
Array2OfReal from TColStd,
+ SequenceOfInteger from TColStd,
+ MapOfInteger from TColStd,
GenId from Aspect,
GraphicDevice from Aspect,
---Purpose: Changes the display priority of the structure <AStructure>.
---Category: Private methods
+ ChangeZLayer ( me : mutable;
+ theStructure : Structure from Graphic3d;
+ theLayerId : Integer from Standard )
+ is redefined static;
+ ---Purpose: Change Z layer for structure. The layer mechanism allows
+ -- to display structures in higher layers in overlay of structures in
+ -- lower layers.
+
+ GetZLayer ( me;
+ theStructure : Structure from Graphic3d )
+ returns Integer from Standard is redefined static;
+ ---Purpose: Get Z layer ID assigned for the structure.
+
+ AddZLayer ( me : mutable;
+ theLayerId : in out Integer from Standard )
+ returns Boolean from Standard is redefined static;
+ ---Purpose: Add a new top-level Z layer and get its ID as
+ -- <theLayerId> value. The method returns Standard_False if the layer
+ -- can not be created. The layer mechanism allows to display
+ -- structures in higher layers in overlay of structures in lower layers.
+
+ RemoveZLayer ( me : mutable;
+ theLayerId : Integer from Standard )
+ returns Boolean from Standard is redefined static;
+ ---Purpose: Remove Z layer with ID <theLayerId>. Method returns
+ -- Standard_False if the layer can not be removed or doesn't exists.
+ -- By default, there are always default bottom-level layer that can't
+ -- be removed.
+
+ GetAllZLayers ( me;
+ theLayerSeq : out SequenceOfInteger from TColStd )
+ is redefined static;
+ ---Purpose: Return all Z layer ids in sequence ordered by overlay level
+ -- from lowest layer to highest ( foreground ). The first layer ID
+ -- in sequence is the default layer that can't be removed.
+
+ getZLayerGenId ( myclass )
+ ---Purpose: Returns global instance of z layer ids generator.
+ ---C++: return &
+ returns GenId from Aspect is protected;
+
+
Clear ( me : mutable;
AStructure : Structure from Graphic3d;
WithDestruction : Boolean from Standard )
-- is managed automatically.
-- Default Standard_False
---Category: Internal methods
---\f
+--
fields
MyZBufferAuto : Boolean from Standard;
MyTransparency : Boolean from Standard;
+ -- Z layer indexes
+ myLayerIds : MapOfInteger from TColStd;
+ myLayerSeq : SequenceOfInteger from TColStd;
+
friends
class View from Visual3d,
#include <Standard_ErrorHandler.hxx>
#include <Aspect.hxx>
+#include <Aspect_IdentDefinitionError.hxx>
#include <Graphic3d_GraphicDriver.hxx>
#include <Graphic3d_MapOfStructure.hxx>
MyZBufferAuto (Standard_False),
MyTransparency (Standard_False)
{
+ // default layer is always presented in display layer sequence
+ // it can not be removed
+ myLayerIds.Add (0);
+ myLayerSeq.Append (0);
-Handle(Aspect_GraphicDriver) agd = aDevice->GraphicDriver ();
-
- MyGraphicDriver = *(Handle(Graphic3d_GraphicDriver) *) &agd;
+ Handle(Aspect_GraphicDriver) agd = aDevice->GraphicDriver ();
+ MyGraphicDriver = *(Handle(Graphic3d_GraphicDriver) *) &agd;
}
//-Destructors
return (MyOverLayer);
}
+
+//=======================================================================
+//function : ChangeZLayer
+//purpose :
+//=======================================================================
+
+void Visual3d_ViewManager::ChangeZLayer (const Handle(Graphic3d_Structure)& theStructure,
+ const Standard_Integer theLayerId)
+{
+ if (!myLayerIds.Contains (theLayerId))
+ return;
+
+ // change display layer for structure in all views
+ if (MyDisplayedStructure.Contains (theStructure))
+ {
+ Visual3d_SetIteratorOfSetOfView aViewIt(MyDefinedView);
+ for ( ; aViewIt.More (); aViewIt.Next ())
+ (aViewIt.Value ())->ChangeZLayer (theStructure, theLayerId);
+ }
+
+ // tell graphic driver to update the structure's display layer
+ MyGraphicDriver->ChangeZLayer (
+ (*(Graphic3d_CStructure*)theStructure->CStructure ()), theLayerId);
+}
+
+//=======================================================================
+//function : GetZLayer
+//purpose :
+//=======================================================================
+
+Standard_Integer Visual3d_ViewManager::GetZLayer (const Handle(Graphic3d_Structure)& theStructure) const
+{
+ Graphic3d_CStructure& aStructure =
+ (*(Graphic3d_CStructure*)theStructure->CStructure ());
+
+ return MyGraphicDriver->GetZLayer (aStructure);
+}
+
+//=======================================================================
+//function : AddZLayer
+//purpose :
+//=======================================================================
+
+Standard_Boolean Visual3d_ViewManager::AddZLayer (Standard_Integer& theLayerId)
+{
+ try
+ {
+ OCC_CATCH_SIGNALS
+ theLayerId = getZLayerGenId ().Next ();
+ myLayerIds.Add (theLayerId);
+ myLayerSeq.Append (theLayerId);
+ }
+ catch (Aspect_IdentDefinitionError)
+ {
+ // new index can't be generated
+ return Standard_False;
+ }
+
+ // tell all managed views to remove display layers
+ Visual3d_SetIteratorOfSetOfView aViewIt(MyDefinedView);
+ for ( ; aViewIt.More (); aViewIt.Next ())
+ (aViewIt.Value ())->AddZLayer (theLayerId);
+
+ return Standard_True;
+}
+
+//=======================================================================
+//function : RemoveZLayer
+//purpose :
+//=======================================================================
+
+Standard_Boolean Visual3d_ViewManager::RemoveZLayer (const Standard_Integer theLayerId)
+{
+ if (!myLayerIds.Contains (theLayerId) || theLayerId == 0)
+ return Standard_False;
+
+ // tell all managed views to remove display layers
+ Visual3d_SetIteratorOfSetOfView aViewIt(MyDefinedView);
+ for ( ; aViewIt.More (); aViewIt.Next ())
+ (aViewIt.Value ())->RemoveZLayer (theLayerId);
+
+ MyGraphicDriver->UnsetZLayer (theLayerId);
+
+ // remove index
+ for (int aIdx = 1; aIdx <= myLayerSeq.Length (); aIdx++)
+ if (myLayerSeq(aIdx) == theLayerId)
+ {
+ myLayerSeq.Remove (aIdx);
+ break;
+ }
+
+ myLayerIds.Remove (theLayerId);
+ getZLayerGenId ().Free (theLayerId);
+
+ return Standard_True;
+}
+
+//=======================================================================
+//function : GetAllZLayers
+//purpose :
+//=======================================================================
+
+void Visual3d_ViewManager::GetAllZLayers (TColStd_SequenceOfInteger& theLayerSeq) const
+{
+ theLayerSeq.Assign (myLayerSeq);
+}
+
+//=======================================================================
+//function : getZLayerGenId
+//purpose :
+//=======================================================================
+
+Aspect_GenId& Visual3d_ViewManager::getZLayerGenId ()
+{
+ static Aspect_GenId aGenId (1, IntegerLast());
+ return aGenId;
+}