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" |
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 | #include "Graphic2d_SetOfSegments.hxx" |
18 | #include "gp_Vec2d.hxx" |
19 | #include "DsgPrs_LengthPresentation.hxx" |
20 | #include "Prs3d_ArrowAspect.hxx" |
21 | |
22 | ////////////////////////////////////////////////////////////////////// |
23 | // Construction/Destruction |
24 | ////////////////////////////////////////////////////////////////////// |
25 | |
26 | ISession_Direction::ISession_Direction() |
27 | { |
28 | |
29 | } |
30 | |
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) |
33 | {} |
34 | |
35 | ISession_Direction::ISession_Direction(gp_Pnt& aPnt,gp_Vec& aVec,Standard_Real anArrowLength) |
36 | :myPnt(aPnt),myDir(aVec),myArrowLength(anArrowLength) |
37 | { |
38 | myLength = aVec.Magnitude(); |
39 | } |
40 | |
41 | ISession_Direction::ISession_Direction(gp_Pnt2d& aPnt2d, |
42 | gp_Dir2d& aDir2d, |
43 | Standard_Real aLength) |
44 | :myPnt(gp_Pnt(aPnt2d.X(),aPnt2d.Y(),0)),myDir(gp_Dir(aDir2d.X(),aDir2d.Y(),0)),myLength(aLength) |
45 | {} |
46 | |
47 | ISession_Direction::ISession_Direction(gp_Pnt2d& aPnt2d, |
48 | gp_Vec2d& aVec2d) |
49 | :myPnt(gp_Pnt(aPnt2d.X(),aPnt2d.Y(),0)),myDir(gp_Dir(aVec2d.X(),aVec2d.Y(),0)) |
50 | { |
51 | myLength = aVec2d.Magnitude(); |
52 | } |
53 | |
54 | |
55 | ISession_Direction::~ISession_Direction() |
56 | { |
57 | |
58 | } |
59 | |
60 | void ISession_Direction::Compute(const Handle(PrsMgr_PresentationManager3d)& aPresentationManager, |
61 | const Handle(Prs3d_Presentation)& aPresentation, |
62 | const Standard_Integer aMode) |
63 | { |
64 | Handle(Prs3d_ArrowAspect) anArrowAspect = myDrawer->ArrowAspect(); |
65 | anArrowAspect->SetLength(myArrowLength); |
66 | myDrawer->SetArrowAspect(anArrowAspect); |
67 | |
68 | gp_Pnt LastPoint = myPnt ; |
69 | LastPoint.Translate (myLength*gp_Vec(myDir)) ; |
70 | |
71 | if (myText.Length() == 0) |
72 | DsgPrs_LengthPresentation::Add(aPresentation,myDrawer,myPnt,LastPoint,DsgPrs_AS_LASTAR); |
73 | else |
74 | { |
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); |
78 | } |
79 | } |
80 | |
81 | |
82 | void ISession_Direction::Compute(const Handle(Prs3d_Projector)& aProjector, |
83 | const Handle(Prs3d_Presentation)& aPresentation) |
84 | { |
85 | } |
86 | |
87 | void ISession_Direction::Compute(const Handle(PrsMgr_PresentationManager2d)& aPresentationManager, |
88 | const Handle(Graphic2d_GraphicObject)& aGrObj, |
89 | const Standard_Integer aMode) |
90 | { |
91 | Handle(Graphic2d_SetOfSegments) segment; |
92 | segment = new Graphic2d_SetOfSegments(aGrObj); |
93 | |
94 | segment->Add(myPnt.X(), |
95 | myPnt.Y(), |
96 | myPnt.X()+myLength*myDir.X(), |
97 | myPnt.Y()+myLength*myDir.Y()); |
98 | |
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 ); |
104 | |
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 ); |
110 | |
111 | } |
112 | void ISession_Direction::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection, |
113 | const Standard_Integer aMode) |
114 | { |
115 | } |
116 | |
117 | void ISession_Direction::SetText(TCollection_ExtendedString & aText) |
118 | { |
119 | myText = aText; |
120 | } |