6aca4d39 |
1 | // Created on: 2012-02-02 |
b311480e |
2 | // Created by: Anton POLETAEV |
6aca4d39 |
3 | // Copyright (c) 2012-2014 OPEN CASCADE SAS |
b311480e |
4 | // |
973c2be1 |
5 | // This file is part of Open CASCADE Technology software library. |
b311480e |
6 | // |
d5f74e42 |
7 | // This library is free software; you can redistribute it and/or modify it under |
8 | // the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
9 | // by the Free Software Foundation, with special exception defined in the file |
10 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
11 | // distribution for complete text of the license and disclaimer of any warranty. |
b311480e |
12 | // |
973c2be1 |
13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. |
59f45b7c |
15 | |
16 | #ifndef _OpenGl_LayerList_Header |
17 | #define _OpenGl_LayerList_Header |
18 | |
19 | #include <OpenGl_PriorityList.hxx> |
c5751993 |
20 | #include <OpenGl_Layer.hxx> |
59f45b7c |
21 | |
22 | #include <InterfaceGraphic_telem.hxx> |
23 | |
24 | #include <NCollection_Sequence.hxx> |
25 | #include <NCollection_DataMap.hxx> |
26 | |
27 | class OpenGl_Structure; |
28 | class Handle(OpenGl_Workspace); |
29 | |
c5751993 |
30 | typedef NCollection_Sequence<OpenGl_Layer> OpenGl_SequenceOfLayers; |
59f45b7c |
31 | typedef NCollection_DataMap<int, int> OpenGl_LayerSeqIds; |
32 | |
33 | class OpenGl_LayerList |
34 | { |
35 | public: |
36 | |
37 | //! Constructor |
38 | OpenGl_LayerList (const Standard_Integer theNbPriorities = 11); |
39 | |
40 | //! Destructor |
41 | virtual ~OpenGl_LayerList (); |
42 | |
43 | //! Method returns the number of available priorities |
44 | Standard_Integer NbPriorities () const; |
45 | |
46 | //! Number of displayed structures |
47 | Standard_Integer NbStructures () const; |
48 | |
49 | //! Insert a new layer with id. |
50 | void AddLayer (const Standard_Integer theLayerId); |
51 | |
52 | //! Check whether the layer with given id is already created. |
53 | Standard_Boolean HasLayer (const Standard_Integer theLayerId) const; |
54 | |
55 | //! Remove layer by its id. |
56 | void RemoveLayer (const Standard_Integer theLayerId); |
57 | |
58 | //! Add structure to list with given priority. The structure will be inserted |
59 | //! to specified layer. If the layer isn't found, the structure will be put |
60 | //! to default bottom-level layer. |
61 | void AddStructure (const OpenGl_Structure *theStructure, |
62 | const Standard_Integer theLayerId, |
b7cd4ba7 |
63 | const Standard_Integer thePriority, |
64 | Standard_Boolean isForChangePriority = Standard_False); |
59f45b7c |
65 | |
66 | //! Remove structure from structure list and return its previous priority |
67 | void RemoveStructure (const OpenGl_Structure *theStructure, |
68 | const Standard_Integer theZLayerId); |
69 | |
70 | //! Change structure z layer |
71 | //! If the new layer is not presented, the structure will be displayed |
72 | //! in default z layer |
73 | void ChangeLayer (const OpenGl_Structure *theStructure, |
74 | const Standard_Integer theOldLayerId, |
75 | const Standard_Integer theNewLayerId); |
c5751993 |
76 | |
b7cd4ba7 |
77 | //! Changes structure priority within its ZLayer |
78 | void ChangePriority (const OpenGl_Structure *theStructure, |
79 | const Standard_Integer theLayerId, |
80 | const Standard_Integer theNewPriority); |
81 | |
c5751993 |
82 | //! Returns reference to the layer with given ID. |
83 | OpenGl_Layer& Layer (const Standard_Integer theLayerId); |
84 | |
85 | //! Returns reference to the layer with given ID. |
86 | const OpenGl_Layer& Layer (const Standard_Integer theLayerId) const; |
59f45b7c |
87 | |
88 | //! Render this element |
89 | void Render (const Handle(OpenGl_Workspace) &theWorkspace) const; |
e276548b |
90 | |
91 | //! Returns the set of OpenGL Z-layers. |
92 | const OpenGl_SequenceOfLayers& Layers() const { return myLayers; } |
e276548b |
93 | |
b7cd4ba7 |
94 | //! Marks BVH tree for given priority list as dirty and |
95 | //! marks primitive set for rebuild. |
96 | void InvalidateBVHData (const Standard_Integer theLayerId); |
97 | |
e276548b |
98 | //! Returns structure modification state (for ray-tracing). |
99 | Standard_Size ModificationState() const { return myModificationState; } |
100 | |
59f45b7c |
101 | private: |
102 | |
103 | //! Get default layer |
c5751993 |
104 | OpenGl_Layer& defaultLayer (); |
59f45b7c |
105 | |
106 | protected: |
107 | |
108 | // number of structures temporary put to default layer |
109 | OpenGl_SequenceOfLayers myLayers; |
110 | OpenGl_LayerSeqIds myLayerIds; |
111 | Standard_Integer myNbPriorities; |
112 | Standard_Integer myNbStructures; |
113 | |
e276548b |
114 | mutable Standard_Size myModificationState; |
e276548b |
115 | |
59f45b7c |
116 | public: |
65c62757 |
117 | DEFINE_STANDARD_ALLOC |
59f45b7c |
118 | }; |
119 | |
120 | #endif //_OpenGl_LayerList_Header |