1 // Copyright (c) 2015 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
5 // This library is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU Lesser General Public License version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
14 #include <Graphic3d_CView.hxx>
16 #include <Aspect_NeutralWindow.hxx>
17 #include <Aspect_OpenVRSession.hxx>
18 #include <Graphic3d_CubeMapPacked.hxx>
19 #include <Graphic3d_Layer.hxx>
20 #include <Graphic3d_MapIteratorOfMapOfStructure.hxx>
21 #include <Graphic3d_StructureManager.hxx>
23 IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_CView,Graphic3d_DataStructureManager)
25 //=======================================================================
26 //function : Constructor
28 //=======================================================================
29 Graphic3d_CView::Graphic3d_CView (const Handle(Graphic3d_StructureManager)& theMgr)
32 myParentView (nullptr),
33 myIsSubviewComposer (Standard_False),
34 mySubviewCorner (Aspect_TOTP_LEFT_UPPER),
35 mySubviewSize (1.0, 1.0),
37 myStructureManager (theMgr),
38 myCamera (new Graphic3d_Camera()),
39 myIsInComputedMode (Standard_False),
40 myIsActive (Standard_False),
41 myIsRemoved (Standard_False),
42 myBackfacing (Graphic3d_TypeOfBackfacingModel_Auto),
43 myVisualization (Graphic3d_TOV_WIREFRAME),
45 myBgColor (Quantity_NOC_BLACK),
46 myBackgroundType (Graphic3d_TOB_NONE),
47 myToUpdateSkydome (Standard_False),
51 myId = myStructureManager->Identification (this);
54 //=======================================================================
55 //function : Destructor
57 //=======================================================================
58 Graphic3d_CView::~Graphic3d_CView()
60 myXRSession.Nullify();
63 myStructureManager->UnIdentification (this);
67 // =======================================================================
68 // function : SetBackgroundSkydome
70 // =======================================================================
71 void Graphic3d_CView::SetBackgroundSkydome (const Aspect_SkydomeBackground& theAspect,
72 Standard_Boolean theToUpdatePBREnv)
74 myToUpdateSkydome = true;
75 mySkydomeAspect = theAspect;
76 myCubeMapBackground = new Graphic3d_CubeMapPacked ("");
77 SetBackgroundType (Graphic3d_TOB_CUBEMAP);
79 && !myCubeMapIBL.IsNull())
81 SetImageBasedLighting (false);
82 SetImageBasedLighting (true);
86 // =======================================================================
87 // function : Activate
89 // =======================================================================
90 void Graphic3d_CView::Activate()
94 myIsActive = Standard_True;
96 // Activation of a new view =>
97 // Display structures that can be displayed in this new view.
98 // All structures with status
99 // Displayed in ViewManager are returned and displayed in
100 // the view directly, if the structure is not already
101 // displayed and if the view accepts it in its context.
102 Graphic3d_MapOfStructure aDisplayedStructs;
103 myStructureManager->DisplayedStructures (aDisplayedStructs);
104 for (Graphic3d_MapIteratorOfMapOfStructure aStructIter (aDisplayedStructs); aStructIter.More(); aStructIter.Next())
106 const Handle(Graphic3d_Structure)& aStruct = aStructIter.Key();
107 if (IsDisplayed (aStruct))
112 // If the structure can be displayed in the new context of the view, it is displayed.
113 const Graphic3d_TypeOfAnswer anAnswer = acceptDisplay (aStruct->Visual());
114 if (anAnswer == Graphic3d_TOA_YES
115 || anAnswer == Graphic3d_TOA_COMPUTE)
125 // =======================================================================
126 // function : Deactivate
128 // =======================================================================
129 void Graphic3d_CView::Deactivate()
133 // Deactivation of a view =>
134 // Removal of structures displayed in this view.
135 // All structures with status
136 // Displayed in ViewManager are returned and removed from
137 // the view directly, if the structure is not already
138 // displayed and if the view accepts it in its context.
139 Graphic3d_MapOfStructure aDisplayedStructs;
140 myStructureManager->DisplayedStructures (aDisplayedStructs);
141 for (Graphic3d_MapIteratorOfMapOfStructure aStructIter (aDisplayedStructs); aStructIter.More(); aStructIter.Next())
143 const Handle(Graphic3d_Structure)& aStruct = aStructIter.Key();
144 if (!IsDisplayed (aStruct))
149 const Graphic3d_TypeOfAnswer anAnswer = acceptDisplay (aStruct->Visual());
150 if (anAnswer == Graphic3d_TOA_YES
151 || anAnswer == Graphic3d_TOA_COMPUTE)
158 myIsActive = Standard_False;
162 // ========================================================================
165 // ========================================================================
166 void Graphic3d_CView::Remove()
173 if (myParentView != nullptr)
175 myParentView->RemoveSubview (this);
176 myParentView = nullptr;
179 NCollection_Sequence<Handle(Graphic3d_CView)> aSubviews = mySubviews;
181 for (const Handle(Graphic3d_CView)& aViewIter : aSubviews)
187 Graphic3d_MapOfStructure aDisplayedStructs (myStructsDisplayed);
188 for (Graphic3d_MapIteratorOfMapOfStructure aStructIter (aDisplayedStructs); aStructIter.More(); aStructIter.Next())
190 Erase (aStructIter.Value());
193 myStructsToCompute.Clear();
194 myStructsComputed .Clear();
195 myStructsDisplayed.Clear();
197 if (!myStructureManager.IsNull())
199 myStructureManager->UnIdentification (this);
202 myIsActive = Standard_False;
203 myIsRemoved = Standard_True;
206 // ========================================================================
207 // function : AddSubview
209 // ========================================================================
210 void Graphic3d_CView::AddSubview (const Handle(Graphic3d_CView)& theView)
212 mySubviews.Append (theView);
215 // ========================================================================
216 // function : RemoveSubview
218 // ========================================================================
219 bool Graphic3d_CView::RemoveSubview (const Graphic3d_CView* theView)
221 for (NCollection_Sequence<Handle(Graphic3d_CView)>::Iterator aViewIter (mySubviews); aViewIter.More(); aViewIter.Next())
223 if (aViewIter.Value() == theView)
225 mySubviews.Remove (aViewIter);
232 // ========================================================================
233 // function : Resized
235 // ========================================================================
236 void Graphic3d_CView::Resized()
240 Handle(Aspect_NeutralWindow) aWindow = Handle(Aspect_NeutralWindow)::DownCast(Window());
241 SubviewResized (aWindow);
245 //! Calculate offset in pixels from fraction.
246 static int getSubViewOffset (double theOffset, int theWinSize)
248 if (theOffset >= 1.0)
250 return int(theOffset);
254 return int(theOffset * theWinSize);
258 // ========================================================================
259 // function : SubviewResized
261 // ========================================================================
262 void Graphic3d_CView::SubviewResized (const Handle(Aspect_NeutralWindow)& theWindow)
265 || theWindow.IsNull())
270 const Graphic3d_Vec2i aWinSize (myParentView->Window()->Dimensions());
271 Graphic3d_Vec2i aViewSize (Graphic3d_Vec2d(aWinSize) * mySubviewSize);
272 if (mySubviewSize.x() > 1.0)
274 aViewSize.x() = (int)mySubviewSize.x();
276 if (mySubviewSize.y() > 1.0)
278 aViewSize.y() = (int)mySubviewSize.y();
281 Graphic3d_Vec2i anOffset (getSubViewOffset (mySubviewOffset.x(), aWinSize.x()),
282 getSubViewOffset (mySubviewOffset.y(), aWinSize.y()));
283 mySubviewTopLeft = (aWinSize - aViewSize) / 2; // Aspect_TOTP_CENTER
284 if ((mySubviewCorner & Aspect_TOTP_LEFT) != 0)
286 mySubviewTopLeft.x() = anOffset.x();
288 else if ((mySubviewCorner & Aspect_TOTP_RIGHT) != 0)
290 mySubviewTopLeft.x() = Max (aWinSize.x() - anOffset.x() - aViewSize.x(), 0);
293 if ((mySubviewCorner & Aspect_TOTP_TOP) != 0)
295 mySubviewTopLeft.y() = anOffset.y();
297 else if ((mySubviewCorner & Aspect_TOTP_BOTTOM) != 0)
299 mySubviewTopLeft.y() = Max (aWinSize.y() - anOffset.y() - aViewSize.y(), 0);
302 mySubviewTopLeft += mySubviewMargins;
303 aViewSize -= mySubviewMargins * 2;
305 const int aRight = Min(mySubviewTopLeft.x() + aViewSize.x(), aWinSize.x());
306 aViewSize.x() = aRight - mySubviewTopLeft.x();
308 const int aBot = Min(mySubviewTopLeft.y() + aViewSize.y(), aWinSize.y());
309 aViewSize.y() = aBot - mySubviewTopLeft.y();
311 theWindow->SetSize (aViewSize.x(), aViewSize.y());
314 // ========================================================================
315 // function : SetComputedMode
317 // ========================================================================
318 void Graphic3d_CView::SetComputedMode (const Standard_Boolean theMode)
320 if (( theMode && myIsInComputedMode)
321 || (!theMode && !myIsInComputedMode))
326 myIsInComputedMode = theMode;
327 if (!myIsInComputedMode)
329 for (Graphic3d_MapOfStructure::Iterator aStructIter (myStructsDisplayed); aStructIter.More(); aStructIter.Next())
331 const Handle(Graphic3d_Structure)& aStruct = aStructIter.Key();
332 const Graphic3d_TypeOfAnswer anAnswer = acceptDisplay (aStruct->Visual());
333 if (anAnswer != Graphic3d_TOA_COMPUTE)
338 const Standard_Integer anIndex = IsComputed (aStruct);
341 const Handle(Graphic3d_Structure)& aStructComp = myStructsComputed.Value (anIndex);
342 eraseStructure (aStructComp->CStructure());
343 displayStructure (aStruct->CStructure(), aStruct->DisplayPriority());
344 Update (aStruct->GetZLayer());
350 for (Graphic3d_MapOfStructure::Iterator aDispStructIter (myStructsDisplayed); aDispStructIter.More(); aDispStructIter.Next())
352 Handle(Graphic3d_Structure) aStruct = aDispStructIter.Key();
353 const Graphic3d_TypeOfAnswer anAnswer = acceptDisplay (aStruct->Visual());
354 if (anAnswer != Graphic3d_TOA_COMPUTE)
359 const Standard_Integer anIndex = IsComputed (aStruct);
362 eraseStructure (aStruct->CStructure());
363 displayStructure (myStructsComputed.Value (anIndex)->CStructure(), aStruct->DisplayPriority());
366 if (aStruct->IsHighlighted())
368 const Handle(Graphic3d_Structure)& aCompStruct = myStructsComputed.Value (anIndex);
369 if (!aCompStruct->IsHighlighted())
371 aCompStruct->Highlight (aStruct->HighlightStyle(), Standard_False);
377 Handle(Graphic3d_Structure) aCompStruct;
378 aStruct->computeHLR (myCamera, aCompStruct);
379 if (aCompStruct.IsNull())
383 aCompStruct->SetHLRValidation (Standard_True);
385 const Standard_Boolean toComputeWireframe = myVisualization == Graphic3d_TOV_WIREFRAME
386 && aStruct->ComputeVisual() != Graphic3d_TOS_SHADING;
387 const Standard_Boolean toComputeShading = myVisualization == Graphic3d_TOV_SHADING
388 && aStruct->ComputeVisual() != Graphic3d_TOS_WIREFRAME;
389 if (toComputeWireframe) aCompStruct->SetVisual (Graphic3d_TOS_WIREFRAME);
390 if (toComputeShading ) aCompStruct->SetVisual (Graphic3d_TOS_SHADING);
392 if (aStruct->IsHighlighted())
394 aCompStruct->Highlight (aStruct->HighlightStyle(), Standard_False);
397 Standard_Boolean hasResult = Standard_False;
398 const Standard_Integer aNbToCompute = myStructsToCompute.Length();
399 const Standard_Integer aStructId = aStruct->Identification();
400 for (Standard_Integer aToCompStructIter = 1; aToCompStructIter <= aNbToCompute; ++aToCompStructIter)
402 if (myStructsToCompute.Value (aToCompStructIter)->Identification() == aStructId)
404 hasResult = Standard_True;
405 myStructsComputed.ChangeValue (aToCompStructIter) = aCompStruct;
412 myStructsToCompute.Append (aStruct);
413 myStructsComputed .Append (aCompStruct);
416 aCompStruct->CalculateBoundBox();
417 eraseStructure (aStruct->CStructure());
418 displayStructure (aCompStruct->CStructure(), aStruct->DisplayPriority());
424 // =======================================================================
425 // function : ReCompute
427 // =======================================================================
428 void Graphic3d_CView::ReCompute (const Handle(Graphic3d_Structure)& theStruct)
430 theStruct->CalculateBoundBox();
431 if (!theStruct->IsMutable()
432 && !theStruct->CStructure()->IsForHighlight
433 && !theStruct->CStructure()->IsInfinite)
435 const Graphic3d_ZLayerId aLayerId = theStruct->GetZLayer();
436 InvalidateBVHData (aLayerId);
441 || !theStruct->IsDisplayed())
446 const Graphic3d_TypeOfAnswer anAnswer = acceptDisplay (theStruct->Visual());
447 if (anAnswer != Graphic3d_TOA_COMPUTE)
452 const Standard_Integer anIndex = IsComputed (theStruct);
458 // compute + validation
459 Handle(Graphic3d_Structure) aCompStructOld = myStructsComputed.ChangeValue (anIndex);
460 Handle(Graphic3d_Structure) aCompStruct = aCompStructOld;
461 aCompStruct->SetTransformation (Handle(TopLoc_Datum3D)());
462 theStruct->computeHLR (myCamera, aCompStruct);
463 if (aCompStruct.IsNull())
468 aCompStruct->SetHLRValidation (Standard_True);
469 aCompStruct->CalculateBoundBox();
471 // of which type will be the computed?
472 const Standard_Boolean toComputeWireframe = myVisualization == Graphic3d_TOV_WIREFRAME
473 && theStruct->ComputeVisual() != Graphic3d_TOS_SHADING;
474 const Standard_Boolean toComputeShading = myVisualization == Graphic3d_TOV_SHADING
475 && theStruct->ComputeVisual() != Graphic3d_TOS_WIREFRAME;
476 if (toComputeWireframe)
478 aCompStruct->SetVisual (Graphic3d_TOS_WIREFRAME);
480 else if (toComputeShading)
482 aCompStruct->SetVisual (Graphic3d_TOS_SHADING);
485 if (theStruct->IsHighlighted())
487 aCompStruct->Highlight (theStruct->HighlightStyle(), Standard_False);
490 // The previous calculation is removed and the new one is displayed
491 eraseStructure (aCompStructOld->CStructure());
492 displayStructure (aCompStruct->CStructure(), theStruct->DisplayPriority());
494 // why not just replace existing items?
495 //myStructsToCompute.ChangeValue (anIndex) = theStruct;
496 //myStructsComputed .ChangeValue (anIndex) = aCompStruct;
498 // hlhsr and the new associated compute are added
499 myStructsToCompute.Append (theStruct);
500 myStructsComputed .Append (aCompStruct);
502 // hlhsr and the new associated compute are removed
503 myStructsToCompute.Remove (anIndex);
504 myStructsComputed .Remove (anIndex);
507 // =======================================================================
510 // =======================================================================
511 void Graphic3d_CView::Update (const Graphic3d_ZLayerId theLayerId)
513 InvalidateZLayerBoundingBox (theLayerId);
516 // =======================================================================
517 // function : InvalidateZLayerBoundingBox
519 // =======================================================================
520 void Graphic3d_CView::InvalidateZLayerBoundingBox (const Graphic3d_ZLayerId theLayerId)
522 if (Handle(Graphic3d_Layer) aLayer = Layer (theLayerId))
524 aLayer->InvalidateBoundingBox();
528 for (NCollection_List<Handle(Graphic3d_Layer)>::Iterator aLayerIter (Layers()); aLayerIter.More(); aLayerIter.Next())
530 const Handle(Graphic3d_Layer)& aLayer = aLayerIter.Value();
531 if (aLayer->NbOfTransformPersistenceObjects() > 0)
533 aLayer->InvalidateBoundingBox();
538 // =======================================================================
539 // function : DisplayedStructures
541 // =======================================================================
542 void Graphic3d_CView::DisplayedStructures (Graphic3d_MapOfStructure& theStructures) const
544 for (Graphic3d_MapOfStructure::Iterator aStructIter (myStructsDisplayed); aStructIter.More(); aStructIter.Next())
546 theStructures.Add (aStructIter.Key());
550 // =======================================================================
551 // function : MinMaxValues
553 // =======================================================================
554 Bnd_Box Graphic3d_CView::MinMaxValues (const Standard_Boolean theToIncludeAuxiliary) const
561 const Handle(Graphic3d_Camera)& aCamera = Camera();
562 Graphic3d_Vec2i aWinSize;
563 Window()->Size (aWinSize.x(), aWinSize.y());
566 for (NCollection_List<Handle(Graphic3d_Layer)>::Iterator aLayerIter (Layers()); aLayerIter.More(); aLayerIter.Next())
568 const Handle(Graphic3d_Layer)& aLayer = aLayerIter.Value();
569 Bnd_Box aBox = aLayer->BoundingBox (Identification(),
571 aWinSize.x(), aWinSize.y(),
572 theToIncludeAuxiliary);
578 // =======================================================================
579 // function : ConsiderZoomPersistenceObjects
581 // =======================================================================
582 Standard_Real Graphic3d_CView::ConsiderZoomPersistenceObjects()
589 const Handle(Graphic3d_Camera)& aCamera = Camera();
590 Graphic3d_Vec2i aWinSize;
591 Window()->Size (aWinSize.x(), aWinSize.y());
593 Standard_Real aMaxCoef = 1.0;
594 for (NCollection_List<Handle(Graphic3d_Layer)>::Iterator aLayerIter (Layers()); aLayerIter.More(); aLayerIter.Next())
596 const Handle(Graphic3d_Layer)& aLayer = aLayerIter.Value();
597 aMaxCoef = Max (aMaxCoef, aLayer->considerZoomPersistenceObjects (Identification(), aCamera, aWinSize.x(), aWinSize.y()));
603 // =======================================================================
604 // function : MinMaxValues
606 // =======================================================================
607 Bnd_Box Graphic3d_CView::MinMaxValues (const Graphic3d_MapOfStructure& theSet,
608 const Standard_Boolean theToIgnoreInfiniteFlag) const
611 const Standard_Integer aViewId = Identification();
613 Handle(Graphic3d_Camera) aCamera = Camera();
614 Standard_Integer aWinWidth = 0;
615 Standard_Integer aWinHeight = 0;
618 Window()->Size (aWinWidth, aWinHeight);
621 for (Graphic3d_MapIteratorOfMapOfStructure aStructIter (theSet); aStructIter.More(); aStructIter.Next())
623 const Handle(Graphic3d_Structure)& aStructure = aStructIter.Key();
624 if (aStructure->IsEmpty()
625 || !aStructure->CStructure()->IsVisible (aViewId))
630 // "FitAll" operation ignores object with transform persistence parameter
631 if (!aStructure->TransformPersistence().IsNull())
633 // Panning and 2d persistence apply changes to projection or/and its translation components.
634 // It makes them incompatible with z-fitting algorithm. Ignored by now.
635 if (!theToIgnoreInfiniteFlag
636 || aStructure->TransformPersistence()->IsTrihedronOr2d())
642 Bnd_Box aBox = aStructure->MinMaxValues (theToIgnoreInfiniteFlag);
644 if (aBox.IsWhole() || aBox.IsVoid())
649 if (!aStructure->TransformPersistence().IsNull())
651 const Graphic3d_Mat4d& aProjectionMat = aCamera->ProjectionMatrix();
652 const Graphic3d_Mat4d& aWorldViewMat = aCamera->OrientationMatrix();
653 aStructure->TransformPersistence()->Apply (aCamera, aProjectionMat, aWorldViewMat, aWinWidth, aWinHeight, aBox);
656 // To prevent float overflow at camera parameters calculation and further
657 // rendering, bounding boxes with at least one vertex coordinate out of
658 // float range are skipped by view fit algorithms
659 if (Abs (aBox.CornerMax().X()) >= ShortRealLast() ||
660 Abs (aBox.CornerMax().Y()) >= ShortRealLast() ||
661 Abs (aBox.CornerMax().Z()) >= ShortRealLast() ||
662 Abs (aBox.CornerMin().X()) >= ShortRealLast() ||
663 Abs (aBox.CornerMin().Y()) >= ShortRealLast() ||
664 Abs (aBox.CornerMin().Z()) >= ShortRealLast())
674 // =======================================================================
675 // function : acceptDisplay
677 // =======================================================================
678 Graphic3d_TypeOfAnswer Graphic3d_CView::acceptDisplay (const Graphic3d_TypeOfStructure theStructType) const
680 switch (theStructType)
682 case Graphic3d_TOS_ALL:
684 return Graphic3d_TOA_YES; // The structure accepts any type of view
686 case Graphic3d_TOS_SHADING:
688 return myVisualization == Graphic3d_TOV_SHADING
692 case Graphic3d_TOS_WIREFRAME:
694 return myVisualization == Graphic3d_TOV_WIREFRAME
698 case Graphic3d_TOS_COMPUTED:
700 return (myVisualization == Graphic3d_TOV_SHADING || myVisualization == Graphic3d_TOV_WIREFRAME)
701 ? Graphic3d_TOA_COMPUTE
705 return Graphic3d_TOA_NO;
708 // =======================================================================
709 // function : Compute
711 // =======================================================================
712 void Graphic3d_CView::Compute()
714 // force HLRValidation to False on all structures calculated in the view
715 for (Graphic3d_SequenceOfStructure::Iterator aStructIter (myStructsComputed); aStructIter.More(); aStructIter.Next())
717 aStructIter.Value()->SetHLRValidation (Standard_False);
725 // Change of orientation or of projection type =>
726 // Remove structures that were calculated for the previous orientation.
727 // Recalculation of new structures.
728 NCollection_Sequence<Handle(Graphic3d_Structure)> aStructsSeq;
729 for (Graphic3d_MapOfStructure::Iterator aStructIter (myStructsDisplayed); aStructIter.More(); aStructIter.Next())
731 const Graphic3d_TypeOfAnswer anAnswer = acceptDisplay (aStructIter.Key()->Visual());
732 if (anAnswer == Graphic3d_TOA_COMPUTE)
734 aStructsSeq.Append (aStructIter.Key()); // if the structure was calculated, it is recalculated
738 for (NCollection_Sequence<Handle(Graphic3d_Structure)>::Iterator aStructIter (aStructsSeq); aStructIter.More(); aStructIter.Next())
740 Display (aStructIter.ChangeValue());
744 // =======================================================================
747 // =======================================================================
748 void Graphic3d_CView::Clear (Graphic3d_Structure* theStructure,
749 const Standard_Boolean theWithDestruction)
751 const Standard_Integer anIndex = IsComputed (theStructure);
754 const Handle(Graphic3d_Structure)& aCompStruct = myStructsComputed.Value (anIndex);
755 aCompStruct->GraphicClear (theWithDestruction);
756 aCompStruct->SetHLRValidation (Standard_False);
760 // =======================================================================
761 // function : Connect
763 // =======================================================================
764 void Graphic3d_CView::Connect (const Graphic3d_Structure* theMother,
765 const Graphic3d_Structure* theDaughter)
767 Standard_Integer anIndexM = IsComputed (theMother);
768 Standard_Integer anIndexD = IsComputed (theDaughter);
772 const Handle(Graphic3d_Structure)& aStructM = myStructsComputed.Value (anIndexM);
773 const Handle(Graphic3d_Structure)& aStructD = myStructsComputed.Value (anIndexD);
774 aStructM->GraphicConnect (aStructD);
778 // =======================================================================
779 // function : Disconnect
781 // =======================================================================
782 void Graphic3d_CView::Disconnect (const Graphic3d_Structure* theMother,
783 const Graphic3d_Structure* theDaughter)
785 Standard_Integer anIndexM = IsComputed (theMother);
786 Standard_Integer anIndexD = IsComputed (theDaughter);
790 const Handle(Graphic3d_Structure)& aStructM = myStructsComputed.Value (anIndexM);
791 const Handle(Graphic3d_Structure)& aStructD = myStructsComputed.Value (anIndexD);
792 aStructM->GraphicDisconnect (aStructD);
796 // =======================================================================
797 // function : Display
799 // =======================================================================
800 void Graphic3d_CView::Display (const Handle(Graphic3d_Structure)& theStructure)
807 // If Display on a structure present in the list of calculated structures while it is not
808 // or more, of calculated type =>
809 // - removes it as well as the associated old computed
810 // THis happens when hlhsr becomes again of type e non computed after SetVisual.
811 Standard_Integer anIndex = IsComputed (theStructure);
813 && theStructure->Visual() != Graphic3d_TOS_COMPUTED)
815 myStructsToCompute.Remove (anIndex);
816 myStructsComputed .Remove (anIndex);
820 Graphic3d_TypeOfAnswer anAnswer = acceptDisplay (theStructure->Visual());
821 if (anAnswer == Graphic3d_TOA_NO)
828 anAnswer = Graphic3d_TOA_YES;
831 if (anAnswer == Graphic3d_TOA_YES)
833 if (!myStructsDisplayed.Add (theStructure))
838 theStructure->CalculateBoundBox();
839 displayStructure (theStructure->CStructure(), theStructure->DisplayPriority());
840 Update (theStructure->GetZLayer());
843 else if (anAnswer != Graphic3d_TOA_COMPUTE)
850 // Already computed, is COMPUTED still valid?
851 const Handle(Graphic3d_Structure)& anOldStruct = myStructsComputed.Value (anIndex);
852 if (anOldStruct->HLRValidation())
854 // Case COMPUTED valid, to be displayed
855 if (!myStructsDisplayed.Add (theStructure))
860 displayStructure (anOldStruct->CStructure(), theStructure->DisplayPriority());
861 Update (anOldStruct->GetZLayer());
866 // Case COMPUTED invalid
867 // Is there another valid representation?
868 // Find in the sequence of already calculated structures
869 // 1/ Structure having the same Owner as <AStructure>
870 // 2/ That is not <AStructure>
871 // 3/ The COMPUTED which of is valid
872 const Standard_Integer aNewIndex = HaveTheSameOwner (theStructure);
875 // Case of COMPUTED invalid, WITH a valid of replacement; to be displayed
876 if (!myStructsDisplayed.Add (theStructure))
881 const Handle(Graphic3d_Structure)& aNewStruct = myStructsComputed.Value (aNewIndex);
882 myStructsComputed.SetValue (anIndex, aNewStruct);
883 displayStructure (aNewStruct->CStructure(), theStructure->DisplayPriority());
884 Update (aNewStruct->GetZLayer());
889 // Case COMPUTED invalid, WITHOUT a valid of replacement
890 // COMPUTED is removed if displayed
891 if (myStructsDisplayed.Contains (theStructure))
893 eraseStructure (anOldStruct->CStructure());
899 // Compute + Validation
900 Handle(Graphic3d_Structure) aStruct;
903 aStruct = myStructsComputed.Value (anIndex);
904 aStruct->SetTransformation (Handle(TopLoc_Datum3D)());
906 theStructure->computeHLR (myCamera, aStruct);
907 if (aStruct.IsNull())
911 aStruct->SetHLRValidation (Standard_True);
913 // TOCOMPUTE and COMPUTED associated to sequences are added
914 myStructsToCompute.Append (theStructure);
915 myStructsComputed .Append (aStruct);
917 // The previous are removed if necessary
920 myStructsToCompute.Remove (anIndex);
921 myStructsComputed .Remove (anIndex);
924 // Of which type will be the computed?
925 const Standard_Boolean toComputeWireframe = myVisualization == Graphic3d_TOV_WIREFRAME
926 && theStructure->ComputeVisual() != Graphic3d_TOS_SHADING;
927 const Standard_Boolean toComputeShading = myVisualization == Graphic3d_TOV_SHADING
928 && theStructure->ComputeVisual() != Graphic3d_TOS_WIREFRAME;
929 if (!toComputeShading && !toComputeWireframe)
931 anAnswer = Graphic3d_TOA_NO;
935 aStruct->SetVisual (toComputeWireframe ? Graphic3d_TOS_WIREFRAME : Graphic3d_TOS_SHADING);
936 anAnswer = acceptDisplay (aStruct->Visual());
939 if (theStructure->IsHighlighted())
941 aStruct->Highlight (theStructure->HighlightStyle(), Standard_False);
944 // It is displayed only if the calculated structure
945 // has a proper type corresponding to the one of the view.
946 if (anAnswer == Graphic3d_TOA_NO)
951 myStructsDisplayed.Add (theStructure);
952 displayStructure (aStruct->CStructure(), theStructure->DisplayPriority());
954 Update (aStruct->GetZLayer());
957 // =======================================================================
960 // =======================================================================
961 void Graphic3d_CView::Erase (const Handle(Graphic3d_Structure)& theStructure)
963 if (!IsDisplayed (theStructure))
968 const Graphic3d_TypeOfAnswer anAnswer = myIsInComputedMode ? acceptDisplay (theStructure->Visual()) : Graphic3d_TOA_YES;
969 if (anAnswer != Graphic3d_TOA_COMPUTE)
971 eraseStructure (theStructure->CStructure());
974 const Standard_Integer anIndex = !myStructsToCompute.IsEmpty() ? IsComputed (theStructure) : 0;
977 if (anAnswer == Graphic3d_TOA_COMPUTE
978 && myIsInComputedMode)
980 const Handle(Graphic3d_Structure)& aCompStruct = myStructsComputed.ChangeValue (anIndex);
981 eraseStructure (aCompStruct->CStructure());
983 myStructsComputed .Remove (anIndex);
984 myStructsToCompute.Remove (anIndex);
987 myStructsDisplayed.Remove (theStructure);
988 Update (theStructure->GetZLayer());
991 // =======================================================================
992 // function : Highlight
994 // =======================================================================
995 void Graphic3d_CView::Highlight (const Handle(Graphic3d_Structure)& theStructure)
997 const Standard_Integer anIndex = IsComputed (theStructure);
1000 const Handle(Graphic3d_Structure)& aCompStruct = myStructsComputed.ChangeValue (anIndex);
1001 aCompStruct->Highlight (theStructure->HighlightStyle(), Standard_False);
1005 // =======================================================================
1006 // function : SetTransform
1008 // =======================================================================
1009 void Graphic3d_CView::SetTransform (const Handle(Graphic3d_Structure)& theStructure,
1010 const Handle(TopLoc_Datum3D)& theTrsf)
1012 const Standard_Integer anIndex = IsComputed (theStructure);
1015 // Test is somewhat light !
1016 // trsf is transferred only if it is :
1019 if (!theTrsf.IsNull()
1020 && (theTrsf->Form() == gp_Translation
1021 || theTrsf->Form() == gp_Scale
1022 || theTrsf->Form() == gp_CompoundTrsf))
1024 ReCompute (theStructure);
1028 const Handle(Graphic3d_Structure)& aCompStruct = myStructsComputed.ChangeValue (anIndex);
1029 aCompStruct->GraphicTransform (theTrsf);
1033 theStructure->CalculateBoundBox();
1034 if (!theStructure->IsMutable()
1035 && !theStructure->CStructure()->IsForHighlight
1036 && !theStructure->CStructure()->IsInfinite)
1038 const Graphic3d_ZLayerId aLayerId = theStructure->GetZLayer();
1039 InvalidateBVHData (aLayerId);
1043 // =======================================================================
1044 // function : UnHighlight
1046 // =======================================================================
1047 void Graphic3d_CView::UnHighlight (const Handle(Graphic3d_Structure)& theStructure)
1049 Standard_Integer anIndex = IsComputed (theStructure);
1052 const Handle(Graphic3d_Structure)& aCompStruct = myStructsComputed.ChangeValue (anIndex);
1053 aCompStruct->CStructure()->GraphicUnhighlight();
1057 // ========================================================================
1058 // function : IsComputed
1060 // ========================================================================
1061 Standard_Boolean Graphic3d_CView::IsComputed (const Standard_Integer theStructId,
1062 Handle(Graphic3d_Structure)& theComputedStruct) const
1064 theComputedStruct.Nullify();
1065 if (!ComputedMode())
1066 return Standard_False;
1068 const Standard_Integer aNbStructs = myStructsToCompute.Length();
1069 for (Standard_Integer aStructIter = 1; aStructIter <= aNbStructs; ++aStructIter)
1071 if (myStructsToCompute.Value (aStructIter)->Identification() == theStructId)
1073 theComputedStruct = myStructsComputed (aStructIter);
1074 return Standard_True;
1077 return Standard_False;
1080 // =======================================================================
1081 // function : IsComputed
1083 // =======================================================================
1084 Standard_Integer Graphic3d_CView::IsComputed (const Graphic3d_Structure* theStructure) const
1086 const Standard_Integer aStructId = theStructure->Identification();
1087 Standard_Integer aStructIndex = 1;
1088 for (Graphic3d_SequenceOfStructure::Iterator aStructIter (myStructsToCompute); aStructIter.More(); aStructIter.Next(), ++aStructIndex)
1090 const Handle(Graphic3d_Structure)& aStruct = aStructIter.Value();
1091 if (aStruct->Identification() == aStructId)
1093 return aStructIndex;
1099 // =======================================================================
1100 // function : IsDisplayed
1102 // =======================================================================
1103 Standard_Boolean Graphic3d_CView::IsDisplayed (const Handle(Graphic3d_Structure)& theStructure) const
1105 return myStructsDisplayed.Contains (theStructure);
1108 // =======================================================================
1109 // function : ChangePriority
1111 // =======================================================================
1112 void Graphic3d_CView::ChangePriority (const Handle(Graphic3d_Structure)& theStructure,
1113 const Graphic3d_DisplayPriority /*theOldPriority*/,
1114 const Graphic3d_DisplayPriority theNewPriority)
1117 || !IsDisplayed (theStructure))
1122 if (!myIsInComputedMode)
1124 changePriority (theStructure->CStructure(), theNewPriority);
1128 const Standard_Integer anIndex = IsComputed (theStructure);
1129 const Handle(Graphic3d_CStructure)& aCStruct = anIndex != 0
1130 ? myStructsComputed.Value (anIndex)->CStructure()
1131 : theStructure->CStructure();
1133 changePriority (aCStruct, theNewPriority);
1136 // =======================================================================
1137 // function : ChangeZLayer
1139 // =======================================================================
1140 void Graphic3d_CView::ChangeZLayer (const Handle(Graphic3d_Structure)& theStructure,
1141 const Graphic3d_ZLayerId theLayerId)
1144 || !IsDisplayed (theStructure))
1149 if (!myIsInComputedMode)
1151 changeZLayer (theStructure->CStructure(), theLayerId);
1155 const Standard_Integer anIndex = IsComputed (theStructure);
1156 Handle(Graphic3d_CStructure) aCStruct = anIndex != 0
1157 ? myStructsComputed.Value (anIndex)->CStructure()
1158 : theStructure->CStructure();
1160 changeZLayer (aCStruct, theLayerId);
1163 // =======================================================================
1164 // function : HaveTheSameOwner
1166 // =======================================================================
1167 Standard_Integer Graphic3d_CView::HaveTheSameOwner (const Handle(Graphic3d_Structure)& theStructure) const
1169 // Find in the sequence of already calculated structures
1170 // 1/ Structure with the same Owner as <AStructure>
1171 // 2/ Which is not <AStructure>
1172 // 3/ COMPUTED which of is valid
1173 const Standard_Integer aNbToCompStructs = myStructsToCompute.Length();
1174 for (Standard_Integer aStructIter = 1; aStructIter <= aNbToCompStructs; ++aStructIter)
1176 const Handle(Graphic3d_Structure)& aStructToComp = myStructsToCompute.Value (aStructIter);
1177 if (aStructToComp->Owner() == theStructure->Owner()
1178 && aStructToComp->Identification() != theStructure->Identification())
1180 const Handle(Graphic3d_Structure)& aStructComp = myStructsComputed.Value (aStructIter);
1181 if (aStructComp->HLRValidation())
1190 // =======================================================================
1191 // function : CopySettings
1193 // =======================================================================
1194 void Graphic3d_CView::CopySettings (const Handle(Graphic3d_CView)& theOther)
1196 ChangeRenderingParams() = theOther->RenderingParams();
1197 SetBackground (theOther->Background());
1198 SetGradientBackground (theOther->GradientBackground());
1199 SetBackgroundImage (theOther->BackgroundImage());
1200 SetBackgroundImageStyle (theOther->BackgroundImageStyle());
1201 SetTextureEnv (theOther->TextureEnv());
1202 SetShadingModel (theOther->ShadingModel());
1203 SetBackfacingModel (theOther->BackfacingModel());
1204 SetCamera (new Graphic3d_Camera (theOther->Camera()));
1205 SetLights (theOther->Lights());
1206 SetClipPlanes (theOther->ClipPlanes());
1209 // =======================================================================
1210 // function : SetShadingModel
1212 // =======================================================================
1213 void Graphic3d_CView::SetShadingModel (Graphic3d_TypeOfShadingModel theModel)
1215 if (theModel == Graphic3d_TypeOfShadingModel_DEFAULT)
1217 throw Standard_ProgramError ("Graphic3d_CView::SetShadingModel() - attempt to set invalid Shading Model!");
1220 myRenderParams.ShadingModel = theModel;
1223 // =======================================================================
1224 // function : SetUnitFactor
1226 // =======================================================================
1227 void Graphic3d_CView::SetUnitFactor (Standard_Real theFactor)
1229 if (theFactor <= 0.0)
1231 throw Standard_ProgramError ("Graphic3d_CView::SetUnitFactor() - invalid unit factor");
1233 myUnitFactor = theFactor;
1234 if (!myXRSession.IsNull())
1236 myXRSession->SetUnitFactor (theFactor);
1240 // =======================================================================
1241 // function : IsActiveXR
1243 // =======================================================================
1244 bool Graphic3d_CView::IsActiveXR() const
1246 return !myXRSession.IsNull()
1247 && myXRSession->IsOpen();
1250 // =======================================================================
1251 // function : InitXR
1253 // =======================================================================
1254 bool Graphic3d_CView::InitXR()
1256 if (myXRSession.IsNull())
1258 myXRSession = new Aspect_OpenVRSession();
1259 myXRSession->SetUnitFactor (myUnitFactor);
1261 if (!myXRSession->IsOpen())
1263 myXRSession->Open();
1264 if (myBackXRCamera.IsNull())
1266 // backup camera properties
1267 myBackXRCamera = new Graphic3d_Camera (myCamera);
1270 return myXRSession->IsOpen();
1273 // =======================================================================
1274 // function : ReleaseXR
1276 // =======================================================================
1277 void Graphic3d_CView::ReleaseXR()
1279 if (!myXRSession.IsNull())
1281 if (myXRSession->IsOpen()
1282 && !myBackXRCamera.IsNull())
1284 // restore projection properties overridden by HMD
1285 myCamera->SetFOV2d (myBackXRCamera->FOV2d());
1286 myCamera->SetFOVy (myBackXRCamera->FOVy());
1287 myCamera->SetAspect(myBackXRCamera->Aspect());
1288 myCamera->SetIOD (myBackXRCamera->GetIODType(), myBackXRCamera->IOD());
1289 myCamera->SetZFocus(myBackXRCamera->ZFocusType(), myBackXRCamera->ZFocus());
1290 myCamera->ResetCustomProjection();
1291 myBackXRCamera.Nullify();
1293 myXRSession->Close();
1297 //=======================================================================
1298 //function : ProcessXRInput
1300 //=======================================================================
1301 void Graphic3d_CView::ProcessXRInput()
1303 if (myRenderParams.StereoMode == Graphic3d_StereoMode_OpenVR
1304 && myCamera->ProjectionType() == Graphic3d_Camera::Projection_Stereo)
1315 myBaseXRCamera.Nullify();
1316 myPosedXRCamera.Nullify();
1320 myXRSession->ProcessEvents();
1323 myCamera->SetFOV2d (myRenderParams.HmdFov2d);
1324 myCamera->SetAspect(myXRSession->Aspect());
1325 myCamera->SetFOVy (myXRSession->FieldOfView());
1326 myCamera->SetIOD (Graphic3d_Camera::IODType_Absolute, myXRSession->IOD());
1327 myCamera->SetZFocus(Graphic3d_Camera::FocusType_Absolute, 1.0 * myUnitFactor);
1329 // VR APIs tend to decompose camera orientation-projection matrices into the following components:
1331 // Model * [View * Eye^-1] * [Projection]
1333 // so that Eye position is encoded into Orientation matrix, and there should be 2 Orientation matrices and 2 Projection matrices to make the stereo.
1334 // Graphic3d_Camera historically follows different decomposition, with Eye position encoded into Projection matrix,
1335 // so that there is only 1 Orientation matrix (matching mono view) and 2 Projection matrices.
1336 if (myXRSession->HasProjectionFrustums())
1338 // note that this definition does not include a small forward/backward offset from head to eye
1339 myCamera->SetCustomStereoFrustums (myXRSession->ProjectionFrustum (Aspect_Eye_Left),
1340 myXRSession->ProjectionFrustum (Aspect_Eye_Right));
1344 const Graphic3d_Mat4d aPoseL = myXRSession->HeadToEyeTransform (Aspect_Eye_Left);
1345 const Graphic3d_Mat4d aPoseR = myXRSession->HeadToEyeTransform (Aspect_Eye_Right);
1346 const Graphic3d_Mat4d aProjL = myXRSession->ProjectionMatrix (Aspect_Eye_Left, myCamera->ZNear(), myCamera->ZFar());
1347 const Graphic3d_Mat4d aProjR = myXRSession->ProjectionMatrix (Aspect_Eye_Right, myCamera->ZNear(), myCamera->ZFar());
1348 myCamera->SetCustomStereoProjection (aProjL, aPoseL, aProjR, aPoseR);
1350 myBaseXRCamera = myCamera;
1351 if (myPosedXRCamera.IsNull())
1353 myPosedXRCamera = new Graphic3d_Camera();
1355 SynchronizeXRBaseToPosedCamera();
1358 //=======================================================================
1359 //function : SynchronizeXRBaseToPosedCamera
1361 //=======================================================================
1362 void Graphic3d_CView::SynchronizeXRBaseToPosedCamera()
1364 if (!myPosedXRCamera.IsNull())
1366 ComputeXRPosedCameraFromBase (*myPosedXRCamera, myXRSession->HeadPose());
1370 //=======================================================================
1371 //function : ComputeXRPosedCameraFromBase
1373 //=======================================================================
1374 void Graphic3d_CView::ComputeXRPosedCameraFromBase (Graphic3d_Camera& theCam,
1375 const gp_Trsf& theXRTrsf) const
1377 theCam.Copy (myBaseXRCamera);
1379 // convert head pose into camera transformation
1380 const gp_Ax3 anAxVr (gp::Origin(), gp::DZ(), gp::DX());
1381 const gp_Ax3 aCameraCS (gp::Origin(), -myBaseXRCamera->Direction(), -myBaseXRCamera->SideRight());
1383 aTrsfCS.SetTransformation (aCameraCS, anAxVr);
1384 const gp_Trsf aTrsfToCamera = aTrsfCS * theXRTrsf * aTrsfCS.Inverted();
1386 aTrsfToEye.SetTranslation (myBaseXRCamera->Eye().XYZ());
1388 const gp_Trsf aTrsf = aTrsfToEye * aTrsfToCamera;
1389 const gp_Dir anUpNew = myBaseXRCamera->Up().Transformed (aTrsf);
1390 const gp_Dir aDirNew = myBaseXRCamera->Direction().Transformed (aTrsf);
1391 const gp_Pnt anEyeNew = gp::Origin().Translated (aTrsf.TranslationPart());
1392 theCam.SetUp (anUpNew);
1393 theCam.SetDirectionFromEye (aDirNew);
1394 theCam.MoveEyeTo (anEyeNew);
1397 //=======================================================================
1398 //function : SynchronizeXRPosedToBaseCamera
1400 //=======================================================================
1401 void Graphic3d_CView::SynchronizeXRPosedToBaseCamera()
1403 if (myPosedXRCameraCopy.IsNull()
1404 || myPosedXRCamera.IsNull()
1405 || myBaseXRCamera.IsNull()
1406 || myCamera != myPosedXRCamera)
1411 if (myPosedXRCameraCopy->Eye().IsEqual (myPosedXRCamera->Eye(), gp::Resolution())
1412 && (myPosedXRCameraCopy->Distance() - myPosedXRCamera->Distance()) <= gp::Resolution()
1413 && myPosedXRCameraCopy->Direction().IsEqual (myPosedXRCamera->Direction(), gp::Resolution())
1414 && myPosedXRCameraCopy->Up().IsEqual (myPosedXRCamera->Up(), gp::Resolution()))
1416 // avoid floating point math in case of no changes
1420 // re-compute myBaseXRCamera from myPosedXRCamera by applying reversed head pose transformation
1421 ComputeXRBaseCameraFromPosed (myPosedXRCamera, myXRSession->HeadPose());
1422 myPosedXRCameraCopy->Copy (myPosedXRCamera);
1425 //=======================================================================
1426 //function : ComputeXRBaseCameraFromPosed
1428 //=======================================================================
1429 void Graphic3d_CView::ComputeXRBaseCameraFromPosed (const Graphic3d_Camera& theCamPosed,
1430 const gp_Trsf& thePoseTrsf)
1432 const gp_Ax3 anAxVr (gp::Origin(), gp::DZ(), gp::DX());
1433 const gp_Ax3 aCameraCS (gp::Origin(), -myBaseXRCamera->Direction(), -myBaseXRCamera->SideRight());
1435 aTrsfCS.SetTransformation (aCameraCS, anAxVr);
1436 const gp_Trsf aTrsfToCamera = aTrsfCS * thePoseTrsf * aTrsfCS.Inverted();
1437 const gp_Trsf aTrsfCamToHead = aTrsfToCamera.Inverted();
1438 const gp_Dir anUpNew = theCamPosed.Up().Transformed (aTrsfCamToHead);
1439 const gp_Dir aDirNew = theCamPosed.Direction().Transformed (aTrsfCamToHead);
1440 const gp_Pnt anEyeNew = theCamPosed.Eye().Translated (aTrsfToCamera.TranslationPart().Reversed());
1441 myBaseXRCamera->SetUp (anUpNew);
1442 myBaseXRCamera->SetDirectionFromEye (aDirNew);
1443 myBaseXRCamera->MoveEyeTo (anEyeNew);
1446 //=======================================================================
1447 //function : TurnViewXRCamera
1449 //=======================================================================
1450 void Graphic3d_CView::TurnViewXRCamera (const gp_Trsf& theTrsfTurn)
1452 // use current eye position as an anchor
1453 const Handle(Graphic3d_Camera)& aCamBase = myBaseXRCamera;
1454 gp_Trsf aHeadTrsfLocal;
1455 aHeadTrsfLocal.SetTranslationPart (myXRSession->HeadPose().TranslationPart());
1456 const gp_Pnt anEyeAnchor = PoseXRToWorld (aHeadTrsfLocal).TranslationPart();
1459 aCamBase->SetDirectionFromEye (aCamBase->Direction().Transformed (theTrsfTurn));
1461 // recompute new eye
1462 const gp_Ax3 anAxVr (gp::Origin(), gp::DZ(), gp::DX());
1463 const gp_Ax3 aCameraCS (gp::Origin(), -aCamBase->Direction(), -aCamBase->SideRight());
1465 aTrsfCS.SetTransformation (aCameraCS, anAxVr);
1466 const gp_Trsf aTrsfToCamera = aTrsfCS * aHeadTrsfLocal * aTrsfCS.Inverted();
1467 const gp_Pnt anEyeNew = anEyeAnchor.Translated (aTrsfToCamera.TranslationPart().Reversed());
1468 aCamBase->MoveEyeTo (anEyeNew);
1470 SynchronizeXRBaseToPosedCamera();
1473 //=======================================================================
1474 //function : SetupXRPosedCamera
1476 //=======================================================================
1477 void Graphic3d_CView::SetupXRPosedCamera()
1479 if (!myPosedXRCamera.IsNull())
1481 myCamera = myPosedXRCamera;
1482 if (myPosedXRCameraCopy.IsNull())
1484 myPosedXRCameraCopy = new Graphic3d_Camera();
1486 myPosedXRCameraCopy->Copy (myPosedXRCamera);
1490 //=======================================================================
1491 //function : UnsetXRPosedCamera
1493 //=======================================================================
1494 void Graphic3d_CView::UnsetXRPosedCamera()
1496 if (myCamera == myPosedXRCamera
1497 && !myBaseXRCamera.IsNull())
1499 SynchronizeXRPosedToBaseCamera();
1500 myCamera = myBaseXRCamera;
1504 //=======================================================================
1505 //function : DiagnosticInformation
1507 //=======================================================================
1508 void Graphic3d_CView::DiagnosticInformation (TColStd_IndexedDataMapOfStringString& theDict,
1509 Graphic3d_DiagnosticInfo theFlags) const
1511 if ((theFlags & Graphic3d_DiagnosticInfo_Device) != 0
1512 && !myXRSession.IsNull())
1514 TCollection_AsciiString aVendor = myXRSession->GetString (Aspect_XRSession::InfoString_Vendor);
1515 TCollection_AsciiString aDevice = myXRSession->GetString (Aspect_XRSession::InfoString_Device);
1516 TCollection_AsciiString aTracker = myXRSession->GetString (Aspect_XRSession::InfoString_Tracker);
1517 TCollection_AsciiString aSerial = myXRSession->GetString (Aspect_XRSession::InfoString_SerialNumber);
1518 TCollection_AsciiString aDisplay = TCollection_AsciiString()
1519 + myXRSession->RecommendedViewport().x() + "x" + myXRSession->RecommendedViewport().y()
1520 + "@" + (int )Round (myXRSession->DisplayFrequency())
1521 + " [FOVy: " + (int )Round (myXRSession->FieldOfView()) + "]";
1523 theDict.ChangeFromIndex (theDict.Add ("VRvendor", aVendor)) = aVendor;
1524 theDict.ChangeFromIndex (theDict.Add ("VRdevice", aDevice)) = aDevice;
1525 theDict.ChangeFromIndex (theDict.Add ("VRtracker", aTracker)) = aTracker;
1526 theDict.ChangeFromIndex (theDict.Add ("VRdisplay", aDisplay)) = aDisplay;
1527 theDict.ChangeFromIndex (theDict.Add ("VRserial", aSerial)) = aSerial;
1531 //=======================================================================
1532 //function : DumpJson
1534 //=======================================================================
1535 void Graphic3d_CView::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const
1537 OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
1539 OCCT_DUMP_BASE_CLASS (theOStream, theDepth, Graphic3d_DataStructureManager);
1541 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myId)
1542 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myRenderParams)
1543 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myBgColor)
1544 OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myStructureManager)
1545 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myCamera.get())
1547 for (Graphic3d_SequenceOfStructure::Iterator anIter (myStructsToCompute); anIter.More(); anIter.Next())
1549 const Handle(Graphic3d_Structure)& aStructToCompute = anIter.Value();
1550 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, aStructToCompute.get())
1553 for (Graphic3d_SequenceOfStructure::Iterator anIter (myStructsComputed); anIter.More(); anIter.Next())
1555 const Handle(Graphic3d_Structure)& aStructComputed = anIter.Value();
1556 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, aStructComputed.get())
1559 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myIsInComputedMode)
1560 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myIsActive)
1561 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myIsRemoved)
1563 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myVisualization)
1565 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myBackXRCamera.get())
1566 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myBaseXRCamera.get())
1567 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myPosedXRCamera.get())
1568 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myPosedXRCameraCopy.get())
1570 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myUnitFactor)