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())
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 (int aSubViewPass = 0; aSubViewPass < 2; ++aSubViewPass)
148 // redraw subviews first
149 const bool isSubViewPass = (aSubViewPass == 0);
150 for (const Handle(V3d_View)& aViewIter : myDefinedViews)
153 && aViewIter->IsSubview())
157 else if (!isSubViewPass
158 && !aViewIter->IsSubview())
166 // ========================================================================
167 // function : RedrawImmediate
169 // ========================================================================
170 void V3d_Viewer::RedrawImmediate() const
172 for (int aSubViewPass = 0; aSubViewPass < 2; ++aSubViewPass)
174 // redraw subviews first
175 const bool isSubViewPass = (aSubViewPass == 0);
176 for (const Handle(V3d_View)& aViewIter : myDefinedViews)
179 && aViewIter->IsSubview())
181 aViewIter->RedrawImmediate();
183 else if (!isSubViewPass
184 && !aViewIter->IsSubview())
186 aViewIter->RedrawImmediate();
192 // ========================================================================
193 // function : Invalidate
195 // ========================================================================
196 void V3d_Viewer::Invalidate() const
198 for (V3d_ListOfView::Iterator aDefViewIter (myDefinedViews); aDefViewIter.More(); aDefViewIter.Next())
200 aDefViewIter.Value()->Invalidate();
204 // ========================================================================
207 // ========================================================================
208 void V3d_Viewer::Remove()
210 myStructureManager->Remove();
213 // ========================================================================
216 // ========================================================================
217 void V3d_Viewer::Erase() const
219 myStructureManager->Erase();
222 // ========================================================================
223 // function : UnHighlight
225 // ========================================================================
226 void V3d_Viewer::UnHighlight() const
228 myStructureManager->UnHighlight();
231 void V3d_Viewer::SetDefaultViewSize (const Standard_Real theSize)
234 throw V3d_BadValue("V3d_Viewer::SetDefaultViewSize, bad size");
235 myViewSize = theSize;
238 // ========================================================================
239 // function : IfMoreViews
241 // ========================================================================
242 Standard_Boolean V3d_Viewer::IfMoreViews() const
244 return myDefinedViews.Size() < myStructureManager->MaxNumOfViews();
247 // ========================================================================
248 // function : AddView
250 // ========================================================================
251 void V3d_Viewer::AddView (const Handle(V3d_View)& theView)
253 if (!myDefinedViews.Contains (theView))
255 myDefinedViews.Append (theView);
259 // ========================================================================
260 // function : DelView
262 // ========================================================================
263 void V3d_Viewer::DelView (const V3d_View* theView)
265 for (V3d_ListOfView::Iterator aViewIter (myActiveViews); aViewIter.More(); aViewIter.Next())
267 if (aViewIter.Value() == theView)
269 myActiveViews.Remove (aViewIter);
273 for (V3d_ListOfView::Iterator aViewIter (myDefinedViews); aViewIter.More(); aViewIter.Next())
275 if (aViewIter.Value() == theView)
277 myDefinedViews.Remove (aViewIter);
283 //=======================================================================
284 //function : InsertLayerBefore
286 //=======================================================================
287 Standard_Boolean V3d_Viewer::InsertLayerBefore (Graphic3d_ZLayerId& theNewLayerId,
288 const Graphic3d_ZLayerSettings& theSettings,
289 const Graphic3d_ZLayerId theLayerAfter)
291 if (myZLayerGenId.Next (theNewLayerId))
293 myLayerIds.Add (theNewLayerId);
294 myDriver->InsertLayerBefore (theNewLayerId, theSettings, theLayerAfter);
295 return Standard_True;
297 return Standard_False;
300 //=======================================================================
301 //function : InsertLayerAfter
303 //=======================================================================
304 Standard_Boolean V3d_Viewer::InsertLayerAfter (Graphic3d_ZLayerId& theNewLayerId,
305 const Graphic3d_ZLayerSettings& theSettings,
306 const Graphic3d_ZLayerId theLayerBefore)
308 if (myZLayerGenId.Next (theNewLayerId))
310 myLayerIds.Add (theNewLayerId);
311 myDriver->InsertLayerAfter (theNewLayerId, theSettings, theLayerBefore);
312 return Standard_True;
314 return Standard_False;
317 //=======================================================================
318 //function : RemoveZLayer
320 //=======================================================================
321 Standard_Boolean V3d_Viewer::RemoveZLayer (const Graphic3d_ZLayerId theLayerId)
323 if (!myLayerIds.Contains (theLayerId)
324 || theLayerId < myZLayerGenId.Lower()
325 || theLayerId > myZLayerGenId.Upper())
327 return Standard_False;
330 myDriver->RemoveZLayer (theLayerId);
331 myLayerIds.Remove (theLayerId);
332 myZLayerGenId.Free (theLayerId);
334 return Standard_True;
337 //=======================================================================
338 //function : GetAllZLayers
340 //=======================================================================
341 void V3d_Viewer::GetAllZLayers (TColStd_SequenceOfInteger& theLayerSeq) const
343 myDriver->ZLayers (theLayerSeq);
346 //=======================================================================
347 //function : SetZLayerSettings
349 //=======================================================================
350 void V3d_Viewer::SetZLayerSettings (const Graphic3d_ZLayerId theLayerId, const Graphic3d_ZLayerSettings& theSettings)
352 myDriver->SetZLayerSettings (theLayerId, theSettings);
355 //=======================================================================
356 //function : ZLayerSettings
358 //=======================================================================
359 const Graphic3d_ZLayerSettings& V3d_Viewer::ZLayerSettings (const Graphic3d_ZLayerId theLayerId) const
361 return myDriver->ZLayerSettings (theLayerId);
364 //=======================================================================
365 //function : UpdateLights
367 //=======================================================================
368 void V3d_Viewer::UpdateLights()
370 for (V3d_ListOfView::Iterator anActiveViewIter (myActiveViews); anActiveViewIter.More(); anActiveViewIter.Next())
372 anActiveViewIter.Value()->UpdateLights();
376 //=======================================================================
377 //function : SetLightOn
379 //=======================================================================
380 void V3d_Viewer::SetLightOn (const Handle(V3d_Light)& theLight)
382 if (!myActiveLights.Contains (theLight))
384 myActiveLights.Append (theLight);
387 for (V3d_ListOfView::Iterator anActiveViewIter (myActiveViews); anActiveViewIter.More(); anActiveViewIter.Next())
389 anActiveViewIter.Value()->SetLightOn (theLight);
393 //=======================================================================
394 //function : SetLightOff
396 //=======================================================================
397 void V3d_Viewer::SetLightOff (const Handle(V3d_Light)& theLight)
399 myActiveLights.Remove (theLight);
400 for (V3d_ListOfView::Iterator anActiveViewIter (myActiveViews); anActiveViewIter.More(); anActiveViewIter.Next())
402 anActiveViewIter.Value()->SetLightOff (theLight);
406 //=======================================================================
407 //function : SetLightOn
409 //=======================================================================
410 void V3d_Viewer::SetLightOn()
412 for (V3d_ListOfLight::Iterator aDefLightIter (myDefinedLights); aDefLightIter.More(); aDefLightIter.Next())
414 if (!myActiveLights.Contains (aDefLightIter.Value()))
416 myActiveLights.Append (aDefLightIter.Value());
417 for (V3d_ListOfView::Iterator anActiveViewIter (myActiveViews); anActiveViewIter.More(); anActiveViewIter.Next())
419 anActiveViewIter.Value()->SetLightOn (aDefLightIter.Value());
425 //=======================================================================
426 //function : SetLightOff
428 //=======================================================================
429 void V3d_Viewer::SetLightOff()
431 for (V3d_ListOfLight::Iterator anActiveLightIter (myActiveLights); anActiveLightIter.More(); anActiveLightIter.Next())
433 for (V3d_ListOfView::Iterator anActiveViewIter (myActiveViews); anActiveViewIter.More(); anActiveViewIter.Next())
435 anActiveViewIter.Value()->SetLightOff (anActiveLightIter.Value());
438 myActiveLights.Clear();
441 //=======================================================================
442 //function : IsGlobalLight
444 //=======================================================================
445 Standard_Boolean V3d_Viewer::IsGlobalLight (const Handle(V3d_Light)& theLight) const
447 return myActiveLights.Contains (theLight);
450 //=======================================================================
451 //function : AddLight
453 //=======================================================================
454 void V3d_Viewer::AddLight (const Handle(V3d_Light)& theLight)
456 if (!myDefinedLights.Contains (theLight))
458 myDefinedLights.Append (theLight);
462 //=======================================================================
463 //function : DelLight
465 //=======================================================================
466 void V3d_Viewer::DelLight (const Handle(V3d_Light)& theLight)
468 SetLightOff (theLight);
469 myDefinedLights.Remove (theLight);
472 //=======================================================================
473 //function : SetDefaultLights
475 //=======================================================================
476 void V3d_Viewer::SetDefaultLights()
478 while (!myDefinedLights.IsEmpty())
480 Handle(V3d_Light) aLight = myDefinedLights.First();
484 Handle(V3d_DirectionalLight) aDirLight = new V3d_DirectionalLight (V3d_Zneg, Quantity_NOC_WHITE);
485 aDirLight->SetName ("headlight");
486 aDirLight->SetHeadlight (true);
487 Handle(V3d_AmbientLight) anAmbLight = new V3d_AmbientLight (Quantity_NOC_WHITE);
488 anAmbLight->SetName ("amblight");
489 AddLight (aDirLight);
490 AddLight (anAmbLight);
491 SetLightOn (aDirLight);
492 SetLightOn (anAmbLight);
495 //=======================================================================
496 //function : SetPrivilegedPlane
498 //=======================================================================
499 void V3d_Viewer::SetPrivilegedPlane (const gp_Ax3& thePlane)
501 myPrivilegedPlane = thePlane;
502 Handle(Aspect_Grid) aGrid = Grid (true);
503 aGrid->SetDrawMode (aGrid->DrawMode()); // aGrid->UpdateDisplay();
504 for (V3d_ListOfView::Iterator anActiveViewIter (myActiveViews); anActiveViewIter.More(); anActiveViewIter.Next())
506 anActiveViewIter.Value()->SetGrid (myPrivilegedPlane, aGrid);
511 DisplayPrivilegedPlane (Standard_True, myDisplayPlaneLength);
515 //=======================================================================
516 //function : DisplayPrivilegedPlane
518 //=======================================================================
519 void V3d_Viewer::DisplayPrivilegedPlane (const Standard_Boolean theOnOff, const Standard_Real theSize)
521 myDisplayPlane = theOnOff;
522 myDisplayPlaneLength = theSize;
526 if (!myPlaneStructure.IsNull())
528 myPlaneStructure->Erase();
533 if (myPlaneStructure.IsNull())
535 myPlaneStructure = new Graphic3d_Structure (StructureManager());
536 myPlaneStructure->SetInfiniteState (Standard_True);
537 myPlaneStructure->Display();
541 myPlaneStructure->Clear();
544 Handle(Graphic3d_Group) aGroup = myPlaneStructure->NewGroup();
546 Handle(Graphic3d_AspectLine3d) aLineAttrib = new Graphic3d_AspectLine3d (Quantity_NOC_GRAY60, Aspect_TOL_SOLID, 1.0);
547 aGroup->SetGroupPrimitivesAspect (aLineAttrib);
549 Handle(Graphic3d_AspectText3d) aTextAttrib = new Graphic3d_AspectText3d();
550 aTextAttrib->SetColor (Quantity_Color (Quantity_NOC_ROYALBLUE1));
551 aGroup->SetGroupPrimitivesAspect (aTextAttrib);
553 Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments (6);
555 const gp_Pnt& p0 = myPrivilegedPlane.Location();
557 const gp_Pnt pX (p0.XYZ() + myDisplayPlaneLength * myPrivilegedPlane.XDirection().XYZ());
558 aPrims->AddVertex (p0);
559 aPrims->AddVertex (pX);
560 Handle(Graphic3d_Text) aText = new Graphic3d_Text (1.0f / 81.0f);
561 aText->SetText ("X");
562 aText->SetPosition (pX);
563 aGroup->AddText (aText);
565 const gp_Pnt pY (p0.XYZ() + myDisplayPlaneLength * myPrivilegedPlane.YDirection().XYZ());
566 aPrims->AddVertex (p0);
567 aPrims->AddVertex (pY);
568 aText = new Graphic3d_Text (1.0f / 81.0f);
569 aText->SetText ("Y");
570 aText->SetPosition (pY);
571 aGroup->AddText (aText);
573 const gp_Pnt pZ (p0.XYZ() + myDisplayPlaneLength * myPrivilegedPlane.Direction().XYZ());
574 aPrims->AddVertex (p0);
575 aPrims->AddVertex (pZ);
576 aText = new Graphic3d_Text (1.0f / 81.0f);
577 aText->SetText ("Z");
578 aText->SetPosition (pZ);
579 aGroup->AddText (aText);
581 aGroup->AddPrimitiveArray (aPrims);
583 myPlaneStructure->Display();
586 // =======================================================================
589 // =======================================================================
590 Handle(Aspect_Grid) V3d_Viewer::Grid (Aspect_GridType theGridType, bool theToCreate)
594 case Aspect_GT_Circular:
596 if (myCGrid.IsNull() && theToCreate)
598 myCGrid = new V3d_CircularGrid (this, Quantity_Color(Quantity_NOC_GRAY50), Quantity_Color(Quantity_NOC_GRAY70));
600 return Handle(Aspect_Grid) (myCGrid);
602 case Aspect_GT_Rectangular:
604 if (myRGrid.IsNull() && theToCreate)
606 myRGrid = new V3d_RectangularGrid (this, Quantity_Color(Quantity_NOC_GRAY50), Quantity_Color(Quantity_NOC_GRAY70));
608 return Handle(Aspect_Grid) (myRGrid);
611 return Handle(Aspect_Grid)();
614 // =======================================================================
615 // function : GridDrawMode
617 // =======================================================================
618 Aspect_GridDrawMode V3d_Viewer::GridDrawMode()
620 Handle(Aspect_Grid) aGrid = Grid (false);
621 return !aGrid.IsNull() ? aGrid->DrawMode() : Aspect_GDM_Lines;
624 // =======================================================================
625 // function : ActivateGrid
627 // =======================================================================
628 void V3d_Viewer::ActivateGrid (const Aspect_GridType theType,
629 const Aspect_GridDrawMode theMode)
631 if (Handle(Aspect_Grid) anOldGrid = Grid (false))
636 myGridType = theType;
637 Handle(Aspect_Grid) aGrid = Grid (true);
638 aGrid->SetDrawMode (theMode);
639 if (theMode != Aspect_GDM_None)
644 for (V3d_ListOfView::Iterator anActiveViewIter (myActiveViews); anActiveViewIter.More(); anActiveViewIter.Next())
646 anActiveViewIter.Value()->SetGrid (myPrivilegedPlane, aGrid);
650 // =======================================================================
651 // function : DeactivateGrid
653 // =======================================================================
654 void V3d_Viewer::DeactivateGrid()
656 Handle(Aspect_Grid) aGrid = Grid (false);
665 myGridType = Aspect_GT_Rectangular;
666 for (V3d_ListOfView::Iterator anActiveViewIter (myActiveViews); anActiveViewIter.More(); anActiveViewIter.Next())
668 anActiveViewIter.Value()->SetGridActivity (Standard_False);
670 && !myGridEchoStructure.IsNull())
672 myGridEchoStructure->Erase();
677 // =======================================================================
678 // function : IsGridActive
680 // =======================================================================
681 Standard_Boolean V3d_Viewer::IsGridActive()
683 Handle(Aspect_Grid) aGrid = Grid (false);
684 return !aGrid.IsNull() && aGrid->IsActive();
687 // =======================================================================
688 // function : RectangularGridValues
690 // =======================================================================
691 void V3d_Viewer::RectangularGridValues (Standard_Real& theXOrigin,
692 Standard_Real& theYOrigin,
693 Standard_Real& theXStep,
694 Standard_Real& theYStep,
695 Standard_Real& theRotationAngle)
697 Grid (Aspect_GT_Rectangular, true);
698 theXOrigin = myRGrid->XOrigin();
699 theYOrigin = myRGrid->YOrigin();
700 theXStep = myRGrid->XStep();
701 theYStep = myRGrid->YStep();
702 theRotationAngle = myRGrid->RotationAngle();
705 // =======================================================================
706 // function : SetRectangularGridValues
708 // =======================================================================
709 void V3d_Viewer::SetRectangularGridValues (const Standard_Real theXOrigin,
710 const Standard_Real theYOrigin,
711 const Standard_Real theXStep,
712 const Standard_Real theYStep,
713 const Standard_Real theRotationAngle)
715 Grid (Aspect_GT_Rectangular, true);
716 myRGrid->SetGridValues (theXOrigin, theYOrigin, theXStep, theYStep, theRotationAngle);
717 for (V3d_ListOfView::Iterator anActiveViewIter (myActiveViews); anActiveViewIter.More(); anActiveViewIter.Next())
719 anActiveViewIter.Value()->SetGrid (myPrivilegedPlane, myRGrid);
723 // =======================================================================
724 // function : CircularGridValues
726 // =======================================================================
727 void V3d_Viewer::CircularGridValues (Standard_Real& theXOrigin,
728 Standard_Real& theYOrigin,
729 Standard_Real& theRadiusStep,
730 Standard_Integer& theDivisionNumber,
731 Standard_Real& theRotationAngle)
733 Grid (Aspect_GT_Circular, true);
734 theXOrigin = myCGrid->XOrigin();
735 theYOrigin = myCGrid->YOrigin();
736 theRadiusStep = myCGrid->RadiusStep();
737 theDivisionNumber = myCGrid->DivisionNumber();
738 theRotationAngle = myCGrid->RotationAngle();
741 // =======================================================================
742 // function : SetCircularGridValues
744 // =======================================================================
745 void V3d_Viewer::SetCircularGridValues (const Standard_Real theXOrigin,
746 const Standard_Real theYOrigin,
747 const Standard_Real theRadiusStep,
748 const Standard_Integer theDivisionNumber,
749 const Standard_Real theRotationAngle)
751 Grid (Aspect_GT_Circular, true);
752 myCGrid->SetGridValues (theXOrigin, theYOrigin, theRadiusStep,
753 theDivisionNumber, theRotationAngle);
754 for (V3d_ListOfView::Iterator anActiveViewIter (myActiveViews); anActiveViewIter.More(); anActiveViewIter.Next())
756 anActiveViewIter.Value()->SetGrid (myPrivilegedPlane, myCGrid);
760 // =======================================================================
761 // function : RectangularGridGraphicValues
763 // =======================================================================
764 void V3d_Viewer::RectangularGridGraphicValues (Standard_Real& theXSize,
765 Standard_Real& theYSize,
766 Standard_Real& theOffSet)
768 Grid (Aspect_GT_Rectangular, true);
769 myRGrid->GraphicValues (theXSize, theYSize, theOffSet);
772 // =======================================================================
773 // function : SetRectangularGridGraphicValues
775 // =======================================================================
776 void V3d_Viewer::SetRectangularGridGraphicValues (const Standard_Real theXSize,
777 const Standard_Real theYSize,
778 const Standard_Real theOffSet)
780 Grid (Aspect_GT_Rectangular, true);
781 myRGrid->SetGraphicValues (theXSize, theYSize, theOffSet);
784 // =======================================================================
785 // function : CircularGridGraphicValues
787 // =======================================================================
788 void V3d_Viewer::CircularGridGraphicValues (Standard_Real& theRadius,
789 Standard_Real& theOffSet)
791 Grid (Aspect_GT_Circular, true);
792 myCGrid->GraphicValues (theRadius, theOffSet);
795 // =======================================================================
796 // function : SetCircularGridGraphicValues
798 // =======================================================================
799 void V3d_Viewer::SetCircularGridGraphicValues (const Standard_Real theRadius,
800 const Standard_Real theOffSet)
802 Grid (Aspect_GT_Circular, true);
803 myCGrid->SetGraphicValues (theRadius, theOffSet);
806 // =======================================================================
807 // function : SetGridEcho
809 // =======================================================================
810 void V3d_Viewer::SetGridEcho (const Standard_Boolean theToShowGrid)
812 if (myGridEcho == theToShowGrid)
817 myGridEcho = theToShowGrid;
819 || myGridEchoStructure.IsNull())
824 myGridEchoStructure->Erase();
827 // =======================================================================
828 // function : SetGridEcho
830 // =======================================================================
831 void V3d_Viewer::SetGridEcho (const Handle(Graphic3d_AspectMarker3d)& theMarker)
833 if (myGridEchoStructure.IsNull())
835 myGridEchoStructure = new Graphic3d_Structure (StructureManager());
836 myGridEchoGroup = myGridEchoStructure->NewGroup();
839 myGridEchoAspect = theMarker;
840 myGridEchoGroup->SetPrimitivesAspect (theMarker);
843 // =======================================================================
844 // function : ShowGridEcho
846 // =======================================================================
847 void V3d_Viewer::ShowGridEcho (const Handle(V3d_View)& theView,
848 const Graphic3d_Vertex& theVertex)
855 if (myGridEchoStructure.IsNull())
857 myGridEchoStructure = new Graphic3d_Structure (StructureManager());
858 myGridEchoGroup = myGridEchoStructure->NewGroup();
860 myGridEchoAspect = new Graphic3d_AspectMarker3d (Aspect_TOM_STAR, Quantity_Color (Quantity_NOC_GRAY90), 3.0);
861 myGridEchoGroup->SetPrimitivesAspect (myGridEchoAspect);
864 if (theVertex.X() == myGridEchoLastVert.X()
865 && theVertex.Y() == myGridEchoLastVert.Y()
866 && theVertex.Z() == myGridEchoLastVert.Z())
871 myGridEchoLastVert = theVertex;
872 myGridEchoGroup->Clear();
873 myGridEchoGroup->SetPrimitivesAspect (myGridEchoAspect);
875 Handle(Graphic3d_ArrayOfPoints) anArrayOfPoints = new Graphic3d_ArrayOfPoints (1);
876 anArrayOfPoints->AddVertex (theVertex.X(), theVertex.Y(), theVertex.Z());
877 myGridEchoGroup->AddPrimitiveArray (anArrayOfPoints);
879 myGridEchoStructure->SetZLayer (Graphic3d_ZLayerId_Topmost);
880 myGridEchoStructure->SetInfiniteState (Standard_True);
881 myGridEchoStructure->CStructure()->ViewAffinity = new Graphic3d_ViewAffinity();
882 myGridEchoStructure->CStructure()->ViewAffinity->SetVisible (Standard_False);
883 myGridEchoStructure->CStructure()->ViewAffinity->SetVisible (theView->View()->Identification(), true);
884 myGridEchoStructure->Display();
887 // =======================================================================
888 // function : HideGridEcho
890 // =======================================================================
891 void V3d_Viewer::HideGridEcho (const Handle(V3d_View)& theView)
893 if (myGridEchoStructure.IsNull())
898 myGridEchoLastVert.SetCoord (ShortRealLast(), ShortRealLast(), ShortRealLast());
899 const Handle(Graphic3d_ViewAffinity)& anAffinity = myGridEchoStructure->CStructure()->ViewAffinity;
900 if (!anAffinity.IsNull() && anAffinity->IsVisible (theView->View()->Identification()))
902 myGridEchoStructure->Erase();
906 //=======================================================================
907 //function : DumpJson
909 //=======================================================================
910 void V3d_Viewer::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const
912 OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
914 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myDriver.get())
915 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myStructureManager.get())
916 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myZLayerGenId)
918 for (V3d_ListOfView::Iterator anIter (myDefinedViews); anIter.More(); anIter.Next())
920 const Handle(V3d_View)& aDefinedView = anIter.Value();
921 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, aDefinedView.get())
924 for (V3d_ListOfView::Iterator anIter (myActiveViews); anIter.More(); anIter.Next())
926 const Handle(V3d_View)& anActiveView = anIter.Value();
927 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, anActiveView.get())
930 for (V3d_ListOfLight::Iterator anIter (myDefinedLights); anIter.More(); anIter.Next())
932 const Handle(Graphic3d_CLight)& aDefinedLight = anIter.Value();
933 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, aDefinedLight.get())
936 for (V3d_ListOfLight::Iterator anIter (myActiveLights); anIter.More(); anIter.Next())
938 const Handle(Graphic3d_CLight)& anActiveLight = anIter.Value();
939 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, anActiveLight.get())
942 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myBackground)
943 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myGradientBackground)
945 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myViewSize)
946 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myViewProj)
947 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myVisualization)
948 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myDefaultTypeOfView)
950 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myDefaultRenderingParams)
951 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myComputedMode)
952 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myDefaultComputedMode)
954 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myPrivilegedPlane)
955 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myPlaneStructure.get())
956 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myDisplayPlane)
957 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myDisplayPlaneLength)
959 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myRGrid.get())
960 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myCGrid.get())
962 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myGridType)
963 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myGridEcho)
964 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myGridEchoStructure.get())
965 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myGridEchoGroup.get())
966 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myGridEchoAspect.get())
967 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myGridEchoLastVert)