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