0028990: Coding Rules - deprecate redundant class Prs3d_Root
[occt.git] / samples / mfc / standard / 01_Geometry / src / ISession2D / ISession_Direction.cpp
1 // ISession_Direction.cpp: implementation of the ISession_Direction class.
2 //
3 //////////////////////////////////////////////////////////////////////
4
5 #include "stdafx.h"
6 #include "..\\GeometryApp.h"
7 #include "ISession_Direction.h"
8 #include <Prs3d_ArrowAspect.hxx>
9 #include <DsgPrs_LengthPresentation.hxx>
10
11 #ifdef _DEBUG
12 #undef THIS_FILE
13 static char THIS_FILE[]=__FILE__;
14 #endif
15
16 IMPLEMENT_STANDARD_RTTIEXT(ISession_Direction,AIS_InteractiveObject)
17
18 //////////////////////////////////////////////////////////////////////
19 // Construction/Destruction
20 //////////////////////////////////////////////////////////////////////
21
22 ISession_Direction::ISession_Direction()
23 {
24
25 }
26
27 ISession_Direction::ISession_Direction (const gp_Pnt& aPnt,
28                                         const gp_Dir& aDir,
29                                         Standard_Real aLength,
30                                         Standard_Real anArrowLength)
31 : myPnt (aPnt),
32   myDir (aDir),
33   myLength (aLength),
34   myArrowLength (anArrowLength)
35 {}
36
37 ISession_Direction::ISession_Direction (const gp_Pnt& aPnt,
38                                         const gp_Vec& aVec,
39                                         Standard_Real anArrowLength)
40 : myPnt (aPnt),
41   myDir (aVec),
42   myArrowLength (anArrowLength)
43 {
44   myLength = aVec.Magnitude();
45 }
46
47 ISession_Direction::ISession_Direction (const gp_Pnt2d& aPnt2d,
48                                         const gp_Dir2d& aDir2d,
49                                         Standard_Real aLength)
50 : myPnt (gp_Pnt(aPnt2d.X(),aPnt2d.Y(),0.0)),
51   myDir (gp_Dir(aDir2d.X(),aDir2d.Y(),0.0)),
52   myLength (aLength)
53 {
54   myArrowLength = myDrawer->ArrowAspect()->Length();
55 }
56
57 ISession_Direction::ISession_Direction (const gp_Pnt2d& aPnt2d,
58                                         const gp_Vec2d& aVec2d)
59 : myPnt (gp_Pnt (aPnt2d.X(), aPnt2d.Y(), 0.0)),
60   myDir (gp_Dir(aVec2d.X(), aVec2d.Y(), 0.0))
61 {
62   myLength = aVec2d.Magnitude();
63   myArrowLength = myDrawer->ArrowAspect()->Length();
64 }
65
66
67 ISession_Direction::~ISession_Direction()
68 {
69
70 }
71
72 void ISession_Direction::Compute (const Handle(PrsMgr_PresentationManager3d)& /*aPresentationManager*/,
73                                   const Handle(Prs3d_Presentation)& aPresentation,
74                                   const Standard_Integer /*aMode*/)
75 {
76   // Set style for arrow
77   Handle(Prs3d_ArrowAspect) anArrowAspect = myDrawer->ArrowAspect();
78   anArrowAspect->SetLength (myArrowLength);
79
80   gp_Pnt aLastPoint = myPnt;
81   aLastPoint.Translate (myLength*gp_Vec(myDir));
82
83   // Draw Line
84   Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments (2);
85   aPrims->AddVertex (myPnt);
86   aPrims->AddVertex (aLastPoint);
87   aPresentation->CurrentGroup()->SetPrimitivesAspect (myDrawer->LineAspect()->Aspect());
88   aPresentation->CurrentGroup()->AddPrimitiveArray (aPrims);
89   // Draw arrow
90   Prs3d_Arrow::Draw (aPresentation->CurrentGroup(),
91                      aLastPoint,
92                      myDir,
93                      anArrowAspect->Angle(),
94                      anArrowAspect->Length());
95
96   // Draw text
97   if (myText.Length() != 0)
98   {
99     gp_Pnt aTextPosition = aLastPoint;
100     Prs3d_Text::Draw (aPresentation->CurrentGroup(),
101                       myDrawer->TextAspect(),
102                       myText,
103                       aTextPosition);
104   }
105 }
106
107 void ISession_Direction::ComputeSelection (const Handle(SelectMgr_Selection)& /*aSelection*/,
108                                            const Standard_Integer /*aMode*/) 
109 {
110 }
111
112 void ISession_Direction::SetText (TCollection_ExtendedString & theText)
113 {
114   myText = theText;
115 }
116
117 void ISession_Direction::SetText (Standard_CString theText)
118 {
119   myText = theText;
120 }
121
122 void ISession_Direction::SetLineAspect (const Handle(Prs3d_LineAspect)& theAspect)
123 {
124   myDrawer->SetLineAspect (theAspect);
125 }