0022048: Visualization, AIS_InteractiveContext - single object selection should alway...
[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
7c3ef2f7 17#include <gp_XYZ.hxx>
18#include <Geom_Transformation.hxx>
19#include <Graphic3d_PolygonOffset.hxx>
20#include <TCollection_AsciiString.hxx>
c5751993 21
22enum Graphic3d_ZLayerSetting
23{
24 Graphic3d_ZLayerDepthTest = 1,
25 Graphic3d_ZLayerDepthWrite = 2,
26 Graphic3d_ZLayerDepthClear = 4,
27 Graphic3d_ZLayerDepthOffset = 8
28};
29
a1954302 30//! Structure defines list of ZLayer properties.
c5751993 31struct Graphic3d_ZLayerSettings
32{
a1954302 33
34 //! Default settings.
c5751993 35 Graphic3d_ZLayerSettings()
7c3ef2f7 36 : myIsImmediate (Standard_False),
37 myUseEnvironmentTexture (Standard_True),
38 myToEnableDepthTest (Standard_True),
39 myToEnableDepthWrite(Standard_True),
40 myToClearDepth (Standard_True) {}
41
42 //! Return user-provided name.
43 const TCollection_AsciiString& Name() const { return myName; }
44
45 //! Set custom name.
46 void SetName (const TCollection_AsciiString& theName) { myName = theName; }
47
48 //! Return the origin of all objects within the layer.
49 const gp_XYZ& Origin() const { return myOrigin; }
50
51 //! Return the transformation to the origin.
52 const Handle(Geom_Transformation)& OriginTransformation() const { return myOriginTrsf; }
53
54 //! Set the origin of all objects within the layer.
55 void SetOrigin (const gp_XYZ& theOrigin)
56 {
57 myOrigin = theOrigin;
58 myOriginTrsf.Nullify();
59 if (!theOrigin.IsEqual (gp_XYZ(0.0, 0.0, 0.0), gp::Resolution()))
60 {
61 myOriginTrsf = new Geom_Transformation();
62 }
63 }
64
65 //! Return true if this layer should be drawn after all normal (non-immediate) layers.
66 Standard_Boolean IsImmediate() const { return myIsImmediate; }
67
68 //! Set the flag indicating the immediate layer, which should be drawn after all normal (non-immediate) layers.
69 void SetImmediate (const Standard_Boolean theValue) { myIsImmediate = theValue; }
70
71 //! Return flag to allow/prevent environment texture mapping usage for specific layer.
72 Standard_Boolean UseEnvironmentTexture() const { return myUseEnvironmentTexture; }
73
74 //! Set the flag to allow/prevent environment texture mapping usage for specific layer.
75 void SetEnvironmentTexture (const Standard_Boolean theValue) { myUseEnvironmentTexture = theValue; }
76
77 //! Return true if depth test should be enabled.
78 Standard_Boolean ToEnableDepthTest() const { return myToEnableDepthTest; }
79
80 //! Set if depth test should be enabled.
81 void SetEnableDepthTest(const Standard_Boolean theValue) { myToEnableDepthTest = theValue; }
82
83 //! Return true depth values should be written during rendering.
84 Standard_Boolean ToEnableDepthWrite() const { return myToEnableDepthWrite; }
85
86 //! Set if depth values should be written during rendering.
87 void SetEnableDepthWrite (const Standard_Boolean theValue) { myToEnableDepthWrite = theValue; }
88
89 //! Return true if depth values should be cleared before drawing the layer.
90 Standard_Boolean ToClearDepth() const { return myToClearDepth; }
91
92 //! Set if depth values should be cleared before drawing the layer.
93 void SetClearDepth (const Standard_Boolean theValue) { myToClearDepth = theValue; }
94
95 //! Return glPolygonOffset() arguments.
96 const Graphic3d_PolygonOffset& PolygonOffset() const { return myPolygonOffset; }
97
98 //! Setup glPolygonOffset() arguments.
99 void SetPolygonOffset (const Graphic3d_PolygonOffset& theParams) { myPolygonOffset = theParams; }
100
101 //! Modify glPolygonOffset() arguments.
102 Graphic3d_PolygonOffset& ChangePolygonOffset() { return myPolygonOffset; }
c5751993 103
104 //! Returns true if theSetting is enabled.
7c3ef2f7 105 Standard_DEPRECATED("Deprecated method IsSettingEnabled() should be replaced by individual property getters")
487bf1ce 106 Standard_Boolean IsSettingEnabled (const Graphic3d_ZLayerSetting theSetting) const
c5751993 107 {
7c3ef2f7 108 switch (theSetting)
109 {
110 case Graphic3d_ZLayerDepthTest: return myToEnableDepthTest;
111 case Graphic3d_ZLayerDepthWrite: return myToEnableDepthWrite;
112 case Graphic3d_ZLayerDepthClear: return myToClearDepth;
113 case Graphic3d_ZLayerDepthOffset: return myPolygonOffset.Mode != Aspect_POM_Off;
114 }
115 return Standard_False;
c5751993 116 }
117
118 //! Enables theSetting
7c3ef2f7 119 Standard_DEPRECATED("Deprecated method EnableSetting() should be replaced by individual property getters")
c5751993 120 void EnableSetting (const Graphic3d_ZLayerSetting theSetting)
121 {
7c3ef2f7 122 switch (theSetting)
123 {
124 case Graphic3d_ZLayerDepthTest: myToEnableDepthTest = Standard_True; return;
125 case Graphic3d_ZLayerDepthWrite: myToEnableDepthWrite = Standard_True; return;
126 case Graphic3d_ZLayerDepthClear: myToClearDepth = Standard_True; return;
127 case Graphic3d_ZLayerDepthOffset: myPolygonOffset.Mode = Aspect_POM_Fill; return;
128 }
c5751993 129 }
130
131 //! Disables theSetting
7c3ef2f7 132 Standard_DEPRECATED("Deprecated method DisableSetting() should be replaced by individual property getters")
c5751993 133 void DisableSetting (const Graphic3d_ZLayerSetting theSetting)
134 {
7c3ef2f7 135 switch (theSetting)
136 {
137 case Graphic3d_ZLayerDepthTest: myToEnableDepthTest = Standard_False; return;
138 case Graphic3d_ZLayerDepthWrite: myToEnableDepthWrite = Standard_False; return;
139 case Graphic3d_ZLayerDepthClear: myToClearDepth = Standard_False; return;
140 case Graphic3d_ZLayerDepthOffset: myPolygonOffset.Mode = Aspect_POM_Off; return;
141 }
c5751993 142 }
143
144 //! Sets minimal possible positive depth offset.
c5751993 145 void SetDepthOffsetPositive()
146 {
7c3ef2f7 147 myPolygonOffset.Mode = Aspect_POM_Fill;
148 myPolygonOffset.Factor = 1.0f;
149 myPolygonOffset.Units = 1.0f;
c5751993 150 }
151
152 //! Sets minimal possible negative depth offset.
c5751993 153 void SetDepthOffsetNegative()
154 {
7c3ef2f7 155 myPolygonOffset.Mode = Aspect_POM_Fill;
156 myPolygonOffset.Factor = 1.0f;
157 myPolygonOffset.Units =-1.0f;
c5751993 158 }
159
7c3ef2f7 160protected:
a1954302 161
7c3ef2f7 162 TCollection_AsciiString myName; //!< user-provided name
163 Handle(Geom_Transformation) myOriginTrsf; //!< transformation to the origin
164 gp_XYZ myOrigin; //!< the origin of all objects within the layer
165 Graphic3d_PolygonOffset myPolygonOffset; //!< glPolygonOffset() arguments
166 Standard_Boolean myIsImmediate; //!< immediate layer will be drawn after all normal layers
167 Standard_Boolean myUseEnvironmentTexture; //!< flag to allow/prevent environment texture mapping usage for specific layer
168 Standard_Boolean myToEnableDepthTest; //!< option to enable depth test
169 Standard_Boolean myToEnableDepthWrite; //!< option to enable write depth values
170 Standard_Boolean myToClearDepth; //!< option to clear depth values before drawing the layer
c5751993 171
c5751993 172};
173
174#endif // _Graphic3d_ZLayerSettings_HeaderFile