0031431: Visualization, PrsMgr_PresentableObject - simplify HLR computing interface
[occt.git] / samples / mfc / standard / 01_Geometry / src / ISession2D / ISession_Direction.cpp
CommitLineData
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"
234e52be 8#include <Prs3d_ArrowAspect.hxx>
9#include <DsgPrs_LengthPresentation.hxx>
7fd59977 10
11#ifdef _DEBUG
12#undef THIS_FILE
13static char THIS_FILE[]=__FILE__;
14#endif
15
7fd59977 16IMPLEMENT_STANDARD_RTTIEXT(ISession_Direction,AIS_InteractiveObject)
17
7fd59977 18//////////////////////////////////////////////////////////////////////
19// Construction/Destruction
20//////////////////////////////////////////////////////////////////////
21
22ISession_Direction::ISession_Direction()
23{
24
25}
26
e5b32824 27ISession_Direction::ISession_Direction (const gp_Pnt& aPnt,
28 const gp_Dir& aDir,
29 Standard_Real aLength,
30 Standard_Real anArrowLength)
31: myPnt (aPnt),
32 myDir (aDir),
33 myLength (aLength),
34 myArrowLength (anArrowLength)
7fd59977 35{}
36
e5b32824 37ISession_Direction::ISession_Direction (const gp_Pnt& aPnt,
38 const gp_Vec& aVec,
39 Standard_Real anArrowLength)
40: myPnt (aPnt),
41 myDir (aVec),
42 myArrowLength (anArrowLength)
7fd59977 43{
44 myLength = aVec.Magnitude();
45}
46
e5b32824 47ISession_Direction::ISession_Direction (const gp_Pnt2d& aPnt2d,
48 const gp_Dir2d& aDir2d,
49 Standard_Real aLength)
50: myPnt (gp_Pnt(aPnt2d.X(),aPnt2d.Y(),0.0)),
51 myDir (gp_Dir(aDir2d.X(),aDir2d.Y(),0.0)),
52 myLength (aLength)
53{
54 myArrowLength = myDrawer->ArrowAspect()->Length();
55}
7fd59977 56
e5b32824 57ISession_Direction::ISession_Direction (const gp_Pnt2d& aPnt2d,
58 const gp_Vec2d& aVec2d)
59: myPnt (gp_Pnt (aPnt2d.X(), aPnt2d.Y(), 0.0)),
60 myDir (gp_Dir(aVec2d.X(), aVec2d.Y(), 0.0))
7fd59977 61{
62 myLength = aVec2d.Magnitude();
e5b32824 63 myArrowLength = myDrawer->ArrowAspect()->Length();
7fd59977 64}
65
66
67ISession_Direction::~ISession_Direction()
68{
69
70}
71
e5b32824 72void ISession_Direction::Compute (const Handle(PrsMgr_PresentationManager3d)& /*aPresentationManager*/,
73 const Handle(Prs3d_Presentation)& aPresentation,
74 const Standard_Integer /*aMode*/)
7fd59977 75{
e5b32824 76 // Set style for arrow
77 Handle(Prs3d_ArrowAspect) anArrowAspect = myDrawer->ArrowAspect();
78 anArrowAspect->SetLength (myArrowLength);
79
80 gp_Pnt aLastPoint = myPnt;
81 aLastPoint.Translate (myLength*gp_Vec(myDir));
82
83 // Draw Line
84 Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments (2);
85 aPrims->AddVertex (myPnt);
86 aPrims->AddVertex (aLastPoint);
87 Prs3d_Root::CurrentGroup (aPresentation)->SetPrimitivesAspect (myDrawer->LineAspect()->Aspect());
88 Prs3d_Root::CurrentGroup (aPresentation)->AddPrimitiveArray (aPrims);
89 // Draw arrow
4ad142d9 90 Prs3d_Arrow::Draw (Prs3d_Root::CurrentGroup (aPresentation),
e5b32824 91 aLastPoint,
92 myDir,
93 anArrowAspect->Angle(),
94 anArrowAspect->Length());
95
96 // Draw text
97 if (myText.Length() != 0)
98 {
99 gp_Pnt aTextPosition = aLastPoint;
4ad142d9 100 Prs3d_Text::Draw (Prs3d_Root::CurrentGroup (aPresentation),
e5b32824 101 myDrawer->TextAspect(),
102 myText,
103 aTextPosition);
104 }
7fd59977 105}
106
e5b32824 107void ISession_Direction::ComputeSelection (const Handle(SelectMgr_Selection)& /*aSelection*/,
108 const Standard_Integer /*aMode*/)
109{
110}
111
112void ISession_Direction::SetText (TCollection_ExtendedString & theText)
113{
114 myText = theText;
7fd59977 115}
116
e5b32824 117void ISession_Direction::SetText (Standard_CString theText)
7fd59977 118{
e5b32824 119 myText = theText;
7fd59977 120}
5c573e69 121
e5b32824 122void ISession_Direction::SetLineAspect (const Handle(Prs3d_LineAspect)& theAspect)
5c573e69 123{
e5b32824 124 myDrawer->SetLineAspect (theAspect);
5c573e69 125}