1 // ISession_Direction.cpp: implementation of the ISession_Direction class.
3 //////////////////////////////////////////////////////////////////////
6 #include "..\\GeometryApp.h"
7 #include "ISession_Direction.h"
8 #include <Prs3d_ArrowAspect.hxx>
9 #include <DsgPrs_LengthPresentation.hxx>
13 static char THIS_FILE[]=__FILE__;
16 IMPLEMENT_STANDARD_HANDLE(ISession_Direction,AIS_InteractiveObject)
17 IMPLEMENT_STANDARD_RTTIEXT(ISession_Direction,AIS_InteractiveObject)
19 //////////////////////////////////////////////////////////////////////
20 // Construction/Destruction
21 //////////////////////////////////////////////////////////////////////
23 ISession_Direction::ISession_Direction()
28 ISession_Direction::ISession_Direction (const gp_Pnt& aPnt,
30 Standard_Real aLength,
31 Standard_Real anArrowLength)
35 myArrowLength (anArrowLength)
38 ISession_Direction::ISession_Direction (const gp_Pnt& aPnt,
40 Standard_Real anArrowLength)
43 myArrowLength (anArrowLength)
45 myLength = aVec.Magnitude();
48 ISession_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)),
55 myArrowLength = myDrawer->ArrowAspect()->Length();
58 ISession_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))
63 myLength = aVec2d.Magnitude();
64 myArrowLength = myDrawer->ArrowAspect()->Length();
68 ISession_Direction::~ISession_Direction()
73 void ISession_Direction::Compute (const Handle(PrsMgr_PresentationManager3d)& /*aPresentationManager*/,
74 const Handle(Prs3d_Presentation)& aPresentation,
75 const Standard_Integer /*aMode*/)
77 // Set style for arrow
78 Handle(Prs3d_ArrowAspect) anArrowAspect = myDrawer->ArrowAspect();
79 anArrowAspect->SetLength (myArrowLength);
81 gp_Pnt aLastPoint = myPnt;
82 aLastPoint.Translate (myLength*gp_Vec(myDir));
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);
91 Prs3d_Arrow::Draw (aPresentation,
94 anArrowAspect->Angle(),
95 anArrowAspect->Length());
98 if (myText.Length() != 0)
100 gp_Pnt aTextPosition = aLastPoint;
101 Prs3d_Text::Draw (aPresentation,
102 myDrawer->TextAspect(),
109 void ISession_Direction::Compute (const Handle(Prs3d_Projector)& /*aProjector*/,
110 const Handle(Prs3d_Presentation)& /*aPresentation*/)
114 void ISession_Direction::ComputeSelection (const Handle(SelectMgr_Selection)& /*aSelection*/,
115 const Standard_Integer /*aMode*/)
119 void ISession_Direction::SetText (TCollection_ExtendedString & theText)
124 void ISession_Direction::SetText (Standard_CString theText)
129 void ISession_Direction::SetLineAspect (const Handle(Prs3d_LineAspect)& theAspect)
131 myDrawer->SetLineAspect (theAspect);