0028574: Get rid of the TestTopOpe* packages
[occt.git] / src / TestTopOpeDraw / TestTopOpeDraw_DrawableC2D.cxx
1 // Created on: 1995-12-01
2 // Created by: Jean Yves LEBEY
3 // Copyright (c) 1995-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17
18 #include <Draw_Color.hxx>
19 #include <Draw_Display.hxx>
20 #include <Draw_Interpretor.hxx>
21 #include <Draw_Text2D.hxx>
22 #include <Geom2d_Curve.hxx>
23 #include <gp_Pnt2d.hxx>
24 #include <Standard_Type.hxx>
25 #include <TestTopOpeDraw_DrawableC2D.hxx>
26 #include <TopOpeBRepTool_define.hxx>
27
28 IMPLEMENT_STANDARD_RTTIEXT(TestTopOpeDraw_DrawableC2D,DrawTrSurf_Curve2d)
29
30 //=======================================================================
31 //function : TestTopOpeDraw_DrawableC2D
32 //purpose  : 
33 //=======================================================================
34 TestTopOpeDraw_DrawableC2D::TestTopOpeDraw_DrawableC2D
35 (const Handle(Geom2d_Curve)& C, const Draw_Color& CColor, 
36  const Standard_CString Text, const Draw_Color& TextColor,
37  const Standard_Integer Discret, const Standard_Boolean DispOrigin, const Standard_Boolean DispCurvRadius,
38  const Standard_Real RadiusMax, const Standard_Real RadiusRatio) :
39  DrawTrSurf_Curve2d(C,CColor,Discret,DispOrigin,DispCurvRadius,RadiusMax,RadiusRatio),
40  myText(Text),
41  myTextColor(TextColor)
42 {
43   myText2D = new Draw_Text2D(Pnt2d(),Text,TextColor);
44 }
45
46 //=======================================================================
47 //function : TestTopOpeDraw_DrawableC2D
48 //purpose : 
49 //=======================================================================
50
51 TestTopOpeDraw_DrawableC2D::TestTopOpeDraw_DrawableC2D
52 (const Handle(Geom2d_Curve)& C, const Draw_Color& CColor) :
53  DrawTrSurf_Curve2d(C,CColor,16,Standard_True,Standard_False,0.01,1), //Discret,Deflect,DrawMode
54  myText(""),
55  myTextColor(CColor)
56 {
57   myText2D = new Draw_Text2D(Pnt2d(),"",CColor);
58 }
59
60 //=======================================================================
61 //function : TestTopOpeDraw_DrawableC2D
62 //purpose : 
63 //=======================================================================
64
65 TestTopOpeDraw_DrawableC2D::TestTopOpeDraw_DrawableC2D
66 (const Handle(Geom2d_Curve)& C, const Draw_Color& CColor, 
67  const Standard_CString Text, const Draw_Color& TextColor) :
68  DrawTrSurf_Curve2d(C,CColor,16,Standard_True,Standard_False,0.01,1), //Discret,Deflect,DrawMode
69  myText(Text),
70  myTextColor(TextColor)
71 {
72   myText2D = new Draw_Text2D(Pnt2d(),Text,TextColor);
73 }
74
75 //=======================================================================
76 //function : Pnt2d
77 //purpose : 
78 //=======================================================================
79
80 gp_Pnt2d TestTopOpeDraw_DrawableC2D::Pnt2d() const
81 {
82   const Handle(Geom2d_Curve)& GC = GetCurve();
83   Standard_Real f = GC->FirstParameter();
84   Standard_Real l = GC->LastParameter();
85   Standard_Real t = 1/2.;
86   Standard_Real p = t*f + (1-t)*l;
87   gp_Pnt2d P = GC->Value(p);
88   return P;
89 }
90
91 //=======================================================================
92 //function : ChangePnt2d
93 //purpose  : 
94 //=======================================================================
95
96 void TestTopOpeDraw_DrawableC2D::ChangePnt2d(const gp_Pnt2d&)
97 {
98   myText2D = new Draw_Text2D(Pnt2d(),myText,myTextColor);
99 }
100
101 //=======================================================================
102 //function : ChangeCurve
103 //purpose  : 
104 //=======================================================================
105
106 void TestTopOpeDraw_DrawableC2D::ChangeCurve(const Handle(Geom2d_Curve)& GC)
107 {
108   curv = GC;
109 }
110
111 //=======================================================================
112 //function : ChangeText
113 //purpose  : 
114 //=======================================================================
115
116 void TestTopOpeDraw_DrawableC2D::ChangeText(const Standard_CString T)
117 {
118   myText = T;
119   myText2D = new Draw_Text2D(Pnt2d(),T,myTextColor);
120 }
121
122 //=======================================================================
123 //function : Whatis
124 //purpose : 
125 //=======================================================================
126
127 void  TestTopOpeDraw_DrawableC2D::Whatis(Draw_Interpretor& s)const 
128 {
129   if (!curv.IsNull())
130     s << "DrawableC2D";
131 }
132
133 //=======================================================================
134 //function : DrawOn
135 //purpose : 
136 //=======================================================================
137 void TestTopOpeDraw_DrawableC2D::DrawOn(Draw_Display& dis) const
138 {
139   DrawTrSurf_Curve2d::DrawOn(dis);
140   myText2D->DrawOn(dis);
141 }
142
143 //=======================================================================
144 //function : Name
145 //purpose  : 
146 //=======================================================================
147
148 void TestTopOpeDraw_DrawableC2D::Name(const Standard_CString N) 
149 {
150   char* temp = new char[2];
151   temp[0] = ' ' ;
152   temp[1] = 0;  
153   strcat(temp, N);
154   Draw_Drawable3D::Name(temp);
155   ChangeText(temp);
156 }