Test for 0022778: Bug in BRepMesh
[occt.git] / src / Prs3d / Prs3d_Datum.gxx
CommitLineData
b311480e 1// Copyright (c) 1995-1999 Matra Datavision
2// Copyright (c) 1999-2012 OPEN CASCADE SAS
3//
4// The content of this file is subject to the Open CASCADE Technology Public
5// License Version 6.5 (the "License"). You may not use the content of this file
6// except in compliance with the License. Please obtain a copy of the License
7// at http://www.opencascade.org and read it completely before using this file.
8//
9// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
10// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
11//
12// The Original Code and all software distributed under the License is
13// distributed on an "AS IS" basis, without warranty of any kind, and the
14// Initial Developer hereby disclaims all such warranties, including without
15// limitation, any warranties of merchantability, fitness for a particular
16// purpose or non-infringement. Please see the License for the specific terms
17// and conditions governing the rights and limitations under the License.
18
7fd59977 19#define IMP120100 // YFR/GG 10/01/2000
20// Enable to compute the triedhron color texts and arrows.
21
22#include <Graphic3d_Group.hxx>
23#include <Graphic3d_AspectMarker3d.hxx>
24#include <Graphic3d_AspectLine3d.hxx>
25#include <Prs3d_Arrow.hxx>
26#include <gp_Dir.hxx>
27#include <gp_Pnt.hxx>
28#include <gp_Ax2.hxx>
29#include <Prs3d_LineAspect.hxx>
30#include <Prs3d_DatumAspect.hxx>
31#include <Prs3d_TextAspect.hxx>
32#include <Prs3d_ArrowAspect.hxx>
33#include <Graphic3d_Array1OfVertex.hxx>
34
35void Prs3d_Datum::Add( const Handle(Prs3d_Presentation)& aPresentation,
36 const anyDatum& aDatum,
37 const Handle(Prs3d_Drawer)& aDrawer ) {
38
39 Handle(Prs3d_DatumAspect) DA = aDrawer->DatumAspect();
40
41 Handle(Graphic3d_Group) G = Prs3d_Root::CurrentGroup(aPresentation);
42
43 Quantity_Color Col; Aspect_TypeOfLine Tol; Standard_Real W;
44 DA->FirstAxisAspect()->Aspect()->Values(Col,Tol,W);
45
46 Handle(Graphic3d_AspectMarker3d) Asp = new Graphic3d_AspectMarker3d
47 (Aspect_TOM_BALL,Col,.1);
48
49 gp_Ax2 Axis = DatumTool::Ax2(aDatum);
50 gp_Pnt Orig = Axis.Location();
51 gp_Dir oX = Axis.XDirection();
52 gp_Dir oY = Axis.YDirection();
53 gp_Dir oZ = Axis.Direction();
54
55//
56// Trace d'une petite sphere au debut du vecteur:
57//
58
59 Quantity_Length xo,yo,zo,x,y,z;
60
61 Orig.Coord(xo,yo,zo);
62 G->SetPrimitivesAspect(Asp);
63 G->Marker(Graphic3d_Vertex (xo,yo,zo));
64
65
66 Graphic3d_Array1OfVertex A(1,2);
67 A(1).SetCoord(xo,yo,zo);
68
69 Quantity_Length DS;
70
71#ifdef IMP120100
72 Quantity_Length arrowAngle = aDrawer->ArrowAspect()->Angle();
73 Quantity_Length textHeight = aDrawer->TextAspect()->Height();
74#endif
75
76 if (DA->DrawFirstAndSecondAxis()) {
77 oX.Coord(x,y,z);
78 DS = DA->FirstAxisLength();
79 x = xo + x*DS; y = yo + y*DS; z = zo + z*DS;
80 A(2).SetCoord(x,y,z);
81 G->SetPrimitivesAspect(DA->FirstAxisAspect()->Aspect());
82 G->Polyline(A);
83#ifdef IMP120100
84 G->SetPrimitivesAspect(aDrawer->ArrowAspect()->Aspect());
85 Prs3d_Arrow::Draw(aPresentation,gp_Pnt(x,y,z),oX,arrowAngle,DS/10.);
86 G->SetPrimitivesAspect(aDrawer->TextAspect()->Aspect());
87 G->Text(Standard_CString("X"),A(2),16.);
88#else
c6541a0c 89 Prs3d_Arrow::Draw(aPresentation,gp_Pnt(x,y,z),oX,M_PI/180.*10.,DS/10.);
7fd59977 90 Prs3d_Root::CurrentGroup(aPresentation)->Text(Standard_CString("X"),A(2),1./81.);
91#endif
92}
93 if (DA->DrawFirstAndSecondAxis()) {
94 oY.Coord(x,y,z);
95 DS = DA->SecondAxisLength();
96 x = xo + x*DS; y = yo + y*DS; z = zo + z*DS;
97 A(2).SetCoord(x,y,z);
98 G->SetPrimitivesAspect(DA->SecondAxisAspect()->Aspect());
99 G->Polyline(A);
100#ifdef IMP120100
101 G->SetPrimitivesAspect(aDrawer->ArrowAspect()->Aspect());
102 Prs3d_Arrow::Draw(aPresentation,gp_Pnt(x,y,z),oY,arrowAngle,DS/10.);
103 G->SetPrimitivesAspect(aDrawer->TextAspect()->Aspect());
104 G->Text(Standard_CString("Y"),A(2),16.);
105#else
c6541a0c 106 Prs3d_Arrow::Draw(aPresentation,gp_Pnt(x,y,z),oY,M_PI/180.*10.,DS/10.);
7fd59977 107 Prs3d_Root::CurrentGroup(aPresentation)->Text(Standard_CString("Y"),A(2),1./81.);
108#endif
109}
110 if (DA->DrawThirdAxis()) {
111 oZ.Coord(x,y,z);
112 DS = DA->ThirdAxisLength();
113 x = xo + x*DS; y = yo + y*DS; z = zo + z*DS;
114 A(2).SetCoord(x,y,z);
115 G->SetPrimitivesAspect(DA->ThirdAxisAspect()->Aspect());
116 G->Polyline(A);
117#ifdef IMP120100
118 G->SetPrimitivesAspect(aDrawer->ArrowAspect()->Aspect());
119 Prs3d_Arrow::Draw(aPresentation,gp_Pnt(x,y,z),oZ,arrowAngle,DS/10.);
120 G->SetPrimitivesAspect(aDrawer->TextAspect()->Aspect());
121 G->Text(Standard_CString("Z"),A(2),16.);
122#else
123 Prs3d_Root::CurrentGroup(aPresentation)->Text(Standard_CString("Z"),A(2),1./81.);
c6541a0c 124 Prs3d_Arrow::Draw(aPresentation,gp_Pnt(x,y,z),oZ,M_PI/180.*10.,DS/10.);
7fd59977 125#endif
126}
127}