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 under
7 // the terms of the GNU Lesser General Public License 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 //=============================================================================
1758 //function : MinMaxValues
1760 //=============================================================================
1761 void Visual3d_View::MinMaxValues (Standard_Real& theXMin,
1762 Standard_Real& theYMin,
1763 Standard_Real& theZMin,
1764 Standard_Real& theXMax,
1765 Standard_Real& theYMax,
1766 Standard_Real& theZMax,
1767 const Standard_Boolean theToIgnoreInfiniteFlag) const
1769 MinMaxValues (MyDisplayedStructure,
1770 theXMin, theYMin, theZMin,
1771 theXMax, theYMax, theZMax,
1772 theToIgnoreInfiniteFlag);
1775 //=============================================================================
1776 //function : MinMaxValues
1778 //=============================================================================
1779 void Visual3d_View::MinMaxValues (const Graphic3d_MapOfStructure& theSet,
1780 Standard_Real& theXMin,
1781 Standard_Real& theYMin,
1782 Standard_Real& theZMin,
1783 Standard_Real& theXMax,
1784 Standard_Real& theYMax,
1785 Standard_Real& theZMax,
1786 const Standard_Boolean theToIgnoreInfiniteFlag) const
1788 if (theSet.IsEmpty ())
1790 theXMin = RealFirst();
1791 theYMin = RealFirst();
1792 theZMin = RealFirst();
1794 theXMax = RealLast();
1795 theYMax = RealLast();
1796 theZMax = RealLast();
1800 Standard_Real aXm, aYm, aZm, aXM, aYM, aZM;
1801 Graphic3d_MapIteratorOfMapOfStructure anIterator (theSet);
1803 theXMin = RealLast();
1804 theYMin = RealLast();
1805 theZMin = RealLast();
1807 theXMax = RealFirst ();
1808 theYMax = RealFirst ();
1809 theZMax = RealFirst ();
1811 for (anIterator.Initialize (theSet); anIterator.More(); anIterator.Next())
1813 const Handle(Graphic3d_Structure)& aStructure = anIterator.Key();
1815 if (aStructure->IsInfinite() && !theToIgnoreInfiniteFlag)
1817 //XMin, YMin .... ZMax are initialized by means of infinite line data
1818 aStructure->MinMaxValues (aXm, aYm, aZm, aXM, aYM, aZM, Standard_False);
1819 if (aXm != RealFirst() && aXm < theXMin)
1823 if (aYm != RealFirst() && aYm < theYMin)
1827 if (aZm != RealFirst() && aZm < theZMin)
1831 if (aXM != RealLast() && aXM > theXMax)
1835 if (aYM != RealLast() && aYM > theYMax)
1839 if (aZM != RealLast() && aZM > theZMax)
1845 // Only non-empty and non-infinite structures
1846 // are taken into account for calculation of MinMax
1847 if ((!aStructure->IsInfinite() || theToIgnoreInfiniteFlag) && !aStructure->IsEmpty())
1849 aStructure->MinMaxValues (aXm, aYm, aZm, aXM, aYM, aZM, theToIgnoreInfiniteFlag);
1851 /* ABD 29/10/04 Transform Persistence of Presentation( pan, zoom, rotate ) */
1852 //"FitAll" operation ignores object with transform persitence parameter
1853 if(aStructure->TransformPersistenceMode() == Graphic3d_TMF_None )
1855 theXMin = Min (aXm, theXMin);
1856 theYMin = Min (aYm, theYMin);
1857 theZMin = Min (aZm, theZMin);
1858 theXMax = Max (aXM, theXMax);
1859 theYMax = Max (aYM, theYMax);
1860 theZMax = Max (aZM, theZMax);
1865 // The following cases are relevant
1866 // For exemple if all structures are empty or infinite
1867 if (theXMax < theXMin) { aXm = theXMin; theXMin = theXMax; theXMax = aXm; }
1868 if (theYMax < theYMin) { aYm = theYMin; theYMin = theYMax; theYMax = aYm; }
1869 if (theZMax < theZMin) { aZm = theZMin; theZMin = theZMax; theZMax = aZm; }
1873 //=============================================================================
1874 //function : MinMaxValues
1876 //=============================================================================
1877 void Visual3d_View::MinMaxValues (Standard_Real& theXMin,
1878 Standard_Real& theYMin,
1879 Standard_Real& theXMax,
1880 Standard_Real& theYMax,
1881 const Standard_Boolean theToIgnoreInfiniteFlag) const
1883 MinMaxValues (MyDisplayedStructure,
1886 theToIgnoreInfiniteFlag);
1889 //=============================================================================
1890 //function : MinMaxValues
1892 //=============================================================================
1893 void Visual3d_View::MinMaxValues (const Graphic3d_MapOfStructure& theSet,
1894 Standard_Real& theXMin,
1895 Standard_Real& theYMin,
1896 Standard_Real& theXMax,
1897 Standard_Real& theYMax,
1898 const Standard_Boolean theToIgnoreInfiniteFlag) const
1900 Standard_Real aXm, aYm, aZm, aXM, aYM, aZM;
1901 Standard_Real aXp, aYp, aZp;
1903 MinMaxValues (theSet, aXm, aYm, aZm, aXM, aYM, aZM, theToIgnoreInfiniteFlag);
1905 Projects (aXm, aYm, aZm, aXp, aYp, aZp);
1909 Projects (aXM, aYM, aZM, aXp, aYp, aZp);
1913 if (theXMax < theXMin) { aXp = theXMax; theXMax = theXMin; theXMin = aXp; }
1914 if (theYMax < theYMin) { aYp = theYMax; theYMax = theYMin; theYMin = aYp; }
1917 Standard_Integer Visual3d_View::NumberOfDisplayedStructures () const {
1919 Standard_Integer Result = MyDisplayedStructure.Extent ();
1925 //=======================================================================
1926 //function : Projects
1928 //=======================================================================
1929 void Visual3d_View::Projects (const Standard_Real theX,
1930 const Standard_Real theY,
1931 const Standard_Real theZ,
1932 Standard_Real& thePX,
1933 Standard_Real& thePY,
1934 Standard_Real& thePZ) const
1936 const Handle(Graphic3d_Camera)& aCamera = MyCView.Context.Camera;
1938 gp_XYZ aViewSpaceDimensions = aCamera->ViewDimensions();
1939 Standard_Real aXSize = aViewSpaceDimensions.X();
1940 Standard_Real aYSize = aViewSpaceDimensions.Y();
1941 Standard_Real aZSize = aViewSpaceDimensions.Z();
1943 gp_Pnt aPoint = aCamera->Project (gp_Pnt (theX, theY, theZ));
1945 // NDC [-1, 1] --> PROJ [ -size / 2, +size / 2 ]
1946 thePX = aPoint.X() * aXSize * 0.5;
1947 thePY = aPoint.Y() * aYSize * 0.5;
1948 thePZ = aPoint.Z() * aZSize * 0.5;
1951 Standard_Integer Visual3d_View::Identification () const {
1953 return (Standard_Integer (MyCView.ViewId));
1958 Standard_Boolean Visual3d_View::ZBufferIsActivated () const {
1960 if (IsDeleted ()) return (Standard_False);
1962 if ((! IsDefined ()) || (! IsActive ())) return (Standard_False);
1964 // -1 => not forced by the programmer => depends on the type of visualisation
1965 // 0 ou 1 => forced by the programmer
1967 if (MyCView.Context.ZBufferActivity == -1)
1968 if (MyContext.Visualization () == Visual3d_TOV_SHADING)
1969 return (Standard_True);
1971 return (Standard_False);
1973 if (MyCView.Context.ZBufferActivity)
1974 return (Standard_True);
1976 return (Standard_False);
1980 void Visual3d_View::SetTransparency (const Standard_Boolean AnActivity) {
1982 if (IsDeleted ()) return;
1984 if ((! IsDefined ()) || (! IsActive ())) return;
1986 MyGraphicDriver->Transparency (MyCView, AnActivity);
1990 void Visual3d_View::SetZBufferActivity (const Standard_Integer AnActivity) {
1992 if (MyCView.Context.ZBufferActivity == AnActivity) return;
1994 if (IsDeleted ()) return;
1996 if ((! IsDefined ()) || (! IsActive ())) return;
1998 MyCView.Context.ZBufferActivity = AnActivity;
1999 MyGraphicDriver->SetVisualisation (MyCView);
2003 void Visual3d_View::UpdateView () {
2005 MyCView.Context.Aliasing = (MyContext.AliasingIsOn () ? 1:0);
2006 MyCView.Context.BackZClipping =
2007 (MyContext.BackZClippingIsOn () ? 1:0);
2008 MyCView.Context.FrontZClipping =
2009 (MyContext.FrontZClippingIsOn() ? 1:0);
2010 MyCView.Context.DepthCueing =
2011 (MyContext.DepthCueingIsOn () ? 1:0);
2013 MyCView.Context.ZClipFrontPlane =
2014 float (MyContext.ZClippingFrontPlane ());
2015 MyCView.Context.ZClipBackPlane =
2016 float (MyContext.ZClippingBackPlane ());
2017 MyCView.Context.DepthFrontPlane =
2018 float (MyContext.DepthCueingFrontPlane ());
2019 MyCView.Context.DepthBackPlane =
2020 float (MyContext.DepthCueingBackPlane ());
2022 MyCView.Context.Model = int (MyContext.Model ());
2023 MyCView.Context.Visualization = int (MyContext.Visualization ());
2025 MyCView.Context.TextureEnv = MyContext.TextureEnv();
2026 MyCView.Context.SurfaceDetail = MyContext.SurfaceDetail();
2030 void Visual3d_View::Compute () {
2033 Standard_Integer Length = MyCOMPUTEDSequence.Length ();
2034 for (i=1; i<=Length; i++)
2035 (MyCOMPUTEDSequence.Value (i))->SetHLRValidation (Standard_False);
2037 if (!ComputedMode())
2043 * Force HLRValidation to False on all structures
2044 * calculated in the view.
2047 if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ()) {
2048 cout << "In Visual3d_View::Compute, ";
2049 cout << "TOCOMPUTE " << MyTOCOMPUTESequence.Length ()
2050 << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
2056 * Change of orientation or of projection type =>
2057 * Remove structures that were calculated for the
2058 * previous orientation.
2059 * Recalculation of new structures.
2061 Graphic3d_MapIteratorOfMapOfStructure S1Iterator (MyDisplayedStructure);
2062 Visual3d_TypeOfAnswer Answer;
2064 i = MyDisplayedStructure.Extent ();
2066 Graphic3d_SequenceOfStructure FooSequence;
2068 while (S1Iterator.More ()) {
2069 Answer = AcceptDisplay (S1Iterator.Key ());
2070 // If the structure was calculated, it is recalculated.
2071 if (Answer == Visual3d_TOA_COMPUTE) {
2073 cout << "AcceptDisplay ("
2074 << (S1Iterator.Key ())->Identification ()
2075 << ") == Visual3d_TOA_COMPUTE;\n";
2078 //Display (S1Iterator.Key (), Aspect_TOU_WAIT);
2079 FooSequence.Append (S1Iterator.Key ());
2082 // S1Iterator.Next () is located on the next structure
2086 Length = FooSequence.Length ();
2087 // All stored structures are displayed
2088 for (i=1; i<=Length; i++)
2089 Display (FooSequence.Value (i), Aspect_TOU_WAIT);
2090 if (Length != 0) FooSequence.Clear ();
2094 void Visual3d_View::ReCompute (const Handle(Graphic3d_Structure)& AStructure) {
2095 if (!ComputedMode()) return;
2097 if (IsDeleted ()) return;
2099 if ((! IsDefined ()) || (! IsActive ())) return;
2101 if (! MyWindow->IsMapped ()) return;
2103 if (! AStructure->IsDisplayed ()) return;
2105 Visual3d_TypeOfAnswer Answer;
2107 Answer = AcceptDisplay (AStructure);
2109 if (Answer == Visual3d_TOA_COMPUTE) {
2110 Standard_Integer Index = IsComputed (AStructure);
2113 cout << "Structure " << AStructure->Identification ()
2114 << " is not calculated in the view "
2115 << Identification () << "\n";
2120 Standard_Integer OldStructId, NewStructId;
2122 MyCOMPUTEDSequence.Value (Index)->Identification ();
2124 Standard_Integer StructId = AStructure->Identification ();
2125 cout << "Structure " << StructId
2126 << " calculated, in the view "
2127 << Identification () << ", by the structure "
2128 << OldStructId << " is recalculated.\n";
2132 // Compute + Validation
2134 Handle(Graphic3d_Structure) TheStructure = AStructure->Compute (this);
2136 Handle(Graphic3d_Structure) TheStructure;
2137 TColStd_Array2OfReal ATrsf (0, 3, 0, 3);
2138 AStructure->Transform (ATrsf);
2140 TColStd_Array2OfReal Ident (0, 3, 0, 3);
2141 Standard_Integer ii, jj;
2142 for (ii=0; ii<=3; ii++)
2143 for (jj=0; jj<=3; jj++)
2144 Ident (ii, jj) = (ii == jj ? 1.0 : 0.0);
2145 TheStructure = MyCOMPUTEDSequence.Value (Index);
2146 TheStructure->SetTransform (Ident, Graphic3d_TOC_REPLACE);
2147 if (AStructure->IsTransformed ()) {
2148 AStructure->Compute (this, ATrsf, TheStructure);
2151 AStructure->Compute (this, TheStructure);
2155 if (AStructure->IsTransformed ()) {
2156 TheStructure = AStructure->Compute (this, ATrsf);
2159 TheStructure = AStructure->Compute (this);
2163 TheStructure->SetHLRValidation (Standard_True);
2165 // Return type of visualisation of the view
2166 Visual3d_TypeOfVisualization ViewType = MyContext.Visualization ();
2168 // Of which type will be the computed ?
2169 Standard_Boolean ComputeWireframe = ((ViewType == Visual3d_TOV_WIREFRAME) &&
2170 (AStructure->ComputeVisual () != Graphic3d_TOS_SHADING));
2172 Standard_Boolean ComputeShading = ((ViewType == Visual3d_TOV_SHADING) &&
2173 (AStructure->ComputeVisual () != Graphic3d_TOS_WIREFRAME));
2175 if (ComputeWireframe)
2176 TheStructure->SetVisual (Graphic3d_TOS_WIREFRAME);
2178 TheStructure->SetVisual (Graphic3d_TOS_SHADING);
2180 if (AStructure->IsHighlighted ()) {
2181 TheStructure->SetHighlightColor
2182 (AStructure->HighlightColor ());
2183 TheStructure->GraphicHighlight (Aspect_TOHM_COLOR);
2187 // Find structure <AStructure>
2188 // in the sequence of structures to be calculated.
2189 NewStructId = TheStructure->Identification ();
2191 // The previous calculation is removed and the new one is dislayed
2192 MyGraphicDriver->EraseStructure (
2194 *(Graphic3d_CStructure *)MyCOMPUTEDSequence.Value (Index)->CStructure ());
2195 MyGraphicDriver->DisplayStructure (
2197 *(Graphic3d_CStructure *)TheStructure->CStructure (),
2198 int (AStructure->DisplayPriority ())
2202 if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ()) {
2203 cout << "In Visual3d_View::ReCompute, ";
2204 cout << "TOCOMPUTE " << MyTOCOMPUTESequence.Length ()
2205 << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
2210 // hlhsr and the new associated compute are added
2211 MyTOCOMPUTESequence.Append (AStructure);
2212 MyCOMPUTEDSequence.Append (TheStructure);
2215 if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ())
2216 cout << "\tTOCOMPUTE " << MyTOCOMPUTESequence.Length ()
2217 << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
2221 // hlhsr and the new associated compute are removed
2223 MyTOCOMPUTESequence.Remove (Index);
2224 MyCOMPUTEDSequence.Remove (Index);
2227 if (MyTOCOMPUTESequence.Length () != MyCOMPUTEDSequence.Length ())
2228 cout << "\tTOCOMPUTE " << MyTOCOMPUTESequence.Length ()
2229 << " != COMPUTED " << MyCOMPUTEDSequence.Length ()
2237 const Handle(Graphic3d_GraphicDriver)& Visual3d_View::GraphicDriver () const {
2239 return MyGraphicDriver;
2243 void Visual3d_View::Plot (const Handle(Graphic3d_Plotter)& thePlotter) const
2245 for (Graphic3d_MapIteratorOfMapOfStructure S1Iterator (MyDisplayedStructure); S1Iterator.More(); S1Iterator.Next())
2247 Standard_Integer Index = IsComputed (S1Iterator.Key ());
2248 // displayed structure is plotted as if it was not calculated
2250 (S1Iterator.Key ())->Plot (thePlotter);
2252 (MyCOMPUTEDSequence.Value (Index))->Plot (thePlotter);
2256 Standard_Integer Visual3d_View::HaveTheSameOwner (const Handle(Graphic3d_Structure)& AStructure) const {
2258 Standard_Integer Result = 0;
2259 Standard_Integer Length = MyTOCOMPUTESequence.Length ();
2261 // Find in the sequence of already calculated structures
2262 // 1/ Structure with the same Owner as <AStructure>
2263 // 2/ Which is not <AStructure>
2264 // 3/ COMPUTED which of is valid
2265 for (Standard_Integer i=1; i<=Length && Result==0; i++)
2266 if ((MyTOCOMPUTESequence.Value (i)->Owner () == AStructure->Owner ())
2267 && (MyTOCOMPUTESequence.Value (i)->Identification () !=
2268 AStructure->Identification ())
2269 && (MyCOMPUTEDSequence.Value (i)->HLRValidation ())) Result = i;
2275 Standard_Address Visual3d_View::CView () const {
2277 return Standard_Address (&MyCView);
2282 // Triedron methods : the Triedron is a non-zoomable object.
2284 void Visual3d_View::ZBufferTriedronSetup(const Quantity_NameOfColor XColor,
2285 const Quantity_NameOfColor YColor,
2286 const Quantity_NameOfColor ZColor,
2287 const Standard_Real SizeRatio,
2288 const Standard_Real AxisDiametr,
2289 const Standard_Integer NbFacettes) {
2290 MyGraphicDriver->ZBufferTriedronSetup(XColor, YColor, ZColor,
2291 SizeRatio, AxisDiametr, NbFacettes);
2296 void Visual3d_View::TriedronDisplay (const Aspect_TypeOfTriedronPosition APosition,
2297 const Quantity_NameOfColor AColor, const Standard_Real AScale, const Standard_Boolean AsWireframe ) {
2299 MyGraphicDriver->TriedronDisplay (MyCView,APosition, AColor, AScale, AsWireframe);
2303 void Visual3d_View::TriedronErase () {
2305 MyGraphicDriver->TriedronErase (MyCView);
2310 void Visual3d_View::TriedronEcho (const Aspect_TypeOfTriedronEcho AType ) {
2312 MyGraphicDriver->TriedronEcho (MyCView,AType);
2316 static Standard_Boolean checkFloat(const Standard_Real value)
2318 return value > -FLT_MAX && value < FLT_MAX;
2321 static void SetMinMaxValuesCallback(Visual3d_View* theView)
2323 Standard_Real xmin, ymin, zmin, xmax, ymax, zmax;
2324 theView->MinMaxValues(xmin, ymin, zmin, xmax, ymax, zmax);
2326 if (checkFloat(xmin) && checkFloat(ymin) && checkFloat(zmin) &&
2327 checkFloat(xmax) && checkFloat(ymax) && checkFloat(zmax))
2329 Handle(Graphic3d_GraphicDriver) driver = Handle(Graphic3d_GraphicDriver)::DownCast(theView->GraphicDriver());
2330 driver->GraduatedTrihedronMinMaxValues((Standard_ShortReal)xmin, (Standard_ShortReal)ymin, (Standard_ShortReal)zmin,
2331 (Standard_ShortReal)xmax, (Standard_ShortReal)ymax, (Standard_ShortReal)zmax);
2335 Standard_Boolean Visual3d_View::GetGraduatedTrihedron
2336 (/* Names of axes */
2337 TCollection_ExtendedString& xname,
2338 TCollection_ExtendedString& yname,
2339 TCollection_ExtendedString& zname,
2341 Standard_Boolean& xdrawname,
2342 Standard_Boolean& ydrawname,
2343 Standard_Boolean& zdrawname,
2345 Standard_Boolean& xdrawvalues,
2346 Standard_Boolean& ydrawvalues,
2347 Standard_Boolean& zdrawvalues,
2349 Standard_Boolean& drawgrid,
2351 Standard_Boolean& drawaxes,
2352 /* Number of splits along axes */
2353 Standard_Integer& nbx,
2354 Standard_Integer& nby,
2355 Standard_Integer& nbz,
2356 /* Offset for drawing values */
2357 Standard_Integer& xoffset,
2358 Standard_Integer& yoffset,
2359 Standard_Integer& zoffset,
2360 /* Offset for drawing names of axes */
2361 Standard_Integer& xaxisoffset,
2362 Standard_Integer& yaxisoffset,
2363 Standard_Integer& zaxisoffset,
2364 /* Draw tickmarks */
2365 Standard_Boolean& xdrawtickmarks,
2366 Standard_Boolean& ydrawtickmarks,
2367 Standard_Boolean& zdrawtickmarks,
2368 /* Length of tickmarks */
2369 Standard_Integer& xtickmarklength,
2370 Standard_Integer& ytickmarklength,
2371 Standard_Integer& ztickmarklength,
2373 Quantity_Color& gridcolor,
2374 /* Colors of axis names */
2375 Quantity_Color& xnamecolor,
2376 Quantity_Color& ynamecolor,
2377 Quantity_Color& znamecolor,
2378 /* Colors of axis and values */
2379 Quantity_Color& xcolor,
2380 Quantity_Color& ycolor,
2381 Quantity_Color& zcolor,
2382 /* Name of font for names of axes */
2383 TCollection_AsciiString& fontOfNames,
2384 /* Style of names of axes */
2385 Font_FontAspect& styleOfNames,
2386 /* Size of names of axes */
2387 Standard_Integer& sizeOfNames,
2388 /* Name of font for values */
2389 TCollection_AsciiString& fontOfValues,
2390 /* Style of values */
2391 Font_FontAspect& styleOfValues,
2392 /* Size of values */
2393 Standard_Integer& sizeOfValues) const
2395 if (!MyGTrihedron.ptrVisual3dView)
2396 return Standard_False;
2399 xname = MyGTrihedron.xname;
2400 yname = MyGTrihedron.yname;
2401 zname = MyGTrihedron.zname;
2403 xdrawname = MyGTrihedron.xdrawname;
2404 ydrawname = MyGTrihedron.ydrawname;
2405 zdrawname = MyGTrihedron.zdrawname;
2407 xdrawvalues = MyGTrihedron.xdrawvalues;
2408 ydrawvalues = MyGTrihedron.ydrawvalues;
2409 zdrawvalues = MyGTrihedron.zdrawvalues;
2411 drawgrid = MyGTrihedron.drawgrid;
2413 drawaxes = MyGTrihedron.drawaxes;
2414 /* Number of splits along axes */
2415 nbx = MyGTrihedron.nbx;
2416 nby = MyGTrihedron.nby;
2417 nbz = MyGTrihedron.nbz;
2418 /* Offset for drawing values */
2419 xoffset = MyGTrihedron.xoffset;
2420 yoffset = MyGTrihedron.yoffset;
2421 zoffset = MyGTrihedron.zoffset;
2422 /* Offset for drawing names of axes */
2423 xaxisoffset = MyGTrihedron.xaxisoffset;
2424 yaxisoffset = MyGTrihedron.yaxisoffset;
2425 zaxisoffset = MyGTrihedron.zaxisoffset;
2426 /* Draw tickmarks */
2427 xdrawtickmarks = MyGTrihedron.xdrawtickmarks;
2428 ydrawtickmarks = MyGTrihedron.ydrawtickmarks;
2429 zdrawtickmarks = MyGTrihedron.zdrawtickmarks;
2430 /* Length of tickmarks */
2431 xtickmarklength = MyGTrihedron.xtickmarklength;
2432 ytickmarklength = MyGTrihedron.ytickmarklength;
2433 ztickmarklength = MyGTrihedron.ztickmarklength;
2435 gridcolor = MyGTrihedron.gridcolor;
2436 /* Colors of axis names */
2437 xnamecolor = MyGTrihedron.xnamecolor;
2438 ynamecolor = MyGTrihedron.ynamecolor;
2439 znamecolor = MyGTrihedron.znamecolor;
2440 /* Colors of axis and values */
2441 xcolor = MyGTrihedron.xcolor;
2442 ycolor = MyGTrihedron.ycolor;
2443 zcolor = MyGTrihedron.zcolor;
2444 /* Name of font for names of axes */
2445 fontOfNames = MyGTrihedron.fontOfNames;
2446 /* Style of names of axes */
2447 styleOfNames = MyGTrihedron.styleOfNames;
2448 /* Size of names of axes */
2449 sizeOfNames = MyGTrihedron.sizeOfNames;
2450 /* Name of font for values */
2451 fontOfValues = MyGTrihedron.fontOfValues;
2452 /* Style of values */
2453 styleOfValues = MyGTrihedron.styleOfValues;
2454 /* Size of values */
2455 sizeOfValues = MyGTrihedron.sizeOfValues;
2457 return Standard_True;
2460 void Visual3d_View::GraduatedTrihedronDisplay
2461 (/* Names of axes */
2462 const TCollection_ExtendedString &xname,
2463 const TCollection_ExtendedString &yname,
2464 const TCollection_ExtendedString &zname,
2466 const Standard_Boolean xdrawname,
2467 const Standard_Boolean ydrawname,
2468 const Standard_Boolean zdrawname,
2470 const Standard_Boolean xdrawvalues,
2471 const Standard_Boolean ydrawvalues,
2472 const Standard_Boolean zdrawvalues,
2474 const Standard_Boolean drawgrid,
2476 const Standard_Boolean drawaxes,
2477 /* Number of splits along axes */
2478 const Standard_Integer nbx,
2479 const Standard_Integer nby,
2480 const Standard_Integer nbz,
2481 /* Offset for drawing values */
2482 const Standard_Integer xoffset,
2483 const Standard_Integer yoffset,
2484 const Standard_Integer zoffset,
2485 /* Offset for drawing names of axes */
2486 const Standard_Integer xaxisoffset,
2487 const Standard_Integer yaxisoffset,
2488 const Standard_Integer zaxisoffset,
2489 /* Draw tickmarks */
2490 const Standard_Boolean xdrawtickmarks,
2491 const Standard_Boolean ydrawtickmarks,
2492 const Standard_Boolean zdrawtickmarks,
2493 /* Length of tickmarks */
2494 const Standard_Integer xtickmarklength,
2495 const Standard_Integer ytickmarklength,
2496 const Standard_Integer ztickmarklength,
2498 const Quantity_Color& gridcolor,
2499 /* Colors of axis names */
2500 const Quantity_Color& xnamecolor,
2501 const Quantity_Color& ynamecolor,
2502 const Quantity_Color& znamecolor,
2503 /* Colors of axis and values */
2504 const Quantity_Color& xcolor,
2505 const Quantity_Color& ycolor,
2506 const Quantity_Color& zcolor,
2507 /* Name of font for names of axes */
2508 const TCollection_AsciiString &fontOfNames,
2509 /* Style of names of axes */
2510 const Font_FontAspect styleOfNames,
2511 /* Size of names of axes */
2512 const Standard_Integer sizeOfNames,
2513 /* Name of font for values */
2514 const TCollection_AsciiString &fontOfValues,
2515 /* Style of values */
2516 const Font_FontAspect styleOfValues,
2517 /* Size of values */
2518 const Standard_Integer sizeOfValues)
2521 MyGTrihedron.xname = xname;
2522 MyGTrihedron.yname = yname;
2523 MyGTrihedron.zname = zname;
2525 MyGTrihedron.xdrawname = xdrawname;
2526 MyGTrihedron.ydrawname = ydrawname;
2527 MyGTrihedron.zdrawname = zdrawname;
2529 MyGTrihedron.xdrawvalues = xdrawvalues;
2530 MyGTrihedron.ydrawvalues = ydrawvalues;
2531 MyGTrihedron.zdrawvalues = zdrawvalues;
2533 MyGTrihedron.drawgrid = drawgrid;
2535 MyGTrihedron.drawaxes = drawaxes;
2536 /* Number of splits along axes */
2537 MyGTrihedron.nbx = nbx;
2538 MyGTrihedron.nby = nby;
2539 MyGTrihedron.nbz = nbz;
2540 /* Offset for drawing values */
2541 MyGTrihedron.xoffset = xoffset;
2542 MyGTrihedron.yoffset = yoffset;
2543 MyGTrihedron.zoffset = zoffset;
2544 /* Offset for drawing names of axes */
2545 MyGTrihedron.xaxisoffset = xaxisoffset;
2546 MyGTrihedron.yaxisoffset = yaxisoffset;
2547 MyGTrihedron.zaxisoffset = zaxisoffset;
2548 /* Draw tickmarks */
2549 MyGTrihedron.xdrawtickmarks = xdrawtickmarks;
2550 MyGTrihedron.ydrawtickmarks = ydrawtickmarks;
2551 MyGTrihedron.zdrawtickmarks = zdrawtickmarks;
2552 /* Length of tickmarks */
2553 MyGTrihedron.xtickmarklength = xtickmarklength;
2554 MyGTrihedron.ytickmarklength = ytickmarklength;
2555 MyGTrihedron.ztickmarklength = ztickmarklength;
2557 MyGTrihedron.gridcolor = gridcolor;
2558 /* Colors of axis names */
2559 MyGTrihedron.xnamecolor = xnamecolor;
2560 MyGTrihedron.ynamecolor = ynamecolor;
2561 MyGTrihedron.znamecolor = znamecolor;
2562 /* Colors of axis and values */
2563 MyGTrihedron.xcolor = xcolor;
2564 MyGTrihedron.ycolor = ycolor;
2565 MyGTrihedron.zcolor = zcolor;
2566 /* Name of font for names of axes */
2567 MyGTrihedron.fontOfNames = fontOfNames;
2568 /* Style of names of axes */
2569 MyGTrihedron.styleOfNames = styleOfNames;
2570 /* Size of names of axes */
2571 MyGTrihedron.sizeOfNames = sizeOfNames;
2572 /* Name of font for values */
2573 MyGTrihedron.fontOfValues = fontOfValues;
2574 /* Style of values */
2575 MyGTrihedron.styleOfValues = styleOfValues;
2576 /* Size of values */
2577 MyGTrihedron.sizeOfValues = sizeOfValues;
2579 MyGTrihedron.ptrVisual3dView = this;
2580 MyGTrihedron.cbCubicAxes = SetMinMaxValuesCallback;
2581 MyGraphicDriver->GraduatedTrihedronDisplay(MyCView,MyGTrihedron);
2584 void Visual3d_View::GraduatedTrihedronErase()
2586 MyGTrihedron.ptrVisual3dView = NULL;
2587 MyGraphicDriver->GraduatedTrihedronErase(MyCView);
2590 const Handle(Visual3d_Layer)& Visual3d_View::UnderLayer () const {
2592 return (MyViewManager->UnderLayer ());
2596 const Handle(Visual3d_Layer)& Visual3d_View::OverLayer () const {
2598 return (MyViewManager->OverLayer ());
2602 Standard_Integer Visual3d_View::LightLimit() const {
2604 Standard_Integer maxlight = MyGraphicDriver->InquireLightLimit ();
2605 // printf(" $$$ Visual3d_View::LightLimit() is %d\n",maxlight);
2609 Standard_Integer Visual3d_View::PlaneLimit() const {
2611 Standard_Integer maxplane = MyGraphicDriver->InquirePlaneLimit ();
2612 // printf(" $$$ Visual3d_View::PlaneLimit() is %d\n",maxplane);
2616 Handle(Visual3d_ViewManager) Visual3d_View::ViewManager() const
2618 return MyPtrViewManager;
2621 void Visual3d_View :: SetComputedMode ( const Standard_Boolean aMode )
2623 if ((aMode && ComputedModeIsActive) ||
2624 (!aMode && !ComputedModeIsActive))
2629 Graphic3d_MapIteratorOfMapOfStructure S1Iterator ( MyDisplayedStructure );
2630 Visual3d_TypeOfAnswer Answer;
2631 Standard_Integer StructId;
2632 Standard_Integer i = MyDisplayedStructure.Extent ();
2633 ComputedModeIsActive = aMode;
2634 if (!ComputedModeIsActive) {
2636 while ( S1Iterator.More () ) {
2638 Answer = AcceptDisplay ( S1Iterator.Key () );
2640 if ( Answer == Visual3d_TOA_COMPUTE ) {
2642 Standard_Integer Index = IsComputed ( S1Iterator.Key () );
2646 StructId = MyCOMPUTEDSequence.Value ( Index ) -> Identification ();
2648 MyGraphicDriver -> EraseStructure (
2650 *( Graphic3d_CStructure* )
2651 MyCOMPUTEDSequence.Value ( Index ) -> CStructure ()
2653 MyGraphicDriver -> DisplayStructure (
2655 *( Graphic3d_CStructure* )
2656 S1Iterator.Key () -> CStructure (),
2657 int ( S1Iterator.Key () -> DisplayPriority () )
2659 } // end if ( Index != 0 ) . . .
2661 } // end if ( Answer . . . )
2669 while ( S1Iterator.More () ) {
2671 Answer = AcceptDisplay ( S1Iterator.Key () );
2673 if ( Answer == Visual3d_TOA_COMPUTE ) {
2675 Standard_Integer Index = IsComputed ( S1Iterator.Key () );
2679 StructId = MyCOMPUTEDSequence.Value ( Index ) -> Identification ();
2681 MyGraphicDriver -> EraseStructure (
2683 *( Graphic3d_CStructure* )
2684 S1Iterator.Key () -> CStructure ()
2686 MyGraphicDriver -> DisplayStructure (
2688 *( Graphic3d_CStructure* )
2689 MyCOMPUTEDSequence.Value ( Index ) -> CStructure (),
2690 int ( S1Iterator.Key () -> DisplayPriority () )
2693 Display ( S1Iterator.Key (), Aspect_TOU_WAIT );
2695 if ( S1Iterator.Key () -> IsHighlighted () ) {
2697 if ( !MyCOMPUTEDSequence.Value ( Index ) -> IsHighlighted () ) {
2699 MyCOMPUTEDSequence.Value ( Index ) -> SetHighlightColor (
2700 S1Iterator.Key () ->
2703 MyCOMPUTEDSequence.Value ( Index ) -> GraphicHighlight (
2712 Handle( Graphic3d_Structure ) AStructure = S1Iterator.Key ();
2714 Handle( Graphic3d_Structure ) TheStructure = AStructure -> Compute ( this );
2716 Handle( Graphic3d_Structure ) TheStructure;
2717 TColStd_Array2OfReal ATrsf ( 0, 3, 0, 3 );
2719 AStructure -> Transform ( ATrsf );
2723 TColStd_Array2OfReal Ident ( 0, 3, 0, 3 );
2724 Standard_Integer ii, jj;
2726 for ( ii = 0; ii <= 3; ++ii )
2728 for ( jj = 0; jj <= 3; ++jj )
2730 Ident ( ii, jj ) = ( ii == jj ? 1.0 : 0.0 );
2732 TheStructure = MyCOMPUTEDSequence.Value ( Index );
2734 TheStructure -> SetTransform ( Ident, Graphic3d_TOC_REPLACE );
2736 if ( AStructure->IsTransformed () )
2738 AStructure -> Compute ( this, ATrsf, TheStructure );
2742 AStructure -> Compute ( this, TheStructure );
2746 if ( AStructure -> IsTransformed () )
2748 TheStructure = AStructure -> Compute ( this, ATrsf );
2752 TheStructure = AStructure -> Compute ( this );
2756 TheStructure -> SetHLRValidation ( Standard_True );
2758 Visual3d_TypeOfVisualization ViewType = MyContext.Visualization ();
2760 Standard_Boolean ComputeWireframe =
2761 ( ( ViewType == Visual3d_TOV_WIREFRAME ) &&
2762 ( S1Iterator.Key () -> ComputeVisual () != Graphic3d_TOS_SHADING )
2765 Standard_Boolean ComputeShading =
2766 ( ( ViewType == Visual3d_TOV_SHADING ) &&
2767 ( S1Iterator.Key () -> ComputeVisual () != Graphic3d_TOS_WIREFRAME )
2770 if ( ComputeWireframe ) TheStructure -> SetVisual ( Graphic3d_TOS_WIREFRAME );
2771 if ( ComputeShading ) TheStructure -> SetVisual ( Graphic3d_TOS_SHADING );
2773 if ( S1Iterator.Key () -> IsHighlighted () ) {
2775 TheStructure -> SetHighlightColor (
2776 S1Iterator.Key () -> HighlightColor ()
2778 TheStructure -> GraphicHighlight ( Aspect_TOHM_COLOR );
2782 Standard_Integer Result = 0;
2783 Standard_Integer Length = MyTOCOMPUTESequence.Length ();
2784 StructId = S1Iterator.Key () -> Identification ();
2786 for ( i = 1; i <= Length && Result == 0; ++i )
2788 if ( MyTOCOMPUTESequence.Value ( i ) -> Identification () == StructId )
2794 MyCOMPUTEDSequence.ChangeValue ( Result ) = TheStructure;
2798 MyTOCOMPUTESequence.Append ( S1Iterator.Key () );
2799 MyCOMPUTEDSequence.Append ( TheStructure );
2803 MyGraphicDriver -> EraseStructure (
2805 *( Graphic3d_CStructure* )
2806 S1Iterator.Key () -> CStructure ()
2808 MyGraphicDriver -> DisplayStructure (
2810 *( Graphic3d_CStructure* )TheStructure -> CStructure (),
2811 int ( S1Iterator.Key () -> DisplayPriority () )
2821 if ( MyViewManager -> UpdateMode () == Aspect_TOU_ASAP ) Update ();
2825 } // end Visual3d_View :: SetComputedMode
2827 Standard_Boolean Visual3d_View :: ComputedMode () const {
2829 return ComputedModeIsActive;
2831 } // end Visual3d_View :: ComputedMode
2833 void Visual3d_View :: SetBackFacingModel (
2834 const Visual3d_TypeOfBackfacingModel aModel
2839 case Visual3d_TOBM_AUTOMATIC:
2840 MyCView.Backfacing = 0;
2843 case Visual3d_TOBM_FORCE:
2844 MyCView.Backfacing = 1;
2847 case Visual3d_TOBM_DISABLE:
2848 MyCView.Backfacing = -1;
2853 MyGraphicDriver -> SetBackFacingModel ( MyCView );
2855 } // end Visual3d_View :: SetBackFacingModel
2857 Visual3d_TypeOfBackfacingModel Visual3d_View :: BackFacingModel () const {
2859 switch ( MyCView.Backfacing ) {
2862 return Visual3d_TOBM_AUTOMATIC;
2865 return Visual3d_TOBM_FORCE;
2869 return Visual3d_TOBM_DISABLE;
2871 } // end Visual3d_View :: BackFacingModel
2873 void Visual3d_View::EnableDepthTest( const Standard_Boolean enable ) const
2875 MyGraphicDriver->SetDepthTestEnabled( MyCView, enable );
2878 Standard_Boolean Visual3d_View::IsDepthTestEnabled() const
2880 return MyGraphicDriver->IsDepthTestEnabled( MyCView );
2883 void Visual3d_View::ReadDepths(const Standard_Integer x,
2884 const Standard_Integer y,
2885 const Standard_Integer width,
2886 const Standard_Integer height,
2887 const Standard_Address buffer) const
2889 MyGraphicDriver->ReadDepths( MyCView, x, y, width, height, buffer );
2892 Graphic3d_PtrFrameBuffer Visual3d_View::FBOCreate(const Standard_Integer theWidth,
2893 const Standard_Integer theHeight)
2895 return MyGraphicDriver->FBOCreate( MyCView, theWidth, theHeight );
2898 void Visual3d_View::FBORelease(Graphic3d_PtrFrameBuffer& theFBOPtr)
2900 MyGraphicDriver->FBORelease( MyCView, theFBOPtr );
2903 void Visual3d_View::FBOGetDimensions(const Graphic3d_PtrFrameBuffer theFBOPtr,
2904 Standard_Integer& theWidth, Standard_Integer& theHeight,
2905 Standard_Integer& theWidthMax, Standard_Integer& theHeightMax)
2907 MyGraphicDriver->FBOGetDimensions( MyCView, theFBOPtr,
2908 theWidth, theHeight,
2909 theWidthMax, theHeightMax );
2912 void Visual3d_View::FBOChangeViewport(Graphic3d_PtrFrameBuffer& theFBOPtr,
2913 const Standard_Integer theWidth, const Standard_Integer theHeight)
2915 MyGraphicDriver->FBOChangeViewport( MyCView, theFBOPtr,
2916 theWidth, theHeight );
2919 Standard_Boolean Visual3d_View::BufferDump (Image_PixMap& theImage,
2920 const Graphic3d_BufferType& theBufferType)
2922 return MyGraphicDriver->BufferDump (MyCView, theImage, theBufferType);
2925 void Visual3d_View::EnableGLLight( const Standard_Boolean enable ) const
2927 MyGraphicDriver->SetGLLightEnabled( MyCView, enable );
2931 Standard_Boolean Visual3d_View::IsGLLightEnabled() const
2933 return MyGraphicDriver->IsGLLightEnabled( MyCView );
2936 Standard_Boolean Visual3d_View::Export (const Standard_CString theFileName,
2937 const Graphic3d_ExportFormat theFormat,
2938 const Graphic3d_SortType theSortType,
2939 const Standard_Real thePrecision,
2940 const Standard_Address theProgressBarFunc,
2941 const Standard_Address theProgressObject) const
2943 Handle(Visual3d_Layer) anUnderLayer = MyViewManager->UnderLayer();
2944 Handle(Visual3d_Layer) anOverLayer = MyViewManager->OverLayer();
2946 Aspect_CLayer2d anOverCLayer;
2947 Aspect_CLayer2d anUnderCLayer;
2948 anOverCLayer.ptrLayer = anUnderCLayer.ptrLayer = NULL;
2950 if (!anOverLayer.IsNull())
2951 anOverCLayer = anOverLayer->CLayer();
2952 if (!anUnderLayer.IsNull())
2953 anUnderCLayer = anUnderLayer->CLayer();
2955 Standard_Integer aWidth, aHeight;
2956 Window()->Size (aWidth, aHeight);
2958 return MyGraphicDriver->Export (theFileName, theFormat, theSortType,
2959 aWidth, aHeight, MyCView, anUnderCLayer, anOverCLayer,
2960 thePrecision, theProgressBarFunc, theProgressObject);
2963 //=======================================================================
2964 //function : AddZLayer
2966 //=======================================================================
2968 void Visual3d_View::AddZLayer (const Standard_Integer theLayerId)
2970 MyGraphicDriver->AddZLayer (MyCView, theLayerId);
2973 //=======================================================================
2974 //function : RemoveZLayer
2976 //=======================================================================
2978 void Visual3d_View::RemoveZLayer (const Standard_Integer theLayerId)
2980 MyGraphicDriver->RemoveZLayer (MyCView, theLayerId);
2983 //=======================================================================
2984 //function : ChangeZLayer
2986 //=======================================================================
2988 void Visual3d_View::ChangeZLayer (const Handle(Graphic3d_Structure)& theStructure,
2989 const Standard_Integer theLayerId)
2991 MyGraphicDriver->ChangeZLayer (
2992 (*(Graphic3d_CStructure*)theStructure->CStructure()), MyCView, theLayerId);