1 // ISession_Direction.cpp: implementation of the ISession_Direction class.
3 //////////////////////////////////////////////////////////////////////
6 #include "..\\GeometryApp.h"
7 #include "ISession_Direction.h"
11 static char THIS_FILE[]=__FILE__;
14 IMPLEMENT_STANDARD_HANDLE(ISession_Direction,AIS_InteractiveObject)
15 IMPLEMENT_STANDARD_RTTIEXT(ISession_Direction,AIS_InteractiveObject)
17 #include "Graphic2d_SetOfSegments.hxx"
18 #include "gp_Vec2d.hxx"
19 #include "DsgPrs_LengthPresentation.hxx"
20 #include "Prs3d_ArrowAspect.hxx"
22 //////////////////////////////////////////////////////////////////////
23 // Construction/Destruction
24 //////////////////////////////////////////////////////////////////////
26 ISession_Direction::ISession_Direction()
31 ISession_Direction::ISession_Direction(gp_Pnt& aPnt,gp_Dir& aDir,Standard_Real aLength,Standard_Real anArrowLength)
32 :myPnt(aPnt),myDir(aDir),myLength(aLength),myArrowLength(anArrowLength)
35 ISession_Direction::ISession_Direction(gp_Pnt& aPnt,gp_Vec& aVec,Standard_Real anArrowLength)
36 :myPnt(aPnt),myDir(aVec),myArrowLength(anArrowLength)
38 myLength = aVec.Magnitude();
41 ISession_Direction::ISession_Direction(gp_Pnt2d& aPnt2d,
43 Standard_Real aLength)
44 :myPnt(gp_Pnt(aPnt2d.X(),aPnt2d.Y(),0)),myDir(gp_Dir(aDir2d.X(),aDir2d.Y(),0)),myLength(aLength)
47 ISession_Direction::ISession_Direction(gp_Pnt2d& aPnt2d,
49 :myPnt(gp_Pnt(aPnt2d.X(),aPnt2d.Y(),0)),myDir(gp_Dir(aVec2d.X(),aVec2d.Y(),0))
51 myLength = aVec2d.Magnitude();
55 ISession_Direction::~ISession_Direction()
60 void ISession_Direction::Compute(const Handle(PrsMgr_PresentationManager3d)& aPresentationManager,
61 const Handle(Prs3d_Presentation)& aPresentation,
62 const Standard_Integer aMode)
64 Handle(Prs3d_ArrowAspect) anArrowAspect = myDrawer->ArrowAspect();
65 anArrowAspect->SetLength(myArrowLength);
66 myDrawer->SetArrowAspect(anArrowAspect);
68 gp_Pnt LastPoint = myPnt ;
69 LastPoint.Translate (myLength*gp_Vec(myDir)) ;
71 if (myText.Length() == 0)
72 DsgPrs_LengthPresentation::Add(aPresentation,myDrawer,myPnt,LastPoint,DsgPrs_AS_LASTAR);
75 gp_Pnt OffsetPoint = myPnt;
76 OffsetPoint.Translate ( (myLength) *gp_Vec(myDir)) ;
77 DsgPrs_LengthPresentation::Add(aPresentation,myDrawer,myText,myPnt,LastPoint, -myDir, OffsetPoint, DsgPrs_AS_LASTAR);
82 void ISession_Direction::Compute(const Handle(Prs3d_Projector)& aProjector,
83 const Handle(Prs3d_Presentation)& aPresentation)
87 void ISession_Direction::Compute(const Handle(PrsMgr_PresentationManager2d)& aPresentationManager,
88 const Handle(Graphic2d_GraphicObject)& aGrObj,
89 const Standard_Integer aMode)
91 Handle(Graphic2d_SetOfSegments) segment;
92 segment = new Graphic2d_SetOfSegments(aGrObj);
94 segment->Add(myPnt.X(),
96 myPnt.X()+myLength*myDir.X(),
97 myPnt.Y()+myLength*myDir.Y());
99 gp_Dir2d aFirstDir = gp_Dir2d(myDir.X(),myDir.Y()).Rotated (200*PI180) ;
100 segment->Add(myPnt.X()+myLength*myDir.X(),
101 myPnt.Y()+myLength*myDir.Y(),
102 myPnt.X()+myLength*myDir.X()+ myLength*aFirstDir.X()/5 ,
103 myPnt.Y()+myLength*myDir.Y()+ myLength*aFirstDir.Y()/5 );
105 gp_Dir2d aSecondDir = gp_Dir2d(myDir.X(),myDir.Y()).Rotated (-200*PI180) ;
106 segment->Add(myPnt.X()+myLength*myDir.X(),
107 myPnt.Y()+myLength*myDir.Y(),
108 myPnt.X()+myLength*myDir.X()+ myLength*aSecondDir.X()/5 ,
109 myPnt.Y()+myLength*myDir.Y()+ myLength*aSecondDir.Y()/5 );
112 void ISession_Direction::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
113 const Standard_Integer aMode)
117 void ISession_Direction::SetText(TCollection_ExtendedString & aText)