1 /***********************************************************************
5 Classe V3d_Viewer_3.cxx :
7 HISTORIQUE DES MODIFICATIONS :
8 --------------------------------
9 00-09-92 : GG ; Creation.
10 27-12-98 : FMN ; PERF: OPTIMISATION LOADER (LOPTIM)
15 ************************************************************************/
17 #define IMP240300 //GG
18 // -> Remove the grid plane axis when it is requested.
19 // -> Redraw the privilegied grid plane after any change
21 /*----------------------------------------------------------------------*/
26 #include <V3d_Viewer.jxx>
28 #include <Graphic3d_AspectLine3d.hxx>
29 #include <Graphic3d_AspectText3d.hxx>
32 #include <Graphic3d_Structure.hxx>
33 #include <Graphic3d_Group.hxx>
35 #include <Graphic3d_Array1OfVertex.hxx>
37 /*----------------------------------------------------------------------*/
44 static TCollection_AsciiString XLetter("X");
45 static TCollection_AsciiString YLetter("Y");
46 static TCollection_AsciiString ZLetter("Z");
48 static TCollection_AsciiString _XLetter() {
49 static TCollection_AsciiString XLetter("X");
52 #define XLetter _XLetter()
54 static TCollection_AsciiString _YLetter() {
55 static TCollection_AsciiString YLetter("Y");
58 #define YLetter _YLetter()
60 static TCollection_AsciiString _ZLetter() {
61 static TCollection_AsciiString ZLetter("Z");
64 #define ZLetter _ZLetter()
68 /*----------------------------------------------------------------------*/
70 void V3d_Viewer::SetPrivilegedPlane(const gp_Ax3& aPlane) {
71 myPrivilegedPlane = aPlane;
73 Grid()->SetDrawMode(Grid()->DrawMode());
74 for (InitActiveViews (); MoreActiveViews (); NextActiveViews ()) {
75 ActiveView ()->SetGrid (myPrivilegedPlane, Grid ());
79 Standard_Real s = myDisplayPlaneLength;
80 DisplayPrivilegedPlane(Standard_True,s);
90 /*----------------------------------------------------------------------*/
91 gp_Ax3 V3d_Viewer::PrivilegedPlane() const {
92 return myPrivilegedPlane;
96 /*----------------------------------------------------------------------*/
97 void V3d_Viewer::DisplayPrivilegedPlane(const Standard_Boolean OnOff, const Quantity_Length aSize) {
98 Standard_Boolean Change = myDisplayPlane != OnOff;
99 myDisplayPlane = OnOff;
100 myDisplayPlaneLength = aSize;
103 if(myPlaneStructure.IsNull()) {
104 myPlaneStructure = new Graphic3d_Structure(MyViewer);
105 myPlaneStructure->SetInfiniteState(Standard_True);
106 myPlaneStructure->Display();
109 myPlaneStructure->Clear();
111 // Handle(Graphic3d_Structure) thePlaneStructure = new Graphic3d_Structure(MyViewer);
112 Handle(Graphic3d_Group) Group = new Graphic3d_Group(myPlaneStructure) ;
114 Handle(Graphic3d_AspectLine3d) LineAttrib = new Graphic3d_AspectLine3d() ;
115 LineAttrib->SetColor(Quantity_Color(Quantity_NOC_GRAY60));
116 Group->SetPrimitivesAspect(LineAttrib) ;
118 Handle(Graphic3d_AspectText3d) TextAttrib = new Graphic3d_AspectText3d();
119 TextAttrib->SetColor(Quantity_Color(Quantity_NOC_ROYALBLUE1));
120 Group->SetPrimitivesAspect(TextAttrib);
122 Graphic3d_Array1OfVertex Points(0,1) ;
123 Standard_Real xl,yl,zl;
124 myPrivilegedPlane.Location().Coord(xl,yl,zl);
125 Points(0).SetCoord(xl,yl,zl);
127 Standard_Real ay,by,cy;
129 myPrivilegedPlane.XDirection().Coord(ay,by,cy);
130 Points(1).SetCoord(xl+myDisplayPlaneLength*ay,
131 yl+myDisplayPlaneLength*by,
132 zl+myDisplayPlaneLength*cy);
133 Group->Polyline(Points);
134 Group->Text(XLetter.ToCString(),Points(1),1./81.);
136 myPrivilegedPlane.YDirection().Coord(ay,by,cy);
137 Points(1).SetCoord(xl+myDisplayPlaneLength*ay,
138 yl+myDisplayPlaneLength*by,
139 zl+myDisplayPlaneLength*cy);
140 Group->Polyline(Points);
141 Group->Text(YLetter.ToCString(),Points(1),1./81.);
143 myPrivilegedPlane.Direction().Coord(ay,by,cy);
144 Points(1).SetCoord(xl+myDisplayPlaneLength*ay,
145 yl+myDisplayPlaneLength*by,
146 zl+myDisplayPlaneLength*cy);
147 Group->Polyline(Points);
148 Group->Text(ZLetter.ToCString(),Points(1),1./81.);
150 myPlaneStructure->Display();
152 if( !myPlaneStructure.IsNull() ) myPlaneStructure->Erase();
158 /*----------------------------------------------------------------------*/