0023634: Eliminate Polyline and Polygon usage in drawers
[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>
b8ddfc2f 33#include <Graphic3d_ArrayOfSegments.hxx>
7fd59977 34
35void Prs3d_Datum::Add( const Handle(Prs3d_Presentation)& aPresentation,
36 const anyDatum& aDatum,
b8ddfc2f 37 const Handle(Prs3d_Drawer)& aDrawer )
38{
7fd59977 39 Handle(Prs3d_DatumAspect) DA = aDrawer->DatumAspect();
7fd59977 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
b8ddfc2f 45 Handle(Graphic3d_AspectMarker3d) Asp = new Graphic3d_AspectMarker3d(Aspect_TOM_BALL,Col,.1);
7fd59977 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
b8ddfc2f 57 Quantity_Length xo,yo,zo;
7fd59977 58 Orig.Coord(xo,yo,zo);
59 G->SetPrimitivesAspect(Asp);
60 G->Marker(Graphic3d_Vertex (xo,yo,zo));
61
7fd59977 62 Quantity_Length DS;
7fd59977 63 Quantity_Length arrowAngle = aDrawer->ArrowAspect()->Angle();
64 Quantity_Length textHeight = aDrawer->TextAspect()->Height();
7fd59977 65
b8ddfc2f 66 Handle(Graphic3d_ArrayOfSegments) aPrims;
67 if (DA->DrawFirstAndSecondAxis())
68 {
7fd59977 69 DS = DA->FirstAxisLength();
b8ddfc2f 70 const gp_Pnt p1(Orig.XYZ() + oX.XYZ()*DS);
71
7fd59977 72 G->SetPrimitivesAspect(DA->FirstAxisAspect()->Aspect());
b8ddfc2f 73 aPrims = new Graphic3d_ArrayOfSegments(2);
74 aPrims->AddVertex(Orig);
75 aPrims->AddVertex(p1);
76 G->AddPrimitiveArray(aPrims);
77
7fd59977 78 G->SetPrimitivesAspect(aDrawer->ArrowAspect()->Aspect());
b8ddfc2f 79 Prs3d_Arrow::Draw(aPresentation,p1,oX,arrowAngle,DS/10.);
7fd59977 80 G->SetPrimitivesAspect(aDrawer->TextAspect()->Aspect());
b8ddfc2f 81 Graphic3d_Vertex v1(p1.X(),p1.Y(),p1.Z());
82 G->Text(Standard_CString("X"),v1,16.);
83
7fd59977 84 DS = DA->SecondAxisLength();
b8ddfc2f 85 const gp_Pnt p2(Orig.XYZ() + oY.XYZ()*DS);
86
7fd59977 87 G->SetPrimitivesAspect(DA->SecondAxisAspect()->Aspect());
b8ddfc2f 88 aPrims = new Graphic3d_ArrayOfSegments(2);
89 aPrims->AddVertex(Orig);
90 aPrims->AddVertex(p2);
91 G->AddPrimitiveArray(aPrims);
92
7fd59977 93 G->SetPrimitivesAspect(aDrawer->ArrowAspect()->Aspect());
b8ddfc2f 94 Prs3d_Arrow::Draw(aPresentation,p2,oY,arrowAngle,DS/10.);
7fd59977 95 G->SetPrimitivesAspect(aDrawer->TextAspect()->Aspect());
b8ddfc2f 96 Graphic3d_Vertex v2(p2.X(),p2.Y(),p2.Z());
97 G->Text(Standard_CString("Y"),v2,16.);
98 }
99 if (DA->DrawThirdAxis())
100 {
7fd59977 101 DS = DA->ThirdAxisLength();
b8ddfc2f 102 const gp_Pnt p3(Orig.XYZ() + oZ.XYZ()*DS);
103
7fd59977 104 G->SetPrimitivesAspect(DA->ThirdAxisAspect()->Aspect());
b8ddfc2f 105 aPrims = new Graphic3d_ArrayOfSegments(2);
106 aPrims->AddVertex(Orig);
107 aPrims->AddVertex(p3);
108 G->AddPrimitiveArray(aPrims);
109
7fd59977 110 G->SetPrimitivesAspect(aDrawer->ArrowAspect()->Aspect());
b8ddfc2f 111 Prs3d_Arrow::Draw(aPresentation,p3,oZ,arrowAngle,DS/10.);
7fd59977 112 G->SetPrimitivesAspect(aDrawer->TextAspect()->Aspect());
b8ddfc2f 113 Graphic3d_Vertex v3(p3.X(),p3.Y(),p3.Z());
114 G->Text(Standard_CString("Z"),v3,16.);
115 }
7fd59977 116}