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.
19 #include <Visual3d_View.ixx>
21 #include <Graphic3d_DataStructureManager.hxx>
22 #include <Graphic3d_GraphicDriver.hxx>
23 #include <Graphic3d_MapOfStructure.hxx>
24 #include <Graphic3d_MapIteratorOfMapOfStructure.hxx>
25 #include <Graphic3d_Structure.hxx>
26 #include <Graphic3d_TextureEnv.hxx>
27 #include <Graphic3d_Vector.hxx>
28 #include <Graphic3d_Vertex.hxx>
29 #include <Visual3d_DepthCueingDefinitionError.hxx>
30 #include <Visual3d_Light.hxx>
31 #include <Visual3d_ZClippingDefinitionError.hxx>
33 #include <TColStd_HArray2OfReal.hxx>
36 #include <WNT_Window.hxx>
37 #elif (defined(__APPLE__) && !defined(MACOSX_USE_GLX))
38 #include <Cocoa_Window.hxx>
40 #include <Xw_Window.hxx>
45 // =======================================================================
46 // function : Visual3d_View
48 // =======================================================================
49 Visual3d_View::Visual3d_View (const Handle(Visual3d_ViewManager)& theMgr)
50 : myViewManager (theMgr.operator->()),
51 myIsInComputedMode (Standard_False),
52 myAutoZFitIsOn (Standard_True),
53 myAutoZFitScaleFactor (1.0),
54 myStructuresUpdated (Standard_True)
56 myHiddenObjects = new Graphic3d_NMapOfTransient();
58 MyCView.ViewId = theMgr->Identification (this);
60 MyCView.IsDeleted = 0;
62 MyCView.DefWindow.IsDefined = 0;
63 MyCView.Context.NbActiveLight = 0;
65 MyCView.Backfacing = 0;
66 MyCView.ptrUnderLayer = 0;
67 MyCView.ptrOverLayer = 0;
69 MyCView.GDisplayCB = 0;
70 MyCView.GClientData = 0;
72 myGraphicDriver = myViewManager->GraphicDriver();
75 // =======================================================================
76 // function : SetWindow
78 // =======================================================================
79 void Visual3d_View::SetWindow (const Handle(Aspect_Window)& theWindow,
80 const Aspect_RenderingContext theContext,
81 const Aspect_GraphicCallbackProc& theDisplayCB,
82 const Standard_Address theClientData)
89 MyCView.GContext = theContext;
90 MyCView.GDisplayCB = theDisplayCB;
91 MyCView.GClientData = theClientData;
92 SetWindow (theWindow);
95 // =======================================================================
96 // function : SetWindow
98 // =======================================================================
99 void Visual3d_View::SetWindow (const Handle(Aspect_Window)& theWindow)
106 MyWindow = theWindow;
107 MyCView.WsId = MyCView.ViewId;
108 MyCView.DefWindow.IsDefined = 1;
109 MyCView.DefWindow.XWindow = theWindow->NativeHandle();
110 MyCView.DefWindow.XParentWindow = theWindow->NativeParentHandle();
112 Standard_Integer aWidth = 0, aHeight = 0, aLeft = 0, aTop = 0;
113 theWindow->Position (aLeft, aTop, aWidth, aHeight);
114 theWindow->Size (aWidth, aHeight);
115 MyCView.DefWindow.left = aLeft;
116 MyCView.DefWindow.top = aTop;
117 MyCView.DefWindow.dx = aWidth;
118 MyCView.DefWindow.dy = aHeight;
120 Standard_Real R, G, B;
121 MyBackground = MyWindow->Background ();
122 MyBackground.Color().Values (R, G, B, Quantity_TOC_RGB);
123 MyCView.DefWindow.Background.r = float (R);
124 MyCView.DefWindow.Background.g = float (G);
125 MyCView.DefWindow.Background.b = float (B);
128 if (!myGraphicDriver->View (MyCView))
130 Visual3d_ViewDefinitionError::Raise ("Association failed");
133 MyGradientBackground = MyWindow->GradientBackground();
134 SetGradientBackground(MyGradientBackground,1);
136 Standard_Boolean AWait = Standard_False; // => immediate update
137 myGraphicDriver->SetVisualisation (MyCView);
138 myGraphicDriver->AntiAliasing (MyCView, MyContext.AliasingIsOn());
139 myGraphicDriver->DepthCueing (MyCView, MyContext.DepthCueingIsOn());
140 myGraphicDriver->ClipLimit (MyCView, AWait);
141 myGraphicDriver->Environment (MyCView);
143 // Make view manager z layer list consistent with the view's list.
144 myViewManager->InstallZLayers (this);
146 // Update planses of model clipping
149 // Update light sources
152 // Association view-window does not cause the display
153 // of structures that can be displayed in the new view.
154 // In fact, association view-window is done, but the
155 // display is produced only if the view is activated (Activate).
159 const Handle(Graphic3d_Camera)& aCamera = MyCView.Context.Camera;
160 if (!aCamera.IsNull())
162 aCamera->InvalidateProjection();
163 aCamera->InvalidateOrientation();
167 // =======================================================================
170 // =======================================================================
171 Handle(Aspect_Window) Visual3d_View::Window() const
175 Visual3d_ViewDefinitionError::Raise ("Window not defined");
180 // =======================================================================
181 // function : IsDefined
183 // =======================================================================
184 Standard_Boolean Visual3d_View::IsDefined() const
186 return MyCView.DefWindow.IsDefined != 0;
189 // =======================================================================
190 // function : IsDeleted
192 // =======================================================================
193 Standard_Boolean Visual3d_View::IsDeleted() const
195 return MyCView.IsDeleted != 0;
198 // =======================================================================
199 // function : Destroy
201 // =======================================================================
202 void Visual3d_View::Destroy()
204 // Since myViewManager can be already destroyed,
205 // avoid attempts to access it in SetBackground()
206 myViewManager = NULL;
210 // =======================================================================
213 // =======================================================================
214 void Visual3d_View::Remove()
222 myStructsToCompute.Clear();
223 myStructsComputed .Clear();
224 myStructsDisplayed.Clear();
226 Aspect_GradientBackground aBlackGrad;
227 SetBackground (Aspect_Background (Quantity_NOC_BLACK));
228 SetGradientBackground (aBlackGrad, Standard_False);
230 if (myViewManager != NULL)
232 myViewManager->UnIdentification (MyCView.ViewId);
235 myGraphicDriver->RemoveView (MyCView);
238 MyCView.IsDeleted = 1;
239 MyCView.DefWindow.IsDefined = 0;
244 // =======================================================================
245 // function : Resized
247 // =======================================================================
248 void Visual3d_View::Resized()
254 else if (!IsDefined())
256 Visual3d_ViewDefinitionError::Raise ("Window not defined");
258 MyWindow->DoResize();
262 // =======================================================================
263 // function : SetRatio
265 // =======================================================================
266 void Visual3d_View::SetRatio()
273 const Aspect_TypeOfUpdate anUpdateMode = myViewManager->UpdateMode();
274 myViewManager->SetUpdateMode (Aspect_TOU_WAIT);
276 Standard_Integer aWidth = 0, aHeight = 0, aLeft = 0, aTop = 0;
277 MyWindow->Position (aLeft, aTop, aWidth, aHeight);
278 MyCView.DefWindow.left = aLeft;
279 MyCView.DefWindow.top = aTop;
281 MyWindow->Size (aWidth, aHeight);
282 if (aWidth > 0 && aHeight > 0)
284 Standard_Real aRatio = (Standard_Real)aWidth / (Standard_Real)aHeight;
286 MyCView.DefWindow.dx = aWidth;
287 MyCView.DefWindow.dy = aHeight;
289 myGraphicDriver->RatioWindow (MyCView);
291 // Update camera aspect
292 const Handle(Graphic3d_Camera)& aCamera = MyCView.Context.Camera;
293 if (!aCamera.IsNull())
295 aCamera->SetAspect (aRatio);
298 if (!myDefaultCamera.IsNull())
300 myDefaultCamera->SetAspect (aRatio);
304 myViewManager->SetUpdateMode (anUpdateMode);
305 Update (anUpdateMode);
308 // =======================================================================
309 // function : UpdateLights
311 // =======================================================================
312 void Visual3d_View::UpdateLights()
320 if (MyContext.Model() == Visual3d_TOM_NONE)
322 // activate only a white ambient light
323 Graphic3d_CLight aCLight;
324 aCLight.Type = Visual3d_TOLS_AMBIENT;
325 aCLight.IsHeadlight = Standard_False;
326 aCLight.Color.r() = aCLight.Color.g() = aCLight.Color.b() = 1.0f;
328 MyCView.Context.NbActiveLight = 1;
329 MyCView.Context.ActiveLight = &aCLight;
330 myGraphicDriver->SetLight (MyCView);
331 MyCView.Context.ActiveLight = NULL;
335 MyCView.Context.NbActiveLight = Min (MyContext.NumberOfActivatedLights(),
336 myGraphicDriver->InquireLightLimit());
337 if (MyCView.Context.NbActiveLight < 1)
339 myGraphicDriver->SetLight (MyCView);
343 // parcing of light sources
344 MyCView.Context.ActiveLight = new Graphic3d_CLight[MyCView.Context.NbActiveLight];
345 for (Standard_Integer aLightIter = 0; aLightIter < MyCView.Context.NbActiveLight; ++aLightIter)
347 MyCView.Context.ActiveLight[aLightIter] = MyContext.ActivatedLight (aLightIter + 1)->CLight();
349 myGraphicDriver->SetLight (MyCView);
350 delete[] MyCView.Context.ActiveLight;
351 MyCView.Context.ActiveLight = NULL;
354 // =======================================================================
355 // function : UpdatePlanes
357 // =======================================================================
358 void Visual3d_View::UpdatePlanes()
360 MyCView.Context.ClipPlanes = MyContext.ClipPlanes();
361 if (IsDeleted() || !IsDefined())
366 myGraphicDriver->SetClipPlanes (MyCView);
369 // =======================================================================
370 // function : SetBackground
372 // =======================================================================
373 void Visual3d_View::SetBackground (const Aspect_Background& theBack)
379 else if (!IsDefined())
381 Visual3d_ViewDefinitionError::Raise ("Window not defined");
384 // At this level, only GL can update the background.
385 // It is not necessary to call MyWindow->SetBackground (ABack); as
386 // this method starts update of window background by X
387 // (if the windowing is X)
389 Standard_Real R, G, B;
390 MyBackground = theBack;
391 MyBackground.Color().Values (R, G, B, Quantity_TOC_RGB);
392 MyCView.DefWindow.Background.r = float (R);
393 MyCView.DefWindow.Background.g = float (G);
394 MyCView.DefWindow.Background.b = float (B);
396 myGraphicDriver->Background (MyCView);
398 if (myViewManager != NULL)
400 Update (myViewManager->UpdateMode());
404 // =======================================================================
405 // function : SetGradientBackground
407 // =======================================================================
408 void Visual3d_View::SetGradientBackground (const Aspect_GradientBackground& theBack,
409 const Standard_Boolean theToUpdate)
415 else if (!IsDefined())
417 Visual3d_ViewDefinitionError::Raise ("Window not defined");
420 MyGradientBackground = theBack;
421 Quantity_Color aCol1, aCol2;
422 MyGradientBackground.Colors (aCol1, aCol2);
423 myGraphicDriver->GradientBackground (MyCView, aCol1, aCol2, MyGradientBackground.BgGradientFillMethod());
427 Update (Aspect_TOU_ASAP);
429 else if (myViewManager != NULL)
431 Update (myViewManager->UpdateMode());
435 // =======================================================================
436 // function : SetBackgroundImage
438 // =======================================================================
439 void Visual3d_View::SetBackgroundImage (const Standard_CString theFileName,
440 const Aspect_FillMethod theFillStyle,
441 const Standard_Boolean theToUpdate)
449 Visual3d_ViewDefinitionError::Raise ("Window not defined");
452 myGraphicDriver->BackgroundImage (theFileName, MyCView, theFillStyle);
454 Update (theToUpdate ? Aspect_TOU_ASAP : myViewManager->UpdateMode());
457 // =======================================================================
458 // function : SetBgImageStyle
460 // =======================================================================
461 void Visual3d_View::SetBgImageStyle (const Aspect_FillMethod theFillStyle,
462 const Standard_Boolean theToUpdate)
470 Visual3d_ViewDefinitionError::Raise ("Window not defined");
473 myGraphicDriver->SetBgImageStyle (MyCView, theFillStyle);
475 Update (theToUpdate ? Aspect_TOU_ASAP : myViewManager->UpdateMode());
478 // =======================================================================
479 // function : Background
481 // =======================================================================
482 Aspect_Background Visual3d_View::Background() const
487 // =======================================================================
488 // function : SetBgGradientStyle
490 // =======================================================================
491 void Visual3d_View::SetBgGradientStyle (const Aspect_GradientFillMethod theFillStyle,
492 const Standard_Boolean theToUpdate)
498 else if (!IsDefined())
500 Visual3d_ViewDefinitionError::Raise ("Window not defined");
503 myGraphicDriver->SetBgGradientStyle (MyCView, theFillStyle);
505 Update (theToUpdate ? Aspect_TOU_ASAP : myViewManager->UpdateMode());
508 // =======================================================================
509 // function : GradientBackground
511 // =======================================================================
512 Aspect_GradientBackground Visual3d_View::GradientBackground() const
514 return MyGradientBackground;
517 // =======================================================================
518 // function : DefaultCamera
520 // =======================================================================
521 const Handle(Graphic3d_Camera)& Visual3d_View::DefaultCamera() const
523 return myDefaultCamera;
526 // =======================================================================
529 // =======================================================================
530 const Handle(Graphic3d_Camera)& Visual3d_View::Camera() const
532 return MyCView.Context.Camera;
535 // =======================================================================
536 // function : SetCamera
538 // =======================================================================
539 void Visual3d_View::SetCamera (const Handle(Graphic3d_Camera)& theCamera)
541 MyCView.Context.Camera = theCamera;
543 myGraphicDriver->SetCamera (MyCView);
545 Update (myViewManager->UpdateMode());
548 // =======================================================================
549 // function : SetViewOrientationDefault
551 // =======================================================================
552 void Visual3d_View::SetViewOrientationDefault()
554 if (myDefaultCamera.IsNull())
556 myDefaultCamera = new Graphic3d_Camera();
559 myDefaultCamera->CopyOrientationData (MyCView.Context.Camera);
562 // =======================================================================
563 // function : ViewOrientationReset
565 // =======================================================================
566 void Visual3d_View::ViewOrientationReset()
573 if (!myDefaultCamera.IsNull())
575 MyCView.Context.Camera->CopyOrientationData (myDefaultCamera);
578 Update (myViewManager->UpdateMode());
581 // =======================================================================
582 // function : SetViewMappingDefault
584 // =======================================================================
585 void Visual3d_View::SetViewMappingDefault()
587 if (myDefaultCamera.IsNull())
589 myDefaultCamera = new Graphic3d_Camera();
591 myDefaultCamera->CopyMappingData (MyCView.Context.Camera);
594 // =======================================================================
595 // function : ViewMappingReset
597 // =======================================================================
598 void Visual3d_View::ViewMappingReset()
605 if (!myDefaultCamera.IsNull())
607 MyCView.Context.Camera->CopyMappingData (myDefaultCamera);
610 Update (myViewManager->UpdateMode());
613 // =======================================================================
614 // function : SetContext
616 // =======================================================================
617 void Visual3d_View::SetContext (const Visual3d_ContextView& theViewCtx)
624 // To manage display only in case of change of visualisation mode
625 const bool isVisModeChanged = theViewCtx.Visualization() != MyContext.Visualization();
626 const bool isModelChanged = theViewCtx.Model() != MyContext.Model();
628 // To manage antialiasing only in case of change
629 const Standard_Boolean anAliasingModeOld = MyContext.AliasingIsOn();
630 const Standard_Boolean anAliasingModeNew = theViewCtx.AliasingIsOn();
632 // To manage the depth cueing only in case of change
633 const Standard_Boolean aDepthCueingModeOld = MyContext.DepthCueingIsOn();
634 const Standard_Boolean aDepthCueingModeNew = theViewCtx.DepthCueingIsOn();
636 const Standard_Real aDepthCueingFrontPlaneOld = MyContext.DepthCueingFrontPlane();
637 const Standard_Real aDepthCueingFrontPlaneNew = theViewCtx.DepthCueingFrontPlane();
638 const Standard_Real aDepthCueingBackPlaneOld = MyContext.DepthCueingBackPlane();
639 const Standard_Real aDepthCueingBackPlaneNew = theViewCtx.DepthCueingBackPlane();
641 // To manage the Zclipping only in case of change
642 const Standard_Boolean aFrontZClippingModeOld = MyContext.FrontZClippingIsOn();
643 const Standard_Boolean aFrontZClippingModeNew = theViewCtx.FrontZClippingIsOn();
644 const Standard_Boolean aBackZClippingModeOld = MyContext.BackZClippingIsOn();
645 const Standard_Boolean aBackZClippingModeNew = theViewCtx.BackZClippingIsOn();
647 const Standard_Real aZClippingFrontPlaneOld = MyContext.ZClippingFrontPlane();
648 const Standard_Real aZClippingFrontPlaneNew = theViewCtx.ZClippingFrontPlane();
649 const Standard_Real aZClippingBackPlaneOld = MyContext.ZClippingBackPlane();
650 const Standard_Real aZClippingBackPlaneNew = theViewCtx.ZClippingBackPlane();
652 const bool isTextEnvChanged = theViewCtx.TextureEnv() != MyContext.TextureEnv();
653 const bool isSurfDetailChanged = theViewCtx.SurfaceDetail() != MyContext.SurfaceDetail();
655 MyContext = theViewCtx;
659 Standard_Boolean toWait = Standard_False; // => immediate update
662 // management of visualization modes and types of shading.
666 myGraphicDriver->SetVisualisation (MyCView);
669 // management of antialiasing
670 if (anAliasingModeOld != anAliasingModeNew)
672 myGraphicDriver->AntiAliasing (MyCView, anAliasingModeNew);
675 // management of depth_cueing
676 if (aDepthCueingModeOld != aDepthCueingModeNew
677 || aDepthCueingFrontPlaneOld != aDepthCueingFrontPlaneNew
678 || aDepthCueingBackPlaneOld != aDepthCueingBackPlaneNew)
680 if (aDepthCueingModeNew
681 && aDepthCueingBackPlaneNew >= aDepthCueingFrontPlaneNew)
683 Visual3d_DepthCueingDefinitionError::Raise ("Bad value for DepthCueingPlanes position");
685 myGraphicDriver->DepthCueing (MyCView, aDepthCueingModeNew);
688 // management of Zclipping
689 if (aFrontZClippingModeOld != aFrontZClippingModeNew
690 || aBackZClippingModeOld != aBackZClippingModeNew
691 || aZClippingFrontPlaneOld != aZClippingFrontPlaneNew
692 || aZClippingBackPlaneOld != aZClippingBackPlaneNew)
694 if (aBackZClippingModeNew
695 && aFrontZClippingModeNew
696 && aZClippingBackPlaneNew >= aZClippingFrontPlaneNew)
698 Visual3d_ZClippingDefinitionError::Raise ("Bad value for ZClippingPlanes position");
701 myGraphicDriver->ClipLimit (MyCView, toWait);
704 // management of textures
706 || isSurfDetailChanged)
708 myGraphicDriver->Environment (MyCView);
711 UpdatePlanes(); // Update of planes of model clipping
712 UpdateLights(); // Update of light sources
715 if (isVisModeChanged)
717 // Change of context =>
718 // Remove structures that cannot be displayed in the new visualisation mode.
719 // It is not necessary to warn ViewManager as this structure should not disappear from
720 // the list of structures displayed in it.
721 NCollection_Sequence<Handle(Graphic3d_Structure)> aStructs;
722 for (Graphic3d_MapOfStructure::Iterator aStructIter (myStructsDisplayed); aStructIter.More(); aStructIter.Next())
724 const Handle(Graphic3d_Structure)& aStruct = aStructIter.Key();
725 const Visual3d_TypeOfAnswer anAnswer = acceptDisplay (aStruct->Visual());
726 if (anAnswer == Visual3d_TOA_NO
727 || anAnswer == Visual3d_TOA_COMPUTE)
729 aStructs.Append (aStruct);
732 for (NCollection_Sequence<Handle(Graphic3d_Structure)>::Iterator aStructIter (aStructs); aStructIter.More(); aStructIter.Next())
734 Erase (aStructIter.ChangeValue(), Aspect_TOU_WAIT);
738 // Change of context =>
739 // Display structures that can be displayed with the new visualisation mode.
740 // All structures with status Displayed are removed from the ViewManager
741 // and displayed in the view directly, if the structure is not already
742 // displayed and if the view accepts it in its context.
743 Graphic3d_MapOfStructure aMapDisplayed;
744 myViewManager->DisplayedStructures (aMapDisplayed);
745 for (Graphic3d_MapIteratorOfMapOfStructure aStructIter (aMapDisplayed); aStructIter.More(); aStructIter.Next())
747 const Handle(Graphic3d_Structure)& aStruct = aStructIter.Key();
748 if (IsDisplayed (aStruct))
753 const Visual3d_TypeOfAnswer anAnswer = acceptDisplay (aStruct->Visual());
754 if (anAnswer == Visual3d_TOA_YES
755 || anAnswer == Visual3d_TOA_COMPUTE)
757 aStructs.Append (aStruct);
761 for (NCollection_Sequence<Handle(Graphic3d_Structure)>::Iterator aStructIter (aStructs); aStructIter.More(); aStructIter.Next())
763 Display (aStructIter.ChangeValue(), Aspect_TOU_WAIT);
767 Update (myViewManager->UpdateMode());
770 // =======================================================================
771 // function : Context
773 // =======================================================================
774 const Visual3d_ContextView& Visual3d_View::Context() const
779 // =======================================================================
780 // function : DisplayedStructures
782 // =======================================================================
783 void Visual3d_View::DisplayedStructures (Graphic3d_MapOfStructure& theStructures) const
790 for (Graphic3d_MapOfStructure::Iterator aStructIter (myStructsDisplayed); aStructIter.More(); aStructIter.Next())
792 theStructures.Add (aStructIter.Key());
796 // =======================================================================
797 // function : Activate
799 // =======================================================================
800 void Visual3d_View::Activate()
806 else if (!IsDefined())
808 Visual3d_ViewDefinitionError::Raise ("Window not defined");
813 myGraphicDriver->ActivateView (MyCView);
814 myGraphicDriver->Background (MyCView);
818 // Activation of a new view =>
819 // Display structures that can be displayed in this new view.
820 // All structures with status
821 // Displayed in ViewManager are returned and displayed in
822 // the view directly, if the structure is not already
823 // displayed and if the view accepts it in its context.
824 Graphic3d_MapOfStructure aDisplayedStructs;
825 myViewManager->DisplayedStructures (aDisplayedStructs);
826 for (Graphic3d_MapIteratorOfMapOfStructure aStructIter (aDisplayedStructs); aStructIter.More(); aStructIter.Next())
828 const Handle(Graphic3d_Structure)& aStruct = aStructIter.Key();
829 if (IsDisplayed (aStruct))
834 // If the structure can be displayed in the new context of the view, it is displayed.
835 const Visual3d_TypeOfAnswer anAnswer = acceptDisplay (aStruct->Visual());
836 if (anAnswer == Visual3d_TOA_YES
837 || anAnswer == Visual3d_TOA_COMPUTE)
839 Display (aStruct, Aspect_TOU_WAIT);
844 Update (myViewManager->UpdateMode());
847 // =======================================================================
848 // function : IsActive
850 // =======================================================================
851 Standard_Boolean Visual3d_View::IsActive() const
857 // =======================================================================
858 // function : Deactivate
860 // =======================================================================
861 void Visual3d_View::Deactivate()
867 else if (!IsDefined())
869 Visual3d_ViewDefinitionError::Raise ("Window not defined");
874 myGraphicDriver->DeactivateView (MyCView);
876 // Deactivation of a view =>
877 // Removal of structures displayed in this view.
878 // All structures with status
879 // Displayed in ViewManager are returned and removed from
880 // the view directly, if the structure is not already
881 // displayed and if the view accepts it in its context.
882 Graphic3d_MapOfStructure aDisplayedStructs;
883 myViewManager->DisplayedStructures (aDisplayedStructs);
884 for (Graphic3d_MapIteratorOfMapOfStructure aStructIter (aDisplayedStructs); aStructIter.More(); aStructIter.Next())
886 const Handle(Graphic3d_Structure)& aStruct = aStructIter.Key();
887 if (IsDisplayed (aStruct))
892 const Visual3d_TypeOfAnswer anAnswer = acceptDisplay (aStruct->Visual());
893 if (anAnswer == Visual3d_TOA_YES
894 || anAnswer == Visual3d_TOA_COMPUTE)
896 Erase (aStruct, Aspect_TOU_WAIT);
900 Update (myViewManager->UpdateMode());
901 MyCView.Active = 0; // No action currently possible in the view
905 // =======================================================================
908 // =======================================================================
909 void Visual3d_View::Redraw()
911 Redraw (myViewManager->UnderLayer(), myViewManager->OverLayer(), 0, 0, 0, 0);
914 // =======================================================================
917 // =======================================================================
918 void Visual3d_View::Redraw (const Standard_Integer theX,
919 const Standard_Integer theY,
920 const Standard_Integer theWidth,
921 const Standard_Integer theHeight)
923 Redraw (myViewManager->UnderLayer(), myViewManager->OverLayer(),
924 theX, theY, theWidth, theHeight);
927 // =======================================================================
930 // =======================================================================
931 void Visual3d_View::Redraw (const Handle(Visual3d_Layer)& theUnderLayer,
932 const Handle(Visual3d_Layer)& theOverLayer)
934 Redraw (theUnderLayer, theOverLayer, 0, 0, 0, 0);
937 // =======================================================================
940 // =======================================================================
941 void Visual3d_View::Redraw (const Handle(Visual3d_Layer)& theUnderLayer,
942 const Handle(Visual3d_Layer)& theOverLayer,
943 const Standard_Integer theX,
944 const Standard_Integer theY,
945 const Standard_Integer theWidth,
946 const Standard_Integer theHeight)
951 || !MyWindow->IsMapped())
956 Aspect_CLayer2d anOverCLayer, anUnderCLayer;
957 anOverCLayer.ptrLayer = anUnderCLayer.ptrLayer = NULL;
958 if (!theOverLayer .IsNull()) anOverCLayer = theOverLayer ->CLayer();
959 if (!theUnderLayer.IsNull()) anUnderCLayer = theUnderLayer->CLayer();
961 for (Standard_Integer aRetryIter = 0; aRetryIter < 2; ++aRetryIter)
963 if (myGraphicDriver->IsDeviceLost())
965 myViewManager->RecomputeStructures();
966 myViewManager->RecomputeStructures (myImmediateStructures);
967 myGraphicDriver->ResetDeviceLostFlag();
970 if (myStructuresUpdated)
973 myStructuresUpdated = Standard_False;
976 myGraphicDriver->Redraw (MyCView, anUnderCLayer, anOverCLayer, theX, theY, theWidth, theHeight);
977 if (!myGraphicDriver->IsDeviceLost())
984 // =======================================================================
985 // function : RedrawImmediate
987 // =======================================================================
988 void Visual3d_View::RedrawImmediate()
990 RedrawImmediate (myViewManager->UnderLayer(), myViewManager->OverLayer());
993 // =======================================================================
994 // function : RedrawImmediate
996 // =======================================================================
997 void Visual3d_View::RedrawImmediate (const Handle(Visual3d_Layer)& theUnderLayer,
998 const Handle(Visual3d_Layer)& theOverLayer)
1003 || !MyWindow->IsMapped())
1008 Aspect_CLayer2d anOverCLayer, anUnderCLayer;
1009 anOverCLayer.ptrLayer = anUnderCLayer.ptrLayer = NULL;
1010 if (!theOverLayer .IsNull()) anOverCLayer = theOverLayer ->CLayer();
1011 if (!theUnderLayer.IsNull()) anUnderCLayer = theUnderLayer->CLayer();
1012 myGraphicDriver->RedrawImmediate (MyCView, anUnderCLayer, anOverCLayer);
1015 // =======================================================================
1016 // function : Invalidate
1018 // =======================================================================
1019 void Visual3d_View::Invalidate()
1021 myGraphicDriver->Invalidate (MyCView);
1024 // =======================================================================
1025 // function : Update
1027 // =======================================================================
1028 void Visual3d_View::Update (Aspect_TypeOfUpdate theUpdateMode)
1030 myStructuresUpdated = Standard_True;
1031 if (theUpdateMode == Aspect_TOU_ASAP)
1034 Redraw (myViewManager->UnderLayer(), myViewManager->OverLayer(), 0, 0, 0, 0);
1038 // =======================================================================
1039 // function : Update
1041 // =======================================================================
1042 void Visual3d_View::Update (const Handle(Visual3d_Layer)& theUnderLayer,
1043 const Handle(Visual3d_Layer)& theOverLayer)
1046 myStructuresUpdated = Standard_True;
1047 Redraw (theUnderLayer, theOverLayer, 0, 0, 0, 0);
1050 // ========================================================================
1051 // function : SetAutoZFitMode
1053 // ========================================================================
1054 void Visual3d_View::SetAutoZFitMode (const Standard_Boolean theIsOn,
1055 const Standard_Real theScaleFactor)
1057 Standard_ASSERT_RAISE (theScaleFactor > 0.0, "Zero or negative scale factor is not allowed.");
1058 myAutoZFitScaleFactor = theScaleFactor;
1059 myAutoZFitIsOn = theIsOn;
1062 // ========================================================================
1063 // function : AutoZFitMode
1065 // ========================================================================
1066 Standard_Boolean Visual3d_View::AutoZFitMode() const
1068 return myAutoZFitIsOn;
1071 // ========================================================================
1072 // function : AutoZFitScaleFactor
1074 // ========================================================================
1075 Standard_Real Visual3d_View::AutoZFitScaleFactor() const
1077 return myAutoZFitScaleFactor;
1080 // ========================================================================
1081 // function : AutoZFit
1083 // ========================================================================
1084 void Visual3d_View::AutoZFit()
1086 if (!AutoZFitMode())
1091 ZFitAll (myAutoZFitScaleFactor);
1094 // ========================================================================
1095 // function : ZFitAll
1097 // ========================================================================
1098 void Visual3d_View::ZFitAll (const Standard_Real theScaleFactor)
1100 Bnd_Box aMinMaxBox = MinMaxValues (Standard_False); // applicative min max boundaries
1101 Bnd_Box aGraphicBox = MinMaxValues (Standard_True); // real graphical boundaries (not accounting infinite flag).
1103 const Handle(Graphic3d_Camera)& aCamera = MyCView.Context.Camera;
1104 aCamera->ZFitAll (theScaleFactor, aMinMaxBox, aGraphicBox);
1107 // ========================================================================
1108 // function : acceptDisplay
1110 // ========================================================================
1111 Visual3d_TypeOfAnswer Visual3d_View::acceptDisplay (const Graphic3d_TypeOfStructure theStructType) const
1113 const Visual3d_TypeOfVisualization aViewType = MyContext.Visualization();
1114 switch (theStructType)
1116 case Graphic3d_TOS_ALL:
1118 return Visual3d_TOA_YES; // The structure accepts any type of view
1120 case Graphic3d_TOS_SHADING:
1122 return aViewType == Visual3d_TOV_SHADING
1126 case Graphic3d_TOS_WIREFRAME:
1128 return aViewType == Visual3d_TOV_WIREFRAME
1132 case Graphic3d_TOS_COMPUTED:
1134 return (aViewType == Visual3d_TOV_SHADING || aViewType == Visual3d_TOV_WIREFRAME)
1135 ? Visual3d_TOA_COMPUTE
1139 return Visual3d_TOA_NO;
1142 // ========================================================================
1143 // function : ChangeDisplayPriority
1145 // ========================================================================
1146 void Visual3d_View::ChangeDisplayPriority (const Handle(Graphic3d_Structure)& theStruct,
1147 const Standard_Integer /*theOldPriority*/,
1148 const Standard_Integer theNewPriority)
1153 || !IsDisplayed (theStruct))
1158 if (!myIsInComputedMode)
1160 myGraphicDriver->ChangePriority (*theStruct->CStructure(), MyCView, theNewPriority);
1164 const Standard_Integer anIndex = IsComputed (theStruct);
1165 const Graphic3d_CStructure& aCStruct = anIndex != 0
1166 ? *(myStructsComputed.Value (anIndex)->CStructure())
1167 : *theStruct->CStructure();
1168 myGraphicDriver->ChangePriority (aCStruct, MyCView, theNewPriority);
1171 // ========================================================================
1174 // ========================================================================
1175 void Visual3d_View::Clear (const Handle(Graphic3d_Structure)& theStruct,
1176 const Standard_Boolean theWithDestruction)
1178 const Standard_Integer anIndex = IsComputed (theStruct);
1181 const Handle(Graphic3d_Structure)& aCompStruct = myStructsComputed.Value (anIndex);
1182 aCompStruct->GraphicClear (theWithDestruction);
1183 aCompStruct->SetHLRValidation (Standard_False);
1187 // ========================================================================
1188 // function : Connect
1190 // ========================================================================
1191 void Visual3d_View::Connect (const Handle(Graphic3d_Structure)& theMother,
1192 const Handle(Graphic3d_Structure)& theDaughter)
1194 Standard_Integer anIndexM = IsComputed (theMother);
1195 Standard_Integer anIndexD = IsComputed (theDaughter);
1199 const Handle(Graphic3d_Structure)& aStructM = myStructsComputed.Value (anIndexM);
1200 const Handle(Graphic3d_Structure)& aStructD = myStructsComputed.Value (anIndexD);
1201 aStructM->GraphicConnect (aStructD);
1205 // ========================================================================
1206 // function : Disconnect
1208 // ========================================================================
1209 void Visual3d_View::Disconnect (const Handle(Graphic3d_Structure)& theMother,
1210 const Handle(Graphic3d_Structure)& theDaughter)
1212 Standard_Integer anIndexM = IsComputed (theMother);
1213 Standard_Integer anIndexD = IsComputed (theDaughter);
1217 const Handle(Graphic3d_Structure)& aStructM = myStructsComputed.Value (anIndexM);
1218 const Handle(Graphic3d_Structure)& aStructD = myStructsComputed.Value (anIndexD);
1219 aStructM->GraphicDisconnect (aStructD);
1223 // ========================================================================
1224 // function : DisplayImmediate
1226 // ========================================================================
1227 Standard_Boolean Visual3d_View::DisplayImmediate (const Handle(Graphic3d_Structure)& theStructure,
1228 const Standard_Boolean theIsSingleView)
1230 if (!myImmediateStructures.Add (theStructure))
1232 return Standard_False;
1235 if (theIsSingleView)
1237 const Visual3d_SequenceOfView& aViews = myViewManager->DefinedViews();
1238 for (Standard_Integer aViewIter = 1; aViewIter <= aViews.Length(); ++aViewIter)
1240 const Handle(Visual3d_View)& aView = aViews.Value (aViewIter);
1243 aView->EraseImmediate (theStructure);
1248 myGraphicDriver->DisplayImmediateStructure (MyCView, theStructure);
1249 return Standard_True;
1252 // ========================================================================
1253 // function : EraseImmediate
1255 // ========================================================================
1256 Standard_Boolean Visual3d_View::EraseImmediate (const Handle(Graphic3d_Structure)& theStructure)
1258 const Standard_Boolean isErased = myImmediateStructures.Remove (theStructure);
1261 myGraphicDriver->EraseImmediateStructure (MyCView, *theStructure->CStructure());
1267 // ========================================================================
1268 // function : ClearImmediate
1270 // ========================================================================
1271 Standard_Boolean Visual3d_View::ClearImmediate()
1273 if (myImmediateStructures.IsEmpty())
1275 return Standard_False;
1278 for (Graphic3d_MapOfStructure::Iterator aStructIter (myImmediateStructures); aStructIter.More(); aStructIter.Next())
1280 myGraphicDriver->EraseImmediateStructure (MyCView, *aStructIter.Key()->CStructure());
1282 myImmediateStructures.Clear();
1283 return Standard_True;
1286 // ========================================================================
1287 // function : Display
1289 // ========================================================================
1290 void Visual3d_View::Display (const Handle(Graphic3d_Structure)& theStruct)
1292 Display (theStruct, myViewManager->UpdateMode());
1295 // ========================================================================
1296 // function : Display
1298 // ========================================================================
1299 void Visual3d_View::Display (const Handle(Graphic3d_Structure)& theStruct,
1300 const Aspect_TypeOfUpdate theUpdateMode)
1309 // If Display on a structure present in the list of calculated structures while it is not
1310 // or more, of calculated type =>
1311 // - removes it as well as the associated old computed
1312 // THis happens when hlhsr becomes again of type e non computed after SetVisual.
1313 Standard_Integer anIndex = IsComputed (theStruct);
1315 && theStruct->Visual() != Graphic3d_TOS_COMPUTED)
1317 myStructsToCompute.Remove (anIndex);
1318 myStructsComputed .Remove (anIndex);
1322 Visual3d_TypeOfAnswer anAnswer = acceptDisplay (theStruct->Visual());
1323 if (anAnswer == Visual3d_TOA_NO)
1328 if (!ComputedMode())
1330 anAnswer = Visual3d_TOA_YES;
1333 if (anAnswer == Visual3d_TOA_YES)
1335 if (!myStructsDisplayed.Add (theStruct))
1340 theStruct->CalculateBoundBox();
1341 myGraphicDriver->DisplayStructure (MyCView, theStruct, theStruct->DisplayPriority());
1342 Update (theUpdateMode);
1345 else if (anAnswer != Visual3d_TOA_COMPUTE)
1352 // Already computed, is COMPUTED still valid?
1353 const Handle(Graphic3d_Structure)& anOldStruct = myStructsComputed.Value (anIndex);
1354 if (anOldStruct->HLRValidation())
1356 // Case COMPUTED valid, to be displayed
1357 if (!myStructsDisplayed.Add (theStruct))
1362 myGraphicDriver->DisplayStructure (MyCView, anOldStruct, theStruct->DisplayPriority());
1363 Update (theUpdateMode);
1368 // Case COMPUTED invalid
1369 // Is there another valid representation?
1370 // Find in the sequence of already calculated structures
1371 // 1/ Structure having the same Owner as <AStructure>
1372 // 2/ That is not <AStructure>
1373 // 3/ The COMPUTED which of is valid
1374 const Standard_Integer aNewIndex = HaveTheSameOwner (theStruct);
1377 // Case of COMPUTED invalid, WITH a valid of replacement; to be displayed
1378 if (!myStructsDisplayed.Add (theStruct))
1383 const Handle(Graphic3d_Structure)& aNewStruct = myStructsComputed.Value (aNewIndex);
1384 myStructsComputed.SetValue (anIndex, aNewStruct);
1385 myGraphicDriver->DisplayStructure (MyCView, aNewStruct, theStruct->DisplayPriority());
1386 Update (theUpdateMode);
1391 // Case COMPUTED invalid, WITHOUT a valid of replacement
1392 // COMPUTED is removed if displayed
1393 if (myStructsDisplayed.Contains (theStruct))
1395 myGraphicDriver->EraseStructure (MyCView, anOldStruct);
1401 // Compute + Validation
1402 Handle(Graphic3d_Structure) aStruct;
1403 TColStd_Array2OfReal aTrsf (0, 3, 0, 3);
1404 theStruct->Transform (aTrsf);
1407 TColStd_Array2OfReal anIdent (0, 3, 0, 3);
1408 for (Standard_Integer ii = 0; ii <= 3; ++ii)
1410 for (Standard_Integer jj = 0; jj <= 3; ++jj)
1412 anIdent (ii, jj) = (ii == jj ? 1.0 : 0.0);
1416 aStruct = myStructsComputed.Value (anIndex);
1417 aStruct->SetTransform (anIdent, Graphic3d_TOC_REPLACE);
1418 if (theStruct->IsTransformed())
1420 theStruct->Compute (this, aTrsf, aStruct);
1424 theStruct->Compute (this, aStruct);
1429 aStruct = theStruct->IsTransformed()
1430 ? theStruct->Compute (this, aTrsf)
1431 : theStruct->Compute (this);
1434 aStruct->SetHLRValidation (Standard_True);
1436 // TOCOMPUTE and COMPUTED associated to sequences are added
1437 myStructsToCompute.Append (theStruct);
1438 myStructsComputed .Append (aStruct);
1440 // The previous are removed if necessary
1443 myStructsToCompute.Remove (anIndex);
1444 myStructsComputed .Remove (anIndex);
1447 // Of which type will be the computed?
1448 const Visual3d_TypeOfVisualization aViewType = MyContext.Visualization();
1449 const Standard_Boolean toComputeWireframe = aViewType == Visual3d_TOV_WIREFRAME
1450 && theStruct->ComputeVisual() != Graphic3d_TOS_SHADING;
1451 const Standard_Boolean toComputeShading = aViewType == Visual3d_TOV_SHADING
1452 && theStruct->ComputeVisual() != Graphic3d_TOS_WIREFRAME;
1453 if (!toComputeShading && !toComputeWireframe)
1455 anAnswer = Visual3d_TOA_NO;
1459 aStruct->SetVisual (toComputeWireframe ? Graphic3d_TOS_WIREFRAME : Graphic3d_TOS_SHADING);
1460 anAnswer = acceptDisplay (aStruct->Visual());
1463 if (theStruct->IsHighlighted())
1465 aStruct->Highlight (Aspect_TOHM_COLOR, theStruct->HighlightColor(), Standard_False);
1468 // It is displayed only if the calculated structure
1469 // has a proper type corresponding to the one of the view.
1470 if (anAnswer == Visual3d_TOA_NO)
1475 myStructsDisplayed.Add (theStruct);
1476 myGraphicDriver->DisplayStructure (MyCView, aStruct, theStruct->DisplayPriority());
1478 Update (theUpdateMode);
1481 // ========================================================================
1484 // ========================================================================
1485 void Visual3d_View::Erase (const Handle(Graphic3d_Structure)& theStruct)
1489 Erase (theStruct, myViewManager->UpdateMode());
1493 // ========================================================================
1496 // ========================================================================
1497 void Visual3d_View::Erase (const Handle(Graphic3d_Structure)& theStruct,
1498 const Aspect_TypeOfUpdate theUpdateMode)
1501 || EraseImmediate (theStruct)
1502 || !IsDisplayed (theStruct))
1507 Visual3d_TypeOfAnswer anAnswer = acceptDisplay (theStruct->Visual());
1508 if (!ComputedMode())
1510 anAnswer = Visual3d_TOA_YES;
1513 if (anAnswer != Visual3d_TOA_COMPUTE)
1515 myGraphicDriver->EraseStructure (MyCView, theStruct);
1517 else if (anAnswer == Visual3d_TOA_COMPUTE
1518 && myIsInComputedMode)
1520 const Standard_Integer anIndex = IsComputed (theStruct);
1523 const Handle(Graphic3d_Structure)& aCompStruct = myStructsComputed.ChangeValue (anIndex);
1524 myGraphicDriver->EraseStructure (MyCView, aCompStruct);
1527 myStructsDisplayed.Remove (theStruct);
1528 Update (theUpdateMode);
1531 // ========================================================================
1532 // function : Highlight
1534 // ========================================================================
1535 void Visual3d_View::Highlight (const Handle(Graphic3d_Structure)& theStruct,
1536 const Aspect_TypeOfHighlightMethod theMethod)
1538 const Standard_Integer anIndex = IsComputed (theStruct);
1541 const Handle(Graphic3d_Structure)& aCompStruct = myStructsComputed.ChangeValue (anIndex);
1542 aCompStruct->Highlight (theMethod, theStruct->HighlightColor(), Standard_False);
1546 // ========================================================================
1547 // function : SetTransform
1549 // ========================================================================
1550 void Visual3d_View::SetTransform (const Handle(Graphic3d_Structure)& theStruct,
1551 const TColStd_Array2OfReal& theTrsf)
1553 const Standard_Integer anIndex = IsComputed (theStruct);
1556 // Test is somewhat light !
1557 // trsf is transferred only if it is :
1560 if (theTrsf (0, 1) != 0.0 || theTrsf (0, 2) != 0.0
1561 || theTrsf (1, 0) != 0.0 || theTrsf (1, 2) != 0.0
1562 || theTrsf (2, 0) != 0.0 || theTrsf (2, 1) != 0.0)
1564 ReCompute (theStruct);
1568 const Handle(Graphic3d_Structure)& aCompStruct = myStructsComputed.ChangeValue (anIndex);
1569 aCompStruct->GraphicTransform (theTrsf);
1573 theStruct->CalculateBoundBox();
1574 if (!theStruct->IsMutable()
1575 && !theStruct->CStructure()->IsForHighlight
1576 && !theStruct->CStructure()->IsInfinite)
1578 const Graphic3d_ZLayerId aLayerId = theStruct->GetZLayer();
1579 myGraphicDriver->InvalidateBVHData (MyCView, aLayerId);
1583 // ========================================================================
1584 // function : UnHighlight
1586 // ========================================================================
1587 void Visual3d_View::UnHighlight (const Handle(Graphic3d_Structure)& theStruct)
1589 Standard_Integer anIndex = IsComputed (theStruct);
1592 const Handle(Graphic3d_Structure)& aCompStruct = myStructsComputed.ChangeValue (anIndex);
1593 aCompStruct->GraphicUnHighlight();
1597 // ========================================================================
1598 // function : IsComputed
1600 // ========================================================================
1601 Standard_Integer Visual3d_View::IsComputed (const Handle(Graphic3d_Structure)& theStruct) const
1603 const Standard_Integer aStructId = theStruct->Identification();
1604 const Standard_Integer aNbStructs = myStructsToCompute.Length();
1605 for (Standard_Integer aStructIter = 1; aStructIter <= aNbStructs; ++aStructIter)
1607 const Handle(Graphic3d_Structure)& aStruct = myStructsToCompute.Value (aStructIter);
1608 if (aStruct->Identification() == aStructId)
1616 // ========================================================================
1617 // function : IsDisplayed
1619 // ========================================================================
1620 Standard_Boolean Visual3d_View::IsDisplayed (const Handle(Graphic3d_Structure)& theStruct) const
1623 && myStructsDisplayed.Contains (theStruct);
1626 // ========================================================================
1627 // function : ContainsFacet
1629 // ========================================================================
1630 Standard_Boolean Visual3d_View::ContainsFacet() const
1632 for (Graphic3d_MapOfStructure::Iterator aStructIter (myStructsDisplayed); aStructIter.More(); aStructIter.Next())
1634 if (aStructIter.Key()->ContainsFacet())
1636 return Standard_True;
1639 return Standard_False;
1642 // ========================================================================
1643 // function : ContainsFacet
1645 // ========================================================================
1646 Standard_Boolean Visual3d_View::ContainsFacet (const Graphic3d_MapOfStructure& theSet) const
1648 for (Graphic3d_MapIteratorOfMapOfStructure aStructIter (theSet); aStructIter.More(); aStructIter.Next())
1650 if (aStructIter.Key()->ContainsFacet())
1652 return Standard_True;
1655 return Standard_False;
1658 //! Auxiliary method for MinMaxValues() method
1659 inline void addStructureBndBox (const Handle(Graphic3d_Structure)& theStruct,
1660 const Standard_Boolean theToIgnoreInfiniteFlag,
1663 if (!theStruct->IsVisible())
1667 else if (theStruct->IsInfinite()
1668 && !theToIgnoreInfiniteFlag)
1670 // XMin, YMin .... ZMax are initialized by means of infinite line data
1671 const Bnd_Box aBox = theStruct->MinMaxValues (Standard_False);
1675 theBndBox.Add (aBox);
1680 // Only non-empty and non-infinite structures
1681 // are taken into account for calculation of MinMax
1682 if (theStruct->IsEmpty()
1683 || theStruct->TransformPersistenceMode() != Graphic3d_TMF_None)
1688 // "FitAll" operation ignores object with transform persistence parameter
1689 const Bnd_Box aBox = theStruct->MinMaxValues (theToIgnoreInfiniteFlag);
1691 // To prevent float overflow at camera parameters calculation and further
1692 // rendering, bounding boxes with at least one vertex coordinate out of
1693 // float range are skipped by view fit algorithms
1694 if (Abs (aBox.CornerMax().X()) >= ShortRealLast() ||
1695 Abs (aBox.CornerMax().Y()) >= ShortRealLast() ||
1696 Abs (aBox.CornerMax().Z()) >= ShortRealLast() ||
1697 Abs (aBox.CornerMin().X()) >= ShortRealLast() ||
1698 Abs (aBox.CornerMin().Y()) >= ShortRealLast() ||
1699 Abs (aBox.CornerMin().Z()) >= ShortRealLast())
1702 theBndBox.Add (aBox);
1705 // ========================================================================
1706 // function : MinMaxValues
1708 // ========================================================================
1709 Bnd_Box Visual3d_View::MinMaxValues (const Standard_Boolean theToIgnoreInfiniteFlag) const
1711 Bnd_Box aResult = MinMaxValues (myStructsDisplayed, theToIgnoreInfiniteFlag);
1712 Bnd_Box anImmediate = MinMaxValues (myImmediateStructures, theToIgnoreInfiniteFlag);
1713 aResult.Add (anImmediate);
1717 // ========================================================================
1718 // function : MinMaxValues
1720 // ========================================================================
1721 Bnd_Box Visual3d_View::MinMaxValues (const Graphic3d_MapOfStructure& theSet,
1722 const Standard_Boolean theToIgnoreInfiniteFlag) const
1725 const Standard_Integer aViewId = MyCView.ViewId;
1726 for (Graphic3d_MapIteratorOfMapOfStructure aStructIter (theSet); aStructIter.More(); aStructIter.Next())
1728 const Handle(Graphic3d_Structure)& aStructure = aStructIter.Key();
1729 if (!aStructIter.Value()->IsVisible())
1733 else if (!aStructIter.Value()->CStructure()->ViewAffinity.IsNull()
1734 && !aStructIter.Value()->CStructure()->ViewAffinity->IsVisible (aViewId))
1739 addStructureBndBox (aStructure, theToIgnoreInfiniteFlag, aResult);
1744 // =======================================================================
1745 // function : NumberOfDisplayedStructures
1747 // =======================================================================
1748 Standard_Integer Visual3d_View::NumberOfDisplayedStructures() const
1750 return myStructsDisplayed.Extent();
1753 // =======================================================================
1754 // function : Projects
1756 // =======================================================================
1757 void Visual3d_View::Projects (const Standard_Real theX,
1758 const Standard_Real theY,
1759 const Standard_Real theZ,
1760 Standard_Real& thePX,
1761 Standard_Real& thePY,
1762 Standard_Real& thePZ) const
1764 const Handle(Graphic3d_Camera)& aCamera = MyCView.Context.Camera;
1766 gp_XYZ aViewSpaceDimensions = aCamera->ViewDimensions();
1767 Standard_Real aXSize = aViewSpaceDimensions.X();
1768 Standard_Real aYSize = aViewSpaceDimensions.Y();
1769 Standard_Real aZSize = aViewSpaceDimensions.Z();
1771 gp_Pnt aPoint = aCamera->Project (gp_Pnt (theX, theY, theZ));
1773 // NDC [-1, 1] --> PROJ [ -size / 2, +size / 2 ]
1774 thePX = aPoint.X() * aXSize * 0.5;
1775 thePY = aPoint.Y() * aYSize * 0.5;
1776 thePZ = aPoint.Z() * aZSize * 0.5;
1779 // =======================================================================
1780 // function : Identification
1782 // =======================================================================
1783 Standard_Integer Visual3d_View::Identification() const
1785 return MyCView.ViewId;
1788 // =======================================================================
1789 // function : UpdateView
1791 // =======================================================================
1792 void Visual3d_View::UpdateView()
1794 MyCView.Context.Aliasing = MyContext.AliasingIsOn();
1795 MyCView.Context.BackZClipping = MyContext.BackZClippingIsOn();
1796 MyCView.Context.FrontZClipping = MyContext.FrontZClippingIsOn();
1797 MyCView.Context.DepthCueing = MyContext.DepthCueingIsOn();
1799 MyCView.Context.ZClipFrontPlane = float (MyContext.ZClippingFrontPlane());
1800 MyCView.Context.ZClipBackPlane = float (MyContext.ZClippingBackPlane());
1801 MyCView.Context.DepthFrontPlane = float (MyContext.DepthCueingFrontPlane());
1802 MyCView.Context.DepthBackPlane = float (MyContext.DepthCueingBackPlane());
1804 MyCView.Context.Model = MyContext.Model();
1805 MyCView.Context.Visualization = MyContext.Visualization();
1807 MyCView.Context.TextureEnv = MyContext.TextureEnv();
1808 MyCView.Context.SurfaceDetail = MyContext.SurfaceDetail();
1811 // =======================================================================
1812 // function : Compute
1814 // =======================================================================
1815 void Visual3d_View::Compute()
1817 // force HLRValidation to False on all structures calculated in the view
1818 const Standard_Integer aNbCompStructs = myStructsComputed.Length();
1819 for (Standard_Integer aStructIter = 1; aStructIter <= aNbCompStructs; ++aStructIter)
1821 myStructsComputed.Value (aStructIter)->SetHLRValidation (Standard_False);
1824 if (!ComputedMode())
1829 // Change of orientation or of projection type =>
1830 // Remove structures that were calculated for the previous orientation.
1831 // Recalculation of new structures.
1832 NCollection_Sequence<Handle(Graphic3d_Structure)> aStructsSeq;
1833 for (Graphic3d_MapOfStructure::Iterator aStructIter (myStructsDisplayed); aStructIter.More(); aStructIter.Next())
1835 const Visual3d_TypeOfAnswer anAnswer = acceptDisplay (aStructIter.Key()->Visual());
1836 if (anAnswer == Visual3d_TOA_COMPUTE)
1838 aStructsSeq.Append (aStructIter.Key()); // if the structure was calculated, it is recalculated
1842 for (NCollection_Sequence<Handle(Graphic3d_Structure)>::Iterator aStructIter (aStructsSeq); aStructIter.More(); aStructIter.Next())
1844 Display (aStructIter.ChangeValue(), Aspect_TOU_WAIT);
1848 // =======================================================================
1849 // function : ReCompute
1851 // =======================================================================
1852 void Visual3d_View::ReCompute (const Handle(Graphic3d_Structure)& theStruct)
1854 theStruct->CalculateBoundBox();
1855 if (!theStruct->IsMutable()
1856 && !theStruct->CStructure()->IsForHighlight
1857 && !theStruct->CStructure()->IsInfinite)
1859 const Standard_Integer aLayerId = theStruct->DisplayPriority();
1860 myGraphicDriver->InvalidateBVHData(MyCView, aLayerId);
1867 || !MyWindow->IsMapped()
1868 || !theStruct->IsDisplayed())
1873 const Visual3d_TypeOfAnswer anAnswer = acceptDisplay (theStruct->Visual());
1874 if (anAnswer != Visual3d_TOA_COMPUTE)
1879 const Standard_Integer anIndex = IsComputed (theStruct);
1885 // compute + validation
1886 TColStd_Array2OfReal anIdent (0, 3, 0, 3);
1887 for (Standard_Integer aRow = 0; aRow <= 3; ++aRow)
1889 for (Standard_Integer aCol = 0; aCol <= 3; ++aCol)
1891 anIdent (aRow, aCol) = (aRow == aCol ? 1.0 : 0.0);
1894 TColStd_Array2OfReal aTrsf (0, 3, 0, 3);
1895 theStruct->Transform (aTrsf);
1897 Handle(Graphic3d_Structure) aCompStructOld = myStructsComputed.ChangeValue (anIndex);
1898 Handle(Graphic3d_Structure) aCompStruct = aCompStructOld;
1899 aCompStruct->SetTransform (anIdent, Graphic3d_TOC_REPLACE);
1900 theStruct->IsTransformed() ? theStruct->Compute (this, aTrsf, aCompStruct)
1901 : theStruct->Compute (this, aCompStruct);
1902 aCompStruct->SetHLRValidation (Standard_True);
1904 // of which type will be the computed?
1905 const Visual3d_TypeOfVisualization aViewType = MyContext.Visualization();
1906 const Standard_Boolean toComputeWireframe = aViewType == Visual3d_TOV_WIREFRAME
1907 && theStruct->ComputeVisual() != Graphic3d_TOS_SHADING;
1908 const Standard_Boolean toComputeShading = aViewType == Visual3d_TOV_SHADING
1909 && theStruct->ComputeVisual() != Graphic3d_TOS_WIREFRAME;
1910 if (toComputeWireframe)
1912 aCompStruct->SetVisual (Graphic3d_TOS_WIREFRAME);
1914 else if (toComputeShading)
1916 aCompStruct->SetVisual (Graphic3d_TOS_SHADING);
1919 if (theStruct->IsHighlighted())
1921 aCompStruct->Highlight (Aspect_TOHM_COLOR, theStruct->HighlightColor(), Standard_False);
1924 // The previous calculation is removed and the new one is displayed
1925 myGraphicDriver->EraseStructure (MyCView, aCompStructOld);
1926 myGraphicDriver->DisplayStructure (MyCView, aCompStruct, theStruct->DisplayPriority());
1928 // why not just replace existing items?
1929 //myStructsToCompute.ChangeValue (anIndex) = theStruct;
1930 //myStructsComputed .ChangeValue (anIndex) = aCompStruct;
1932 // hlhsr and the new associated compute are added
1933 myStructsToCompute.Append (theStruct);
1934 myStructsComputed .Append (aCompStruct);
1936 // hlhsr and the new associated compute are removed
1937 myStructsToCompute.Remove (anIndex);
1938 myStructsComputed .Remove (anIndex);
1941 // =======================================================================
1942 // function : GraphicDriver
1944 // =======================================================================
1945 const Handle(Graphic3d_GraphicDriver)& Visual3d_View::GraphicDriver() const
1947 return myGraphicDriver;
1950 // =======================================================================
1951 // function : HaveTheSameOwner
1953 // =======================================================================
1954 Standard_Integer Visual3d_View::HaveTheSameOwner (const Handle(Graphic3d_Structure)& theStruct) const
1956 // Find in the sequence of already calculated structures
1957 // 1/ Structure with the same Owner as <AStructure>
1958 // 2/ Which is not <AStructure>
1959 // 3/ COMPUTED which of is valid
1960 const Standard_Integer aNbToCompStructs = myStructsToCompute.Length();
1961 for (Standard_Integer aStructIter = 1; aStructIter <= aNbToCompStructs; ++aStructIter)
1963 const Handle(Graphic3d_Structure)& aStructToComp = myStructsToCompute.Value (aStructIter);
1964 if (aStructToComp->Owner() == theStruct->Owner()
1965 && aStructToComp->Identification() != theStruct->Identification())
1967 const Handle(Graphic3d_Structure)& aStructComp = myStructsComputed.Value (aStructIter);
1968 if (aStructComp->HLRValidation())
1977 // =======================================================================
1980 // =======================================================================
1981 Standard_Address Visual3d_View::CView() const
1983 return Standard_Address (&MyCView);
1986 // =======================================================================
1987 // function : ZBufferTriedronSetup
1989 // =======================================================================
1990 void Visual3d_View::ZBufferTriedronSetup (const Quantity_NameOfColor theXColor,
1991 const Quantity_NameOfColor theYColor,
1992 const Quantity_NameOfColor theZColor,
1993 const Standard_Real theSizeRatio,
1994 const Standard_Real theAxisDiametr,
1995 const Standard_Integer theNbFacettes)
1997 myGraphicDriver->ZBufferTriedronSetup (MyCView, theXColor, theYColor, theZColor,
1998 theSizeRatio, theAxisDiametr, theNbFacettes);
2001 // =======================================================================
2002 // function : TriedronDisplay
2004 // =======================================================================
2005 void Visual3d_View::TriedronDisplay (const Aspect_TypeOfTriedronPosition thePosition,
2006 const Quantity_NameOfColor theColor,
2007 const Standard_Real theScale,
2008 const Standard_Boolean theAsWireframe)
2010 myGraphicDriver->TriedronDisplay (MyCView, thePosition, theColor, theScale, theAsWireframe);
2013 // =======================================================================
2014 // function : TriedronErase
2016 // =======================================================================
2017 void Visual3d_View::TriedronErase()
2019 myGraphicDriver->TriedronErase (MyCView);
2022 // =======================================================================
2023 // function : TriedronEcho
2025 // =======================================================================
2026 void Visual3d_View::TriedronEcho (const Aspect_TypeOfTriedronEcho theType)
2028 myGraphicDriver->TriedronEcho (MyCView, theType);
2031 static void SetMinMaxValuesCallback (Visual3d_View* theView)
2033 Graphic3d_CView* aCView = (Graphic3d_CView* )(theView->CView());
2034 Bnd_Box aBox = theView->MinMaxValues();
2037 gp_Pnt aMin = aBox.CornerMin();
2038 gp_Pnt aMax = aBox.CornerMax();
2040 Graphic3d_Vec3 aMinVec ((Standard_ShortReal )aMin.X(), (Standard_ShortReal )aMin.Y(), (Standard_ShortReal )aMin.Z());
2041 Graphic3d_Vec3 aMaxVec ((Standard_ShortReal )aMax.X(), (Standard_ShortReal )aMax.Y(), (Standard_ShortReal )aMax.Z());
2042 const Handle(Graphic3d_GraphicDriver)& aDriver = theView->GraphicDriver();
2043 aDriver->GraduatedTrihedronMinMaxValues (*aCView, aMinVec, aMaxVec);
2048 // =======================================================================
2049 // function : GetGraduatedTrihedron
2051 // =======================================================================
2052 const Graphic3d_GraduatedTrihedron& Visual3d_View::GetGraduatedTrihedron() const
2054 return myGTrihedron;
2057 // =======================================================================
2058 // function : GraduatedTrihedronDisplay
2060 // =======================================================================
2061 void Visual3d_View::GraduatedTrihedronDisplay (const Graphic3d_GraduatedTrihedron& theTrihedronData)
2063 myGTrihedron = theTrihedronData;
2065 myGTrihedron.PtrVisual3dView = this;
2066 myGTrihedron.CubicAxesCallback = SetMinMaxValuesCallback;
2068 myGraphicDriver->GraduatedTrihedronDisplay (MyCView, myGTrihedron);
2071 // =======================================================================
2072 // function : GraduatedTrihedronErase
2074 // =======================================================================
2075 void Visual3d_View::GraduatedTrihedronErase()
2077 myGTrihedron.PtrVisual3dView = NULL;
2078 myGraphicDriver->GraduatedTrihedronErase (MyCView);
2081 // =======================================================================
2082 // function : UnderLayer
2084 // =======================================================================
2085 const Handle(Visual3d_Layer)& Visual3d_View::UnderLayer() const
2087 return myViewManager->UnderLayer();
2090 // =======================================================================
2091 // function : OverLayer
2093 // =======================================================================
2094 const Handle(Visual3d_Layer)& Visual3d_View::OverLayer() const
2096 return myViewManager->OverLayer();
2099 // =======================================================================
2100 // function : LightLimit
2102 // =======================================================================
2103 Standard_Integer Visual3d_View::LightLimit() const
2105 return myGraphicDriver->InquireLightLimit();
2108 // =======================================================================
2109 // function : PlaneLimit
2111 // =======================================================================
2112 Standard_Integer Visual3d_View::PlaneLimit() const
2114 return myGraphicDriver->InquirePlaneLimit();
2117 // =======================================================================
2118 // function : ViewManager
2120 // =======================================================================
2121 Handle(Visual3d_ViewManager) Visual3d_View::ViewManager() const
2123 return myViewManager;
2126 // =======================================================================
2127 // function : SetComputedMode
2129 // =======================================================================
2130 void Visual3d_View::SetComputedMode (const Standard_Boolean theMode)
2132 if (( theMode && myIsInComputedMode)
2133 || (!theMode && !myIsInComputedMode))
2138 myIsInComputedMode = theMode;
2139 if (!myIsInComputedMode)
2141 for (Graphic3d_MapOfStructure::Iterator aStructIter (myStructsDisplayed); aStructIter.More(); aStructIter.Next())
2143 const Handle(Graphic3d_Structure)& aStruct = aStructIter.Key();
2144 const Visual3d_TypeOfAnswer anAnswer = acceptDisplay (aStruct->Visual());
2145 if (anAnswer != Visual3d_TOA_COMPUTE)
2150 const Standard_Integer anIndex = IsComputed (aStruct);
2153 const Handle(Graphic3d_Structure)& aStructComp = myStructsComputed.Value (anIndex);
2154 myGraphicDriver->EraseStructure (MyCView, aStructComp);
2155 myGraphicDriver->DisplayStructure (MyCView, aStruct, aStruct->DisplayPriority());
2161 for (Graphic3d_MapOfStructure::Iterator aDispStructIter (myStructsDisplayed); aDispStructIter.More(); aDispStructIter.Next())
2163 Handle(Graphic3d_Structure) aStruct = aDispStructIter.Key();
2164 const Visual3d_TypeOfAnswer anAnswer = acceptDisplay (aStruct->Visual());
2165 if (anAnswer != Visual3d_TOA_COMPUTE)
2170 const Standard_Integer anIndex = IsComputed (aStruct);
2173 myGraphicDriver->EraseStructure (MyCView, aStruct);
2174 myGraphicDriver->DisplayStructure (MyCView, myStructsComputed.Value (anIndex), aStruct->DisplayPriority());
2176 Display (aStruct, Aspect_TOU_WAIT);
2177 if (aStruct->IsHighlighted())
2179 const Handle(Graphic3d_Structure)& aCompStruct = myStructsComputed.Value (anIndex);
2180 if (!aCompStruct->IsHighlighted())
2182 aCompStruct->Highlight (Aspect_TOHM_COLOR, aStruct->HighlightColor(), Standard_False);
2188 TColStd_Array2OfReal aTrsf (0, 3, 0, 3);
2189 aStruct->Transform (aTrsf);
2190 Handle(Graphic3d_Structure) aCompStruct = aStruct->IsTransformed() ? aStruct->Compute (this, aTrsf) : aStruct->Compute (this);
2191 aCompStruct->SetHLRValidation (Standard_True);
2193 const Visual3d_TypeOfVisualization aViewType = MyContext.Visualization();
2194 const Standard_Boolean toComputeWireframe = aViewType == Visual3d_TOV_WIREFRAME
2195 && aStruct->ComputeVisual() != Graphic3d_TOS_SHADING;
2196 const Standard_Boolean toComputeShading = aViewType == Visual3d_TOV_SHADING
2197 && aStruct->ComputeVisual() != Graphic3d_TOS_WIREFRAME;
2198 if (toComputeWireframe) aCompStruct->SetVisual (Graphic3d_TOS_WIREFRAME);
2199 if (toComputeShading ) aCompStruct->SetVisual (Graphic3d_TOS_SHADING);
2201 if (aStruct->IsHighlighted())
2203 aCompStruct->Highlight (Aspect_TOHM_COLOR, aStruct->HighlightColor(), Standard_False);
2206 Standard_Boolean hasResult = Standard_False;
2207 const Standard_Integer aNbToCompute = myStructsToCompute.Length();
2208 const Standard_Integer aStructId = aStruct->Identification();
2209 for (Standard_Integer aToCompStructIter = 1; aToCompStructIter <= aNbToCompute; ++aToCompStructIter)
2211 if (myStructsToCompute.Value (aToCompStructIter)->Identification() == aStructId)
2213 hasResult = Standard_True;
2214 myStructsComputed.ChangeValue (aToCompStructIter) = aCompStruct;
2221 myStructsToCompute.Append (aStruct);
2222 myStructsComputed .Append (aCompStruct);
2225 myGraphicDriver->EraseStructure (MyCView, aStruct);
2226 myGraphicDriver->DisplayStructure (MyCView, aCompStruct, aStruct->DisplayPriority());
2229 Update (myViewManager->UpdateMode());
2232 // =======================================================================
2233 // function : ComputedMode
2235 // =======================================================================
2236 Standard_Boolean Visual3d_View::ComputedMode() const
2238 return myIsInComputedMode;
2241 // =======================================================================
2242 // function : SetBackFacingModel
2244 // =======================================================================
2245 void Visual3d_View::SetBackFacingModel (const Visual3d_TypeOfBackfacingModel theModel)
2250 case Visual3d_TOBM_AUTOMATIC:
2251 MyCView.Backfacing = 0;
2253 case Visual3d_TOBM_FORCE:
2254 MyCView.Backfacing = 1;
2256 case Visual3d_TOBM_DISABLE:
2257 MyCView.Backfacing = -1;
2260 myGraphicDriver->SetBackFacingModel (MyCView);
2263 // =======================================================================
2264 // function : BackFacingModel
2266 // =======================================================================
2267 Visual3d_TypeOfBackfacingModel Visual3d_View::BackFacingModel() const
2269 switch (MyCView.Backfacing)
2271 case 0: return Visual3d_TOBM_AUTOMATIC;
2272 case 1: return Visual3d_TOBM_FORCE;
2274 return Visual3d_TOBM_DISABLE;
2277 // =======================================================================
2278 // function : ReadDepths
2280 // =======================================================================
2281 void Visual3d_View::ReadDepths (const Standard_Integer theX,
2282 const Standard_Integer theY,
2283 const Standard_Integer theWidth,
2284 const Standard_Integer theHeight,
2285 const Standard_Address theBuffer) const
2287 myGraphicDriver->ReadDepths (MyCView, theX, theY, theWidth, theHeight, theBuffer);
2290 // =======================================================================
2291 // function : FBOCreate
2293 // =======================================================================
2294 Graphic3d_PtrFrameBuffer Visual3d_View::FBOCreate(const Standard_Integer theWidth,
2295 const Standard_Integer theHeight)
2297 return myGraphicDriver->FBOCreate( MyCView, theWidth, theHeight );
2300 // =======================================================================
2301 // function : FBORelease
2303 // =======================================================================
2304 void Visual3d_View::FBORelease(Graphic3d_PtrFrameBuffer& theFBOPtr)
2306 myGraphicDriver->FBORelease( MyCView, theFBOPtr );
2309 // =======================================================================
2310 // function : FBOGetDimensions
2312 // =======================================================================
2313 void Visual3d_View::FBOGetDimensions(const Graphic3d_PtrFrameBuffer theFBOPtr,
2314 Standard_Integer& theWidth, Standard_Integer& theHeight,
2315 Standard_Integer& theWidthMax, Standard_Integer& theHeightMax)
2317 myGraphicDriver->FBOGetDimensions( MyCView, theFBOPtr,
2318 theWidth, theHeight,
2319 theWidthMax, theHeightMax );
2322 // =======================================================================
2323 // function : FBOChangeViewport
2325 // =======================================================================
2326 void Visual3d_View::FBOChangeViewport(Graphic3d_PtrFrameBuffer& theFBOPtr,
2327 const Standard_Integer theWidth, const Standard_Integer theHeight)
2329 myGraphicDriver->FBOChangeViewport( MyCView, theFBOPtr,
2330 theWidth, theHeight );
2333 // =======================================================================
2334 // function : BufferDump
2336 // =======================================================================
2337 Standard_Boolean Visual3d_View::BufferDump (Image_PixMap& theImage,
2338 const Graphic3d_BufferType& theBufferType)
2340 return myGraphicDriver->BufferDump (MyCView, theImage, theBufferType);
2343 // =======================================================================
2344 // function : EnableGLLight
2346 // =======================================================================
2347 void Visual3d_View::EnableGLLight( const Standard_Boolean enable ) const
2349 myGraphicDriver->SetGLLightEnabled( MyCView, enable );
2352 // =======================================================================
2353 // function : IsGLLightEnabled
2355 // =======================================================================
2356 Standard_Boolean Visual3d_View::IsGLLightEnabled() const
2358 return myGraphicDriver->IsGLLightEnabled( MyCView );
2361 // =======================================================================
2362 // function : Export
2364 // =======================================================================
2365 Standard_Boolean Visual3d_View::Export (const Standard_CString theFileName,
2366 const Graphic3d_ExportFormat theFormat,
2367 const Graphic3d_SortType theSortType,
2368 const Standard_Real thePrecision,
2369 const Standard_Address theProgressBarFunc,
2370 const Standard_Address theProgressObject) const
2372 Handle(Visual3d_Layer) anUnderLayer = myViewManager->UnderLayer();
2373 Handle(Visual3d_Layer) anOverLayer = myViewManager->OverLayer();
2375 Aspect_CLayer2d anOverCLayer;
2376 Aspect_CLayer2d anUnderCLayer;
2377 anOverCLayer.ptrLayer = anUnderCLayer.ptrLayer = NULL;
2379 if (!anOverLayer.IsNull())
2380 anOverCLayer = anOverLayer->CLayer();
2381 if (!anUnderLayer.IsNull())
2382 anUnderCLayer = anUnderLayer->CLayer();
2384 Standard_Integer aWidth, aHeight;
2385 Window()->Size (aWidth, aHeight);
2387 return myGraphicDriver->Export (theFileName, theFormat, theSortType,
2388 aWidth, aHeight, MyCView, anUnderCLayer, anOverCLayer,
2389 thePrecision, theProgressBarFunc, theProgressObject);
2392 // =======================================================================
2393 // function : SetZLayerSettings
2395 // =======================================================================
2396 void Visual3d_View::SetZLayerSettings (const Graphic3d_ZLayerId theLayerId,
2397 const Graphic3d_ZLayerSettings& theSettings)
2399 myGraphicDriver->SetZLayerSettings (MyCView, theLayerId, theSettings);
2402 // =======================================================================
2403 // function : AddZLayer
2405 // =======================================================================
2406 void Visual3d_View::AddZLayer (const Graphic3d_ZLayerId theLayerId)
2408 myGraphicDriver->AddZLayer (MyCView, theLayerId);
2411 // =======================================================================
2412 // function : RemoveZLayer
2414 // =======================================================================
2415 void Visual3d_View::RemoveZLayer (const Graphic3d_ZLayerId theLayerId)
2417 myGraphicDriver->RemoveZLayer (MyCView, theLayerId);
2420 // =======================================================================
2421 // function : ChangeZLayer
2423 // =======================================================================
2424 void Visual3d_View::ChangeZLayer (const Handle(Graphic3d_Structure)& theStructure,
2425 const Graphic3d_ZLayerId theLayerId)
2427 myGraphicDriver->ChangeZLayer (*(theStructure->CStructure()), MyCView, theLayerId);
2430 // =======================================================================
2433 // =======================================================================
2434 Standard_Boolean Visual3d_View::Print (const Aspect_Handle thePrintDC,
2435 const Standard_Boolean theToShowBackground,
2436 const Standard_CString theFilename,
2437 const Aspect_PrintAlgo thePrintAlgorithm,
2438 const Standard_Real theScaleFactor) const
2440 return Print (myViewManager->UnderLayer(),
2441 myViewManager->OverLayer(),
2442 thePrintDC, theToShowBackground,
2443 theFilename, thePrintAlgorithm,
2447 // =======================================================================
2450 // =======================================================================
2451 Standard_Boolean Visual3d_View::Print (const Handle(Visual3d_Layer)& theUnderLayer,
2452 const Handle(Visual3d_Layer)& theOverLayer,
2453 const Aspect_Handle thePrintDC,
2454 const Standard_Boolean theToShowBackground,
2455 const Standard_CString theFilename,
2456 const Aspect_PrintAlgo thePrintAlgorithm,
2457 const Standard_Real theScaleFactor) const
2462 || !MyWindow->IsMapped())
2464 return Standard_False;
2467 Aspect_CLayer2d anOverCLayer;
2468 Aspect_CLayer2d anUnderCLayer;
2469 anOverCLayer.ptrLayer = anUnderCLayer.ptrLayer = NULL;
2470 if (!theOverLayer.IsNull()) anOverCLayer = theOverLayer->CLayer();
2471 if (!theUnderLayer.IsNull()) anUnderCLayer = theUnderLayer->CLayer();
2472 return myGraphicDriver->Print (MyCView, anUnderCLayer, anOverCLayer,
2473 thePrintDC, theToShowBackground, theFilename,
2474 thePrintAlgorithm, theScaleFactor);
2477 //=============================================================================
2478 //function : HiddenObjects
2480 //=============================================================================
2481 const Handle(Graphic3d_NMapOfTransient)& Visual3d_View::HiddenObjects() const
2483 return myHiddenObjects;
2486 //=============================================================================
2487 //function : HiddenObjects
2489 //=============================================================================
2490 Handle(Graphic3d_NMapOfTransient)& Visual3d_View::ChangeHiddenObjects()
2492 return myHiddenObjects;