0023776: Redesign of MFC samples after V2d viewer removing
[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
9 #ifdef _DEBUG
10 #undef THIS_FILE
11 static char THIS_FILE[]=__FILE__;
12 #endif
13
14 IMPLEMENT_STANDARD_HANDLE(ISession_Direction,AIS_InteractiveObject)
15 IMPLEMENT_STANDARD_RTTIEXT(ISession_Direction,AIS_InteractiveObject)
16
17 //////////////////////////////////////////////////////////////////////
18 // Construction/Destruction
19 //////////////////////////////////////////////////////////////////////
20
21 ISession_Direction::ISession_Direction()
22 {
23
24 }
25
26 ISession_Direction::ISession_Direction(gp_Pnt& aPnt,gp_Dir&   aDir,Standard_Real aLength,Standard_Real anArrowLength)
27 :myPnt(aPnt),myDir(aDir),myLength(aLength),myArrowLength(anArrowLength)
28 {}
29
30 ISession_Direction::ISession_Direction(gp_Pnt& aPnt,gp_Vec&   aVec,Standard_Real anArrowLength)
31 :myPnt(aPnt),myDir(aVec),myArrowLength(anArrowLength)
32 {
33   myLength = aVec.Magnitude();
34 }
35
36 ISession_Direction::ISession_Direction(gp_Pnt2d& aPnt2d,
37                                        gp_Dir2d& aDir2d,
38                                        Standard_Real aLength)
39 :myPnt(gp_Pnt(aPnt2d.X(),aPnt2d.Y(),0)),myDir(gp_Dir(aDir2d.X(),aDir2d.Y(),0)),myLength(aLength)
40 {}
41
42 ISession_Direction::ISession_Direction(gp_Pnt2d& aPnt2d,
43                                        gp_Vec2d&   aVec2d)
44 :myPnt(gp_Pnt(aPnt2d.X(),aPnt2d.Y(),0)),myDir(gp_Dir(aVec2d.X(),aVec2d.Y(),0))
45 {
46   myLength = aVec2d.Magnitude();
47 }
48
49
50 ISession_Direction::~ISession_Direction()
51 {
52
53 }
54
55 void ISession_Direction::Compute(const Handle(PrsMgr_PresentationManager3d)& aPresentationManager,
56                              const Handle(Prs3d_Presentation)& aPresentation,
57                              const Standard_Integer aMode)
58 {
59     Handle(Prs3d_ArrowAspect) anArrowAspect = myDrawer->ArrowAspect();
60     anArrowAspect->SetLength(myArrowLength);
61     myDrawer->SetArrowAspect(anArrowAspect);
62
63     gp_Pnt LastPoint = myPnt  ;
64     LastPoint.Translate (myLength*gp_Vec(myDir))  ;
65
66     if (myText.Length() == 0)
67         DsgPrs_LengthPresentation::Add(aPresentation,myDrawer,myPnt,LastPoint,DsgPrs_AS_LASTAR);
68     else
69     {
70         gp_Pnt OffsetPoint = myPnt;
71         OffsetPoint.Translate ( (myLength) *gp_Vec(myDir))  ;
72         DsgPrs_LengthPresentation::Add(aPresentation,myDrawer,myText,myPnt,LastPoint, -myDir, OffsetPoint,  DsgPrs_AS_LASTAR);
73     }
74 }
75
76
77 void ISession_Direction::Compute(const Handle(Prs3d_Projector)& aProjector,
78                              const Handle(Prs3d_Presentation)& aPresentation) 
79  {
80  }
81
82 void ISession_Direction::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
83                                       const Standard_Integer aMode) 
84
85 }
86
87 void ISession_Direction::SetText(TCollection_ExtendedString & aText)
88 {
89     myText = aText;
90 }