0022779: Pixel format should be chosen to support stencil buffer
[occt.git] / src / OpenGl / OpenGl_LayerList.hxx
1 // Created on: 2012-02-02
2 // Created by: Anton POLETAEV
3 // Copyright (c) -1999 Matra Datavision
4 // Copyright (c) 2012-2012 OPEN CASCADE SAS
5 //
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
10 //
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13 //
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
20
21
22 #ifndef _OpenGl_LayerList_Header
23 #define _OpenGl_LayerList_Header
24
25 #include <OpenGl_PriorityList.hxx>
26
27 #include <InterfaceGraphic_telem.hxx>
28
29 #include <NCollection_Sequence.hxx>
30 #include <NCollection_DataMap.hxx>
31
32 class OpenGl_Structure;
33 class Handle(OpenGl_Workspace);
34
35 typedef NCollection_Sequence<OpenGl_PriorityList> OpenGl_SequenceOfLayers;
36 typedef NCollection_DataMap<int, int> OpenGl_LayerSeqIds;
37
38 class OpenGl_LayerList
39 {
40  public:
41   
42   //! Constructor
43   OpenGl_LayerList (const Standard_Integer theNbPriorities = 11);
44   
45   //! Destructor
46   virtual ~OpenGl_LayerList ();
47   
48   //! Method returns the number of available priorities
49   Standard_Integer NbPriorities () const;
50
51   //! Number of displayed structures
52   Standard_Integer NbStructures () const;
53
54   //! Insert a new layer with id.
55   void AddLayer (const Standard_Integer theLayerId);
56   
57   //! Check whether the layer with given id is already created.
58   Standard_Boolean HasLayer (const Standard_Integer theLayerId) const;
59   
60   //! Remove layer by its id.
61   void RemoveLayer (const Standard_Integer theLayerId);
62   
63   //! Add structure to list with given priority. The structure will be inserted
64   //! to specified layer. If the layer isn't found, the structure will be put
65   //! to default bottom-level layer.
66   void AddStructure (const OpenGl_Structure *theStructure,
67                      const Standard_Integer  theLayerId,
68                      const Standard_Integer  thePriority);
69   
70   //! Remove structure from structure list and return its previous priority
71   void RemoveStructure (const OpenGl_Structure *theStructure,
72                         const Standard_Integer  theZLayerId);
73   
74   //! Change structure z layer
75   //! If the new layer is not presented, the structure will be displayed
76   //! in default z layer
77   void ChangeLayer (const OpenGl_Structure *theStructure,
78                     const Standard_Integer  theOldLayerId,
79                     const Standard_Integer  theNewLayerId);
80   
81   //! Render this element
82   void Render (const Handle(OpenGl_Workspace) &theWorkspace) const;
83   
84  private:
85   
86   //! Get default layer
87   OpenGl_PriorityList& defaultLayer ();
88   
89  protected:
90
91   // number of structures temporary put to default layer
92   OpenGl_SequenceOfLayers myLayers;
93   OpenGl_LayerSeqIds      myLayerIds;
94   Standard_Integer        myNbPriorities;
95   Standard_Integer        myNbStructures;
96
97  public:
98   DEFINE_STANDARD_ALLOC
99 };
100
101 #endif //_OpenGl_LayerList_Header