1 /***********************************************************************
5 Classe Visual3d_ContextView.cxx :
7 Declaration des variables specifiques aux contextes des vues.
9 Un contexte de vues est defini par :
10 - l'activite de l'aliasing
11 - l'activite du depth-cueing
12 - l'activite du Z clipping
13 - l'activite des sources lumineuses definies
14 - le type de visualisation demande
15 - le modele de shading si besoin est
17 HISTORIQUE DES MODIFICATIONS :
18 --------------------------------
19 Mars 1992 : NW,JPB,CAL ; Creation.
20 01-08-97 : PCT ; Ajout support texture mapping
21 01-10-97 : CAL ; Retrait de DownCast.
23 ************************************************************************/
25 #define BUC60572 //GG 03-08-99 Move Zcueing and Zclipping front & back planes
26 // coherence checking in Visual3d_View::SetContext()
29 /*----------------------------------------------------------------------*/
34 #include <Visual3d_ContextView.ixx>
36 /*----------------------------------------------------------------------*/
38 Visual3d_ContextView::Visual3d_ContextView ():
39 AliasingIsActive (Standard_False),
40 ZcueingIsActive (Standard_False),
41 FrontZclippingIsActive (Standard_False),
42 BackZclippingIsActive (Standard_False),
43 MyZclippingFrontPlane (Standard_ShortReal (1.0)),
44 MyZclippingBackPlane (Standard_ShortReal (0.0)),
45 MyDepthCueingFrontPlane (Standard_ShortReal (1.0)),
46 MyDepthCueingBackPlane (Standard_ShortReal (0.0)),
47 MyModel (Visual3d_TOM_NONE),
48 MyVisual (Visual3d_TOV_WIREFRAME),
52 MySurfaceDetail(Visual3d_TOD_NONE)
56 /*----------------------------------------------------------------------*/
58 void Visual3d_ContextView::SetAliasingOn () {
60 AliasingIsActive = Standard_True;
64 void Visual3d_ContextView::SetAliasingOff () {
66 AliasingIsActive = Standard_False;
70 Standard_Boolean Visual3d_ContextView::AliasingIsOn () const {
72 return (AliasingIsActive);
76 void Visual3d_ContextView::SetZClippingOn () {
78 BackZclippingIsActive = Standard_True;
79 FrontZclippingIsActive = Standard_True;
83 void Visual3d_ContextView::SetZClippingOff () {
85 BackZclippingIsActive = Standard_False;
86 FrontZclippingIsActive = Standard_False;
90 Standard_Boolean Visual3d_ContextView::BackZClippingIsOn () const {
92 return (BackZclippingIsActive);
96 void Visual3d_ContextView::SetBackZClippingOn () {
98 BackZclippingIsActive = Standard_True;
102 void Visual3d_ContextView::SetBackZClippingOff () {
104 BackZclippingIsActive = Standard_False;
108 Standard_Boolean Visual3d_ContextView::FrontZClippingIsOn () const {
110 return (FrontZclippingIsActive);
114 void Visual3d_ContextView::SetFrontZClippingOn () {
116 FrontZclippingIsActive = Standard_True;
120 void Visual3d_ContextView::SetFrontZClippingOff () {
122 FrontZclippingIsActive = Standard_False;
126 void Visual3d_ContextView::SetZClippingFrontPlane (const Standard_Real AFront) {
129 if ( (FrontZclippingIsActive) && (BackZclippingIsActive) &&
130 (MyZclippingBackPlane >= AFront) )
131 Visual3d_ZClippingDefinitionError::Raise
132 ("Bad value for ZClippingFrontPlane");
135 MyZclippingFrontPlane = Standard_ShortReal (AFront);
139 Standard_Real Visual3d_ContextView::ZClippingFrontPlane () const {
141 return (Standard_Real (MyZclippingFrontPlane));
145 void Visual3d_ContextView::SetDepthCueingFrontPlane (const Standard_Real AFront) {
148 if ( (ZcueingIsActive) && (MyDepthCueingBackPlane >= AFront) )
149 Visual3d_DepthCueingDefinitionError::Raise
150 ("Bad value for DepthCueingFrontPlane");
153 MyDepthCueingFrontPlane = Standard_ShortReal (AFront);
157 Standard_Real Visual3d_ContextView::DepthCueingFrontPlane () const {
159 return (Standard_Real (MyDepthCueingFrontPlane));
163 void Visual3d_ContextView::SetZClippingBackPlane (const Standard_Real ABack) {
166 if ( (FrontZclippingIsActive) && (FrontZclippingIsActive) &&
167 (MyZclippingFrontPlane <= ABack) )
168 Visual3d_ZClippingDefinitionError::Raise
169 ("Bad value for ZClippingBackPlane");
172 MyZclippingBackPlane = Standard_ShortReal (ABack);
176 Standard_Real Visual3d_ContextView::ZClippingBackPlane () const {
178 return (Standard_Real (MyZclippingBackPlane));
182 void Visual3d_ContextView::SetDepthCueingBackPlane (const Standard_Real ABack) {
185 if ( (ZcueingIsActive) && (MyDepthCueingFrontPlane <= ABack) )
186 Visual3d_DepthCueingDefinitionError::Raise
187 ("Bad value for DepthCueingBackPlane");
190 MyDepthCueingBackPlane = Standard_ShortReal (ABack);
194 Standard_Real Visual3d_ContextView::DepthCueingBackPlane () const {
196 return (Standard_Real (MyDepthCueingBackPlane));
200 void Visual3d_ContextView::SetDepthCueingOn () {
202 ZcueingIsActive = Standard_True;
206 void Visual3d_ContextView::SetDepthCueingOff () {
208 ZcueingIsActive = Standard_False;
212 Standard_Boolean Visual3d_ContextView::DepthCueingIsOn () const {
214 return (ZcueingIsActive);
218 void Visual3d_ContextView::SetModel (const Visual3d_TypeOfModel AModel) {
224 Visual3d_TypeOfModel Visual3d_ContextView::Model () const {
230 void Visual3d_ContextView::SetVisualization (const Visual3d_TypeOfVisualization AVisual) {
236 Visual3d_TypeOfVisualization Visual3d_ContextView::Visualization () const {
242 void Visual3d_ContextView::SetLightOn (const Handle(Visual3d_Light)& ALight) {
244 Standard_Integer LengthL = MyLights.Length ();
245 Standard_Integer indexL = 0;
247 // Recherche de la light <ALight> dans la
248 // sequence des lights deja allumees
249 for (Standard_Integer i=1; i<=LengthL && indexL==0; i++)
250 if ((void *) (MyLights.Value (i)) ==
251 (void *) (ALight.operator->())) indexL = i;
253 // Il s'agit d'une nouvelle light a activer
255 MyLights.Append ((void *) ALight.operator->());
259 void Visual3d_ContextView::SetLightOff (const Handle(Visual3d_Light)& ALight) {
261 Standard_Integer LengthL = MyLights.Length ();
262 Standard_Integer indexL = 0;
264 // Recherche de la light <ALight> dans la
265 // sequence des lights deja allumees
266 for (Standard_Integer i=1; i<=LengthL && indexL==0; i++)
267 if ((void *) (MyLights.Value (i)) ==
268 (void *) (ALight.operator->())) indexL = i;
270 // Il s'agit d'une light allumee
271 if (indexL != 0) MyLights.Remove (indexL);
275 Handle(Visual3d_HSetOfLight) Visual3d_ContextView::ActivatedLights () const {
277 Handle(Visual3d_HSetOfLight) SG = new Visual3d_HSetOfLight ();
278 Standard_Integer Length = MyLights.Length ();
280 for (Standard_Integer i=1; i<=Length; i++)
281 SG->Add ((Visual3d_Light *) (MyLights.Value (i)));
287 Standard_Integer Visual3d_ContextView::NumberOfActivatedLights () const {
289 Standard_Integer Length = MyLights.Length ();
295 Handle(Visual3d_Light) Visual3d_ContextView::ActivatedLight (const Standard_Integer AnIndex) const {
297 return (Visual3d_Light *) (MyLights.Value (AnIndex));
301 void Visual3d_ContextView::SetClipPlaneOn (const Handle(Visual3d_ClipPlane)& AClipPlane) {
303 Standard_Integer LengthC = MyClipPlanes.Length ();
304 Standard_Integer indexC = 0;
306 // Recherche du plan <AClipPlane> dans la
307 // sequence des plans deja actives
308 for (Standard_Integer i=1; i<=LengthC && indexC==0; i++)
309 if ((void *) (MyClipPlanes.Value (i)) ==
310 (void *) (AClipPlane.operator->())) indexC = i;
312 // Il s'agit d'un nouveau plan a activer
314 MyClipPlanes.Append ((void *) AClipPlane.operator->());
318 void Visual3d_ContextView::SetClipPlaneOff (const Handle(Visual3d_ClipPlane)& AClipPlane) {
320 Standard_Integer LengthC = MyClipPlanes.Length ();
321 Standard_Integer indexC = 0;
323 // Recherche du plan <AClipPlane> dans la
324 // sequence des plans deja actives
325 for (Standard_Integer i=1; i<=LengthC && indexC==0; i++)
326 if ((void *) (MyClipPlanes.Value (i)) ==
327 (void *) (AClipPlane.operator->())) indexC = i;
329 // Il s'agit d'un plane actif
330 if (indexC != 0) MyClipPlanes.Remove (indexC);
334 Handle(Visual3d_HSetOfClipPlane) Visual3d_ContextView::ActivatedClipPlanes () const {
336 Handle(Visual3d_HSetOfClipPlane) SG = new Visual3d_HSetOfClipPlane ();
337 Standard_Integer Length = MyClipPlanes.Length ();
339 for (Standard_Integer i=1; i<=Length; i++)
340 SG->Add ((Visual3d_ClipPlane *) (MyClipPlanes.Value (i)));
346 Standard_Integer Visual3d_ContextView::NumberOfActivatedClipPlanes () const {
348 Standard_Integer Length = MyClipPlanes.Length ();
354 Handle(Visual3d_ClipPlane) Visual3d_ContextView::ActivatedClipPlane (const Standard_Integer AnIndex) const {
356 return (Visual3d_ClipPlane *) (MyClipPlanes.Value (AnIndex));
360 void Visual3d_ContextView::SetSurfaceDetail(const Visual3d_TypeOfSurfaceDetail TOSD)
362 MySurfaceDetail = TOSD;
366 void Visual3d_ContextView::SetTextureEnv(const Handle(Graphic3d_TextureEnv)& ATexture)
368 MyTextureEnv = ATexture;
372 Handle_Graphic3d_TextureEnv Visual3d_ContextView::TextureEnv() const
378 Visual3d_TypeOfSurfaceDetail Visual3d_ContextView::SurfaceDetail() const
380 return MySurfaceDetail;