Integration of OCCT 6.5.0 from SVN
[occt.git] / samples / java / src / ISession / ISession_Direction.cxx
CommitLineData
7fd59977 1#include <ISession_Direction.ixx>
2#include <Prs3d_ArrowAspect.hxx>
3#include <gp_Pnt.hxx>
4#include <DsgPrs_LengthPresentation.hxx>
5#include <DsgPrs.hxx>
6#include <Graphic2d_SetOfSegments.hxx>
7#include <gp_Dir2d.hxx>
8#include <AIS_Drawer.hxx>
9
10ISession_Direction::ISession_Direction()
11{
12}
13
14ISession_Direction::ISession_Direction(const gp_Pnt& aPnt,const gp_Dir& aDir,const Standard_Real aLength,const Standard_Real anArrowLength)
15 :myPnt(aPnt),myDir(aDir),myLength(aLength),myArrowLength(anArrowLength)
16{
17}
18
19ISession_Direction::ISession_Direction(const gp_Pnt& aPnt,const gp_Vec& aVec,const Standard_Real aLength)
20 :myPnt(aPnt),myDir(aVec),myArrowLength(aLength)
21{
22 myLength = aVec.Magnitude();
23}
24
25ISession_Direction::ISession_Direction(const gp_Pnt2d& aPnt2d,const gp_Dir2d& aDir2d,const Standard_Real aLength)
26 :myPnt(gp_Pnt(aPnt2d.X(),aPnt2d.Y(),0)),myDir(gp_Dir(aDir2d.X(),aDir2d.Y(),0)),myLength(aLength)
27{
28}
29
30ISession_Direction::ISession_Direction(const gp_Pnt2d& aPnt2d,const gp_Vec2d& aVec2d)
31 :myPnt(gp_Pnt(aPnt2d.X(),aPnt2d.Y(),0)),myDir(gp_Dir(aVec2d.X(),aVec2d.Y(),0))
32{
33 myLength = aVec2d.Magnitude();
34}
35
36 void ISession_Direction::SetText(const TCollection_ExtendedString& aText)
37{
38 myText = aText;
39}
40
41 void ISession_Direction::Compute(const Handle(PrsMgr_PresentationManager3d)& ,const Handle(Prs3d_Presentation)& aPresentation,const Standard_Integer )
42{
43 Handle(Prs3d_ArrowAspect) anArrowAspect = myDrawer->ArrowAspect();
44 anArrowAspect->SetLength(myArrowLength);
45 myDrawer->SetArrowAspect(anArrowAspect);
46
47 gp_Pnt LastPoint = myPnt;
48 LastPoint.Translate (myLength*gp_Vec(myDir));
49
50 if (myText.Length() == 0)
51 DsgPrs_LengthPresentation::Add(aPresentation,myDrawer,myPnt,LastPoint,DsgPrs_AS_LASTAR);
52 else
53 {
54 gp_Pnt OffsetPoint = myPnt;
55 OffsetPoint.Translate ((myLength) *gp_Vec(myDir));
56 DsgPrs_LengthPresentation::Add(aPresentation,myDrawer,myText,myPnt,LastPoint, -myDir, OffsetPoint, DsgPrs_AS_LASTAR);
57 }
58}
59
60 void ISession_Direction::Compute(const Handle(Prs3d_Projector)& ,const Handle(Prs3d_Presentation)& )
61{
62}
63
64 void ISession_Direction::Compute(const Handle(PrsMgr_PresentationManager2d)& ,const Handle(Graphic2d_GraphicObject)& aGrObj,const Standard_Integer )
65{
66 Handle(Graphic2d_SetOfSegments) segment;
67 segment = new Graphic2d_SetOfSegments(aGrObj);
68
69 segment->Add(myPnt.X(),
70 myPnt.Y(),
71 myPnt.X()+myLength*myDir.X(),
72 myPnt.Y()+myLength*myDir.Y());
73
74 gp_Dir2d aFirstDir = gp_Dir2d(myDir.X(),myDir.Y()).Rotated (200*PI180);
75 segment->Add(myPnt.X()+myLength*myDir.X(),
76 myPnt.Y()+myLength*myDir.Y(),
77 myPnt.X()+myLength*myDir.X()+ myLength*aFirstDir.X()/5,
78 myPnt.Y()+myLength*myDir.Y()+ myLength*aFirstDir.Y()/5);
79
80 gp_Dir2d aSecondDir = gp_Dir2d(myDir.X(),myDir.Y()).Rotated (-200*PI180);
81 segment->Add(myPnt.X()+myLength*myDir.X(),
82 myPnt.Y()+myLength*myDir.Y(),
83 myPnt.X()+myLength*myDir.X()+ myLength*aSecondDir.X()/5,
84 myPnt.Y()+myLength*myDir.Y()+ myLength*aSecondDir.Y()/5);
85}
86
87 void ISession_Direction::ComputeSelection(const Handle(SelectMgr_Selection)& ,const Standard_Integer )
88{
89}
90