0024339: Vectors not displayed correctly in MFC samples [6.7.0 Beta]: ISession_Direct...
[occt.git] / samples / mfc / standard / 02_Modeling / src / ISession_Direction.cpp
1 // ISession_Direction.cpp: implementation of the ISession_Direction class.
2 //
3 //////////////////////////////////////////////////////////////////////
4
5 #include "stdafx.h"
6 #include "ISession_Direction.h"
7
8 #ifdef _DEBUG
9 #undef THIS_FILE
10 static char THIS_FILE[]=__FILE__;
11 #endif
12
13 IMPLEMENT_STANDARD_HANDLE(ISession_Direction,AIS_InteractiveObject)
14 IMPLEMENT_STANDARD_RTTIEXT(ISession_Direction,AIS_InteractiveObject)
15
16 #include "DsgPrs_LengthPresentation.hxx"
17 #include "Prs3d_ArrowAspect.hxx"
18 #include "AIS_Drawer.hxx"
19 //////////////////////////////////////////////////////////////////////
20 // Construction/Destruction
21 //////////////////////////////////////////////////////////////////////
22
23
24 ISession_Direction::ISession_Direction(const gp_Pnt& aPnt,const gp_Pnt& aPnt2)
25 :myStartPnt(aPnt),myEndPnt(aPnt2)
26 {}
27
28 ISession_Direction::ISession_Direction(const gp_Pnt& aPnt,const gp_Vec& aVec)
29 :myStartPnt(aPnt)
30 {
31   myEndPnt = myStartPnt.Translated(aVec);
32 }
33
34
35 void ISession_Direction::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentationManager*/,
36                                  const Handle(Prs3d_Presentation)& aPresentation,
37                                  const Standard_Integer /*aMode*/)
38 {
39   // Set style for arrow
40   Handle(Prs3d_ArrowAspect) anArrowAspect = myDrawer->ArrowAspect();
41
42   // Draw Line
43   Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments (2);
44   aPrims->AddVertex (myStartPnt);
45   aPrims->AddVertex (myEndPnt);
46   Prs3d_Root::CurrentGroup (aPresentation)->SetPrimitivesAspect (myDrawer->LineAspect()->Aspect());
47   Prs3d_Root::CurrentGroup (aPresentation)->AddPrimitiveArray (aPrims);
48   // Draw arrow
49   Prs3d_Arrow::Draw (aPresentation,
50                      myEndPnt,
51                      gp_Dir (gp_Vec(myStartPnt, myEndPnt)),
52                      anArrowAspect->Angle(),
53                      anArrowAspect->Length());
54 }