0027341: Incorrect exact HLR results
[occt.git] / src / OpenGl / OpenGl_LayerList.hxx
CommitLineData
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
c5751993 19#include <OpenGl_Layer.hxx>
91c60b57 20#include <OpenGl_LayerFilter.hxx>
59f45b7c 21
22#include <InterfaceGraphic_telem.hxx>
23
24#include <NCollection_Sequence.hxx>
25#include <NCollection_DataMap.hxx>
26
27class OpenGl_Structure;
59f45b7c 28
c5751993 29typedef NCollection_Sequence<OpenGl_Layer> OpenGl_SequenceOfLayers;
59f45b7c 30typedef NCollection_DataMap<int, int> OpenGl_LayerSeqIds;
31
32class OpenGl_LayerList
33{
a1954302 34public:
35
59f45b7c 36 //! Constructor
37 OpenGl_LayerList (const Standard_Integer theNbPriorities = 11);
a1954302 38
59f45b7c 39 //! Destructor
a1954302 40 virtual ~OpenGl_LayerList();
41
59f45b7c 42 //! Method returns the number of available priorities
a1954302 43 Standard_Integer NbPriorities() const { return myNbPriorities; }
59f45b7c 44
45 //! Number of displayed structures
a1954302 46 Standard_Integer NbStructures() const { return myNbStructures; }
47
48 //! Return number of structures within immediate layers
49 Standard_Integer NbImmediateStructures() const { return myImmediateNbStructures; }
59f45b7c 50
51 //! Insert a new layer with id.
a1954302 52 void AddLayer (const Graphic3d_ZLayerId theLayerId);
53
59f45b7c 54 //! Remove layer by its id.
a1954302 55 void RemoveLayer (const Graphic3d_ZLayerId theLayerId);
56
59f45b7c 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.
a1954302 60 void AddStructure (const OpenGl_Structure* theStruct,
61 const Graphic3d_ZLayerId theLayerId,
62 const Standard_Integer thePriority,
63 Standard_Boolean isForChangePriority = Standard_False);
64
59f45b7c 65 //! Remove structure from structure list and return its previous priority
c357e426 66 void RemoveStructure (const OpenGl_Structure* theStructure);
a1954302 67
59f45b7c 68 //! Change structure z layer
69 //! If the new layer is not presented, the structure will be displayed
70 //! in default z layer
a1954302 71 void ChangeLayer (const OpenGl_Structure* theStructure,
72 const Graphic3d_ZLayerId theOldLayerId,
73 const Graphic3d_ZLayerId theNewLayerId);
c5751993 74
b7cd4ba7 75 //! Changes structure priority within its ZLayer
a1954302 76 void ChangePriority (const OpenGl_Structure* theStructure,
77 const Graphic3d_ZLayerId theLayerId,
78 const Standard_Integer theNewPriority);
b7cd4ba7 79
c5751993 80 //! Returns reference to the layer with given ID.
a1954302 81 OpenGl_Layer& Layer (const Graphic3d_ZLayerId theLayerId);
c5751993 82
83 //! Returns reference to the layer with given ID.
a1954302 84 const OpenGl_Layer& Layer (const Graphic3d_ZLayerId theLayerId) const;
85
86 //! Assign new settings to the layer.
87 void SetLayerSettings (const Graphic3d_ZLayerId theLayerId,
88 const Graphic3d_ZLayerSettings& theSettings);
89
59f45b7c 90 //! Render this element
a1954302 91 void Render (const Handle(OpenGl_Workspace)& theWorkspace,
91c60b57 92 const Standard_Boolean theToDrawImmediate,
93 const OpenGl_LayerFilter theLayersToProcess) const;
e276548b 94
95 //! Returns the set of OpenGL Z-layers.
96 const OpenGl_SequenceOfLayers& Layers() const { return myLayers; }
e276548b 97
b7cd4ba7 98 //! Marks BVH tree for given priority list as dirty and
99 //! marks primitive set for rebuild.
a1954302 100 void InvalidateBVHData (const Graphic3d_ZLayerId theLayerId);
b7cd4ba7 101
e276548b 102 //! Returns structure modification state (for ray-tracing).
103 Standard_Size ModificationState() const { return myModificationState; }
104
a1954302 105protected:
59f45b7c 106
107 // number of structures temporary put to default layer
108 OpenGl_SequenceOfLayers myLayers;
109 OpenGl_LayerSeqIds myLayerIds;
a1954302 110
59f45b7c 111 Standard_Integer myNbPriorities;
112 Standard_Integer myNbStructures;
a1954302 113 Standard_Integer myImmediateNbStructures; //!< number of structures within immediate layers
59f45b7c 114
e276548b 115 mutable Standard_Size myModificationState;
e276548b 116
a1954302 117public:
118
65c62757 119 DEFINE_STANDARD_ALLOC
a1954302 120
59f45b7c 121};
122
123#endif //_OpenGl_LayerList_Header