b5fb3986bfc93680e03f0e9fb0fe9603dad443bd
[occt.git] / src / Graphic3d / Graphic3d_ZLayerSettings.hxx
1 // Copyright (c) 2014 OPEN CASCADE SAS
2 //
3 // This file is part of Open CASCADE Technology software library.
4 //
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
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
19 enum Graphic3d_ZLayerSetting
20 {
21   Graphic3d_ZLayerDepthTest = 1,
22   Graphic3d_ZLayerDepthWrite = 2,
23   Graphic3d_ZLayerDepthClear = 4,
24   Graphic3d_ZLayerDepthOffset = 8
25 };
26
27 //! Structure defines list of ZLayer properties.
28 struct Graphic3d_ZLayerSettings
29 {
30
31   //! Default settings.
32   Graphic3d_ZLayerSettings()
33     : DepthOffsetFactor (1.0f),
34       DepthOffsetUnits  (1.0f),
35       Flags (Graphic3d_ZLayerDepthTest
36            | Graphic3d_ZLayerDepthWrite
37            | Graphic3d_ZLayerDepthClear),
38       IsImmediate (false)
39   {}
40
41   //! Returns true if theSetting is enabled.
42   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
77 public:
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
83
84 };
85
86 #endif // _Graphic3d_ZLayerSettings_HeaderFile