0024704: Visualization - inherit OpenGl_Structure from Graphic3d_CStructure
[occt.git] / src / Visual3d / Visual3d_View.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
17 FONCTION :
18 ----------
19 Classe Visual3d_View.cxx :
20
21
81bba717 22 Declaration of variables specific to views.
7fd59977 23
81bba717 24 A view is defined by :
25 - ViewManager
26 - ContextView
7fd59977 27
28 HISTORIQUE DES MODIFICATIONS :
29 --------------------------------
30 Mars 1992 : NW,JPB,CAL ; Creation.
31 04-02-97 : FMN ; Suppression de PSOutput, XWDOutput ...
32 22-04-97 : CAL ; Ajout du Plot.
33 03-06-97 : FMN ; Correction calcul SetRatio
34 06-05-97 : CAL ; Ajout du Clear sur les TOS_COMPUTED.
35 28-07-97 : PCT ; Ajout lumiere frontale headlight.
36 19-09-97 : CAL ; Remplacement de Window->Position par Window->Size;
37 17-10-97 : CAL ; Le Projects nouveau est arrive. (NewProjects)
38 24-10-97 : CAL ; Retrait de DownCast.
39 24-10-97 : CAL ; Retrait des DataStructure (Vieille maquette inutilisee).
40 17-11-97 : FMN ; Ajout DoResize dans Resized()
41 20-11-97 : CAL ; Disparition de la dependance avec math
42 ??-11-97 : CAL ; Retrait de la dependance avec math. Calcul developpe.
43 ??-11-97 : CAL ; Ajout de NumberOfDisplayedStructures
44 07-08-97 : PCT ; ajout support texture mapping
7fd59977 45 15-01-98 : FMN ; FRA60019 calcul Ratio pour MyViewMappingReset
46 15-01-98 : CAL ; Ajout de la transformation d'une TOS_COMPUTED
47 26-01-98 : CAL ; Ajout de la methode HaveTheSameOwner
48 06-02-98 : FMN ; CTS19079: TOP TEN: Probleme de highlight dans EDesigner.
49 05-03-98 : CAL ; GraphicTransform que si Trsf non invalidante
50 27-03-98 : CAL ; Ajout de TheStructure = devant Compute (...) !!!!
51 16-04-98 : CAL ; Remise a ID de la Trsf sur la COMPUTED
52 20-05-98 : CAL ; Perfs. Connection entre structures COMPUTED.
53 24-06-98 : CAL ; PRO14526 SetTransparency sur une vue non active.
54 17-07-98 : CAL ; PRO14872 test sur aTrsf dans ::SetTransform.
55 16-09-98 : BGN ; Points d'entree du Triedre (S3819, Phase 1)
56 22-09-98 : BGN ; S3989 (anciennement S3819)
57 TypeOfTriedron* from Aspect (pas Visual3d)
58 06-10-98 : CAL ; Ajout d'un TIMER si CSF_GraphicTimer est definie.
59 16-10-98 : CAL ; Ajout d'un TIMER si CSF_GraphicTimer est definie.
60 02-11-98 : CAL ; Retrait de OSD::SetSignal.
61 18-11-98 : FMN ; Correction sur la gestion de la perspective
62 02-12-98 : CAL ; S4062. Ajout des layers.
63 13-09-99 : GG ; GER61454 Adds LightLimit() and PlaneLimit() methods
64 10-11-99 : GG ; PRO19603 Add Redraw( area ) method
65 14-01-00 : GG ; IMP140100 Add ViewManager( ) method
66 22-10-01 : SAV ; Added EnableDepthTest() method.
67 30-04-02 : JMB ; MyDisplayStructure : use a Map instead of a Set (very bad performance
68 in data access when a lot of objects are used)
69 Will improve performance of selection mechanisms
70
71************************************************************************/
72
73#define BUC60572 //GG_03-08-99 Add protection on Zclipping & Zcueing planes
74// positions.
75
7fd59977 76#define GER61454 //GG 14-09-99 Activates model clipping planes
77
7fd59977 78#define RIC120302 //GG Add a NEW SetWindow method which enable
79// to connect a graphic widget and context to OGL.
80
b8ddfc2f 81//BUC61044 25/10/01 SAV ; added functionality to control gl depth testing from higher API
82//BUC61045 25/10/01 SAV ; added functionality to control gl lighting from higher API
7fd59977 83
b8ddfc2f 84//OCC1188 SAV Added methods to set background image
7fd59977 85
86/*----------------------------------------------------------------------*/
87/*
88 * Constantes
89 */
90
91#define NO_DEBUG
92#define NO_DESTROY
93#define NO_TRACE
94#define NO_TRACE_ACCEPT
95#define NO_TRACE_CLEAR
96#define NO_TRACE_CONNECT
97#define NO_TRACE_HIGH
98#define NO_TRACE_COMP
99#define NO_TRACE_TRSF
100#define NO_TRACE_DISPLAY
101#define NO_TRACE_ISCOMP
102#define NO_TRACE_LENGTH
103#define NO_TRACE_LAYER
104
105/*----------------------------------------------------------------------*/
106/*
107 * Includes
108 */
109
110#ifdef WNT
111#include <windows.h>
112#endif
113
114// for the class
115#include <Visual3d_View.ixx>
116#include <Visual3d_View.pxx>
117#include <Visual3d_DepthCueingDefinitionError.hxx>
118#include <Visual3d_ZClippingDefinitionError.hxx>
119
120#ifdef OLD_METHOD
121#include <math_Vector.hxx>
122#endif /* OLD_METHOD */
123
124#include <OSD.hxx>
125
126#include <Graphic3d_Structure.hxx>
127#include <Graphic3d_MapOfStructure.hxx>
128#include <Graphic3d_MapIteratorOfMapOfStructure.hxx>
129#include <Graphic3d_DataStructureManager.hxx>
130
131#include <Graphic3d_GraphicDriver.hxx>
7fd59977 132
133#include <Graphic3d_Vector.hxx>
134#include <Graphic3d_Vertex.hxx>
135
136#include <Visual3d_Light.hxx>
137#include <Visual3d_SetOfLight.hxx>
138#include <Visual3d_HSetOfLight.hxx>
139#include <Visual3d_SetIteratorOfSetOfLight.hxx>
140
7fd59977 141#include <Visual3d_SetIteratorOfSetOfView.hxx>
142
143#include <Graphic3d_TextureEnv.hxx>
144
145#include <TColStd_HArray2OfReal.hxx>
146
4fe56619 147#if (defined(_WIN32) || defined(__WIN32__))
148 #include <WNT_Window.hxx>
149#elif (defined(__APPLE__) && !defined(MACOSX_USE_GLX))
150 #include <Cocoa_Window.hxx>
7fd59977 151#else
4fe56619 152 #include <Xw_Window.hxx>
153#endif
7fd59977 154
155#include <float.h>
156
157//-Aliases
158
159//-Global data definitions
160
161//-Constructors
162
163Visual3d_View::Visual3d_View (const Handle(Visual3d_ViewManager)& AManager):
164MyContext (),
7fd59977 165MyTOCOMPUTESequence (),
166MyCOMPUTEDSequence (),
167MyDisplayedStructure ()
168{
7fd59977 169
7fd59977 170 MyPtrViewManager = AManager.operator->();
7fd59977 171 MyCView.ViewId = int (AManager->Identification (this));
172 MyCView.Active = 0;
173 MyCView.IsDeleted = 0;
174
bf75be98 175 MyCView.WsId = -1;
176 MyCView.DefWindow.IsDefined = 0;
7fd59977 177
bf75be98 178 MyCView.Context.NbActiveLight = 0;
7fd59977 179
7fd59977 180 MyCView.Context.ZBufferActivity = -1;
181
bd92cc2a 182 IsInitialized = Standard_False;
7fd59977 183 ComputedModeIsActive = Standard_False;
184 MyCView.Backfacing = 0;
7fd59977 185
7fd59977 186 MyCView.ptrUnderLayer = 0;
187 MyCView.ptrOverLayer = 0;
188 MyCView.GContext = 0;
189 MyCView.GDisplayCB = 0;
190 MyCView.GClientData = 0;
191
dc3fe572 192 MyGraphicDriver = MyViewManager->GraphicDriver();
7fd59977 193
194}
195
7fd59977 196//-Methods, in order
197// RIC120302
198void Visual3d_View::SetWindow (const Handle(Aspect_Window)& AWindow,
199 const Aspect_RenderingContext AContext,
200 const Aspect_GraphicCallbackProc& ADisplayCB,
201 const Standard_Address AClientData)
202{
203 if (IsDeleted ()) return;
204
205 if (IsDefined ())
206 Visual3d_ViewDefinitionError::Raise ("Window already defined");
207
208 MyCView.GContext = AContext;
209 MyCView.GDisplayCB = ADisplayCB;
210 MyCView.GClientData = AClientData;
211 SetWindow(AWindow);
212}
213// RIC120302
214
4fe56619 215void Visual3d_View::SetWindow (const Handle(Aspect_Window)& theWindow)
216{
b5ac8292 217 if (IsDeleted ()) return;
7fd59977 218
b5ac8292 219 if (IsDefined ())
220 {
221 Visual3d_ViewDefinitionError::Raise ("Window already defined");
222 }
4fe56619 223
b5ac8292 224 MyWindow = theWindow;
225 MyCView.WsId = MyCView.ViewId;
226 MyCView.DefWindow.IsDefined = 1;
4fe56619 227#if (defined(_WIN32) || defined(__WIN32__))
228 const Handle(WNT_Window) aWin = Handle(WNT_Window)::DownCast (theWindow);
229 MyCView.DefWindow.XWindow = (HWND )(aWin->HWindow());
230 MyCView.DefWindow.XParentWindow = (HWND )(aWin->HParentWindow());
231 WNT_WindowData* aWinData = (WNT_WindowData* )GetWindowLongPtr ((HWND )(aWin->HWindow()), GWLP_USERDATA);
232 aWinData->WNT_WDriver_Ptr = (void* )this;
233 aWinData->WNT_VMgr = (void* )MyPtrViewManager;
234#elif (defined(__APPLE__) && !defined(MACOSX_USE_GLX))
235 const Handle(Cocoa_Window) aWin = Handle(Cocoa_Window)::DownCast (theWindow);
236 MyCView.DefWindow.XWindow = (Aspect_Drawable )aWin->HView();
237 MyCView.DefWindow.XParentWindow = NULL;
238 //MyCView.DefWindow.XParentWindow = aWin->HParentWindow();
7fd59977 239#else
4fe56619 240 const Handle(Xw_Window) aWin = Handle(Xw_Window)::DownCast (theWindow);
241 MyCView.DefWindow.XWindow = aWin->XWindow();
ed97f43c 242 //MyCView.DefWindow.XParentWindow = aWin->XParentWindow();
7fd59977 243#endif
7fd59977 244
245 Standard_Integer Width, Height;
4fe56619 246 theWindow->Size (Width, Height);
7fd59977 247
248 MyCView.DefWindow.dx = float( Width );
249 MyCView.DefWindow.dy = float( Height );
250
251 Standard_Real R, G, B;
252 MyBackground = MyWindow->Background ();
253 (MyBackground.Color ()).Values (R, G, B, Quantity_TOC_RGB);
254 MyCView.DefWindow.Background.r = float (R);
255 MyCView.DefWindow.Background.g = float (G);
256 MyCView.DefWindow.Background.b = float (B);
257
258 UpdateView ();
259 if (! MyGraphicDriver->View (MyCView))
260 Visual3d_ViewDefinitionError::Raise ("Association failed");
261
262 MyGradientBackground = MyWindow->GradientBackground();
263 SetGradientBackground(MyGradientBackground,1);
264
81bba717 265 Standard_Boolean AWait = Standard_False; // => immediate update
7fd59977 266 MyGraphicDriver->SetVisualisation (MyCView);
267 MyGraphicDriver->AntiAliasing (MyCView, MyContext.AliasingIsOn ());
268 MyGraphicDriver->DepthCueing (MyCView, MyContext.DepthCueingIsOn ());
269 MyGraphicDriver->ClipLimit (MyCView, AWait);
270 MyGraphicDriver->Environment(MyCView);
271
71c4f9c6 272 // Make view manager z layer list consistent with the view's list.
273 MyViewManager->InstallZLayers (this);
274
81bba717 275 // Update planses of model clipping
7fd59977 276 UpdatePlanes ();
277
bf75be98 278 // Update light sources
7fd59977 279 UpdateLights ();
280
281 /*
81bba717 282 * Association view-window does not cause the display
283 * of structures that can be displayed in the new view.
284 * In fact, association view-window is done, but the
285 * display is produced only if the view is activated (Activate).
7fd59977 286 */
287
288 SetRatio ();
289
290}
291
292Handle(Aspect_Window) Visual3d_View::Window () const {
293
294 if (! IsDefined ())
295 Visual3d_ViewDefinitionError::Raise ("Window not defined");
296
297 return (MyWindow);
298
299}
300
301Standard_Boolean Visual3d_View::IsDefined () const {
302
303 if (MyCView.DefWindow.IsDefined)
304 return (Standard_True);
305 else
306 return (Standard_False);
307
308}
309
310Standard_Boolean Visual3d_View::IsDeleted () const {
311
312 if (MyCView.IsDeleted)
313 return (Standard_True);
314 else
315 return (Standard_False);
316
317}
318
319void Visual3d_View::Destroy () {
320
321#ifdef DESTROY
322 cout << "Visual3d_View::Destroy (" << Identification () << ")\n";
323#endif
324
325 // Since MyPtrViewManager can be already distroyed,
326 // avoid attempts to access it in SetBackground()
327 MyPtrViewManager = 0;
328 Remove ();
329
330}
331
332void Visual3d_View::Remove () {
333
334#ifdef DESTROY
335 cout << "Visual3d_View::Remove (" << Identification () << ")" << endl;
336#endif
337
338 if (IsDeleted ()) return;
339 if (! IsDefined ()) return;
340
341 MyTOCOMPUTESequence.Clear ();
342 MyCOMPUTEDSequence.Clear ();
343 MyDisplayedStructure.Clear ();
344
345 Quantity_Color BlackColor (0.0, 0.0, 0.0, Quantity_TOC_RGB);
346 Aspect_Background BlackBackground (BlackColor);
347 SetBackground (BlackBackground);
348
349 Aspect_GradientBackground BlackGradBackground;
350 SetGradientBackground (BlackGradBackground,0);
351
352 if (MyPtrViewManager)
353 MyPtrViewManager->UnIdentification( MyCView.ViewId );
354
355 MyGraphicDriver->RemoveView (MyCView);
356
357 MyCView.WsId = -1;
358 MyCView.IsDeleted = 1;
359 MyCView.DefWindow.IsDefined = 0;
360
bd92cc2a 361 IsInitialized = Standard_False;
362
7fd59977 363 MyWindow.Nullify ();
364
365}
366
367void Visual3d_View::Resized () {
368
369 if (IsDeleted ()) return;
370
371 if (! IsDefined ())
372 Visual3d_ViewDefinitionError::Raise ("Window not defined");
373 MyWindow->DoResize() ;
374 SetRatio ();
375
376}
377
b5ac8292 378void Visual3d_View::SetRatio()
379{
380 if (IsDeleted())
381 {
382 return;
383 }
7fd59977 384
b5ac8292 385 Aspect_TypeOfUpdate UpdateMode = MyViewManager->UpdateMode();
7fd59977 386
b5ac8292 387 MyViewManager->SetUpdateMode (Aspect_TOU_WAIT);
7fd59977 388
b5ac8292 389 Standard_Integer aWidth, aHeight;
7fd59977 390
b5ac8292 391 MyWindow->Size (aWidth, aHeight);
7fd59977 392
b5ac8292 393 if( aWidth > 0 && aHeight > 0 )
394 {
395 Standard_Real aRatio = (Standard_Real)aWidth / (Standard_Real)aHeight;
7fd59977 396
b5ac8292 397 MyCView.DefWindow.dx = Standard_ShortReal (aWidth);
398 MyCView.DefWindow.dy = Standard_ShortReal (aHeight);
7fd59977 399
b5ac8292 400 MyGraphicDriver->RatioWindow (MyCView);
7fd59977 401
b5ac8292 402 // Update camera aspect
403 Handle(Graphic3d_Camera) aCamera = MyCView.Context.Camera;
7fd59977 404
b5ac8292 405 if (!aCamera.IsNull())
406 {
407 aCamera->SetAspect (aRatio);
408 }
7fd59977 409
b5ac8292 410 if (!myDefaultCamera.IsNull())
411 {
412 myDefaultCamera->SetAspect (aRatio);
413 }
414 }
7fd59977 415
b5ac8292 416 MyViewManager->SetUpdateMode (UpdateMode);
417 if (UpdateMode == Aspect_TOU_ASAP)
418 Update();
7fd59977 419}
420
12381341 421void Visual3d_View::UpdateLights()
422{
423 if (IsDeleted()
424 || !IsDefined())
425 {
426 return;
427 }
7fd59977 428
12381341 429 if (MyContext.Model() == Visual3d_TOM_NONE)
430 {
431 // activate only a white ambient light
432 Graphic3d_CLight aCLight;
433 aCLight.Type = Visual3d_TOLS_AMBIENT;
434 aCLight.IsHeadlight = Standard_False;
435 aCLight.Color.r() = aCLight.Color.g() = aCLight.Color.b() = 1.0f;
7fd59977 436
7fd59977 437 MyCView.Context.NbActiveLight = 1;
12381341 438 MyCView.Context.ActiveLight = &aCLight;
439 MyGraphicDriver->SetLight (MyCView);
440 MyCView.Context.ActiveLight = NULL;
441 return;
7fd59977 442 }
7fd59977 443
12381341 444 MyCView.Context.NbActiveLight = Min (MyContext.NumberOfActivatedLights(),
445 MyGraphicDriver->InquireLightLimit());
446 if (MyCView.Context.NbActiveLight < 1)
447 {
4fe9ad57 448 MyGraphicDriver->SetLight (MyCView);
12381341 449 return;
450 }
7fd59977 451
12381341 452 // parcing of light sources
453 MyCView.Context.ActiveLight = new Graphic3d_CLight[MyCView.Context.NbActiveLight];
454 for (Standard_Integer aLightIter = 0; aLightIter < MyCView.Context.NbActiveLight; ++aLightIter)
455 {
456 MyCView.Context.ActiveLight[aLightIter] = MyContext.ActivatedLight (aLightIter + 1)->CLight();
457 }
458 MyGraphicDriver->SetLight (MyCView);
459 delete[] MyCView.Context.ActiveLight;
460 MyCView.Context.ActiveLight = NULL;
7fd59977 461}
462
51b10cd4 463void Visual3d_View::UpdatePlanes()
4269bd1b 464{
51b10cd4 465 MyCView.Context.ClipPlanes = MyContext.ClipPlanes();
4269bd1b 466 if (IsDeleted() || !IsDefined())
51b10cd4 467 {
4269bd1b 468 return;
51b10cd4 469 }
7fd59977 470
4269bd1b 471 MyGraphicDriver->SetClipPlanes (MyCView);
7fd59977 472}
473
474void Visual3d_View::SetBackground (const Aspect_Background& ABack) {
475
476 if (IsDeleted ()) return;
477
478 if (! IsDefined ())
479 Visual3d_ViewDefinitionError::Raise ("Window not defined");
480
81bba717 481 // At this level, only GL can update the background.
482 // It is not necessary to call MyWindow->SetBackground (ABack); as
483 // this method starts update of window background by X
484 // (if the windowing is X)
7fd59977 485
486 Standard_Real R, G, B;
487 MyBackground = ABack;
488 (MyBackground.Color ()).Values (R, G, B, Quantity_TOC_RGB);
489 MyCView.DefWindow.Background.r = float (R);
490 MyCView.DefWindow.Background.g = float (G);
491 MyCView.DefWindow.Background.b = float (B);
492
493 MyGraphicDriver->Background (MyCView);
494
495 if (MyPtrViewManager && MyViewManager->UpdateMode () == Aspect_TOU_ASAP)
496 Update ();
497
498}
499
500void Visual3d_View::SetGradientBackground(const Aspect_GradientBackground& ABack, const Standard_Boolean update)
501{
502
503 if (IsDeleted ()) return;
504
505 if (! IsDefined ())
506 Visual3d_ViewDefinitionError::Raise ("Window not defined");
507
508 MyGradientBackground = ABack;
509 Quantity_Color aCol1,aCol2;
510 MyGradientBackground.Colors(aCol1,aCol2);
511 MyGraphicDriver->GradientBackground(MyCView, aCol1, aCol2, MyGradientBackground.BgGradientFillMethod());
512
513 if ( update )
514 Update ();
515 else if (MyPtrViewManager && MyViewManager->UpdateMode () == Aspect_TOU_ASAP)
516 Update();
517}
518
519void Visual3d_View::SetBackgroundImage( const Standard_CString FileName,
520 const Aspect_FillMethod FillStyle,
521 const Standard_Boolean update )
522{
7fd59977 523 if ( IsDeleted() )
524 return;
525 if ( !IsDefined() )
526 Visual3d_ViewDefinitionError::Raise ("Window not defined");
527
528 MyGraphicDriver->BackgroundImage( FileName, MyCView, FillStyle );
529
530 if ( update )
531 Update();
532 else if ( MyViewManager->UpdateMode() == Aspect_TOU_ASAP )
533 Update();
7fd59977 534}
535
536void Visual3d_View::SetBgImageStyle( const Aspect_FillMethod FillStyle,
537 const Standard_Boolean update )
538{
7fd59977 539 if ( IsDeleted() )
540 return;
541 if ( !IsDefined() )
542 Visual3d_ViewDefinitionError::Raise ("Window not defined");
543
544 MyGraphicDriver->SetBgImageStyle( MyCView, FillStyle );
545
546 if ( update )
547 Update();
548 else if ( MyViewManager->UpdateMode() == Aspect_TOU_ASAP )
549 Update();
7fd59977 550}
551
552Aspect_Background Visual3d_View::Background () const {
553
554 return (MyBackground);
555
556}
557
558void Visual3d_View::SetBgGradientStyle( const Aspect_GradientFillMethod FillStyle,
559 const Standard_Boolean update )
560{
561 if ( IsDeleted() )
562 return;
563 if ( !IsDefined() )
564 Visual3d_ViewDefinitionError::Raise ("Window not defined");
565
566 MyGraphicDriver->SetBgGradientStyle( MyCView, FillStyle );
567
568 if ( update )
569 Update();
570 else if ( MyViewManager->UpdateMode() == Aspect_TOU_ASAP )
571 Update();
572
573}
574
575Aspect_GradientBackground Visual3d_View::GradientBackground () const {
576
577 return MyGradientBackground;
578
579}
580
b5ac8292 581// =======================================================================
582// function : DefaultCamera
583// purpose :
584// =======================================================================
585const Handle(Graphic3d_Camera)& Visual3d_View::DefaultCamera() const
586{
587 return myDefaultCamera;
7fd59977 588}
589
b5ac8292 590// =======================================================================
591// function : Camera
592// purpose :
593// =======================================================================
594const Handle(Graphic3d_Camera)& Visual3d_View::Camera() const{ return MyCView.Context.Camera;}
7fd59977 595
b5ac8292 596// =======================================================================
597// function : SetCamera
598// purpose :
599// =======================================================================
600void Visual3d_View::SetCamera (const Handle(Graphic3d_Camera)& theCamera)
601{
602 MyCView.Context.Camera = theCamera;
7fd59977 603
b5ac8292 604 MyGraphicDriver->SetCamera (MyCView);
7fd59977 605
b5ac8292 606 if (MyViewManager->UpdateMode() == Aspect_TOU_ASAP)
607 {
608 Update();
609 }
7fd59977 610}
611
b5ac8292 612// =======================================================================
613// function : SetViewOrientationDefault
614// purpose :
615// =======================================================================
616void Visual3d_View::SetViewOrientationDefault ()
617{
618 if (myDefaultCamera.IsNull())
619 {
620 myDefaultCamera = new Graphic3d_Camera();
621 }
7fd59977 622
b5ac8292 623 myDefaultCamera->CopyOrientationData (MyCView.Context.Camera);
7fd59977 624}
625
b5ac8292 626// =======================================================================
627// function : ViewOrientationReset
628// purpose :
629// =======================================================================
630void Visual3d_View::ViewOrientationReset ()
631{
632 if (IsDeleted())
633 {
634 return;
635 }
7fd59977 636
b5ac8292 637 if (!myDefaultCamera.IsNull())
638 {
639 MyCView.Context.Camera->CopyOrientationData (myDefaultCamera);
640 }
7fd59977 641
b5ac8292 642 if (MyViewManager->UpdateMode() == Aspect_TOU_ASAP)
643 {
644 Update();
645 }
7fd59977 646}
647
b5ac8292 648// =======================================================================
649// function : SetViewMappingDefault
650// purpose :
651// =======================================================================
652void Visual3d_View::SetViewMappingDefault()
653{
654 if (myDefaultCamera.IsNull())
655 {
656 myDefaultCamera = new Graphic3d_Camera();
657 }
658 myDefaultCamera->CopyMappingData (MyCView.Context.Camera);
7fd59977 659}
660
b5ac8292 661// =======================================================================
662// function : ViewMappingReset
663// purpose :
664// =======================================================================
665void Visual3d_View::ViewMappingReset ()
666{
667 if (IsDeleted ())
668 {
669 return;
670 }
7fd59977 671
b5ac8292 672 if (!myDefaultCamera.IsNull())
673 {
674 MyCView.Context.Camera->CopyMappingData (myDefaultCamera);
675 }
7fd59977 676
b5ac8292 677 if (MyViewManager->UpdateMode() == Aspect_TOU_ASAP)
678 {
679 Update();
680 }
7fd59977 681}
682
683void Visual3d_View::SetContext (const Visual3d_ContextView& CTX) {
684
685 if (IsDeleted ()) return;
686
687Visual3d_TypeOfVisualization OldVisualMode;
688Visual3d_TypeOfVisualization NewVisualMode;
689
bf75be98 690 // To manage display only in case of
81bba717 691 // change of visualisation mode.
7fd59977 692 OldVisualMode = MyContext.Visualization ();
693 NewVisualMode = CTX.Visualization ();
694
695Visual3d_TypeOfModel OldModel;
696Visual3d_TypeOfModel NewModel;
697
bf75be98 698 // To manage change of visualisation only in case
81bba717 699 // of change of mode of visualisation or of type of shading.
7fd59977 700 OldModel = MyContext.Model ();
701 NewModel = CTX.Model ();
702
703Standard_Boolean OldAliasingMode;
704Standard_Boolean NewAliasingMode;
705
81bba717 706 // To manage antialiasing only in case of change.
7fd59977 707 OldAliasingMode = MyContext.AliasingIsOn ();
708 NewAliasingMode = CTX.AliasingIsOn ();
709
710Standard_Boolean OldDepthCueingMode;
711Standard_Boolean NewDepthCueingMode;
712
713Standard_Real OldDepthCueingFrontPlane;
714Standard_Real NewDepthCueingFrontPlane;
715Standard_Real OldDepthCueingBackPlane;
716Standard_Real NewDepthCueingBackPlane;
717
81bba717 718 // To manage the depth cueing only in case of change.
7fd59977 719 OldDepthCueingMode = MyContext.DepthCueingIsOn ();
720 NewDepthCueingMode = CTX.DepthCueingIsOn ();
721
722 OldDepthCueingFrontPlane = MyContext.DepthCueingFrontPlane ();
723 NewDepthCueingFrontPlane = CTX.DepthCueingFrontPlane ();
724 OldDepthCueingBackPlane = MyContext.DepthCueingBackPlane ();
725 NewDepthCueingBackPlane = CTX.DepthCueingBackPlane ();
726
727Standard_Boolean OldFrontZClippingMode;
728Standard_Boolean NewFrontZClippingMode;
729Standard_Boolean OldBackZClippingMode;
730Standard_Boolean NewBackZClippingMode;
731
732Standard_Real OldZClippingFrontPlane;
733Standard_Real NewZClippingFrontPlane;
734Standard_Real OldZClippingBackPlane;
735Standard_Real NewZClippingBackPlane;
736
81bba717 737 // To manage the Zclipping only in case of change.
7fd59977 738 OldFrontZClippingMode = MyContext.FrontZClippingIsOn ();
739 NewFrontZClippingMode = CTX.FrontZClippingIsOn ();
740 OldBackZClippingMode = MyContext.BackZClippingIsOn ();
741 NewBackZClippingMode = CTX.BackZClippingIsOn ();
742
743 OldZClippingFrontPlane = MyContext.ZClippingFrontPlane ();
744 NewZClippingFrontPlane = CTX.ZClippingFrontPlane ();
745 OldZClippingBackPlane = MyContext.ZClippingBackPlane ();
746 NewZClippingBackPlane = CTX.ZClippingBackPlane ();
747
bf75be98 748 Handle(Graphic3d_TextureEnv) aTexEnvOld = MyContext.TextureEnv();
749 Handle(Graphic3d_TextureEnv) aTexEnvNew = CTX.TextureEnv();
7fd59977 750
bf75be98 751 Visual3d_TypeOfSurfaceDetail OldSurfaceDetail = MyContext.SurfaceDetail();
752 Visual3d_TypeOfSurfaceDetail NewSurfaceDetail = CTX.SurfaceDetail();
7fd59977 753
754 MyContext = CTX;
755
756 UpdateView ();
757
81bba717 758Standard_Boolean AWait = Standard_False; // => immediate update
7fd59977 759 if (IsDefined ()) {
81bba717 760 // management of visualization modes and types of shading.
7fd59977 761 if ((OldVisualMode != NewVisualMode) || (OldModel != NewModel))
762 MyGraphicDriver->SetVisualisation (MyCView);
763
81bba717 764 // management of antialiasing.
7fd59977 765 if (OldAliasingMode != NewAliasingMode)
766 MyGraphicDriver->AntiAliasing (MyCView, NewAliasingMode);
767
81bba717 768 // management of depth_cueing.
7fd59977 769 if ((OldDepthCueingMode != NewDepthCueingMode) ||
770 (OldDepthCueingFrontPlane != NewDepthCueingFrontPlane) ||
771 (OldDepthCueingBackPlane != NewDepthCueingBackPlane)) {
772#ifdef BUC60572
773 if( NewDepthCueingMode &&
774 (NewDepthCueingBackPlane >= NewDepthCueingFrontPlane) )
775 Visual3d_DepthCueingDefinitionError::Raise
776 ("Bad value for DepthCueingPlanes position");
777#endif
778 MyGraphicDriver->DepthCueing
779 (MyCView, NewDepthCueingMode);
780 }
781
81bba717 782 // management of Zclipping
7fd59977 783 if ((OldFrontZClippingMode != NewFrontZClippingMode) ||
784 (OldBackZClippingMode != NewBackZClippingMode) ||
785 (OldZClippingFrontPlane != NewZClippingFrontPlane) ||
786 (OldZClippingBackPlane != NewZClippingBackPlane)) {
787#ifdef BUC60572
788 if( NewBackZClippingMode && NewFrontZClippingMode &&
789 (NewZClippingBackPlane >= NewZClippingFrontPlane) )
790 Visual3d_ZClippingDefinitionError::Raise
791 ("Bad value for ZClippingPlanes position");
792#endif
793 MyGraphicDriver->ClipLimit (MyCView, AWait);
794 }
795
81bba717 796 // management of textures
bf75be98 797 if ((aTexEnvOld != aTexEnvNew) || (OldSurfaceDetail != NewSurfaceDetail))
798 {
7fd59977 799 MyGraphicDriver->Environment(MyCView);
bf75be98 800 }
7fd59977 801
81bba717 802 // Update of planes of model clipping
7fd59977 803 UpdatePlanes ();
804
bf75be98 805 // Update of light sources
7fd59977 806 UpdateLights ();
807 }
808
809 if (OldVisualMode != NewVisualMode) {
810
811 /*
81bba717 812 * Change of context =>
813 * Remove structures that cannot be displayed
814 * in the new visualisation mode.
815 * It is not necessary to warn ViewManager as
816 * this structure should not disappear from
817 * the list of structures displayed in it.
7fd59977 818 */
819Graphic3d_MapIteratorOfMapOfStructure S1Iterator (MyDisplayedStructure);
820Visual3d_TypeOfAnswer Answer;
821
822 Standard_Integer i = MyDisplayedStructure.Extent ();
823
824Graphic3d_SequenceOfStructure FooSequence;
825
826 while (S1Iterator.More ()) {
827 Answer = AcceptDisplay (S1Iterator.Key ());
bf75be98 828 // If the structure can't be displayed in the
81bba717 829 // new context of the view, it is removed.
7fd59977 830 if ((Answer == Visual3d_TOA_NO) ||
831 (Answer == Visual3d_TOA_COMPUTE))
832 //Erase (S1Iterator.Key (), Aspect_TOU_WAIT);
833 FooSequence.Append (S1Iterator.Key ());
834
81bba717 835 // S1Iterator.Next () is located on the next structure
7fd59977 836 S1Iterator.Next ();
837 }
838
839Standard_Integer Length = FooSequence.Length ();
81bba717 840 // The stored structures are removed
7fd59977 841 for (i=1; i<=Length; i++)
842 Erase (FooSequence.Value (i), Aspect_TOU_WAIT);
843 if (Length != 0) FooSequence.Clear ();
844
845 /*
81bba717 846 * Change of context =>
bf75be98 847 * Display structures that can be displayed
81bba717 848 * with the new visualisation mode.
bf75be98 849 * All structures with status Displayed are removed from the ViewManager
850 * and displayed in the view directly, if the structure is not already
81bba717 851 * displayed and if the view accepts it in its context.
7fd59977 852 */
853
854 i = MyViewManager->NumberOfDisplayedStructures ();
855 Graphic3d_MapOfStructure Map;
856 MyViewManager->DisplayedStructures(Map);
857 Graphic3d_MapIteratorOfMapOfStructure it(Map);
858
859 for (; it.More(); it.Next()) {
860 Handle(Graphic3d_Structure) SG = it.Key();
861 if (! IsDisplayed (SG)) {
862 Answer = AcceptDisplay(SG);
bf75be98 863 // If the structure can be displayed in the
81bba717 864 // new context of the view, it is displayed.
7fd59977 865 if ((Answer == Visual3d_TOA_YES) ||
866 (Answer == Visual3d_TOA_COMPUTE))
867 //Display (MyViewManager->DisplayedStructure (j),
868 //Aspect_TOU_WAIT);
869 FooSequence.Append (SG);
870 }
871 }
872
873 Length = FooSequence.Length ();
81bba717 874 // The stored structures are displayed
7fd59977 875 for (i=1; i<=Length; i++)
876 Display (FooSequence.Value (i), Aspect_TOU_WAIT);
877 if (Length != 0) FooSequence.Clear ();
878 }
879
880 if (MyViewManager->UpdateMode () == Aspect_TOU_ASAP) Update ();
881
882}
883
884const Visual3d_ContextView& Visual3d_View::Context () const {
885
886 return (MyContext);
887
888}
889
890void Visual3d_View::DisplayedStructures (Graphic3d_MapOfStructure& SG) const
891{
892
893 if (IsDeleted ()) return;
894
895 Graphic3d_MapIteratorOfMapOfStructure Iterator (MyDisplayedStructure);
896
897 while (Iterator.More ()) {
898 SG.Add (Iterator.Key ());
899
81bba717 900 // Iterator.Next () is located on the next structure
7fd59977 901 Iterator.Next ();
902 }
903
904}
905
906void Visual3d_View::Activate () {
907
908 if (IsDeleted ()) return;
909
910 if (! IsDefined ())
911 Visual3d_ViewDefinitionError::Raise ("Window not defined");
912
913 if (! IsActive ()) {
914
915 MyGraphicDriver->ActivateView (MyCView);
916 MyGraphicDriver->Background (MyCView);
917 MyGraphicDriver->Transparency
918 (MyCView, MyViewManager->Transparency ());
919
920 MyCView.Active = 1;
921
922 /*
81bba717 923 * Activation of a new view =>
924 * Display structures that can be displayed in this new view.
925 * All structures with status
bf75be98 926 * Displayed in ViewManager are returned and displayed in
927 * the view directly, if the structure is not already
81bba717 928 * displayed and if the view accepts it in its context.
7fd59977 929 */
930
931 Visual3d_TypeOfAnswer Answer;
932 Graphic3d_MapOfStructure Map;
933 MyViewManager->DisplayedStructures(Map);
934 Graphic3d_MapIteratorOfMapOfStructure it(Map);
935
936 for (; it.More(); it.Next()) {
937 Handle(Graphic3d_Structure) SG = it.Key();
938 if (! IsDisplayed (SG)) {
939 Answer = AcceptDisplay(SG);
81bba717 940 // If the structure can be displayed in the
941 // new context of the view, it is displayed.
7fd59977 942 if ((Answer == Visual3d_TOA_YES) ||
943 (Answer == Visual3d_TOA_COMPUTE))
944 Display (SG,Aspect_TOU_WAIT);
945 }
946 }
947
948 }
949
81bba717 950 // If the activation/desactivation of ZBuffer should be automatic
951 // depending on the presence or absence of facets.
7fd59977 952 if (MyViewManager->ZBufferAuto ()) {
953Standard_Boolean BContainsFacet = ContainsFacet ();
954Standard_Boolean BZBuffer = ZBufferIsActivated ();
81bba717 955 // If the view contains facets
956 // and if ZBuffer is not active
7fd59977 957 if (BContainsFacet && ! BZBuffer)
958 SetZBufferActivity (1);
81bba717 959 // If the view does not contain facets
960 // and if ZBuffer is active
7fd59977 961 if (! BContainsFacet && BZBuffer)
962 SetZBufferActivity (0);
963 }
964
965 if (MyViewManager->UpdateMode () == Aspect_TOU_ASAP) Update ();
966
967}
968
969Standard_Boolean Visual3d_View::IsActive () const {
970
971 if (IsDeleted ()) return (Standard_False);
972
973 if (MyCView.Active)
974 return (Standard_True);
975 else
976 return (Standard_False);
977
978}
979
980void Visual3d_View::Deactivate () {
981
982 if (IsDeleted ()) return;
983
984 if (! IsDefined ())
985 Visual3d_ViewDefinitionError::Raise ("Window not defined");
986
987 if (IsActive ()) {
988
989 MyGraphicDriver->DeactivateView (MyCView);
990
991 /*
81bba717 992 * Deactivation of a view =>
993 * Removal of structures displayed in this view.
994 * All structures with status
bf75be98 995 * Displayed in ViewManager are returned and removed from
996 * the view directly, if the structure is not already
81bba717 997 * displayed and if the view accepts it in its context.
998 */
7fd59977 999
1000 Visual3d_TypeOfAnswer Answer;
1001 Graphic3d_MapOfStructure Map;
1002 MyViewManager->DisplayedStructures(Map);
1003 Graphic3d_MapIteratorOfMapOfStructure it(Map);
1004
1005 for (; it.More(); it.Next()) {
1006 Handle(Graphic3d_Structure) SG = it.Key();
1007 if (! IsDisplayed (SG)) {
1008 Answer = AcceptDisplay(SG);
81bba717 1009 // If the structure was displayed it is removed.
7fd59977 1010 if ((Answer == Visual3d_TOA_YES) ||
1011 (Answer == Visual3d_TOA_COMPUTE))
1012 Erase (SG,Aspect_TOU_WAIT);
1013 }
1014 }
1015
1016 if (MyViewManager->UpdateMode () == Aspect_TOU_ASAP) Update ();
1017
81bba717 1018 // No action currently possible in the view
7fd59977 1019 MyCView.Active = 0;
1020 }
1021
1022}
1023
1024void Visual3d_View::Redraw () {
1025
1026 Redraw (MyViewManager->UnderLayer (), MyViewManager->OverLayer ());
1027
1028}
1029
1030void Visual3d_View::Redraw (const Standard_Integer x, const Standard_Integer y, const Standard_Integer width, const Standard_Integer height) {
1031
1032 Redraw (MyViewManager->UnderLayer (), MyViewManager->OverLayer (), x, y, width, height);
1033}
1034
1035void Visual3d_View::Redraw (const Handle(Visual3d_Layer)& AnUnderLayer, const Handle(Visual3d_Layer)& AnOverLayer) {
1036
1037 if (IsDeleted ()) return;
1038
1039 if ((! IsDefined ()) || (! IsActive ())) return;
1040
1041 if (! MyWindow->IsMapped ()) return;
1042
1043 // san - 14/04/2004 - set up Z buffer state before redrawing
81bba717 1044 // If the activation/desactivation of ZBuffer should be automatic
1045 // depending on the presence or absence of facets.
7fd59977 1046 if (MyViewManager->ZBufferAuto ()) {
1047 Standard_Boolean BContainsFacet = ContainsFacet ();
1048 Standard_Boolean BZBuffer = ZBufferIsActivated ();
81bba717 1049 // If the view contains facets
1050 // and if ZBuffer is not active
7fd59977 1051 if (BContainsFacet && ! BZBuffer)
1052 SetZBufferActivity (1);
81bba717 1053 // If the view contains only facets
1054 // and if ZBuffer is active
7fd59977 1055 if (! BContainsFacet && BZBuffer)
1056 SetZBufferActivity (0);
1057 }
1058
1059 Aspect_CLayer2d OverCLayer;
1060 Aspect_CLayer2d UnderCLayer;
1061 OverCLayer.ptrLayer = UnderCLayer.ptrLayer = NULL;
1062 if (! AnOverLayer.IsNull ()) OverCLayer = AnOverLayer->CLayer ();
1063 if (! AnUnderLayer.IsNull ()) UnderCLayer = AnUnderLayer->CLayer ();
1064 MyGraphicDriver->Redraw (MyCView, UnderCLayer, OverCLayer);
1065
1066}
1067
1068void Visual3d_View::Redraw (const Handle(Visual3d_Layer)& AnUnderLayer, const Handle(Visual3d_Layer)& AnOverLayer, const Standard_Integer x, const Standard_Integer y, const Standard_Integer width, const Standard_Integer height) {
1069
1070 if (IsDeleted ()) return;
1071
1072 if ((! IsDefined ()) || (! IsActive ())) return;
1073
1074 if (! MyWindow->IsMapped ()) return;
1075
1076 // san - 14/04/2004 - set up Z buffer state before redrawing
81bba717 1077 // If activation/desactivation of ZBuffer should be automatic
1078 // depending on the presence or absence of facets.
7fd59977 1079 if (MyViewManager->ZBufferAuto ()) {
1080 Standard_Boolean BContainsFacet = ContainsFacet ();
1081 Standard_Boolean BZBuffer = ZBufferIsActivated ();
81bba717 1082 // If the view contains facets
1083 // and if ZBuffer is not active
7fd59977 1084 if (BContainsFacet && ! BZBuffer)
1085 SetZBufferActivity (1);
81bba717 1086 // If the view contains only facets
1087 // and if ZBuffer is active
7fd59977 1088 if (! BContainsFacet && BZBuffer)
1089 SetZBufferActivity (0);
1090 }
1091
1092 Aspect_CLayer2d OverCLayer;
1093 Aspect_CLayer2d UnderCLayer;
1094 OverCLayer.ptrLayer = UnderCLayer.ptrLayer = NULL;
1095 if (! AnOverLayer.IsNull ()) OverCLayer = AnOverLayer->CLayer ();
1096 if (! AnUnderLayer.IsNull ()) UnderCLayer = AnUnderLayer->CLayer ();
1097 MyGraphicDriver->Redraw (MyCView, UnderCLayer, OverCLayer, x, y, width, height);
1098
1099}
1100
b5ac8292 1101void Visual3d_View::Update ()
1102{
1103 IsInitialized = Standard_True;
7fd59977 1104
b5ac8292 1105 Compute ();
7fd59977 1106
b5ac8292 1107 Update (MyViewManager->UnderLayer (), MyViewManager->OverLayer ());
7fd59977 1108}
1109
1110void Visual3d_View::Update (const Handle(Visual3d_Layer)& AnUnderLayer, const Handle(Visual3d_Layer)& AnOverLayer) {
1111
1112 if (IsDeleted ()) return;
1113
1114 if ((! IsDefined ()) || (! IsActive ())) return;
1115
1116 if (! MyWindow->IsMapped ()) return;
1117
eb4320f2 1118 if (MyGraphicDriver->IsDeviceLost())
1119 {
8bb96a97 1120 MyViewManager->RecomputeStructures();
eb4320f2 1121 MyGraphicDriver->ResetDeviceLostFlag();
1122 }
1123
81bba717 1124 // If activation/desactivation of ZBuffer should be automatic
1125 // depending on the presence or absence of facets.
7fd59977 1126 if (MyViewManager->ZBufferAuto ()) {
1127Standard_Boolean BContainsFacet = ContainsFacet ();
1128Standard_Boolean BZBuffer = ZBufferIsActivated ();
81bba717 1129 // If the view contains facets
1130 // and if ZBuffer is not active
1131 if (BContainsFacet && ! BZBuffer)
7fd59977 1132 SetZBufferActivity (1);
81bba717 1133 // If the view does not contain facets
1134 // and if ZBuffer is active
7fd59977 1135 if (! BContainsFacet && BZBuffer)
1136 SetZBufferActivity (0);
1137 }
1138
1139Aspect_CLayer2d OverCLayer;
1140Aspect_CLayer2d UnderCLayer;
1141 OverCLayer.ptrLayer = UnderCLayer.ptrLayer = NULL;
1142 if (! AnUnderLayer.IsNull ()) UnderCLayer = AnUnderLayer->CLayer ();
1143 if (! AnOverLayer.IsNull ()) OverCLayer = AnOverLayer->CLayer ();
1144 //OSD::SetSignal (Standard_False);
1145 MyGraphicDriver->Update (MyCView, UnderCLayer, OverCLayer);
1146 //OSD::SetSignal (Standard_True);
1147
7fd59977 1148}
1149
1150Visual3d_TypeOfAnswer Visual3d_View::AcceptDisplay (const Handle(Graphic3d_Structure)& AStructure) const {
1151
81bba717 1152// Return type of visualization of the view
7fd59977 1153Visual3d_TypeOfVisualization ViewType = MyContext.Visualization ();
1154
81bba717 1155// Return type of visualization of the structure
7fd59977 1156Graphic3d_TypeOfStructure StructType = AStructure->Visual ();
1157
1158Visual3d_TypeOfAnswer Result = Visual3d_TOA_NO;
1159
1160 if (StructType == Graphic3d_TOS_ALL)
81bba717 1161 // The structure accepts any type of view
7fd59977 1162 Result = Visual3d_TOA_YES;
1163 else {
1164 if ((StructType == Graphic3d_TOS_SHADING)
1165 && (ViewType == Visual3d_TOV_SHADING))
1166 Result = Visual3d_TOA_YES;
1167 if ((StructType == Graphic3d_TOS_WIREFRAME)
1168 && (ViewType == Visual3d_TOV_WIREFRAME))
1169 Result = Visual3d_TOA_YES;
1170 if ((StructType == Graphic3d_TOS_COMPUTED)
1171 && (ViewType == Visual3d_TOV_WIREFRAME))
1172 Result = Visual3d_TOA_COMPUTE;
1173 if ((StructType == Graphic3d_TOS_COMPUTED)
1174 && (ViewType == Visual3d_TOV_SHADING))
1175 Result = Visual3d_TOA_COMPUTE;
1176 }
1177
1178#ifdef TRACE_ACCEPT
1179 if (Result == Visual3d_TOA_YES)
1180 cout << "YES = Visual3d_View" << MyCView.ViewId
1181 << "::AcceptDisplay (" << AStructure->Identification () << ")\n";
1182 if (Result == Visual3d_TOA_NO)
1183 cout << "NO = Visual3d_View" << MyCView.ViewId
1184 << "::AcceptDisplay (" << AStructure->Identification () << ")\n";
1185 if (Result == Visual3d_TOA_COMPUTE)
1186 cout << "COMPUTE = Visual3d_View" << MyCView.ViewId
1187 << "::AcceptDisplay (" << AStructure->Identification () << ")\n";
1188 cout << flush;
1189#endif
1190
1191 return (Result);
1192
1193}
1194
35e08fe8 1195void Visual3d_View::ChangeDisplayPriority (const Handle(Graphic3d_Structure)& AStructure, const Standard_Integer /*OldPriority*/, const Standard_Integer NewPriority) {
7fd59977 1196
1197 if (IsDeleted ()) return;
1198 if (! IsDefined ()) return;
1199 if (! IsActive ()) return;
1200 if (! IsDisplayed (AStructure)) return;
1201
1202Standard_Integer Index = IsComputed (AStructure);
de75ed09 1203 if (Index != 0 && ComputedMode())
7fd59977 1204 {
1205#ifdef TRACE
1206 Standard_Integer StructId = MyCOMPUTEDSequence.Value (Index)->Identification ();
1207 cout << "Visual3d_View" << MyCView.ViewId << "::ChangeDisplayPriority ("
1208 << AStructure->Identification () << "/" << StructId
1209 << ", " << OldPriority << ", " << NewPriority << ")\n";
1210 cout << flush;
1211#endif
63bcc448 1212 MyGraphicDriver->EraseStructure (MyCView, *(MyCOMPUTEDSequence.Value (Index)->CStructure()));
1213 MyGraphicDriver->DisplayStructure (MyCView, *(MyCOMPUTEDSequence.Value (Index)->CStructure()), NewPriority);
7fd59977 1214 }
63bcc448 1215 else
1216 {
7fd59977 1217#ifdef TRACE
1218 Standard_Integer StructId = AStructure->Identification ();
1219 cout << "Visual3d_View" << MyCView.ViewId << "::ChangeDisplayPriority ("
1220 << AStructure->Identification () << "/" << StructId
1221 << ", " << OldPriority << ", " << NewPriority << ")\n";
1222 cout << flush;
1223#endif
63bcc448 1224 MyGraphicDriver->EraseStructure (MyCView, *(AStructure->CStructure()));
1225 MyGraphicDriver->DisplayStructure (MyCView, *(AStructure->CStructure()), NewPriority);
7fd59977 1226 }
1227
1228}
1229
1230void Visual3d_View::Clear (const Handle(Graphic3d_Structure)& AStructure, const Standard_Boolean WithDestruction) {
1231
1232#ifdef TRACE_CLEAR
1233 cout << "Visual3d_View" << MyCView.ViewId << "::Clear ("
1234 << AStructure->Identification () << ")\n";
1235 cout << flush;
1236#endif
1237
1238Standard_Integer Index = IsComputed (AStructure);
1239 if (Index != 0) {
1240#ifdef TRACE_CLEAR
81bba717 1241 cout << "Structure " << AStructure->Identification ()
1242 << " calculated in the view "
1243 << Identification () << ", by structure "
7fd59977 1244 << MyCOMPUTEDSequence.Value (Index)->Identification ()
81bba717 1245 << " is emptied.\n";
7fd59977 1246 cout << flush;
1247#endif
1248 MyCOMPUTEDSequence.Value (Index)->GraphicClear (WithDestruction);
1249 MyCOMPUTEDSequence.Value (Index)->SetHLRValidation (Standard_False);
1250 }
1251
1252}
1253
1254void Visual3d_View::Connect (const Handle(Graphic3d_Structure)& AMother, const Handle(Graphic3d_Structure)& ADaughter) {
1255
1256#ifdef TRACE_CONNECT
1257 cout << "Visual3d_View" << MyCView.ViewId << "::Connect ("
1258 << AMother->Identification ()
1259 << ADaughter->Identification () << ")\n";
1260 cout << flush;
1261#endif
1262
1263Standard_Integer IndexM = IsComputed (AMother);
1264Standard_Integer IndexD = IsComputed (ADaughter);
1265
1266 if (IndexM != 0 && IndexD != 0) {
1267#ifdef TRACE_CONNECT
81bba717 1268 cout << "Structure " << AMother->Identification ()
1269 << " is connected to structure "
7fd59977 1270 << ADaughter->Identification () << endl;
81bba717 1271 cout << "These structures are calculated.\n";
1272 cout << "In the view " << Identification ()
1273 << "Structure "
7fd59977 1274 << MyCOMPUTEDSequence.Value (IndexM)->Identification ()
81bba717 1275 << " is connected to the structure "
7fd59977 1276 << MyCOMPUTEDSequence.Value (IndexD)->Identification ()
1277 << endl;
1278#endif
1279 MyCOMPUTEDSequence.Value (IndexM)->GraphicConnect (MyCOMPUTEDSequence.Value (IndexD));
1280 }
1281
1282}
1283
1284void Visual3d_View::Disconnect (const Handle(Graphic3d_Structure)& AMother, const Handle(Graphic3d_Structure)& ADaughter) {
1285
1286#ifdef TRACE_CONNECT
1287 cout << "Visual3d_View" << MyCView.ViewId << "::Disconnect ("
1288 << AMother->Identification ()
1289 << ADaughter->Identification () << ")\n";
1290 cout << flush;
1291#endif
1292
1293Standard_Integer IndexM = IsComputed (AMother);
1294Standard_Integer IndexD = IsComputed (ADaughter);
1295
1296 if (IndexM != 0 && IndexD != 0) {
1297#ifdef TRACE_CONNECT
81bba717 1298 cout << "Structure " << AMother->Identification ()
1299 << " is disconnected from the structure "
7fd59977 1300 << ADaughter->Identification () << endl;
81bba717 1301 cout << "These structures are calculated.\n";
1302 cout << "In the view " << Identification ()
1303 << "Structure "
7fd59977 1304 << MyCOMPUTEDSequence.Value (IndexM)->Identification ()
81bba717 1305 << " is disconnected from the structure "
7fd59977 1306 << MyCOMPUTEDSequence.Value (IndexD)->Identification ()
1307 << endl;
1308#endif
1309 MyCOMPUTEDSequence.Value (IndexM)->GraphicDisconnect (MyCOMPUTEDSequence.Value (IndexD));
1310 }
1311
1312}
1313
1314void Visual3d_View::Display (const Handle(Graphic3d_Structure)& AStructure) {
1315
1316 Display (AStructure, MyViewManager->UpdateMode ());
1317
1318}
1319
1320void Visual3d_View::Display (const Handle(Graphic3d_Structure)& AStructure, const Aspect_TypeOfUpdate AnUpdateMode) {
1321
1322 if (IsDeleted ()) return;
1323 if (! IsDefined ()) return;
1324 if (! IsActive ()) return;
1325
81bba717 1326 // If Display on a structure present in the list
bf75be98 1327 // of calculated structures while it is not
81bba717 1328 // or more, of calculated type =>
1329 // - removes it as well as the associated old computed
1330 // THis happens when hlhsr becomes again of type e
1331 // non computed after SetVisual.
7fd59977 1332Standard_Integer Index = IsComputed (AStructure);
1333
1334 if ((Index != 0) && (AStructure->Visual () != Graphic3d_TOS_COMPUTED)) {
7fd59977 1335 MyTOCOMPUTESequence.Remove (Index);
1336 MyCOMPUTEDSequence.Remove (Index);
7fd59977 1337 Index = 0;
1338 }
1339
1340 Visual3d_TypeOfAnswer Answer = AcceptDisplay (AStructure);
1341
7fd59977 1342 if (Answer == Visual3d_TOA_NO) {
7fd59977 1343 return;
1344 }
1345
de75ed09 1346 if (!ComputedMode())
1347 {
1348 Answer = Visual3d_TOA_YES;
1349 }
7fd59977 1350
1351 if (Answer == Visual3d_TOA_YES ) {
7fd59977 1352 if (IsDisplayed (AStructure)) return;
63bcc448 1353 MyGraphicDriver->DisplayStructure (MyCView, *(AStructure->CStructure()), AStructure->DisplayPriority());
7fd59977 1354 MyDisplayedStructure.Add (AStructure);
1355 if (AnUpdateMode == Aspect_TOU_ASAP) Update ();
1356 }
1357
1358 if (Answer == Visual3d_TOA_COMPUTE) {
7fd59977 1359 if (Index != 0) {
81bba717 1360 // Already computed, is COMPUTED still valid?
7fd59977 1361Standard_Integer OldStructId =
1362 MyCOMPUTEDSequence.Value (Index)->Identification ();
1363
81bba717 1364 // Case COMPUTED valide
7fd59977 1365 if (MyCOMPUTEDSequence.Value (Index)->HLRValidation ()) {
81bba717 1366 // to be displayed
7fd59977 1367 if (! IsDisplayed (AStructure)) {
1368 MyDisplayedStructure.Add (AStructure);
63bcc448 1369 MyGraphicDriver->DisplayStructure (MyCView, *(MyCOMPUTEDSequence.Value (Index)->CStructure()), AStructure->DisplayPriority ());
7fd59977 1370 if (AnUpdateMode == Aspect_TOU_ASAP) Update ();
1371 }
1372 return;
1373 }
1374
81bba717 1375 // Case COMPUTED invalid
7fd59977 1376 else {
81bba717 1377 // Is there another valid representation ?
1378 // Find in the sequence of already calculated structures
1379 // 1/ Structure having the same Owner as <AStructure>
1380 // 2/ That is not <AStructure>
1381 // 3/ The COMPUTED which of is valid
7fd59977 1382 Standard_Integer NewIndex = HaveTheSameOwner (AStructure);
1383
81bba717 1384 // Case of COMPUTED invalid, WITH a valid of replacement
7fd59977 1385 if (NewIndex != 0) {
81bba717 1386 // to be displayed
7fd59977 1387 if (! IsDisplayed (AStructure)) {
1388 MyCOMPUTEDSequence.SetValue
1389 (Index, MyCOMPUTEDSequence.Value (NewIndex));
1390 OldStructId = MyCOMPUTEDSequence.Value (NewIndex)->
1391 Identification ();
1392 MyDisplayedStructure.Add (AStructure);
63bcc448 1393 MyGraphicDriver->DisplayStructure (MyCView, *(MyCOMPUTEDSequence.Value (NewIndex)->CStructure()), AStructure->DisplayPriority ());
7fd59977 1394 if (AnUpdateMode == Aspect_TOU_ASAP) Update ();
1395 }
1396 return;
1397 }
1398
81bba717 1399 // Cas COMPUTED invalid, WITHOUT a valid of replacement
7fd59977 1400 else {
bf75be98 1401 // COMPUTED is removed if displayed
7fd59977 1402 if (IsDisplayed (AStructure))
63bcc448 1403 MyGraphicDriver->EraseStructure (MyCView, *(MyCOMPUTEDSequence.Value (Index)->CStructure()));
7fd59977 1404 }
1405 }
1406 } // if (Index != 0)
1407
1408 // Compute + Validation
1409#ifdef OLD
1410Handle(Graphic3d_Structure) TheStructure = AStructure->Compute (this);
1411#else
1412Handle(Graphic3d_Structure) TheStructure;
1413TColStd_Array2OfReal ATrsf (0, 3, 0, 3);
1414 AStructure->Transform (ATrsf);
1415 if (Index != 0) {
1416TColStd_Array2OfReal Ident (0, 3, 0, 3);
1417Standard_Integer ii, jj;
1418 for (ii=0; ii<=3; ii++)
1419 for (jj=0; jj<=3; jj++)
1420 Ident (ii, jj) = (ii == jj ? 1.0 : 0.0);
1421 TheStructure = MyCOMPUTEDSequence.Value (Index);
1422 TheStructure->SetTransform (Ident, Graphic3d_TOC_REPLACE);
1423 if (AStructure->IsTransformed ()) {
1424 AStructure->Compute (this, ATrsf, TheStructure);
1425 }
1426 else {
1427 AStructure->Compute (this, TheStructure);
1428 }
1429 }
1430 else {
1431 if (AStructure->IsTransformed ()) {
1432 TheStructure = AStructure->Compute (this, ATrsf);
1433 }
1434 else {
1435 TheStructure = AStructure->Compute (this);
1436 }
1437 }
1438#endif
1439 TheStructure->SetHLRValidation (Standard_True);
1440
81bba717 1441 // TOCOMPUTE and COMPUTED associated to sequences are added
7fd59977 1442 MyTOCOMPUTESequence.Append (AStructure);
1443 MyCOMPUTEDSequence.Append (TheStructure);
1444
81bba717 1445 // The previous are removed if necessary
7fd59977 1446 if (Index != 0) {
1447 MyTOCOMPUTESequence.Remove (Index);
1448 MyCOMPUTEDSequence.Remove (Index);
1449 }
1450
81bba717 1451// Return type of visualisation of the view
7fd59977 1452Visual3d_TypeOfVisualization ViewType = MyContext.Visualization ();
1453
81bba717 1454// Of which type will be the computed ?
7fd59977 1455Standard_Boolean ComputeWireframe = ((ViewType == Visual3d_TOV_WIREFRAME) &&
1456 (AStructure->ComputeVisual () != Graphic3d_TOS_SHADING));
1457
1458Standard_Boolean ComputeShading = ((ViewType == Visual3d_TOV_SHADING) &&
1459 (AStructure->ComputeVisual () != Graphic3d_TOS_WIREFRAME));
1460
1461 if (ComputeWireframe)
1462 TheStructure->SetVisual (Graphic3d_TOS_WIREFRAME);
1463 if (ComputeShading)
1464 TheStructure->SetVisual (Graphic3d_TOS_SHADING);
1465
1466 if (! ComputeShading && ! ComputeWireframe)
1467 Answer = Visual3d_TOA_NO;
1468 else
1469 Answer = AcceptDisplay (TheStructure);
1470
1471 if (AStructure->IsHighlighted()) {
1472 TheStructure->SetHighlightColor (AStructure->HighlightColor ());
1473 TheStructure->GraphicHighlight (Aspect_TOHM_COLOR);
1474 }
1475
bf75be98 1476 // It is displayed only if the calculated structure
81bba717 1477 // has a proper type corresponding to the one of the view.
7fd59977 1478 if (Answer != Visual3d_TOA_NO) {
1479 if (! IsDisplayed (AStructure))
1480 MyDisplayedStructure.Add (AStructure);
63bcc448 1481 MyGraphicDriver->DisplayStructure (MyCView, *(TheStructure->CStructure()), AStructure->DisplayPriority ());
7fd59977 1482 if (AnUpdateMode == Aspect_TOU_ASAP) Update ();
1483 }
1484 } // Visual3d_TOA_COMPUTE
1485}
1486
1487void Visual3d_View::Erase (const Handle(Graphic3d_Structure)& AStructure) {
1488
1489 if (IsDeleted ()) return;
1490
1491 Erase (AStructure, MyViewManager->UpdateMode ());
1492
1493}
1494
1495void Visual3d_View::Erase (const Handle(Graphic3d_Structure)& AStructure, const Aspect_TypeOfUpdate AnUpdateMode) {
1496
1497Standard_Integer StructId;
1498
1499 if (IsDeleted ()) return;
1500
bf75be98 1501 // No test on window as the structure is displayed only if
81bba717 1502 // the window exists, so only one test is enough.
7fd59977 1503 if (IsDisplayed (AStructure)) {
1504Visual3d_TypeOfAnswer Answer = AcceptDisplay (AStructure);
1505
de75ed09 1506 if (!ComputedMode())
1507 {
1508 Answer = Visual3d_TOA_YES;
1509 }
7fd59977 1510
1511 if (Answer != Visual3d_TOA_COMPUTE) {
63bcc448 1512 MyGraphicDriver->EraseStructure (MyCView, *(AStructure->CStructure()));
7fd59977 1513 }
1514
1515 if (Answer == Visual3d_TOA_COMPUTE) {
1516Standard_Integer Index = IsComputed (AStructure);
1517#ifdef TRACE_COMP
1518 cout << "Visual3d_View" << MyCView.ViewId << "::Erase ("
1519 << AStructure->Identification () << ");\n";
1520 cout << "Index : " << Index << "\n";
1521 cout << flush;
1522#endif
de75ed09 1523
1524 if (Index != 0 && ComputedMode())
7fd59977 1525 {
1526 StructId =
1527 MyCOMPUTEDSequence.Value (Index)->Identification ();
1528#ifdef TRACE_COMP
1529 cout << "Structure " << AStructure->Identification ()
81bba717 1530 << " calculated, in the view "
1531 << Identification () << ", by the structure "
1532 << StructId << " is removed. \n";
7fd59977 1533 cout << flush;
1534#endif
63bcc448 1535 MyGraphicDriver->EraseStructure (MyCView, *(MyCOMPUTEDSequence.Value (Index)->CStructure()));
7fd59977 1536 }
81bba717 1537 // else is impossible
7fd59977 1538 }
1539 MyDisplayedStructure.Remove (AStructure);
1540 if (AnUpdateMode == Aspect_TOU_ASAP) Update ();
1541 }
1542
1543}
1544
1545void Visual3d_View::Highlight (const Handle(Graphic3d_Structure)& AStructure, const Aspect_TypeOfHighlightMethod AMethod) {
1546
1547#ifdef TRACE_HIGH
1548 cout << "Visual3d_View" << MyCView.ViewId << "::Highlight ("
1549 << AStructure->Identification () << ")\n";
1550 cout << flush;
1551#endif
1552
1553Standard_Integer Index = IsComputed (AStructure);
1554 if (Index != 0) {
1555#ifdef TRACE_HIGH
81bba717 1556 cout << "Structure " << AStructure->Identification ()
1557 << " calculated, in the view "
1558 << Identification () << ", by the structure "
7fd59977 1559 << MyCOMPUTEDSequence.Value (Index)->Identification ()
81bba717 1560 << " passes in highlight mode.\n";
7fd59977 1561 cout << flush;
1562#endif
1563 (MyCOMPUTEDSequence.Value (Index))->SetHighlightColor
1564 (AStructure->HighlightColor ());
1565 (MyCOMPUTEDSequence.Value (Index))->GraphicHighlight (AMethod);
1566 }
1567
1568}
1569
1570void Visual3d_View::SetTransform (const Handle(Graphic3d_Structure)& AStructure, const TColStd_Array2OfReal& ATrsf) {
1571
1572#ifdef TRACE_TRSF
1573 cout << "Visual3d_View" << MyCView.ViewId << "::Transform ("
1574 << AStructure->Identification () << ")\n";
1575 cout << flush;
1576#endif
1577
1578Standard_Integer Index = IsComputed (AStructure);
1579 if (Index != 0) {
1580#ifdef TRACE_TRSF
81bba717 1581 cout << "The structure " << AStructure->Identification ()
1582 << " calculated, in the view "
1583 << Identification () << ", by the structure "
7fd59977 1584 << MyCOMPUTEDSequence.Value (Index)->Identification ()
81bba717 1585 << " is transformed.\n";
7fd59977 1586 cout << flush;
1587#endif
81bba717 1588 // Test is somewhat light !
1589 // trsf is transferred only if it is :
1590 // a translation
1591 // a scale
7fd59977 1592 if (ATrsf (0, 1) != 0. || ATrsf (0, 2) != 0.
1593 || ATrsf (1, 0) != 0. || ATrsf (1, 2) != 0.
1594 || ATrsf (2, 0) != 0. || ATrsf (2, 1) != 0.)
1595 ReCompute (AStructure);
1596 else
1597 MyCOMPUTEDSequence.Value (Index)->GraphicTransform (ATrsf);
1598 }
1599
1600}
1601
1602void Visual3d_View::UnHighlight (const Handle(Graphic3d_Structure)& AStructure) {
1603
1604#ifdef TRACE_HIGH
1605 cout << "Visual3d_View" << MyCView.ViewId << "::UnHighlight ("
1606 << AStructure->Identification () << ")\n";
1607 cout << flush;
1608#endif
1609
1610Standard_Integer Index = IsComputed (AStructure);
1611 if (Index != 0) {
1612#ifdef TRACE_HIGH
81bba717 1613 cout << "Structure " << AStructure->Identification ()
1614 << " calculated, in the view "
1615 << Identification () << ", by the structure "
7fd59977 1616 << MyCOMPUTEDSequence.Value (Index)->Identification ()
81bba717 1617 << " passes in unhighlight mode.\n";
7fd59977 1618 cout << flush;
1619#endif
1620 MyCOMPUTEDSequence.Value (Index)->GraphicUnHighlight ();
1621 }
1622
1623
1624}
1625
1626Standard_Integer Visual3d_View::IsComputed (const Handle(Graphic3d_Structure)& AStructure) const {
1627
1628Standard_Integer StrId = AStructure->Identification ();
1629
1630Standard_Integer Result = 0;
1631Standard_Integer Length = MyTOCOMPUTESequence.Length ();
1632
1633 // Recherche de la structure <AStructure> dans la
1634 // sequence des structures deja calculees
1635 for (Standard_Integer i=1; i<=Length && Result==0; i++)
1636 if ((MyTOCOMPUTESequence.Value (i))->Identification ()
1637 == StrId) Result = i;
1638#ifdef TRACE_ISCOMP
81bba717 1639 cout << "\n In the view " << Identification () << " the structure ";
7fd59977 1640 if (Result != 0)
81bba717 1641 cout << StrId << " is calculated by "
7fd59977 1642 << MyCOMPUTEDSequence.Value (Result)->Identification ()
1643 << "\n" << flush;
1644 else
81bba717 1645 cout << StrId << " is not calculated\n" << flush;
7fd59977 1646#endif
1647
1648#ifdef TRACE_LENGTH
1649 if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ()) {
1650 cout << "In Visual3d_View::IsComputed, ";
1651 cout << "TOCOMPUTE " << MyTOCOMPUTESequence.Length ()
1652 << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
1653 << "\n" << flush;
1654 }
1655#endif
1656
1657 return (Result);
1658
1659}
1660
1661Standard_Boolean Visual3d_View::IsDisplayed (const Handle(Graphic3d_Structure)& AStructure) const {
1662
1663Standard_Boolean Result = Standard_False;
1664
1665 if (IsDeleted ()) return Result;
1666
1667 Result = MyDisplayedStructure.Contains (AStructure);
1668
1669 return Result;
1670
1671}
1672
1673#ifdef IMPLEMENTED
1674Standard_Boolean Visual3d_View::ContainsComputedStructure () const {
1675
1676Standard_Boolean Result = Standard_False;
1677
1678 if (MyDisplayedStructure.IsEmpty ()) return Result;
1679
1680Graphic3d_MapIteratorOfMapOfStructure Iterator (MyDisplayedStructure);
1681
1682 Standard_Integer i = MyDisplayedStructure.Extent ();
1683
81bba717 1684 // Stop at the first structure of type TOS_COMPUTED
7fd59977 1685 while (! Result && Iterator.More ()) {
1686 Result =
1687 (((Iterator.Key ())->Visual ()) == Graphic3d_TOS_COMPUTED);
1688
bf75be98 1689 // Iterator.Next () is located on the
81bba717 1690 // next structure
7fd59977 1691 Iterator.Next ();
1692 }
1693
1694 return Result;
1695
1696}
1697#endif
1698
1699Standard_Boolean Visual3d_View::ContainsFacet () const {
1700
1701 return ContainsFacet (MyDisplayedStructure);
1702
1703}
1704
1705Standard_Boolean Visual3d_View::ContainsFacet (const Graphic3d_MapOfStructure& ASet) const {
1706
1707Standard_Boolean Result = Standard_False;
1708
1709 if (ASet.IsEmpty ()) return Result;
1710
1711Graphic3d_MapIteratorOfMapOfStructure Iterator (ASet);
1712
81bba717 1713 // Stop at the first structure containing a facet
7fd59977 1714 for ( Iterator.Initialize (ASet);
1715 Iterator.More () && ! Result;
1716 Iterator.Next ())
1717 Result = (Iterator.Key ())->ContainsFacet ();
1718
1719 return Result;
1720
1721}
1722
197ac94e 1723//=============================================================================
1724//function : MinMaxValues
1725//purpose :
1726//=============================================================================
1727void Visual3d_View::MinMaxValues (Standard_Real& theXMin,
1728 Standard_Real& theYMin,
1729 Standard_Real& theZMin,
1730 Standard_Real& theXMax,
1731 Standard_Real& theYMax,
1732 Standard_Real& theZMax,
1733 const Standard_Boolean theToIgnoreInfiniteFlag) const
1734{
1735 MinMaxValues (MyDisplayedStructure,
1736 theXMin, theYMin, theZMin,
1737 theXMax, theYMax, theZMax,
1738 theToIgnoreInfiniteFlag);
7fd59977 1739}
1740
197ac94e 1741//=============================================================================
1742//function : MinMaxValues
1743//purpose :
1744//=============================================================================
1745void Visual3d_View::MinMaxValues (const Graphic3d_MapOfStructure& theSet,
1746 Standard_Real& theXMin,
1747 Standard_Real& theYMin,
1748 Standard_Real& theZMin,
1749 Standard_Real& theXMax,
1750 Standard_Real& theYMax,
1751 Standard_Real& theZMax,
1752 const Standard_Boolean theToIgnoreInfiniteFlag) const
1753{
1754 if (theSet.IsEmpty ())
1755 {
1756 theXMin = RealFirst();
1757 theYMin = RealFirst();
1758 theZMin = RealFirst();
7fd59977 1759
197ac94e 1760 theXMax = RealLast();
1761 theYMax = RealLast();
1762 theZMax = RealLast();
7fd59977 1763 }
197ac94e 1764 else
1765 {
1766 Standard_Real aXm, aYm, aZm, aXM, aYM, aZM;
1767 Graphic3d_MapIteratorOfMapOfStructure anIterator (theSet);
7fd59977 1768
197ac94e 1769 theXMin = RealLast();
1770 theYMin = RealLast();
1771 theZMin = RealLast();
7fd59977 1772
197ac94e 1773 theXMax = RealFirst ();
1774 theYMax = RealFirst ();
1775 theZMax = RealFirst ();
7fd59977 1776
197ac94e 1777 for (anIterator.Initialize (theSet); anIterator.More(); anIterator.Next())
1778 {
1779 const Handle(Graphic3d_Structure)& aStructure = anIterator.Key();
7fd59977 1780
197ac94e 1781 if (aStructure->IsInfinite() && !theToIgnoreInfiniteFlag)
1782 {
7fd59977 1783 //XMin, YMin .... ZMax are initialized by means of infinite line data
197ac94e 1784 aStructure->MinMaxValues (aXm, aYm, aZm, aXM, aYM, aZM, Standard_False);
1785 if (aXm != RealFirst() && aXm < theXMin)
1786 {
1787 theXMin = aXm;
1788 }
1789 if (aYm != RealFirst() && aYm < theYMin)
1790 {
1791 theYMin = aYm;
1792 }
1793 if (aZm != RealFirst() && aZm < theZMin)
1794 {
1795 theZMin = aZm;
1796 }
1797 if (aXM != RealLast() && aXM > theXMax)
1798 {
1799 theXMax = aXM;
1800 }
1801 if (aYM != RealLast() && aYM > theYMax)
1802 {
1803 theYMax = aYM;
1804 }
1805 if (aZM != RealLast() && aZM > theZMax)
1806 {
1807 theZMax = aZM;
1808 }
7fd59977 1809 }
197ac94e 1810
bf75be98 1811 // Only non-empty and non-infinite structures
81bba717 1812 // are taken into account for calculation of MinMax
197ac94e 1813 if ((!aStructure->IsInfinite() || theToIgnoreInfiniteFlag) && !aStructure->IsEmpty())
1814 {
1815 aStructure->MinMaxValues (aXm, aYm, aZm, aXM, aYM, aZM, theToIgnoreInfiniteFlag);
1816
1817 /* ABD 29/10/04 Transform Persistence of Presentation( pan, zoom, rotate ) */
1818 //"FitAll" operation ignores object with transform persitence parameter
1819 if(aStructure->TransformPersistenceMode() == Graphic3d_TMF_None )
1820 {
1821 theXMin = Min (aXm, theXMin);
1822 theYMin = Min (aYm, theYMin);
1823 theZMin = Min (aZm, theZMin);
1824 theXMax = Max (aXM, theXMax);
1825 theYMax = Max (aYM, theYMax);
1826 theZMax = Max (aZM, theZMax);
7fd59977 1827 }
197ac94e 1828 }
7fd59977 1829 }
1830
81bba717 1831 // The following cases are relevant
1832 // For exemple if all structures are empty or infinite
197ac94e 1833 if (theXMax < theXMin) { aXm = theXMin; theXMin = theXMax; theXMax = aXm; }
1834 if (theYMax < theYMin) { aYm = theYMin; theYMin = theYMax; theYMax = aYm; }
1835 if (theZMax < theZMin) { aZm = theZMin; theZMin = theZMax; theZMax = aZm; }
7fd59977 1836 }
7fd59977 1837}
1838
197ac94e 1839//=============================================================================
1840//function : MinMaxValues
1841//purpose :
1842//=============================================================================
1843void Visual3d_View::MinMaxValues (Standard_Real& theXMin,
1844 Standard_Real& theYMin,
1845 Standard_Real& theXMax,
1846 Standard_Real& theYMax,
1847 const Standard_Boolean theToIgnoreInfiniteFlag) const
1848{
1849 MinMaxValues (MyDisplayedStructure,
1850 theXMin, theYMin,
1851 theXMax, theYMax,
1852 theToIgnoreInfiniteFlag);
7fd59977 1853}
1854
197ac94e 1855//=============================================================================
1856//function : MinMaxValues
1857//purpose :
1858//=============================================================================
1859void Visual3d_View::MinMaxValues (const Graphic3d_MapOfStructure& theSet,
1860 Standard_Real& theXMin,
1861 Standard_Real& theYMin,
1862 Standard_Real& theXMax,
1863 Standard_Real& theYMax,
1864 const Standard_Boolean theToIgnoreInfiniteFlag) const
1865{
1866 Standard_Real aXm, aYm, aZm, aXM, aYM, aZM;
1867 Standard_Real aXp, aYp, aZp;
7fd59977 1868
197ac94e 1869 MinMaxValues (theSet, aXm, aYm, aZm, aXM, aYM, aZM, theToIgnoreInfiniteFlag);
7fd59977 1870
197ac94e 1871 Projects (aXm, aYm, aZm, aXp, aYp, aZp);
1872 theXMin = aXp;
1873 theYMin = aYp;
7fd59977 1874
197ac94e 1875 Projects (aXM, aYM, aZM, aXp, aYp, aZp);
1876 theXMax = aXp;
1877 theYMax = aYp;
7fd59977 1878
197ac94e 1879 if (theXMax < theXMin) { aXp = theXMax; theXMax = theXMin; theXMin = aXp; }
1880 if (theYMax < theYMin) { aYp = theYMax; theYMax = theYMin; theYMin = aYp; }
7fd59977 1881}
1882
7fd59977 1883Standard_Integer Visual3d_View::NumberOfDisplayedStructures () const {
1884
1885Standard_Integer Result = MyDisplayedStructure.Extent ();
1886
1887 return (Result);
1888
1889}
1890
197ac94e 1891//=======================================================================
1892//function : Projects
1893//purpose :
1894//=======================================================================
1895void Visual3d_View::Projects (const Standard_Real theX,
1896 const Standard_Real theY,
1897 const Standard_Real theZ,
1898 Standard_Real& thePX,
1899 Standard_Real& thePY,
1900 Standard_Real& thePZ) const
b5ac8292 1901{
197ac94e 1902 const Handle(Graphic3d_Camera)& aCamera = MyCView.Context.Camera;
7fd59977 1903
197ac94e 1904 gp_XYZ aViewSpaceDimensions = aCamera->ViewDimensions();
1905 Standard_Real aXSize = aViewSpaceDimensions.X();
1906 Standard_Real aYSize = aViewSpaceDimensions.Y();
1907 Standard_Real aZSize = aViewSpaceDimensions.Z();
7fd59977 1908
197ac94e 1909 gp_Pnt aPoint = aCamera->Project (gp_Pnt (theX, theY, theZ));
7fd59977 1910
197ac94e 1911 // NDC [-1, 1] --> PROJ [ -size / 2, +size / 2 ]
1912 thePX = aPoint.X() * aXSize * 0.5;
1913 thePY = aPoint.Y() * aYSize * 0.5;
1914 thePZ = aPoint.Z() * aZSize * 0.5;
7fd59977 1915}
1916
1917Standard_Integer Visual3d_View::Identification () const {
1918
1919 return (Standard_Integer (MyCView.ViewId));
1920
1921}
1922
7fd59977 1923
1924Standard_Boolean Visual3d_View::ZBufferIsActivated () const {
1925
1926 if (IsDeleted ()) return (Standard_False);
1927
1928 if ((! IsDefined ()) || (! IsActive ())) return (Standard_False);
1929
81bba717 1930// -1 => not forced by the programmer => depends on the type of visualisation
1931// 0 ou 1 => forced by the programmer
7fd59977 1932
1933 if (MyCView.Context.ZBufferActivity == -1)
1934 if (MyContext.Visualization () == Visual3d_TOV_SHADING)
1935 return (Standard_True);
1936 else
1937 return (Standard_False);
1938 else
1939 if (MyCView.Context.ZBufferActivity)
1940 return (Standard_True);
1941 else
1942 return (Standard_False);
1943
1944}
1945
1946void Visual3d_View::SetTransparency (const Standard_Boolean AnActivity) {
1947
1948 if (IsDeleted ()) return;
1949
1950 if ((! IsDefined ()) || (! IsActive ())) return;
1951
1952 MyGraphicDriver->Transparency (MyCView, AnActivity);
1953
1954}
1955
1956void Visual3d_View::SetZBufferActivity (const Standard_Integer AnActivity) {
1957
1958 if (MyCView.Context.ZBufferActivity == AnActivity) return;
1959
1960 if (IsDeleted ()) return;
1961
1962 if ((! IsDefined ()) || (! IsActive ())) return;
1963
1964 MyCView.Context.ZBufferActivity = AnActivity;
1965 MyGraphicDriver->SetVisualisation (MyCView);
1966
1967}
1968
1969void Visual3d_View::UpdateView () {
1970
1971 MyCView.Context.Aliasing = (MyContext.AliasingIsOn () ? 1:0);
1972 MyCView.Context.BackZClipping =
1973 (MyContext.BackZClippingIsOn () ? 1:0);
1974 MyCView.Context.FrontZClipping =
1975 (MyContext.FrontZClippingIsOn() ? 1:0);
1976 MyCView.Context.DepthCueing =
1977 (MyContext.DepthCueingIsOn () ? 1:0);
1978
1979 MyCView.Context.ZClipFrontPlane =
1980 float (MyContext.ZClippingFrontPlane ());
1981 MyCView.Context.ZClipBackPlane =
1982 float (MyContext.ZClippingBackPlane ());
1983 MyCView.Context.DepthFrontPlane =
1984 float (MyContext.DepthCueingFrontPlane ());
1985 MyCView.Context.DepthBackPlane =
1986 float (MyContext.DepthCueingBackPlane ());
1987
1988 MyCView.Context.Model = int (MyContext.Model ());
1989 MyCView.Context.Visualization = int (MyContext.Visualization ());
1990
bf75be98 1991 MyCView.Context.TextureEnv = MyContext.TextureEnv();
7fd59977 1992 MyCView.Context.SurfaceDetail = MyContext.SurfaceDetail();
1993
1994}
1995
1996void Visual3d_View::Compute () {
1997
1998Standard_Integer i;
1999Standard_Integer Length = MyCOMPUTEDSequence.Length ();
2000 for (i=1; i<=Length; i++)
2001 (MyCOMPUTEDSequence.Value (i))->SetHLRValidation (Standard_False);
2002
de75ed09 2003 if (!ComputedMode())
2004 {
2005 return;
2006 }
7fd59977 2007
2008 /*
81bba717 2009 * Force HLRValidation to False on all structures
2010 * calculated in the view.
7fd59977 2011 */
2012#ifdef TRACE_LENGTH
2013 if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ()) {
2014 cout << "In Visual3d_View::Compute, ";
2015 cout << "TOCOMPUTE " << MyTOCOMPUTESequence.Length ()
2016 << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
2017 << "\n" << flush;
2018 }
2019#endif
2020
2021 /*
81bba717 2022 * Change of orientation or of projection type =>
2023 * Remove structures that were calculated for the
2024 * previous orientation.
2025 * Recalculation of new structures.
7fd59977 2026 */
2027Graphic3d_MapIteratorOfMapOfStructure S1Iterator (MyDisplayedStructure);
2028Visual3d_TypeOfAnswer Answer;
2029
2030 i = MyDisplayedStructure.Extent ();
2031
2032Graphic3d_SequenceOfStructure FooSequence;
2033
2034 while (S1Iterator.More ()) {
2035 Answer = AcceptDisplay (S1Iterator.Key ());
81bba717 2036 // If the structure was calculated, it is recalculated.
7fd59977 2037 if (Answer == Visual3d_TOA_COMPUTE) {
2038#ifdef TRACE
2039 cout << "AcceptDisplay ("
2040 << (S1Iterator.Key ())->Identification ()
2041 << ") == Visual3d_TOA_COMPUTE;\n";
2042 cout << flush;
2043#endif
2044 //Display (S1Iterator.Key (), Aspect_TOU_WAIT);
2045 FooSequence.Append (S1Iterator.Key ());
2046 }
2047
81bba717 2048 // S1Iterator.Next () is located on the next structure
7fd59977 2049 S1Iterator.Next ();
2050 }
2051
2052 Length = FooSequence.Length ();
81bba717 2053 // All stored structures are displayed
7fd59977 2054 for (i=1; i<=Length; i++)
2055 Display (FooSequence.Value (i), Aspect_TOU_WAIT);
2056 if (Length != 0) FooSequence.Clear ();
2057
2058}
2059
2060void Visual3d_View::ReCompute (const Handle(Graphic3d_Structure)& AStructure) {
de75ed09 2061 if (!ComputedMode()) return;
7fd59977 2062
2063 if (IsDeleted ()) return;
2064
2065 if ((! IsDefined ()) || (! IsActive ())) return;
2066
2067 if (! MyWindow->IsMapped ()) return;
2068
2069 if (! AStructure->IsDisplayed ()) return;
2070
2071Visual3d_TypeOfAnswer Answer;
2072
2073 Answer = AcceptDisplay (AStructure);
2074
2075 if (Answer == Visual3d_TOA_COMPUTE) {
2076Standard_Integer Index = IsComputed (AStructure);
2077 if (Index == 0) {
2078#ifdef TRACE_COMP
81bba717 2079 cout << "Structure " << AStructure->Identification ()
2080 << " is not calculated in the view "
7fd59977 2081 << Identification () << "\n";
2082 cout << flush;
2083#endif
2084 }
2085 else {
2086 Standard_Integer OldStructId, NewStructId;
2087 OldStructId =
2088 MyCOMPUTEDSequence.Value (Index)->Identification ();
2089#ifdef TRACE_COMP
2090 Standard_Integer StructId = AStructure->Identification ();
81bba717 2091 cout << "Structure " << StructId
2092 << " calculated, in the view "
2093 << Identification () << ", by the structure "
2094 << OldStructId << " is recalculated.\n";
7fd59977 2095 cout << flush;
2096#endif
2097
2098 // Compute + Validation
2099#ifdef OLD
2100Handle(Graphic3d_Structure) TheStructure = AStructure->Compute (this);
2101#else
2102Handle(Graphic3d_Structure) TheStructure;
2103TColStd_Array2OfReal ATrsf (0, 3, 0, 3);
2104 AStructure->Transform (ATrsf);
2105 if (Index != 0) {
2106TColStd_Array2OfReal Ident (0, 3, 0, 3);
2107Standard_Integer ii, jj;
2108 for (ii=0; ii<=3; ii++)
2109 for (jj=0; jj<=3; jj++)
2110 Ident (ii, jj) = (ii == jj ? 1.0 : 0.0);
2111 TheStructure = MyCOMPUTEDSequence.Value (Index);
2112 TheStructure->SetTransform (Ident, Graphic3d_TOC_REPLACE);
2113 if (AStructure->IsTransformed ()) {
2114 AStructure->Compute (this, ATrsf, TheStructure);
2115 }
2116 else {
2117 AStructure->Compute (this, TheStructure);
2118 }
2119 }
2120 else {
2121 if (AStructure->IsTransformed ()) {
2122 TheStructure = AStructure->Compute (this, ATrsf);
2123 }
2124 else {
2125 TheStructure = AStructure->Compute (this);
2126 }
2127 }
2128#endif
2129 TheStructure->SetHLRValidation (Standard_True);
2130
81bba717 2131// Return type of visualisation of the view
7fd59977 2132Visual3d_TypeOfVisualization ViewType = MyContext.Visualization ();
2133
81bba717 2134// Of which type will be the computed ?
7fd59977 2135Standard_Boolean ComputeWireframe = ((ViewType == Visual3d_TOV_WIREFRAME) &&
2136 (AStructure->ComputeVisual () != Graphic3d_TOS_SHADING));
2137
2138Standard_Boolean ComputeShading = ((ViewType == Visual3d_TOV_SHADING) &&
2139 (AStructure->ComputeVisual () != Graphic3d_TOS_WIREFRAME));
2140
2141 if (ComputeWireframe)
2142 TheStructure->SetVisual (Graphic3d_TOS_WIREFRAME);
2143 if (ComputeShading)
2144 TheStructure->SetVisual (Graphic3d_TOS_SHADING);
2145
2146 if (AStructure->IsHighlighted ()) {
2147 TheStructure->SetHighlightColor
2148 (AStructure->HighlightColor ());
2149 TheStructure->GraphicHighlight (Aspect_TOHM_COLOR);
2150 }
2151
81bba717 2152 // Ot is ranged
2153 // Find structure <AStructure>
2154 // in the sequence of structures to be calculated.
7fd59977 2155 NewStructId = TheStructure->Identification ();
2156
81bba717 2157 // The previous calculation is removed and the new one is dislayed
63bcc448 2158 MyGraphicDriver->EraseStructure (MyCView, *(MyCOMPUTEDSequence.Value (Index)->CStructure()));
2159 MyGraphicDriver->DisplayStructure (MyCView, *(TheStructure->CStructure()), AStructure->DisplayPriority());
7fd59977 2160
2161#ifdef TRACE_LENGTH
2162 if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ()) {
2163 cout << "In Visual3d_View::ReCompute, ";
2164 cout << "TOCOMPUTE " << MyTOCOMPUTESequence.Length ()
2165 << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
2166 << "\n" << flush;
2167 }
2168#endif
2169
81bba717 2170 // hlhsr and the new associated compute are added
7fd59977 2171 MyTOCOMPUTESequence.Append (AStructure);
2172 MyCOMPUTEDSequence.Append (TheStructure);
2173
2174#ifdef TRACE_LENGTH
2175 if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ())
2176 cout << "\tTOCOMPUTE " << MyTOCOMPUTESequence.Length ()
2177 << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
2178 << "\n" << flush;
2179#endif
2180
bf75be98 2181 // hlhsr and the new associated compute are removed
7fd59977 2182
2183 MyTOCOMPUTESequence.Remove (Index);
2184 MyCOMPUTEDSequence.Remove (Index);
2185
2186#ifdef TRACE_LENGTH
2187 if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ())
2188 cout << "\tTOCOMPUTE " << MyTOCOMPUTESequence.Length ()
2189 << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
2190 << "\n" << flush;
2191#endif
2192 }
2193 }
2194
2195}
2196
6942f04a 2197const Handle(Graphic3d_GraphicDriver)& Visual3d_View::GraphicDriver () const {
7fd59977 2198
2199 return MyGraphicDriver;
2200
2201}
2202
de75ed09 2203void Visual3d_View::Plot (const Handle(Graphic3d_Plotter)& thePlotter) const
2204{
2205 for (Graphic3d_MapIteratorOfMapOfStructure S1Iterator (MyDisplayedStructure); S1Iterator.More(); S1Iterator.Next())
2206 {
2207 Standard_Integer Index = IsComputed (S1Iterator.Key ());
2208 // displayed structure is plotted as if it was not calculated
2209 if (Index == 0)
2210 (S1Iterator.Key ())->Plot (thePlotter);
2211 else
2212 (MyCOMPUTEDSequence.Value (Index))->Plot (thePlotter);
2213 }
7fd59977 2214}
2215
2216Standard_Integer Visual3d_View::HaveTheSameOwner (const Handle(Graphic3d_Structure)& AStructure) const {
2217
2218Standard_Integer Result = 0;
2219Standard_Integer Length = MyTOCOMPUTESequence.Length ();
2220
bf75be98 2221 // Find in the sequence of already calculated structures
81bba717 2222 // 1/ Structure with the same Owner as <AStructure>
2223 // 2/ Which is not <AStructure>
2224 // 3/ COMPUTED which of is valid
7fd59977 2225 for (Standard_Integer i=1; i<=Length && Result==0; i++)
2226 if ((MyTOCOMPUTESequence.Value (i)->Owner () == AStructure->Owner ())
2227 && (MyTOCOMPUTESequence.Value (i)->Identification () !=
2228 AStructure->Identification ())
2229 && (MyCOMPUTEDSequence.Value (i)->HLRValidation ())) Result = i;
2230
2231 return (Result);
2232
2233}
2234
2235Standard_Address Visual3d_View::CView () const {
2236
2237 return Standard_Address (&MyCView);
2238
2239}
2240
2241
2242// Triedron methods : the Triedron is a non-zoomable object.
2243
2244void Visual3d_View::ZBufferTriedronSetup(const Quantity_NameOfColor XColor,
2245 const Quantity_NameOfColor YColor,
2246 const Quantity_NameOfColor ZColor,
2247 const Standard_Real SizeRatio,
2248 const Standard_Real AxisDiametr,
2249 const Standard_Integer NbFacettes) {
2250 MyGraphicDriver->ZBufferTriedronSetup(XColor, YColor, ZColor,
2251 SizeRatio, AxisDiametr, NbFacettes);
2252}
2253
2254
2255
2256void Visual3d_View::TriedronDisplay (const Aspect_TypeOfTriedronPosition APosition,
2257 const Quantity_NameOfColor AColor, const Standard_Real AScale, const Standard_Boolean AsWireframe ) {
2258
2259 MyGraphicDriver->TriedronDisplay (MyCView,APosition, AColor, AScale, AsWireframe);
2260
2261}
2262
2263void Visual3d_View::TriedronErase () {
2264
2265 MyGraphicDriver->TriedronErase (MyCView);
2266
2267
2268}
2269
2270void Visual3d_View::TriedronEcho (const Aspect_TypeOfTriedronEcho AType ) {
2271
2272 MyGraphicDriver->TriedronEcho (MyCView,AType);
2273
2274}
2275
fd03ee4b 2276static Standard_Boolean checkFloat(const Standard_Real value)
7fd59977 2277{
2278 return value > -FLT_MAX && value < FLT_MAX;
2279}
2280
fd03ee4b 2281static void SetMinMaxValuesCallback(Visual3d_View* theView)
7fd59977 2282{
2283 Standard_Real xmin, ymin, zmin, xmax, ymax, zmax;
fd03ee4b 2284 theView->MinMaxValues(xmin, ymin, zmin, xmax, ymax, zmax);
7fd59977 2285
2286 if (checkFloat(xmin) && checkFloat(ymin) && checkFloat(zmin) &&
2287 checkFloat(xmax) && checkFloat(ymax) && checkFloat(zmax))
2288 {
fd03ee4b 2289 Handle(Graphic3d_GraphicDriver) driver = Handle(Graphic3d_GraphicDriver)::DownCast(theView->GraphicDriver());
7fd59977 2290 driver->GraduatedTrihedronMinMaxValues((Standard_ShortReal)xmin, (Standard_ShortReal)ymin, (Standard_ShortReal)zmin,
2291 (Standard_ShortReal)xmax, (Standard_ShortReal)ymax, (Standard_ShortReal)zmax);
2292 }
2293}
2294
13a22457
S
2295Standard_Boolean Visual3d_View::GetGraduatedTrihedron
2296 (/* Names of axes */
2297 TCollection_ExtendedString& xname,
2298 TCollection_ExtendedString& yname,
2299 TCollection_ExtendedString& zname,
2300 /* Draw names */
2301 Standard_Boolean& xdrawname,
2302 Standard_Boolean& ydrawname,
2303 Standard_Boolean& zdrawname,
2304 /* Draw values */
2305 Standard_Boolean& xdrawvalues,
2306 Standard_Boolean& ydrawvalues,
2307 Standard_Boolean& zdrawvalues,
2308 /* Draw grid */
2309 Standard_Boolean& drawgrid,
2310 /* Draw axes */
2311 Standard_Boolean& drawaxes,
2312 /* Number of splits along axes */
2313 Standard_Integer& nbx,
2314 Standard_Integer& nby,
2315 Standard_Integer& nbz,
2316 /* Offset for drawing values */
2317 Standard_Integer& xoffset,
2318 Standard_Integer& yoffset,
2319 Standard_Integer& zoffset,
2320 /* Offset for drawing names of axes */
2321 Standard_Integer& xaxisoffset,
2322 Standard_Integer& yaxisoffset,
2323 Standard_Integer& zaxisoffset,
2324 /* Draw tickmarks */
2325 Standard_Boolean& xdrawtickmarks,
2326 Standard_Boolean& ydrawtickmarks,
2327 Standard_Boolean& zdrawtickmarks,
2328 /* Length of tickmarks */
2329 Standard_Integer& xtickmarklength,
2330 Standard_Integer& ytickmarklength,
2331 Standard_Integer& ztickmarklength,
2332 /* Grid color */
2333 Quantity_Color& gridcolor,
2334 /* Colors of axis names */
2335 Quantity_Color& xnamecolor,
2336 Quantity_Color& ynamecolor,
2337 Quantity_Color& znamecolor,
2338 /* Colors of axis and values */
2339 Quantity_Color& xcolor,
2340 Quantity_Color& ycolor,
2341 Quantity_Color& zcolor,
2342 /* Name of font for names of axes */
2343 TCollection_AsciiString& fontOfNames,
2344 /* Style of names of axes */
eeaaaefb 2345 Font_FontAspect& styleOfNames,
13a22457
S
2346 /* Size of names of axes */
2347 Standard_Integer& sizeOfNames,
2348 /* Name of font for values */
2349 TCollection_AsciiString& fontOfValues,
2350 /* Style of values */
eeaaaefb 2351 Font_FontAspect& styleOfValues,
13a22457
S
2352 /* Size of values */
2353 Standard_Integer& sizeOfValues) const
7fd59977 2354{
13a22457
S
2355 if (!MyGTrihedron.ptrVisual3dView)
2356 return Standard_False;
2357
2358 /* Names of axes */
2359 xname = MyGTrihedron.xname;
bf75be98 2360 yname = MyGTrihedron.yname;
13a22457
S
2361 zname = MyGTrihedron.zname;
2362 /* Draw names */
bf75be98 2363 xdrawname = MyGTrihedron.xdrawname;
2364 ydrawname = MyGTrihedron.ydrawname;
13a22457
S
2365 zdrawname = MyGTrihedron.zdrawname;
2366 /* Draw values */
bf75be98 2367 xdrawvalues = MyGTrihedron.xdrawvalues;
2368 ydrawvalues = MyGTrihedron.ydrawvalues;
13a22457
S
2369 zdrawvalues = MyGTrihedron.zdrawvalues;
2370 /* Draw grid */
2371 drawgrid = MyGTrihedron.drawgrid;
2372 /* Draw axes */
2373 drawaxes = MyGTrihedron.drawaxes;
2374 /* Number of splits along axes */
2375 nbx = MyGTrihedron.nbx;
2376 nby = MyGTrihedron.nby;
2377 nbz = MyGTrihedron.nbz;
2378 /* Offset for drawing values */
2379 xoffset = MyGTrihedron.xoffset;
2380 yoffset = MyGTrihedron.yoffset;
2381 zoffset = MyGTrihedron.zoffset;
2382 /* Offset for drawing names of axes */
2383 xaxisoffset = MyGTrihedron.xaxisoffset;
2384 yaxisoffset = MyGTrihedron.yaxisoffset;
2385 zaxisoffset = MyGTrihedron.zaxisoffset;
2386 /* Draw tickmarks */
2387 xdrawtickmarks = MyGTrihedron.xdrawtickmarks;
2388 ydrawtickmarks = MyGTrihedron.ydrawtickmarks;
2389 zdrawtickmarks = MyGTrihedron.zdrawtickmarks;
2390 /* Length of tickmarks */
2391 xtickmarklength = MyGTrihedron.xtickmarklength;
2392 ytickmarklength = MyGTrihedron.ytickmarklength;
2393 ztickmarklength = MyGTrihedron.ztickmarklength;
2394 /* Grid color */
2395 gridcolor = MyGTrihedron.gridcolor;
2396 /* Colors of axis names */
2397 xnamecolor = MyGTrihedron.xnamecolor;
2398 ynamecolor = MyGTrihedron.ynamecolor;
2399 znamecolor = MyGTrihedron.znamecolor;
2400 /* Colors of axis and values */
2401 xcolor = MyGTrihedron.xcolor;
2402 ycolor = MyGTrihedron.ycolor;
2403 zcolor = MyGTrihedron.zcolor;
2404 /* Name of font for names of axes */
2405 fontOfNames = MyGTrihedron.fontOfNames;
2406 /* Style of names of axes */
2407 styleOfNames = MyGTrihedron.styleOfNames;
2408 /* Size of names of axes */
2409 sizeOfNames = MyGTrihedron.sizeOfNames;
2410 /* Name of font for values */
2411 fontOfValues = MyGTrihedron.fontOfValues;
2412 /* Style of values */
2413 styleOfValues = MyGTrihedron.styleOfValues;
2414 /* Size of values */
2415 sizeOfValues = MyGTrihedron.sizeOfValues;
2416
2417 return Standard_True;
2418}
2419
2420void Visual3d_View::GraduatedTrihedronDisplay
2421 (/* Names of axes */
2422 const TCollection_ExtendedString &xname,
2423 const TCollection_ExtendedString &yname,
2424 const TCollection_ExtendedString &zname,
2425 /* Draw names */
2426 const Standard_Boolean xdrawname,
2427 const Standard_Boolean ydrawname,
2428 const Standard_Boolean zdrawname,
2429 /* Draw values */
2430 const Standard_Boolean xdrawvalues,
2431 const Standard_Boolean ydrawvalues,
2432 const Standard_Boolean zdrawvalues,
2433 /* Draw grid */
2434 const Standard_Boolean drawgrid,
2435 /* Draw axes */
2436 const Standard_Boolean drawaxes,
2437 /* Number of splits along axes */
2438 const Standard_Integer nbx,
2439 const Standard_Integer nby,
2440 const Standard_Integer nbz,
2441 /* Offset for drawing values */
2442 const Standard_Integer xoffset,
2443 const Standard_Integer yoffset,
2444 const Standard_Integer zoffset,
2445 /* Offset for drawing names of axes */
2446 const Standard_Integer xaxisoffset,
2447 const Standard_Integer yaxisoffset,
2448 const Standard_Integer zaxisoffset,
2449 /* Draw tickmarks */
2450 const Standard_Boolean xdrawtickmarks,
2451 const Standard_Boolean ydrawtickmarks,
2452 const Standard_Boolean zdrawtickmarks,
2453 /* Length of tickmarks */
2454 const Standard_Integer xtickmarklength,
2455 const Standard_Integer ytickmarklength,
2456 const Standard_Integer ztickmarklength,
2457 /* Grid color */
2458 const Quantity_Color& gridcolor,
2459 /* Colors of axis names */
2460 const Quantity_Color& xnamecolor,
2461 const Quantity_Color& ynamecolor,
2462 const Quantity_Color& znamecolor,
2463 /* Colors of axis and values */
2464 const Quantity_Color& xcolor,
2465 const Quantity_Color& ycolor,
2466 const Quantity_Color& zcolor,
2467 /* Name of font for names of axes */
2468 const TCollection_AsciiString &fontOfNames,
2469 /* Style of names of axes */
eeaaaefb 2470 const Font_FontAspect styleOfNames,
13a22457
S
2471 /* Size of names of axes */
2472 const Standard_Integer sizeOfNames,
2473 /* Name of font for values */
2474 const TCollection_AsciiString &fontOfValues,
2475 /* Style of values */
eeaaaefb 2476 const Font_FontAspect styleOfValues,
13a22457
S
2477 /* Size of values */
2478 const Standard_Integer sizeOfValues)
7fd59977 2479{
13a22457
S
2480 /* Names of axes */
2481 MyGTrihedron.xname = xname;
2482 MyGTrihedron.yname = yname;
2483 MyGTrihedron.zname = zname;
2484 /* Draw names */
2485 MyGTrihedron.xdrawname = xdrawname;
2486 MyGTrihedron.ydrawname = ydrawname;
2487 MyGTrihedron.zdrawname = zdrawname;
2488 /* Draw values */
2489 MyGTrihedron.xdrawvalues = xdrawvalues;
2490 MyGTrihedron.ydrawvalues = ydrawvalues;
2491 MyGTrihedron.zdrawvalues = zdrawvalues;
2492 /* Draw grid */
2493 MyGTrihedron.drawgrid = drawgrid;
2494 /* Draw axes */
2495 MyGTrihedron.drawaxes = drawaxes;
2496 /* Number of splits along axes */
2497 MyGTrihedron.nbx = nbx;
2498 MyGTrihedron.nby = nby;
2499 MyGTrihedron.nbz = nbz;
2500 /* Offset for drawing values */
2501 MyGTrihedron.xoffset = xoffset;
2502 MyGTrihedron.yoffset = yoffset;
2503 MyGTrihedron.zoffset = zoffset;
2504 /* Offset for drawing names of axes */
2505 MyGTrihedron.xaxisoffset = xaxisoffset;
2506 MyGTrihedron.yaxisoffset = yaxisoffset;
2507 MyGTrihedron.zaxisoffset = zaxisoffset;
2508 /* Draw tickmarks */
2509 MyGTrihedron.xdrawtickmarks = xdrawtickmarks;
2510 MyGTrihedron.ydrawtickmarks = ydrawtickmarks;
2511 MyGTrihedron.zdrawtickmarks = zdrawtickmarks;
2512 /* Length of tickmarks */
2513 MyGTrihedron.xtickmarklength = xtickmarklength;
2514 MyGTrihedron.ytickmarklength = ytickmarklength;
2515 MyGTrihedron.ztickmarklength = ztickmarklength;
2516 /* Grid color */
2517 MyGTrihedron.gridcolor = gridcolor;
2518 /* Colors of axis names */
2519 MyGTrihedron.xnamecolor = xnamecolor;
2520 MyGTrihedron.ynamecolor = ynamecolor;
2521 MyGTrihedron.znamecolor = znamecolor;
2522 /* Colors of axis and values */
2523 MyGTrihedron.xcolor = xcolor;
2524 MyGTrihedron.ycolor = ycolor;
2525 MyGTrihedron.zcolor = zcolor;
2526 /* Name of font for names of axes */
2527 MyGTrihedron.fontOfNames = fontOfNames;
2528 /* Style of names of axes */
2529 MyGTrihedron.styleOfNames = styleOfNames;
2530 /* Size of names of axes */
2531 MyGTrihedron.sizeOfNames = sizeOfNames;
2532 /* Name of font for values */
2533 MyGTrihedron.fontOfValues = fontOfValues;
2534 /* Style of values */
2535 MyGTrihedron.styleOfValues = styleOfValues;
2536 /* Size of values */
2537 MyGTrihedron.sizeOfValues = sizeOfValues;
2538
2539 MyGTrihedron.ptrVisual3dView = this;
2540 MyGTrihedron.cbCubicAxes = SetMinMaxValuesCallback;
2541 MyGraphicDriver->GraduatedTrihedronDisplay(MyCView,MyGTrihedron);
7fd59977 2542}
2543
2544void Visual3d_View::GraduatedTrihedronErase()
2545{
13a22457 2546 MyGTrihedron.ptrVisual3dView = NULL;
7fd59977 2547 MyGraphicDriver->GraduatedTrihedronErase(MyCView);
2548}
2549
2550const Handle(Visual3d_Layer)& Visual3d_View::UnderLayer () const {
2551
2552 return (MyViewManager->UnderLayer ());
2553
2554}
2555
2556const Handle(Visual3d_Layer)& Visual3d_View::OverLayer () const {
2557
2558 return (MyViewManager->OverLayer ());
2559
2560}
2561
2562Standard_Integer Visual3d_View::LightLimit() const {
2563
2564 Standard_Integer maxlight = MyGraphicDriver->InquireLightLimit ();
2565// printf(" $$$ Visual3d_View::LightLimit() is %d\n",maxlight);
2566 return maxlight;
2567}
2568
2569Standard_Integer Visual3d_View::PlaneLimit() const {
2570
2571 Standard_Integer maxplane = MyGraphicDriver->InquirePlaneLimit ();
2572// printf(" $$$ Visual3d_View::PlaneLimit() is %d\n",maxplane);
2573 return maxplane;
2574}
2575
bf75be98 2576Handle(Visual3d_ViewManager) Visual3d_View::ViewManager() const
2577{
2578 return MyPtrViewManager;
7fd59977 2579}
7fd59977 2580
de75ed09 2581void Visual3d_View :: SetComputedMode ( const Standard_Boolean aMode )
2582{
2583 if ((aMode && ComputedModeIsActive) ||
2584 (!aMode && !ComputedModeIsActive))
2585 {
2586 return;
2587 }
7fd59977 2588
2589 Graphic3d_MapIteratorOfMapOfStructure S1Iterator ( MyDisplayedStructure );
2590 Visual3d_TypeOfAnswer Answer;
2591 Standard_Integer StructId;
2592 Standard_Integer i = MyDisplayedStructure.Extent ();
773f53f1 2593 ComputedModeIsActive = aMode;
2594 if (!ComputedModeIsActive) {
7fd59977 2595
2596 while ( S1Iterator.More () ) {
2597
2598 Answer = AcceptDisplay ( S1Iterator.Key () );
2599
2600 if ( Answer == Visual3d_TOA_COMPUTE ) {
2601
2602 Standard_Integer Index = IsComputed ( S1Iterator.Key () );
2603
2604 if ( Index != 0 ) {
2605
2606 StructId = MyCOMPUTEDSequence.Value ( Index ) -> Identification ();
2607
63bcc448 2608 MyGraphicDriver->EraseStructure (MyCView, *(MyCOMPUTEDSequence.Value (Index)->CStructure()));
2609 MyGraphicDriver->DisplayStructure (MyCView, *(S1Iterator.Key()->CStructure()), S1Iterator.Key()->DisplayPriority());
7fd59977 2610 } // end if ( Index != 0 ) . . .
2611
2612 } // end if ( Answer . . . )
2613
2614 S1Iterator.Next ();
2615
2616 } // end while
2617
2618 } else {
2619
2620 while ( S1Iterator.More () ) {
2621
2622 Answer = AcceptDisplay ( S1Iterator.Key () );
2623
2624 if ( Answer == Visual3d_TOA_COMPUTE ) {
2625
2626 Standard_Integer Index = IsComputed ( S1Iterator.Key () );
2627
2628 if ( Index != 0 ) {
2629
2630 StructId = MyCOMPUTEDSequence.Value ( Index ) -> Identification ();
2631
63bcc448 2632 MyGraphicDriver->EraseStructure (MyCView, *(S1Iterator.Key()->CStructure()));
2633 MyGraphicDriver->DisplayStructure (MyCView, *(MyCOMPUTEDSequence.Value (Index)->CStructure()), S1Iterator.Key()->DisplayPriority());
7fd59977 2634
2635 Display ( S1Iterator.Key (), Aspect_TOU_WAIT );
2636
2637 if ( S1Iterator.Key () -> IsHighlighted () ) {
2638
2639 if ( !MyCOMPUTEDSequence.Value ( Index ) -> IsHighlighted () ) {
2640
2641 MyCOMPUTEDSequence.Value ( Index ) -> SetHighlightColor (
2642 S1Iterator.Key () ->
2643 HighlightColor ()
2644 );
2645 MyCOMPUTEDSequence.Value ( Index ) -> GraphicHighlight (
2646 Aspect_TOHM_COLOR
2647 );
2648 } // end if
2649
2650 } // end if
2651
2652 } else {
2653
2654 Handle( Graphic3d_Structure ) AStructure = S1Iterator.Key ();
2655#ifdef OLD
2656 Handle( Graphic3d_Structure ) TheStructure = AStructure -> Compute ( this );
2657#else
2658 Handle( Graphic3d_Structure ) TheStructure;
2659 TColStd_Array2OfReal ATrsf ( 0, 3, 0, 3 );
2660
2661 AStructure -> Transform ( ATrsf );
2662
2663 if ( Index != 0 ) {
2664
2665 TColStd_Array2OfReal Ident ( 0, 3, 0, 3 );
2666 Standard_Integer ii, jj;
2667
2668 for ( ii = 0; ii <= 3; ++ii )
2669
2670 for ( jj = 0; jj <= 3; ++jj )
2671
2672 Ident ( ii, jj ) = ( ii == jj ? 1.0 : 0.0 );
2673
2674 TheStructure = MyCOMPUTEDSequence.Value ( Index );
2675
2676 TheStructure -> SetTransform ( Ident, Graphic3d_TOC_REPLACE );
2677
2678 if ( AStructure->IsTransformed () )
2679
2680 AStructure -> Compute ( this, ATrsf, TheStructure );
2681
2682 else
2683
2684 AStructure -> Compute ( this, TheStructure );
2685
2686 } else {
2687
2688 if ( AStructure -> IsTransformed () )
2689
2690 TheStructure = AStructure -> Compute ( this, ATrsf );
2691
2692 else
2693
2694 TheStructure = AStructure -> Compute ( this );
2695
2696 } // end else
2697#endif // OLD
2698 TheStructure -> SetHLRValidation ( Standard_True );
2699
2700 Visual3d_TypeOfVisualization ViewType = MyContext.Visualization ();
2701
2702 Standard_Boolean ComputeWireframe =
2703 ( ( ViewType == Visual3d_TOV_WIREFRAME ) &&
2704 ( S1Iterator.Key () -> ComputeVisual () != Graphic3d_TOS_SHADING )
2705 );
2706
2707 Standard_Boolean ComputeShading =
2708 ( ( ViewType == Visual3d_TOV_SHADING ) &&
2709 ( S1Iterator.Key () -> ComputeVisual () != Graphic3d_TOS_WIREFRAME )
2710 );
2711
2712 if ( ComputeWireframe ) TheStructure -> SetVisual ( Graphic3d_TOS_WIREFRAME );
2713 if ( ComputeShading ) TheStructure -> SetVisual ( Graphic3d_TOS_SHADING );
2714
2715 if ( S1Iterator.Key () -> IsHighlighted () ) {
2716
2717 TheStructure -> SetHighlightColor (
2718 S1Iterator.Key () -> HighlightColor ()
2719 );
2720 TheStructure -> GraphicHighlight ( Aspect_TOHM_COLOR );
2721
2722 } // end if
2723
2724 Standard_Integer Result = 0;
2725 Standard_Integer Length = MyTOCOMPUTESequence.Length ();
2726 StructId = S1Iterator.Key () -> Identification ();
2727
2728 for ( i = 1; i <= Length && Result == 0; ++i )
2729
2730 if ( MyTOCOMPUTESequence.Value ( i ) -> Identification () == StructId )
2731
2732 Result = i;
2733
2734 if ( Result )
2735
2736 MyCOMPUTEDSequence.ChangeValue ( Result ) = TheStructure;
2737
2738 else {
2739
2740 MyTOCOMPUTESequence.Append ( S1Iterator.Key () );
2741 MyCOMPUTEDSequence.Append ( TheStructure );
2742
2743 } // end else
2744
63bcc448 2745 MyGraphicDriver->EraseStructure (MyCView, *(S1Iterator.Key()->CStructure()));
2746 MyGraphicDriver->DisplayStructure (MyCView, *(TheStructure->CStructure()), S1Iterator.Key()->DisplayPriority());
7fd59977 2747 } // end else
2748
2749 } // end if
2750
2751 S1Iterator.Next ();
2752
2753 } // end while
2754
2755 if ( MyViewManager -> UpdateMode () == Aspect_TOU_ASAP ) Update ();
2756
2757 } // end else
2758
2759} // end Visual3d_View :: SetComputedMode
2760
2761Standard_Boolean Visual3d_View :: ComputedMode () const {
2762
2763 return ComputedModeIsActive;
2764
2765} // end Visual3d_View :: ComputedMode
2766
2767void Visual3d_View :: SetBackFacingModel (
2768 const Visual3d_TypeOfBackfacingModel aModel
2769 ) {
2770 switch ( aModel ) {
2771
2772 default:
2773 case Visual3d_TOBM_AUTOMATIC:
2774 MyCView.Backfacing = 0;
2775 break;
2776
2777 case Visual3d_TOBM_FORCE:
2778 MyCView.Backfacing = 1;
2779 break;
2780
2781 case Visual3d_TOBM_DISABLE:
2782 MyCView.Backfacing = -1;
2783 break;
2784
2785 } // end switch
2786
2787 MyGraphicDriver -> SetBackFacingModel ( MyCView );
2788
2789} // end Visual3d_View :: SetBackFacingModel
2790
2791Visual3d_TypeOfBackfacingModel Visual3d_View :: BackFacingModel () const {
2792
2793 switch ( MyCView.Backfacing ) {
2794
2795 case 0:
2796 return Visual3d_TOBM_AUTOMATIC;
2797
2798 case 1:
2799 return Visual3d_TOBM_FORCE;
2800
2801 } // end switch
2802
2803 return Visual3d_TOBM_DISABLE;
2804
2805} // end Visual3d_View :: BackFacingModel
7fd59977 2806
2807void Visual3d_View::EnableDepthTest( const Standard_Boolean enable ) const
2808{
7fd59977 2809 MyGraphicDriver->SetDepthTestEnabled( MyCView, enable );
7fd59977 2810}
2811
2812Standard_Boolean Visual3d_View::IsDepthTestEnabled() const
2813{
7fd59977 2814 return MyGraphicDriver->IsDepthTestEnabled( MyCView );
7fd59977 2815}
2816
2817void Visual3d_View::ReadDepths(const Standard_Integer x,
2818 const Standard_Integer y,
2819 const Standard_Integer width,
2820 const Standard_Integer height,
2821 const Standard_Address buffer) const
2822{
2823 MyGraphicDriver->ReadDepths( MyCView, x, y, width, height, buffer );
2824}
2825
2826Graphic3d_PtrFrameBuffer Visual3d_View::FBOCreate(const Standard_Integer theWidth,
2827 const Standard_Integer theHeight)
2828{
2829 return MyGraphicDriver->FBOCreate( MyCView, theWidth, theHeight );
2830}
2831
2832void Visual3d_View::FBORelease(Graphic3d_PtrFrameBuffer& theFBOPtr)
2833{
2834 MyGraphicDriver->FBORelease( MyCView, theFBOPtr );
2835}
2836
2837void Visual3d_View::FBOGetDimensions(const Graphic3d_PtrFrameBuffer theFBOPtr,
2838 Standard_Integer& theWidth, Standard_Integer& theHeight,
2839 Standard_Integer& theWidthMax, Standard_Integer& theHeightMax)
2840{
2841 MyGraphicDriver->FBOGetDimensions( MyCView, theFBOPtr,
2842 theWidth, theHeight,
2843 theWidthMax, theHeightMax );
2844}
2845
2846void Visual3d_View::FBOChangeViewport(Graphic3d_PtrFrameBuffer& theFBOPtr,
2847 const Standard_Integer theWidth, const Standard_Integer theHeight)
2848{
2849 MyGraphicDriver->FBOChangeViewport( MyCView, theFBOPtr,
2850 theWidth, theHeight );
2851}
2852
692613e5 2853Standard_Boolean Visual3d_View::BufferDump (Image_PixMap& theImage,
2854 const Graphic3d_BufferType& theBufferType)
7fd59977 2855{
692613e5 2856 return MyGraphicDriver->BufferDump (MyCView, theImage, theBufferType);
7fd59977 2857}
2858
2859void Visual3d_View::EnableGLLight( const Standard_Boolean enable ) const
2860{
7fd59977 2861 MyGraphicDriver->SetGLLightEnabled( MyCView, enable );
7fd59977 2862}
2863
2864
2865Standard_Boolean Visual3d_View::IsGLLightEnabled() const
2866{
7fd59977 2867 return MyGraphicDriver->IsGLLightEnabled( MyCView );
7fd59977 2868}
2869
5cedc27f
K
2870Standard_Boolean Visual3d_View::Export (const Standard_CString theFileName,
2871 const Graphic3d_ExportFormat theFormat,
2872 const Graphic3d_SortType theSortType,
2873 const Standard_Real thePrecision,
2874 const Standard_Address theProgressBarFunc,
2875 const Standard_Address theProgressObject) const
7fd59977 2876{
5cedc27f
K
2877 Handle(Visual3d_Layer) anUnderLayer = MyViewManager->UnderLayer();
2878 Handle(Visual3d_Layer) anOverLayer = MyViewManager->OverLayer();
7fd59977 2879
5cedc27f
K
2880 Aspect_CLayer2d anOverCLayer;
2881 Aspect_CLayer2d anUnderCLayer;
2882 anOverCLayer.ptrLayer = anUnderCLayer.ptrLayer = NULL;
7fd59977 2883
5cedc27f
K
2884 if (!anOverLayer.IsNull())
2885 anOverCLayer = anOverLayer->CLayer();
2886 if (!anUnderLayer.IsNull())
2887 anUnderCLayer = anUnderLayer->CLayer();
7fd59977 2888
5cedc27f
K
2889 Standard_Integer aWidth, aHeight;
2890 Window()->Size (aWidth, aHeight);
7fd59977 2891
5cedc27f
K
2892 return MyGraphicDriver->Export (theFileName, theFormat, theSortType,
2893 aWidth, aHeight, MyCView, anUnderCLayer, anOverCLayer,
2894 thePrecision, theProgressBarFunc, theProgressObject);
7fd59977 2895}
59f45b7c 2896
2897//=======================================================================
2898//function : AddZLayer
2899//purpose :
2900//=======================================================================
2901
2902void Visual3d_View::AddZLayer (const Standard_Integer theLayerId)
2903{
2904 MyGraphicDriver->AddZLayer (MyCView, theLayerId);
2905}
2906
2907//=======================================================================
2908//function : RemoveZLayer
bf75be98 2909//purpose :
59f45b7c 2910//=======================================================================
2911
2912void Visual3d_View::RemoveZLayer (const Standard_Integer theLayerId)
2913{
2914 MyGraphicDriver->RemoveZLayer (MyCView, theLayerId);
2915}
2916
2917//=======================================================================
2918//function : ChangeZLayer
bf75be98 2919//purpose :
59f45b7c 2920//=======================================================================
2921
2922void Visual3d_View::ChangeZLayer (const Handle(Graphic3d_Structure)& theStructure,
2923 const Standard_Integer theLayerId)
2924{
63bcc448 2925 MyGraphicDriver->ChangeZLayer (*(theStructure->CStructure()), MyCView, theLayerId);
59f45b7c 2926}