1 // Created on: 2012-02-02
2 // Created by: Anton POLETAEV
3 // Copyright (c) 2012-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
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
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.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #ifndef _OpenGl_LayerList_Header
17 #define _OpenGl_LayerList_Header
19 #include <OpenGl_Layer.hxx>
21 #include <InterfaceGraphic_telem.hxx>
23 #include <NCollection_Sequence.hxx>
24 #include <NCollection_DataMap.hxx>
26 class OpenGl_Structure;
27 class Handle(OpenGl_Workspace);
29 typedef NCollection_Sequence<OpenGl_Layer> OpenGl_SequenceOfLayers;
30 typedef NCollection_DataMap<int, int> OpenGl_LayerSeqIds;
32 class OpenGl_LayerList
37 OpenGl_LayerList (const Standard_Integer theNbPriorities = 11);
40 virtual ~OpenGl_LayerList();
42 //! Method returns the number of available priorities
43 Standard_Integer NbPriorities() const { return myNbPriorities; }
45 //! Number of displayed structures
46 Standard_Integer NbStructures() const { return myNbStructures; }
48 //! Return number of structures within immediate layers
49 Standard_Integer NbImmediateStructures() const { return myImmediateNbStructures; }
51 //! Insert a new layer with id.
52 void AddLayer (const Graphic3d_ZLayerId theLayerId);
54 //! Remove layer by its id.
55 void RemoveLayer (const Graphic3d_ZLayerId theLayerId);
57 //! Add structure to list with given priority. The structure will be inserted
58 //! to specified layer. If the layer isn't found, the structure will be put
59 //! to default bottom-level layer.
60 void AddStructure (const OpenGl_Structure* theStruct,
61 const Graphic3d_ZLayerId theLayerId,
62 const Standard_Integer thePriority,
63 Standard_Boolean isForChangePriority = Standard_False);
65 //! Remove structure from structure list and return its previous priority
66 void RemoveStructure (const Handle(Graphic3d_Structure)& theStructure);
68 //! Change structure z layer
69 //! If the new layer is not presented, the structure will be displayed
70 //! in default z layer
71 void ChangeLayer (const OpenGl_Structure* theStructure,
72 const Graphic3d_ZLayerId theOldLayerId,
73 const Graphic3d_ZLayerId theNewLayerId);
75 //! Changes structure priority within its ZLayer
76 void ChangePriority (const OpenGl_Structure* theStructure,
77 const Graphic3d_ZLayerId theLayerId,
78 const Standard_Integer theNewPriority);
80 //! Returns reference to the layer with given ID.
81 OpenGl_Layer& Layer (const Graphic3d_ZLayerId theLayerId);
83 //! Returns reference to the layer with given ID.
84 const OpenGl_Layer& Layer (const Graphic3d_ZLayerId theLayerId) const;
86 //! Assign new settings to the layer.
87 void SetLayerSettings (const Graphic3d_ZLayerId theLayerId,
88 const Graphic3d_ZLayerSettings& theSettings);
90 //! Render this element
91 void Render (const Handle(OpenGl_Workspace)& theWorkspace,
92 const Standard_Boolean theToDrawImmediate) const;
94 //! Returns the set of OpenGL Z-layers.
95 const OpenGl_SequenceOfLayers& Layers() const { return myLayers; }
97 //! Marks BVH tree for given priority list as dirty and
98 //! marks primitive set for rebuild.
99 void InvalidateBVHData (const Graphic3d_ZLayerId theLayerId);
101 //! Returns structure modification state (for ray-tracing).
102 Standard_Size ModificationState() const { return myModificationState; }
106 // number of structures temporary put to default layer
107 OpenGl_SequenceOfLayers myLayers;
108 OpenGl_LayerSeqIds myLayerIds;
110 Standard_Integer myNbPriorities;
111 Standard_Integer myNbStructures;
112 Standard_Integer myImmediateNbStructures; //!< number of structures within immediate layers
114 mutable Standard_Size myModificationState;
118 DEFINE_STANDARD_ALLOC
122 #endif //_OpenGl_LayerList_Header