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 |
61 | extern Draw_Viewer dout; |
62 | #else |
63 | Standard_IMPORT Draw_Viewer dout; |
64 | #endif |
65 | //======================================================================= |
66 | //function : DDataStd_PNT |
67 | //purpose : SetPoint (DF, entry, x, y, z) |
68 | //======================================================================= |
69 | |
70 | static 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); |
79 | Standard_Real x = atof(arg[3]); |
80 | Standard_Real y = atof(arg[4]); |
81 | Standard_Real z = atof(arg[5]); |
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 | } |
88 | |
89 | |
90 | |
91 | //======================================================================= |
92 | //function : DDataStd_DrawStdDriver |
93 | //purpose : DrawStdDriver |
94 | //======================================================================= |
95 | // Unused : |
96 | #ifdef DEB |
97 | static Standard_Integer DDataStd_DrawStdDriver (Draw_Interpretor& /*di*/, |
98 | Standard_Integer /*nb*/, |
99 | const char** /*arg*/) |
100 | { |
101 | DDataStd_DrawDriver::Set(new DDataStd_DrawDriver()); |
102 | return 0; |
103 | } |
104 | #endif |
105 | |
106 | //======================================================================= |
107 | //function : DDataStd_Rmdraw |
108 | //purpose : Rmdraw (name) |
109 | //======================================================================= |
110 | |
111 | static Standard_Integer DDataStd_Rmdraw (Draw_Interpretor& di, |
112 | Standard_Integer nb, |
113 | const char** arg) |
114 | { |
115 | if (nb == 2) { |
116 | Handle(Draw_Drawable3D) D3D; |
117 | D3D = Draw::Get(arg[1],Standard_True); |
118 | if (!D3D.IsNull()) dout.RemoveDrawable(D3D); |
119 | return 0; |
120 | } |
121 | di << "DDataStd_Rmdraw : Error : not done" << "\n"; |
122 | return 1; |
123 | } |
124 | |
125 | //======================================================================= |
126 | //function : DDataStd_DrawOwner |
127 | //purpose : DrawOwner (drawable) |
128 | //======================================================================= |
129 | |
130 | static Standard_Integer DDataStd_DrawOwner (Draw_Interpretor& di, |
131 | Standard_Integer nb, |
132 | const char** arg) |
133 | { |
134 | if (nb == 2) { |
135 | Handle(Draw_Drawable3D) D = Draw::Get(arg[1]); |
136 | if (!D.IsNull()) { |
137 | TCollection_AsciiString entry; |
138 | TCollection_AsciiString name (D->Name()); |
139 | Standard_Integer index = name.Search("_0:"); |
140 | if (index > 0) { |
141 | entry = name.Split(index); |
142 | name.Remove(index); |
143 | di << entry.ToCString(); |
144 | } |
145 | else di << name.ToCString(); |
146 | } |
147 | else di << 0; |
148 | return 0; |
149 | } |
150 | di << "DDataStd_DrawOwner : Error" << "\n"; |
151 | return 1; |
152 | } |
153 | |
154 | //======================================================================= |
155 | //function : DDataStd_DrawDisplay |
156 | //purpose : DDisplay (DOC,entry) |
157 | //======================================================================= |
158 | |
159 | static Standard_Integer DDataStd_DrawDisplay (Draw_Interpretor& di, |
160 | Standard_Integer nb, |
161 | const char** arg) |
162 | { |
163 | if (nb == 3) { |
164 | Handle(TDF_Data) DF; |
165 | if (!DDF::GetDF(arg[1],DF)) return 1; |
166 | TDF_Label L; |
167 | if (!DDF::FindLabel(DF,arg[2],L)) return 1; |
168 | DDataStd_DrawPresentation::Display(L); |
169 | return 0; |
170 | } |
171 | di << "DDataStd_DrawDisplay : Error" << "\n"; |
172 | return 1; |
173 | } |
174 | |
175 | // //======================================================================= |
176 | // //function : DDataStd_DrawRedisplay |
177 | // //purpose : DrawRedisplay (DOC,entry) |
178 | // //======================================================================= |
179 | |
180 | // static Standard_Integer DDataStd_DrawRedisplay (Draw_Interpretor&, |
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::Display(L,Standard_True); |
190 | // return 0; |
191 | // } |
192 | // cout << "DDataStd_DrawRedisplay : Error" << endl; |
193 | // return 1; |
194 | // } |
195 | |
196 | |
197 | //======================================================================= |
198 | //function : DDataStd_DrawErase |
199 | //purpose : DrawErase (DOC,entry) |
200 | //======================================================================= |
201 | |
202 | static Standard_Integer DDataStd_DrawErase (Draw_Interpretor& di, |
203 | Standard_Integer nb, |
204 | const char** arg) |
205 | { |
206 | if (nb == 3) { |
207 | Handle(TDF_Data) DF; |
208 | if (!DDF::GetDF(arg[1],DF)) return 1; |
209 | TDF_Label L; |
210 | if (!DDF::FindLabel(DF,arg[2],L)) return 1; |
211 | DDataStd_DrawPresentation::Erase(L); |
212 | return 0; |
213 | } |
214 | di << "DDataStd_DrawErase : Error" << "\n"; |
215 | return 1; |
216 | } |
217 | |
218 | //======================================================================= |
219 | //function : DDataStd_DrawUpdate |
220 | //purpose : DrawUpdate (DOC,entry) |
221 | //======================================================================= |
222 | |
223 | static Standard_Integer DDataStd_DrawUpdate (Draw_Interpretor& di, |
224 | Standard_Integer nb, |
225 | const char** arg) |
226 | { |
227 | if (nb == 3) { |
228 | Handle(TDF_Data) DF; |
229 | if (!DDF::GetDF(arg[1],DF)) return 1; |
230 | TDF_Label L; |
231 | if (!DDF::FindLabel(DF,arg[2],L)) return 1; |
232 | DDataStd_DrawPresentation::Update(L); |
233 | return 0; |
234 | } |
235 | di << "DDataStd_DrawUpdate : Error" << "\n"; |
236 | return 1; |
237 | } |
238 | |
239 | //======================================================================= |
240 | //function : DDataStd_DrawRepaint |
241 | //purpose : |
242 | //======================================================================= |
243 | |
244 | static Standard_Integer DDataStd_DrawRepaint (Draw_Interpretor& /*di*/, |
245 | Standard_Integer /*nb*/, |
246 | const char** /*arg*/) |
247 | { |
248 | dout.Repaint3D(); |
249 | dout.Flush(); |
250 | return 0; |
251 | } |
252 | |
253 | |
254 | //======================================================================= |
255 | //function : DrawDisplayCommands |
256 | //purpose : |
257 | //======================================================================= |
258 | |
259 | |
260 | void DDataStd::DrawDisplayCommands (Draw_Interpretor& theCommands) |
261 | { |
262 | |
263 | static Standard_Boolean done = Standard_False; |
264 | if (done) return; |
265 | done = Standard_True; |
266 | const char* g = "SKETCH commands" ; |
267 | |
268 | |
269 | theCommands.Add ("PNT", |
270 | "PNT (DF, entry, x, y, z)", |
271 | __FILE__, DDataStd_PNT, g); |
272 | |
273 | |
274 | // remove drawable |
275 | |
276 | |
277 | theCommands.Add ("rmdraw", |
278 | "rmdraw(name)", |
279 | __FILE__, DDataStd_Rmdraw, g); |
280 | |
281 | |
282 | // rtetrieve a label from a drawable |
283 | |
284 | |
285 | theCommands.Add ("DrawOwner", |
286 | "DrawOwner (drawable)", |
287 | __FILE__, DDataStd_DrawOwner, g); |
288 | |
289 | // draw display |
290 | |
291 | |
292 | theCommands.Add ("DrawDisplay", |
293 | "DrawDisplay (DF, entry)", |
294 | __FILE__, DDataStd_DrawDisplay, g); |
295 | |
296 | theCommands.Add ("DrawErase", |
297 | "DrawErase (DF, entry)", |
298 | __FILE__, DDataStd_DrawErase, g); |
299 | |
300 | theCommands.Add ("DrawUpdate", |
301 | "DrawUpdate (DF, entry)", |
302 | __FILE__, DDataStd_DrawUpdate, g); |
303 | |
304 | theCommands.Add ("DrawRepaint", |
305 | "update the draw viewer", |
306 | __FILE__, DDataStd_DrawRepaint, g); |
307 | } |
308 | |
309 | |
310 | |
311 | |
312 | |
313 | |
314 | |
315 | |
316 | |
317 | |
318 | |