1 // Copyright (c) 1995-1999 Matra Datavision
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
4 // This file is part of Open CASCADE Technology software library.
6 // This library is free software; you can redistribute it and / or modify it
7 // under the terms of the GNU Lesser General Public version 2.1 as published
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.
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
15 /***********************************************************************
19 Classe Visual3d_View.cxx :
22 Declaration of variables specific to views.
24 A view is defined by :
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
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
71 ************************************************************************/
73 #define BUC60572 //GG_03-08-99 Add protection on Zclipping & Zcueing planes
76 #define GER61454 //GG 14-09-99 Activates model clipping planes
78 #define RIC120302 //GG Add a NEW SetWindow method which enable
79 // to connect a graphic widget and context to OGL.
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
84 //OCC1188 SAV Added methods to set background image
86 /*----------------------------------------------------------------------*/
94 #define NO_TRACE_ACCEPT
95 #define NO_TRACE_CLEAR
96 #define NO_TRACE_CONNECT
100 #define NO_TRACE_DISPLAY
101 #define NO_TRACE_ISCOMP
102 #define NO_TRACE_LENGTH
103 #define NO_TRACE_LAYER
105 /*----------------------------------------------------------------------*/
115 #include <Visual3d_View.ixx>
116 #include <Visual3d_View.pxx>
117 #include <Visual3d_DepthCueingDefinitionError.hxx>
118 #include <Visual3d_ZClippingDefinitionError.hxx>
121 #include <math_Vector.hxx>
122 #endif /* OLD_METHOD */
126 #include <Graphic3d_Structure.hxx>
127 #include <Graphic3d_MapOfStructure.hxx>
128 #include <Graphic3d_MapIteratorOfMapOfStructure.hxx>
129 #include <Graphic3d_DataStructureManager.hxx>
131 #include <Graphic3d_GraphicDriver.hxx>
133 #include <Graphic3d_Vector.hxx>
134 #include <Graphic3d_Vertex.hxx>
136 #include <Visual3d_Light.hxx>
137 #include <Visual3d_SetOfLight.hxx>
138 #include <Visual3d_HSetOfLight.hxx>
139 #include <Visual3d_SetIteratorOfSetOfLight.hxx>
141 #include <Visual3d_SetIteratorOfSetOfView.hxx>
143 #include <Graphic3d_TextureEnv.hxx>
145 #include <TColStd_HArray2OfReal.hxx>
147 #if (defined(_WIN32) || defined(__WIN32__))
148 #include <WNT_Window.hxx>
149 #elif (defined(__APPLE__) && !defined(MACOSX_USE_GLX))
150 #include <Cocoa_Window.hxx>
152 #include <Xw_Window.hxx>
159 //-Global data definitions
163 Visual3d_View::Visual3d_View (const Handle(Visual3d_ViewManager)& AManager):
165 MyTOCOMPUTESequence (),
166 MyCOMPUTEDSequence (),
167 MyDisplayedStructure ()
170 MyPtrViewManager = AManager.operator->();
171 MyCView.ViewId = int (AManager->Identification (this));
173 MyCView.IsDeleted = 0;
176 MyCView.DefWindow.IsDefined = 0;
178 MyCView.Context.NbActiveLight = 0;
180 MyCView.Context.ZBufferActivity = -1;
182 IsInitialized = Standard_False;
183 ComputedModeIsActive = Standard_False;
184 MyCView.Backfacing = 0;
186 MyCView.ptrUnderLayer = 0;
187 MyCView.ptrOverLayer = 0;
188 MyCView.GContext = 0;
189 MyCView.GDisplayCB = 0;
190 MyCView.GClientData = 0;
192 MyGraphicDriver = MyViewManager->GraphicDriver();
198 void Visual3d_View::SetWindow (const Handle(Aspect_Window)& AWindow,
199 const Aspect_RenderingContext AContext,
200 const Aspect_GraphicCallbackProc& ADisplayCB,
201 const Standard_Address AClientData)
203 if (IsDeleted ()) return;
206 Visual3d_ViewDefinitionError::Raise ("Window already defined");
208 MyCView.GContext = AContext;
209 MyCView.GDisplayCB = ADisplayCB;
210 MyCView.GClientData = AClientData;
215 void Visual3d_View::SetWindow (const Handle(Aspect_Window)& theWindow)
217 if (IsDeleted ()) return;
221 Visual3d_ViewDefinitionError::Raise ("Window already defined");
224 MyWindow = theWindow;
225 MyCView.WsId = MyCView.ViewId;
226 MyCView.DefWindow.IsDefined = 1;
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();
240 const Handle(Xw_Window) aWin = Handle(Xw_Window)::DownCast (theWindow);
241 MyCView.DefWindow.XWindow = aWin->XWindow();
242 //MyCView.DefWindow.XParentWindow = aWin->XParentWindow();
245 Standard_Integer Width, Height;
246 theWindow->Size (Width, Height);
248 MyCView.DefWindow.dx = float( Width );
249 MyCView.DefWindow.dy = float( Height );
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);
259 if (! MyGraphicDriver->View (MyCView))
260 Visual3d_ViewDefinitionError::Raise ("Association failed");
262 MyGradientBackground = MyWindow->GradientBackground();
263 SetGradientBackground(MyGradientBackground,1);
265 Standard_Boolean AWait = Standard_False; // => immediate update
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);
272 // Make view manager z layer list consistent with the view's list.
273 MyViewManager->InstallZLayers (this);
275 // Update planses of model clipping
278 // Update light sources
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).
292 Handle(Aspect_Window) Visual3d_View::Window () const {
295 Visual3d_ViewDefinitionError::Raise ("Window not defined");
301 Standard_Boolean Visual3d_View::IsDefined () const {
303 if (MyCView.DefWindow.IsDefined)
304 return (Standard_True);
306 return (Standard_False);
310 Standard_Boolean Visual3d_View::IsDeleted () const {
312 if (MyCView.IsDeleted)
313 return (Standard_True);
315 return (Standard_False);
319 void Visual3d_View::Destroy () {
322 cout << "Visual3d_View::Destroy (" << Identification () << ")\n";
325 // Since MyPtrViewManager can be already distroyed,
326 // avoid attempts to access it in SetBackground()
327 MyPtrViewManager = 0;
332 void Visual3d_View::Remove () {
335 cout << "Visual3d_View::Remove (" << Identification () << ")" << endl;
338 if (IsDeleted ()) return;
339 if (! IsDefined ()) return;
341 MyTOCOMPUTESequence.Clear ();
342 MyCOMPUTEDSequence.Clear ();
343 MyDisplayedStructure.Clear ();
345 Quantity_Color BlackColor (0.0, 0.0, 0.0, Quantity_TOC_RGB);
346 Aspect_Background BlackBackground (BlackColor);
347 SetBackground (BlackBackground);
349 Aspect_GradientBackground BlackGradBackground;
350 SetGradientBackground (BlackGradBackground,0);
352 if (MyPtrViewManager)
353 MyPtrViewManager->UnIdentification( MyCView.ViewId );
355 MyGraphicDriver->RemoveView (MyCView);
358 MyCView.IsDeleted = 1;
359 MyCView.DefWindow.IsDefined = 0;
361 IsInitialized = Standard_False;
367 void Visual3d_View::Resized () {
369 if (IsDeleted ()) return;
372 Visual3d_ViewDefinitionError::Raise ("Window not defined");
373 MyWindow->DoResize() ;
378 void Visual3d_View::SetRatio()
385 Aspect_TypeOfUpdate UpdateMode = MyViewManager->UpdateMode();
387 MyViewManager->SetUpdateMode (Aspect_TOU_WAIT);
389 Standard_Integer aWidth, aHeight;
391 MyWindow->Size (aWidth, aHeight);
393 if( aWidth > 0 && aHeight > 0 )
395 Standard_Real aRatio = (Standard_Real)aWidth / (Standard_Real)aHeight;
397 MyCView.DefWindow.dx = Standard_ShortReal (aWidth);
398 MyCView.DefWindow.dy = Standard_ShortReal (aHeight);
400 MyGraphicDriver->RatioWindow (MyCView);
402 // Update camera aspect
403 Handle(Graphic3d_Camera) aCamera = MyCView.Context.Camera;
405 if (!aCamera.IsNull())
407 aCamera->SetAspect (aRatio);
410 if (!myDefaultCamera.IsNull())
412 myDefaultCamera->SetAspect (aRatio);
416 MyViewManager->SetUpdateMode (UpdateMode);
417 if (UpdateMode == Aspect_TOU_ASAP)
421 void Visual3d_View::UpdateLights()
429 if (MyContext.Model() == Visual3d_TOM_NONE)
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;
437 MyCView.Context.NbActiveLight = 1;
438 MyCView.Context.ActiveLight = &aCLight;
439 MyGraphicDriver->SetLight (MyCView);
440 MyCView.Context.ActiveLight = NULL;
444 MyCView.Context.NbActiveLight = Min (MyContext.NumberOfActivatedLights(),
445 MyGraphicDriver->InquireLightLimit());
446 if (MyCView.Context.NbActiveLight < 1)
448 MyGraphicDriver->SetLight (MyCView);
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)
456 MyCView.Context.ActiveLight[aLightIter] = MyContext.ActivatedLight (aLightIter + 1)->CLight();
458 MyGraphicDriver->SetLight (MyCView);
459 delete[] MyCView.Context.ActiveLight;
460 MyCView.Context.ActiveLight = NULL;
463 void Visual3d_View::UpdatePlanes()
465 MyCView.Context.ClipPlanes = MyContext.ClipPlanes();
466 if (IsDeleted() || !IsDefined())
471 MyGraphicDriver->SetClipPlanes (MyCView);
474 void Visual3d_View::SetBackground (const Aspect_Background& ABack) {
476 if (IsDeleted ()) return;
479 Visual3d_ViewDefinitionError::Raise ("Window not defined");
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)
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);
493 MyGraphicDriver->Background (MyCView);
495 if (MyPtrViewManager && MyViewManager->UpdateMode () == Aspect_TOU_ASAP)
500 void Visual3d_View::SetGradientBackground(const Aspect_GradientBackground& ABack, const Standard_Boolean update)
503 if (IsDeleted ()) return;
506 Visual3d_ViewDefinitionError::Raise ("Window not defined");
508 MyGradientBackground = ABack;
509 Quantity_Color aCol1,aCol2;
510 MyGradientBackground.Colors(aCol1,aCol2);
511 MyGraphicDriver->GradientBackground(MyCView, aCol1, aCol2, MyGradientBackground.BgGradientFillMethod());
515 else if (MyPtrViewManager && MyViewManager->UpdateMode () == Aspect_TOU_ASAP)
519 void Visual3d_View::SetBackgroundImage( const Standard_CString FileName,
520 const Aspect_FillMethod FillStyle,
521 const Standard_Boolean update )
526 Visual3d_ViewDefinitionError::Raise ("Window not defined");
528 MyGraphicDriver->BackgroundImage( FileName, MyCView, FillStyle );
532 else if ( MyViewManager->UpdateMode() == Aspect_TOU_ASAP )
536 void Visual3d_View::SetBgImageStyle( const Aspect_FillMethod FillStyle,
537 const Standard_Boolean update )
542 Visual3d_ViewDefinitionError::Raise ("Window not defined");
544 MyGraphicDriver->SetBgImageStyle( MyCView, FillStyle );
548 else if ( MyViewManager->UpdateMode() == Aspect_TOU_ASAP )
552 Aspect_Background Visual3d_View::Background () const {
554 return (MyBackground);
558 void Visual3d_View::SetBgGradientStyle( const Aspect_GradientFillMethod FillStyle,
559 const Standard_Boolean update )
564 Visual3d_ViewDefinitionError::Raise ("Window not defined");
566 MyGraphicDriver->SetBgGradientStyle( MyCView, FillStyle );
570 else if ( MyViewManager->UpdateMode() == Aspect_TOU_ASAP )
575 Aspect_GradientBackground Visual3d_View::GradientBackground () const {
577 return MyGradientBackground;
581 // =======================================================================
582 // function : DefaultCamera
584 // =======================================================================
585 const Handle(Graphic3d_Camera)& Visual3d_View::DefaultCamera() const
587 return myDefaultCamera;
590 // =======================================================================
593 // =======================================================================
594 const Handle(Graphic3d_Camera)& Visual3d_View::Camera() const{ return MyCView.Context.Camera;}
596 // =======================================================================
597 // function : SetCamera
599 // =======================================================================
600 void Visual3d_View::SetCamera (const Handle(Graphic3d_Camera)& theCamera)
602 MyCView.Context.Camera = theCamera;
604 MyGraphicDriver->SetCamera (MyCView);
606 if (MyViewManager->UpdateMode() == Aspect_TOU_ASAP)
612 // =======================================================================
613 // function : SetViewOrientationDefault
615 // =======================================================================
616 void Visual3d_View::SetViewOrientationDefault ()
618 if (myDefaultCamera.IsNull())
620 myDefaultCamera = new Graphic3d_Camera();
623 myDefaultCamera->CopyOrientationData (MyCView.Context.Camera);
626 // =======================================================================
627 // function : ViewOrientationReset
629 // =======================================================================
630 void Visual3d_View::ViewOrientationReset ()
637 if (!myDefaultCamera.IsNull())
639 MyCView.Context.Camera->CopyOrientationData (myDefaultCamera);
642 if (MyViewManager->UpdateMode() == Aspect_TOU_ASAP)
648 // =======================================================================
649 // function : SetViewMappingDefault
651 // =======================================================================
652 void Visual3d_View::SetViewMappingDefault()
654 if (myDefaultCamera.IsNull())
656 myDefaultCamera = new Graphic3d_Camera();
658 myDefaultCamera->CopyMappingData (MyCView.Context.Camera);
661 // =======================================================================
662 // function : ViewMappingReset
664 // =======================================================================
665 void Visual3d_View::ViewMappingReset ()
672 if (!myDefaultCamera.IsNull())
674 MyCView.Context.Camera->CopyMappingData (myDefaultCamera);
677 if (MyViewManager->UpdateMode() == Aspect_TOU_ASAP)
683 void Visual3d_View::SetContext (const Visual3d_ContextView& CTX) {
685 if (IsDeleted ()) return;
687 Visual3d_TypeOfVisualization OldVisualMode;
688 Visual3d_TypeOfVisualization NewVisualMode;
690 // To manage display only in case of
691 // change of visualisation mode.
692 OldVisualMode = MyContext.Visualization ();
693 NewVisualMode = CTX.Visualization ();
695 Visual3d_TypeOfModel OldModel;
696 Visual3d_TypeOfModel NewModel;
698 // To manage change of visualisation only in case
699 // of change of mode of visualisation or of type of shading.
700 OldModel = MyContext.Model ();
701 NewModel = CTX.Model ();
703 Standard_Boolean OldAliasingMode;
704 Standard_Boolean NewAliasingMode;
706 // To manage antialiasing only in case of change.
707 OldAliasingMode = MyContext.AliasingIsOn ();
708 NewAliasingMode = CTX.AliasingIsOn ();
710 Standard_Boolean OldDepthCueingMode;
711 Standard_Boolean NewDepthCueingMode;
713 Standard_Real OldDepthCueingFrontPlane;
714 Standard_Real NewDepthCueingFrontPlane;
715 Standard_Real OldDepthCueingBackPlane;
716 Standard_Real NewDepthCueingBackPlane;
718 // To manage the depth cueing only in case of change.
719 OldDepthCueingMode = MyContext.DepthCueingIsOn ();
720 NewDepthCueingMode = CTX.DepthCueingIsOn ();
722 OldDepthCueingFrontPlane = MyContext.DepthCueingFrontPlane ();
723 NewDepthCueingFrontPlane = CTX.DepthCueingFrontPlane ();
724 OldDepthCueingBackPlane = MyContext.DepthCueingBackPlane ();
725 NewDepthCueingBackPlane = CTX.DepthCueingBackPlane ();
727 Standard_Boolean OldFrontZClippingMode;
728 Standard_Boolean NewFrontZClippingMode;
729 Standard_Boolean OldBackZClippingMode;
730 Standard_Boolean NewBackZClippingMode;
732 Standard_Real OldZClippingFrontPlane;
733 Standard_Real NewZClippingFrontPlane;
734 Standard_Real OldZClippingBackPlane;
735 Standard_Real NewZClippingBackPlane;
737 // To manage the Zclipping only in case of change.
738 OldFrontZClippingMode = MyContext.FrontZClippingIsOn ();
739 NewFrontZClippingMode = CTX.FrontZClippingIsOn ();
740 OldBackZClippingMode = MyContext.BackZClippingIsOn ();
741 NewBackZClippingMode = CTX.BackZClippingIsOn ();
743 OldZClippingFrontPlane = MyContext.ZClippingFrontPlane ();
744 NewZClippingFrontPlane = CTX.ZClippingFrontPlane ();
745 OldZClippingBackPlane = MyContext.ZClippingBackPlane ();
746 NewZClippingBackPlane = CTX.ZClippingBackPlane ();
748 Handle(Graphic3d_TextureEnv) aTexEnvOld = MyContext.TextureEnv();
749 Handle(Graphic3d_TextureEnv) aTexEnvNew = CTX.TextureEnv();
751 Visual3d_TypeOfSurfaceDetail OldSurfaceDetail = MyContext.SurfaceDetail();
752 Visual3d_TypeOfSurfaceDetail NewSurfaceDetail = CTX.SurfaceDetail();
758 Standard_Boolean AWait = Standard_False; // => immediate update
760 // management of visualization modes and types of shading.
761 if ((OldVisualMode != NewVisualMode) || (OldModel != NewModel))
762 MyGraphicDriver->SetVisualisation (MyCView);
764 // management of antialiasing.
765 if (OldAliasingMode != NewAliasingMode)
766 MyGraphicDriver->AntiAliasing (MyCView, NewAliasingMode);
768 // management of depth_cueing.
769 if ((OldDepthCueingMode != NewDepthCueingMode) ||
770 (OldDepthCueingFrontPlane != NewDepthCueingFrontPlane) ||
771 (OldDepthCueingBackPlane != NewDepthCueingBackPlane)) {
773 if( NewDepthCueingMode &&
774 (NewDepthCueingBackPlane >= NewDepthCueingFrontPlane) )
775 Visual3d_DepthCueingDefinitionError::Raise
776 ("Bad value for DepthCueingPlanes position");
778 MyGraphicDriver->DepthCueing
779 (MyCView, NewDepthCueingMode);
782 // management of Zclipping
783 if ((OldFrontZClippingMode != NewFrontZClippingMode) ||
784 (OldBackZClippingMode != NewBackZClippingMode) ||
785 (OldZClippingFrontPlane != NewZClippingFrontPlane) ||
786 (OldZClippingBackPlane != NewZClippingBackPlane)) {
788 if( NewBackZClippingMode && NewFrontZClippingMode &&
789 (NewZClippingBackPlane >= NewZClippingFrontPlane) )
790 Visual3d_ZClippingDefinitionError::Raise
791 ("Bad value for ZClippingPlanes position");
793 MyGraphicDriver->ClipLimit (MyCView, AWait);
796 // management of textures
797 if ((aTexEnvOld != aTexEnvNew) || (OldSurfaceDetail != NewSurfaceDetail))
799 MyGraphicDriver->Environment(MyCView);
802 // Update of planes of model clipping
805 // Update of light sources
809 if (OldVisualMode != NewVisualMode) {
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.
819 Graphic3d_MapIteratorOfMapOfStructure S1Iterator (MyDisplayedStructure);
820 Visual3d_TypeOfAnswer Answer;
822 Standard_Integer i = MyDisplayedStructure.Extent ();
824 Graphic3d_SequenceOfStructure FooSequence;
826 while (S1Iterator.More ()) {
827 Answer = AcceptDisplay (S1Iterator.Key ());
828 // If the structure can't be displayed in the
829 // new context of the view, it is removed.
830 if ((Answer == Visual3d_TOA_NO) ||
831 (Answer == Visual3d_TOA_COMPUTE))
832 //Erase (S1Iterator.Key (), Aspect_TOU_WAIT);
833 FooSequence.Append (S1Iterator.Key ());
835 // S1Iterator.Next () is located on the next structure
839 Standard_Integer Length = FooSequence.Length ();
840 // The stored structures are removed
841 for (i=1; i<=Length; i++)
842 Erase (FooSequence.Value (i), Aspect_TOU_WAIT);
843 if (Length != 0) FooSequence.Clear ();
846 * Change of context =>
847 * Display structures that can be displayed
848 * with the new visualisation mode.
849 * All structures with status Displayed are removed from the ViewManager
850 * and displayed in the view directly, if the structure is not already
851 * displayed and if the view accepts it in its context.
854 i = MyViewManager->NumberOfDisplayedStructures ();
855 Graphic3d_MapOfStructure Map;
856 MyViewManager->DisplayedStructures(Map);
857 Graphic3d_MapIteratorOfMapOfStructure it(Map);
859 for (; it.More(); it.Next()) {
860 Handle(Graphic3d_Structure) SG = it.Key();
861 if (! IsDisplayed (SG)) {
862 Answer = AcceptDisplay(SG);
863 // If the structure can be displayed in the
864 // new context of the view, it is displayed.
865 if ((Answer == Visual3d_TOA_YES) ||
866 (Answer == Visual3d_TOA_COMPUTE))
867 //Display (MyViewManager->DisplayedStructure (j),
869 FooSequence.Append (SG);
873 Length = FooSequence.Length ();
874 // The stored structures are displayed
875 for (i=1; i<=Length; i++)
876 Display (FooSequence.Value (i), Aspect_TOU_WAIT);
877 if (Length != 0) FooSequence.Clear ();
880 if (MyViewManager->UpdateMode () == Aspect_TOU_ASAP) Update ();
884 const Visual3d_ContextView& Visual3d_View::Context () const {
890 void Visual3d_View::DisplayedStructures (Graphic3d_MapOfStructure& SG) const
893 if (IsDeleted ()) return;
895 Graphic3d_MapIteratorOfMapOfStructure Iterator (MyDisplayedStructure);
897 while (Iterator.More ()) {
898 SG.Add (Iterator.Key ());
900 // Iterator.Next () is located on the next structure
906 void Visual3d_View::Activate () {
908 if (IsDeleted ()) return;
911 Visual3d_ViewDefinitionError::Raise ("Window not defined");
915 MyGraphicDriver->ActivateView (MyCView);
916 MyGraphicDriver->Background (MyCView);
917 MyGraphicDriver->Transparency
918 (MyCView, MyViewManager->Transparency ());
923 * Activation of a new view =>
924 * Display structures that can be displayed in this new view.
925 * All structures with status
926 * Displayed in ViewManager are returned and displayed in
927 * the view directly, if the structure is not already
928 * displayed and if the view accepts it in its context.
931 Visual3d_TypeOfAnswer Answer;
932 Graphic3d_MapOfStructure Map;
933 MyViewManager->DisplayedStructures(Map);
934 Graphic3d_MapIteratorOfMapOfStructure it(Map);
936 for (; it.More(); it.Next()) {
937 Handle(Graphic3d_Structure) SG = it.Key();
938 if (! IsDisplayed (SG)) {
939 Answer = AcceptDisplay(SG);
940 // If the structure can be displayed in the
941 // new context of the view, it is displayed.
942 if ((Answer == Visual3d_TOA_YES) ||
943 (Answer == Visual3d_TOA_COMPUTE))
944 Display (SG,Aspect_TOU_WAIT);
950 // If the activation/desactivation of ZBuffer should be automatic
951 // depending on the presence or absence of facets.
952 if (MyViewManager->ZBufferAuto ()) {
953 Standard_Boolean BContainsFacet = ContainsFacet ();
954 Standard_Boolean BZBuffer = ZBufferIsActivated ();
955 // If the view contains facets
956 // and if ZBuffer is not active
957 if (BContainsFacet && ! BZBuffer)
958 SetZBufferActivity (1);
959 // If the view does not contain facets
960 // and if ZBuffer is active
961 if (! BContainsFacet && BZBuffer)
962 SetZBufferActivity (0);
965 if (MyViewManager->UpdateMode () == Aspect_TOU_ASAP) Update ();
969 Standard_Boolean Visual3d_View::IsActive () const {
971 if (IsDeleted ()) return (Standard_False);
974 return (Standard_True);
976 return (Standard_False);
980 void Visual3d_View::Deactivate () {
982 if (IsDeleted ()) return;
985 Visual3d_ViewDefinitionError::Raise ("Window not defined");
989 MyGraphicDriver->DeactivateView (MyCView);
992 * Deactivation of a view =>
993 * Removal of structures displayed in this view.
994 * All structures with status
995 * Displayed in ViewManager are returned and removed from
996 * the view directly, if the structure is not already
997 * displayed and if the view accepts it in its context.
1000 Visual3d_TypeOfAnswer Answer;
1001 Graphic3d_MapOfStructure Map;
1002 MyViewManager->DisplayedStructures(Map);
1003 Graphic3d_MapIteratorOfMapOfStructure it(Map);
1005 for (; it.More(); it.Next()) {
1006 Handle(Graphic3d_Structure) SG = it.Key();
1007 if (! IsDisplayed (SG)) {
1008 Answer = AcceptDisplay(SG);
1009 // If the structure was displayed it is removed.
1010 if ((Answer == Visual3d_TOA_YES) ||
1011 (Answer == Visual3d_TOA_COMPUTE))
1012 Erase (SG,Aspect_TOU_WAIT);
1016 if (MyViewManager->UpdateMode () == Aspect_TOU_ASAP) Update ();
1018 // No action currently possible in the view
1024 void Visual3d_View::Redraw () {
1026 Redraw (MyViewManager->UnderLayer (), MyViewManager->OverLayer ());
1030 void Visual3d_View::Redraw (const Standard_Integer x, const Standard_Integer y, const Standard_Integer width, const Standard_Integer height) {
1032 Redraw (MyViewManager->UnderLayer (), MyViewManager->OverLayer (), x, y, width, height);
1035 void Visual3d_View::Redraw (const Handle(Visual3d_Layer)& AnUnderLayer, const Handle(Visual3d_Layer)& AnOverLayer) {
1037 if (IsDeleted ()) return;
1039 if ((! IsDefined ()) || (! IsActive ())) return;
1041 if (! MyWindow->IsMapped ()) return;
1043 // san - 14/04/2004 - set up Z buffer state before redrawing
1044 // If the activation/desactivation of ZBuffer should be automatic
1045 // depending on the presence or absence of facets.
1046 if (MyViewManager->ZBufferAuto ()) {
1047 Standard_Boolean BContainsFacet = ContainsFacet ();
1048 Standard_Boolean BZBuffer = ZBufferIsActivated ();
1049 // If the view contains facets
1050 // and if ZBuffer is not active
1051 if (BContainsFacet && ! BZBuffer)
1052 SetZBufferActivity (1);
1053 // If the view contains only facets
1054 // and if ZBuffer is active
1055 if (! BContainsFacet && BZBuffer)
1056 SetZBufferActivity (0);
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);
1068 void 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) {
1070 if (IsDeleted ()) return;
1072 if ((! IsDefined ()) || (! IsActive ())) return;
1074 if (! MyWindow->IsMapped ()) return;
1076 // san - 14/04/2004 - set up Z buffer state before redrawing
1077 // If activation/desactivation of ZBuffer should be automatic
1078 // depending on the presence or absence of facets.
1079 if (MyViewManager->ZBufferAuto ()) {
1080 Standard_Boolean BContainsFacet = ContainsFacet ();
1081 Standard_Boolean BZBuffer = ZBufferIsActivated ();
1082 // If the view contains facets
1083 // and if ZBuffer is not active
1084 if (BContainsFacet && ! BZBuffer)
1085 SetZBufferActivity (1);
1086 // If the view contains only facets
1087 // and if ZBuffer is active
1088 if (! BContainsFacet && BZBuffer)
1089 SetZBufferActivity (0);
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);
1101 void Visual3d_View::Update ()
1103 IsInitialized = Standard_True;
1107 Update (MyViewManager->UnderLayer (), MyViewManager->OverLayer ());
1110 void Visual3d_View::Update (const Handle(Visual3d_Layer)& AnUnderLayer, const Handle(Visual3d_Layer)& AnOverLayer) {
1112 if (IsDeleted ()) return;
1114 if ((! IsDefined ()) || (! IsActive ())) return;
1116 if (! MyWindow->IsMapped ()) return;
1118 if (MyGraphicDriver->IsDeviceLost())
1120 MyViewManager->ReComputeStructures();
1121 MyGraphicDriver->ResetDeviceLostFlag();
1124 // If activation/desactivation of ZBuffer should be automatic
1125 // depending on the presence or absence of facets.
1126 if (MyViewManager->ZBufferAuto ()) {
1127 Standard_Boolean BContainsFacet = ContainsFacet ();
1128 Standard_Boolean BZBuffer = ZBufferIsActivated ();
1129 // If the view contains facets
1130 // and if ZBuffer is not active
1131 if (BContainsFacet && ! BZBuffer)
1132 SetZBufferActivity (1);
1133 // If the view does not contain facets
1134 // and if ZBuffer is active
1135 if (! BContainsFacet && BZBuffer)
1136 SetZBufferActivity (0);
1139 Aspect_CLayer2d OverCLayer;
1140 Aspect_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);
1150 Visual3d_TypeOfAnswer Visual3d_View::AcceptDisplay (const Handle(Graphic3d_Structure)& AStructure) const {
1152 // Return type of visualization of the view
1153 Visual3d_TypeOfVisualization ViewType = MyContext.Visualization ();
1155 // Return type of visualization of the structure
1156 Graphic3d_TypeOfStructure StructType = AStructure->Visual ();
1158 Visual3d_TypeOfAnswer Result = Visual3d_TOA_NO;
1160 if (StructType == Graphic3d_TOS_ALL)
1161 // The structure accepts any type of view
1162 Result = Visual3d_TOA_YES;
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;
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";
1195 void Visual3d_View::ChangeDisplayPriority (const Handle(Graphic3d_Structure)& AStructure, const Standard_Integer /*OldPriority*/, const Standard_Integer NewPriority) {
1197 if (IsDeleted ()) return;
1198 if (! IsDefined ()) return;
1199 if (! IsActive ()) return;
1200 if (! IsDisplayed (AStructure)) return;
1202 Standard_Integer Index = IsComputed (AStructure);
1203 if (Index != 0 && ComputedMode())
1206 Standard_Integer StructId = MyCOMPUTEDSequence.Value (Index)->Identification ();
1207 cout << "Visual3d_View" << MyCView.ViewId << "::ChangeDisplayPriority ("
1208 << AStructure->Identification () << "/" << StructId
1209 << ", " << OldPriority << ", " << NewPriority << ")\n";
1212 MyGraphicDriver->EraseStructure
1214 *(Graphic3d_CStructure *)
1215 MyCOMPUTEDSequence.Value (Index)->CStructure ());
1216 MyGraphicDriver->DisplayStructure
1218 *(Graphic3d_CStructure *)
1219 MyCOMPUTEDSequence.Value (Index)->CStructure (),
1224 Standard_Integer StructId = AStructure->Identification ();
1225 cout << "Visual3d_View" << MyCView.ViewId << "::ChangeDisplayPriority ("
1226 << AStructure->Identification () << "/" << StructId
1227 << ", " << OldPriority << ", " << NewPriority << ")\n";
1230 MyGraphicDriver->EraseStructure
1232 *(Graphic3d_CStructure *)AStructure->CStructure ());
1233 MyGraphicDriver->DisplayStructure
1235 *(Graphic3d_CStructure *)AStructure->CStructure (),
1241 void Visual3d_View::Clear (const Handle(Graphic3d_Structure)& AStructure, const Standard_Boolean WithDestruction) {
1244 cout << "Visual3d_View" << MyCView.ViewId << "::Clear ("
1245 << AStructure->Identification () << ")\n";
1249 Standard_Integer Index = IsComputed (AStructure);
1252 cout << "Structure " << AStructure->Identification ()
1253 << " calculated in the view "
1254 << Identification () << ", by structure "
1255 << MyCOMPUTEDSequence.Value (Index)->Identification ()
1256 << " is emptied.\n";
1259 MyCOMPUTEDSequence.Value (Index)->GraphicClear (WithDestruction);
1260 MyCOMPUTEDSequence.Value (Index)->SetHLRValidation (Standard_False);
1265 void Visual3d_View::Connect (const Handle(Graphic3d_Structure)& AMother, const Handle(Graphic3d_Structure)& ADaughter) {
1267 #ifdef TRACE_CONNECT
1268 cout << "Visual3d_View" << MyCView.ViewId << "::Connect ("
1269 << AMother->Identification ()
1270 << ADaughter->Identification () << ")\n";
1274 Standard_Integer IndexM = IsComputed (AMother);
1275 Standard_Integer IndexD = IsComputed (ADaughter);
1277 if (IndexM != 0 && IndexD != 0) {
1278 #ifdef TRACE_CONNECT
1279 cout << "Structure " << AMother->Identification ()
1280 << " is connected to structure "
1281 << ADaughter->Identification () << endl;
1282 cout << "These structures are calculated.\n";
1283 cout << "In the view " << Identification ()
1285 << MyCOMPUTEDSequence.Value (IndexM)->Identification ()
1286 << " is connected to the structure "
1287 << MyCOMPUTEDSequence.Value (IndexD)->Identification ()
1290 MyCOMPUTEDSequence.Value (IndexM)->GraphicConnect (MyCOMPUTEDSequence.Value (IndexD));
1295 void Visual3d_View::Disconnect (const Handle(Graphic3d_Structure)& AMother, const Handle(Graphic3d_Structure)& ADaughter) {
1297 #ifdef TRACE_CONNECT
1298 cout << "Visual3d_View" << MyCView.ViewId << "::Disconnect ("
1299 << AMother->Identification ()
1300 << ADaughter->Identification () << ")\n";
1304 Standard_Integer IndexM = IsComputed (AMother);
1305 Standard_Integer IndexD = IsComputed (ADaughter);
1307 if (IndexM != 0 && IndexD != 0) {
1308 #ifdef TRACE_CONNECT
1309 cout << "Structure " << AMother->Identification ()
1310 << " is disconnected from the structure "
1311 << ADaughter->Identification () << endl;
1312 cout << "These structures are calculated.\n";
1313 cout << "In the view " << Identification ()
1315 << MyCOMPUTEDSequence.Value (IndexM)->Identification ()
1316 << " is disconnected from the structure "
1317 << MyCOMPUTEDSequence.Value (IndexD)->Identification ()
1320 MyCOMPUTEDSequence.Value (IndexM)->GraphicDisconnect (MyCOMPUTEDSequence.Value (IndexD));
1325 void Visual3d_View::Display (const Handle(Graphic3d_Structure)& AStructure) {
1327 Display (AStructure, MyViewManager->UpdateMode ());
1331 void Visual3d_View::Display (const Handle(Graphic3d_Structure)& AStructure, const Aspect_TypeOfUpdate AnUpdateMode) {
1333 if (IsDeleted ()) return;
1334 if (! IsDefined ()) return;
1335 if (! IsActive ()) return;
1337 // If Display on a structure present in the list
1338 // of calculated structures while it is not
1339 // or more, of calculated type =>
1340 // - removes it as well as the associated old computed
1341 // THis happens when hlhsr becomes again of type e
1342 // non computed after SetVisual.
1343 Standard_Integer Index = IsComputed (AStructure);
1345 if ((Index != 0) && (AStructure->Visual () != Graphic3d_TOS_COMPUTED)) {
1346 MyTOCOMPUTESequence.Remove (Index);
1347 MyCOMPUTEDSequence.Remove (Index);
1351 Visual3d_TypeOfAnswer Answer = AcceptDisplay (AStructure);
1353 if (Answer == Visual3d_TOA_NO) {
1357 if (!ComputedMode())
1359 Answer = Visual3d_TOA_YES;
1362 if (Answer == Visual3d_TOA_YES ) {
1363 if (IsDisplayed (AStructure)) return;
1364 MyGraphicDriver->DisplayStructure (
1366 *(Graphic3d_CStructure *)AStructure->CStructure (),
1367 int (AStructure->DisplayPriority ())
1369 MyDisplayedStructure.Add (AStructure);
1370 if (AnUpdateMode == Aspect_TOU_ASAP) Update ();
1373 if (Answer == Visual3d_TOA_COMPUTE) {
1375 // Already computed, is COMPUTED still valid?
1376 Standard_Integer OldStructId =
1377 MyCOMPUTEDSequence.Value (Index)->Identification ();
1379 // Case COMPUTED valide
1380 if (MyCOMPUTEDSequence.Value (Index)->HLRValidation ()) {
1382 if (! IsDisplayed (AStructure)) {
1383 MyDisplayedStructure.Add (AStructure);
1384 MyGraphicDriver->DisplayStructure (
1386 *(Graphic3d_CStructure *)MyCOMPUTEDSequence.Value (Index)->CStructure (),
1387 int (AStructure->DisplayPriority ())
1389 if (AnUpdateMode == Aspect_TOU_ASAP) Update ();
1394 // Case COMPUTED invalid
1396 // Is there another valid representation ?
1397 // Find in the sequence of already calculated structures
1398 // 1/ Structure having the same Owner as <AStructure>
1399 // 2/ That is not <AStructure>
1400 // 3/ The COMPUTED which of is valid
1401 Standard_Integer NewIndex = HaveTheSameOwner (AStructure);
1403 // Case of COMPUTED invalid, WITH a valid of replacement
1404 if (NewIndex != 0) {
1406 if (! IsDisplayed (AStructure)) {
1407 MyCOMPUTEDSequence.SetValue
1408 (Index, MyCOMPUTEDSequence.Value (NewIndex));
1409 OldStructId = MyCOMPUTEDSequence.Value (NewIndex)->
1411 MyDisplayedStructure.Add (AStructure);
1412 MyGraphicDriver->DisplayStructure (
1414 *(Graphic3d_CStructure *)MyCOMPUTEDSequence.Value (NewIndex)->CStructure (),
1415 int (AStructure->DisplayPriority ())
1417 if (AnUpdateMode == Aspect_TOU_ASAP) Update ();
1422 // Cas COMPUTED invalid, WITHOUT a valid of replacement
1424 // COMPUTED is removed if displayed
1425 if (IsDisplayed (AStructure))
1426 MyGraphicDriver->EraseStructure (
1428 *(Graphic3d_CStructure *)MyCOMPUTEDSequence.Value (Index)->CStructure ()
1432 } // if (Index != 0)
1434 // Compute + Validation
1436 Handle(Graphic3d_Structure) TheStructure = AStructure->Compute (this);
1438 Handle(Graphic3d_Structure) TheStructure;
1439 TColStd_Array2OfReal ATrsf (0, 3, 0, 3);
1440 AStructure->Transform (ATrsf);
1442 TColStd_Array2OfReal Ident (0, 3, 0, 3);
1443 Standard_Integer ii, jj;
1444 for (ii=0; ii<=3; ii++)
1445 for (jj=0; jj<=3; jj++)
1446 Ident (ii, jj) = (ii == jj ? 1.0 : 0.0);
1447 TheStructure = MyCOMPUTEDSequence.Value (Index);
1448 TheStructure->SetTransform (Ident, Graphic3d_TOC_REPLACE);
1449 if (AStructure->IsTransformed ()) {
1450 AStructure->Compute (this, ATrsf, TheStructure);
1453 AStructure->Compute (this, TheStructure);
1457 if (AStructure->IsTransformed ()) {
1458 TheStructure = AStructure->Compute (this, ATrsf);
1461 TheStructure = AStructure->Compute (this);
1465 TheStructure->SetHLRValidation (Standard_True);
1467 // TOCOMPUTE and COMPUTED associated to sequences are added
1468 MyTOCOMPUTESequence.Append (AStructure);
1469 MyCOMPUTEDSequence.Append (TheStructure);
1471 // The previous are removed if necessary
1473 MyTOCOMPUTESequence.Remove (Index);
1474 MyCOMPUTEDSequence.Remove (Index);
1477 // Return type of visualisation of the view
1478 Visual3d_TypeOfVisualization ViewType = MyContext.Visualization ();
1480 // Of which type will be the computed ?
1481 Standard_Boolean ComputeWireframe = ((ViewType == Visual3d_TOV_WIREFRAME) &&
1482 (AStructure->ComputeVisual () != Graphic3d_TOS_SHADING));
1484 Standard_Boolean ComputeShading = ((ViewType == Visual3d_TOV_SHADING) &&
1485 (AStructure->ComputeVisual () != Graphic3d_TOS_WIREFRAME));
1487 if (ComputeWireframe)
1488 TheStructure->SetVisual (Graphic3d_TOS_WIREFRAME);
1490 TheStructure->SetVisual (Graphic3d_TOS_SHADING);
1492 if (! ComputeShading && ! ComputeWireframe)
1493 Answer = Visual3d_TOA_NO;
1495 Answer = AcceptDisplay (TheStructure);
1497 if (AStructure->IsHighlighted()) {
1498 TheStructure->SetHighlightColor (AStructure->HighlightColor ());
1499 TheStructure->GraphicHighlight (Aspect_TOHM_COLOR);
1502 // It is displayed only if the calculated structure
1503 // has a proper type corresponding to the one of the view.
1504 if (Answer != Visual3d_TOA_NO) {
1505 if (! IsDisplayed (AStructure))
1506 MyDisplayedStructure.Add (AStructure);
1507 MyGraphicDriver->DisplayStructure (
1509 *(Graphic3d_CStructure *)TheStructure->CStructure (),
1510 int (AStructure->DisplayPriority ())
1512 if (AnUpdateMode == Aspect_TOU_ASAP) Update ();
1514 } // Visual3d_TOA_COMPUTE
1517 void Visual3d_View::Erase (const Handle(Graphic3d_Structure)& AStructure) {
1519 if (IsDeleted ()) return;
1521 Erase (AStructure, MyViewManager->UpdateMode ());
1525 void Visual3d_View::Erase (const Handle(Graphic3d_Structure)& AStructure, const Aspect_TypeOfUpdate AnUpdateMode) {
1527 Standard_Integer StructId;
1529 if (IsDeleted ()) return;
1531 // No test on window as the structure is displayed only if
1532 // the window exists, so only one test is enough.
1533 if (IsDisplayed (AStructure)) {
1534 Visual3d_TypeOfAnswer Answer = AcceptDisplay (AStructure);
1536 if (!ComputedMode())
1538 Answer = Visual3d_TOA_YES;
1541 if (Answer != Visual3d_TOA_COMPUTE) {
1542 MyGraphicDriver->EraseStructure (
1544 *(Graphic3d_CStructure *)AStructure->CStructure ()
1548 if (Answer == Visual3d_TOA_COMPUTE) {
1549 Standard_Integer Index = IsComputed (AStructure);
1551 cout << "Visual3d_View" << MyCView.ViewId << "::Erase ("
1552 << AStructure->Identification () << ");\n";
1553 cout << "Index : " << Index << "\n";
1557 if (Index != 0 && ComputedMode())
1560 MyCOMPUTEDSequence.Value (Index)->Identification ();
1562 cout << "Structure " << AStructure->Identification ()
1563 << " calculated, in the view "
1564 << Identification () << ", by the structure "
1565 << StructId << " is removed. \n";
1568 MyGraphicDriver->EraseStructure
1569 (MyCView, *(Graphic3d_CStructure *)MyCOMPUTEDSequence.Value (Index)->CStructure ());
1571 // else is impossible
1573 MyDisplayedStructure.Remove (AStructure);
1574 if (AnUpdateMode == Aspect_TOU_ASAP) Update ();
1579 void Visual3d_View::Highlight (const Handle(Graphic3d_Structure)& AStructure, const Aspect_TypeOfHighlightMethod AMethod) {
1582 cout << "Visual3d_View" << MyCView.ViewId << "::Highlight ("
1583 << AStructure->Identification () << ")\n";
1587 Standard_Integer Index = IsComputed (AStructure);
1590 cout << "Structure " << AStructure->Identification ()
1591 << " calculated, in the view "
1592 << Identification () << ", by the structure "
1593 << MyCOMPUTEDSequence.Value (Index)->Identification ()
1594 << " passes in highlight mode.\n";
1597 (MyCOMPUTEDSequence.Value (Index))->SetHighlightColor
1598 (AStructure->HighlightColor ());
1599 (MyCOMPUTEDSequence.Value (Index))->GraphicHighlight (AMethod);
1604 void Visual3d_View::SetTransform (const Handle(Graphic3d_Structure)& AStructure, const TColStd_Array2OfReal& ATrsf) {
1607 cout << "Visual3d_View" << MyCView.ViewId << "::Transform ("
1608 << AStructure->Identification () << ")\n";
1612 Standard_Integer Index = IsComputed (AStructure);
1615 cout << "The structure " << AStructure->Identification ()
1616 << " calculated, in the view "
1617 << Identification () << ", by the structure "
1618 << MyCOMPUTEDSequence.Value (Index)->Identification ()
1619 << " is transformed.\n";
1622 // Test is somewhat light !
1623 // trsf is transferred only if it is :
1626 if (ATrsf (0, 1) != 0. || ATrsf (0, 2) != 0.
1627 || ATrsf (1, 0) != 0. || ATrsf (1, 2) != 0.
1628 || ATrsf (2, 0) != 0. || ATrsf (2, 1) != 0.)
1629 ReCompute (AStructure);
1631 MyCOMPUTEDSequence.Value (Index)->GraphicTransform (ATrsf);
1636 void Visual3d_View::UnHighlight (const Handle(Graphic3d_Structure)& AStructure) {
1639 cout << "Visual3d_View" << MyCView.ViewId << "::UnHighlight ("
1640 << AStructure->Identification () << ")\n";
1644 Standard_Integer Index = IsComputed (AStructure);
1647 cout << "Structure " << AStructure->Identification ()
1648 << " calculated, in the view "
1649 << Identification () << ", by the structure "
1650 << MyCOMPUTEDSequence.Value (Index)->Identification ()
1651 << " passes in unhighlight mode.\n";
1654 MyCOMPUTEDSequence.Value (Index)->GraphicUnHighlight ();
1660 Standard_Integer Visual3d_View::IsComputed (const Handle(Graphic3d_Structure)& AStructure) const {
1662 Standard_Integer StrId = AStructure->Identification ();
1664 Standard_Integer Result = 0;
1665 Standard_Integer Length = MyTOCOMPUTESequence.Length ();
1667 // Recherche de la structure <AStructure> dans la
1668 // sequence des structures deja calculees
1669 for (Standard_Integer i=1; i<=Length && Result==0; i++)
1670 if ((MyTOCOMPUTESequence.Value (i))->Identification ()
1671 == StrId) Result = i;
1673 cout << "\n In the view " << Identification () << " the structure ";
1675 cout << StrId << " is calculated by "
1676 << MyCOMPUTEDSequence.Value (Result)->Identification ()
1679 cout << StrId << " is not calculated\n" << flush;
1683 if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ()) {
1684 cout << "In Visual3d_View::IsComputed, ";
1685 cout << "TOCOMPUTE " << MyTOCOMPUTESequence.Length ()
1686 << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
1695 Standard_Boolean Visual3d_View::IsDisplayed (const Handle(Graphic3d_Structure)& AStructure) const {
1697 Standard_Boolean Result = Standard_False;
1699 if (IsDeleted ()) return Result;
1701 Result = MyDisplayedStructure.Contains (AStructure);
1708 Standard_Boolean Visual3d_View::ContainsComputedStructure () const {
1710 Standard_Boolean Result = Standard_False;
1712 if (MyDisplayedStructure.IsEmpty ()) return Result;
1714 Graphic3d_MapIteratorOfMapOfStructure Iterator (MyDisplayedStructure);
1716 Standard_Integer i = MyDisplayedStructure.Extent ();
1718 // Stop at the first structure of type TOS_COMPUTED
1719 while (! Result && Iterator.More ()) {
1721 (((Iterator.Key ())->Visual ()) == Graphic3d_TOS_COMPUTED);
1723 // Iterator.Next () is located on the
1733 Standard_Boolean Visual3d_View::ContainsFacet () const {
1735 return ContainsFacet (MyDisplayedStructure);
1739 Standard_Boolean Visual3d_View::ContainsFacet (const Graphic3d_MapOfStructure& ASet) const {
1741 Standard_Boolean Result = Standard_False;
1743 if (ASet.IsEmpty ()) return Result;
1745 Graphic3d_MapIteratorOfMapOfStructure Iterator (ASet);
1747 // Stop at the first structure containing a facet
1748 for ( Iterator.Initialize (ASet);
1749 Iterator.More () && ! Result;
1751 Result = (Iterator.Key ())->ContainsFacet ();
1757 void Visual3d_View::MinMaxValues (Standard_Real& XMin, Standard_Real& YMin, Standard_Real& ZMin, Standard_Real& XMax, Standard_Real& YMax, Standard_Real& ZMax) const {
1760 (MyDisplayedStructure, XMin, YMin, ZMin, XMax, YMax, ZMax);
1764 void Visual3d_View::MinMaxValues (const Graphic3d_MapOfStructure& ASet, Standard_Real& XMin, Standard_Real& YMin, Standard_Real& ZMin, Standard_Real& XMax, Standard_Real& YMax, Standard_Real& ZMax) const {
1766 if (ASet.IsEmpty ()) {
1767 XMin = RealFirst ();
1768 YMin = RealFirst ();
1769 ZMin = RealFirst ();
1777 Standard_Real Xm, Ym, Zm, XM, YM, ZM;
1778 Graphic3d_MapIteratorOfMapOfStructure Iterator (ASet);
1784 XMax = RealFirst ();
1785 YMax = RealFirst ();
1786 ZMax = RealFirst ();
1788 for ( Iterator.Initialize (ASet);
1792 if ((Iterator.Key ())->IsInfinite ()){
1793 //XMin, YMin .... ZMax are initialized by means of infinite line data
1794 (Iterator.Key ())->MinMaxValues (Xm, Ym, Zm, XM, YM, ZM);
1795 if ( Xm != RealFirst() && Xm < XMin )
1797 if ( Ym != RealFirst() && Ym < YMin )
1799 if ( Zm != RealFirst() && Zm < ZMin )
1801 if ( XM != RealLast() && XM > XMax )
1803 if ( YM != RealLast() && YM > YMax )
1805 if ( ZM != RealLast() && ZM > ZMax )
1808 // Only non-empty and non-infinite structures
1809 // are taken into account for calculation of MinMax
1810 if (! (Iterator.Key ())->IsInfinite () &&
1811 ! (Iterator.Key ())->IsEmpty ()) {
1812 (Iterator.Key ())->MinMaxValues(Xm, Ym, Zm, XM, YM, ZM);
1813 /* ABD 29/10/04 Transform Persistence of Presentation( pan, zoom, rotate ) */
1814 //"FitAll" operation ignores object with transform persitence parameter
1815 if( (Iterator.Key ())->TransformPersistenceMode() == Graphic3d_TMF_None )
1817 if (Xm < XMin) XMin = Xm;
1818 if (Ym < YMin) YMin = Ym;
1819 if (Zm < ZMin) ZMin = Zm;
1820 if (XM > XMax) XMax = XM;
1821 if (YM > YMax) YMax = YM;
1822 if (ZM > ZMax) ZMax = ZM;
1827 // The following cases are relevant
1828 // For exemple if all structures are empty or infinite
1829 if (XMax < XMin) { Xm = XMin; XMin = XMax; XMax = Xm; }
1830 if (YMax < YMin) { Ym = YMin; YMin = YMax; YMax = Ym; }
1831 if (ZMax < ZMin) { Zm = ZMin; ZMin = ZMax; ZMax = Zm; }
1835 void Visual3d_View::MinMaxValues (Standard_Real& XMin, Standard_Real& YMin, Standard_Real& XMax, Standard_Real& YMax) {
1837 MinMaxValues (MyDisplayedStructure, XMin, YMin, XMax, YMax);
1841 void Visual3d_View::MinMaxValues (const Graphic3d_MapOfStructure& ASet, Standard_Real& XMin, Standard_Real& YMin, Standard_Real& XMax, Standard_Real& YMax) {
1843 Standard_Real Xm, Ym, Zm, XM, YM, ZM;
1844 Standard_Real Xp, Yp, Zp;
1846 MinMaxValues (ASet, Xm, Ym, Zm, XM, YM, ZM);
1848 Projects (Xm, Ym, Zm, Xp, Yp, Zp);
1852 Projects (XM, YM, ZM, Xp, Yp, Zp);
1856 if (XMax < XMin) { Xp = XMax; XMax = XMin; XMin = Xp; }
1857 if (YMax < YMin) { Yp = YMax; YMax = YMin; YMin = Yp; }
1861 Standard_Integer Visual3d_View::NumberOfDisplayedStructures () const {
1863 Standard_Integer Result = MyDisplayedStructure.Extent ();
1869 void Visual3d_View::Projects (const Standard_Real AX,
1870 const Standard_Real AY,
1871 const Standard_Real AZ,
1876 Handle(Graphic3d_Camera) aCamera = MyCView.Context.Camera;
1878 Standard_Real aUmin, aVMin, aUMax, aVMax;
1879 Standard_Real aNear, aFar;
1880 aCamera->WindowLimit (aUmin, aVMin, aUMax, aVMax);
1882 aNear = aCamera->ZNear();
1883 aFar = aCamera->ZFar();
1885 gp_Pnt aPoint (AX, AY, AZ);
1886 aPoint = aCamera->Project (aPoint);
1888 APX = (aPoint.X() + 1) * 0.5 * (aUMax - aUmin) + aUmin;
1889 APY = (aPoint.Y() + 1) * 0.5 * (aVMax - aVMin) + aVMin;
1890 APZ = aPoint.Z() * (aFar - aNear) + aNear;
1893 Standard_Integer Visual3d_View::Identification () const {
1895 return (Standard_Integer (MyCView.ViewId));
1900 Standard_Boolean Visual3d_View::ZBufferIsActivated () const {
1902 if (IsDeleted ()) return (Standard_False);
1904 if ((! IsDefined ()) || (! IsActive ())) return (Standard_False);
1906 // -1 => not forced by the programmer => depends on the type of visualisation
1907 // 0 ou 1 => forced by the programmer
1909 if (MyCView.Context.ZBufferActivity == -1)
1910 if (MyContext.Visualization () == Visual3d_TOV_SHADING)
1911 return (Standard_True);
1913 return (Standard_False);
1915 if (MyCView.Context.ZBufferActivity)
1916 return (Standard_True);
1918 return (Standard_False);
1922 void Visual3d_View::SetTransparency (const Standard_Boolean AnActivity) {
1924 if (IsDeleted ()) return;
1926 if ((! IsDefined ()) || (! IsActive ())) return;
1928 MyGraphicDriver->Transparency (MyCView, AnActivity);
1932 void Visual3d_View::SetZBufferActivity (const Standard_Integer AnActivity) {
1934 if (MyCView.Context.ZBufferActivity == AnActivity) return;
1936 if (IsDeleted ()) return;
1938 if ((! IsDefined ()) || (! IsActive ())) return;
1940 MyCView.Context.ZBufferActivity = AnActivity;
1941 MyGraphicDriver->SetVisualisation (MyCView);
1945 void Visual3d_View::UpdateView () {
1947 MyCView.Context.Aliasing = (MyContext.AliasingIsOn () ? 1:0);
1948 MyCView.Context.BackZClipping =
1949 (MyContext.BackZClippingIsOn () ? 1:0);
1950 MyCView.Context.FrontZClipping =
1951 (MyContext.FrontZClippingIsOn() ? 1:0);
1952 MyCView.Context.DepthCueing =
1953 (MyContext.DepthCueingIsOn () ? 1:0);
1955 MyCView.Context.ZClipFrontPlane =
1956 float (MyContext.ZClippingFrontPlane ());
1957 MyCView.Context.ZClipBackPlane =
1958 float (MyContext.ZClippingBackPlane ());
1959 MyCView.Context.DepthFrontPlane =
1960 float (MyContext.DepthCueingFrontPlane ());
1961 MyCView.Context.DepthBackPlane =
1962 float (MyContext.DepthCueingBackPlane ());
1964 MyCView.Context.Model = int (MyContext.Model ());
1965 MyCView.Context.Visualization = int (MyContext.Visualization ());
1967 MyCView.Context.TextureEnv = MyContext.TextureEnv();
1968 MyCView.Context.SurfaceDetail = MyContext.SurfaceDetail();
1972 void Visual3d_View::Compute () {
1975 Standard_Integer Length = MyCOMPUTEDSequence.Length ();
1976 for (i=1; i<=Length; i++)
1977 (MyCOMPUTEDSequence.Value (i))->SetHLRValidation (Standard_False);
1979 if (!ComputedMode())
1985 * Force HLRValidation to False on all structures
1986 * calculated in the view.
1989 if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ()) {
1990 cout << "In Visual3d_View::Compute, ";
1991 cout << "TOCOMPUTE " << MyTOCOMPUTESequence.Length ()
1992 << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
1998 * Change of orientation or of projection type =>
1999 * Remove structures that were calculated for the
2000 * previous orientation.
2001 * Recalculation of new structures.
2003 Graphic3d_MapIteratorOfMapOfStructure S1Iterator (MyDisplayedStructure);
2004 Visual3d_TypeOfAnswer Answer;
2006 i = MyDisplayedStructure.Extent ();
2008 Graphic3d_SequenceOfStructure FooSequence;
2010 while (S1Iterator.More ()) {
2011 Answer = AcceptDisplay (S1Iterator.Key ());
2012 // If the structure was calculated, it is recalculated.
2013 if (Answer == Visual3d_TOA_COMPUTE) {
2015 cout << "AcceptDisplay ("
2016 << (S1Iterator.Key ())->Identification ()
2017 << ") == Visual3d_TOA_COMPUTE;\n";
2020 //Display (S1Iterator.Key (), Aspect_TOU_WAIT);
2021 FooSequence.Append (S1Iterator.Key ());
2024 // S1Iterator.Next () is located on the next structure
2028 Length = FooSequence.Length ();
2029 // All stored structures are displayed
2030 for (i=1; i<=Length; i++)
2031 Display (FooSequence.Value (i), Aspect_TOU_WAIT);
2032 if (Length != 0) FooSequence.Clear ();
2036 void Visual3d_View::ReCompute (const Handle(Graphic3d_Structure)& AStructure) {
2037 if (!ComputedMode()) return;
2039 if (IsDeleted ()) return;
2041 if ((! IsDefined ()) || (! IsActive ())) return;
2043 if (! MyWindow->IsMapped ()) return;
2045 if (! AStructure->IsDisplayed ()) return;
2047 Visual3d_TypeOfAnswer Answer;
2049 Answer = AcceptDisplay (AStructure);
2051 if (Answer == Visual3d_TOA_COMPUTE) {
2052 Standard_Integer Index = IsComputed (AStructure);
2055 cout << "Structure " << AStructure->Identification ()
2056 << " is not calculated in the view "
2057 << Identification () << "\n";
2062 Standard_Integer OldStructId, NewStructId;
2064 MyCOMPUTEDSequence.Value (Index)->Identification ();
2066 Standard_Integer StructId = AStructure->Identification ();
2067 cout << "Structure " << StructId
2068 << " calculated, in the view "
2069 << Identification () << ", by the structure "
2070 << OldStructId << " is recalculated.\n";
2074 // Compute + Validation
2076 Handle(Graphic3d_Structure) TheStructure = AStructure->Compute (this);
2078 Handle(Graphic3d_Structure) TheStructure;
2079 TColStd_Array2OfReal ATrsf (0, 3, 0, 3);
2080 AStructure->Transform (ATrsf);
2082 TColStd_Array2OfReal Ident (0, 3, 0, 3);
2083 Standard_Integer ii, jj;
2084 for (ii=0; ii<=3; ii++)
2085 for (jj=0; jj<=3; jj++)
2086 Ident (ii, jj) = (ii == jj ? 1.0 : 0.0);
2087 TheStructure = MyCOMPUTEDSequence.Value (Index);
2088 TheStructure->SetTransform (Ident, Graphic3d_TOC_REPLACE);
2089 if (AStructure->IsTransformed ()) {
2090 AStructure->Compute (this, ATrsf, TheStructure);
2093 AStructure->Compute (this, TheStructure);
2097 if (AStructure->IsTransformed ()) {
2098 TheStructure = AStructure->Compute (this, ATrsf);
2101 TheStructure = AStructure->Compute (this);
2105 TheStructure->SetHLRValidation (Standard_True);
2107 // Return type of visualisation of the view
2108 Visual3d_TypeOfVisualization ViewType = MyContext.Visualization ();
2110 // Of which type will be the computed ?
2111 Standard_Boolean ComputeWireframe = ((ViewType == Visual3d_TOV_WIREFRAME) &&
2112 (AStructure->ComputeVisual () != Graphic3d_TOS_SHADING));
2114 Standard_Boolean ComputeShading = ((ViewType == Visual3d_TOV_SHADING) &&
2115 (AStructure->ComputeVisual () != Graphic3d_TOS_WIREFRAME));
2117 if (ComputeWireframe)
2118 TheStructure->SetVisual (Graphic3d_TOS_WIREFRAME);
2120 TheStructure->SetVisual (Graphic3d_TOS_SHADING);
2122 if (AStructure->IsHighlighted ()) {
2123 TheStructure->SetHighlightColor
2124 (AStructure->HighlightColor ());
2125 TheStructure->GraphicHighlight (Aspect_TOHM_COLOR);
2129 // Find structure <AStructure>
2130 // in the sequence of structures to be calculated.
2131 NewStructId = TheStructure->Identification ();
2133 // The previous calculation is removed and the new one is dislayed
2134 MyGraphicDriver->EraseStructure (
2136 *(Graphic3d_CStructure *)MyCOMPUTEDSequence.Value (Index)->CStructure ());
2137 MyGraphicDriver->DisplayStructure (
2139 *(Graphic3d_CStructure *)TheStructure->CStructure (),
2140 int (AStructure->DisplayPriority ())
2144 if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ()) {
2145 cout << "In Visual3d_View::ReCompute, ";
2146 cout << "TOCOMPUTE " << MyTOCOMPUTESequence.Length ()
2147 << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
2152 // hlhsr and the new associated compute are added
2153 MyTOCOMPUTESequence.Append (AStructure);
2154 MyCOMPUTEDSequence.Append (TheStructure);
2157 if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ())
2158 cout << "\tTOCOMPUTE " << MyTOCOMPUTESequence.Length ()
2159 << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
2163 // hlhsr and the new associated compute are removed
2165 MyTOCOMPUTESequence.Remove (Index);
2166 MyCOMPUTEDSequence.Remove (Index);
2169 if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ())
2170 cout << "\tTOCOMPUTE " << MyTOCOMPUTESequence.Length ()
2171 << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
2179 const Handle(Graphic3d_GraphicDriver)& Visual3d_View::GraphicDriver () const {
2181 return MyGraphicDriver;
2185 void Visual3d_View::Plot (const Handle(Graphic3d_Plotter)& thePlotter) const
2187 for (Graphic3d_MapIteratorOfMapOfStructure S1Iterator (MyDisplayedStructure); S1Iterator.More(); S1Iterator.Next())
2189 Standard_Integer Index = IsComputed (S1Iterator.Key ());
2190 // displayed structure is plotted as if it was not calculated
2192 (S1Iterator.Key ())->Plot (thePlotter);
2194 (MyCOMPUTEDSequence.Value (Index))->Plot (thePlotter);
2198 Standard_Integer Visual3d_View::HaveTheSameOwner (const Handle(Graphic3d_Structure)& AStructure) const {
2200 Standard_Integer Result = 0;
2201 Standard_Integer Length = MyTOCOMPUTESequence.Length ();
2203 // Find in the sequence of already calculated structures
2204 // 1/ Structure with the same Owner as <AStructure>
2205 // 2/ Which is not <AStructure>
2206 // 3/ COMPUTED which of is valid
2207 for (Standard_Integer i=1; i<=Length && Result==0; i++)
2208 if ((MyTOCOMPUTESequence.Value (i)->Owner () == AStructure->Owner ())
2209 && (MyTOCOMPUTESequence.Value (i)->Identification () !=
2210 AStructure->Identification ())
2211 && (MyCOMPUTEDSequence.Value (i)->HLRValidation ())) Result = i;
2217 Standard_Address Visual3d_View::CView () const {
2219 return Standard_Address (&MyCView);
2224 // Triedron methods : the Triedron is a non-zoomable object.
2226 void Visual3d_View::ZBufferTriedronSetup(const Quantity_NameOfColor XColor,
2227 const Quantity_NameOfColor YColor,
2228 const Quantity_NameOfColor ZColor,
2229 const Standard_Real SizeRatio,
2230 const Standard_Real AxisDiametr,
2231 const Standard_Integer NbFacettes) {
2232 MyGraphicDriver->ZBufferTriedronSetup(XColor, YColor, ZColor,
2233 SizeRatio, AxisDiametr, NbFacettes);
2238 void Visual3d_View::TriedronDisplay (const Aspect_TypeOfTriedronPosition APosition,
2239 const Quantity_NameOfColor AColor, const Standard_Real AScale, const Standard_Boolean AsWireframe ) {
2241 MyGraphicDriver->TriedronDisplay (MyCView,APosition, AColor, AScale, AsWireframe);
2245 void Visual3d_View::TriedronErase () {
2247 MyGraphicDriver->TriedronErase (MyCView);
2252 void Visual3d_View::TriedronEcho (const Aspect_TypeOfTriedronEcho AType ) {
2254 MyGraphicDriver->TriedronEcho (MyCView,AType);
2258 static Standard_Boolean checkFloat(const Standard_Real value)
2260 return value > -FLT_MAX && value < FLT_MAX;
2263 static void SetMinMaxValuesCallback(Visual3d_View* theView)
2265 Standard_Real xmin, ymin, zmin, xmax, ymax, zmax;
2266 theView->MinMaxValues(xmin, ymin, zmin, xmax, ymax, zmax);
2268 if (checkFloat(xmin) && checkFloat(ymin) && checkFloat(zmin) &&
2269 checkFloat(xmax) && checkFloat(ymax) && checkFloat(zmax))
2271 Handle(Graphic3d_GraphicDriver) driver = Handle(Graphic3d_GraphicDriver)::DownCast(theView->GraphicDriver());
2272 driver->GraduatedTrihedronMinMaxValues((Standard_ShortReal)xmin, (Standard_ShortReal)ymin, (Standard_ShortReal)zmin,
2273 (Standard_ShortReal)xmax, (Standard_ShortReal)ymax, (Standard_ShortReal)zmax);
2277 Standard_Boolean Visual3d_View::GetGraduatedTrihedron
2278 (/* Names of axes */
2279 TCollection_ExtendedString& xname,
2280 TCollection_ExtendedString& yname,
2281 TCollection_ExtendedString& zname,
2283 Standard_Boolean& xdrawname,
2284 Standard_Boolean& ydrawname,
2285 Standard_Boolean& zdrawname,
2287 Standard_Boolean& xdrawvalues,
2288 Standard_Boolean& ydrawvalues,
2289 Standard_Boolean& zdrawvalues,
2291 Standard_Boolean& drawgrid,
2293 Standard_Boolean& drawaxes,
2294 /* Number of splits along axes */
2295 Standard_Integer& nbx,
2296 Standard_Integer& nby,
2297 Standard_Integer& nbz,
2298 /* Offset for drawing values */
2299 Standard_Integer& xoffset,
2300 Standard_Integer& yoffset,
2301 Standard_Integer& zoffset,
2302 /* Offset for drawing names of axes */
2303 Standard_Integer& xaxisoffset,
2304 Standard_Integer& yaxisoffset,
2305 Standard_Integer& zaxisoffset,
2306 /* Draw tickmarks */
2307 Standard_Boolean& xdrawtickmarks,
2308 Standard_Boolean& ydrawtickmarks,
2309 Standard_Boolean& zdrawtickmarks,
2310 /* Length of tickmarks */
2311 Standard_Integer& xtickmarklength,
2312 Standard_Integer& ytickmarklength,
2313 Standard_Integer& ztickmarklength,
2315 Quantity_Color& gridcolor,
2316 /* Colors of axis names */
2317 Quantity_Color& xnamecolor,
2318 Quantity_Color& ynamecolor,
2319 Quantity_Color& znamecolor,
2320 /* Colors of axis and values */
2321 Quantity_Color& xcolor,
2322 Quantity_Color& ycolor,
2323 Quantity_Color& zcolor,
2324 /* Name of font for names of axes */
2325 TCollection_AsciiString& fontOfNames,
2326 /* Style of names of axes */
2327 Font_FontAspect& styleOfNames,
2328 /* Size of names of axes */
2329 Standard_Integer& sizeOfNames,
2330 /* Name of font for values */
2331 TCollection_AsciiString& fontOfValues,
2332 /* Style of values */
2333 Font_FontAspect& styleOfValues,
2334 /* Size of values */
2335 Standard_Integer& sizeOfValues) const
2337 if (!MyGTrihedron.ptrVisual3dView)
2338 return Standard_False;
2341 xname = MyGTrihedron.xname;
2342 yname = MyGTrihedron.yname;
2343 zname = MyGTrihedron.zname;
2345 xdrawname = MyGTrihedron.xdrawname;
2346 ydrawname = MyGTrihedron.ydrawname;
2347 zdrawname = MyGTrihedron.zdrawname;
2349 xdrawvalues = MyGTrihedron.xdrawvalues;
2350 ydrawvalues = MyGTrihedron.ydrawvalues;
2351 zdrawvalues = MyGTrihedron.zdrawvalues;
2353 drawgrid = MyGTrihedron.drawgrid;
2355 drawaxes = MyGTrihedron.drawaxes;
2356 /* Number of splits along axes */
2357 nbx = MyGTrihedron.nbx;
2358 nby = MyGTrihedron.nby;
2359 nbz = MyGTrihedron.nbz;
2360 /* Offset for drawing values */
2361 xoffset = MyGTrihedron.xoffset;
2362 yoffset = MyGTrihedron.yoffset;
2363 zoffset = MyGTrihedron.zoffset;
2364 /* Offset for drawing names of axes */
2365 xaxisoffset = MyGTrihedron.xaxisoffset;
2366 yaxisoffset = MyGTrihedron.yaxisoffset;
2367 zaxisoffset = MyGTrihedron.zaxisoffset;
2368 /* Draw tickmarks */
2369 xdrawtickmarks = MyGTrihedron.xdrawtickmarks;
2370 ydrawtickmarks = MyGTrihedron.ydrawtickmarks;
2371 zdrawtickmarks = MyGTrihedron.zdrawtickmarks;
2372 /* Length of tickmarks */
2373 xtickmarklength = MyGTrihedron.xtickmarklength;
2374 ytickmarklength = MyGTrihedron.ytickmarklength;
2375 ztickmarklength = MyGTrihedron.ztickmarklength;
2377 gridcolor = MyGTrihedron.gridcolor;
2378 /* Colors of axis names */
2379 xnamecolor = MyGTrihedron.xnamecolor;
2380 ynamecolor = MyGTrihedron.ynamecolor;
2381 znamecolor = MyGTrihedron.znamecolor;
2382 /* Colors of axis and values */
2383 xcolor = MyGTrihedron.xcolor;
2384 ycolor = MyGTrihedron.ycolor;
2385 zcolor = MyGTrihedron.zcolor;
2386 /* Name of font for names of axes */
2387 fontOfNames = MyGTrihedron.fontOfNames;
2388 /* Style of names of axes */
2389 styleOfNames = MyGTrihedron.styleOfNames;
2390 /* Size of names of axes */
2391 sizeOfNames = MyGTrihedron.sizeOfNames;
2392 /* Name of font for values */
2393 fontOfValues = MyGTrihedron.fontOfValues;
2394 /* Style of values */
2395 styleOfValues = MyGTrihedron.styleOfValues;
2396 /* Size of values */
2397 sizeOfValues = MyGTrihedron.sizeOfValues;
2399 return Standard_True;
2402 void Visual3d_View::GraduatedTrihedronDisplay
2403 (/* Names of axes */
2404 const TCollection_ExtendedString &xname,
2405 const TCollection_ExtendedString &yname,
2406 const TCollection_ExtendedString &zname,
2408 const Standard_Boolean xdrawname,
2409 const Standard_Boolean ydrawname,
2410 const Standard_Boolean zdrawname,
2412 const Standard_Boolean xdrawvalues,
2413 const Standard_Boolean ydrawvalues,
2414 const Standard_Boolean zdrawvalues,
2416 const Standard_Boolean drawgrid,
2418 const Standard_Boolean drawaxes,
2419 /* Number of splits along axes */
2420 const Standard_Integer nbx,
2421 const Standard_Integer nby,
2422 const Standard_Integer nbz,
2423 /* Offset for drawing values */
2424 const Standard_Integer xoffset,
2425 const Standard_Integer yoffset,
2426 const Standard_Integer zoffset,
2427 /* Offset for drawing names of axes */
2428 const Standard_Integer xaxisoffset,
2429 const Standard_Integer yaxisoffset,
2430 const Standard_Integer zaxisoffset,
2431 /* Draw tickmarks */
2432 const Standard_Boolean xdrawtickmarks,
2433 const Standard_Boolean ydrawtickmarks,
2434 const Standard_Boolean zdrawtickmarks,
2435 /* Length of tickmarks */
2436 const Standard_Integer xtickmarklength,
2437 const Standard_Integer ytickmarklength,
2438 const Standard_Integer ztickmarklength,
2440 const Quantity_Color& gridcolor,
2441 /* Colors of axis names */
2442 const Quantity_Color& xnamecolor,
2443 const Quantity_Color& ynamecolor,
2444 const Quantity_Color& znamecolor,
2445 /* Colors of axis and values */
2446 const Quantity_Color& xcolor,
2447 const Quantity_Color& ycolor,
2448 const Quantity_Color& zcolor,
2449 /* Name of font for names of axes */
2450 const TCollection_AsciiString &fontOfNames,
2451 /* Style of names of axes */
2452 const Font_FontAspect styleOfNames,
2453 /* Size of names of axes */
2454 const Standard_Integer sizeOfNames,
2455 /* Name of font for values */
2456 const TCollection_AsciiString &fontOfValues,
2457 /* Style of values */
2458 const Font_FontAspect styleOfValues,
2459 /* Size of values */
2460 const Standard_Integer sizeOfValues)
2463 MyGTrihedron.xname = xname;
2464 MyGTrihedron.yname = yname;
2465 MyGTrihedron.zname = zname;
2467 MyGTrihedron.xdrawname = xdrawname;
2468 MyGTrihedron.ydrawname = ydrawname;
2469 MyGTrihedron.zdrawname = zdrawname;
2471 MyGTrihedron.xdrawvalues = xdrawvalues;
2472 MyGTrihedron.ydrawvalues = ydrawvalues;
2473 MyGTrihedron.zdrawvalues = zdrawvalues;
2475 MyGTrihedron.drawgrid = drawgrid;
2477 MyGTrihedron.drawaxes = drawaxes;
2478 /* Number of splits along axes */
2479 MyGTrihedron.nbx = nbx;
2480 MyGTrihedron.nby = nby;
2481 MyGTrihedron.nbz = nbz;
2482 /* Offset for drawing values */
2483 MyGTrihedron.xoffset = xoffset;
2484 MyGTrihedron.yoffset = yoffset;
2485 MyGTrihedron.zoffset = zoffset;
2486 /* Offset for drawing names of axes */
2487 MyGTrihedron.xaxisoffset = xaxisoffset;
2488 MyGTrihedron.yaxisoffset = yaxisoffset;
2489 MyGTrihedron.zaxisoffset = zaxisoffset;
2490 /* Draw tickmarks */
2491 MyGTrihedron.xdrawtickmarks = xdrawtickmarks;
2492 MyGTrihedron.ydrawtickmarks = ydrawtickmarks;
2493 MyGTrihedron.zdrawtickmarks = zdrawtickmarks;
2494 /* Length of tickmarks */
2495 MyGTrihedron.xtickmarklength = xtickmarklength;
2496 MyGTrihedron.ytickmarklength = ytickmarklength;
2497 MyGTrihedron.ztickmarklength = ztickmarklength;
2499 MyGTrihedron.gridcolor = gridcolor;
2500 /* Colors of axis names */
2501 MyGTrihedron.xnamecolor = xnamecolor;
2502 MyGTrihedron.ynamecolor = ynamecolor;
2503 MyGTrihedron.znamecolor = znamecolor;
2504 /* Colors of axis and values */
2505 MyGTrihedron.xcolor = xcolor;
2506 MyGTrihedron.ycolor = ycolor;
2507 MyGTrihedron.zcolor = zcolor;
2508 /* Name of font for names of axes */
2509 MyGTrihedron.fontOfNames = fontOfNames;
2510 /* Style of names of axes */
2511 MyGTrihedron.styleOfNames = styleOfNames;
2512 /* Size of names of axes */
2513 MyGTrihedron.sizeOfNames = sizeOfNames;
2514 /* Name of font for values */
2515 MyGTrihedron.fontOfValues = fontOfValues;
2516 /* Style of values */
2517 MyGTrihedron.styleOfValues = styleOfValues;
2518 /* Size of values */
2519 MyGTrihedron.sizeOfValues = sizeOfValues;
2521 MyGTrihedron.ptrVisual3dView = this;
2522 MyGTrihedron.cbCubicAxes = SetMinMaxValuesCallback;
2523 MyGraphicDriver->GraduatedTrihedronDisplay(MyCView,MyGTrihedron);
2526 void Visual3d_View::GraduatedTrihedronErase()
2528 MyGTrihedron.ptrVisual3dView = NULL;
2529 MyGraphicDriver->GraduatedTrihedronErase(MyCView);
2532 const Handle(Visual3d_Layer)& Visual3d_View::UnderLayer () const {
2534 return (MyViewManager->UnderLayer ());
2538 const Handle(Visual3d_Layer)& Visual3d_View::OverLayer () const {
2540 return (MyViewManager->OverLayer ());
2544 Standard_Integer Visual3d_View::LightLimit() const {
2546 Standard_Integer maxlight = MyGraphicDriver->InquireLightLimit ();
2547 // printf(" $$$ Visual3d_View::LightLimit() is %d\n",maxlight);
2551 Standard_Integer Visual3d_View::PlaneLimit() const {
2553 Standard_Integer maxplane = MyGraphicDriver->InquirePlaneLimit ();
2554 // printf(" $$$ Visual3d_View::PlaneLimit() is %d\n",maxplane);
2558 Handle(Visual3d_ViewManager) Visual3d_View::ViewManager() const
2560 return MyPtrViewManager;
2563 void Visual3d_View :: SetComputedMode ( const Standard_Boolean aMode )
2565 if ((aMode && ComputedModeIsActive) ||
2566 (!aMode && !ComputedModeIsActive))
2571 Graphic3d_MapIteratorOfMapOfStructure S1Iterator ( MyDisplayedStructure );
2572 Visual3d_TypeOfAnswer Answer;
2573 Standard_Integer StructId;
2574 Standard_Integer i = MyDisplayedStructure.Extent ();
2575 ComputedModeIsActive = aMode;
2576 if (!ComputedModeIsActive) {
2578 while ( S1Iterator.More () ) {
2580 Answer = AcceptDisplay ( S1Iterator.Key () );
2582 if ( Answer == Visual3d_TOA_COMPUTE ) {
2584 Standard_Integer Index = IsComputed ( S1Iterator.Key () );
2588 StructId = MyCOMPUTEDSequence.Value ( Index ) -> Identification ();
2590 MyGraphicDriver -> EraseStructure (
2592 *( Graphic3d_CStructure* )
2593 MyCOMPUTEDSequence.Value ( Index ) -> CStructure ()
2595 MyGraphicDriver -> DisplayStructure (
2597 *( Graphic3d_CStructure* )
2598 S1Iterator.Key () -> CStructure (),
2599 int ( S1Iterator.Key () -> DisplayPriority () )
2601 } // end if ( Index != 0 ) . . .
2603 } // end if ( Answer . . . )
2611 while ( S1Iterator.More () ) {
2613 Answer = AcceptDisplay ( S1Iterator.Key () );
2615 if ( Answer == Visual3d_TOA_COMPUTE ) {
2617 Standard_Integer Index = IsComputed ( S1Iterator.Key () );
2621 StructId = MyCOMPUTEDSequence.Value ( Index ) -> Identification ();
2623 MyGraphicDriver -> EraseStructure (
2625 *( Graphic3d_CStructure* )
2626 S1Iterator.Key () -> CStructure ()
2628 MyGraphicDriver -> DisplayStructure (
2630 *( Graphic3d_CStructure* )
2631 MyCOMPUTEDSequence.Value ( Index ) -> CStructure (),
2632 int ( S1Iterator.Key () -> DisplayPriority () )
2635 Display ( S1Iterator.Key (), Aspect_TOU_WAIT );
2637 if ( S1Iterator.Key () -> IsHighlighted () ) {
2639 if ( !MyCOMPUTEDSequence.Value ( Index ) -> IsHighlighted () ) {
2641 MyCOMPUTEDSequence.Value ( Index ) -> SetHighlightColor (
2642 S1Iterator.Key () ->
2645 MyCOMPUTEDSequence.Value ( Index ) -> GraphicHighlight (
2654 Handle( Graphic3d_Structure ) AStructure = S1Iterator.Key ();
2656 Handle( Graphic3d_Structure ) TheStructure = AStructure -> Compute ( this );
2658 Handle( Graphic3d_Structure ) TheStructure;
2659 TColStd_Array2OfReal ATrsf ( 0, 3, 0, 3 );
2661 AStructure -> Transform ( ATrsf );
2665 TColStd_Array2OfReal Ident ( 0, 3, 0, 3 );
2666 Standard_Integer ii, jj;
2668 for ( ii = 0; ii <= 3; ++ii )
2670 for ( jj = 0; jj <= 3; ++jj )
2672 Ident ( ii, jj ) = ( ii == jj ? 1.0 : 0.0 );
2674 TheStructure = MyCOMPUTEDSequence.Value ( Index );
2676 TheStructure -> SetTransform ( Ident, Graphic3d_TOC_REPLACE );
2678 if ( AStructure->IsTransformed () )
2680 AStructure -> Compute ( this, ATrsf, TheStructure );
2684 AStructure -> Compute ( this, TheStructure );
2688 if ( AStructure -> IsTransformed () )
2690 TheStructure = AStructure -> Compute ( this, ATrsf );
2694 TheStructure = AStructure -> Compute ( this );
2698 TheStructure -> SetHLRValidation ( Standard_True );
2700 Visual3d_TypeOfVisualization ViewType = MyContext.Visualization ();
2702 Standard_Boolean ComputeWireframe =
2703 ( ( ViewType == Visual3d_TOV_WIREFRAME ) &&
2704 ( S1Iterator.Key () -> ComputeVisual () != Graphic3d_TOS_SHADING )
2707 Standard_Boolean ComputeShading =
2708 ( ( ViewType == Visual3d_TOV_SHADING ) &&
2709 ( S1Iterator.Key () -> ComputeVisual () != Graphic3d_TOS_WIREFRAME )
2712 if ( ComputeWireframe ) TheStructure -> SetVisual ( Graphic3d_TOS_WIREFRAME );
2713 if ( ComputeShading ) TheStructure -> SetVisual ( Graphic3d_TOS_SHADING );
2715 if ( S1Iterator.Key () -> IsHighlighted () ) {
2717 TheStructure -> SetHighlightColor (
2718 S1Iterator.Key () -> HighlightColor ()
2720 TheStructure -> GraphicHighlight ( Aspect_TOHM_COLOR );
2724 Standard_Integer Result = 0;
2725 Standard_Integer Length = MyTOCOMPUTESequence.Length ();
2726 StructId = S1Iterator.Key () -> Identification ();
2728 for ( i = 1; i <= Length && Result == 0; ++i )
2730 if ( MyTOCOMPUTESequence.Value ( i ) -> Identification () == StructId )
2736 MyCOMPUTEDSequence.ChangeValue ( Result ) = TheStructure;
2740 MyTOCOMPUTESequence.Append ( S1Iterator.Key () );
2741 MyCOMPUTEDSequence.Append ( TheStructure );
2745 MyGraphicDriver -> EraseStructure (
2747 *( Graphic3d_CStructure* )
2748 S1Iterator.Key () -> CStructure ()
2750 MyGraphicDriver -> DisplayStructure (
2752 *( Graphic3d_CStructure* )TheStructure -> CStructure (),
2753 int ( S1Iterator.Key () -> DisplayPriority () )
2763 if ( MyViewManager -> UpdateMode () == Aspect_TOU_ASAP ) Update ();
2767 } // end Visual3d_View :: SetComputedMode
2769 Standard_Boolean Visual3d_View :: ComputedMode () const {
2771 return ComputedModeIsActive;
2773 } // end Visual3d_View :: ComputedMode
2775 void Visual3d_View :: SetBackFacingModel (
2776 const Visual3d_TypeOfBackfacingModel aModel
2781 case Visual3d_TOBM_AUTOMATIC:
2782 MyCView.Backfacing = 0;
2785 case Visual3d_TOBM_FORCE:
2786 MyCView.Backfacing = 1;
2789 case Visual3d_TOBM_DISABLE:
2790 MyCView.Backfacing = -1;
2795 MyGraphicDriver -> SetBackFacingModel ( MyCView );
2797 } // end Visual3d_View :: SetBackFacingModel
2799 Visual3d_TypeOfBackfacingModel Visual3d_View :: BackFacingModel () const {
2801 switch ( MyCView.Backfacing ) {
2804 return Visual3d_TOBM_AUTOMATIC;
2807 return Visual3d_TOBM_FORCE;
2811 return Visual3d_TOBM_DISABLE;
2813 } // end Visual3d_View :: BackFacingModel
2815 void Visual3d_View::EnableDepthTest( const Standard_Boolean enable ) const
2817 MyGraphicDriver->SetDepthTestEnabled( MyCView, enable );
2820 Standard_Boolean Visual3d_View::IsDepthTestEnabled() const
2822 return MyGraphicDriver->IsDepthTestEnabled( MyCView );
2825 void Visual3d_View::ReadDepths(const Standard_Integer x,
2826 const Standard_Integer y,
2827 const Standard_Integer width,
2828 const Standard_Integer height,
2829 const Standard_Address buffer) const
2831 MyGraphicDriver->ReadDepths( MyCView, x, y, width, height, buffer );
2834 Graphic3d_PtrFrameBuffer Visual3d_View::FBOCreate(const Standard_Integer theWidth,
2835 const Standard_Integer theHeight)
2837 return MyGraphicDriver->FBOCreate( MyCView, theWidth, theHeight );
2840 void Visual3d_View::FBORelease(Graphic3d_PtrFrameBuffer& theFBOPtr)
2842 MyGraphicDriver->FBORelease( MyCView, theFBOPtr );
2845 void Visual3d_View::FBOGetDimensions(const Graphic3d_PtrFrameBuffer theFBOPtr,
2846 Standard_Integer& theWidth, Standard_Integer& theHeight,
2847 Standard_Integer& theWidthMax, Standard_Integer& theHeightMax)
2849 MyGraphicDriver->FBOGetDimensions( MyCView, theFBOPtr,
2850 theWidth, theHeight,
2851 theWidthMax, theHeightMax );
2854 void Visual3d_View::FBOChangeViewport(Graphic3d_PtrFrameBuffer& theFBOPtr,
2855 const Standard_Integer theWidth, const Standard_Integer theHeight)
2857 MyGraphicDriver->FBOChangeViewport( MyCView, theFBOPtr,
2858 theWidth, theHeight );
2861 Standard_Boolean Visual3d_View::BufferDump (Image_PixMap& theImage,
2862 const Graphic3d_BufferType& theBufferType)
2864 return MyGraphicDriver->BufferDump (MyCView, theImage, theBufferType);
2867 void Visual3d_View::EnableGLLight( const Standard_Boolean enable ) const
2869 MyGraphicDriver->SetGLLightEnabled( MyCView, enable );
2873 Standard_Boolean Visual3d_View::IsGLLightEnabled() const
2875 return MyGraphicDriver->IsGLLightEnabled( MyCView );
2878 Standard_Boolean Visual3d_View::Export (const Standard_CString theFileName,
2879 const Graphic3d_ExportFormat theFormat,
2880 const Graphic3d_SortType theSortType,
2881 const Standard_Real thePrecision,
2882 const Standard_Address theProgressBarFunc,
2883 const Standard_Address theProgressObject) const
2885 Handle(Visual3d_Layer) anUnderLayer = MyViewManager->UnderLayer();
2886 Handle(Visual3d_Layer) anOverLayer = MyViewManager->OverLayer();
2888 Aspect_CLayer2d anOverCLayer;
2889 Aspect_CLayer2d anUnderCLayer;
2890 anOverCLayer.ptrLayer = anUnderCLayer.ptrLayer = NULL;
2892 if (!anOverLayer.IsNull())
2893 anOverCLayer = anOverLayer->CLayer();
2894 if (!anUnderLayer.IsNull())
2895 anUnderCLayer = anUnderLayer->CLayer();
2897 Standard_Integer aWidth, aHeight;
2898 Window()->Size (aWidth, aHeight);
2900 return MyGraphicDriver->Export (theFileName, theFormat, theSortType,
2901 aWidth, aHeight, MyCView, anUnderCLayer, anOverCLayer,
2902 thePrecision, theProgressBarFunc, theProgressObject);
2905 //=======================================================================
2906 //function : AddZLayer
2908 //=======================================================================
2910 void Visual3d_View::AddZLayer (const Standard_Integer theLayerId)
2912 MyGraphicDriver->AddZLayer (MyCView, theLayerId);
2915 //=======================================================================
2916 //function : RemoveZLayer
2918 //=======================================================================
2920 void Visual3d_View::RemoveZLayer (const Standard_Integer theLayerId)
2922 MyGraphicDriver->RemoveZLayer (MyCView, theLayerId);
2925 //=======================================================================
2926 //function : ChangeZLayer
2928 //=======================================================================
2930 void Visual3d_View::ChangeZLayer (const Handle(Graphic3d_Structure)& theStructure,
2931 const Standard_Integer theLayerId)
2933 MyGraphicDriver->ChangeZLayer (
2934 (*(Graphic3d_CStructure*)theStructure->CStructure()), MyCView, theLayerId);