973c2be1 |
1 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
2 | // |
973c2be1 |
3 | // This file is part of Open CASCADE Technology software library. |
b311480e |
4 | // |
d5f74e42 |
5 | // This library is free software; you can redistribute it and/or modify it under |
6 | // the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
7 | // by the Free Software Foundation, with special exception defined in the file |
8 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
9 | // distribution for complete text of the license and disclaimer of any warranty. |
b311480e |
10 | // |
973c2be1 |
11 | // Alternatively, this file may be used under the terms of Open CASCADE |
12 | // commercial license or contractual agreement. |
b311480e |
13 | |
7fd59977 |
14 | |
42cf5bc1 |
15 | #include <IFSelect_IntParam.hxx> |
16 | #include <IFSelect_PacketList.hxx> |
17 | #include <IFSelect_SelectSignature.hxx> |
18 | #include <IFSelect_SessionPilot.hxx> |
7fd59977 |
19 | #include <IFSelect_WorkLibrary.hxx> |
42cf5bc1 |
20 | #include <IFSelect_WorkSession.hxx> |
7fd59977 |
21 | #include <IGESData_IGESEntity.hxx> |
42cf5bc1 |
22 | #include <IGESData_IGESModel.hxx> |
7fd59977 |
23 | #include <IGESData_Protocol.hxx> |
42cf5bc1 |
24 | #include <IGESSelect_Activator.hxx> |
25 | #include <IGESSelect_AddGroup.hxx> |
26 | #include <IGESSelect_AutoCorrect.hxx> |
27 | #include <IGESSelect_ComputeStatus.hxx> |
7fd59977 |
28 | #include <IGESSelect_DispPerDrawing.hxx> |
42cf5bc1 |
29 | #include <IGESSelect_DispPerSingleView.hxx> |
30 | #include <IGESSelect_FloatFormat.hxx> |
31 | #include <IGESSelect_IGESTypeForm.hxx> |
32 | #include <IGESSelect_RebuildDrawings.hxx> |
33 | #include <IGESSelect_RebuildGroups.hxx> |
34 | #include <IGESSelect_SelectBypassGroup.hxx> |
35 | #include <IGESSelect_SelectDrawingFrom.hxx> |
36 | #include <IGESSelect_SelectFromDrawing.hxx> |
37 | #include <IGESSelect_SelectFromSingleView.hxx> |
7fd59977 |
38 | #include <IGESSelect_SelectLevelNumber.hxx> |
39 | #include <IGESSelect_SelectName.hxx> |
7fd59977 |
40 | #include <IGESSelect_SelectSingleViewFrom.hxx> |
42cf5bc1 |
41 | #include <IGESSelect_SelectVisibleStatus.hxx> |
7fd59977 |
42 | #include <IGESSelect_SetGlobalParameter.hxx> |
42cf5bc1 |
43 | #include <IGESSelect_SetVersion5.hxx> |
7fd59977 |
44 | #include <IGESSelect_SplineToBSpline.hxx> |
42cf5bc1 |
45 | #include <IGESSelect_UpdateCreationDate.hxx> |
46 | #include <IGESSelect_UpdateFileName.hxx> |
47 | #include <IGESSelect_UpdateLastChange.hxx> |
48 | #include <IGESSelect_ViewSorter.hxx> |
7fd59977 |
49 | #include <IGESSelect_WorkLibrary.hxx> |
42cf5bc1 |
50 | #include <Interface_EntityIterator.hxx> |
51 | #include <Interface_Macros.hxx> |
52 | #include <Standard_ErrorHandler.hxx> |
53 | #include <Standard_Failure.hxx> |
54 | #include <Standard_Type.hxx> |
55 | #include <TCollection_HAsciiString.hxx> |
56 | #include <TColStd_HSequenceOfTransient.hxx> |
7fd59977 |
57 | |
42cf5bc1 |
58 | #include <stdio.h> |
92efcf78 |
59 | IMPLEMENT_STANDARD_RTTIEXT(IGESSelect_Activator,IFSelect_Activator) |
60 | |
c48e2889 |
61 | static int THE_IGESSelect_Activator_initActivator = 0; |
7fd59977 |
62 | |
c48e2889 |
63 | IGESSelect_Activator::IGESSelect_Activator() |
7fd59977 |
64 | { |
c48e2889 |
65 | if (THE_IGESSelect_Activator_initActivator) |
66 | { |
67 | return; |
68 | } |
69 | THE_IGESSelect_Activator_initActivator = 1; |
7fd59977 |
70 | // Add ( 0,"load"); |
71 | // Add ( 0,"loadiges"); // homonyme |
72 | SetForGroup ("XSTEP-IGES"); |
73 | |
74 | Add ( 5,"listviews"); |
75 | Add ( 6,"listdrawings"); |
76 | Add ( 7,"listsviews"); |
77 | |
78 | AddSet (10,"igestype"); |
79 | AddSet (11,"bypassgroup"); |
80 | AddSet (12,"igesname"); |
81 | AddSet (13,"igesvisible"); |
82 | AddSet (14,"igeslevel"); |
83 | |
84 | AddSet (21,"igesfromdrawing"); |
85 | AddSet (22,"igesfromview"); |
86 | AddSet (23,"igesdrawingfrom"); |
87 | AddSet (24,"igesviewfrom"); |
88 | |
89 | AddSet (31,"igesdispdrawing"); |
90 | AddSet (32,"igesdispview"); |
91 | |
92 | AddSet (40,"floatformat"); |
93 | AddSet (41,"setglobalparam"); |
94 | AddSet (42,"setversion5"); |
95 | AddSet (43,"updatecreationdate"); |
96 | AddSet (44,"updatelastchange"); |
97 | AddSet (45,"updatefilename"); |
98 | |
99 | AddSet (50,"autocorrect"); |
100 | AddSet (51,"computestatus"); |
101 | AddSet (52,"rebuildgroups"); |
102 | AddSet (53,"rebuilddrawings"); |
103 | AddSet (54,"addgroup"); |
104 | |
105 | AddSet (60,"splinetobspline"); |
106 | |
107 | Add (70,"setuseflag"); |
108 | } |
109 | |
110 | |
111 | IFSelect_ReturnStatus IGESSelect_Activator::Do |
112 | (const Standard_Integer number, |
113 | const Handle(IFSelect_SessionPilot)& pilot) |
114 | { |
115 | Standard_Integer argc = pilot->NbWords(); |
116 | const Standard_CString arg1 = pilot->Word(1).ToCString(); |
117 | const Standard_CString arg2 = pilot->Word(2).ToCString(); |
118 | // const Standard_CString arg3 = pilot->Word(3).ToCString(); |
119 | Handle(IFSelect_WorkSession) WS = pilot->Session(); |
120 | |
121 | switch (number) { |
122 | |
123 | case 5 : // **** ListViews (sans tri complementaire) |
124 | case 6 : // **** ListDrawings |
125 | case 7 : { // **** ListS(ingle)Views |
126 | Standard_Integer listmode = 0; |
127 | if (argc == 2 && arg1[0] == '?') argc = -1; |
128 | if (argc < 2) { |
04232180 |
129 | std::cout<<"Ajouter un argument pour avoir :\n"<< |
7fd59977 |
130 | " l : liste resumee"<< |
131 | " c : liste complete par item (mais pas pour remaining)\n"<< |
132 | " r : idem + liste complete remaining\n"<< |
04232180 |
133 | " sur tout le modele. Ajouter nom selection pour lister sur une partie"<<std::endl; |
7fd59977 |
134 | return (argc >= 0 ? IFSelect_RetError : IFSelect_RetVoid); |
135 | } |
136 | if (arg1[0] == 'l') { |
04232180 |
137 | listmode = 0; std::cout<<"Liste resumee"; |
7fd59977 |
138 | } |
139 | else if (arg1[0] == 'c') { |
04232180 |
140 | listmode = 1; std::cout<<"Liste complete par item (pas pour Remaining)"<<std::endl; |
7fd59977 |
141 | } |
142 | else if (arg1[0] == 'r') { |
04232180 |
143 | listmode = 2; std::cout<<"Liste complete par item et pour Remaining"<<std::endl; |
7fd59977 |
144 | } |
145 | else { |
04232180 |
146 | std::cout<<"Parametre de listage non compris"<<std::endl; return IFSelect_RetError; |
7fd59977 |
147 | } |
148 | |
149 | Handle(IGESSelect_ViewSorter) vs = new IGESSelect_ViewSorter; |
150 | vs->SetModel(GetCasted(IGESData_IGESModel,WS->Model())); |
151 | if (argc == 2) vs->AddModel(WS->Model()); |
152 | else { |
153 | // on demande une selection |
154 | DeclareAndCast(IFSelect_Selection,sel,WS->NamedItem(arg2)); |
155 | if (sel.IsNull()) { |
04232180 |
156 | std::cout<<"Pas une selection : "<<arg2<<std::endl; |
7fd59977 |
157 | return IFSelect_RetError; |
158 | } |
159 | vs->AddList (WS->SelectionResult(sel)); |
160 | } |
161 | Standard_Boolean listdr = (number > 5); |
162 | if (number == 6) vs->SortDrawings(WS->Graph()); |
163 | if (number == 7) vs->SortSingleViews(Standard_True); |
164 | Handle(IFSelect_PacketList) sets = vs->Sets(listdr); |
165 | Standard_Integer nb = vs->NbSets(listdr); |
04232180 |
166 | std::cout<<" -- ViewSorter for"; |
167 | if (number == 5) std::cout<<" Views & Drawings"; |
168 | if (number == 6) std::cout<<" Drawings only (complete)"; |
169 | if (number == 7) std::cout<<" Single Views & Drawing Frames"; |
170 | std::cout<<", on "<<vs->NbEntities()<<" ent.s, give "<<nb<<" Sets"<<std::endl; |
7fd59977 |
171 | |
172 | Interface_EntityIterator iter; |
173 | for (Standard_Integer i = 1; i <= nb; i ++) { |
04232180 |
174 | std::cout<<" -- Set n0 "<<i<<" Item=entity n0: "<< |
7fd59977 |
175 | WS->Model()->Number(vs->SetItem(i,listdr))<<" List:"; |
04232180 |
176 | std::cout<<sets->NbEntities(i)<<" ent.s:"<<std::endl; |
7fd59977 |
177 | if (listmode == 0) continue; |
178 | iter = sets->Entities(i); |
179 | WS->ListEntities (iter,0); |
180 | } |
181 | |
04232180 |
182 | std::cout <<" -- Remaining Entities (not yet sorted) :" |
183 | <<sets->NbDuplicated(0,Standard_False)<<std::endl; |
7fd59977 |
184 | if (listmode < 2) return IFSelect_RetVoid; |
185 | iter = sets->Duplicated(0,Standard_False); |
186 | WS->ListEntities(iter,0); |
187 | return IFSelect_RetVoid; |
188 | } |
189 | |
190 | case 10 : { // **** IGESType (form Type/Form) |
191 | if (argc < 2) { |
04232180 |
192 | std::cout<<"Donner le n0 de type desire, + en option la forme\n" |
193 | <<" Si pas de forme, prend toutes les formes du type demande"<<std::endl; |
7fd59977 |
194 | return IFSelect_RetError; |
195 | } |
196 | char signature[20]; |
197 | if (argc == 2) sprintf(signature,"%s",arg1); |
198 | else sprintf(signature,"%s %s",arg1,arg2); |
199 | Handle(IFSelect_SelectSignature) sel = new IFSelect_SelectSignature |
200 | (new IGESSelect_IGESTypeForm, signature,(argc > 2)); |
201 | return pilot->RecordItem (sel); |
202 | } |
203 | |
204 | case 11 : { // **** IGES BypassGroup |
205 | return pilot->RecordItem (new IGESSelect_SelectBypassGroup); |
206 | } |
207 | |
208 | case 12 : { // **** IGES Name |
209 | if (argc < 2) { |
04232180 |
210 | std::cout<<"Donner un Nom de TextParam pour IGESName"<<std::endl; |
7fd59977 |
211 | return IFSelect_RetError; |
212 | } |
213 | Handle(IGESSelect_SelectName) sel = new IGESSelect_SelectName; |
214 | sel->SetName |
215 | (GetCasted(TCollection_HAsciiString,WS->NamedItem(arg1)) ); |
216 | return pilot->RecordItem (sel); |
217 | } |
218 | |
219 | case 13 : { // **** IGES VisibleStatus |
220 | return pilot->RecordItem (new IGESSelect_SelectVisibleStatus); |
221 | } |
222 | |
223 | case 14 : { // **** IGES LevelNumber |
224 | if (argc < 2) { |
04232180 |
225 | std::cout<<"Donner nom IntParam pour Level"<<std::endl; |
7fd59977 |
226 | return IFSelect_RetError; |
227 | } |
228 | DeclareAndCast(IFSelect_IntParam,lev,WS->NamedItem(arg1)); |
229 | if (lev.IsNull()) { |
04232180 |
230 | std::cout<<arg1<<" : pas un IntParam (pour Level)"<<std::endl; |
7fd59977 |
231 | return IFSelect_RetError; |
232 | } |
233 | Handle(IGESSelect_SelectLevelNumber) sel = new IGESSelect_SelectLevelNumber; |
234 | sel->SetLevelNumber(lev); |
235 | return pilot->RecordItem (sel); |
236 | } |
237 | |
238 | case 21 : { // **** IGES FromDrawing |
239 | return pilot->RecordItem (new IGESSelect_SelectFromDrawing); |
240 | } |
241 | case 22 : { // **** IGES FromSingleView |
242 | return pilot->RecordItem (new IGESSelect_SelectFromSingleView); |
243 | } |
244 | case 23 : { // **** IGES FromDrawing |
245 | return pilot->RecordItem (new IGESSelect_SelectDrawingFrom); |
246 | } |
247 | case 24 : { // **** IGES FromDrawing |
248 | return pilot->RecordItem (new IGESSelect_SelectSingleViewFrom); |
249 | } |
250 | |
251 | case 31 : { // **** IGES DispatchPerDrawing |
252 | return pilot->RecordItem (new IGESSelect_DispPerDrawing); |
253 | } |
254 | case 32 : { // **** IGES DispatchPerSingleView |
255 | return pilot->RecordItem (new IGESSelect_DispPerSingleView); |
256 | } |
257 | |
258 | case 40 : { // **** FloatFormat |
259 | char prem = ' '; |
260 | if (argc < 2) prem = '?'; |
261 | else if (argc == 5) { |
04232180 |
262 | std::cout<<"floatformat tout court donne les formes admises"<<std::endl; |
7fd59977 |
263 | return IFSelect_RetError; |
264 | } |
265 | else prem = arg1[0]; |
266 | Standard_Boolean zerosup=Standard_False; |
267 | Standard_Integer digits = 0; |
268 | if (prem == 'N' || prem == 'n') zerosup = Standard_False; |
269 | else if (prem == 'Z' || prem == 'z') zerosup = Standard_True; |
270 | else if (prem >= 48 && prem <= 57) digits = atoi(arg1); |
271 | else { |
04232180 |
272 | std::cout<<"floatformat digits, digits=nb de chiffres signifiants, ou\n" |
7fd59977 |
273 | << "floatformat NZ %mainformat [%rangeformat [Rmin Rmax]]\n" |
274 | <<" NZ : N ou n pour Non-zero-suppress, Z ou z pour zero-suppress\n" |
275 | <<" %mainformat : format principal type printf, ex,: %E\n" |
276 | <<" + optionnel : format secondaire (flottants autour de 1.) :\n" |
277 | <<" %rangeformat Rmin Rmax : format type printf entre Rmin et Rmax\n" |
278 | <<" %rangeformat tout seul : format type printf entre 0.1 et 1000.\n" |
04232180 |
279 | <<std::flush; |
7fd59977 |
280 | return (prem == '?' ? IFSelect_RetVoid : IFSelect_RetError); |
281 | } |
282 | Standard_Real Rmin=0., Rmax=0.; |
283 | if (argc > 4) { |
91322f44 |
284 | Rmin = Atof(pilot->Word(4).ToCString()); |
285 | Rmax = Atof(pilot->Word(5).ToCString()); |
04232180 |
286 | if (Rmin <= 0 || Rmax <= 0) { std::cout<<"intervalle : donner reels > 0"<<std::endl; return IFSelect_RetError; } |
7fd59977 |
287 | } |
288 | Handle(IGESSelect_FloatFormat) fm = new IGESSelect_FloatFormat; |
289 | if (argc == 2) fm->SetDefault(digits); |
290 | else { |
291 | fm->SetZeroSuppress(zerosup); |
292 | fm->SetFormat (arg2); |
293 | if (argc == 4) fm->SetFormatForRange(pilot->Word(3).ToCString()); |
294 | else if (argc >= 6) fm->SetFormatForRange(pilot->Word(3).ToCString(),Rmin,Rmax); |
295 | else fm->SetFormatForRange(""); |
296 | } |
297 | return pilot->RecordItem(fm); |
298 | } |
299 | |
300 | case 41 : { // **** SetGlobalParameter |
301 | if (argc < 3) { |
04232180 |
302 | std::cout<<"Donner entier=n0 param a changer + nom TextParam pour la valeur"<<std::endl; |
7fd59977 |
303 | return IFSelect_RetError; |
304 | } |
305 | Standard_Integer numpar = atoi(arg1); |
306 | if (numpar <= 0) { |
04232180 |
307 | std::cout<<"Pas un n0 de param global correct:"<<arg1<<std::endl; |
7fd59977 |
308 | return IFSelect_RetError; |
309 | } |
310 | DeclareAndCast(TCollection_HAsciiString,val,WS->NamedItem(arg2)); |
311 | if (val.IsNull()) { |
04232180 |
312 | std::cout<<"Pas un nom de TextParam:"<<arg2<<std::endl; |
7fd59977 |
313 | return IFSelect_RetError; |
314 | } |
315 | Handle(IGESSelect_SetGlobalParameter) mod = |
316 | new IGESSelect_SetGlobalParameter(numpar); |
317 | mod->SetValue(val); |
318 | return pilot->RecordItem (mod); |
319 | } |
320 | |
321 | case 42 : { // **** Set IGES Version 5.1 |
322 | return pilot->RecordItem (new IGESSelect_SetVersion5); |
323 | } |
324 | case 43 : { // **** Update Creation Date |
325 | return pilot->RecordItem (new IGESSelect_UpdateCreationDate); |
326 | } |
327 | case 44 : { // **** Update Last Change Date |
328 | return pilot->RecordItem (new IGESSelect_UpdateLastChange); |
329 | } |
330 | case 45 : { // **** Update File Name |
331 | return pilot->RecordItem (new IGESSelect_UpdateFileName); |
332 | } |
333 | |
334 | case 50 : { // **** AutoCorrect |
335 | return pilot->RecordItem (new IGESSelect_AutoCorrect); |
336 | } |
337 | case 51 : { // **** Compute Status |
338 | return pilot->RecordItem (new IGESSelect_ComputeStatus); |
339 | } |
340 | case 52 : { // **** Rebuild Groups |
341 | return pilot->RecordItem (new IGESSelect_RebuildGroups); |
342 | } |
343 | case 53 : { // **** Rebuild Drawings |
344 | return pilot->RecordItem (new IGESSelect_RebuildDrawings); |
345 | } |
346 | case 54 : { // **** Add Group |
347 | return pilot->RecordItem (new IGESSelect_AddGroup); |
348 | } |
349 | |
350 | case 60 : { // **** Spline To BSpline |
351 | if (argc < 2) { |
04232180 |
352 | std::cout<<"Pour SplineToBSpline, donner mode :\n"<< |
353 | " n pour normal, t pour tryC2"<<std::endl; |
7fd59977 |
354 | return IFSelect_RetError; |
355 | } |
356 | Standard_Boolean tryC2; |
357 | if (arg1[0] == 'n' || arg1[0] == 'N') |
358 | tryC2 = Standard_False; |
359 | else if (arg1[0] == 't' || arg1[0] == 'T') |
360 | tryC2 = Standard_True; |
361 | else { |
04232180 |
362 | std::cout<<" Mode incorrect : "<<arg1<<std::endl; |
7fd59977 |
363 | return IFSelect_RetError; |
364 | } |
365 | Handle(IGESSelect_SplineToBSpline) conv = |
366 | new IGESSelect_SplineToBSpline (tryC2); |
367 | return pilot->RecordItem(conv); |
368 | } |
369 | |
370 | case 70 : { // **** SetUseFlag |
371 | Standard_Integer usefl = atoi (arg1); |
372 | if (argc > 2) { |
373 | Handle(TColStd_HSequenceOfTransient) list = WS->GiveList(pilot->CommandPart(2)); |
374 | Standard_Integer i, nb = list->Length(); |
375 | for (i = 1; i <= nb; i ++) { |
376 | DeclareAndCast(IGESData_IGESEntity,ent,list->Value(i)); |
377 | if (!ent.IsNull()) ent->InitStatus |
378 | (ent->BlankStatus(),ent->SubordinateStatus(),usefl,ent->HierarchyStatus()); |
379 | } |
380 | } |
381 | else { |
382 | Standard_Integer i, nb = WS->NbStartingEntities(); |
383 | for (i = 1; i <= nb; i ++) { |
384 | DeclareAndCast(IGESData_IGESEntity,ent,WS->StartingEntity(i)); |
385 | if (!ent.IsNull()) ent->InitStatus |
386 | (ent->BlankStatus(),ent->SubordinateStatus(),usefl,ent->HierarchyStatus()); |
387 | } |
388 | } |
389 | return IFSelect_RetDone; |
390 | } |
391 | |
392 | default : break; |
393 | } |
394 | return IFSelect_RetVoid; |
395 | |
396 | } |
397 | |
398 | Standard_CString IGESSelect_Activator::Help |
399 | (const Standard_Integer number) const |
400 | { |
401 | switch (number) { |
402 | case 5 : return "Liste Vues (tous types). Nom selection sinon tout modele"; |
403 | case 6 : return "Liste Drawings. Nom selection sinon tout modele"; |
404 | case 7 : return "Liste Vues SIMPLES. Nom selection sinon tout modele"; |
405 | |
406 | case 10 : return "type:integer [form:integer] : cree Select IGESType"; |
407 | case 11 : return "cree Select Bypass Group"; |
408 | case 12 : return "name:TextParam : cree Select Name (Name/Label)"; |
409 | case 13 : return "cree Select Visible Status (Blank Status = 0 sinon 1)"; |
410 | case 14 : return "level:IntParam : cree Select LevelNumber"; |
411 | |
412 | case 21 : return "cree Select From Drawing"; |
413 | case 22 : return "cree Select From Single View"; |
414 | case 23 : return "cree Select Drawing From, drawing(s) pour une liste d entites"; |
415 | case 24 : return "cree Select View From, views pour une liste d entites"; |
416 | |
417 | case 31 : return "cree Dispatch Per Drawing"; |
418 | case 32 : return "cree Dispatch Per SingleView"; |
419 | |
420 | case 40 : return "options... : cree FloatFormat ... floatformat tout court->help"; |
421 | case 41 : return "numpar:integer value:TextParam : cree Set Global Param"; |
422 | case 42 : return "cree Set Version -> 5.1"; |
423 | case 43 : return "cree Update Creation Date"; |
424 | case 44 : return "cree Update Last Change Date"; |
425 | case 45 : return "cree Update File Name (dynamic)"; |
426 | |
427 | case 50 : return "cree AutoCorrect"; |
428 | case 51 : return "cree Compute Status (in D.E.)"; |
429 | case 52 : return "cree Rebuild Groups"; |
430 | case 53 : return "cree Rebuild Drawings"; |
431 | case 54 : return "cree AddGroup"; |
432 | |
433 | case 60 : return "cree SplineToBSpline Conversion"; |
434 | |
435 | case 70 : return "useflag givelist : Set Use Flag to value"; |
436 | |
437 | default : break; |
438 | } |
439 | return "??"; |
440 | } |