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.
20 #include <Aspect_Background.hxx>
21 #include <Aspect_GradientBackground.hxx>
22 #include <Aspect_Window.hxx>
23 #include <Bnd_Box.hxx>
24 #include <Graphic3d_DataStructureManager.hxx>
25 #include <Graphic3d_GraphicDriver.hxx>
26 #include <Graphic3d_MapIteratorOfMapOfStructure.hxx>
27 #include <Graphic3d_MapOfStructure.hxx>
28 #include <Graphic3d_Structure.hxx>
29 #include <Graphic3d_TextureEnv.hxx>
30 #include <Graphic3d_Vector.hxx>
31 #include <Graphic3d_Vertex.hxx>
33 #include <Standard_Type.hxx>
34 #include <TColStd_HArray2OfReal.hxx>
35 #include <Visual3d_ContextView.hxx>
36 #include <Visual3d_DepthCueingDefinitionError.hxx>
37 #include <Visual3d_Layer.hxx>
38 #include <Visual3d_Light.hxx>
39 #include <Visual3d_TransformError.hxx>
40 #include <Visual3d_View.hxx>
41 #include <Visual3d_ViewDefinitionError.hxx>
42 #include <Visual3d_ViewManager.hxx>
43 #include <Visual3d_ZClippingDefinitionError.hxx>
46 #include <WNT_Window.hxx>
47 #elif (defined(__APPLE__) && !defined(MACOSX_USE_GLX))
48 #include <Cocoa_Window.hxx>
50 #include <Xw_Window.hxx>
55 // =======================================================================
56 // function : Visual3d_View
58 // =======================================================================
59 Visual3d_View::Visual3d_View (const Handle(Visual3d_ViewManager)& theMgr)
60 : myViewManager (theMgr.operator->()),
61 myIsInComputedMode (Standard_False),
62 myAutoZFitIsOn (Standard_True),
63 myAutoZFitScaleFactor (1.0),
64 myStructuresUpdated (Standard_True)
66 myHiddenObjects = new Graphic3d_NMapOfTransient();
68 MyCView.ViewId = theMgr->Identification (this);
70 MyCView.IsDeleted = 0;
72 MyCView.DefWindow.IsDefined = 0;
73 MyCView.Context.NbActiveLight = 0;
75 MyCView.Backfacing = 0;
76 MyCView.ptrUnderLayer = 0;
77 MyCView.ptrOverLayer = 0;
79 MyCView.GDisplayCB = 0;
80 MyCView.GClientData = 0;
82 myGraphicDriver = myViewManager->GraphicDriver();
85 // =======================================================================
86 // function : SetWindow
88 // =======================================================================
89 void Visual3d_View::SetWindow (const Handle(Aspect_Window)& theWindow,
90 const Aspect_RenderingContext theContext,
91 const Aspect_GraphicCallbackProc& theDisplayCB,
92 const Standard_Address theClientData)
99 MyCView.GContext = theContext;
100 MyCView.GDisplayCB = theDisplayCB;
101 MyCView.GClientData = theClientData;
102 SetWindow (theWindow);
105 // =======================================================================
106 // function : SetWindow
108 // =======================================================================
109 void Visual3d_View::SetWindow (const Handle(Aspect_Window)& theWindow)
116 MyWindow = theWindow;
117 MyCView.WsId = MyCView.ViewId;
118 MyCView.DefWindow.IsDefined = 1;
119 MyCView.DefWindow.XWindow = theWindow->NativeHandle();
120 MyCView.DefWindow.XParentWindow = theWindow->NativeParentHandle();
122 Standard_Integer aWidth = 0, aHeight = 0, aLeft = 0, aTop = 0;
123 theWindow->Position (aLeft, aTop, aWidth, aHeight);
124 theWindow->Size (aWidth, aHeight);
125 MyCView.DefWindow.left = aLeft;
126 MyCView.DefWindow.top = aTop;
127 MyCView.DefWindow.dx = aWidth;
128 MyCView.DefWindow.dy = aHeight;
130 Standard_Real R, G, B;
131 MyBackground = MyWindow->Background ();
132 MyBackground.Color().Values (R, G, B, Quantity_TOC_RGB);
133 MyCView.DefWindow.Background.r = float (R);
134 MyCView.DefWindow.Background.g = float (G);
135 MyCView.DefWindow.Background.b = float (B);
138 if (!myGraphicDriver->View (MyCView))
140 Visual3d_ViewDefinitionError::Raise ("Association failed");
143 MyGradientBackground = MyWindow->GradientBackground();
144 SetGradientBackground(MyGradientBackground,1);
146 Standard_Boolean AWait = Standard_False; // => immediate update
147 myGraphicDriver->SetVisualisation (MyCView);
148 myGraphicDriver->AntiAliasing (MyCView, MyContext.AliasingIsOn());
149 myGraphicDriver->DepthCueing (MyCView, MyContext.DepthCueingIsOn());
150 myGraphicDriver->ClipLimit (MyCView, AWait);
151 myGraphicDriver->Environment (MyCView);
153 // Make view manager z layer list consistent with the view's list.
154 myViewManager->InstallZLayers (this);
156 // Update planses of model clipping
159 // Update light sources
162 // Association view-window does not cause the display
163 // of structures that can be displayed in the new view.
164 // In fact, association view-window is done, but the
165 // display is produced only if the view is activated (Activate).
169 const Handle(Graphic3d_Camera)& aCamera = MyCView.Context.Camera;
170 if (!aCamera.IsNull())
172 aCamera->InvalidateProjection();
173 aCamera->InvalidateOrientation();
177 // =======================================================================
180 // =======================================================================
181 Handle(Aspect_Window) Visual3d_View::Window() const
185 Visual3d_ViewDefinitionError::Raise ("Window not defined");
190 // =======================================================================
191 // function : IsDefined
193 // =======================================================================
194 Standard_Boolean Visual3d_View::IsDefined() const
196 return MyCView.DefWindow.IsDefined != 0;
199 // =======================================================================
200 // function : IsDeleted
202 // =======================================================================
203 Standard_Boolean Visual3d_View::IsDeleted() const
205 return MyCView.IsDeleted != 0;
208 // =======================================================================
209 // function : Destroy
211 // =======================================================================
212 void Visual3d_View::Destroy()
214 // Since myViewManager can be already destroyed,
215 // avoid attempts to access it in SetBackground()
216 myViewManager = NULL;
220 // =======================================================================
223 // =======================================================================
224 void Visual3d_View::Remove()
232 myStructsToCompute.Clear();
233 myStructsComputed .Clear();
234 myStructsDisplayed.Clear();
236 Aspect_GradientBackground aBlackGrad;
237 SetBackground (Aspect_Background (Quantity_NOC_BLACK));
238 SetGradientBackground (aBlackGrad, Standard_False);
240 if (myViewManager != NULL)
242 myViewManager->UnIdentification (MyCView.ViewId);
245 myGraphicDriver->RemoveView (MyCView);
248 MyCView.IsDeleted = 1;
249 MyCView.DefWindow.IsDefined = 0;
254 // =======================================================================
255 // function : Resized
257 // =======================================================================
258 void Visual3d_View::Resized()
264 else if (!IsDefined())
266 Visual3d_ViewDefinitionError::Raise ("Window not defined");
268 MyWindow->DoResize();
272 // =======================================================================
273 // function : SetRatio
275 // =======================================================================
276 void Visual3d_View::SetRatio()
283 const Aspect_TypeOfUpdate anUpdateMode = myViewManager->UpdateMode();
284 myViewManager->SetUpdateMode (Aspect_TOU_WAIT);
286 Standard_Integer aWidth = 0, aHeight = 0, aLeft = 0, aTop = 0;
287 MyWindow->Position (aLeft, aTop, aWidth, aHeight);
288 MyCView.DefWindow.left = aLeft;
289 MyCView.DefWindow.top = aTop;
291 MyWindow->Size (aWidth, aHeight);
292 if (aWidth > 0 && aHeight > 0)
294 Standard_Real aRatio = (Standard_Real)aWidth / (Standard_Real)aHeight;
296 MyCView.DefWindow.dx = aWidth;
297 MyCView.DefWindow.dy = aHeight;
299 myGraphicDriver->RatioWindow (MyCView);
301 // Update camera aspect
302 const Handle(Graphic3d_Camera)& aCamera = MyCView.Context.Camera;
303 if (!aCamera.IsNull())
305 aCamera->SetAspect (aRatio);
308 if (!myDefaultCamera.IsNull())
310 myDefaultCamera->SetAspect (aRatio);
314 myViewManager->SetUpdateMode (anUpdateMode);
315 Update (anUpdateMode);
318 // =======================================================================
319 // function : UpdateLights
321 // =======================================================================
322 void Visual3d_View::UpdateLights()
330 if (MyContext.Model() == Visual3d_TOM_NONE)
332 // activate only a white ambient light
333 Graphic3d_CLight aCLight;
334 aCLight.Type = Visual3d_TOLS_AMBIENT;
335 aCLight.IsHeadlight = Standard_False;
336 aCLight.Color.r() = aCLight.Color.g() = aCLight.Color.b() = 1.0f;
338 MyCView.Context.NbActiveLight = 1;
339 MyCView.Context.ActiveLight = &aCLight;
340 myGraphicDriver->SetLight (MyCView);
341 MyCView.Context.ActiveLight = NULL;
345 MyCView.Context.NbActiveLight = Min (MyContext.NumberOfActivatedLights(),
346 myGraphicDriver->InquireLightLimit());
347 if (MyCView.Context.NbActiveLight < 1)
349 myGraphicDriver->SetLight (MyCView);
353 // parcing of light sources
354 MyCView.Context.ActiveLight = new Graphic3d_CLight[MyCView.Context.NbActiveLight];
355 for (Standard_Integer aLightIter = 0; aLightIter < MyCView.Context.NbActiveLight; ++aLightIter)
357 MyCView.Context.ActiveLight[aLightIter] = MyContext.ActivatedLight (aLightIter + 1)->CLight();
359 myGraphicDriver->SetLight (MyCView);
360 delete[] MyCView.Context.ActiveLight;
361 MyCView.Context.ActiveLight = NULL;
364 // =======================================================================
365 // function : UpdatePlanes
367 // =======================================================================
368 void Visual3d_View::UpdatePlanes()
370 MyCView.Context.ClipPlanes = MyContext.ClipPlanes();
371 if (IsDeleted() || !IsDefined())
376 myGraphicDriver->SetClipPlanes (MyCView);
379 // =======================================================================
380 // function : SetBackground
382 // =======================================================================
383 void Visual3d_View::SetBackground (const Aspect_Background& theBack)
389 else if (!IsDefined())
391 Visual3d_ViewDefinitionError::Raise ("Window not defined");
394 // At this level, only GL can update the background.
395 // It is not necessary to call MyWindow->SetBackground (ABack); as
396 // this method starts update of window background by X
397 // (if the windowing is X)
399 Standard_Real R, G, B;
400 MyBackground = theBack;
401 MyBackground.Color().Values (R, G, B, Quantity_TOC_RGB);
402 MyCView.DefWindow.Background.r = float (R);
403 MyCView.DefWindow.Background.g = float (G);
404 MyCView.DefWindow.Background.b = float (B);
406 myGraphicDriver->Background (MyCView);
408 if (myViewManager != NULL)
410 Update (myViewManager->UpdateMode());
414 // =======================================================================
415 // function : SetGradientBackground
417 // =======================================================================
418 void Visual3d_View::SetGradientBackground (const Aspect_GradientBackground& theBack,
419 const Standard_Boolean theToUpdate)
425 else if (!IsDefined())
427 Visual3d_ViewDefinitionError::Raise ("Window not defined");
430 MyGradientBackground = theBack;
431 Quantity_Color aCol1, aCol2;
432 MyGradientBackground.Colors (aCol1, aCol2);
433 myGraphicDriver->GradientBackground (MyCView, aCol1, aCol2, MyGradientBackground.BgGradientFillMethod());
437 Update (Aspect_TOU_ASAP);
439 else if (myViewManager != NULL)
441 Update (myViewManager->UpdateMode());
445 // =======================================================================
446 // function : SetBackgroundImage
448 // =======================================================================
449 void Visual3d_View::SetBackgroundImage (const Standard_CString theFileName,
450 const Aspect_FillMethod theFillStyle,
451 const Standard_Boolean theToUpdate)
459 Visual3d_ViewDefinitionError::Raise ("Window not defined");
462 myGraphicDriver->BackgroundImage (theFileName, MyCView, theFillStyle);
464 Update (theToUpdate ? Aspect_TOU_ASAP : myViewManager->UpdateMode());
467 // =======================================================================
468 // function : SetBgImageStyle
470 // =======================================================================
471 void Visual3d_View::SetBgImageStyle (const Aspect_FillMethod theFillStyle,
472 const Standard_Boolean theToUpdate)
480 Visual3d_ViewDefinitionError::Raise ("Window not defined");
483 myGraphicDriver->SetBgImageStyle (MyCView, theFillStyle);
485 Update (theToUpdate ? Aspect_TOU_ASAP : myViewManager->UpdateMode());
488 // =======================================================================
489 // function : Background
491 // =======================================================================
492 Aspect_Background Visual3d_View::Background() const
497 // =======================================================================
498 // function : SetBgGradientStyle
500 // =======================================================================
501 void Visual3d_View::SetBgGradientStyle (const Aspect_GradientFillMethod theFillStyle,
502 const Standard_Boolean theToUpdate)
508 else if (!IsDefined())
510 Visual3d_ViewDefinitionError::Raise ("Window not defined");
513 myGraphicDriver->SetBgGradientStyle (MyCView, theFillStyle);
515 Update (theToUpdate ? Aspect_TOU_ASAP : myViewManager->UpdateMode());
518 // =======================================================================
519 // function : GradientBackground
521 // =======================================================================
522 Aspect_GradientBackground Visual3d_View::GradientBackground() const
524 return MyGradientBackground;
527 // =======================================================================
528 // function : DefaultCamera
530 // =======================================================================
531 const Handle(Graphic3d_Camera)& Visual3d_View::DefaultCamera() const
533 return myDefaultCamera;
536 // =======================================================================
539 // =======================================================================
540 const Handle(Graphic3d_Camera)& Visual3d_View::Camera() const
542 return MyCView.Context.Camera;
545 // =======================================================================
546 // function : SetCamera
548 // =======================================================================
549 void Visual3d_View::SetCamera (const Handle(Graphic3d_Camera)& theCamera)
551 MyCView.Context.Camera = theCamera;
553 myGraphicDriver->SetCamera (MyCView);
555 Update (myViewManager->UpdateMode());
558 // =======================================================================
559 // function : SetViewOrientationDefault
561 // =======================================================================
562 void Visual3d_View::SetViewOrientationDefault()
564 if (myDefaultCamera.IsNull())
566 myDefaultCamera = new Graphic3d_Camera();
569 myDefaultCamera->CopyOrientationData (MyCView.Context.Camera);
572 // =======================================================================
573 // function : ViewOrientationReset
575 // =======================================================================
576 void Visual3d_View::ViewOrientationReset()
583 if (!myDefaultCamera.IsNull())
585 MyCView.Context.Camera->CopyOrientationData (myDefaultCamera);
588 Update (myViewManager->UpdateMode());
591 // =======================================================================
592 // function : SetViewMappingDefault
594 // =======================================================================
595 void Visual3d_View::SetViewMappingDefault()
597 if (myDefaultCamera.IsNull())
599 myDefaultCamera = new Graphic3d_Camera();
601 myDefaultCamera->CopyMappingData (MyCView.Context.Camera);
604 // =======================================================================
605 // function : ViewMappingReset
607 // =======================================================================
608 void Visual3d_View::ViewMappingReset()
615 if (!myDefaultCamera.IsNull())
617 MyCView.Context.Camera->CopyMappingData (myDefaultCamera);
620 Update (myViewManager->UpdateMode());
623 // =======================================================================
624 // function : SetContext
626 // =======================================================================
627 void Visual3d_View::SetContext (const Visual3d_ContextView& theViewCtx)
634 // To manage display only in case of change of visualisation mode
635 const bool isVisModeChanged = theViewCtx.Visualization() != MyContext.Visualization();
636 const bool isModelChanged = theViewCtx.Model() != MyContext.Model();
638 // To manage antialiasing only in case of change
639 const Standard_Boolean anAliasingModeOld = MyContext.AliasingIsOn();
640 const Standard_Boolean anAliasingModeNew = theViewCtx.AliasingIsOn();
642 // To manage the depth cueing only in case of change
643 const Standard_Boolean aDepthCueingModeOld = MyContext.DepthCueingIsOn();
644 const Standard_Boolean aDepthCueingModeNew = theViewCtx.DepthCueingIsOn();
646 const Standard_Real aDepthCueingFrontPlaneOld = MyContext.DepthCueingFrontPlane();
647 const Standard_Real aDepthCueingFrontPlaneNew = theViewCtx.DepthCueingFrontPlane();
648 const Standard_Real aDepthCueingBackPlaneOld = MyContext.DepthCueingBackPlane();
649 const Standard_Real aDepthCueingBackPlaneNew = theViewCtx.DepthCueingBackPlane();
651 // To manage the Zclipping only in case of change
652 const Standard_Boolean aFrontZClippingModeOld = MyContext.FrontZClippingIsOn();
653 const Standard_Boolean aFrontZClippingModeNew = theViewCtx.FrontZClippingIsOn();
654 const Standard_Boolean aBackZClippingModeOld = MyContext.BackZClippingIsOn();
655 const Standard_Boolean aBackZClippingModeNew = theViewCtx.BackZClippingIsOn();
657 const Standard_Real aZClippingFrontPlaneOld = MyContext.ZClippingFrontPlane();
658 const Standard_Real aZClippingFrontPlaneNew = theViewCtx.ZClippingFrontPlane();
659 const Standard_Real aZClippingBackPlaneOld = MyContext.ZClippingBackPlane();
660 const Standard_Real aZClippingBackPlaneNew = theViewCtx.ZClippingBackPlane();
662 const bool isTextEnvChanged = theViewCtx.TextureEnv() != MyContext.TextureEnv();
663 const bool isSurfDetailChanged = theViewCtx.SurfaceDetail() != MyContext.SurfaceDetail();
665 MyContext = theViewCtx;
669 Standard_Boolean toWait = Standard_False; // => immediate update
672 // management of visualization modes and types of shading.
676 myGraphicDriver->SetVisualisation (MyCView);
679 // management of antialiasing
680 if (anAliasingModeOld != anAliasingModeNew)
682 myGraphicDriver->AntiAliasing (MyCView, anAliasingModeNew);
685 // management of depth_cueing
686 if (aDepthCueingModeOld != aDepthCueingModeNew
687 || aDepthCueingFrontPlaneOld != aDepthCueingFrontPlaneNew
688 || aDepthCueingBackPlaneOld != aDepthCueingBackPlaneNew)
690 if (aDepthCueingModeNew
691 && aDepthCueingBackPlaneNew >= aDepthCueingFrontPlaneNew)
693 Visual3d_DepthCueingDefinitionError::Raise ("Bad value for DepthCueingPlanes position");
695 myGraphicDriver->DepthCueing (MyCView, aDepthCueingModeNew);
698 // management of Zclipping
699 if (aFrontZClippingModeOld != aFrontZClippingModeNew
700 || aBackZClippingModeOld != aBackZClippingModeNew
701 || aZClippingFrontPlaneOld != aZClippingFrontPlaneNew
702 || aZClippingBackPlaneOld != aZClippingBackPlaneNew)
704 if (aBackZClippingModeNew
705 && aFrontZClippingModeNew
706 && aZClippingBackPlaneNew >= aZClippingFrontPlaneNew)
708 Visual3d_ZClippingDefinitionError::Raise ("Bad value for ZClippingPlanes position");
711 myGraphicDriver->ClipLimit (MyCView, toWait);
714 // management of textures
716 || isSurfDetailChanged)
718 myGraphicDriver->Environment (MyCView);
721 UpdatePlanes(); // Update of planes of model clipping
722 UpdateLights(); // Update of light sources
725 if (isVisModeChanged)
727 // Change of context =>
728 // Remove structures that cannot be displayed in the new visualisation mode.
729 // It is not necessary to warn ViewManager as this structure should not disappear from
730 // the list of structures displayed in it.
731 NCollection_Sequence<Handle(Graphic3d_Structure)> aStructs;
732 for (Graphic3d_MapOfStructure::Iterator aStructIter (myStructsDisplayed); aStructIter.More(); aStructIter.Next())
734 const Handle(Graphic3d_Structure)& aStruct = aStructIter.Key();
735 const Visual3d_TypeOfAnswer anAnswer = acceptDisplay (aStruct->Visual());
736 if (anAnswer == Visual3d_TOA_NO
737 || anAnswer == Visual3d_TOA_COMPUTE)
739 aStructs.Append (aStruct);
742 for (NCollection_Sequence<Handle(Graphic3d_Structure)>::Iterator aStructIter (aStructs); aStructIter.More(); aStructIter.Next())
744 Erase (aStructIter.ChangeValue(), Aspect_TOU_WAIT);
748 // Change of context =>
749 // Display structures that can be displayed with the new visualisation mode.
750 // All structures with status Displayed are removed from the ViewManager
751 // and displayed in the view directly, if the structure is not already
752 // displayed and if the view accepts it in its context.
753 Graphic3d_MapOfStructure aMapDisplayed;
754 myViewManager->DisplayedStructures (aMapDisplayed);
755 for (Graphic3d_MapIteratorOfMapOfStructure aStructIter (aMapDisplayed); aStructIter.More(); aStructIter.Next())
757 const Handle(Graphic3d_Structure)& aStruct = aStructIter.Key();
758 if (IsDisplayed (aStruct))
763 const Visual3d_TypeOfAnswer anAnswer = acceptDisplay (aStruct->Visual());
764 if (anAnswer == Visual3d_TOA_YES
765 || anAnswer == Visual3d_TOA_COMPUTE)
767 aStructs.Append (aStruct);
771 for (NCollection_Sequence<Handle(Graphic3d_Structure)>::Iterator aStructIter (aStructs); aStructIter.More(); aStructIter.Next())
773 Display (aStructIter.ChangeValue(), Aspect_TOU_WAIT);
777 Update (myViewManager->UpdateMode());
780 // =======================================================================
781 // function : Context
783 // =======================================================================
784 const Visual3d_ContextView& Visual3d_View::Context() const
789 // =======================================================================
790 // function : DisplayedStructures
792 // =======================================================================
793 void Visual3d_View::DisplayedStructures (Graphic3d_MapOfStructure& theStructures) const
800 for (Graphic3d_MapOfStructure::Iterator aStructIter (myStructsDisplayed); aStructIter.More(); aStructIter.Next())
802 theStructures.Add (aStructIter.Key());
806 // =======================================================================
807 // function : Activate
809 // =======================================================================
810 void Visual3d_View::Activate()
816 else if (!IsDefined())
818 Visual3d_ViewDefinitionError::Raise ("Window not defined");
823 myGraphicDriver->ActivateView (MyCView);
824 myGraphicDriver->Background (MyCView);
828 // Activation of a new view =>
829 // Display structures that can be displayed in this new view.
830 // All structures with status
831 // Displayed in ViewManager are returned and displayed in
832 // the view directly, if the structure is not already
833 // displayed and if the view accepts it in its context.
834 Graphic3d_MapOfStructure aDisplayedStructs;
835 myViewManager->DisplayedStructures (aDisplayedStructs);
836 for (Graphic3d_MapIteratorOfMapOfStructure aStructIter (aDisplayedStructs); aStructIter.More(); aStructIter.Next())
838 const Handle(Graphic3d_Structure)& aStruct = aStructIter.Key();
839 if (IsDisplayed (aStruct))
844 // If the structure can be displayed in the new context of the view, it is displayed.
845 const Visual3d_TypeOfAnswer anAnswer = acceptDisplay (aStruct->Visual());
846 if (anAnswer == Visual3d_TOA_YES
847 || anAnswer == Visual3d_TOA_COMPUTE)
849 Display (aStruct, Aspect_TOU_WAIT);
854 Update (myViewManager->UpdateMode());
857 // =======================================================================
858 // function : IsActive
860 // =======================================================================
861 Standard_Boolean Visual3d_View::IsActive() const
867 // =======================================================================
868 // function : Deactivate
870 // =======================================================================
871 void Visual3d_View::Deactivate()
877 else if (!IsDefined())
879 Visual3d_ViewDefinitionError::Raise ("Window not defined");
884 myGraphicDriver->DeactivateView (MyCView);
886 // Deactivation of a view =>
887 // Removal of structures displayed in this view.
888 // All structures with status
889 // Displayed in ViewManager are returned and removed from
890 // the view directly, if the structure is not already
891 // displayed and if the view accepts it in its context.
892 Graphic3d_MapOfStructure aDisplayedStructs;
893 myViewManager->DisplayedStructures (aDisplayedStructs);
894 for (Graphic3d_MapIteratorOfMapOfStructure aStructIter (aDisplayedStructs); aStructIter.More(); aStructIter.Next())
896 const Handle(Graphic3d_Structure)& aStruct = aStructIter.Key();
897 if (IsDisplayed (aStruct))
902 const Visual3d_TypeOfAnswer anAnswer = acceptDisplay (aStruct->Visual());
903 if (anAnswer == Visual3d_TOA_YES
904 || anAnswer == Visual3d_TOA_COMPUTE)
906 Erase (aStruct, Aspect_TOU_WAIT);
910 Update (myViewManager->UpdateMode());
911 MyCView.Active = 0; // No action currently possible in the view
915 // =======================================================================
918 // =======================================================================
919 void Visual3d_View::Redraw()
921 Redraw (myViewManager->UnderLayer(), myViewManager->OverLayer(), 0, 0, 0, 0);
924 // =======================================================================
927 // =======================================================================
928 void Visual3d_View::Redraw (const Standard_Integer theX,
929 const Standard_Integer theY,
930 const Standard_Integer theWidth,
931 const Standard_Integer theHeight)
933 Redraw (myViewManager->UnderLayer(), myViewManager->OverLayer(),
934 theX, theY, theWidth, theHeight);
937 // =======================================================================
940 // =======================================================================
941 void Visual3d_View::Redraw (const Handle(Visual3d_Layer)& theUnderLayer,
942 const Handle(Visual3d_Layer)& theOverLayer)
944 Redraw (theUnderLayer, theOverLayer, 0, 0, 0, 0);
947 // =======================================================================
950 // =======================================================================
951 void Visual3d_View::Redraw (const Handle(Visual3d_Layer)& theUnderLayer,
952 const Handle(Visual3d_Layer)& theOverLayer,
953 const Standard_Integer theX,
954 const Standard_Integer theY,
955 const Standard_Integer theWidth,
956 const Standard_Integer theHeight)
961 || !MyWindow->IsMapped())
966 Aspect_CLayer2d anOverCLayer, anUnderCLayer;
967 anOverCLayer.ptrLayer = anUnderCLayer.ptrLayer = NULL;
968 if (!theOverLayer .IsNull()) anOverCLayer = theOverLayer ->CLayer();
969 if (!theUnderLayer.IsNull()) anUnderCLayer = theUnderLayer->CLayer();
971 for (Standard_Integer aRetryIter = 0; aRetryIter < 2; ++aRetryIter)
973 if (myGraphicDriver->IsDeviceLost())
975 myViewManager->RecomputeStructures();
976 myViewManager->RecomputeStructures (myImmediateStructures);
977 myGraphicDriver->ResetDeviceLostFlag();
980 if (myStructuresUpdated)
983 myStructuresUpdated = Standard_False;
986 myGraphicDriver->Redraw (MyCView, anUnderCLayer, anOverCLayer, theX, theY, theWidth, theHeight);
987 if (!myGraphicDriver->IsDeviceLost())
994 // =======================================================================
995 // function : RedrawImmediate
997 // =======================================================================
998 void Visual3d_View::RedrawImmediate()
1000 RedrawImmediate (myViewManager->UnderLayer(), myViewManager->OverLayer());
1003 // =======================================================================
1004 // function : RedrawImmediate
1006 // =======================================================================
1007 void Visual3d_View::RedrawImmediate (const Handle(Visual3d_Layer)& theUnderLayer,
1008 const Handle(Visual3d_Layer)& theOverLayer)
1013 || !MyWindow->IsMapped())
1018 Aspect_CLayer2d anOverCLayer, anUnderCLayer;
1019 anOverCLayer.ptrLayer = anUnderCLayer.ptrLayer = NULL;
1020 if (!theOverLayer .IsNull()) anOverCLayer = theOverLayer ->CLayer();
1021 if (!theUnderLayer.IsNull()) anUnderCLayer = theUnderLayer->CLayer();
1022 myGraphicDriver->RedrawImmediate (MyCView, anUnderCLayer, anOverCLayer);
1025 // =======================================================================
1026 // function : Invalidate
1028 // =======================================================================
1029 void Visual3d_View::Invalidate()
1031 myGraphicDriver->Invalidate (MyCView);
1034 // =======================================================================
1035 // function : Update
1037 // =======================================================================
1038 void Visual3d_View::Update (Aspect_TypeOfUpdate theUpdateMode)
1040 myStructuresUpdated = Standard_True;
1041 if (theUpdateMode == Aspect_TOU_ASAP)
1044 Redraw (myViewManager->UnderLayer(), myViewManager->OverLayer(), 0, 0, 0, 0);
1048 // =======================================================================
1049 // function : Update
1051 // =======================================================================
1052 void Visual3d_View::Update (const Handle(Visual3d_Layer)& theUnderLayer,
1053 const Handle(Visual3d_Layer)& theOverLayer)
1056 myStructuresUpdated = Standard_True;
1057 Redraw (theUnderLayer, theOverLayer, 0, 0, 0, 0);
1060 // ========================================================================
1061 // function : SetAutoZFitMode
1063 // ========================================================================
1064 void Visual3d_View::SetAutoZFitMode (const Standard_Boolean theIsOn,
1065 const Standard_Real theScaleFactor)
1067 Standard_ASSERT_RAISE (theScaleFactor > 0.0, "Zero or negative scale factor is not allowed.");
1068 myAutoZFitScaleFactor = theScaleFactor;
1069 myAutoZFitIsOn = theIsOn;
1072 // ========================================================================
1073 // function : AutoZFitMode
1075 // ========================================================================
1076 Standard_Boolean Visual3d_View::AutoZFitMode() const
1078 return myAutoZFitIsOn;
1081 // ========================================================================
1082 // function : AutoZFitScaleFactor
1084 // ========================================================================
1085 Standard_Real Visual3d_View::AutoZFitScaleFactor() const
1087 return myAutoZFitScaleFactor;
1090 // ========================================================================
1091 // function : AutoZFit
1093 // ========================================================================
1094 void Visual3d_View::AutoZFit()
1096 if (!AutoZFitMode())
1101 ZFitAll (myAutoZFitScaleFactor);
1104 // ========================================================================
1105 // function : ZFitAll
1107 // ========================================================================
1108 void Visual3d_View::ZFitAll (const Standard_Real theScaleFactor)
1110 Bnd_Box aMinMaxBox = MinMaxValues (Standard_False); // applicative min max boundaries
1111 Bnd_Box aGraphicBox = MinMaxValues (Standard_True); // real graphical boundaries (not accounting infinite flag).
1113 const Handle(Graphic3d_Camera)& aCamera = MyCView.Context.Camera;
1114 aCamera->ZFitAll (theScaleFactor, aMinMaxBox, aGraphicBox);
1117 // ========================================================================
1118 // function : acceptDisplay
1120 // ========================================================================
1121 Visual3d_TypeOfAnswer Visual3d_View::acceptDisplay (const Graphic3d_TypeOfStructure theStructType) const
1123 const Visual3d_TypeOfVisualization aViewType = MyContext.Visualization();
1124 switch (theStructType)
1126 case Graphic3d_TOS_ALL:
1128 return Visual3d_TOA_YES; // The structure accepts any type of view
1130 case Graphic3d_TOS_SHADING:
1132 return aViewType == Visual3d_TOV_SHADING
1136 case Graphic3d_TOS_WIREFRAME:
1138 return aViewType == Visual3d_TOV_WIREFRAME
1142 case Graphic3d_TOS_COMPUTED:
1144 return (aViewType == Visual3d_TOV_SHADING || aViewType == Visual3d_TOV_WIREFRAME)
1145 ? Visual3d_TOA_COMPUTE
1149 return Visual3d_TOA_NO;
1152 // ========================================================================
1153 // function : ChangeDisplayPriority
1155 // ========================================================================
1156 void Visual3d_View::ChangeDisplayPriority (const Handle(Graphic3d_Structure)& theStruct,
1157 const Standard_Integer /*theOldPriority*/,
1158 const Standard_Integer theNewPriority)
1163 || !IsDisplayed (theStruct))
1168 if (!myIsInComputedMode)
1170 myGraphicDriver->ChangePriority (*theStruct->CStructure(), MyCView, theNewPriority);
1174 const Standard_Integer anIndex = IsComputed (theStruct);
1175 const Graphic3d_CStructure& aCStruct = anIndex != 0
1176 ? *(myStructsComputed.Value (anIndex)->CStructure())
1177 : *theStruct->CStructure();
1178 myGraphicDriver->ChangePriority (aCStruct, MyCView, theNewPriority);
1181 // ========================================================================
1184 // ========================================================================
1185 void Visual3d_View::Clear (const Handle(Graphic3d_Structure)& theStruct,
1186 const Standard_Boolean theWithDestruction)
1188 const Standard_Integer anIndex = IsComputed (theStruct);
1191 const Handle(Graphic3d_Structure)& aCompStruct = myStructsComputed.Value (anIndex);
1192 aCompStruct->GraphicClear (theWithDestruction);
1193 aCompStruct->SetHLRValidation (Standard_False);
1197 // ========================================================================
1198 // function : Connect
1200 // ========================================================================
1201 void Visual3d_View::Connect (const Handle(Graphic3d_Structure)& theMother,
1202 const Handle(Graphic3d_Structure)& theDaughter)
1204 Standard_Integer anIndexM = IsComputed (theMother);
1205 Standard_Integer anIndexD = IsComputed (theDaughter);
1209 const Handle(Graphic3d_Structure)& aStructM = myStructsComputed.Value (anIndexM);
1210 const Handle(Graphic3d_Structure)& aStructD = myStructsComputed.Value (anIndexD);
1211 aStructM->GraphicConnect (aStructD);
1215 // ========================================================================
1216 // function : Disconnect
1218 // ========================================================================
1219 void Visual3d_View::Disconnect (const Handle(Graphic3d_Structure)& theMother,
1220 const Handle(Graphic3d_Structure)& theDaughter)
1222 Standard_Integer anIndexM = IsComputed (theMother);
1223 Standard_Integer anIndexD = IsComputed (theDaughter);
1227 const Handle(Graphic3d_Structure)& aStructM = myStructsComputed.Value (anIndexM);
1228 const Handle(Graphic3d_Structure)& aStructD = myStructsComputed.Value (anIndexD);
1229 aStructM->GraphicDisconnect (aStructD);
1233 // ========================================================================
1234 // function : DisplayImmediate
1236 // ========================================================================
1237 Standard_Boolean Visual3d_View::DisplayImmediate (const Handle(Graphic3d_Structure)& theStructure,
1238 const Standard_Boolean theIsSingleView)
1240 if (!myImmediateStructures.Add (theStructure))
1242 return Standard_False;
1245 if (theIsSingleView)
1247 const Visual3d_SequenceOfView& aViews = myViewManager->DefinedViews();
1248 for (Standard_Integer aViewIter = 1; aViewIter <= aViews.Length(); ++aViewIter)
1250 const Handle(Visual3d_View)& aView = aViews.Value (aViewIter);
1253 aView->EraseImmediate (theStructure);
1258 myGraphicDriver->DisplayImmediateStructure (MyCView, theStructure);
1259 return Standard_True;
1262 // ========================================================================
1263 // function : EraseImmediate
1265 // ========================================================================
1266 Standard_Boolean Visual3d_View::EraseImmediate (const Handle(Graphic3d_Structure)& theStructure)
1268 const Standard_Boolean isErased = myImmediateStructures.Remove (theStructure);
1271 myGraphicDriver->EraseImmediateStructure (MyCView, *theStructure->CStructure());
1277 // ========================================================================
1278 // function : ClearImmediate
1280 // ========================================================================
1281 Standard_Boolean Visual3d_View::ClearImmediate()
1283 if (myImmediateStructures.IsEmpty())
1285 return Standard_False;
1288 for (Graphic3d_MapOfStructure::Iterator aStructIter (myImmediateStructures); aStructIter.More(); aStructIter.Next())
1290 myGraphicDriver->EraseImmediateStructure (MyCView, *aStructIter.Key()->CStructure());
1292 myImmediateStructures.Clear();
1293 return Standard_True;
1296 // ========================================================================
1297 // function : Display
1299 // ========================================================================
1300 void Visual3d_View::Display (const Handle(Graphic3d_Structure)& theStruct)
1302 Display (theStruct, myViewManager->UpdateMode());
1305 // ========================================================================
1306 // function : Display
1308 // ========================================================================
1309 void Visual3d_View::Display (const Handle(Graphic3d_Structure)& theStruct,
1310 const Aspect_TypeOfUpdate theUpdateMode)
1319 // If Display on a structure present in the list of calculated structures while it is not
1320 // or more, of calculated type =>
1321 // - removes it as well as the associated old computed
1322 // THis happens when hlhsr becomes again of type e non computed after SetVisual.
1323 Standard_Integer anIndex = IsComputed (theStruct);
1325 && theStruct->Visual() != Graphic3d_TOS_COMPUTED)
1327 myStructsToCompute.Remove (anIndex);
1328 myStructsComputed .Remove (anIndex);
1332 Visual3d_TypeOfAnswer anAnswer = acceptDisplay (theStruct->Visual());
1333 if (anAnswer == Visual3d_TOA_NO)
1338 if (!ComputedMode())
1340 anAnswer = Visual3d_TOA_YES;
1343 if (anAnswer == Visual3d_TOA_YES)
1345 if (!myStructsDisplayed.Add (theStruct))
1350 theStruct->CalculateBoundBox();
1351 myGraphicDriver->DisplayStructure (MyCView, theStruct, theStruct->DisplayPriority());
1352 Update (theUpdateMode);
1355 else if (anAnswer != Visual3d_TOA_COMPUTE)
1362 // Already computed, is COMPUTED still valid?
1363 const Handle(Graphic3d_Structure)& anOldStruct = myStructsComputed.Value (anIndex);
1364 if (anOldStruct->HLRValidation())
1366 // Case COMPUTED valid, to be displayed
1367 if (!myStructsDisplayed.Add (theStruct))
1372 myGraphicDriver->DisplayStructure (MyCView, anOldStruct, theStruct->DisplayPriority());
1373 Update (theUpdateMode);
1378 // Case COMPUTED invalid
1379 // Is there another valid representation?
1380 // Find in the sequence of already calculated structures
1381 // 1/ Structure having the same Owner as <AStructure>
1382 // 2/ That is not <AStructure>
1383 // 3/ The COMPUTED which of is valid
1384 const Standard_Integer aNewIndex = HaveTheSameOwner (theStruct);
1387 // Case of COMPUTED invalid, WITH a valid of replacement; to be displayed
1388 if (!myStructsDisplayed.Add (theStruct))
1393 const Handle(Graphic3d_Structure)& aNewStruct = myStructsComputed.Value (aNewIndex);
1394 myStructsComputed.SetValue (anIndex, aNewStruct);
1395 myGraphicDriver->DisplayStructure (MyCView, aNewStruct, theStruct->DisplayPriority());
1396 Update (theUpdateMode);
1401 // Case COMPUTED invalid, WITHOUT a valid of replacement
1402 // COMPUTED is removed if displayed
1403 if (myStructsDisplayed.Contains (theStruct))
1405 myGraphicDriver->EraseStructure (MyCView, anOldStruct);
1411 // Compute + Validation
1412 Handle(Graphic3d_Structure) aStruct;
1413 TColStd_Array2OfReal aTrsf (0, 3, 0, 3);
1414 theStruct->Transform (aTrsf);
1417 TColStd_Array2OfReal anIdent (0, 3, 0, 3);
1418 for (Standard_Integer ii = 0; ii <= 3; ++ii)
1420 for (Standard_Integer jj = 0; jj <= 3; ++jj)
1422 anIdent (ii, jj) = (ii == jj ? 1.0 : 0.0);
1426 aStruct = myStructsComputed.Value (anIndex);
1427 aStruct->SetTransform (anIdent, Graphic3d_TOC_REPLACE);
1428 if (theStruct->IsTransformed())
1430 theStruct->Compute (this, aTrsf, aStruct);
1434 theStruct->Compute (this, aStruct);
1439 aStruct = theStruct->IsTransformed()
1440 ? theStruct->Compute (this, aTrsf)
1441 : theStruct->Compute (this);
1444 aStruct->SetHLRValidation (Standard_True);
1446 // TOCOMPUTE and COMPUTED associated to sequences are added
1447 myStructsToCompute.Append (theStruct);
1448 myStructsComputed .Append (aStruct);
1450 // The previous are removed if necessary
1453 myStructsToCompute.Remove (anIndex);
1454 myStructsComputed .Remove (anIndex);
1457 // Of which type will be the computed?
1458 const Visual3d_TypeOfVisualization aViewType = MyContext.Visualization();
1459 const Standard_Boolean toComputeWireframe = aViewType == Visual3d_TOV_WIREFRAME
1460 && theStruct->ComputeVisual() != Graphic3d_TOS_SHADING;
1461 const Standard_Boolean toComputeShading = aViewType == Visual3d_TOV_SHADING
1462 && theStruct->ComputeVisual() != Graphic3d_TOS_WIREFRAME;
1463 if (!toComputeShading && !toComputeWireframe)
1465 anAnswer = Visual3d_TOA_NO;
1469 aStruct->SetVisual (toComputeWireframe ? Graphic3d_TOS_WIREFRAME : Graphic3d_TOS_SHADING);
1470 anAnswer = acceptDisplay (aStruct->Visual());
1473 if (theStruct->IsHighlighted())
1475 aStruct->Highlight (Aspect_TOHM_COLOR, theStruct->HighlightColor(), Standard_False);
1478 // It is displayed only if the calculated structure
1479 // has a proper type corresponding to the one of the view.
1480 if (anAnswer == Visual3d_TOA_NO)
1485 myStructsDisplayed.Add (theStruct);
1486 myGraphicDriver->DisplayStructure (MyCView, aStruct, theStruct->DisplayPriority());
1488 Update (theUpdateMode);
1491 // ========================================================================
1494 // ========================================================================
1495 void Visual3d_View::Erase (const Handle(Graphic3d_Structure)& theStruct)
1499 Erase (theStruct, myViewManager->UpdateMode());
1503 // ========================================================================
1506 // ========================================================================
1507 void Visual3d_View::Erase (const Handle(Graphic3d_Structure)& theStruct,
1508 const Aspect_TypeOfUpdate theUpdateMode)
1511 || EraseImmediate (theStruct)
1512 || !IsDisplayed (theStruct))
1517 Visual3d_TypeOfAnswer anAnswer = acceptDisplay (theStruct->Visual());
1518 if (!ComputedMode())
1520 anAnswer = Visual3d_TOA_YES;
1523 if (anAnswer != Visual3d_TOA_COMPUTE)
1525 myGraphicDriver->EraseStructure (MyCView, theStruct);
1527 else if (anAnswer == Visual3d_TOA_COMPUTE
1528 && myIsInComputedMode)
1530 const Standard_Integer anIndex = IsComputed (theStruct);
1533 const Handle(Graphic3d_Structure)& aCompStruct = myStructsComputed.ChangeValue (anIndex);
1534 myGraphicDriver->EraseStructure (MyCView, aCompStruct);
1537 myStructsDisplayed.Remove (theStruct);
1538 Update (theUpdateMode);
1541 // ========================================================================
1542 // function : Highlight
1544 // ========================================================================
1545 void Visual3d_View::Highlight (const Handle(Graphic3d_Structure)& theStruct,
1546 const Aspect_TypeOfHighlightMethod theMethod)
1548 const Standard_Integer anIndex = IsComputed (theStruct);
1551 const Handle(Graphic3d_Structure)& aCompStruct = myStructsComputed.ChangeValue (anIndex);
1552 aCompStruct->Highlight (theMethod, theStruct->HighlightColor(), Standard_False);
1556 // ========================================================================
1557 // function : SetTransform
1559 // ========================================================================
1560 void Visual3d_View::SetTransform (const Handle(Graphic3d_Structure)& theStruct,
1561 const TColStd_Array2OfReal& theTrsf)
1563 const Standard_Integer anIndex = IsComputed (theStruct);
1566 // Test is somewhat light !
1567 // trsf is transferred only if it is :
1570 if (theTrsf (0, 1) != 0.0 || theTrsf (0, 2) != 0.0
1571 || theTrsf (1, 0) != 0.0 || theTrsf (1, 2) != 0.0
1572 || theTrsf (2, 0) != 0.0 || theTrsf (2, 1) != 0.0)
1574 ReCompute (theStruct);
1578 const Handle(Graphic3d_Structure)& aCompStruct = myStructsComputed.ChangeValue (anIndex);
1579 aCompStruct->GraphicTransform (theTrsf);
1583 theStruct->CalculateBoundBox();
1584 if (!theStruct->IsMutable()
1585 && !theStruct->CStructure()->IsForHighlight
1586 && !theStruct->CStructure()->IsInfinite)
1588 const Graphic3d_ZLayerId aLayerId = theStruct->GetZLayer();
1589 myGraphicDriver->InvalidateBVHData (MyCView, aLayerId);
1593 // ========================================================================
1594 // function : UnHighlight
1596 // ========================================================================
1597 void Visual3d_View::UnHighlight (const Handle(Graphic3d_Structure)& theStruct)
1599 Standard_Integer anIndex = IsComputed (theStruct);
1602 const Handle(Graphic3d_Structure)& aCompStruct = myStructsComputed.ChangeValue (anIndex);
1603 aCompStruct->GraphicUnHighlight();
1607 // ========================================================================
1608 // function : IsComputed
1610 // ========================================================================
1611 Standard_Integer Visual3d_View::IsComputed (const Handle(Graphic3d_Structure)& theStruct) const
1613 const Standard_Integer aStructId = theStruct->Identification();
1614 const Standard_Integer aNbStructs = myStructsToCompute.Length();
1615 for (Standard_Integer aStructIter = 1; aStructIter <= aNbStructs; ++aStructIter)
1617 const Handle(Graphic3d_Structure)& aStruct = myStructsToCompute.Value (aStructIter);
1618 if (aStruct->Identification() == aStructId)
1626 // ========================================================================
1627 // function : IsDisplayed
1629 // ========================================================================
1630 Standard_Boolean Visual3d_View::IsDisplayed (const Handle(Graphic3d_Structure)& theStruct) const
1633 && myStructsDisplayed.Contains (theStruct);
1636 // ========================================================================
1637 // function : ContainsFacet
1639 // ========================================================================
1640 Standard_Boolean Visual3d_View::ContainsFacet() const
1642 for (Graphic3d_MapOfStructure::Iterator aStructIter (myStructsDisplayed); aStructIter.More(); aStructIter.Next())
1644 if (aStructIter.Key()->ContainsFacet())
1646 return Standard_True;
1649 return Standard_False;
1652 // ========================================================================
1653 // function : ContainsFacet
1655 // ========================================================================
1656 Standard_Boolean Visual3d_View::ContainsFacet (const Graphic3d_MapOfStructure& theSet) const
1658 for (Graphic3d_MapIteratorOfMapOfStructure aStructIter (theSet); aStructIter.More(); aStructIter.Next())
1660 if (aStructIter.Key()->ContainsFacet())
1662 return Standard_True;
1665 return Standard_False;
1668 //! Auxiliary method for MinMaxValues() method
1669 inline void addStructureBndBox (const Handle(Graphic3d_Structure)& theStruct,
1670 const Standard_Boolean theToIgnoreInfiniteFlag,
1673 if (!theStruct->IsVisible())
1677 else if (theStruct->IsInfinite()
1678 && !theToIgnoreInfiniteFlag)
1680 // XMin, YMin .... ZMax are initialized by means of infinite line data
1681 const Bnd_Box aBox = theStruct->MinMaxValues (Standard_False);
1685 theBndBox.Add (aBox);
1690 // Only non-empty and non-infinite structures
1691 // are taken into account for calculation of MinMax
1692 if (theStruct->IsEmpty()
1693 || theStruct->TransformPersistenceMode() != Graphic3d_TMF_None)
1698 // "FitAll" operation ignores object with transform persistence parameter
1699 const Bnd_Box aBox = theStruct->MinMaxValues (theToIgnoreInfiniteFlag);
1701 // To prevent float overflow at camera parameters calculation and further
1702 // rendering, bounding boxes with at least one vertex coordinate out of
1703 // float range are skipped by view fit algorithms
1704 if (Abs (aBox.CornerMax().X()) >= ShortRealLast() ||
1705 Abs (aBox.CornerMax().Y()) >= ShortRealLast() ||
1706 Abs (aBox.CornerMax().Z()) >= ShortRealLast() ||
1707 Abs (aBox.CornerMin().X()) >= ShortRealLast() ||
1708 Abs (aBox.CornerMin().Y()) >= ShortRealLast() ||
1709 Abs (aBox.CornerMin().Z()) >= ShortRealLast())
1712 theBndBox.Add (aBox);
1715 // ========================================================================
1716 // function : MinMaxValues
1718 // ========================================================================
1719 Bnd_Box Visual3d_View::MinMaxValues (const Standard_Boolean theToIgnoreInfiniteFlag) const
1721 Bnd_Box aResult = MinMaxValues (myStructsDisplayed, theToIgnoreInfiniteFlag);
1722 Bnd_Box anImmediate = MinMaxValues (myImmediateStructures, theToIgnoreInfiniteFlag);
1723 aResult.Add (anImmediate);
1727 // ========================================================================
1728 // function : MinMaxValues
1730 // ========================================================================
1731 Bnd_Box Visual3d_View::MinMaxValues (const Graphic3d_MapOfStructure& theSet,
1732 const Standard_Boolean theToIgnoreInfiniteFlag) const
1735 const Standard_Integer aViewId = MyCView.ViewId;
1736 for (Graphic3d_MapIteratorOfMapOfStructure aStructIter (theSet); aStructIter.More(); aStructIter.Next())
1738 const Handle(Graphic3d_Structure)& aStructure = aStructIter.Key();
1739 if (!aStructIter.Value()->IsVisible())
1743 else if (!aStructIter.Value()->CStructure()->ViewAffinity.IsNull()
1744 && !aStructIter.Value()->CStructure()->ViewAffinity->IsVisible (aViewId))
1749 addStructureBndBox (aStructure, theToIgnoreInfiniteFlag, aResult);
1754 // =======================================================================
1755 // function : NumberOfDisplayedStructures
1757 // =======================================================================
1758 Standard_Integer Visual3d_View::NumberOfDisplayedStructures() const
1760 return myStructsDisplayed.Extent();
1763 // =======================================================================
1764 // function : Projects
1766 // =======================================================================
1767 void Visual3d_View::Projects (const Standard_Real theX,
1768 const Standard_Real theY,
1769 const Standard_Real theZ,
1770 Standard_Real& thePX,
1771 Standard_Real& thePY,
1772 Standard_Real& thePZ) const
1774 const Handle(Graphic3d_Camera)& aCamera = MyCView.Context.Camera;
1776 gp_XYZ aViewSpaceDimensions = aCamera->ViewDimensions();
1777 Standard_Real aXSize = aViewSpaceDimensions.X();
1778 Standard_Real aYSize = aViewSpaceDimensions.Y();
1779 Standard_Real aZSize = aViewSpaceDimensions.Z();
1781 gp_Pnt aPoint = aCamera->Project (gp_Pnt (theX, theY, theZ));
1783 // NDC [-1, 1] --> PROJ [ -size / 2, +size / 2 ]
1784 thePX = aPoint.X() * aXSize * 0.5;
1785 thePY = aPoint.Y() * aYSize * 0.5;
1786 thePZ = aPoint.Z() * aZSize * 0.5;
1789 // =======================================================================
1790 // function : Identification
1792 // =======================================================================
1793 Standard_Integer Visual3d_View::Identification() const
1795 return MyCView.ViewId;
1798 // =======================================================================
1799 // function : UpdateView
1801 // =======================================================================
1802 void Visual3d_View::UpdateView()
1804 MyCView.Context.Aliasing = MyContext.AliasingIsOn();
1805 MyCView.Context.BackZClipping = MyContext.BackZClippingIsOn();
1806 MyCView.Context.FrontZClipping = MyContext.FrontZClippingIsOn();
1807 MyCView.Context.DepthCueing = MyContext.DepthCueingIsOn();
1809 MyCView.Context.ZClipFrontPlane = float (MyContext.ZClippingFrontPlane());
1810 MyCView.Context.ZClipBackPlane = float (MyContext.ZClippingBackPlane());
1811 MyCView.Context.DepthFrontPlane = float (MyContext.DepthCueingFrontPlane());
1812 MyCView.Context.DepthBackPlane = float (MyContext.DepthCueingBackPlane());
1814 MyCView.Context.Model = MyContext.Model();
1815 MyCView.Context.Visualization = MyContext.Visualization();
1817 MyCView.Context.TextureEnv = MyContext.TextureEnv();
1818 MyCView.Context.SurfaceDetail = MyContext.SurfaceDetail();
1821 // =======================================================================
1822 // function : Compute
1824 // =======================================================================
1825 void Visual3d_View::Compute()
1827 // force HLRValidation to False on all structures calculated in the view
1828 const Standard_Integer aNbCompStructs = myStructsComputed.Length();
1829 for (Standard_Integer aStructIter = 1; aStructIter <= aNbCompStructs; ++aStructIter)
1831 myStructsComputed.Value (aStructIter)->SetHLRValidation (Standard_False);
1834 if (!ComputedMode())
1839 // Change of orientation or of projection type =>
1840 // Remove structures that were calculated for the previous orientation.
1841 // Recalculation of new structures.
1842 NCollection_Sequence<Handle(Graphic3d_Structure)> aStructsSeq;
1843 for (Graphic3d_MapOfStructure::Iterator aStructIter (myStructsDisplayed); aStructIter.More(); aStructIter.Next())
1845 const Visual3d_TypeOfAnswer anAnswer = acceptDisplay (aStructIter.Key()->Visual());
1846 if (anAnswer == Visual3d_TOA_COMPUTE)
1848 aStructsSeq.Append (aStructIter.Key()); // if the structure was calculated, it is recalculated
1852 for (NCollection_Sequence<Handle(Graphic3d_Structure)>::Iterator aStructIter (aStructsSeq); aStructIter.More(); aStructIter.Next())
1854 Display (aStructIter.ChangeValue(), Aspect_TOU_WAIT);
1858 // =======================================================================
1859 // function : ReCompute
1861 // =======================================================================
1862 void Visual3d_View::ReCompute (const Handle(Graphic3d_Structure)& theStruct)
1864 theStruct->CalculateBoundBox();
1865 if (!theStruct->IsMutable()
1866 && !theStruct->CStructure()->IsForHighlight
1867 && !theStruct->CStructure()->IsInfinite)
1869 const Standard_Integer aLayerId = theStruct->DisplayPriority();
1870 myGraphicDriver->InvalidateBVHData(MyCView, aLayerId);
1877 || !MyWindow->IsMapped()
1878 || !theStruct->IsDisplayed())
1883 const Visual3d_TypeOfAnswer anAnswer = acceptDisplay (theStruct->Visual());
1884 if (anAnswer != Visual3d_TOA_COMPUTE)
1889 const Standard_Integer anIndex = IsComputed (theStruct);
1895 // compute + validation
1896 TColStd_Array2OfReal anIdent (0, 3, 0, 3);
1897 for (Standard_Integer aRow = 0; aRow <= 3; ++aRow)
1899 for (Standard_Integer aCol = 0; aCol <= 3; ++aCol)
1901 anIdent (aRow, aCol) = (aRow == aCol ? 1.0 : 0.0);
1904 TColStd_Array2OfReal aTrsf (0, 3, 0, 3);
1905 theStruct->Transform (aTrsf);
1907 Handle(Graphic3d_Structure) aCompStructOld = myStructsComputed.ChangeValue (anIndex);
1908 Handle(Graphic3d_Structure) aCompStruct = aCompStructOld;
1909 aCompStruct->SetTransform (anIdent, Graphic3d_TOC_REPLACE);
1910 theStruct->IsTransformed() ? theStruct->Compute (this, aTrsf, aCompStruct)
1911 : theStruct->Compute (this, aCompStruct);
1912 aCompStruct->SetHLRValidation (Standard_True);
1914 // of which type will be the computed?
1915 const Visual3d_TypeOfVisualization aViewType = MyContext.Visualization();
1916 const Standard_Boolean toComputeWireframe = aViewType == Visual3d_TOV_WIREFRAME
1917 && theStruct->ComputeVisual() != Graphic3d_TOS_SHADING;
1918 const Standard_Boolean toComputeShading = aViewType == Visual3d_TOV_SHADING
1919 && theStruct->ComputeVisual() != Graphic3d_TOS_WIREFRAME;
1920 if (toComputeWireframe)
1922 aCompStruct->SetVisual (Graphic3d_TOS_WIREFRAME);
1924 else if (toComputeShading)
1926 aCompStruct->SetVisual (Graphic3d_TOS_SHADING);
1929 if (theStruct->IsHighlighted())
1931 aCompStruct->Highlight (Aspect_TOHM_COLOR, theStruct->HighlightColor(), Standard_False);
1934 // The previous calculation is removed and the new one is displayed
1935 myGraphicDriver->EraseStructure (MyCView, aCompStructOld);
1936 myGraphicDriver->DisplayStructure (MyCView, aCompStruct, theStruct->DisplayPriority());
1938 // why not just replace existing items?
1939 //myStructsToCompute.ChangeValue (anIndex) = theStruct;
1940 //myStructsComputed .ChangeValue (anIndex) = aCompStruct;
1942 // hlhsr and the new associated compute are added
1943 myStructsToCompute.Append (theStruct);
1944 myStructsComputed .Append (aCompStruct);
1946 // hlhsr and the new associated compute are removed
1947 myStructsToCompute.Remove (anIndex);
1948 myStructsComputed .Remove (anIndex);
1951 // =======================================================================
1952 // function : GraphicDriver
1954 // =======================================================================
1955 const Handle(Graphic3d_GraphicDriver)& Visual3d_View::GraphicDriver() const
1957 return myGraphicDriver;
1960 // =======================================================================
1961 // function : HaveTheSameOwner
1963 // =======================================================================
1964 Standard_Integer Visual3d_View::HaveTheSameOwner (const Handle(Graphic3d_Structure)& theStruct) const
1966 // Find in the sequence of already calculated structures
1967 // 1/ Structure with the same Owner as <AStructure>
1968 // 2/ Which is not <AStructure>
1969 // 3/ COMPUTED which of is valid
1970 const Standard_Integer aNbToCompStructs = myStructsToCompute.Length();
1971 for (Standard_Integer aStructIter = 1; aStructIter <= aNbToCompStructs; ++aStructIter)
1973 const Handle(Graphic3d_Structure)& aStructToComp = myStructsToCompute.Value (aStructIter);
1974 if (aStructToComp->Owner() == theStruct->Owner()
1975 && aStructToComp->Identification() != theStruct->Identification())
1977 const Handle(Graphic3d_Structure)& aStructComp = myStructsComputed.Value (aStructIter);
1978 if (aStructComp->HLRValidation())
1987 // =======================================================================
1990 // =======================================================================
1991 Standard_Address Visual3d_View::CView() const
1993 return Standard_Address (&MyCView);
1996 // =======================================================================
1997 // function : ZBufferTriedronSetup
1999 // =======================================================================
2000 void Visual3d_View::ZBufferTriedronSetup (const Quantity_NameOfColor theXColor,
2001 const Quantity_NameOfColor theYColor,
2002 const Quantity_NameOfColor theZColor,
2003 const Standard_Real theSizeRatio,
2004 const Standard_Real theAxisDiametr,
2005 const Standard_Integer theNbFacettes)
2007 myGraphicDriver->ZBufferTriedronSetup (MyCView, theXColor, theYColor, theZColor,
2008 theSizeRatio, theAxisDiametr, theNbFacettes);
2011 // =======================================================================
2012 // function : TriedronDisplay
2014 // =======================================================================
2015 void Visual3d_View::TriedronDisplay (const Aspect_TypeOfTriedronPosition thePosition,
2016 const Quantity_NameOfColor theColor,
2017 const Standard_Real theScale,
2018 const Standard_Boolean theAsWireframe)
2020 myGraphicDriver->TriedronDisplay (MyCView, thePosition, theColor, theScale, theAsWireframe);
2023 // =======================================================================
2024 // function : TriedronErase
2026 // =======================================================================
2027 void Visual3d_View::TriedronErase()
2029 myGraphicDriver->TriedronErase (MyCView);
2032 // =======================================================================
2033 // function : TriedronEcho
2035 // =======================================================================
2036 void Visual3d_View::TriedronEcho (const Aspect_TypeOfTriedronEcho theType)
2038 myGraphicDriver->TriedronEcho (MyCView, theType);
2041 static void SetMinMaxValuesCallback (Visual3d_View* theView)
2043 Graphic3d_CView* aCView = (Graphic3d_CView* )(theView->CView());
2044 Bnd_Box aBox = theView->MinMaxValues();
2047 gp_Pnt aMin = aBox.CornerMin();
2048 gp_Pnt aMax = aBox.CornerMax();
2050 Graphic3d_Vec3 aMinVec ((Standard_ShortReal )aMin.X(), (Standard_ShortReal )aMin.Y(), (Standard_ShortReal )aMin.Z());
2051 Graphic3d_Vec3 aMaxVec ((Standard_ShortReal )aMax.X(), (Standard_ShortReal )aMax.Y(), (Standard_ShortReal )aMax.Z());
2052 const Handle(Graphic3d_GraphicDriver)& aDriver = theView->GraphicDriver();
2053 aDriver->GraduatedTrihedronMinMaxValues (*aCView, aMinVec, aMaxVec);
2058 // =======================================================================
2059 // function : GetGraduatedTrihedron
2061 // =======================================================================
2062 const Graphic3d_GraduatedTrihedron& Visual3d_View::GetGraduatedTrihedron() const
2064 return myGTrihedron;
2067 // =======================================================================
2068 // function : GraduatedTrihedronDisplay
2070 // =======================================================================
2071 void Visual3d_View::GraduatedTrihedronDisplay (const Graphic3d_GraduatedTrihedron& theTrihedronData)
2073 myGTrihedron = theTrihedronData;
2075 myGTrihedron.PtrVisual3dView = this;
2076 myGTrihedron.CubicAxesCallback = SetMinMaxValuesCallback;
2078 myGraphicDriver->GraduatedTrihedronDisplay (MyCView, myGTrihedron);
2081 // =======================================================================
2082 // function : GraduatedTrihedronErase
2084 // =======================================================================
2085 void Visual3d_View::GraduatedTrihedronErase()
2087 myGTrihedron.PtrVisual3dView = NULL;
2088 myGraphicDriver->GraduatedTrihedronErase (MyCView);
2091 // =======================================================================
2092 // function : UnderLayer
2094 // =======================================================================
2095 const Handle(Visual3d_Layer)& Visual3d_View::UnderLayer() const
2097 return myViewManager->UnderLayer();
2100 // =======================================================================
2101 // function : OverLayer
2103 // =======================================================================
2104 const Handle(Visual3d_Layer)& Visual3d_View::OverLayer() const
2106 return myViewManager->OverLayer();
2109 // =======================================================================
2110 // function : LightLimit
2112 // =======================================================================
2113 Standard_Integer Visual3d_View::LightLimit() const
2115 return myGraphicDriver->InquireLightLimit();
2118 // =======================================================================
2119 // function : PlaneLimit
2121 // =======================================================================
2122 Standard_Integer Visual3d_View::PlaneLimit() const
2124 return myGraphicDriver->InquirePlaneLimit();
2127 // =======================================================================
2128 // function : ViewManager
2130 // =======================================================================
2131 Handle(Visual3d_ViewManager) Visual3d_View::ViewManager() const
2133 return myViewManager;
2136 // =======================================================================
2137 // function : SetComputedMode
2139 // =======================================================================
2140 void Visual3d_View::SetComputedMode (const Standard_Boolean theMode)
2142 if (( theMode && myIsInComputedMode)
2143 || (!theMode && !myIsInComputedMode))
2148 myIsInComputedMode = theMode;
2149 if (!myIsInComputedMode)
2151 for (Graphic3d_MapOfStructure::Iterator aStructIter (myStructsDisplayed); aStructIter.More(); aStructIter.Next())
2153 const Handle(Graphic3d_Structure)& aStruct = aStructIter.Key();
2154 const Visual3d_TypeOfAnswer anAnswer = acceptDisplay (aStruct->Visual());
2155 if (anAnswer != Visual3d_TOA_COMPUTE)
2160 const Standard_Integer anIndex = IsComputed (aStruct);
2163 const Handle(Graphic3d_Structure)& aStructComp = myStructsComputed.Value (anIndex);
2164 myGraphicDriver->EraseStructure (MyCView, aStructComp);
2165 myGraphicDriver->DisplayStructure (MyCView, aStruct, aStruct->DisplayPriority());
2171 for (Graphic3d_MapOfStructure::Iterator aDispStructIter (myStructsDisplayed); aDispStructIter.More(); aDispStructIter.Next())
2173 Handle(Graphic3d_Structure) aStruct = aDispStructIter.Key();
2174 const Visual3d_TypeOfAnswer anAnswer = acceptDisplay (aStruct->Visual());
2175 if (anAnswer != Visual3d_TOA_COMPUTE)
2180 const Standard_Integer anIndex = IsComputed (aStruct);
2183 myGraphicDriver->EraseStructure (MyCView, aStruct);
2184 myGraphicDriver->DisplayStructure (MyCView, myStructsComputed.Value (anIndex), aStruct->DisplayPriority());
2186 Display (aStruct, Aspect_TOU_WAIT);
2187 if (aStruct->IsHighlighted())
2189 const Handle(Graphic3d_Structure)& aCompStruct = myStructsComputed.Value (anIndex);
2190 if (!aCompStruct->IsHighlighted())
2192 aCompStruct->Highlight (Aspect_TOHM_COLOR, aStruct->HighlightColor(), Standard_False);
2198 TColStd_Array2OfReal aTrsf (0, 3, 0, 3);
2199 aStruct->Transform (aTrsf);
2200 Handle(Graphic3d_Structure) aCompStruct = aStruct->IsTransformed() ? aStruct->Compute (this, aTrsf) : aStruct->Compute (this);
2201 aCompStruct->SetHLRValidation (Standard_True);
2203 const Visual3d_TypeOfVisualization aViewType = MyContext.Visualization();
2204 const Standard_Boolean toComputeWireframe = aViewType == Visual3d_TOV_WIREFRAME
2205 && aStruct->ComputeVisual() != Graphic3d_TOS_SHADING;
2206 const Standard_Boolean toComputeShading = aViewType == Visual3d_TOV_SHADING
2207 && aStruct->ComputeVisual() != Graphic3d_TOS_WIREFRAME;
2208 if (toComputeWireframe) aCompStruct->SetVisual (Graphic3d_TOS_WIREFRAME);
2209 if (toComputeShading ) aCompStruct->SetVisual (Graphic3d_TOS_SHADING);
2211 if (aStruct->IsHighlighted())
2213 aCompStruct->Highlight (Aspect_TOHM_COLOR, aStruct->HighlightColor(), Standard_False);
2216 Standard_Boolean hasResult = Standard_False;
2217 const Standard_Integer aNbToCompute = myStructsToCompute.Length();
2218 const Standard_Integer aStructId = aStruct->Identification();
2219 for (Standard_Integer aToCompStructIter = 1; aToCompStructIter <= aNbToCompute; ++aToCompStructIter)
2221 if (myStructsToCompute.Value (aToCompStructIter)->Identification() == aStructId)
2223 hasResult = Standard_True;
2224 myStructsComputed.ChangeValue (aToCompStructIter) = aCompStruct;
2231 myStructsToCompute.Append (aStruct);
2232 myStructsComputed .Append (aCompStruct);
2235 myGraphicDriver->EraseStructure (MyCView, aStruct);
2236 myGraphicDriver->DisplayStructure (MyCView, aCompStruct, aStruct->DisplayPriority());
2239 Update (myViewManager->UpdateMode());
2242 // =======================================================================
2243 // function : ComputedMode
2245 // =======================================================================
2246 Standard_Boolean Visual3d_View::ComputedMode() const
2248 return myIsInComputedMode;
2251 // =======================================================================
2252 // function : SetBackFacingModel
2254 // =======================================================================
2255 void Visual3d_View::SetBackFacingModel (const Visual3d_TypeOfBackfacingModel theModel)
2260 case Visual3d_TOBM_AUTOMATIC:
2261 MyCView.Backfacing = 0;
2263 case Visual3d_TOBM_FORCE:
2264 MyCView.Backfacing = 1;
2266 case Visual3d_TOBM_DISABLE:
2267 MyCView.Backfacing = -1;
2270 myGraphicDriver->SetBackFacingModel (MyCView);
2273 // =======================================================================
2274 // function : BackFacingModel
2276 // =======================================================================
2277 Visual3d_TypeOfBackfacingModel Visual3d_View::BackFacingModel() const
2279 switch (MyCView.Backfacing)
2281 case 0: return Visual3d_TOBM_AUTOMATIC;
2282 case 1: return Visual3d_TOBM_FORCE;
2284 return Visual3d_TOBM_DISABLE;
2287 // =======================================================================
2288 // function : ReadDepths
2290 // =======================================================================
2291 void Visual3d_View::ReadDepths (const Standard_Integer theX,
2292 const Standard_Integer theY,
2293 const Standard_Integer theWidth,
2294 const Standard_Integer theHeight,
2295 const Standard_Address theBuffer) const
2297 myGraphicDriver->ReadDepths (MyCView, theX, theY, theWidth, theHeight, theBuffer);
2300 // =======================================================================
2301 // function : FBOCreate
2303 // =======================================================================
2304 Graphic3d_PtrFrameBuffer Visual3d_View::FBOCreate(const Standard_Integer theWidth,
2305 const Standard_Integer theHeight)
2307 return myGraphicDriver->FBOCreate( MyCView, theWidth, theHeight );
2310 // =======================================================================
2311 // function : FBORelease
2313 // =======================================================================
2314 void Visual3d_View::FBORelease(Graphic3d_PtrFrameBuffer& theFBOPtr)
2316 myGraphicDriver->FBORelease( MyCView, theFBOPtr );
2319 // =======================================================================
2320 // function : FBOGetDimensions
2322 // =======================================================================
2323 void Visual3d_View::FBOGetDimensions(const Graphic3d_PtrFrameBuffer theFBOPtr,
2324 Standard_Integer& theWidth, Standard_Integer& theHeight,
2325 Standard_Integer& theWidthMax, Standard_Integer& theHeightMax)
2327 myGraphicDriver->FBOGetDimensions( MyCView, theFBOPtr,
2328 theWidth, theHeight,
2329 theWidthMax, theHeightMax );
2332 // =======================================================================
2333 // function : FBOChangeViewport
2335 // =======================================================================
2336 void Visual3d_View::FBOChangeViewport(Graphic3d_PtrFrameBuffer& theFBOPtr,
2337 const Standard_Integer theWidth, const Standard_Integer theHeight)
2339 myGraphicDriver->FBOChangeViewport( MyCView, theFBOPtr,
2340 theWidth, theHeight );
2343 // =======================================================================
2344 // function : BufferDump
2346 // =======================================================================
2347 Standard_Boolean Visual3d_View::BufferDump (Image_PixMap& theImage,
2348 const Graphic3d_BufferType& theBufferType)
2350 return myGraphicDriver->BufferDump (MyCView, theImage, theBufferType);
2353 // =======================================================================
2354 // function : EnableGLLight
2356 // =======================================================================
2357 void Visual3d_View::EnableGLLight( const Standard_Boolean enable ) const
2359 myGraphicDriver->SetGLLightEnabled( MyCView, enable );
2362 // =======================================================================
2363 // function : IsGLLightEnabled
2365 // =======================================================================
2366 Standard_Boolean Visual3d_View::IsGLLightEnabled() const
2368 return myGraphicDriver->IsGLLightEnabled( MyCView );
2371 // =======================================================================
2372 // function : Export
2374 // =======================================================================
2375 Standard_Boolean Visual3d_View::Export (const Standard_CString theFileName,
2376 const Graphic3d_ExportFormat theFormat,
2377 const Graphic3d_SortType theSortType,
2378 const Standard_Real thePrecision,
2379 const Standard_Address theProgressBarFunc,
2380 const Standard_Address theProgressObject) const
2382 Handle(Visual3d_Layer) anUnderLayer = myViewManager->UnderLayer();
2383 Handle(Visual3d_Layer) anOverLayer = myViewManager->OverLayer();
2385 Aspect_CLayer2d anOverCLayer;
2386 Aspect_CLayer2d anUnderCLayer;
2387 anOverCLayer.ptrLayer = anUnderCLayer.ptrLayer = NULL;
2389 if (!anOverLayer.IsNull())
2390 anOverCLayer = anOverLayer->CLayer();
2391 if (!anUnderLayer.IsNull())
2392 anUnderCLayer = anUnderLayer->CLayer();
2394 Standard_Integer aWidth, aHeight;
2395 Window()->Size (aWidth, aHeight);
2397 return myGraphicDriver->Export (theFileName, theFormat, theSortType,
2398 aWidth, aHeight, MyCView, anUnderCLayer, anOverCLayer,
2399 thePrecision, theProgressBarFunc, theProgressObject);
2402 // =======================================================================
2403 // function : SetZLayerSettings
2405 // =======================================================================
2406 void Visual3d_View::SetZLayerSettings (const Graphic3d_ZLayerId theLayerId,
2407 const Graphic3d_ZLayerSettings& theSettings)
2409 myGraphicDriver->SetZLayerSettings (MyCView, theLayerId, theSettings);
2412 // =======================================================================
2413 // function : AddZLayer
2415 // =======================================================================
2416 void Visual3d_View::AddZLayer (const Graphic3d_ZLayerId theLayerId)
2418 myGraphicDriver->AddZLayer (MyCView, theLayerId);
2421 // =======================================================================
2422 // function : RemoveZLayer
2424 // =======================================================================
2425 void Visual3d_View::RemoveZLayer (const Graphic3d_ZLayerId theLayerId)
2427 myGraphicDriver->RemoveZLayer (MyCView, theLayerId);
2430 // =======================================================================
2431 // function : ChangeZLayer
2433 // =======================================================================
2434 void Visual3d_View::ChangeZLayer (const Handle(Graphic3d_Structure)& theStructure,
2435 const Graphic3d_ZLayerId theLayerId)
2437 myGraphicDriver->ChangeZLayer (*(theStructure->CStructure()), MyCView, theLayerId);
2440 // =======================================================================
2443 // =======================================================================
2444 Standard_Boolean Visual3d_View::Print (const Aspect_Handle thePrintDC,
2445 const Standard_Boolean theToShowBackground,
2446 const Standard_CString theFilename,
2447 const Aspect_PrintAlgo thePrintAlgorithm,
2448 const Standard_Real theScaleFactor) const
2450 return Print (myViewManager->UnderLayer(),
2451 myViewManager->OverLayer(),
2452 thePrintDC, theToShowBackground,
2453 theFilename, thePrintAlgorithm,
2457 // =======================================================================
2460 // =======================================================================
2461 Standard_Boolean Visual3d_View::Print (const Handle(Visual3d_Layer)& theUnderLayer,
2462 const Handle(Visual3d_Layer)& theOverLayer,
2463 const Aspect_Handle thePrintDC,
2464 const Standard_Boolean theToShowBackground,
2465 const Standard_CString theFilename,
2466 const Aspect_PrintAlgo thePrintAlgorithm,
2467 const Standard_Real theScaleFactor) const
2472 || !MyWindow->IsMapped())
2474 return Standard_False;
2477 Aspect_CLayer2d anOverCLayer;
2478 Aspect_CLayer2d anUnderCLayer;
2479 anOverCLayer.ptrLayer = anUnderCLayer.ptrLayer = NULL;
2480 if (!theOverLayer.IsNull()) anOverCLayer = theOverLayer->CLayer();
2481 if (!theUnderLayer.IsNull()) anUnderCLayer = theUnderLayer->CLayer();
2482 return myGraphicDriver->Print (MyCView, anUnderCLayer, anOverCLayer,
2483 thePrintDC, theToShowBackground, theFilename,
2484 thePrintAlgorithm, theScaleFactor);
2487 //=============================================================================
2488 //function : HiddenObjects
2490 //=============================================================================
2491 const Handle(Graphic3d_NMapOfTransient)& Visual3d_View::HiddenObjects() const
2493 return myHiddenObjects;
2496 //=============================================================================
2497 //function : HiddenObjects
2499 //=============================================================================
2500 Handle(Graphic3d_NMapOfTransient)& Visual3d_View::ChangeHiddenObjects()
2502 return myHiddenObjects;