0028316: Coding Rules - Elimilate confusing aliases of Standard_Real type in V3d_View
[occt.git] / src / V3d / V3d_Viewer_3.cxx
1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
2 //
3 // This file is part of Open CASCADE Technology software library.
4 //
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.
10 //
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
13
14 /***********************************************************************
15      FONCTION :
16      ----------
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)
22      REMARQUES :
23      -----------
24 ************************************************************************/
25 //                      -> Remove the grid plane axis when it is requested.
26 //                      -> Redraw the privilegied grid plane after any change
27 /*----------------------------------------------------------------------*/
28 /*
29  * Includes
30  */
31
32 #include <Aspect_Background.hxx>
33 #include <Aspect_GradientBackground.hxx>
34 #include <Aspect_Grid.hxx>
35 #include <gp_Ax3.hxx>
36 #include <gp_Dir.hxx>
37 #include <gp_Pnt.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>
52
53 /*----------------------------------------------------------------------*/
54
55 void V3d_Viewer::SetPrivilegedPlane(const gp_Ax3& aPlane)
56 {
57   myPrivilegedPlane = aPlane;
58   Grid()->SetDrawMode(Grid()->DrawMode());
59   for (V3d_ListOfView::Iterator anActiveViewIter (myActiveViews); anActiveViewIter.More(); anActiveViewIter.Next())
60   {
61     anActiveViewIter.Value()->SetGrid (myPrivilegedPlane, Grid());
62   }
63
64   if(myDisplayPlane)
65     DisplayPrivilegedPlane(Standard_True,myDisplayPlaneLength);
66 }
67
68 /*----------------------------------------------------------------------*/
69
70 gp_Ax3 V3d_Viewer::PrivilegedPlane() const
71 {
72   return myPrivilegedPlane;
73 }
74
75 /*----------------------------------------------------------------------*/
76 void V3d_Viewer::DisplayPrivilegedPlane(const Standard_Boolean OnOff, const Standard_Real aSize)
77 {
78   myDisplayPlane = OnOff;
79   myDisplayPlaneLength = aSize;
80
81   if(myDisplayPlane)
82   {
83     if(myPlaneStructure.IsNull()) {
84       myPlaneStructure = new Graphic3d_Structure(StructureManager());
85       myPlaneStructure->SetInfiniteState(Standard_True);
86       myPlaneStructure->Display();
87     }
88     else
89       myPlaneStructure->Clear();
90
91     Handle(Graphic3d_Group) Group = myPlaneStructure->NewGroup();
92
93     Handle(Graphic3d_AspectLine3d) LineAttrib = new Graphic3d_AspectLine3d() ;
94     LineAttrib->SetColor(Quantity_Color(Quantity_NOC_GRAY60));
95     Group->SetPrimitivesAspect(LineAttrib) ;
96
97     Handle(Graphic3d_AspectText3d) TextAttrib = new Graphic3d_AspectText3d();
98     TextAttrib->SetColor(Quantity_Color(Quantity_NOC_ROYALBLUE1));
99     Group->SetPrimitivesAspect(TextAttrib);
100
101     Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments(6);
102
103     const gp_Pnt &p0 = myPrivilegedPlane.Location();
104
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.);
109
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.);
114     
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.);
119
120     Group->AddPrimitiveArray(aPrims);
121
122         myPlaneStructure->Display();
123   }
124   else
125   {
126     if( !myPlaneStructure.IsNull() )  myPlaneStructure->Erase();
127   }
128 }
129
130 /*----------------------------------------------------------------------*/