0025765: Coding rules - clean up code from obsolete macro checks
[occt.git] / src / Visual3d / Visual3d_ContextView.cxx
CommitLineData
b311480e 1// Copyright (c) 1995-1999 Matra Datavision
973c2be1 2// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 3//
973c2be1 4// This file is part of Open CASCADE Technology software library.
b311480e 5//
d5f74e42 6// This library is free software; you can redistribute it and/or modify it under
7// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 8// by the Free Software Foundation, with special exception defined in the file
9// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10// distribution for complete text of the license and disclaimer of any warranty.
b311480e 11//
973c2be1 12// Alternatively, this file may be used under the terms of Open CASCADE
13// commercial license or contractual agreement.
b311480e 14
7fd59977 15/***********************************************************************
16
81bba717 17 FUNCTION :
7fd59977 18 ----------
81bba717 19 Class Visual3d_ContextView.cxx :
7fd59977 20
81bba717 21 Declaration of variables specific to view contexts.
7fd59977 22
81bba717 23 A view context is defined by :
24 - the activity of aliasing
25 - the activity of depth-cueing
26 - the activity of Z clipping
27 - the activity of defined light sources
28 - the required type of visualization
29 - the model of shading if required
7fd59977 30
7fd59977 31
32************************************************************************/
33
7fd59977 34/*----------------------------------------------------------------------*/
35/*
36 * Includes
37 */
38
39#include <Visual3d_ContextView.ixx>
40
41/*----------------------------------------------------------------------*/
42
43Visual3d_ContextView::Visual3d_ContextView ():
44AliasingIsActive (Standard_False),
45ZcueingIsActive (Standard_False),
46FrontZclippingIsActive (Standard_False),
47BackZclippingIsActive (Standard_False),
48MyZclippingFrontPlane (Standard_ShortReal (1.0)),
49MyZclippingBackPlane (Standard_ShortReal (0.0)),
50MyDepthCueingFrontPlane (Standard_ShortReal (1.0)),
51MyDepthCueingBackPlane (Standard_ShortReal (0.0)),
52MyModel (Visual3d_TOM_NONE),
53MyVisual (Visual3d_TOV_WIREFRAME),
54MyLights (),
7fd59977 55MyTextureEnv(),
a6964ce6 56MySurfaceDetail(Visual3d_TOD_ALL),
4269bd1b 57myClipPlanes()
7fd59977 58{
59}
60
61/*----------------------------------------------------------------------*/
62
63void Visual3d_ContextView::SetAliasingOn () {
64
65 AliasingIsActive = Standard_True;
66
67}
68
69void Visual3d_ContextView::SetAliasingOff () {
70
71 AliasingIsActive = Standard_False;
72
73}
74
75Standard_Boolean Visual3d_ContextView::AliasingIsOn () const {
76
77 return (AliasingIsActive);
78
79}
80
81void Visual3d_ContextView::SetZClippingOn () {
82
83 BackZclippingIsActive = Standard_True;
84 FrontZclippingIsActive = Standard_True;
85
86}
87
88void Visual3d_ContextView::SetZClippingOff () {
89
90 BackZclippingIsActive = Standard_False;
91 FrontZclippingIsActive = Standard_False;
92
93}
94
95Standard_Boolean Visual3d_ContextView::BackZClippingIsOn () const {
96
97 return (BackZclippingIsActive);
98
99}
100
101void Visual3d_ContextView::SetBackZClippingOn () {
102
103 BackZclippingIsActive = Standard_True;
104
105}
106
107void Visual3d_ContextView::SetBackZClippingOff () {
108
109 BackZclippingIsActive = Standard_False;
110
111}
112
113Standard_Boolean Visual3d_ContextView::FrontZClippingIsOn () const {
114
115 return (FrontZclippingIsActive);
116
117}
118
119void Visual3d_ContextView::SetFrontZClippingOn () {
120
121 FrontZclippingIsActive = Standard_True;
122
123}
124
125void Visual3d_ContextView::SetFrontZClippingOff () {
126
127 FrontZclippingIsActive = Standard_False;
128
129}
130
131void Visual3d_ContextView::SetZClippingFrontPlane (const Standard_Real AFront) {
132
7fd59977 133 MyZclippingFrontPlane = Standard_ShortReal (AFront);
134
135}
136
137Standard_Real Visual3d_ContextView::ZClippingFrontPlane () const {
138
139 return (Standard_Real (MyZclippingFrontPlane));
140
141}
142
143void Visual3d_ContextView::SetDepthCueingFrontPlane (const Standard_Real AFront) {
144
7fd59977 145 MyDepthCueingFrontPlane = Standard_ShortReal (AFront);
146
147}
148
149Standard_Real Visual3d_ContextView::DepthCueingFrontPlane () const {
150
151 return (Standard_Real (MyDepthCueingFrontPlane));
152
153}
154
155void Visual3d_ContextView::SetZClippingBackPlane (const Standard_Real ABack) {
156
7fd59977 157 MyZclippingBackPlane = Standard_ShortReal (ABack);
158
159}
160
161Standard_Real Visual3d_ContextView::ZClippingBackPlane () const {
162
163 return (Standard_Real (MyZclippingBackPlane));
164
165}
166
167void Visual3d_ContextView::SetDepthCueingBackPlane (const Standard_Real ABack) {
168
7fd59977 169 MyDepthCueingBackPlane = Standard_ShortReal (ABack);
170
171}
172
173Standard_Real Visual3d_ContextView::DepthCueingBackPlane () const {
174
175 return (Standard_Real (MyDepthCueingBackPlane));
176
177}
178
179void Visual3d_ContextView::SetDepthCueingOn () {
180
181 ZcueingIsActive = Standard_True;
182
183}
184
185void Visual3d_ContextView::SetDepthCueingOff () {
186
187 ZcueingIsActive = Standard_False;
188
189}
190
191Standard_Boolean Visual3d_ContextView::DepthCueingIsOn () const {
192
193 return (ZcueingIsActive);
194
195}
196
197void Visual3d_ContextView::SetModel (const Visual3d_TypeOfModel AModel) {
198
199 MyModel = AModel;
200
201}
202
203Visual3d_TypeOfModel Visual3d_ContextView::Model () const {
204
205 return (MyModel);
206
207}
208
209void Visual3d_ContextView::SetVisualization (const Visual3d_TypeOfVisualization AVisual) {
210
211 MyVisual = AVisual;
212
213}
214
215Visual3d_TypeOfVisualization Visual3d_ContextView::Visualization () const {
216
217 return (MyVisual);
218
219}
220
221void Visual3d_ContextView::SetLightOn (const Handle(Visual3d_Light)& ALight) {
222
223Standard_Integer LengthL = MyLights.Length ();
224Standard_Integer indexL = 0;
225
81bba717 226 // Find light <ALight> in
227 // the sequence of already active lights
7fd59977 228 for (Standard_Integer i=1; i<=LengthL && indexL==0; i++)
229 if ((void *) (MyLights.Value (i)) ==
230 (void *) (ALight.operator->())) indexL = i;
231
81bba717 232 // This is the activation of a new light
7fd59977 233 if (indexL == 0)
234 MyLights.Append ((void *) ALight.operator->());
235
236}
237
238void Visual3d_ContextView::SetLightOff (const Handle(Visual3d_Light)& ALight) {
239
240Standard_Integer LengthL = MyLights.Length ();
241Standard_Integer indexL = 0;
242
81bba717 243 // Find light <ALight> in
244 // the sequence of already active lights
7fd59977 245 for (Standard_Integer i=1; i<=LengthL && indexL==0; i++)
246 if ((void *) (MyLights.Value (i)) ==
247 (void *) (ALight.operator->())) indexL = i;
248
81bba717 249 // This is the activation of a new light
7fd59977 250 if (indexL != 0) MyLights.Remove (indexL);
251
252}
253
54f7544d 254Handle(Visual3d_HSequenceOfLight) Visual3d_ContextView::ActivatedLights () const {
7fd59977 255
54f7544d 256Handle(Visual3d_HSequenceOfLight) SG = new Visual3d_HSequenceOfLight();
7fd59977 257Standard_Integer Length = MyLights.Length ();
258
259 for (Standard_Integer i=1; i<=Length; i++)
54f7544d 260 SG->Append((Visual3d_Light *) (MyLights.Value (i)));
7fd59977 261
262 return (SG);
263
264}
265
266Standard_Integer Visual3d_ContextView::NumberOfActivatedLights () const {
267
268Standard_Integer Length = MyLights.Length ();
269
270 return (Length);
271
272}
273
274Handle(Visual3d_Light) Visual3d_ContextView::ActivatedLight (const Standard_Integer AnIndex) const {
275
276 return (Visual3d_Light *) (MyLights.Value (AnIndex));
277
278}
279
7fd59977 280void Visual3d_ContextView::SetSurfaceDetail(const Visual3d_TypeOfSurfaceDetail TOSD)
281{
282 MySurfaceDetail = TOSD;
283}
284
285
286void Visual3d_ContextView::SetTextureEnv(const Handle(Graphic3d_TextureEnv)& ATexture)
287{
288 MyTextureEnv = ATexture;
289}
290
291
857ffd5e 292Handle(Graphic3d_TextureEnv) Visual3d_ContextView::TextureEnv() const
7fd59977 293{
294 return MyTextureEnv;
295}
296
297
298Visual3d_TypeOfSurfaceDetail Visual3d_ContextView::SurfaceDetail() const
299{
300 return MySurfaceDetail;
301}
4269bd1b 302
51b10cd4 303//=======================================================================
304//function : ClipPlanes
305//purpose :
306//=======================================================================
307const Graphic3d_SequenceOfHClipPlane& Visual3d_ContextView::ClipPlanes() const
4269bd1b 308{
51b10cd4 309 return myClipPlanes;
4269bd1b 310}
311
51b10cd4 312//=======================================================================
313//function : ChangeClipPlanes
314//purpose :
315//=======================================================================
316Graphic3d_SequenceOfHClipPlane& Visual3d_ContextView::ChangeClipPlanes()
4269bd1b 317{
318 return myClipPlanes;
319}