0029915: Porting to VC 2017 : Regressions in Modeling Algorithms on VC 2017
[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
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
d5f74e42 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
973c2be1 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.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
7fd59977 16
17#include <DDataStd.hxx>
18#include <DDF.hxx>
19#include <Draw.hxx>
20#include <Draw_Drawable3D.hxx>
21#include <Draw_Appli.hxx>
22#include <Draw_Interpretor.hxx>
23#include <Draw_Viewer.hxx>
24#include <Draw_ColorKind.hxx>
25#include <TCollection_AsciiString.hxx>
26#include <gp_Trsf.hxx>
27#include <gp_Pnt.hxx>
28#include <gp_Lin.hxx>
29#include <gp_Pln.hxx>
30#include <Precision.hxx>
31#include <TopAbs.hxx>
32#include <TopoDS.hxx>
33#include <TopoDS_Face.hxx>
34#include <TopoDS_Vertex.hxx>
35#include <TopAbs.hxx>
7fd59977 36#include <TDF_AttributeList.hxx>
37#include <TDF_ListIteratorOfAttributeList.hxx>
38#include <TNaming_Tool.hxx>
39#include <TDF_ChildIterator.hxx>
40#include <TDF_LabelList.hxx>
41#include <TDF_ListIteratorOfLabelList.hxx>
42#include <TDF_Tool.hxx>
43#include <TNaming_NamedShape.hxx>
44#include <TDataXtd_Point.hxx>
45#include <TDataXtd_Axis.hxx>
46#include <TDataXtd_Geometry.hxx>
47#include <TDataXtd_Constraint.hxx>
48#include <ElSLib.hxx>
49#include <TopoDS_Edge.hxx>
50#include <TopoDS_Compound.hxx>
51
52#include <DDataStd_DrawPresentation.hxx>
53#include <DDataStd_DrawDriver.hxx>
54
57c28b61 55#ifndef _WIN32
7fd59977 56extern Draw_Viewer dout;
57#else
58Standard_IMPORT Draw_Viewer dout;
59#endif
60//=======================================================================
61//function : DDataStd_PNT
62//purpose : SetPoint (DF, entry, x, y, z)
63//=======================================================================
64
65static Standard_Integer DDataStd_PNT (Draw_Interpretor& di,
66 Standard_Integer nb,
67 const char** arg)
68{
69 if (nb == 6) {
70 Handle(TDF_Data) DF;
71 if (!DDF::GetDF (arg[1], DF)) return 1;
72 TDF_Label L;
73 DDF::AddLabel (DF, arg[2], L);
91322f44 74 Standard_Real x = Draw::Atof(arg[3]);
75 Standard_Real y = Draw::Atof(arg[4]);
76 Standard_Real z = Draw::Atof(arg[5]);
7fd59977 77 TDataXtd_Point::Set (L,gp_Pnt(x,y,z));
78 return 0;
79 }
586db386 80 di << "DDataStd_PNT : Error : not done\n";
7fd59977 81 return 1;
82}
7fd59977 83
84//=======================================================================
85//function : DDataStd_Rmdraw
86//purpose : Rmdraw (name)
87//=======================================================================
88
89static Standard_Integer DDataStd_Rmdraw (Draw_Interpretor& di,
90 Standard_Integer nb,
91 const char** arg)
92{
93 if (nb == 2) {
94 Handle(Draw_Drawable3D) D3D;
95 D3D = Draw::Get(arg[1],Standard_True);
96 if (!D3D.IsNull()) dout.RemoveDrawable(D3D);
97 return 0;
98 }
586db386 99 di << "DDataStd_Rmdraw : Error : not done\n";
7fd59977 100 return 1;
101}
102
103//=======================================================================
104//function : DDataStd_DrawOwner
105//purpose : DrawOwner (drawable)
106//=======================================================================
107
108static Standard_Integer DDataStd_DrawOwner (Draw_Interpretor& di,
109 Standard_Integer nb,
110 const char** arg)
111{
112 if (nb == 2) {
113 Handle(Draw_Drawable3D) D = Draw::Get(arg[1]);
114 if (!D.IsNull()) {
115 TCollection_AsciiString entry;
116 TCollection_AsciiString name (D->Name());
117 Standard_Integer index = name.Search("_0:");
118 if (index > 0) {
119 entry = name.Split(index);
120 name.Remove(index);
121 di << entry.ToCString();
122 }
123 else di << name.ToCString();
124 }
125 else di << 0;
126 return 0;
127 }
586db386 128 di << "DDataStd_DrawOwner : Error\n";
7fd59977 129 return 1;
130}
131
132//=======================================================================
133//function : DDataStd_DrawDisplay
134//purpose : DDisplay (DOC,entry)
135//=======================================================================
136
137static Standard_Integer DDataStd_DrawDisplay (Draw_Interpretor& di,
138 Standard_Integer nb,
139 const char** arg)
140{
141 if (nb == 3) {
142 Handle(TDF_Data) DF;
143 if (!DDF::GetDF(arg[1],DF)) return 1;
144 TDF_Label L;
145 if (!DDF::FindLabel(DF,arg[2],L)) return 1;
146 DDataStd_DrawPresentation::Display(L);
147 return 0;
148 }
586db386 149 di << "DDataStd_DrawDisplay : Error\n";
7fd59977 150 return 1;
151}
152
153// //=======================================================================
154// //function : DDataStd_DrawRedisplay
155// //purpose : DrawRedisplay (DOC,entry)
156// //=======================================================================
157
158// static Standard_Integer DDataStd_DrawRedisplay (Draw_Interpretor&,
159// Standard_Integer nb,
160// const char** arg)
161// {
162// if (nb == 3) {
163// Handle(TDF_Data) DF;
164// if (!DDF::GetDF(arg[1],DF)) return 1;
165// TDF_Label L;
166// if (!DDF::FindLabel(DF,arg[2],L)) return 1;
167// DDataStd_DrawPresentation::Display(L,Standard_True);
168// return 0;
169// }
170// cout << "DDataStd_DrawRedisplay : Error" << endl;
171// return 1;
172// }
173
174
175//=======================================================================
176//function : DDataStd_DrawErase
177//purpose : DrawErase (DOC,entry)
178//=======================================================================
179
180static Standard_Integer DDataStd_DrawErase (Draw_Interpretor& di,
181 Standard_Integer nb,
182 const char** arg)
183{
184 if (nb == 3) {
185 Handle(TDF_Data) DF;
186 if (!DDF::GetDF(arg[1],DF)) return 1;
187 TDF_Label L;
188 if (!DDF::FindLabel(DF,arg[2],L)) return 1;
189 DDataStd_DrawPresentation::Erase(L);
190 return 0;
191 }
586db386 192 di << "DDataStd_DrawErase : Error\n";
7fd59977 193 return 1;
194}
195
196//=======================================================================
197//function : DDataStd_DrawUpdate
198//purpose : DrawUpdate (DOC,entry)
199//=======================================================================
200
201static Standard_Integer DDataStd_DrawUpdate (Draw_Interpretor& di,
202 Standard_Integer nb,
203 const char** arg)
204{
205 if (nb == 3) {
206 Handle(TDF_Data) DF;
207 if (!DDF::GetDF(arg[1],DF)) return 1;
208 TDF_Label L;
209 if (!DDF::FindLabel(DF,arg[2],L)) return 1;
210 DDataStd_DrawPresentation::Update(L);
211 return 0;
212 }
586db386 213 di << "DDataStd_DrawUpdate : Error\n";
7fd59977 214 return 1;
215}
216
217//=======================================================================
218//function : DDataStd_DrawRepaint
219//purpose :
220//=======================================================================
221
222static Standard_Integer DDataStd_DrawRepaint (Draw_Interpretor& /*di*/,
223 Standard_Integer /*nb*/,
224 const char** /*arg*/)
225{
226 dout.Repaint3D();
227 dout.Flush();
228 return 0;
229}
230
231
232//=======================================================================
233//function : DrawDisplayCommands
234//purpose :
235//=======================================================================
236
237
238void DDataStd::DrawDisplayCommands (Draw_Interpretor& theCommands)
239{
240
241 static Standard_Boolean done = Standard_False;
242 if (done) return;
243 done = Standard_True;
244 const char* g = "SKETCH commands" ;
245
246
247 theCommands.Add ("PNT",
248 "PNT (DF, entry, x, y, z)",
249 __FILE__, DDataStd_PNT, g);
250
251
252 // remove drawable
253
254
255 theCommands.Add ("rmdraw",
256 "rmdraw(name)",
257 __FILE__, DDataStd_Rmdraw, g);
258
259
260 // rtetrieve a label from a drawable
261
262
263 theCommands.Add ("DrawOwner",
264 "DrawOwner (drawable)",
265 __FILE__, DDataStd_DrawOwner, g);
266
267 // draw display
268
269
270 theCommands.Add ("DrawDisplay",
271 "DrawDisplay (DF, entry)",
272 __FILE__, DDataStd_DrawDisplay, g);
273
274 theCommands.Add ("DrawErase",
275 "DrawErase (DF, entry)",
276 __FILE__, DDataStd_DrawErase, g);
277
278 theCommands.Add ("DrawUpdate",
279 "DrawUpdate (DF, entry)",
280 __FILE__, DDataStd_DrawUpdate, g);
281
282 theCommands.Add ("DrawRepaint",
283 "update the draw viewer",
284 __FILE__, DDataStd_DrawRepaint, g);
285}
286
287
288
289
290
291
292
293
294
295
296