1 // Copyright (c) 1999-2014 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 <V3d_Viewer.hxx>
16 #include <Aspect_Grid.hxx>
17 #include <Aspect_IdentDefinitionError.hxx>
18 #include <Graphic3d_ArrayOfPoints.hxx>
19 #include <Graphic3d_ArrayOfSegments.hxx>
20 #include <Graphic3d_AspectLine3d.hxx>
21 #include <Graphic3d_AspectMarker3d.hxx>
22 #include <Graphic3d_AspectText3d.hxx>
23 #include <Graphic3d_GraphicDriver.hxx>
24 #include <Graphic3d_Group.hxx>
25 #include <Graphic3d_Structure.hxx>
26 #include <Graphic3d_Text.hxx>
27 #include <Standard_ErrorHandler.hxx>
29 #include <V3d_BadValue.hxx>
30 #include <V3d_CircularGrid.hxx>
31 #include <V3d_AmbientLight.hxx>
32 #include <V3d_DirectionalLight.hxx>
33 #include <V3d_RectangularGrid.hxx>
34 #include <V3d_View.hxx>
36 IMPLEMENT_STANDARD_RTTIEXT(V3d_Viewer, Standard_Transient)
38 // ========================================================================
39 // function : V3d_Viewer
41 // ========================================================================
42 V3d_Viewer::V3d_Viewer (const Handle(Graphic3d_GraphicDriver)& theDriver)
43 : myDriver (theDriver),
44 myStructureManager (new Graphic3d_StructureManager (theDriver)),
45 myZLayerGenId (1, IntegerLast()),
46 myBackground (Quantity_NOC_GRAY30),
48 myViewProj (V3d_XposYnegZpos),
49 myVisualization (V3d_ZBUFFER),
50 myDefaultTypeOfView (V3d_ORTHOGRAPHIC),
51 myComputedMode (Standard_True),
52 myDefaultComputedMode (Standard_False),
53 myPrivilegedPlane (gp_Ax3 (gp_Pnt (0.,0.,0), gp_Dir (0.,0.,1.), gp_Dir (1.,0.,0.))),
54 myDisplayPlane (Standard_False),
55 myDisplayPlaneLength (1000.0),
56 myGridType (Aspect_GT_Rectangular),
57 myGridEcho (Standard_True),
58 myGridEchoLastVert (ShortRealLast(), ShortRealLast(), ShortRealLast())
60 myDefaultRenderingParams.ShadingModel = Graphic3d_TOSM_VERTEX;
63 // ========================================================================
64 // function : CreateView
66 // ========================================================================
67 Handle(V3d_View) V3d_Viewer::CreateView ()
69 return new V3d_View(this, myDefaultTypeOfView);
72 // ========================================================================
73 // function : SetViewOn
75 // ========================================================================
76 void V3d_Viewer::SetViewOn()
78 for (V3d_ListOfView::Iterator aDefViewIter (myDefinedViews); aDefViewIter.More(); aDefViewIter.Next())
80 SetViewOn (aDefViewIter.Value());
84 // ========================================================================
85 // function : SetViewOff
87 // ========================================================================
88 void V3d_Viewer::SetViewOff()
90 for (V3d_ListOfView::Iterator aDefViewIter (myDefinedViews); aDefViewIter.More(); aDefViewIter.Next())
92 SetViewOff (aDefViewIter.Value());
96 // ========================================================================
97 // function : SetViewOn
99 // ========================================================================
100 void V3d_Viewer::SetViewOn (const Handle(V3d_View)& theView)
102 Handle(Graphic3d_CView) aViewImpl = theView->View();
103 if (!aViewImpl->IsDefined() || myActiveViews.Contains (theView))
108 myActiveViews.Append (theView);
109 aViewImpl->Activate();
110 for (V3d_ListOfLight::Iterator anActiveLightIter (myActiveLights); anActiveLightIter.More(); anActiveLightIter.Next())
112 theView->SetLightOn (anActiveLightIter.Value());
114 if (Handle(Aspect_Grid) aGrid = Grid (false))
116 theView->SetGrid (myPrivilegedPlane, aGrid);
117 theView->SetGridActivity (aGrid->IsActive());
119 if (theView->SetImmediateUpdate (Standard_False))
122 theView->SetImmediateUpdate (Standard_True);
126 // ========================================================================
127 // function : SetViewOff
129 // ========================================================================
130 void V3d_Viewer::SetViewOff (const Handle(V3d_View)& theView)
132 Handle(Graphic3d_CView) aViewImpl = theView->View();
133 if (aViewImpl->IsDefined() && myActiveViews.Contains (theView))
135 myActiveViews.Remove (theView);
136 aViewImpl->Deactivate() ;
140 // ========================================================================
143 // ========================================================================
144 void V3d_Viewer::Redraw() const
146 for (V3d_ListOfView::Iterator aDefViewIter (myDefinedViews); aDefViewIter.More(); aDefViewIter.Next())
148 aDefViewIter.Value()->Redraw();
152 // ========================================================================
153 // function : RedrawImmediate
155 // ========================================================================
156 void V3d_Viewer::RedrawImmediate() const
158 for (V3d_ListOfView::Iterator aDefViewIter (myDefinedViews); aDefViewIter.More(); aDefViewIter.Next())
160 aDefViewIter.Value()->RedrawImmediate();
164 // ========================================================================
165 // function : Invalidate
167 // ========================================================================
168 void V3d_Viewer::Invalidate() const
170 for (V3d_ListOfView::Iterator aDefViewIter (myDefinedViews); aDefViewIter.More(); aDefViewIter.Next())
172 aDefViewIter.Value()->Invalidate();
176 // ========================================================================
179 // ========================================================================
180 void V3d_Viewer::Remove()
182 myStructureManager->Remove();
185 // ========================================================================
188 // ========================================================================
189 void V3d_Viewer::Erase() const
191 myStructureManager->Erase();
194 // ========================================================================
195 // function : UnHighlight
197 // ========================================================================
198 void V3d_Viewer::UnHighlight() const
200 myStructureManager->UnHighlight();
203 void V3d_Viewer::SetDefaultViewSize (const Standard_Real theSize)
206 throw V3d_BadValue("V3d_Viewer::SetDefaultViewSize, bad size");
207 myViewSize = theSize;
210 // ========================================================================
211 // function : IfMoreViews
213 // ========================================================================
214 Standard_Boolean V3d_Viewer::IfMoreViews() const
216 return myDefinedViews.Size() < myStructureManager->MaxNumOfViews();
219 // ========================================================================
220 // function : AddView
222 // ========================================================================
223 void V3d_Viewer::AddView (const Handle(V3d_View)& theView)
225 if (!myDefinedViews.Contains (theView))
227 myDefinedViews.Append (theView);
231 // ========================================================================
232 // function : DelView
234 // ========================================================================
235 void V3d_Viewer::DelView (const Handle(V3d_View)& theView)
237 myActiveViews.Remove (theView);
238 myDefinedViews.Remove (theView);
241 //=======================================================================
242 //function : InsertLayerBefore
244 //=======================================================================
245 Standard_Boolean V3d_Viewer::InsertLayerBefore (Graphic3d_ZLayerId& theNewLayerId,
246 const Graphic3d_ZLayerSettings& theSettings,
247 const Graphic3d_ZLayerId theLayerAfter)
249 if (myZLayerGenId.Next (theNewLayerId))
251 myLayerIds.Add (theNewLayerId);
252 myDriver->InsertLayerBefore (theNewLayerId, theSettings, theLayerAfter);
253 return Standard_True;
255 return Standard_False;
258 //=======================================================================
259 //function : InsertLayerAfter
261 //=======================================================================
262 Standard_Boolean V3d_Viewer::InsertLayerAfter (Graphic3d_ZLayerId& theNewLayerId,
263 const Graphic3d_ZLayerSettings& theSettings,
264 const Graphic3d_ZLayerId theLayerBefore)
266 if (myZLayerGenId.Next (theNewLayerId))
268 myLayerIds.Add (theNewLayerId);
269 myDriver->InsertLayerAfter (theNewLayerId, theSettings, theLayerBefore);
270 return Standard_True;
272 return Standard_False;
275 //=======================================================================
276 //function : RemoveZLayer
278 //=======================================================================
279 Standard_Boolean V3d_Viewer::RemoveZLayer (const Graphic3d_ZLayerId theLayerId)
281 if (!myLayerIds.Contains (theLayerId)
282 || theLayerId < myZLayerGenId.Lower()
283 || theLayerId > myZLayerGenId.Upper())
285 return Standard_False;
288 myDriver->RemoveZLayer (theLayerId);
289 myLayerIds.Remove (theLayerId);
290 myZLayerGenId.Free (theLayerId);
292 return Standard_True;
295 //=======================================================================
296 //function : GetAllZLayers
298 //=======================================================================
299 void V3d_Viewer::GetAllZLayers (TColStd_SequenceOfInteger& theLayerSeq) const
301 myDriver->ZLayers (theLayerSeq);
304 //=======================================================================
305 //function : SetZLayerSettings
307 //=======================================================================
308 void V3d_Viewer::SetZLayerSettings (const Graphic3d_ZLayerId theLayerId, const Graphic3d_ZLayerSettings& theSettings)
310 myDriver->SetZLayerSettings (theLayerId, theSettings);
313 //=======================================================================
314 //function : ZLayerSettings
316 //=======================================================================
317 const Graphic3d_ZLayerSettings& V3d_Viewer::ZLayerSettings (const Graphic3d_ZLayerId theLayerId) const
319 return myDriver->ZLayerSettings (theLayerId);
322 //=======================================================================
323 //function : UpdateLights
325 //=======================================================================
326 void V3d_Viewer::UpdateLights()
328 for (V3d_ListOfView::Iterator anActiveViewIter (myActiveViews); anActiveViewIter.More(); anActiveViewIter.Next())
330 anActiveViewIter.Value()->UpdateLights();
334 //=======================================================================
335 //function : SetLightOn
337 //=======================================================================
338 void V3d_Viewer::SetLightOn (const Handle(V3d_Light)& theLight)
340 if (!myActiveLights.Contains (theLight))
342 myActiveLights.Append (theLight);
345 for (V3d_ListOfView::Iterator anActiveViewIter (myActiveViews); anActiveViewIter.More(); anActiveViewIter.Next())
347 anActiveViewIter.Value()->SetLightOn (theLight);
351 //=======================================================================
352 //function : SetLightOff
354 //=======================================================================
355 void V3d_Viewer::SetLightOff (const Handle(V3d_Light)& theLight)
357 myActiveLights.Remove (theLight);
358 for (V3d_ListOfView::Iterator anActiveViewIter (myActiveViews); anActiveViewIter.More(); anActiveViewIter.Next())
360 anActiveViewIter.Value()->SetLightOff (theLight);
364 //=======================================================================
365 //function : SetLightOn
367 //=======================================================================
368 void V3d_Viewer::SetLightOn()
370 for (V3d_ListOfLight::Iterator aDefLightIter (myDefinedLights); aDefLightIter.More(); aDefLightIter.Next())
372 if (!myActiveLights.Contains (aDefLightIter.Value()))
374 myActiveLights.Append (aDefLightIter.Value());
375 for (V3d_ListOfView::Iterator anActiveViewIter (myActiveViews); anActiveViewIter.More(); anActiveViewIter.Next())
377 anActiveViewIter.Value()->SetLightOn (aDefLightIter.Value());
383 //=======================================================================
384 //function : SetLightOff
386 //=======================================================================
387 void V3d_Viewer::SetLightOff()
389 for (V3d_ListOfLight::Iterator anActiveLightIter (myActiveLights); anActiveLightIter.More(); anActiveLightIter.Next())
391 for (V3d_ListOfView::Iterator anActiveViewIter (myActiveViews); anActiveViewIter.More(); anActiveViewIter.Next())
393 anActiveViewIter.Value()->SetLightOff (anActiveLightIter.Value());
396 myActiveLights.Clear();
399 //=======================================================================
400 //function : IsGlobalLight
402 //=======================================================================
403 Standard_Boolean V3d_Viewer::IsGlobalLight (const Handle(V3d_Light)& theLight) const
405 return myActiveLights.Contains (theLight);
408 //=======================================================================
409 //function : AddLight
411 //=======================================================================
412 void V3d_Viewer::AddLight (const Handle(V3d_Light)& theLight)
414 if (!myDefinedLights.Contains (theLight))
416 myDefinedLights.Append (theLight);
420 //=======================================================================
421 //function : DelLight
423 //=======================================================================
424 void V3d_Viewer::DelLight (const Handle(V3d_Light)& theLight)
426 SetLightOff (theLight);
427 myDefinedLights.Remove (theLight);
430 //=======================================================================
431 //function : SetDefaultLights
433 //=======================================================================
434 void V3d_Viewer::SetDefaultLights()
436 while (!myDefinedLights.IsEmpty())
438 Handle(V3d_Light) aLight = myDefinedLights.First();
442 Handle(V3d_DirectionalLight) aDirLight = new V3d_DirectionalLight (V3d_Zneg, Quantity_NOC_WHITE, Standard_True);
443 Handle(V3d_AmbientLight) anAmbLight = new V3d_AmbientLight (Quantity_NOC_WHITE);
444 AddLight (aDirLight);
445 AddLight (anAmbLight);
446 SetLightOn (aDirLight);
447 SetLightOn (anAmbLight);
450 //=======================================================================
451 //function : SetPrivilegedPlane
453 //=======================================================================
454 void V3d_Viewer::SetPrivilegedPlane (const gp_Ax3& thePlane)
456 myPrivilegedPlane = thePlane;
457 Handle(Aspect_Grid) aGrid = Grid (true);
458 aGrid->SetDrawMode (aGrid->DrawMode()); // aGrid->UpdateDisplay();
459 for (V3d_ListOfView::Iterator anActiveViewIter (myActiveViews); anActiveViewIter.More(); anActiveViewIter.Next())
461 anActiveViewIter.Value()->SetGrid (myPrivilegedPlane, aGrid);
466 DisplayPrivilegedPlane (Standard_True, myDisplayPlaneLength);
470 //=======================================================================
471 //function : DisplayPrivilegedPlane
473 //=======================================================================
474 void V3d_Viewer::DisplayPrivilegedPlane (const Standard_Boolean theOnOff, const Standard_Real theSize)
476 myDisplayPlane = theOnOff;
477 myDisplayPlaneLength = theSize;
481 if (!myPlaneStructure.IsNull())
483 myPlaneStructure->Erase();
488 if (myPlaneStructure.IsNull())
490 myPlaneStructure = new Graphic3d_Structure (StructureManager());
491 myPlaneStructure->SetInfiniteState (Standard_True);
492 myPlaneStructure->Display();
496 myPlaneStructure->Clear();
499 Handle(Graphic3d_Group) aGroup = myPlaneStructure->NewGroup();
501 Handle(Graphic3d_AspectLine3d) aLineAttrib = new Graphic3d_AspectLine3d (Quantity_NOC_GRAY60, Aspect_TOL_SOLID, 1.0);
502 aGroup->SetGroupPrimitivesAspect (aLineAttrib);
504 Handle(Graphic3d_AspectText3d) aTextAttrib = new Graphic3d_AspectText3d();
505 aTextAttrib->SetColor (Quantity_Color (Quantity_NOC_ROYALBLUE1));
506 aGroup->SetGroupPrimitivesAspect (aTextAttrib);
508 Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments (6);
510 const gp_Pnt& p0 = myPrivilegedPlane.Location();
512 const gp_Pnt pX (p0.XYZ() + myDisplayPlaneLength * myPrivilegedPlane.XDirection().XYZ());
513 aPrims->AddVertex (p0);
514 aPrims->AddVertex (pX);
515 Handle(Graphic3d_Text) aText = new Graphic3d_Text (1.0f / 81.0f);
516 aText->SetText ("X");
517 aText->SetPosition (pX);
518 aGroup->AddText (aText);
520 const gp_Pnt pY (p0.XYZ() + myDisplayPlaneLength * myPrivilegedPlane.YDirection().XYZ());
521 aPrims->AddVertex (p0);
522 aPrims->AddVertex (pY);
523 aText = new Graphic3d_Text (1.0f / 81.0f);
524 aText->SetText ("Y");
525 aText->SetPosition (pY);
526 aGroup->AddText (aText);
528 const gp_Pnt pZ (p0.XYZ() + myDisplayPlaneLength * myPrivilegedPlane.Direction().XYZ());
529 aPrims->AddVertex (p0);
530 aPrims->AddVertex (pZ);
531 aText = new Graphic3d_Text (1.0f / 81.0f);
532 aText->SetText ("Z");
533 aText->SetPosition (pZ);
534 aGroup->AddText (aText);
536 aGroup->AddPrimitiveArray (aPrims);
538 myPlaneStructure->Display();
541 // =======================================================================
544 // =======================================================================
545 Handle(Aspect_Grid) V3d_Viewer::Grid (Aspect_GridType theGridType, bool theToCreate)
549 case Aspect_GT_Circular:
551 if (myCGrid.IsNull() && theToCreate)
553 myCGrid = new V3d_CircularGrid (this, Quantity_Color(Quantity_NOC_GRAY50), Quantity_Color(Quantity_NOC_GRAY70));
555 return Handle(Aspect_Grid) (myCGrid);
557 case Aspect_GT_Rectangular:
559 if (myRGrid.IsNull() && theToCreate)
561 myRGrid = new V3d_RectangularGrid (this, Quantity_Color(Quantity_NOC_GRAY50), Quantity_Color(Quantity_NOC_GRAY70));
563 return Handle(Aspect_Grid) (myRGrid);
566 return Handle(Aspect_Grid)();
569 // =======================================================================
570 // function : GridDrawMode
572 // =======================================================================
573 Aspect_GridDrawMode V3d_Viewer::GridDrawMode()
575 Handle(Aspect_Grid) aGrid = Grid (false);
576 return !aGrid.IsNull() ? aGrid->DrawMode() : Aspect_GDM_Lines;
579 // =======================================================================
580 // function : ActivateGrid
582 // =======================================================================
583 void V3d_Viewer::ActivateGrid (const Aspect_GridType theType,
584 const Aspect_GridDrawMode theMode)
586 if (Handle(Aspect_Grid) anOldGrid = Grid (false))
591 myGridType = theType;
592 Handle(Aspect_Grid) aGrid = Grid (true);
593 aGrid->SetDrawMode (theMode);
594 if (theMode != Aspect_GDM_None)
599 for (V3d_ListOfView::Iterator anActiveViewIter (myActiveViews); anActiveViewIter.More(); anActiveViewIter.Next())
601 anActiveViewIter.Value()->SetGrid (myPrivilegedPlane, aGrid);
605 // =======================================================================
606 // function : DeactivateGrid
608 // =======================================================================
609 void V3d_Viewer::DeactivateGrid()
611 Handle(Aspect_Grid) aGrid = Grid (false);
620 myGridType = Aspect_GT_Rectangular;
621 for (V3d_ListOfView::Iterator anActiveViewIter (myActiveViews); anActiveViewIter.More(); anActiveViewIter.Next())
623 anActiveViewIter.Value()->SetGridActivity (Standard_False);
625 && !myGridEchoStructure.IsNull())
627 myGridEchoStructure->Erase();
632 // =======================================================================
633 // function : IsGridActive
635 // =======================================================================
636 Standard_Boolean V3d_Viewer::IsGridActive()
638 Handle(Aspect_Grid) aGrid = Grid (false);
639 return !aGrid.IsNull() && aGrid->IsActive();
642 // =======================================================================
643 // function : RectangularGridValues
645 // =======================================================================
646 void V3d_Viewer::RectangularGridValues (Standard_Real& theXOrigin,
647 Standard_Real& theYOrigin,
648 Standard_Real& theXStep,
649 Standard_Real& theYStep,
650 Standard_Real& theRotationAngle)
652 Grid (Aspect_GT_Rectangular, true);
653 theXOrigin = myRGrid->XOrigin();
654 theYOrigin = myRGrid->YOrigin();
655 theXStep = myRGrid->XStep();
656 theYStep = myRGrid->YStep();
657 theRotationAngle = myRGrid->RotationAngle();
660 // =======================================================================
661 // function : SetRectangularGridValues
663 // =======================================================================
664 void V3d_Viewer::SetRectangularGridValues (const Standard_Real theXOrigin,
665 const Standard_Real theYOrigin,
666 const Standard_Real theXStep,
667 const Standard_Real theYStep,
668 const Standard_Real theRotationAngle)
670 Grid (Aspect_GT_Rectangular, true);
671 myRGrid->SetGridValues (theXOrigin, theYOrigin, theXStep, theYStep, theRotationAngle);
672 for (V3d_ListOfView::Iterator anActiveViewIter (myActiveViews); anActiveViewIter.More(); anActiveViewIter.Next())
674 anActiveViewIter.Value()->SetGrid (myPrivilegedPlane, myRGrid);
678 // =======================================================================
679 // function : CircularGridValues
681 // =======================================================================
682 void V3d_Viewer::CircularGridValues (Standard_Real& theXOrigin,
683 Standard_Real& theYOrigin,
684 Standard_Real& theRadiusStep,
685 Standard_Integer& theDivisionNumber,
686 Standard_Real& theRotationAngle)
688 Grid (Aspect_GT_Circular, true);
689 theXOrigin = myCGrid->XOrigin();
690 theYOrigin = myCGrid->YOrigin();
691 theRadiusStep = myCGrid->RadiusStep();
692 theDivisionNumber = myCGrid->DivisionNumber();
693 theRotationAngle = myCGrid->RotationAngle();
696 // =======================================================================
697 // function : SetCircularGridValues
699 // =======================================================================
700 void V3d_Viewer::SetCircularGridValues (const Standard_Real theXOrigin,
701 const Standard_Real theYOrigin,
702 const Standard_Real theRadiusStep,
703 const Standard_Integer theDivisionNumber,
704 const Standard_Real theRotationAngle)
706 Grid (Aspect_GT_Circular, true);
707 myCGrid->SetGridValues (theXOrigin, theYOrigin, theRadiusStep,
708 theDivisionNumber, theRotationAngle);
709 for (V3d_ListOfView::Iterator anActiveViewIter (myActiveViews); anActiveViewIter.More(); anActiveViewIter.Next())
711 anActiveViewIter.Value()->SetGrid (myPrivilegedPlane, myCGrid);
715 // =======================================================================
716 // function : RectangularGridGraphicValues
718 // =======================================================================
719 void V3d_Viewer::RectangularGridGraphicValues (Standard_Real& theXSize,
720 Standard_Real& theYSize,
721 Standard_Real& theOffSet)
723 Grid (Aspect_GT_Rectangular, true);
724 myRGrid->GraphicValues (theXSize, theYSize, theOffSet);
727 // =======================================================================
728 // function : SetRectangularGridGraphicValues
730 // =======================================================================
731 void V3d_Viewer::SetRectangularGridGraphicValues (const Standard_Real theXSize,
732 const Standard_Real theYSize,
733 const Standard_Real theOffSet)
735 Grid (Aspect_GT_Rectangular, true);
736 myRGrid->SetGraphicValues (theXSize, theYSize, theOffSet);
739 // =======================================================================
740 // function : CircularGridGraphicValues
742 // =======================================================================
743 void V3d_Viewer::CircularGridGraphicValues (Standard_Real& theRadius,
744 Standard_Real& theOffSet)
746 Grid (Aspect_GT_Circular, true);
747 myCGrid->GraphicValues (theRadius, theOffSet);
750 // =======================================================================
751 // function : SetCircularGridGraphicValues
753 // =======================================================================
754 void V3d_Viewer::SetCircularGridGraphicValues (const Standard_Real theRadius,
755 const Standard_Real theOffSet)
757 Grid (Aspect_GT_Circular, true);
758 myCGrid->SetGraphicValues (theRadius, theOffSet);
761 // =======================================================================
762 // function : SetGridEcho
764 // =======================================================================
765 void V3d_Viewer::SetGridEcho (const Standard_Boolean theToShowGrid)
767 if (myGridEcho == theToShowGrid)
772 myGridEcho = theToShowGrid;
774 || myGridEchoStructure.IsNull())
779 myGridEchoStructure->Erase();
782 // =======================================================================
783 // function : SetGridEcho
785 // =======================================================================
786 void V3d_Viewer::SetGridEcho (const Handle(Graphic3d_AspectMarker3d)& theMarker)
788 if (myGridEchoStructure.IsNull())
790 myGridEchoStructure = new Graphic3d_Structure (StructureManager());
791 myGridEchoGroup = myGridEchoStructure->NewGroup();
794 myGridEchoAspect = theMarker;
795 myGridEchoGroup->SetPrimitivesAspect (theMarker);
798 // =======================================================================
799 // function : ShowGridEcho
801 // =======================================================================
802 void V3d_Viewer::ShowGridEcho (const Handle(V3d_View)& theView,
803 const Graphic3d_Vertex& theVertex)
810 if (myGridEchoStructure.IsNull())
812 myGridEchoStructure = new Graphic3d_Structure (StructureManager());
813 myGridEchoGroup = myGridEchoStructure->NewGroup();
815 myGridEchoAspect = new Graphic3d_AspectMarker3d (Aspect_TOM_STAR, Quantity_Color (Quantity_NOC_GRAY90), 3.0);
816 myGridEchoGroup->SetPrimitivesAspect (myGridEchoAspect);
819 if (theVertex.X() == myGridEchoLastVert.X()
820 && theVertex.Y() == myGridEchoLastVert.Y()
821 && theVertex.Z() == myGridEchoLastVert.Z())
826 myGridEchoLastVert = theVertex;
827 myGridEchoGroup->Clear();
828 myGridEchoGroup->SetPrimitivesAspect (myGridEchoAspect);
830 Handle(Graphic3d_ArrayOfPoints) anArrayOfPoints = new Graphic3d_ArrayOfPoints (1);
831 anArrayOfPoints->AddVertex (theVertex.X(), theVertex.Y(), theVertex.Z());
832 myGridEchoGroup->AddPrimitiveArray (anArrayOfPoints);
834 myGridEchoStructure->SetZLayer (Graphic3d_ZLayerId_Topmost);
835 myGridEchoStructure->SetInfiniteState (Standard_True);
836 myGridEchoStructure->CStructure()->ViewAffinity = new Graphic3d_ViewAffinity();
837 myGridEchoStructure->CStructure()->ViewAffinity->SetVisible (Standard_False);
838 myGridEchoStructure->CStructure()->ViewAffinity->SetVisible (theView->View()->Identification(), true);
839 myGridEchoStructure->Display();
842 // =======================================================================
843 // function : HideGridEcho
845 // =======================================================================
846 void V3d_Viewer::HideGridEcho (const Handle(V3d_View)& theView)
848 if (myGridEchoStructure.IsNull())
853 myGridEchoLastVert.SetCoord (ShortRealLast(), ShortRealLast(), ShortRealLast());
854 const Handle(Graphic3d_ViewAffinity)& anAffinity = myGridEchoStructure->CStructure()->ViewAffinity;
855 if (!anAffinity.IsNull() && anAffinity->IsVisible (theView->View()->Identification()))
857 myGridEchoStructure->Erase();
861 //=======================================================================
862 //function : DumpJson
864 //=======================================================================
865 void V3d_Viewer::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const
867 OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
869 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myDriver.get())
870 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myStructureManager.get())
871 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myZLayerGenId)
873 for (V3d_ListOfView::Iterator anIter (myDefinedViews); anIter.More(); anIter.Next())
875 const Handle(V3d_View)& aDefinedView = anIter.Value();
876 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, aDefinedView.get())
879 for (V3d_ListOfView::Iterator anIter (myActiveViews); anIter.More(); anIter.Next())
881 const Handle(V3d_View)& anActiveView = anIter.Value();
882 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, anActiveView.get())
885 for (V3d_ListOfLight::Iterator anIter (myDefinedLights); anIter.More(); anIter.Next())
887 const Handle(Graphic3d_CLight)& aDefinedLight = anIter.Value();
888 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, aDefinedLight.get())
891 for (V3d_ListOfLight::Iterator anIter (myActiveLights); anIter.More(); anIter.Next())
893 const Handle(Graphic3d_CLight)& anActiveLight = anIter.Value();
894 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, anActiveLight.get())
897 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myBackground)
898 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myGradientBackground)
900 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myViewSize)
901 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myViewProj)
902 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myVisualization)
903 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myDefaultTypeOfView)
905 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myDefaultRenderingParams)
906 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myComputedMode)
907 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myDefaultComputedMode)
909 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myPrivilegedPlane)
910 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myPlaneStructure.get())
911 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myDisplayPlane)
912 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myDisplayPlaneLength)
914 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myRGrid.get())
915 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myCGrid.get())
917 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myGridType)
918 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myGridEcho)
919 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myGridEchoStructure.get())
920 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myGridEchoGroup.get())
921 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myGridEchoAspect.get())
922 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myGridEchoLastVert)