0024394: Visualization - implement more general way for rendering of immediate objects
[occt.git] / src / Graphic3d / Graphic3d_ZLayerSettings.hxx
CommitLineData
c5751993 1// Copyright (c) 2014 OPEN CASCADE SAS
2//
3// This file is part of Open CASCADE Technology software library.
4//
0a36ca0a 5// This library is free software; you can redistribute it and/or modify it under
6// the terms of the GNU Lesser General Public License version 2.1 as published
c5751993 7// by the Free Software Foundation, with special exception defined in the file
8// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9// distribution for complete text of the license and disclaimer of any warranty.
10//
11// Alternatively, this file may be used under the terms of Open CASCADE
12// commercial license or contractual agreement.
13
14#ifndef _Graphic3d_ZLayerSettings_HeaderFile
15#define _Graphic3d_ZLayerSettings_HeaderFile
16
17#include <Standard_TypeDef.hxx>
18
19enum Graphic3d_ZLayerSetting
20{
21 Graphic3d_ZLayerDepthTest = 1,
22 Graphic3d_ZLayerDepthWrite = 2,
23 Graphic3d_ZLayerDepthClear = 4,
24 Graphic3d_ZLayerDepthOffset = 8
25};
26
a1954302 27//! Structure defines list of ZLayer properties.
c5751993 28struct Graphic3d_ZLayerSettings
29{
a1954302 30
31 //! Default settings.
c5751993 32 Graphic3d_ZLayerSettings()
33 : DepthOffsetFactor (1.0f),
34 DepthOffsetUnits (1.0f),
35 Flags (Graphic3d_ZLayerDepthTest
36 | Graphic3d_ZLayerDepthWrite
a1954302 37 | Graphic3d_ZLayerDepthClear),
38 IsImmediate (false)
c5751993 39 {}
40
41 //! Returns true if theSetting is enabled.
42 const Standard_Boolean IsSettingEnabled (const Graphic3d_ZLayerSetting theSetting) const
43 {
44 return (Flags & theSetting) == theSetting;
45 }
46
47 //! Enables theSetting
48 void EnableSetting (const Graphic3d_ZLayerSetting theSetting)
49 {
50 Flags = Flags | theSetting;
51 }
52
53 //! Disables theSetting
54 void DisableSetting (const Graphic3d_ZLayerSetting theSetting)
55 {
56 Flags = Flags & (~theSetting);
57 }
58
59 //! Sets minimal possible positive depth offset.
60 //! Access DepthOffsetFactor and DepthOffsetUnits values for manual offset control.
61 void SetDepthOffsetPositive()
62 {
63 DepthOffsetFactor = 1.f;
64 DepthOffsetUnits = 1.f;
65 EnableSetting (Graphic3d_ZLayerDepthOffset);
66 }
67
68 //! Sets minimal possible negative depth offset.
69 //! Access DepthOffsetFactor and DepthOffsetUnits values for manual offset control.
70 void SetDepthOffsetNegative()
71 {
72 DepthOffsetFactor = 1.f;
73 DepthOffsetUnits = -1.f;
74 EnableSetting (Graphic3d_ZLayerDepthOffset);
75 }
76
a1954302 77public:
78
79 Standard_ShortReal DepthOffsetFactor; //!< factor argument value for OpenGl glPolygonOffset function
80 Standard_ShortReal DepthOffsetUnits; //!< units argument value for OpenGl glPolygonOffset function
81 Standard_Integer Flags; //!< storage field for settings
82 bool IsImmediate; //!< immediate layer will be drawn after all normal layers
c5751993 83
c5751993 84};
85
86#endif // _Graphic3d_ZLayerSettings_HeaderFile