ccbbccde6f766b1305ca19fb7bd0f95ae3d99bf2
[occt.git] / src / DsgPrs / DsgPrs_XYZAxisPresentation.cxx
1 // Created on: 1997-02-10
2 // Created by: Odile Olivier
3 // Copyright (c) 1997-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
5 //
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
10 //
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13 //
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
20
21
22 #define OCC218  // SAV Enable to compute the triedhron color texts and arrows.
23
24
25 #include <DsgPrs_XYZAxisPresentation.ixx>
26 #include <Prs3d_Root.hxx>
27 #include <Prs3d_Arrow.hxx>
28 #include <Graphic3d_Group.hxx>
29 #include <Graphic3d_Array1OfVertex.hxx>
30
31
32 //=======================================================================
33 //function : Add
34 //purpose  : 
35 //=======================================================================
36
37 void DsgPrs_XYZAxisPresentation::Add(
38                        const Handle(Prs3d_Presentation)& aPresentation,
39                        const Handle(Prs3d_LineAspect)& aLineAspect,          
40                        const gp_Dir & aDir, 
41                        const Standard_Real aVal,
42                        const Standard_CString aText,
43                        const gp_Pnt& aPfirst,
44                        const gp_Pnt& aPlast)
45 {
46
47
48  Handle(Graphic3d_Group) G = Prs3d_Root::CurrentGroup(aPresentation);
49
50  Quantity_Length xo,yo,zo,x,y,z;
51   
52  aPfirst.Coord(xo,yo,zo);
53  aPlast.Coord(x,y,z);
54  
55  Graphic3d_Array1OfVertex A(1,2);
56  A(1).SetCoord(xo,yo,zo);
57  A(2).SetCoord(x,y,z);
58  
59  G->SetPrimitivesAspect(aLineAspect->Aspect());
60  G->Polyline(A);
61  Prs3d_Arrow::Draw(aPresentation,gp_Pnt(x,y,z),aDir,M_PI/180.*10.,aVal/10.);
62  Prs3d_Root::CurrentGroup(aPresentation)->Text(aText,A(2),1./81.);
63
64 }
65
66
67 void DsgPrs_XYZAxisPresentation::Add(const Handle(Prs3d_Presentation)& aPresentation,
68                                      const Handle(Prs3d_LineAspect)& aLineAspect,
69                                      const Handle(Prs3d_ArrowAspect)& anArrowAspect,
70                                      const Handle(Prs3d_TextAspect)& aTextAspect,
71                                      const gp_Dir & aDir, 
72                                      const Standard_Real aVal,
73                                      const Standard_CString aText,
74                                      const gp_Pnt& aPfirst,
75                                      const gp_Pnt& aPlast)
76 {
77 #ifdef OCC218
78   Handle(Graphic3d_Group) G = Prs3d_Root::CurrentGroup(aPresentation);
79
80   Quantity_Length xo,yo,zo,x,y,z;
81   
82   aPfirst.Coord(xo,yo,zo);
83   aPlast.Coord(x,y,z);
84  
85   Graphic3d_Array1OfVertex A(1,2);
86   A(1).SetCoord(xo,yo,zo);
87   A(2).SetCoord(x,y,z);
88  
89   G->SetPrimitivesAspect(aLineAspect->Aspect());
90   G->Polyline(A);
91   G->SetPrimitivesAspect( anArrowAspect->Aspect() );
92   Prs3d_Arrow::Draw(aPresentation,gp_Pnt(x,y,z),aDir,M_PI/180.*10.,aVal/10.);
93   G->SetPrimitivesAspect(aTextAspect->Aspect());
94   Prs3d_Root::CurrentGroup(aPresentation)->Text(aText,A(2),1./81.);
95 #endif
96 }