0022807: Loading of STEP entities in model during reading of STEP file requires redun...
[occt.git] / src / Prs3d / Prs3d_Datum.gxx
CommitLineData
7fd59977 1#define IMP120100 // YFR/GG 10/01/2000
2// Enable to compute the triedhron color texts and arrows.
3
4#include <Graphic3d_Group.hxx>
5#include <Graphic3d_AspectMarker3d.hxx>
6#include <Graphic3d_AspectLine3d.hxx>
7#include <Prs3d_Arrow.hxx>
8#include <gp_Dir.hxx>
9#include <gp_Pnt.hxx>
10#include <gp_Ax2.hxx>
11#include <Prs3d_LineAspect.hxx>
12#include <Prs3d_DatumAspect.hxx>
13#include <Prs3d_TextAspect.hxx>
14#include <Prs3d_ArrowAspect.hxx>
15#include <Graphic3d_Array1OfVertex.hxx>
16
17void Prs3d_Datum::Add( const Handle(Prs3d_Presentation)& aPresentation,
18 const anyDatum& aDatum,
19 const Handle(Prs3d_Drawer)& aDrawer ) {
20
21 Handle(Prs3d_DatumAspect) DA = aDrawer->DatumAspect();
22
23 Handle(Graphic3d_Group) G = Prs3d_Root::CurrentGroup(aPresentation);
24
25 Quantity_Color Col; Aspect_TypeOfLine Tol; Standard_Real W;
26 DA->FirstAxisAspect()->Aspect()->Values(Col,Tol,W);
27
28 Handle(Graphic3d_AspectMarker3d) Asp = new Graphic3d_AspectMarker3d
29 (Aspect_TOM_BALL,Col,.1);
30
31 gp_Ax2 Axis = DatumTool::Ax2(aDatum);
32 gp_Pnt Orig = Axis.Location();
33 gp_Dir oX = Axis.XDirection();
34 gp_Dir oY = Axis.YDirection();
35 gp_Dir oZ = Axis.Direction();
36
37//
38// Trace d'une petite sphere au debut du vecteur:
39//
40
41 Quantity_Length xo,yo,zo,x,y,z;
42
43 Orig.Coord(xo,yo,zo);
44 G->SetPrimitivesAspect(Asp);
45 G->Marker(Graphic3d_Vertex (xo,yo,zo));
46
47
48 Graphic3d_Array1OfVertex A(1,2);
49 A(1).SetCoord(xo,yo,zo);
50
51 Quantity_Length DS;
52
53#ifdef IMP120100
54 Quantity_Length arrowAngle = aDrawer->ArrowAspect()->Angle();
55 Quantity_Length textHeight = aDrawer->TextAspect()->Height();
56#endif
57
58 if (DA->DrawFirstAndSecondAxis()) {
59 oX.Coord(x,y,z);
60 DS = DA->FirstAxisLength();
61 x = xo + x*DS; y = yo + y*DS; z = zo + z*DS;
62 A(2).SetCoord(x,y,z);
63 G->SetPrimitivesAspect(DA->FirstAxisAspect()->Aspect());
64 G->Polyline(A);
65#ifdef IMP120100
66 G->SetPrimitivesAspect(aDrawer->ArrowAspect()->Aspect());
67 Prs3d_Arrow::Draw(aPresentation,gp_Pnt(x,y,z),oX,arrowAngle,DS/10.);
68 G->SetPrimitivesAspect(aDrawer->TextAspect()->Aspect());
69 G->Text(Standard_CString("X"),A(2),16.);
70#else
71 Prs3d_Arrow::Draw(aPresentation,gp_Pnt(x,y,z),oX,PI/180.*10.,DS/10.);
72 Prs3d_Root::CurrentGroup(aPresentation)->Text(Standard_CString("X"),A(2),1./81.);
73#endif
74}
75 if (DA->DrawFirstAndSecondAxis()) {
76 oY.Coord(x,y,z);
77 DS = DA->SecondAxisLength();
78 x = xo + x*DS; y = yo + y*DS; z = zo + z*DS;
79 A(2).SetCoord(x,y,z);
80 G->SetPrimitivesAspect(DA->SecondAxisAspect()->Aspect());
81 G->Polyline(A);
82#ifdef IMP120100
83 G->SetPrimitivesAspect(aDrawer->ArrowAspect()->Aspect());
84 Prs3d_Arrow::Draw(aPresentation,gp_Pnt(x,y,z),oY,arrowAngle,DS/10.);
85 G->SetPrimitivesAspect(aDrawer->TextAspect()->Aspect());
86 G->Text(Standard_CString("Y"),A(2),16.);
87#else
88 Prs3d_Arrow::Draw(aPresentation,gp_Pnt(x,y,z),oY,PI/180.*10.,DS/10.);
89 Prs3d_Root::CurrentGroup(aPresentation)->Text(Standard_CString("Y"),A(2),1./81.);
90#endif
91}
92 if (DA->DrawThirdAxis()) {
93 oZ.Coord(x,y,z);
94 DS = DA->ThirdAxisLength();
95 x = xo + x*DS; y = yo + y*DS; z = zo + z*DS;
96 A(2).SetCoord(x,y,z);
97 G->SetPrimitivesAspect(DA->ThirdAxisAspect()->Aspect());
98 G->Polyline(A);
99#ifdef IMP120100
100 G->SetPrimitivesAspect(aDrawer->ArrowAspect()->Aspect());
101 Prs3d_Arrow::Draw(aPresentation,gp_Pnt(x,y,z),oZ,arrowAngle,DS/10.);
102 G->SetPrimitivesAspect(aDrawer->TextAspect()->Aspect());
103 G->Text(Standard_CString("Z"),A(2),16.);
104#else
105 Prs3d_Root::CurrentGroup(aPresentation)->Text(Standard_CString("Z"),A(2),1./81.);
106 Prs3d_Arrow::Draw(aPresentation,gp_Pnt(x,y,z),oZ,PI/180.*10.,DS/10.);
107#endif
108}
109}