Integration of OCCT 6.5.0 from SVN
[occt.git] / src / TestTopOpeDraw / TestTopOpeDraw_DrawableC2D.cxx
CommitLineData
7fd59977 1// File: TestTopOpeDraw_DrawableC2D.cxx
2// Created: Fri Dec 1 18:06:28 1995
3// Author: Jean Yves LEBEY
4// <jyl@meteox>
5
6#include <TestTopOpeDraw_DrawableC2D.ixx>
7#include <Draw_Interpretor.hxx>
8#include <TopOpeBRepTool_define.hxx>
9
10//=======================================================================
11//function : TestTopOpeDraw_DrawableC2D
12//purpose :
13//=======================================================================
14
15TestTopOpeDraw_DrawableC2D::TestTopOpeDraw_DrawableC2D
16(const Handle(Geom2d_Curve)& C, const Draw_Color& CColor,
17 const Standard_CString Text, const Draw_Color& TextColor,
18 const Standard_Integer Discret, const Standard_Boolean DispOrigin, const Standard_Boolean DispCurvRadius,
19 const Standard_Real RadiusMax, const Standard_Real RadiusRatio) :
20 DrawTrSurf_Curve2d(C,CColor,Discret,DispOrigin,DispCurvRadius,RadiusMax,RadiusRatio),
21 myText(Text),
22 myTextColor(TextColor)
23{
24 myText2D = new Draw_Text2D(Pnt2d(),Text,TextColor);
25}
26
27//=======================================================================
28//function : TestTopOpeDraw_DrawableC2D
29//purpose :
30//=======================================================================
31
32TestTopOpeDraw_DrawableC2D::TestTopOpeDraw_DrawableC2D
33(const Handle(Geom2d_Curve)& C, const Draw_Color& CColor) :
34 DrawTrSurf_Curve2d(C,CColor,16,Standard_True,Standard_False,0.01,1), //Discret,Deflect,DrawMode
35 myText(""),
36 myTextColor(CColor)
37{
38 myText2D = new Draw_Text2D(Pnt2d(),"",CColor);
39}
40
41//=======================================================================
42//function : TestTopOpeDraw_DrawableC2D
43//purpose :
44//=======================================================================
45
46TestTopOpeDraw_DrawableC2D::TestTopOpeDraw_DrawableC2D
47(const Handle(Geom2d_Curve)& C, const Draw_Color& CColor,
48 const Standard_CString Text, const Draw_Color& TextColor) :
49 DrawTrSurf_Curve2d(C,CColor,16,Standard_True,Standard_False,0.01,1), //Discret,Deflect,DrawMode
50 myText(Text),
51 myTextColor(TextColor)
52{
53 myText2D = new Draw_Text2D(Pnt2d(),Text,TextColor);
54}
55
56//=======================================================================
57//function : Pnt2d
58//purpose :
59//=======================================================================
60
61gp_Pnt2d TestTopOpeDraw_DrawableC2D::Pnt2d() const
62{
63 const Handle(Geom2d_Curve)& GC = GetCurve();
64 Standard_Real f = GC->FirstParameter();
65 Standard_Real l = GC->LastParameter();
66 Standard_Real t = 1/2.;
67 Standard_Real p = t*f + (1-t)*l;
68 gp_Pnt2d P = GC->Value(p);
69 return P;
70}
71
72//=======================================================================
73//function : ChangePnt2d
74//purpose :
75//=======================================================================
76
77void TestTopOpeDraw_DrawableC2D::ChangePnt2d(const gp_Pnt2d& P)
78{
79 myText2D = new Draw_Text2D(Pnt2d(),myText,myTextColor);
80}
81
82//=======================================================================
83//function : ChangeCurve
84//purpose :
85//=======================================================================
86
87void TestTopOpeDraw_DrawableC2D::ChangeCurve(const Handle(Geom2d_Curve)& GC)
88{
89 curv = GC;
90}
91
92//=======================================================================
93//function : ChangeText
94//purpose :
95//=======================================================================
96
97void TestTopOpeDraw_DrawableC2D::ChangeText(const Standard_CString T)
98{
99 myText = T;
100 myText2D = new Draw_Text2D(Pnt2d(),T,myTextColor);
101}
102
103//=======================================================================
104//function : Whatis
105//purpose :
106//=======================================================================
107
108void TestTopOpeDraw_DrawableC2D::Whatis(Draw_Interpretor& s)const
109{
110 if (!curv.IsNull())
111 s << "DrawableC2D";
112}
113
114//=======================================================================
115//function : DrawOn
116//purpose :
117//=======================================================================
118void TestTopOpeDraw_DrawableC2D::DrawOn(Draw_Display& dis) const
119{
120 DrawTrSurf_Curve2d::DrawOn(dis);
121 myText2D->DrawOn(dis);
122}
123
124//=======================================================================
125//function : Name
126//purpose :
127//=======================================================================
128
129void TestTopOpeDraw_DrawableC2D::Name(const Standard_CString N)
130{
131 char* temp = new char[2];
132 temp[0] = ' ' ;
133 temp[1] = 0;
134 strcat(temp, N);
135 Draw_Drawable3D::Name(temp);
136 ChangeText(temp);
137}