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 /***********************************************************************
17 Classe V3d_Viewer_3.cxx :
18 HISTORIQUE DES MODIFICATIONS :
19 --------------------------------
20 00-09-92 : GG ; Creation.
21 27-12-98 : FMN ; PERF: OPTIMISATION LOADER (LOPTIM)
24 ************************************************************************/
25 // -> Remove the grid plane axis when it is requested.
26 // -> Redraw the privilegied grid plane after any change
27 /*----------------------------------------------------------------------*/
32 #include <Aspect_Background.hxx>
33 #include <Aspect_GradientBackground.hxx>
34 #include <Aspect_Grid.hxx>
38 #include <Graphic3d_ArrayOfSegments.hxx>
39 #include <Graphic3d_AspectLine3d.hxx>
40 #include <Graphic3d_AspectMarker3d.hxx>
41 #include <Graphic3d_AspectText3d.hxx>
42 #include <Graphic3d_GraphicDriver.hxx>
43 #include <Graphic3d_Group.hxx>
44 #include <Graphic3d_Structure.hxx>
45 #include <Quantity_Color.hxx>
46 #include <V3d_BadValue.hxx>
47 #include <V3d_CircularGrid.hxx>
48 #include <V3d_Light.hxx>
49 #include <V3d_RectangularGrid.hxx>
50 #include <V3d_View.hxx>
51 #include <V3d_Viewer.hxx>
53 /*----------------------------------------------------------------------*/
55 void V3d_Viewer::SetPrivilegedPlane(const gp_Ax3& aPlane)
57 myPrivilegedPlane = aPlane;
58 Grid()->SetDrawMode(Grid()->DrawMode());
59 for (V3d_ListOfView::Iterator anActiveViewIter (myActiveViews); anActiveViewIter.More(); anActiveViewIter.Next())
61 anActiveViewIter.Value()->SetGrid (myPrivilegedPlane, Grid());
65 DisplayPrivilegedPlane(Standard_True,myDisplayPlaneLength);
68 /*----------------------------------------------------------------------*/
70 gp_Ax3 V3d_Viewer::PrivilegedPlane() const
72 return myPrivilegedPlane;
75 /*----------------------------------------------------------------------*/
76 void V3d_Viewer::DisplayPrivilegedPlane(const Standard_Boolean OnOff, const Standard_Real aSize)
78 myDisplayPlane = OnOff;
79 myDisplayPlaneLength = aSize;
83 if(myPlaneStructure.IsNull()) {
84 myPlaneStructure = new Graphic3d_Structure(StructureManager());
85 myPlaneStructure->SetInfiniteState(Standard_True);
86 myPlaneStructure->Display();
89 myPlaneStructure->Clear();
91 Handle(Graphic3d_Group) Group = myPlaneStructure->NewGroup();
93 Handle(Graphic3d_AspectLine3d) LineAttrib = new Graphic3d_AspectLine3d() ;
94 LineAttrib->SetColor(Quantity_Color(Quantity_NOC_GRAY60));
95 Group->SetPrimitivesAspect(LineAttrib) ;
97 Handle(Graphic3d_AspectText3d) TextAttrib = new Graphic3d_AspectText3d();
98 TextAttrib->SetColor(Quantity_Color(Quantity_NOC_ROYALBLUE1));
99 Group->SetPrimitivesAspect(TextAttrib);
101 Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments(6);
103 const gp_Pnt &p0 = myPrivilegedPlane.Location();
105 const gp_Pnt pX(p0.XYZ() + myDisplayPlaneLength*myPrivilegedPlane.XDirection().XYZ());
106 aPrims->AddVertex(p0);
107 aPrims->AddVertex(pX);
108 Group->Text("X",Graphic3d_Vertex(pX.X(),pX.Y(),pX.Z()),1./81.);
110 const gp_Pnt pY(p0.XYZ() + myDisplayPlaneLength*myPrivilegedPlane.YDirection().XYZ());
111 aPrims->AddVertex(p0);
112 aPrims->AddVertex(pY);
113 Group->Text("Y",Graphic3d_Vertex(pY.X(),pY.Y(),pY.Z()),1./81.);
115 const gp_Pnt pZ(p0.XYZ() + myDisplayPlaneLength*myPrivilegedPlane.Direction().XYZ());
116 aPrims->AddVertex(p0);
117 aPrims->AddVertex(pZ);
118 Group->Text("Z",Graphic3d_Vertex(pZ.X(),pZ.Y(),pZ.Z()),1./81.);
120 Group->AddPrimitiveArray(aPrims);
122 myPlaneStructure->Display();
126 if( !myPlaneStructure.IsNull() ) myPlaneStructure->Erase();
130 /*----------------------------------------------------------------------*/