1 -- Created on: 1991-09-05
2 -- Created by: NW,JPB,CAL
3 -- Copyright (c) 1991-1999 Matra Datavision
4 -- Copyright (c) 1999-2012 OPEN CASCADE SAS
6 -- The content of this file is subject to the Open CASCADE Technology Public
7 -- License Version 6.5 (the "License"). You may not use the content of this file
8 -- except in compliance with the License. Please obtain a copy of the License
9 -- at http://www.opencascade.org and read it completely before using this file.
11 -- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 -- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
14 -- The Original Code and all software distributed under the License is
15 -- distributed on an "AS IS" basis, without warranty of any kind, and the
16 -- Initial Developer hereby disclaims all such warranties, including without
17 -- limitation, any warranties of merchantability, fitness for a particular
18 -- purpose or non-infringement. Please see the License for the specific terms
19 -- and conditions governing the rights and limitations under the License.
22 -- 1/08/97 ; PCT : Ajout texture mapping
23 -- 15/01/98 ; FMN : Suppression Hidden Line
25 class ContextView from Visual3d
29 ---Purpose: This class manages the creation and update of
30 -- a visualization context for one view in the viewer.
31 -- A context is defined by :
35 -- The type of visualization.
41 SequenceOfAddress from TColStd,
43 HSetOfLight from Visual3d,
45 TypeOfModel from Visual3d,
46 TypeOfVisualization from Visual3d,
47 TypeOfSurfaceDetail from Visual3d,
48 TextureEnv from Graphic3d,
49 SetOfHClipPlane from Graphic3d
53 ClipDefinitionError from Visual3d,
54 DepthCueingDefinitionError from Visual3d,
55 LightDefinitionError from Visual3d,
56 ZClippingDefinitionError from Visual3d
61 returns ContextView from Visual3d;
63 ---Purpose: Creates a context from default values
66 -- BackZClipping : OFF
67 -- FrontZClipping : OFF
71 -- Type Of Visualization : TOV_WIREFRAME
72 -- Type Of Model : TOM_NONE
73 -- Type Of SurfaceDetail : TOSD_NONE
76 SetSurfaceDetail(me : in out;
77 TOSD : TypeOfSurfaceDetail);
78 ---Purpose: Selects the kind of rendering
79 -- default to: TOSD_NONE
81 SetTextureEnv(me : in out;
82 ATexture : TextureEnv from Graphic3d);
83 ---Purpose: Sets the environment texture to use
84 -- no environment texture by default
87 ---------------------------------------------------
88 -- Category: Methods to modify the class definition
90 ---------------------------------------------------
92 SetAliasingOn ( me : in out )
95 ---Purpose: Activates antialiasing.
96 -- Antialiasing can be activated on all the structures
98 ---Category: Methods to modify the class definition
100 SetAliasingOff ( me : in out )
103 ---Purpose: Deactivates the antialiasing.
104 ---Category: Methods to modify the class definition
106 ---------------------------------------------------
107 -- Category: Methods to modify the class definition
109 ---------------------------------------------------
111 SetDepthCueingBackPlane ( me : in out;
112 ABack : Real from Standard )
114 ---Purpose: Modifies the back depth-cueing plane.
115 -- Category: Methods to modify the class definition
116 -- Warning: Raises DepthCueingDefinitionError if <BackPlane>
117 -- is front of <FrontPlane> and DepthCueing is ON.
118 raises DepthCueingDefinitionError is static;
120 SetDepthCueingFrontPlane ( me : in out;
121 ABack : Real from Standard )
123 ---Purpose: Modifies the front depth-cueing plane.
124 -- Category: Methods to modify the class definition
125 -- Warning: Raises DepthCueingDefinitionError if <BackPlane> is
126 -- front of <FrontPlane> and DepthCueing is ON.
127 raises DepthCueingDefinitionError is static;
129 SetDepthCueingOn ( me : in out )
131 ---Purpose: Activates the depth-cueing.
132 -- Depth-cueing can be activated on all structures
133 -- present in the view.
134 -- Category: Methods to modify the class definition
135 -- Warning: Raises DepthCueingDefinitionError if <BackPlane> is
136 -- front of <FrontPlane>.
137 raises DepthCueingDefinitionError is static;
139 SetDepthCueingOff ( me : in out )
142 ---Purpose: Deactivates the depth-cueing.
143 ---Category: Methods to modify the class definition
145 ---------------------------------------------------
146 -- Category: Methods to modify the class definition
148 ---------------------------------------------------
150 SetClipPlanes (me : in out; thePlanes : SetOfHClipPlane from Graphic3d);
151 ---Purpose: Set list of clip planes to the view context.
152 -- @param thePlanes [in] the clip planes to set.
154 GetClipPlanes (me) returns SetOfHClipPlane from Graphic3d;
155 ---C++: return const&
156 ---Purpose: Get clip planes.
157 -- @return sequence of clip planes.
159 ---------------------------------------------------
160 -- Category: Methods to modify the class definition
162 ---------------------------------------------------
164 SetLightOn ( me : in out;
165 ALight : Light from Visual3d )
168 ---Purpose: Activates the light source <ALight>
169 ---Category: Methods to modify the class definition
171 SetLightOff ( me : in out;
172 ALight : Light from Visual3d )
175 ---Purpose: Deactivates the light source <ALight>
176 ---Category: Methods to modify the class definition
178 ---------------------------------------------------
179 -- Category: Methods to modify the class definition
180 -- Visualization and Shading
181 ---------------------------------------------------
183 SetModel ( me : in out;
184 AModel : TypeOfModel from Visual3d )
187 ---Purpose: Modifies the shading model when the type of
188 -- visualization is TOV_SHADING
190 -- TypeOfModel : TOM_NONE
195 ---Category: Methods to modify the class definition
197 SetVisualization ( me : in out;
198 AVisual : TypeOfVisualization from Visual3d )
201 ---Purpose: Modifies the mode of visualization.
203 -- TypeOfVisualization : TOV_WIREFRAME
206 ---Category: Methods to modify the class definition
208 ---------------------------------------------------
209 -- Category: Methods to modify the class definition
211 ---------------------------------------------------
213 SetZClippingBackPlane ( me : in out;
214 ABack : Real from Standard )
216 ---Purpose: Modifies the back Z-clipping plane.
217 -- Category: Methods to modify the class definition
218 -- Warning: Raises ZClippingDefinitionError if <BackPlane> is
219 -- front of <FrontPlane> and ZClipping is ON.
220 raises ZClippingDefinitionError is static;
222 SetZClippingFrontPlane ( me : in out;
223 AFront : Real from Standard )
225 ---Purpose: Modifies the front Z-clipping plane.
226 -- Category: Methods to modify the class definition
227 -- Warning: Raises ZClippingDefinitionError if <BackPlane> is
228 -- front of <FrontPlane> and ZClipping is ON.
229 raises ZClippingDefinitionError is static;
231 SetZClippingOn ( me : in out )
233 ---Purpose: Activates the Z-clipping planes defined by
234 -- SetZClippingFrontPlane and SetZClippingBackPlane.
235 -- Category: Methods to modify the class definition
236 -- Warning: Raises ZClippingDefinitionError if <BackPlane> is
237 -- front of <FrontPlane>.
238 raises ZClippingDefinitionError is static;
240 SetZClippingOff ( me : in out )
243 ---Purpose: Deactivates the Z-clipping planes defined by
244 -- SetFrontPlane and SetBackPlane.
245 ---Category: Methods to modify the class definition
247 SetFrontZClippingOn ( me: in out )
249 ---Purpose: Activates the front Z-clipping plane defined by
250 -- SetFrontPlane method.
251 ---Category: Methods to modify the class definition
253 raises ZClippingDefinitionError is static;
254 -- if <BackPlane> is front of <FrontPlane>.
256 SetFrontZClippingOff ( me: in out )
259 ---Purpose: Deactivates the front Z-clipping plane defined by
260 -- SetFrontPlane method.
261 ---Category: Methods to modify the class definition
263 SetBackZClippingOn ( me : in out )
265 ---Purpose: Activates the back Z-clipping plane defined by
266 -- SetBackPlane method.
267 -- Category: Methods to modify the class definition
268 -- Warning: Raises ZClippingDefinitionError if <BackPlane> is
269 -- front of <FrontPlane>.
270 raises ZClippingDefinitionError is static;
272 SetBackZClippingOff ( me : in out )
275 ---Purpose: Deactivates the back Z-clipping plane defined by
276 -- SetBackPlane method.
277 ---Category: Methods to modify the class definition
279 ----------------------------
280 -- Category: Inquire methods
281 ----------------------------
283 ActivatedLights ( me )
284 returns HSetOfLight from Visual3d
287 ---Purpose: Returns the group of active light sources
288 -- in the view of context <me>.
289 ---Category: Inquire methods
291 NumberOfActivatedLights ( me )
292 returns Integer from Standard
295 ---Purpose: Returns the number of active light sources
296 -- in the view of context <me>.
297 ---Category: Inquire methods
300 AnIndex : Integer from Standard )
301 returns Light from Visual3d
304 ---Category: Inquire methods
307 returns Boolean from Standard
310 ---Purpose: Returns the activity of the aliasing.
311 ---Category: Inquire methods
313 BackZClippingIsOn ( me )
314 returns Boolean from Standard
317 ---Purpose: Returns the activity of the ZClipping.
318 ---Category: Inquire methods
320 DepthCueingBackPlane ( me )
321 returns Real from Standard
324 ---Purpose: Returns the definition of the back depth-cueing plane.
325 ---Category: Inquire methods
327 DepthCueingFrontPlane ( me )
328 returns Real from Standard
331 ---Purpose: Returns the definition of the front depth-cueing plane.
332 ---Category: Inquire methods
334 DepthCueingIsOn ( me )
335 returns Boolean from Standard
338 ---Purpose: Returns the activity of the depth-cueing.
339 ---Category: Inquire methods
341 FrontZClippingIsOn ( me )
342 returns Boolean from Standard
345 ---Purpose: Returns the activity of the ZClipping.
346 ---Category: Inquire methods
349 returns TypeOfModel from Visual3d
352 ---Purpose: Returns the shading model.
353 ---Category: Inquire methods
356 returns TypeOfVisualization from Visual3d
359 ---Purpose: Returns the mode of visualization.
360 ---Category: Inquire methods
362 ZClippingBackPlane ( me )
363 returns Real from Standard
366 ---Purpose: Returns the definition of the back Z-clipping plane.
367 ---Category: Inquire methods
369 ZClippingFrontPlane ( me )
370 returns Real from Standard
373 ---Purpose: Returns the definition of the front Z-clipping plane.
374 ---Category: Inquire methods
378 returns TypeOfSurfaceDetail from Visual3d;
380 -- purpose: returns the current SurfaceDetail mode
383 TextureEnv(me) returns TextureEnv from Graphic3d;
385 -- purpose: return the current environment texture used
393 -- Class : Visual3d_ContextView
395 -- Purpose : Declaration of variables specific to view contexts.
398 -- Reminders : A view context is defined by :
399 -- - aliasing activity
400 -- - depth-cueing activity
401 -- - Z clipping activity
402 -- - activity of defined light sources
403 -- - the type of visualization
404 -- - the shading model if required
407 -- flag for aliasing activity
408 AliasingIsActive : Boolean from Standard;
410 -- flag for depth cueing activity
411 ZcueingIsActive : Boolean from Standard;
413 -- flag for Z clipping activity
414 FrontZclippingIsActive : Boolean from Standard;
416 -- flag for Z clipping activity
417 BackZclippingIsActive : Boolean from Standard;
419 -- Z clipping, front plane
420 MyZclippingFrontPlane : ShortReal from Standard;
422 -- Z clipping, back plane
423 MyZclippingBackPlane : ShortReal from Standard;
425 -- DepthCueing, front plane
426 MyDepthCueingFrontPlane : ShortReal from Standard;
428 -- DepthCueing, back plane
429 MyDepthCueingBackPlane : ShortReal from Standard;
431 -- the type of shading activated
432 MyModel : TypeOfModel from Visual3d;
434 -- the type of visualization activated
435 MyVisual : TypeOfVisualization from Visual3d;
437 -- the light sources activated
438 MyLights : SequenceOfAddress from TColStd;
440 MyTextureEnv : TextureEnv from Graphic3d;
441 MySurfaceDetail : TypeOfSurfaceDetail from Visual3d;
443 myClipPlanes : SetOfHClipPlane from Graphic3d;