a1954302 |
1 | // Created on: 2011-11-02 |
2 | // Created by: Sergey ZERCHANINOV |
3 | // Copyright (c) 2011-2015 OPEN CASCADE SAS |
c5751993 |
4 | // |
5 | // This file is part of Open CASCADE Technology software library. |
6 | // |
0a36ca0a |
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 |
c5751993 |
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. |
12 | // |
13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. |
15 | |
16 | #ifndef _OpenGl_Layer_Header |
17 | #define _OpenGl_Layer_Header |
18 | |
a1954302 |
19 | #include <NCollection_Sequence.hxx> |
20 | #include <NCollection_Array1.hxx> |
21 | |
22 | #include <InterfaceGraphic_telem.hxx> |
23 | |
24 | #include <Handle_OpenGl_Workspace.hxx> |
25 | #include <OpenGl_BVHClipPrimitiveSet.hxx> |
26 | #include <OpenGl_BVHTreeSelector.hxx> |
27 | |
c5751993 |
28 | #include <Graphic3d_ZLayerSettings.hxx> |
550f3b8b |
29 | #include <OpenGl_GlCore11.hxx> |
c5751993 |
30 | |
31 | class Handle(OpenGl_Workspace); |
32 | |
550f3b8b |
33 | struct OpenGl_GlobalLayerSettings |
34 | { |
35 | GLint DepthFunc; |
36 | GLboolean DepthMask; |
37 | }; |
38 | |
a1954302 |
39 | //! Presentations list sorted within priorities. |
c5751993 |
40 | class OpenGl_Layer |
41 | { |
42 | public: |
43 | |
44 | //! Initializes associated priority list and layer properties |
45 | OpenGl_Layer (const Standard_Integer theNbPriorities = 11); |
46 | |
a1954302 |
47 | //! Destructor. |
48 | virtual ~OpenGl_Layer(); |
49 | |
c5751993 |
50 | //! Returns settings of the layer object. |
a1954302 |
51 | const Graphic3d_ZLayerSettings& LayerSettings() const { return myLayerSettings; }; |
c5751993 |
52 | |
53 | //! Sets settings of the layer object. |
a1954302 |
54 | void SetLayerSettings (const Graphic3d_ZLayerSettings& theSettings) |
c5751993 |
55 | { |
56 | myLayerSettings = theSettings; |
57 | } |
58 | |
59 | //! Returns true if theSetting is enabled for the layer. |
60 | const Standard_Boolean IsSettingEnabled (const Graphic3d_ZLayerSetting theSetting) const |
61 | { |
62 | return myLayerSettings.IsSettingEnabled (theSetting); |
63 | } |
64 | |
a1954302 |
65 | void Add (const OpenGl_Structure* theStruct, |
66 | const Standard_Integer thePriority, |
67 | Standard_Boolean isForChangePriority = Standard_False); |
68 | |
69 | //! Remove structure and returns its priority, if the structure is not found, method returns negative value |
70 | bool Remove (const OpenGl_Structure* theStruct, |
71 | Standard_Integer& thePriority, |
72 | Standard_Boolean isForChangePriority = Standard_False); |
73 | |
74 | //! @return the number of structures |
75 | Standard_Integer NbStructures() const { return myNbStructures; } |
76 | |
77 | //! Returns the number of available priority levels |
78 | Standard_Integer NbPriorities() const { return myArray.Length(); } |
79 | |
80 | //! Append layer of acceptable type (with similar number of priorities or less). |
81 | //! Returns Standard_False if the list can not be accepted. |
82 | Standard_Boolean Append (const OpenGl_Layer& theOther); |
83 | |
84 | //! Returns array of OpenGL structures. |
85 | const OpenGl_ArrayOfStructure& ArrayOfStructures() const { return myArray; } |
c5751993 |
86 | |
a1954302 |
87 | //! Marks BVH tree for given priority list as dirty and |
88 | //! marks primitive set for rebuild. |
89 | void InvalidateBVHData(); |
c5751993 |
90 | |
a1954302 |
91 | // Render all structures. |
92 | void Render (const Handle(OpenGl_Workspace)& theWorkspace, |
93 | const OpenGl_GlobalLayerSettings& theDefaultSettings) const; |
94 | |
95 | protected: |
96 | |
97 | //! Traverses through BVH tree to determine which structures are in view volume. |
98 | void traverse (OpenGl_BVHTreeSelector& theSelector) const; |
99 | |
100 | //! Iterates through the hierarchical list of existing structures and renders them all. |
101 | void renderAll (const Handle(OpenGl_Workspace)& theWorkspace) const; |
102 | |
103 | //! Iterates through the hierarchical list of existing structures and renders only overlapping ones. |
104 | void renderTraverse (const Handle(OpenGl_Workspace)& theWorkspace) const; |
c5751993 |
105 | |
106 | private: |
107 | |
a1954302 |
108 | OpenGl_ArrayOfStructure myArray; |
109 | Standard_Integer myNbStructures; |
110 | Graphic3d_ZLayerSettings myLayerSettings; //!< Layer setting flags |
111 | mutable OpenGl_BVHClipPrimitiveSet myBVHPrimitives; //<! Set of OpenGl_Structures for building BVH tree |
112 | mutable Standard_Boolean myBVHIsLeftChildQueuedFirst; //<! Is needed for implementation of stochastic order of BVH traverse |
113 | mutable Standard_Boolean myIsBVHPrimitivesNeedsReset; //<! Defines if the primitive set for BVH is outdated |
114 | |
115 | public: |
116 | |
117 | DEFINE_STANDARD_ALLOC |
c5751993 |
118 | |
c5751993 |
119 | }; |
a1954302 |
120 | |
c5751993 |
121 | #endif //_OpenGl_Layer_Header |