Integration of OCCT 6.5.0 from SVN
[occt.git] / samples / mfc / standard / 01_Geometry / src / ISession2D / ISession_Text.cpp
1 // ISession_Text.cpp: implementation of the ISession_Text class.
2 //
3 //////////////////////////////////////////////////////////////////////
4
5 #include "stdafx.h"
6 #include "..\\GeometryApp.h"
7 #include "ISession_Text.h"
8
9 #ifdef _DEBUG
10 #undef THIS_FILE
11 static char THIS_FILE[]=__FILE__;
12 //#define new DEBUG_NEW
13 #endif
14 IMPLEMENT_STANDARD_HANDLE(ISession_Text,AIS_InteractiveObject)
15 IMPLEMENT_STANDARD_RTTIEXT(ISession_Text,AIS_InteractiveObject)
16
17 #include <Graphic2d_Text.hxx>
18 #include <Select2D_SensitiveBox.hxx>
19 #include <Graphic2d_Segment.hxx>
20 #include <OSD_Environment.hxx>
21 #include <Graphic2d_View.hxx>
22 #include <Graphic2d_Drawer.hxx>
23 #include "PrsMgr_PresentationManager2d.hxx"
24 #include "SelectMgr_Selection.hxx"
25 #include "Graphic2d_Array1OfVertex.hxx"
26 #include "Graphic2d_Polyline.hxx"
27 #include "Graphic2d_Vertex.hxx"
28 #include "Graphic2d_DisplayList.hxx"
29 #include "Prs3d_Text.hxx"
30
31 //////////////////////////////////////////////////////////////////////
32 // Construction/Destruction
33 //////////////////////////////////////////////////////////////////////
34
35 ISession_Text::ISession_Text()
36 {
37
38 }
39
40
41 ISession_Text::ISession_Text
42                  (const TCollection_AsciiString& aText, 
43                   const Standard_Real            anX ,        // = 0
44                   const Standard_Real            anY ,        // = 0
45                   const Standard_Real            aZ  ,        // = 0
46                               const Aspect_TypeOfText        aType,       // = SOLID,
47                               const Quantity_PlaneAngle      anAngle,     // = 0.0
48                               const Standard_Real            aslant,      // = 0.0
49                               const Standard_Integer         aColorIndex, // = 0
50                               const Standard_Integer         aFontIndex,  // = 1
51                               const Quantity_Factor          aScale)      // = 1
52                   :AIS_InteractiveObject(),MyText(aText),MyX(anX),MyY(anY),MyZ(aZ),
53                   MyTypeOfText(aType),MyAngle(anAngle),MySlant(aslant),MyFontIndex(aFontIndex),
54                   MyColorIndex(aColorIndex),MyScale(aScale),MyWidth(0),MyHeight(0)
55 {}
56
57 ISession_Text::ISession_Text
58                  (const TCollection_AsciiString& aText, 
59                   gp_Pnt&                        aPoint,
60                               const Aspect_TypeOfText        aType,       // = SOLID,
61                               const Quantity_PlaneAngle      anAngle,     // = 0.0
62                               const Standard_Real            aslant,      // = 0.0
63                               const Standard_Integer         aColorIndex, // = 0
64                               const Standard_Integer         aFontIndex,  // = 1
65                               const Quantity_Factor          aScale)      // = 1
66                   :AIS_InteractiveObject(),MyText(aText),MyX(aPoint.X()),MyY(aPoint.Y()),MyZ(aPoint.Z()),
67                   MyTypeOfText(aType),MyAngle(anAngle),MySlant(aslant),MyFontIndex(aFontIndex),
68                   MyColorIndex(aColorIndex),MyScale(aScale),MyWidth(0),MyHeight(0)
69 {}
70
71
72
73 ISession_Text::~ISession_Text()
74 {
75
76 }
77
78 void ISession_Text::Compute(const Handle(PrsMgr_PresentationManager3d)& aPresentationManager,
79                              const Handle(Prs3d_Presentation)& aPresentation,
80                              const Standard_Integer aMode)
81 {
82     Prs3d_Text::Draw(aPresentation,myDrawer,MyText,gp_Pnt(  MyX ,MyY,MyZ ));
83 }
84
85 void ISession_Text::Compute(const Handle(Prs3d_Projector)& aProjector,
86                              const Handle(Prs3d_Presentation)& aPresentation) 
87  {
88  }
89
90 void ISession_Text::Compute(const Handle(PrsMgr_PresentationManager2d)& aPresentationManager, 
91                          const Handle(Graphic2d_GraphicObject)& aGrObj, 
92                          const Standard_Integer unMode)
93 {
94   Handle(Graphic2d_Text) text;
95   text = new Graphic2d_Text(aGrObj, MyText, MyX, MyY, MyAngle,MyTypeOfText,MyScale);
96   text->SetFontIndex(MyFontIndex);
97  
98   text->SetColorIndex(MyColorIndex);
99  
100   text->SetSlant(MySlant);
101   text->SetUnderline(Standard_False);
102   text->SetZoomable(Standard_True);
103   aGrObj->Display();
104   Quantity_Length anXoffset,anYoffset;
105   text->TextSize(MyWidth, MyHeight,anXoffset,anYoffset);
106
107 }
108
109 void ISession_Text::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection, 
110                                       const Standard_Integer unMode)
111 {
112 }
113