0024096: Eliminate compiler warning C4505 in MSVC++ with warning level 4
[occt.git] / src / DDataStd / DDataStd_DrawDisplayCommands.cxx
CommitLineData
b311480e 1// Created on: 1998-02-12
2// Created by: Denis PASCAL
3// Copyright (c) 1998-1999 Matra Datavision
4// Copyright (c) 1999-2012 OPEN CASCADE SAS
5//
6// The content of this file is subject to the Open CASCADE Technology Public
7// License Version 6.5 (the "License"). You may not use the content of this file
8// except in compliance with the License. Please obtain a copy of the License
9// at http://www.opencascade.org and read it completely before using this file.
10//
11// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13//
14// The Original Code and all software distributed under the License is
15// distributed on an "AS IS" basis, without warranty of any kind, and the
16// Initial Developer hereby disclaims all such warranties, including without
17// limitation, any warranties of merchantability, fitness for a particular
18// purpose or non-infringement. Please see the License for the specific terms
19// and conditions governing the rights and limitations under the License.
20
7fd59977 21
22#include <DDataStd.hxx>
23#include <DDF.hxx>
24#include <Draw.hxx>
25#include <Draw_Drawable3D.hxx>
26#include <Draw_Appli.hxx>
27#include <Draw_Interpretor.hxx>
28#include <Draw_Viewer.hxx>
29#include <Draw_ColorKind.hxx>
30#include <TCollection_AsciiString.hxx>
31#include <gp_Trsf.hxx>
32#include <gp_Pnt.hxx>
33#include <gp_Lin.hxx>
34#include <gp_Pln.hxx>
35#include <Precision.hxx>
36#include <TopAbs.hxx>
37#include <TopoDS.hxx>
38#include <TopoDS_Face.hxx>
39#include <TopoDS_Vertex.hxx>
40#include <TopAbs.hxx>
7fd59977 41#include <TDF_AttributeList.hxx>
42#include <TDF_ListIteratorOfAttributeList.hxx>
43#include <TNaming_Tool.hxx>
44#include <TDF_ChildIterator.hxx>
45#include <TDF_LabelList.hxx>
46#include <TDF_ListIteratorOfLabelList.hxx>
47#include <TDF_Tool.hxx>
48#include <TNaming_NamedShape.hxx>
49#include <TDataXtd_Point.hxx>
50#include <TDataXtd_Axis.hxx>
51#include <TDataXtd_Geometry.hxx>
52#include <TDataXtd_Constraint.hxx>
53#include <ElSLib.hxx>
54#include <TopoDS_Edge.hxx>
55#include <TopoDS_Compound.hxx>
56
57#include <DDataStd_DrawPresentation.hxx>
58#include <DDataStd_DrawDriver.hxx>
59
60#ifndef WNT
61extern Draw_Viewer dout;
62#else
63Standard_IMPORT Draw_Viewer dout;
64#endif
65//=======================================================================
66//function : DDataStd_PNT
67//purpose : SetPoint (DF, entry, x, y, z)
68//=======================================================================
69
70static Standard_Integer DDataStd_PNT (Draw_Interpretor& di,
71 Standard_Integer nb,
72 const char** arg)
73{
74 if (nb == 6) {
75 Handle(TDF_Data) DF;
76 if (!DDF::GetDF (arg[1], DF)) return 1;
77 TDF_Label L;
78 DDF::AddLabel (DF, arg[2], L);
91322f44 79 Standard_Real x = Draw::Atof(arg[3]);
80 Standard_Real y = Draw::Atof(arg[4]);
81 Standard_Real z = Draw::Atof(arg[5]);
7fd59977 82 TDataXtd_Point::Set (L,gp_Pnt(x,y,z));
83 return 0;
84 }
85 di << "DDataStd_PNT : Error : not done" << "\n";
86 return 1;
87}
7fd59977 88
89//=======================================================================
90//function : DDataStd_Rmdraw
91//purpose : Rmdraw (name)
92//=======================================================================
93
94static Standard_Integer DDataStd_Rmdraw (Draw_Interpretor& di,
95 Standard_Integer nb,
96 const char** arg)
97{
98 if (nb == 2) {
99 Handle(Draw_Drawable3D) D3D;
100 D3D = Draw::Get(arg[1],Standard_True);
101 if (!D3D.IsNull()) dout.RemoveDrawable(D3D);
102 return 0;
103 }
104 di << "DDataStd_Rmdraw : Error : not done" << "\n";
105 return 1;
106}
107
108//=======================================================================
109//function : DDataStd_DrawOwner
110//purpose : DrawOwner (drawable)
111//=======================================================================
112
113static Standard_Integer DDataStd_DrawOwner (Draw_Interpretor& di,
114 Standard_Integer nb,
115 const char** arg)
116{
117 if (nb == 2) {
118 Handle(Draw_Drawable3D) D = Draw::Get(arg[1]);
119 if (!D.IsNull()) {
120 TCollection_AsciiString entry;
121 TCollection_AsciiString name (D->Name());
122 Standard_Integer index = name.Search("_0:");
123 if (index > 0) {
124 entry = name.Split(index);
125 name.Remove(index);
126 di << entry.ToCString();
127 }
128 else di << name.ToCString();
129 }
130 else di << 0;
131 return 0;
132 }
133 di << "DDataStd_DrawOwner : Error" << "\n";
134 return 1;
135}
136
137//=======================================================================
138//function : DDataStd_DrawDisplay
139//purpose : DDisplay (DOC,entry)
140//=======================================================================
141
142static Standard_Integer DDataStd_DrawDisplay (Draw_Interpretor& di,
143 Standard_Integer nb,
144 const char** arg)
145{
146 if (nb == 3) {
147 Handle(TDF_Data) DF;
148 if (!DDF::GetDF(arg[1],DF)) return 1;
149 TDF_Label L;
150 if (!DDF::FindLabel(DF,arg[2],L)) return 1;
151 DDataStd_DrawPresentation::Display(L);
152 return 0;
153 }
154 di << "DDataStd_DrawDisplay : Error" << "\n";
155 return 1;
156}
157
158// //=======================================================================
159// //function : DDataStd_DrawRedisplay
160// //purpose : DrawRedisplay (DOC,entry)
161// //=======================================================================
162
163// static Standard_Integer DDataStd_DrawRedisplay (Draw_Interpretor&,
164// Standard_Integer nb,
165// const char** arg)
166// {
167// if (nb == 3) {
168// Handle(TDF_Data) DF;
169// if (!DDF::GetDF(arg[1],DF)) return 1;
170// TDF_Label L;
171// if (!DDF::FindLabel(DF,arg[2],L)) return 1;
172// DDataStd_DrawPresentation::Display(L,Standard_True);
173// return 0;
174// }
175// cout << "DDataStd_DrawRedisplay : Error" << endl;
176// return 1;
177// }
178
179
180//=======================================================================
181//function : DDataStd_DrawErase
182//purpose : DrawErase (DOC,entry)
183//=======================================================================
184
185static Standard_Integer DDataStd_DrawErase (Draw_Interpretor& di,
186 Standard_Integer nb,
187 const char** arg)
188{
189 if (nb == 3) {
190 Handle(TDF_Data) DF;
191 if (!DDF::GetDF(arg[1],DF)) return 1;
192 TDF_Label L;
193 if (!DDF::FindLabel(DF,arg[2],L)) return 1;
194 DDataStd_DrawPresentation::Erase(L);
195 return 0;
196 }
197 di << "DDataStd_DrawErase : Error" << "\n";
198 return 1;
199}
200
201//=======================================================================
202//function : DDataStd_DrawUpdate
203//purpose : DrawUpdate (DOC,entry)
204//=======================================================================
205
206static Standard_Integer DDataStd_DrawUpdate (Draw_Interpretor& di,
207 Standard_Integer nb,
208 const char** arg)
209{
210 if (nb == 3) {
211 Handle(TDF_Data) DF;
212 if (!DDF::GetDF(arg[1],DF)) return 1;
213 TDF_Label L;
214 if (!DDF::FindLabel(DF,arg[2],L)) return 1;
215 DDataStd_DrawPresentation::Update(L);
216 return 0;
217 }
218 di << "DDataStd_DrawUpdate : Error" << "\n";
219 return 1;
220}
221
222//=======================================================================
223//function : DDataStd_DrawRepaint
224//purpose :
225//=======================================================================
226
227static Standard_Integer DDataStd_DrawRepaint (Draw_Interpretor& /*di*/,
228 Standard_Integer /*nb*/,
229 const char** /*arg*/)
230{
231 dout.Repaint3D();
232 dout.Flush();
233 return 0;
234}
235
236
237//=======================================================================
238//function : DrawDisplayCommands
239//purpose :
240//=======================================================================
241
242
243void DDataStd::DrawDisplayCommands (Draw_Interpretor& theCommands)
244{
245
246 static Standard_Boolean done = Standard_False;
247 if (done) return;
248 done = Standard_True;
249 const char* g = "SKETCH commands" ;
250
251
252 theCommands.Add ("PNT",
253 "PNT (DF, entry, x, y, z)",
254 __FILE__, DDataStd_PNT, g);
255
256
257 // remove drawable
258
259
260 theCommands.Add ("rmdraw",
261 "rmdraw(name)",
262 __FILE__, DDataStd_Rmdraw, g);
263
264
265 // rtetrieve a label from a drawable
266
267
268 theCommands.Add ("DrawOwner",
269 "DrawOwner (drawable)",
270 __FILE__, DDataStd_DrawOwner, g);
271
272 // draw display
273
274
275 theCommands.Add ("DrawDisplay",
276 "DrawDisplay (DF, entry)",
277 __FILE__, DDataStd_DrawDisplay, g);
278
279 theCommands.Add ("DrawErase",
280 "DrawErase (DF, entry)",
281 __FILE__, DDataStd_DrawErase, g);
282
283 theCommands.Add ("DrawUpdate",
284 "DrawUpdate (DF, entry)",
285 __FILE__, DDataStd_DrawUpdate, g);
286
287 theCommands.Add ("DrawRepaint",
288 "update the draw viewer",
289 __FILE__, DDataStd_DrawRepaint, g);
290}
291
292
293
294
295
296
297
298
299
300
301