0024030: Undefined reference to `NCollection_IncAllocator::DefaultBlockSize'.
[occt.git] / src / Prs3d / Prs3d_Datum.gxx
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
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_ArrayOfSegments.hxx>
34
35 void 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   Handle(Graphic3d_Group) G = Prs3d_Root::CurrentGroup(aPresentation);
41
42   Quantity_Color Col; Aspect_TypeOfLine Tol; Standard_Real W;
43   DA->FirstAxisAspect()->Aspect()->Values(Col,Tol,W);
44
45   Handle(Graphic3d_AspectMarker3d) Asp = new Graphic3d_AspectMarker3d(Aspect_TOM_BALL,Col,.1);
46
47   gp_Ax2 Axis = DatumTool::Ax2(aDatum);
48   gp_Pnt Orig = Axis.Location();
49   gp_Dir oX = Axis.XDirection();
50   gp_Dir oY = Axis.YDirection();
51   gp_Dir oZ = Axis.Direction();
52
53 //
54 // Trace d'une petite sphere au debut du vecteur:
55 //
56
57   Quantity_Length xo,yo,zo;
58   Orig.Coord(xo,yo,zo);
59   G->SetPrimitivesAspect(Asp);
60   G->Marker(Graphic3d_Vertex (xo,yo,zo));
61
62   Quantity_Length DS;
63   Quantity_Length arrowAngle = aDrawer->ArrowAspect()->Angle();
64   Quantity_Length textHeight = aDrawer->TextAspect()->Height();
65
66   Handle(Graphic3d_ArrayOfSegments) aPrims;
67   if (DA->DrawFirstAndSecondAxis())
68   {
69     DS = DA->FirstAxisLength();
70     const gp_Pnt p1(Orig.XYZ() + oX.XYZ()*DS);
71     
72     G->SetPrimitivesAspect(DA->FirstAxisAspect()->Aspect());
73     aPrims = new Graphic3d_ArrayOfSegments(2);
74     aPrims->AddVertex(Orig);
75     aPrims->AddVertex(p1);
76     G->AddPrimitiveArray(aPrims);
77
78     G->SetPrimitivesAspect(aDrawer->ArrowAspect()->Aspect());
79     Prs3d_Arrow::Draw(aPresentation,p1,oX,arrowAngle,DS/10.);
80     G->SetPrimitivesAspect(aDrawer->TextAspect()->Aspect());
81     Graphic3d_Vertex v1(p1.X(),p1.Y(),p1.Z());
82     G->Text(Standard_CString("X"),v1,16.);
83
84     DS = DA->SecondAxisLength();
85     const gp_Pnt p2(Orig.XYZ() + oY.XYZ()*DS);
86
87     G->SetPrimitivesAspect(DA->SecondAxisAspect()->Aspect());
88     aPrims = new Graphic3d_ArrayOfSegments(2);
89     aPrims->AddVertex(Orig);
90     aPrims->AddVertex(p2);
91     G->AddPrimitiveArray(aPrims);
92
93     G->SetPrimitivesAspect(aDrawer->ArrowAspect()->Aspect());
94     Prs3d_Arrow::Draw(aPresentation,p2,oY,arrowAngle,DS/10.);
95     G->SetPrimitivesAspect(aDrawer->TextAspect()->Aspect());
96     Graphic3d_Vertex v2(p2.X(),p2.Y(),p2.Z());
97     G->Text(Standard_CString("Y"),v2,16.);
98   }
99   if (DA->DrawThirdAxis())
100   {
101     DS = DA->ThirdAxisLength();
102     const gp_Pnt p3(Orig.XYZ() + oZ.XYZ()*DS);
103
104     G->SetPrimitivesAspect(DA->ThirdAxisAspect()->Aspect());
105     aPrims = new Graphic3d_ArrayOfSegments(2);
106     aPrims->AddVertex(Orig);
107     aPrims->AddVertex(p3);
108     G->AddPrimitiveArray(aPrims);
109
110     G->SetPrimitivesAspect(aDrawer->ArrowAspect()->Aspect());
111     Prs3d_Arrow::Draw(aPresentation,p3,oZ,arrowAngle,DS/10.);
112     G->SetPrimitivesAspect(aDrawer->TextAspect()->Aspect());
113     Graphic3d_Vertex v3(p3.X(),p3.Y(),p3.Z());
114     G->Text(Standard_CString("Z"),v3,16.);
115   }
116 }