1 // Created on: 1998-02-12
2 // Created by: Denis PASCAL
3 // Copyright (c) 1998-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #include <DDataStd.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>
30 #include <Precision.hxx>
33 #include <TopoDS_Face.hxx>
34 #include <TopoDS_Vertex.hxx>
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>
49 #include <TopoDS_Edge.hxx>
50 #include <TopoDS_Compound.hxx>
52 #include <DDataStd_DrawPresentation.hxx>
53 #include <DDataStd_DrawDriver.hxx>
56 extern Draw_Viewer dout;
58 Standard_IMPORT Draw_Viewer dout;
60 //=======================================================================
61 //function : DDataStd_PNT
62 //purpose : SetPoint (DF, entry, x, y, z)
63 //=======================================================================
65 static Standard_Integer DDataStd_PNT (Draw_Interpretor& di,
71 if (!DDF::GetDF (arg[1], DF)) return 1;
73 DDF::AddLabel (DF, arg[2], L);
74 Standard_Real x = Draw::Atof(arg[3]);
75 Standard_Real y = Draw::Atof(arg[4]);
76 Standard_Real z = Draw::Atof(arg[5]);
77 TDataXtd_Point::Set (L,gp_Pnt(x,y,z));
80 di << "DDataStd_PNT : Error : not done\n";
84 //=======================================================================
85 //function : DDataStd_Rmdraw
86 //purpose : Rmdraw (name)
87 //=======================================================================
89 static Standard_Integer DDataStd_Rmdraw (Draw_Interpretor& ,
95 std::cout << "Syntax error: wrong number of arguments\n";
99 if (Handle(Draw_Drawable3D) D3D = Draw::Get (arg[1]))
101 dout.RemoveDrawable (D3D);
106 std::cout << "Syntax error: variable '" << arg[1] << "' not found\n";
111 //=======================================================================
112 //function : DDataStd_DrawOwner
113 //purpose : DrawOwner (drawable)
114 //=======================================================================
116 static Standard_Integer DDataStd_DrawOwner (Draw_Interpretor& di,
121 Handle(Draw_Drawable3D) D = Draw::Get(arg[1]);
123 TCollection_AsciiString entry;
124 TCollection_AsciiString name (D->Name());
125 Standard_Integer index = name.Search("_0:");
127 entry = name.Split(index);
129 di << entry.ToCString();
131 else di << name.ToCString();
136 di << "DDataStd_DrawOwner : Error\n";
140 //=======================================================================
141 //function : DDataStd_DrawDisplay
142 //purpose : DDisplay (DOC,entry)
143 //=======================================================================
145 static Standard_Integer DDataStd_DrawDisplay (Draw_Interpretor& di,
151 if (!DDF::GetDF(arg[1],DF)) return 1;
153 if (!DDF::FindLabel(DF,arg[2],L)) return 1;
154 DDataStd_DrawPresentation::Display(L);
157 di << "DDataStd_DrawDisplay : Error\n";
161 // //=======================================================================
162 // //function : DDataStd_DrawRedisplay
163 // //purpose : DrawRedisplay (DOC,entry)
164 // //=======================================================================
166 // static Standard_Integer DDataStd_DrawRedisplay (Draw_Interpretor&,
167 // Standard_Integer nb,
171 // Handle(TDF_Data) DF;
172 // if (!DDF::GetDF(arg[1],DF)) return 1;
174 // if (!DDF::FindLabel(DF,arg[2],L)) return 1;
175 // DDataStd_DrawPresentation::Display(L,Standard_True);
178 // std::cout << "DDataStd_DrawRedisplay : Error" << std::endl;
183 //=======================================================================
184 //function : DDataStd_DrawErase
185 //purpose : DrawErase (DOC,entry)
186 //=======================================================================
188 static Standard_Integer DDataStd_DrawErase (Draw_Interpretor& di,
194 if (!DDF::GetDF(arg[1],DF)) return 1;
196 if (!DDF::FindLabel(DF,arg[2],L)) return 1;
197 DDataStd_DrawPresentation::Erase(L);
200 di << "DDataStd_DrawErase : Error\n";
204 //=======================================================================
205 //function : DDataStd_DrawUpdate
206 //purpose : DrawUpdate (DOC,entry)
207 //=======================================================================
209 static Standard_Integer DDataStd_DrawUpdate (Draw_Interpretor& di,
215 if (!DDF::GetDF(arg[1],DF)) return 1;
217 if (!DDF::FindLabel(DF,arg[2],L)) return 1;
218 DDataStd_DrawPresentation::Update(L);
221 di << "DDataStd_DrawUpdate : Error\n";
225 //=======================================================================
226 //function : DDataStd_DrawRepaint
228 //=======================================================================
230 static Standard_Integer DDataStd_DrawRepaint (Draw_Interpretor& /*di*/,
231 Standard_Integer /*nb*/,
232 const char** /*arg*/)
240 //=======================================================================
241 //function : DrawDisplayCommands
243 //=======================================================================
246 void DDataStd::DrawDisplayCommands (Draw_Interpretor& theCommands)
249 static Standard_Boolean done = Standard_False;
251 done = Standard_True;
252 const char* g = "SKETCH commands" ;
255 theCommands.Add ("PNT",
256 "PNT (DF, entry, x, y, z)",
257 __FILE__, DDataStd_PNT, g);
263 theCommands.Add ("rmdraw",
265 __FILE__, DDataStd_Rmdraw, g);
268 // rtetrieve a label from a drawable
271 theCommands.Add ("DrawOwner",
272 "DrawOwner (drawable)",
273 __FILE__, DDataStd_DrawOwner, g);
278 theCommands.Add ("DrawDisplay",
279 "DrawDisplay (DF, entry)",
280 __FILE__, DDataStd_DrawDisplay, g);
282 theCommands.Add ("DrawErase",
283 "DrawErase (DF, entry)",
284 __FILE__, DDataStd_DrawErase, g);
286 theCommands.Add ("DrawUpdate",
287 "DrawUpdate (DF, entry)",
288 __FILE__, DDataStd_DrawUpdate, g);
290 theCommands.Add ("DrawRepaint",
291 "update the draw viewer",
292 __FILE__, DDataStd_DrawRepaint, g);