f2945861ef6afa2ab1f3e6088a12703b23aea5c6
[occt.git] / src / IFSelect / IFSelect_Functions.cxx
1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
2 //
3 // This file is part of Open CASCADE Technology software library.
4 //
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
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.
10 //
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
13
14 //#58 rln 28.12.98 Versioning
15
16 #include <IFSelect_Functions.ixx>
17 #include <IFSelect_Act.hxx>
18 #include <IFSelect_SessionPilot.hxx>
19
20 #include <TCollection_AsciiString.hxx>
21 #include <TCollection_HAsciiString.hxx>
22 #include <IFSelect_SignType.hxx>
23 #include <IFSelect_SignatureList.hxx>
24 #include <IFSelect_IntParam.hxx>
25 #include <TColStd_HSequenceOfAsciiString.hxx>
26 #include <TColStd_HSequenceOfHAsciiString.hxx>
27 #include <TColStd_HSequenceOfTransient.hxx>
28 #include <TColStd_MapOfInteger.hxx>
29 #include <Interface_Static.hxx>
30 #include <Interface_EntityIterator.hxx>
31
32 #include <IFSelect_WorkSession.hxx>
33 #include <IFSelect_GeneralModifier.hxx>
34 #include <IFSelect_Modifier.hxx>
35 #include <IFSelect_WorkLibrary.hxx>
36 #include <Interface_InterfaceModel.hxx>
37 #include <IFSelect_SessionFile.hxx>
38 #include <Message_Messenger.hxx>
39 #include <Message.hxx>
40
41 #include <Interface_Category.hxx>
42 #include <Interface_CheckIterator.hxx>
43 #include <IFSelect_CheckCounter.hxx>
44 #include <IFSelect_SignCounter.hxx>
45 #include <IFSelect_GraphCounter.hxx>
46
47 #include <IFSelect_Dispatch.hxx>
48 #include <IFSelect_DispGlobal.hxx>
49 #include <IFSelect_DispPerOne.hxx>
50 #include <IFSelect_DispPerCount.hxx>
51 #include <IFSelect_DispPerFiles.hxx>
52 #include <IFSelect_DispPerSignature.hxx>
53 #include <IFSelect_Selection.hxx>
54 #include <IFSelect_SelectDeduct.hxx>
55 #include <IFSelect_SelectModelEntities.hxx>
56 #include <IFSelect_SelectModelRoots.hxx>
57 #include <IFSelect_SelectEntityNumber.hxx>
58 #include <IFSelect_SelectRoots.hxx>
59 #include <IFSelect_SelectDiff.hxx>
60 #include <IFSelect_SelectUnion.hxx>
61 #include <IFSelect_SelectIntersection.hxx>
62 #include <IFSelect_SelectShared.hxx>
63 #include <IFSelect_SelectRange.hxx>
64 #include <IFSelect_Signature.hxx>
65 #include <IFSelect_SelectSignature.hxx>
66 #include <IFSelect_SelectErrorEntities.hxx>
67 #include <IFSelect_SelectUnknownEntities.hxx>
68 #include <IFSelect_SelectIncorrectEntities.hxx>
69 #include <IFSelect_SelectSharing.hxx>
70 #include <IFSelect_SelectPointed.hxx>
71 #include <IFSelect_SelectSuite.hxx>
72 #include <IFSelect_ModifReorder.hxx>
73 #include <IFSelect_Editor.hxx>
74 #include <IFSelect_EditForm.hxx>
75 #include <IFSelect_ListEditor.hxx>
76
77 #include <Interface_Macros.hxx>
78 #include <Interface_Version.hxx>
79 #include <Interface_MSG.hxx>
80 #include <stdio.h>
81
82
83 //  Decomposition of a file name in its parts : prefix, root, suffix
84
85 static void SplitFileName
86   (const Standard_CString filename,
87    TCollection_AsciiString& prefix,
88    TCollection_AsciiString& fileroot,
89    TCollection_AsciiString& suffix)
90 {
91   Standard_Integer nomdeb, nomfin, nomlon;
92   TCollection_AsciiString resfile (filename);
93   nomlon = resfile.Length();
94   nomdeb = resfile.SearchFromEnd ("/");
95   if (nomdeb <= 0) nomdeb = resfile.SearchFromEnd("\\");  // pour NT
96   if (nomdeb <  0) nomdeb = 0;
97   nomfin = resfile.SearchFromEnd (".");
98   if (nomfin < nomdeb) nomfin = nomlon + 1;
99
100   if (nomdeb > 0) prefix = resfile.SubString (1,nomdeb);
101   fileroot = resfile.SubString(nomdeb+1,nomfin-1);
102   if (nomfin <= nomlon) suffix = resfile.SubString (nomfin,nomlon);
103 }
104
105
106
107 //  Functions definit un certain nombre de commandes
108 //  enregistrees dans le Dictionnaire de Activator (par des Act unitaires)
109 //  Les actions elles-memes sont regroupees en fin de fichier
110
111 //  Les definitions
112
113 static IFSelect_ReturnStatus funstatus
114   (const Handle(IFSelect_SessionPilot)& )
115 {
116 //        ****    Version & cie     ****
117   //#58 rln
118   Handle(Message_Messenger) sout = Message::DefaultMessenger();
119   sout<<"Processor Version : "<<XSTEP_PROCESSOR_VERSION<<endl;
120   sout<<"OL Version        : "<<XSTEP_SYSTEM_VERSION<<endl;
121   sout<<"Configuration     : "<<XSTEP_Config<<endl;
122   sout<<"UL Names          : "<<XSTEP_ULNames<<endl;
123   return IFSelect_RetVoid;
124 }
125
126 static IFSelect_ReturnStatus fun1
127   (const Handle(IFSelect_SessionPilot)& pilot)
128 {
129   Handle(IFSelect_WorkSession) WS = pilot->Session();
130 //        ****    ToggleHandler     ****
131   int hand = !WS->ErrorHandle();
132   Handle(Message_Messenger) sout = Message::DefaultMessenger();
133   if (hand) sout << " --  Mode Catch Error now Active"   <<endl;
134   else      sout << " --  Mode Catch Error now Inactive" <<endl;
135   WS->SetErrorHandle(hand);
136   return IFSelect_RetDone;
137 }
138
139 static IFSelect_ReturnStatus fun2
140   (const Handle(IFSelect_SessionPilot)& pilot)
141 {
142 //        ****    Trace File        ****
143   Standard_Integer argc = pilot->NbWords();
144
145   Handle(Message_Messenger) sout = Message::DefaultMessenger();
146   const Standard_CString arg1 = pilot->Arg(1);
147   if (argc < 2) {
148 //    sout<<" Trace : Level="<<Message_PrinterOStream::Default()->GetTraceLevel();
149   } else if (arg1[1] == '\0' && arg1[0] == '.') {
150     sout<<" Trace -> Standard Output"<<endl;
151 //    Message_PrinterOStream::SetDefault();
152   } else if (arg1[1] == '\0' && (arg1[0] >= '0' && arg1[0] <= '9')) {
153     sout<<" Trace Level : "<<arg1<<endl;
154 //    Message_PrinterOStream::Default()->SetTraceLevel((Message_TraceLevel)atoi(arg1));
155   } else {
156     sout<<" Trace -> Append File : "<<arg1<<endl;
157 //    Message_PrinterOStream::SetDefault (Message_PrinterOStream::Default()->GetTraceLevel(),arg1,Standard_True);
158   }
159   return IFSelect_RetVoid;
160 }
161
162 static IFSelect_ReturnStatus fun3
163   (const Handle(IFSelect_SessionPilot)& pilot)
164 {
165   Handle(IFSelect_WorkSession) WS = pilot->Session();
166   Standard_Integer argc = pilot->NbWords();
167   const Standard_CString arg1 = pilot->Arg(1);
168 //        ****    XRead / Load         ****
169   Handle(Message_Messenger) sout = Message::DefaultMessenger();
170   if (argc < 2) { sout<<"Read/Load : give file name !"<<endl; return IFSelect_RetError; }
171   if (WS->Protocol().IsNull()) { sout<<"Protocol not defined"<<endl; return IFSelect_RetError; }
172   if (WS->WorkLibrary().IsNull()) { sout<<"WorkLibrary not defined"<<endl; return IFSelect_RetError; }
173
174   IFSelect_ReturnStatus status = WS->ReadFile (arg1);
175 // status : 0 OK, 1 erreur lecture, 2 Fail(try/catch),
176 //          -1 fichier non trouve, -2 lecture faite mais resultat vide
177   switch (status) {
178     case IFSelect_RetVoid  : sout<<"file:"<<arg1<<" gives empty result"<<endl; break;
179     case IFSelect_RetError : sout<<"file:"<<arg1<<" could not be opened"<<endl; break;
180     case IFSelect_RetDone  : sout<<"file:"<<arg1<<" read"<<endl; break;
181     case IFSelect_RetFail  : sout<<"file:"<<arg1<<" : error while reading"<<endl; break;
182     case IFSelect_RetStop  : sout<<"file:"<<arg1<<" : EXCEPTION while reading"<<endl; break;
183     default : sout<<"file:"<<arg1<<" could not be read"<<endl; break;
184   }
185   if (status != IFSelect_RetDone) return status;
186 //      sout<<" - clearing list of already written files"<<endl;
187   WS->BeginSentFiles(Standard_True);
188   return status;
189 }
190
191 static IFSelect_ReturnStatus fun_whatfile
192   (const Handle(IFSelect_SessionPilot)& pilot)
193 {
194   TCollection_AsciiString whatcom = IFSelect_Activator::Alias ("whatfile");
195   if (whatcom.Length() > 0) return pilot->ExecuteAlias (whatcom);
196   Handle(Message_Messenger) sout = Message::DefaultMessenger();
197   sout<<"Load File : "<<pilot->Session()->LoadedFile()<<endl;
198   sout<<"No specific whatfile available"<<endl;
199   return IFSelect_RetVoid;
200 }
201
202 static IFSelect_ReturnStatus fun4
203   (const Handle(IFSelect_SessionPilot)& pilot)
204 {
205   Handle(IFSelect_WorkSession) WS = pilot->Session();
206   Standard_Integer argc = pilot->NbWords();
207   const Standard_CString arg1 = pilot->Arg(1);
208 //        ****    Write All         ****
209   Handle(Message_Messenger) sout = Message::DefaultMessenger();
210   if (argc < 2) { sout<<"Write All : give file name !"<<endl; return IFSelect_RetError; }
211   return WS->SendAll (arg1);
212 }
213
214 static IFSelect_ReturnStatus fun5
215   (const Handle(IFSelect_SessionPilot)& pilot)
216 {
217   Handle(IFSelect_WorkSession) WS = pilot->Session();
218   Standard_Integer argc = pilot->NbWords();
219   const Standard_CString arg1 = pilot->Arg(1);
220 //  const Standard_CString arg2 = pilot->Arg(2);
221 //        ****    Write Selected         ****
222   Handle(Message_Messenger) sout = Message::DefaultMessenger();
223   if (argc < 3) { sout<<"Write Selected : give file name + givelist !"<<endl; return IFSelect_RetError; }
224   Handle(TColStd_HSequenceOfTransient) result =
225     IFSelect_Functions::GiveList (WS,pilot->CommandPart( 2));
226   if (result.IsNull()) { sout<<"No entity selected"<<endl; return IFSelect_RetError; }
227   else sout<<"Nb Entities selected : "<<result->Length()<<endl;
228   Handle(IFSelect_SelectPointed) sp = new IFSelect_SelectPointed;
229   sp->SetList (result);
230   return WS->SendSelected (arg1,sp);
231 }
232
233 static IFSelect_ReturnStatus fun6
234   (const Handle(IFSelect_SessionPilot)& pilot)
235 {
236   Handle(IFSelect_WorkSession) WS = pilot->Session();
237   Standard_Integer argc = pilot->NbWords();
238   const Standard_CString arg1 = pilot->Arg(1);
239 //        ****    Write Entite(s)         ****
240   Handle(Message_Messenger) sout = Message::DefaultMessenger();
241   if (argc < 3) { sout<<"Write Entitie(s) : give file name + n0s entitie(s)!"<<endl; return IFSelect_RetError; }
242   int ko = 0;
243   Handle(IFSelect_SelectPointed) sp = new IFSelect_SelectPointed;
244   for (Standard_Integer ia = 2; ia < argc ; ia ++) {
245     Standard_Integer id = pilot->Number(pilot->Arg(ia));
246     if (id > 0) {
247       Handle(Standard_Transient) item = WS->StartingEntity(id);
248       if (sp->Add(item)) sout<<"Added:no."<<id<<endl;
249       else { sout<<" Fail Add n0."<<id<<endl; ko ++; }
250     }
251     else { sout<<"Not an entity number:"<<pilot->Arg(ia)<<endl; ko ++; }
252   }
253   if (ko > 0) { sout<<ko<<" bad arguments, abandon"<<endl; return IFSelect_RetError; }
254   return WS->SendSelected (arg1,sp);
255 }
256
257 static IFSelect_ReturnStatus fun7
258   (const Handle(IFSelect_SessionPilot)& pilot)
259 {
260   Handle(IFSelect_WorkSession) WS = pilot->Session();
261   Standard_Integer argc = pilot->NbWords();
262   const Standard_CString arg1 = pilot->Arg(1);
263 //        ****    Entity Label       ****
264   Handle(Message_Messenger) sout = Message::DefaultMessenger();
265   if (argc < 2) { sout<<"Give entity number"<<endl; return IFSelect_RetError; }
266   if (!WS->HasModel()) { sout<<"No loaded model, abandon"<<endl; return IFSelect_RetError; }
267   Standard_Integer nument = WS->NumberFromLabel (arg1);
268   if (nument <= 0 || nument > WS->NbStartingEntities())
269     { sout<<"Not a suitable number: "<<arg1<<endl;  return IFSelect_RetError; }
270   sout<<"N0."<<nument<<" ->Label in Model : ";
271   WS->Model()->PrintLabel(WS->StartingEntity(nument),sout);  
272   sout<<endl;
273   return IFSelect_RetVoid;
274 }
275
276 static IFSelect_ReturnStatus fun8
277   (const Handle(IFSelect_SessionPilot)& pilot)
278 {
279   Handle(IFSelect_WorkSession) WS = pilot->Session();
280   Standard_Integer argc = pilot->NbWords();
281   const Standard_CString arg1 = pilot->Arg(1);
282 //        ****    Entity Number      ****
283   Handle(Message_Messenger) sout = Message::DefaultMessenger();
284   if (argc < 2) { sout<<"Give label to search"<<endl; return IFSelect_RetError; }
285   if (!WS->HasModel()) { sout<<"No loaded model, abandon"<<endl; return IFSelect_RetError; }
286   Handle(Interface_InterfaceModel) model = WS->Model();
287   Standard_Integer i, cnt = 0;
288   Standard_Boolean exact = Standard_False;
289   sout<<" **  Search Entity Number for Label : "<<arg1<<endl;
290   for (i = model->NextNumberForLabel (arg1, 0, exact)  ; i != 0;
291        i = model->NextNumberForLabel (arg1, i, exact)) {
292     cnt ++;
293     sout<<" **  Found n0/id:"; model->Print (model->Value(i),sout); sout<<endl;
294   }
295   
296   if (cnt == 0) sout<<" **  No Match"<<endl;
297   else if (cnt == 1) sout<<" **  1 Match"<<endl;
298   else sout<<cnt<<" Matches"<<endl;
299   return IFSelect_RetVoid;
300 }
301
302 static IFSelect_ReturnStatus fun9
303   (const Handle(IFSelect_SessionPilot)& pilot)
304 {
305 //        ****    List Types         ****
306   Handle(IFSelect_WorkSession) WS = pilot->Session();
307   Handle(IFSelect_Signature) signtype = WS->SignType();
308   if (signtype.IsNull()) signtype = new IFSelect_SignType;
309   Handle(IFSelect_SignCounter) counter =
310     new IFSelect_SignCounter(signtype,Standard_False);
311   return pilot->ExecuteCounter (counter,1);
312 }
313
314 static IFSelect_ReturnStatus funcount
315   (const Handle(IFSelect_SessionPilot)& pilot)
316 {
317   Handle(IFSelect_WorkSession) WS = pilot->Session();
318   Standard_Integer argc = pilot->NbWords();
319   const Standard_CString arg0 = pilot->Arg(0);
320   const Standard_CString arg1 = pilot->Arg(1);
321   Standard_Boolean listmode = (arg0[0] == 'l');
322 //        ****    List Counter         ****
323
324   Handle(Message_Messenger) sout = Message::DefaultMessenger();
325   if (argc < 2) {
326     sout<<"Designer signature ou compteur, + facultatif selection + facultatif entite"<<endl;
327     sout<<" signature/compteur seul -> tout le modele"<<endl
328       <<  " sign/compteur + selection -> cette selection, evaluation normale"<<endl
329         <<" sign/compteur + sel + num -> cette selection evaluee sur entite n0 num"<<endl;
330     return IFSelect_RetError;
331   }
332   DeclareAndCast(IFSelect_SignCounter,counter,WS->NamedItem(arg1));
333   if (counter.IsNull()) {
334     DeclareAndCast(IFSelect_Signature,signa,WS->NamedItem(arg1));
335     if (!signa.IsNull()) counter = new IFSelect_SignCounter(signa,Standard_False,listmode);
336   }
337 //  Handle(IFSelect_Selection) sel;
338 //  Standard_Integer n3 = 0;  if (argc > 3) n3 = WS->NumberFromLabel(arg3);
339 //  if (argc > 2) sel = GetCasted(IFSelect_Selection,WS->NamedItem(arg2));
340 //  if (counter.IsNull() || (argc > 2 && n3 <= 0 && sel.IsNull()) ) {
341 //    sout<<"Nom:"<<arg1; if (argc > 2) sout<<" et/ou "<<arg2;
342 //    sout<<" incorrect (demande: compteur ou signature [selection])"<<endl;
343 //    return IFSelect_RetError;
344 //  }
345
346 //  Ajout : si Selection, on applique un GraphCounter
347 //   Et en ce cas, on peut en avoir plusieurs : la limite est le mot-cle "on"
348   Standard_Integer onflag = 0;
349   Standard_Integer i; // svv Jan11 2000 : porting on DEC
350   for (i = 2; i < argc; i ++) {
351     if (!strcmp (pilot->Arg(i),"on")) { onflag = i; break; }
352   }
353
354   Handle(IFSelect_Selection) sel = WS->GiveSelection(arg1);
355   DeclareAndCast(IFSelect_SelectDeduct,seld,sel);
356   if (!seld.IsNull()) {
357 //  Si onflag, faire une SelectSuite
358     if (onflag > 2) {
359       Handle(IFSelect_SelectSuite) suite = new IFSelect_SelectSuite;
360       for (i = 1; i < onflag; i ++) {
361         sel = WS->GiveSelection(pilot->Arg(i));
362         if (!suite->AddInput(sel)) {
363           sout<<"Incorrect definition for applied selection"<<endl;
364           return IFSelect_RetError;
365         }
366       }
367       seld = suite;
368     }
369
370     Handle(IFSelect_GraphCounter) gc = new IFSelect_GraphCounter(Standard_False,listmode);
371     gc->SetApplied (seld);
372     counter = gc;
373   }
374
375   if (counter.IsNull()) {
376     sout<<"Neither Counter nor Signature : "<<arg1<<endl;
377     return IFSelect_RetError;
378   }
379
380   if (onflag == 0) onflag = 1;
381   IFSelect_PrintCount pcm = IFSelect_ListByItem;
382   if (arg0[0] == 'c') pcm = IFSelect_CountByItem;
383   if (arg0[0] == 's') pcm = IFSelect_CountSummary;
384   return pilot->ExecuteCounter (counter,onflag+1, pcm);
385 }
386
387 static IFSelect_ReturnStatus funsigntype
388   (const Handle(IFSelect_SessionPilot)& pilot)
389 {
390   Handle(IFSelect_WorkSession) WS = pilot->Session();
391   Standard_Integer argc = pilot->NbWords();
392   const Standard_CString arg1 = pilot->Arg(1);
393 //        ****    Sign Type              ****
394   Handle(IFSelect_Signature) signtype = WS->SignType();
395   Handle(Message_Messenger) sout = Message::DefaultMessenger();
396   if (signtype.IsNull()) sout<<"signtype actually undefined"<<endl;
397   else {
398     Handle(TCollection_HAsciiString) str = WS->Name (signtype);
399     Standard_Integer id = WS->ItemIdent (signtype);
400     sout<<signtype->Label()<<endl;
401     if (str.IsNull()) {
402       if (id > 0) sout<<"signtype : item n0 "<<id<<endl;
403     } else {
404       sout<<"signtype : also named as "<<str->ToCString()<<endl;
405     }
406   }
407   if (argc < 2) sout<<"signtype newitem  to change, signtype . to clear"<<endl;
408   else {
409     if (arg1[0] == '.' && arg1[1] == '\0') {
410       signtype.Nullify();
411       sout<<"signtype now cleared"<<endl;
412     } else {
413       signtype = GetCasted(IFSelect_Signature,WS->NamedItem(arg1));
414       if (signtype.IsNull()) { sout<<"Not a Signature : "<<arg1<<endl; return IFSelect_RetError; }
415       else sout<<"signtype now set to "<<arg1<<endl;
416     }
417     WS->SetSignType(signtype);
418     return IFSelect_RetDone;
419   }
420   return IFSelect_RetVoid;
421 }
422
423 static IFSelect_ReturnStatus funsigncase
424   (const Handle(IFSelect_SessionPilot)& pilot)
425 {
426   Handle(IFSelect_WorkSession) WS = pilot->Session();
427   const Standard_CString arg1 = pilot->Arg(1);
428 //        ****    Sign Case              ****
429   Handle(IFSelect_Signature) signcase = GetCasted(IFSelect_Signature,WS->NamedItem(arg1));
430   Handle(Message_Messenger) sout = Message::DefaultMessenger();
431   if (signcase.IsNull()) sout<<"Not a Signature : "<<arg1<<endl;
432   else {
433     Standard_Boolean hasmin,hasmax;  Standard_Integer valmin,valmax;
434     if (signcase->IsIntCase(hasmin,valmin,hasmax,valmax)) {
435       sout<<"Signature "<<arg1<<" : Integer Case";
436       if (hasmin) sout<<" - Mini:"<<valmin;
437       if (hasmax) sout<<" - Maxi:"<<valmax;
438       sout<<endl;
439     }
440     Handle(TColStd_HSequenceOfAsciiString) caselist = signcase->CaseList();
441     if (caselist.IsNull()) sout<<"Signature "<<arg1<<" : no predefined case, see command  count "<<arg1<<endl;
442     else {
443       Standard_Integer i, nb = caselist->Length();
444       sout<<"Signature "<<arg1<<" : "<<nb<<" basic cases :"<<endl;
445       for (i = 1; i <= nb; i ++) sout<<"  "<<caselist->Value(i);
446       sout<<endl;
447     }
448   }
449   return IFSelect_RetVoid;
450 }
451
452
453 static IFSelect_ReturnStatus fun10
454   (const Handle(IFSelect_SessionPilot)& pilot)
455 {
456   Handle(IFSelect_WorkSession) WS = pilot->Session();
457   Standard_Integer argc = pilot->NbWords();
458   const Standard_CString arg1 = pilot->Arg(1);
459 //        ****    Entity Status          ****
460   Standard_Integer i,nb;
461   Handle(Message_Messenger) sout = Message::DefaultMessenger();
462   if (argc < 2) {
463     nb = Interface_Category::NbCategories();
464     sout<<" Categories defined :"<<nb<<" i.e. :\n";
465     for (i = 0; i <= nb; i ++)
466       sout<<"Cat."<<i<<"  : "<<Interface_Category::Name(i)<<"\n";
467     sout<<" On a given entity : give its number"<<endl;
468     return IFSelect_RetVoid;
469   }
470   Standard_Integer num = pilot->Number(arg1);
471   if (num <= 0 || num > WS->NbStartingEntities())
472     { sout<<"Not a suitable entity number : "<<arg1<<endl; return IFSelect_RetError; }
473   Handle(Standard_Transient) ent = WS->StartingEntity(num);
474   WS->PrintEntityStatus(ent,sout);
475   return IFSelect_RetVoid;
476 }
477
478 static IFSelect_ReturnStatus fun11
479   (const Handle(IFSelect_SessionPilot)& pilot)
480 {
481   Handle(IFSelect_WorkSession) WS = pilot->Session();
482 //  Standard_Integer argc = pilot->NbWords();
483   const Standard_CString arg1 = pilot->Arg(1);
484 //        ****    DumpModel (Data)  ****
485   Standard_Integer niv = 0;
486 //  char arg10 = arg1[0];
487 //  if (argc < 2) arg10 = '?';
488   Handle(Message_Messenger) sout = Message::DefaultMessenger();
489   switch (arg1[0]) {
490     case '?' :
491      sout<<"? for this help, else give a listing mode (first letter suffices) :\n"
492         <<" general    General Statistics\n roots    Roots\n"
493         <<" entities   All Entities\n"
494         <<" listfails  CheckList (fails)    per entity\n"
495         <<" messages   CheckList (complete) per entity\n"
496         <<" fails      CheckList (fails)    per message (counting)\n"
497         <<" check      CheckList (complete) per message (counting)\n"
498         <<" totalcheck CheckList (complete) per message (listing n0 ents)\n"
499         <<" FAILS      CheckList (fails)    per message (listing complete)\n"
500         <<" TOTALCHECK CheckList (complete) per message (listing complete)"<<endl;
501      return IFSelect_RetVoid;
502     case 'g' : niv = 0; break;
503     case 'r' : niv = 1; break;
504     case 'e' : niv = 2; break;
505     case 'l' : niv = 3; break;
506     case 'm' : niv = 4; break;
507     case 'c' : niv = 5; break;
508     case 't' : niv = 6; break;
509     case 'T' : niv = 7; break;
510     case 'f' : niv = 8; break;
511     case 'F' : niv =10; break;
512     default  : sout<<"Unknown Mode .  data tout court pour help"<<endl; return IFSelect_RetError;
513   }
514   WS->TraceDumpModel(niv);
515   return IFSelect_RetVoid;
516 }
517
518 static IFSelect_ReturnStatus fundumpent
519   (const Handle(IFSelect_SessionPilot)& pilot)
520 {
521   Handle(IFSelect_WorkSession) WS = pilot->Session();
522   Standard_Integer argc = pilot->NbWords();
523   Handle(IFSelect_WorkLibrary) WL = WS->WorkLibrary();
524   Standard_Integer levdef=0,levmax=10,level;
525   WL->DumpLevels (levdef,levmax);
526   Handle(Message_Messenger) sout = Message::DefaultMessenger();
527   if (argc < 2 || (argc == 2 && levmax < 0)) {
528     sout<<"Give n0 or id of entity";
529     if (levmax < 0) sout<<"  and dump level"<<endl;
530     else sout<<"  + optinal, dump level in [0 - "<<levmax<<"] , default = "<<levdef<<endl;
531     for (level = 0; level <= levmax; level ++) {
532       Standard_CString help = WL->DumpHelp (level);
533       if (help[0] != '\0') sout<<level<<" : "<<help<<endl;
534     }
535     return IFSelect_RetError;
536   }
537
538   const Standard_CString arg1 = pilot->Arg(1);
539   const Standard_CString arg2 = pilot->Arg(2);
540   Standard_Integer num = pilot->Number(arg1);
541   if (num == 0) return IFSelect_RetError;
542   level = levdef;
543   if (argc > 2) level = atoi(arg2);
544   Handle(Standard_Transient) ent = WS->StartingEntity(num);
545   if ( ent.IsNull() ) {
546     sout << "No entity with given id " << arg1 << " (" << num << ") is found in the current model" << endl;
547   }
548   else {
549     sout << "  --   DUMP  Entity n0 " << num << "  level " << level << endl;
550     WL->DumpEntity (WS->Model(),WS->Protocol(),ent,sout,level);
551
552     Interface_CheckIterator chl = WS->CheckOne (ent);
553     if (!chl.IsEmpty(Standard_False)) chl.Print(sout,WS->Model(),Standard_False);
554   }
555 //  sout << flush;
556
557   return IFSelect_RetVoid;
558 }
559
560 static IFSelect_ReturnStatus funsign
561   (const Handle(IFSelect_SessionPilot)& pilot)
562 {
563   Handle(IFSelect_WorkSession) WS = pilot->Session();
564   Standard_Integer argc = pilot->NbWords();
565   const Standard_CString arg1 = pilot->Arg(1);
566   const Standard_CString arg2 = pilot->Arg(2);
567   Handle(Message_Messenger) sout = Message::DefaultMessenger();
568   if (argc < 3) { sout<<" Give signature name + n0 or id of entity"<<endl; return IFSelect_RetError; }
569   DeclareAndCast(IFSelect_Signature,sign,WS->NamedItem(arg1));
570   if (sign.IsNull()) { sout<<"Not a signature : "<<arg1<<endl; return IFSelect_RetError; }
571   Standard_Integer num = pilot->Number(arg2);
572   Handle(Standard_Transient) ent = WS->StartingEntity (num);
573   if (num == 0) return IFSelect_RetError;
574   sout<<"Entity n0 "<<num<<" : "<<WS->SignValue(sign,ent)<<endl;
575   return IFSelect_RetVoid;
576 }
577
578 static IFSelect_ReturnStatus funqp
579   (const Handle(IFSelect_SessionPilot)& pilot)
580 {
581   Handle(IFSelect_WorkSession) WS = pilot->Session();
582   Standard_Integer argc = pilot->NbWords();
583   const Standard_CString arg1 = pilot->Arg(1);
584   const Standard_CString arg2 = pilot->Arg(2);
585   Handle(Message_Messenger) sout = Message::DefaultMessenger();
586   if (argc < 3) { sout<<" Give 2 numeros or labels : dad son"<<endl; return IFSelect_RetError; }
587   Standard_Integer n1 = WS->NumberFromLabel(arg1);
588   Standard_Integer n2 = WS->NumberFromLabel(arg2);
589   sout<<"QueryParent for dad:"<<arg1<<":"<<n1<<" and son:"<<arg2<<":"<<n2<<endl;
590   Standard_Integer qp = WS->QueryParent(WS->StartingEntity(n1),WS->StartingEntity(n2));
591   if (qp < 0) sout<<arg1<<" is not super-entity of "<<arg2<<endl;
592   else if (qp == 0) sout<<arg1<<" is same as "<<arg2<<endl;
593   else sout<<arg1<<" is super-entity of "<<arg2<<" , max level found="<<qp<<endl;
594 //  sout<<" Trouve "<<qp<<endl;
595   return IFSelect_RetVoid;
596 }
597   
598
599 static IFSelect_ReturnStatus fun12
600   (const Handle(IFSelect_SessionPilot)& pilot)
601 {
602   Handle(IFSelect_WorkSession) WS = pilot->Session();
603 //        ****    DumpShare         ****
604   WS->DumpShare();  return IFSelect_RetVoid;
605 }
606
607 static IFSelect_ReturnStatus fun13
608   (const Handle(IFSelect_SessionPilot)& pilot)
609 {
610   Handle(IFSelect_WorkSession) WS = pilot->Session();
611 //        ****    ListItems         ****
612   WS->ListItems(pilot->Arg(1));  return IFSelect_RetVoid;
613 }
614
615 static IFSelect_ReturnStatus fun14
616   (const Handle(IFSelect_SessionPilot)& pilot)
617 {
618   Handle(IFSelect_WorkSession) WS = pilot->Session();
619   Standard_Integer argc = pilot->NbWords();
620   const Standard_CString arg1 = pilot->Arg(1);
621 //        ****    NewInt            ****
622   Handle(Message_Messenger) sout = Message::DefaultMessenger();
623   if (argc < 1) { sout<<"Donner la valeur entiere pour IntParam"<<endl; return IFSelect_RetError; }
624   Handle(IFSelect_IntParam) intpar = new IFSelect_IntParam;
625   if (argc >= 1)       intpar->SetValue(atoi(arg1));
626   return pilot->RecordItem (intpar);
627 }
628
629 static IFSelect_ReturnStatus fun15
630   (const Handle(IFSelect_SessionPilot)& pilot)
631 {
632   Handle(IFSelect_WorkSession) WS = pilot->Session();
633   Standard_Integer argc = pilot->NbWords();
634   const Standard_CString arg1 = pilot->Arg(1);
635   const Standard_CString arg2 = pilot->Arg(2);
636 //        ****    SetInt            ****
637   Handle(Message_Messenger) sout = Message::DefaultMessenger();
638   if (argc < 3)
639     { sout<<"Donner 2 arguments : nom Parametre et Valeur"<<endl; return IFSelect_RetError; }
640   Standard_Integer val = atoi(arg2);
641   DeclareAndCast(IFSelect_IntParam,par,WS->NamedItem(arg1));
642   if (!WS->SetIntValue(par,val)) return IFSelect_RetFail;
643   return IFSelect_RetDone;
644 }
645
646 static IFSelect_ReturnStatus fun16
647   (const Handle(IFSelect_SessionPilot)& pilot)
648 {
649   Handle(IFSelect_WorkSession) WS = pilot->Session();
650   Standard_Integer argc = pilot->NbWords();
651   const Standard_CString arg1 = pilot->Arg(1);
652 //        ****    NewText           ****
653   Handle(Message_Messenger) sout = Message::DefaultMessenger();
654   if (argc < 1) { sout<<"Donner la valeur texte pour TextParam"<<endl; return IFSelect_RetError; }
655   Handle(TCollection_HAsciiString) textpar = new TCollection_HAsciiString();
656   if (argc >= 1) textpar->AssignCat(arg1);
657   return pilot->RecordItem (textpar);
658 }
659
660 static IFSelect_ReturnStatus fun17
661   (const Handle(IFSelect_SessionPilot)& pilot)
662 {
663   Handle(IFSelect_WorkSession) WS = pilot->Session();
664   Standard_Integer argc = pilot->NbWords();
665   const Standard_CString arg1 = pilot->Arg(1);
666   const Standard_CString arg2 = pilot->Arg(2);
667 //        ****    SetText           ****
668   Handle(Message_Messenger) sout = Message::DefaultMessenger();
669   if (argc < 3)
670     { sout<<"Donner 2 arguments : nom Parametre et Valeur"<<endl; return IFSelect_RetError; }
671   DeclareAndCast(TCollection_HAsciiString,par,WS->NamedItem(arg1));
672   if (!WS->SetTextValue(par,arg2)) return IFSelect_RetFail;
673   return IFSelect_RetDone;
674 }
675
676 static IFSelect_ReturnStatus fun19
677   (const Handle(IFSelect_SessionPilot)& pilot)
678 {
679   Handle(IFSelect_WorkSession) WS = pilot->Session();
680   Standard_Integer argc = pilot->NbWords();
681   const Standard_CString arg1 = pilot->Arg(1);
682 //        ****    DumpSel           ****
683   Handle(Message_Messenger) sout = Message::DefaultMessenger();
684   if (argc < 2) { sout<<"Give 1 argument : Selection Name"<<endl; return IFSelect_RetError; }
685   WS->DumpSelection (GetCasted(IFSelect_Selection,WS->NamedItem(arg1)));
686   return IFSelect_RetVoid;
687 }
688
689 static IFSelect_ReturnStatus fun20
690   (const Handle(IFSelect_SessionPilot)& pilot)
691 {
692   Handle(IFSelect_WorkSession) WS = pilot->Session();
693   Standard_Integer argc = pilot->NbWords();
694 //        ****    EvalSel           ****
695 //        ****    GiveList          ****
696 //        ****    GiveShort GivePointed  ****
697 //        ****    MakeList          ****
698   char mode = pilot->Arg(0)[0];  // givelist/makelist
699   if (mode == 'g') mode = pilot->Arg(0)[4];  // l list  s short  p pointed
700   Handle(Message_Messenger) sout = Message::DefaultMessenger();
701   if (argc < 2) { sout<<"Give Entity ID, or Selection Name [+ optional other selection or entity]"<<endl; return IFSelect_RetError; }
702
703 //    MakeList : sur Pointed existante ou a creer
704   Handle(IFSelect_SelectPointed) pnt;
705   if (mode == 'm') {
706     const Standard_CString arg1 = pilot->Arg(1);
707     Handle(Standard_Transient) item = WS->NamedItem (arg1);
708     pnt = GetCasted(IFSelect_SelectPointed,item);
709     if (!pnt.IsNull()) {
710       sout<<arg1<<":Already existing Selection for List, cleared then filled"<<endl;
711       pnt->Clear();
712     } else if (!item.IsNull()) {
713       sout<<arg1<<":Already existing Item not for a List, command ignored"<<endl;
714       return IFSelect_RetFail;
715     } else {
716       pnt = new IFSelect_SelectPointed;
717       WS->AddNamedItem (arg1,pnt);
718     }
719   }
720
721   Handle(TColStd_HSequenceOfTransient) result =
722     IFSelect_Functions::GiveList (WS,pilot->CommandPart( (mode == 'm' ? 2 : 1) ));
723   if (result.IsNull()) return IFSelect_RetError;
724   Interface_EntityIterator iter (result);
725   sout<<pilot->CommandPart( (mode == 'm' ? 2 : 1) )<<" : ";
726   if      (mode == 'l')   WS->ListEntities (iter,0);
727   else if (mode == 's' || mode == 'm') WS->ListEntities (iter,2);
728   else if (mode == 'p') {
729     sout<<iter.NbEntities()<<" Entities : ";
730     for (iter.Start(); iter.More(); iter.Next())
731       sout<<" +"<<WS->StartingNumber (iter.Value());
732     sout<<endl;
733   }
734
735   if (!pnt.IsNull()) {
736     pnt->SetList (result);
737     sout<<"List set to a SelectPointed : "<<pilot->Arg(1)<<endl;
738     sout<<"Later editable by command setlist"<<endl;
739   }
740
741   return IFSelect_RetVoid;
742 }
743
744 static IFSelect_ReturnStatus fun20c
745   (const Handle(IFSelect_SessionPilot)& pilot)
746 {
747   Handle(IFSelect_WorkSession) WS = pilot->Session();
748   Standard_Integer argc = pilot->NbWords();
749 //        ****    GiveCount         ****
750   Handle(Message_Messenger) sout = Message::DefaultMessenger();
751   if (argc < 2) { sout<<"Give Entity ID, or Selection Name [+ optional other selection or entity]"<<endl; return IFSelect_RetError; }
752 //  WS->EvaluateSelection(GetCasted(IFSelect_Selection,WS->NamedItem(arg1)));
753   Handle(TColStd_HSequenceOfTransient) result =
754     IFSelect_Functions::GiveList (WS,pilot->CommandPart(1));
755   if (result.IsNull()) return IFSelect_RetError;
756   sout<<pilot->CommandPart(1)<<" : List of "<<result->Length()<<" Entities"<<endl;
757   return IFSelect_RetVoid;
758 }
759
760 static IFSelect_ReturnStatus funselsuite
761   (const Handle(IFSelect_SessionPilot)& pilot)
762 {
763   Handle(IFSelect_WorkSession) WS = pilot->Session();
764   Standard_Integer argc = pilot->NbWords();
765 //        ****    SelSuite         ****
766   Handle(Message_Messenger) sout = Message::DefaultMessenger();
767   if (argc < 2) { sout<<"Give Entity ID, or Selection Name [+ optional other selection or entity]"<<endl; return IFSelect_RetError; }
768 //  WS->EvaluateSelection(GetCasted(IFSelect_Selection,WS->NamedItem(arg1)));
769   Handle(IFSelect_SelectSuite) selsuite = new IFSelect_SelectSuite;
770
771   for (Standard_Integer i = 1; i < argc; i ++) {
772     Handle(IFSelect_Selection) sel = WS->GiveSelection(pilot->Arg(i));
773     if (!selsuite->AddInput(sel)) {
774       sout<<pilot->Arg(i-1)<<" : not a SelectDeduct, no more can be added. Abandon"<<endl;
775       return IFSelect_RetError;
776     }
777   }
778   selsuite->SetLabel (pilot->CommandPart(1));
779   return pilot->RecordItem (selsuite);
780 }
781
782
783 static IFSelect_ReturnStatus fun21
784   (const Handle(IFSelect_SessionPilot)& pilot)
785 {
786   Handle(IFSelect_WorkSession) WS = pilot->Session();
787 //        ****    ClearItems           ****
788   WS->ClearItems();  WS->ClearFinalModifiers();  WS->ClearShareOut(Standard_False);
789   return IFSelect_RetDone;
790 }
791
792 static IFSelect_ReturnStatus fun22
793   (const Handle(IFSelect_SessionPilot)& pilot)
794 {
795   Handle(IFSelect_WorkSession) WS = pilot->Session();
796   Standard_Integer argc = pilot->NbWords();
797   const Standard_CString arg1 = pilot->Arg(1);
798 //        ****    ClearData           ****
799   Standard_Integer mode = -1;
800   if (argc >= 2) {
801     if (arg1[0] == 'a') mode = 1;
802     if (arg1[0] == 'g') mode = 2;
803     if (arg1[0] == 'c') mode = 3;
804     if (arg1[0] == 'p') mode = 4;
805     if (arg1[0] == '?') mode = -1;
806   }
807   else mode = 0;
808   Handle(Message_Messenger) sout = Message::DefaultMessenger();
809   if (mode <= 0) {
810     if (mode < 0) sout<<"Give a suitable mode";
811     sout<<"  Available Modes :\n"
812       <<" a : all data    g : graph+check  c : check  p : selectpointed"<<endl;
813     return (mode < 0 ? IFSelect_RetError : IFSelect_RetVoid);
814   }
815   WS->ClearData (mode);
816   return IFSelect_RetDone;
817 }
818
819 static IFSelect_ReturnStatus fun24
820   (const Handle(IFSelect_SessionPilot)& pilot)
821 {
822   Handle(IFSelect_WorkSession) WS = pilot->Session();
823   Standard_Integer argc = pilot->NbWords();
824 //        ****    Item Label         ****
825   Handle(Message_Messenger) sout = Message::DefaultMessenger();
826   TCollection_AsciiString label;
827   if (argc < 2) { sout<<" Give  label to search"<<endl;  return IFSelect_RetError;  }
828   for (int i = 1; i < argc; i ++) {
829     label.AssignCat(pilot->Arg(i));
830     if (i < argc-1) label.AssignCat(" ");
831   }
832   for (int mode = 0; mode <= 2; mode ++) {
833     int nbitems = 0;  int id;
834     sout<<"Searching label : "<<label<<". in mode ";
835     if (mode == 0) sout <<" exact" << endl;
836     if (mode == 1) sout <<" same head" << endl;
837     if (mode == 2) sout <<" search if present" << endl;
838     for (id = WS->NextIdentForLabel(label.ToCString(), 0,mode)  ; id != 0;
839          id = WS->NextIdentForLabel(label.ToCString(),id,mode)) {
840       sout<<" "<<id;  nbitems ++;
841     }
842     sout<<" -- giving " << nbitems << " found" << endl;
843   }
844   return IFSelect_RetVoid;
845 }
846
847 static IFSelect_ReturnStatus fun25
848   (const Handle(IFSelect_SessionPilot)& pilot)
849 {
850   Handle(IFSelect_WorkSession) WS = pilot->Session();
851   Standard_Integer argc = pilot->NbWords();
852   const Standard_CString arg1 = pilot->Arg(1);
853 //        ****    Save (Dump)       ****
854   Handle(Message_Messenger) sout = Message::DefaultMessenger();
855   if (argc < 2) { sout<<"Donner nom du Fichier"<<endl; return IFSelect_RetError; }
856   IFSelect_SessionFile dumper(WS,arg1);
857   if (!dumper.IsDone()) return IFSelect_RetFail;
858   return IFSelect_RetDone;
859 }
860
861 static IFSelect_ReturnStatus fun26
862   (const Handle(IFSelect_SessionPilot)& pilot)
863 {
864   Handle(IFSelect_WorkSession) WS = pilot->Session();
865   Standard_Integer argc = pilot->NbWords();
866   const Standard_CString arg1 = pilot->Arg(1);
867 //        ****    Restore (Dump)    ****
868   Handle(Message_Messenger) sout = Message::DefaultMessenger();
869   if (argc < 2) { sout<<"Donner nom du Fichier"<<endl; return IFSelect_RetError; }
870   IFSelect_SessionFile dumper(WS);
871   Standard_Integer readstat = dumper.Read(arg1);
872   if      (readstat == 0) return IFSelect_RetDone;
873   else if (readstat >  0) sout << "-- Erreur Lecture Fichier "<<arg1<<endl;
874   else                    sout << "-- Pas pu ouvrir Fichier "<<arg1<<endl;
875   return IFSelect_RetDone;
876 }
877
878 static IFSelect_ReturnStatus fun27
879   (const Handle(IFSelect_SessionPilot)& pilot)
880 {
881   Standard_Integer argc = pilot->NbWords();
882   Handle(IFSelect_WorkSession) WS = pilot->Session();
883   const Standard_CString arg1 = pilot->Arg(1);
884   const Standard_CString arg2 = pilot->Arg(2);
885 //        ****    Param(Value)         ****
886   Handle(Message_Messenger) sout = Message::DefaultMessenger();
887   if (argc < 2) {
888     Handle(TColStd_HSequenceOfHAsciiString) li = Interface_Static::Items();
889     Standard_Integer i,nb = li->Length();
890     sout<<" List of parameters : "<<nb<<" items : "<<endl;
891     for (i = 1; i <= nb; i ++) {
892       sout<<li->Value(i);
893       sout<<" : "<<Interface_Static::CVal(li->Value(i)->ToCString())<<endl;
894     }
895     return IFSelect_RetVoid;
896   } else if (atoi(arg1) > 0) {
897     Standard_Integer use = atoi (arg1);
898     WS->TraceStatics (use);
899   } else {
900     if (argc > 2) sout<<"     FORMER STATUS of Static Parameter "<<arg1<<endl;
901     else          sout<<"     ACTUAL STATUS of Static Parameter "<<arg1<<endl;
902     if (!Interface_Static::IsPresent(arg1)) { sout<<" Parameter "<<arg1<<" undefined"<<endl; return IFSelect_RetError; }
903     if (!Interface_Static::IsSet(arg1)) sout<<" Parameter "<<arg1<<" not valued"<<endl;
904     else if (argc == 2) Interface_Static::Static (arg1) -> Print(sout);
905     else sout<<" Value : "<<Interface_Static::CVal(arg1)<<endl;
906
907     if (argc == 2) sout<<"To modify, param name_param new_val"<<endl;
908     else {
909       sout<<" New demanded value : "<<arg2;
910       if (Interface_Static::SetCVal (arg1,arg2))
911         {  sout<<"   OK"<<endl;  return IFSelect_RetDone;  }
912       else  {  sout <<" , refused"<<endl;  return IFSelect_RetError;  }
913     }
914   }
915   return IFSelect_RetVoid;
916 }
917
918 static IFSelect_ReturnStatus fun28
919   (const Handle(IFSelect_SessionPilot)& pilot)
920 {
921   Standard_Integer argc = pilot->NbWords();
922   const Standard_CString arg1 = pilot->Arg(1);
923   const Standard_CString arg2 = pilot->Arg(2);
924   const Standard_CString arg3 = pilot->Arg(3);
925 //        ****    DefParam         ****
926   Handle(Message_Messenger) sout = Message::DefaultMessenger();
927   if (argc < 2) {
928     Handle(TColStd_HSequenceOfHAsciiString) li = Interface_Static::Items();
929     Standard_Integer i,nb = li->Length();
930     sout<<" List of parameters : "<<nb<<" items :"<<endl;
931     for (i = 1; i <= nb; i ++) sout<<"  "<<li->Value(i)->ToCString();
932     sout<<endl<<"  defparam name_param  to known more about one"<<endl;
933     sout<<"  defparam nom_param e options  to edit a definition"<<endl;
934
935   } else if (argc == 2) {
936     sout<<" Definition of Parameter : "<<arg1<<endl;
937     Handle(Interface_Static) unst = Interface_Static::Static (arg1);
938     if (unst.IsNull()) sout<<"  undefined"<<endl;
939     else unst->Print(sout);
940     return IFSelect_RetVoid;
941
942   } else if (arg2[0] == 'i') {
943 //  initialisation : arg1=nompar  a2='i'  a3=family  a4=type  [a5=val]
944     if (argc < 5) { sout<<" name init family type [valinit]"<<endl; return IFSelect_RetVoid; }
945     char typ = (pilot->Arg(4))[0];
946     Standard_Boolean ok= (argc==5 ? Interface_Static::Init(arg3,arg1,typ) :
947                           Interface_Static::Init(arg3,arg1,typ,pilot->Arg(5)));
948     return (ok ? IFSelect_RetDone : IFSelect_RetFail);
949
950   } else if (arg2[0] == 'e') {
951 //  edition : arg1=nompar  arg2='e' arg3=option  arg4...=parametres option
952     char comm[100];
953     if (argc < 4) {
954       sout<<" give name and options !  Options (according type), 1 a time\n"
955           <<" imin ival / imax ival / rmin rval / rmax rval /\n"
956           <<" enum stnum / enum stnum match / eval e1 e2 e3 ... (maxi 10)\n"
957           <<endl;
958       return IFSelect_RetVoid;
959     }
960     if (argc > 4) sout<<"Only the command and ONE more arg are considered"<<endl;
961     sprintf(comm,"%s %s",pilot->Arg(3),pilot->Arg(4));
962     sout<<"Editing parameter : "<<arg1<<" , by command : "<<comm<<endl;
963
964     Handle(Interface_Static) unst = Interface_Static::Static (arg1);
965     if (unst.IsNull()) { sout<<arg1<<"  undefined"<<endl; return IFSelect_RetError; }
966     if (Interface_Static::Init(unst->Family(),arg1,'&',comm))
967       {  sout<<"Editing done"<<endl;  return IFSelect_RetDone;  }
968     else  {  sout<<"Command not processed : "<<comm<<endl; return IFSelect_RetFail;  }
969   }
970   sout<<"Unknown Option : "<<arg2<<endl;
971   return IFSelect_RetVoid;
972 }
973
974 static IFSelect_ReturnStatus fun29
975   (const Handle(IFSelect_SessionPilot)& pilot)
976 {
977   Handle(IFSelect_WorkSession) WS = pilot->Session();
978 //        ****    SentFiles         ****
979   Handle(TColStd_HSequenceOfHAsciiString) list = WS->SentFiles();
980   Handle(Message_Messenger) sout = Message::DefaultMessenger();
981   if (list.IsNull())
982     { sout<<"List of Sent Files not enabled"<<endl; return IFSelect_RetVoid; }
983   Standard_Integer i, nb = list->Length();
984   sout<<"  Sent Files : "<<nb<<" : "<<endl;
985   for (i = 1; i <= nb; i ++)
986     sout<<list->Value(i)->ToCString()<<endl; 
987   return IFSelect_RetVoid;
988 }
989
990 static IFSelect_ReturnStatus fun30
991   (const Handle(IFSelect_SessionPilot)& pilot)
992 {
993   Handle(IFSelect_WorkSession) WS = pilot->Session();
994   Standard_Integer argc = pilot->NbWords();
995   const Standard_CString arg1 = pilot->Arg(1);
996 //        ****    FilePrefix        ****
997   Handle(Message_Messenger) sout = Message::DefaultMessenger();
998   if (argc < 2) {
999     if (WS->FilePrefix().IsNull()) sout<<"Pas de prefixe defini"<<endl;
1000     else sout<<"Prefixe : "<<WS->FilePrefix()->ToCString()<<endl;
1001     sout<<"Pour changer :  filepref newprefix"<<endl;
1002     return IFSelect_RetVoid;
1003   }
1004   WS->SetFilePrefix(arg1);
1005   return IFSelect_RetDone;
1006 }
1007
1008 static IFSelect_ReturnStatus fun31
1009   (const Handle(IFSelect_SessionPilot)& pilot)
1010 {
1011   Handle(IFSelect_WorkSession) WS = pilot->Session();
1012   Standard_Integer argc = pilot->NbWords();
1013   const Standard_CString arg1 = pilot->Arg(1);
1014 //        ****    FileExtension     ****
1015   Handle(Message_Messenger) sout = Message::DefaultMessenger();
1016   if (argc < 2) {
1017     if (WS->FileExtension().IsNull()) sout<<"Pas d extension definie"<<endl;
1018     else sout<<"Extension : "<<WS->FileExtension()->ToCString()<<endl;
1019     sout<<"Pour changer :  fileext newext"<<endl;
1020     return IFSelect_RetVoid;
1021   }
1022   WS->SetFileExtension(arg1);
1023   return IFSelect_RetDone;
1024 }
1025
1026 static IFSelect_ReturnStatus fun32
1027   (const Handle(IFSelect_SessionPilot)& pilot)
1028 {
1029   Handle(IFSelect_WorkSession) WS = pilot->Session();
1030   Standard_Integer argc = pilot->NbWords();
1031   const Standard_CString arg1 = pilot->Arg(1);
1032   const Standard_CString arg2 = pilot->Arg(2);
1033 //        ****    FileRoot          ****
1034   Handle(Message_Messenger) sout = Message::DefaultMessenger();
1035   if (argc < 2) { sout<<"Donner Dispatch et nom de Root"<<endl; return IFSelect_RetError; }
1036   DeclareAndCast(IFSelect_Dispatch,disp,WS->NamedItem(arg1));
1037   if (argc < 3) {
1038     if (WS->FileRoot(disp).IsNull()) sout<<"Pas de racine definie pour "<<arg1<<endl;
1039     else sout<<"Racine pour "<<arg1<<" : "<<WS->FileRoot(disp)->ToCString()<<endl;
1040     sout<<"Pour changer :  fileroot nomdisp newroot"<<endl;
1041     return IFSelect_RetVoid;
1042   }
1043   if (!WS->SetFileRoot(disp,arg2)) return IFSelect_RetFail;
1044   return IFSelect_RetDone;
1045 }
1046
1047 static IFSelect_ReturnStatus fun33
1048   (const Handle(IFSelect_SessionPilot)& pilot)
1049 {
1050   Handle(IFSelect_WorkSession) WS = pilot->Session();
1051   Standard_Integer argc = pilot->NbWords();
1052   const Standard_CString arg1 = pilot->Arg(1);
1053 //        ****    Default File Root     ****
1054   Handle(Message_Messenger) sout = Message::DefaultMessenger();
1055   if (argc < 2) {
1056     if (WS->DefaultFileRoot().IsNull()) sout<<"Pas de racine par defaut definie"<<endl;
1057     else sout<<"Racine par defaut : "<<WS->DefaultFileRoot()->ToCString()<<endl;
1058     sout<<"Pour changer :  filedef newdef"<<endl;
1059     return IFSelect_RetVoid;
1060   }
1061   WS->SetDefaultFileRoot(arg1);
1062   return IFSelect_RetDone;
1063 }
1064
1065 static IFSelect_ReturnStatus fun34
1066   (const Handle(IFSelect_SessionPilot)& pilot)
1067 {
1068   Handle(IFSelect_WorkSession) WS = pilot->Session();
1069 //        ****    EvalFile          ****
1070   Handle(Message_Messenger) sout = Message::DefaultMessenger();
1071   if (!WS->HasModel()) 
1072     {  sout<<"Pas de Modele charge, abandon"<<endl;  return IFSelect_RetFail; }
1073
1074   sout<<"Evaluation avec Memorisation des resultats"<<endl;
1075   WS->EvaluateFile();
1076   Standard_Integer nbf = WS->NbFiles();
1077   for (Standard_Integer i = 1; i <= nbf; i ++) {
1078     Handle(Interface_InterfaceModel) mod = WS->FileModel(i);
1079     if (mod.IsNull())
1080       {  sout<<"Modele "<<i<<" Model non genere ..."<<endl; continue;  }
1081     TCollection_AsciiString name = WS->FileName(i);
1082     sout<<"Fichier n0 "<<i<<" Nb Entites : "<<mod->NbEntities()<<"  Nom: ";
1083     sout<<name<<endl;
1084   }
1085   return IFSelect_RetDone;
1086 }
1087
1088 static IFSelect_ReturnStatus fun35
1089   (const Handle(IFSelect_SessionPilot)& pilot)
1090 {
1091   Handle(IFSelect_WorkSession) WS = pilot->Session();
1092 //        ****    ClearFile          ****
1093   WS->ClearFile();  return IFSelect_RetDone;
1094 }
1095
1096 static IFSelect_ReturnStatus fun36
1097   (const Handle(IFSelect_SessionPilot)& pilot)
1098 {
1099   Handle(IFSelect_WorkSession) WS = pilot->Session();
1100   Standard_Integer argc = pilot->NbWords();
1101 //        ****    Split              ****
1102   Handle(Message_Messenger) sout = Message::DefaultMessenger();
1103   IFSelect_ReturnStatus stat = IFSelect_RetVoid;
1104   if (argc < 2) sout<<"Split : derniere liste de dispatches definie"<<endl;
1105   else {
1106     WS->ClearShareOut(Standard_True);
1107     for (Standard_Integer i = 1; i < argc; i ++) {
1108       DeclareAndCast(IFSelect_Dispatch,disp,WS->NamedItem(pilot->Arg(i)));
1109       if (disp.IsNull()) {
1110         sout<<"Pas un dispatch:"<<pilot->Arg(i)<<", Splitt abandonne"<<endl;
1111         stat = IFSelect_RetError;
1112       }
1113       else WS->SetActive(disp,Standard_True);
1114     }
1115   }
1116   if (stat ==  IFSelect_RetError) return stat;
1117   WS->BeginSentFiles(Standard_True);
1118   if (!WS->SendSplit()) return IFSelect_RetFail;
1119   return IFSelect_RetDone;
1120 }
1121
1122 static IFSelect_ReturnStatus fun37
1123   (const Handle(IFSelect_SessionPilot)& pilot)
1124 {
1125   Handle(IFSelect_WorkSession) WS = pilot->Session();
1126   Standard_Integer argc = pilot->NbWords();
1127   const Standard_CString arg1 = pilot->Arg(1);
1128 //        ****    Remaining Data     ****
1129   char mode = '?';  IFSelect_RemainMode numod = IFSelect_RemainDisplay;
1130   if (argc >= 2) mode = arg1[0];
1131   if      (mode == 'u') numod = IFSelect_RemainUndo;
1132   else if (mode == 'l') numod = IFSelect_RemainDisplay;
1133   else if (mode == 'c') numod = IFSelect_RemainCompute;
1134   else if (mode == 'f') numod = IFSelect_RemainForget;
1135   else {
1136     Handle(Message_Messenger) sout = Message::DefaultMessenger();
1137     if (argc<2) sout<<"Donner un Mode - ";
1138     sout<<"Modes possibles : l  list, c compute, u undo, f forget"<<endl;
1139     if (mode == '?') return IFSelect_RetDone;   else return IFSelect_RetError;
1140   }
1141   if (!WS->SetRemaining(numod)) return IFSelect_RetVoid;
1142   return IFSelect_RetDone;
1143 }
1144
1145 static IFSelect_ReturnStatus fun38
1146   (const Handle(IFSelect_SessionPilot)& pilot)
1147 {
1148   Handle(IFSelect_WorkSession) WS = pilot->Session();
1149   Standard_Integer argc = pilot->NbWords();
1150   const Standard_CString arg1 = pilot->Arg(1);
1151   const Standard_CString arg2 = pilot->Arg(2);
1152 //        ****    SetModelContent    ****
1153   Handle(Message_Messenger) sout = Message::DefaultMessenger();
1154   if (argc < 3) { sout<<"Donner nom selection et mode (k=keep,r=remove)"<<endl;  return IFSelect_RetError; }
1155   Standard_Boolean keepmode;
1156   DeclareAndCast(IFSelect_Selection,sel,WS->NamedItem(arg1));
1157   if (sel.IsNull())
1158     { sout<<"Pas de Selection de Nom : "<<arg1<<endl; return IFSelect_RetError; }
1159   if      (arg2[0] == 'k') {  sout<<" -- SetContent keep ..."; keepmode = Standard_True; }
1160   else if (arg2[0] == 'r') {  sout<<" -- SetContent remove ..."; keepmode = Standard_False; }
1161   else { sout<<"Donner nom selection et mode (k=keep,r=remove)"<<endl;  return IFSelect_RetError; }
1162   
1163   if (WS->SetModelContent(sel,keepmode)) sout<<" Done"<<endl;
1164   else sout<<" Result empty, ignored"<<endl;
1165   return IFSelect_RetDone;
1166 }
1167
1168 static IFSelect_ReturnStatus fun40
1169   (const Handle(IFSelect_SessionPilot)& pilot)
1170 {
1171   Handle(IFSelect_WorkSession) WS = pilot->Session();
1172 //        ****    ListModif          ****
1173   WS->ListFinalModifiers(Standard_True);
1174   WS->ListFinalModifiers(Standard_False);  return IFSelect_RetVoid;
1175 }
1176
1177 static IFSelect_ReturnStatus fun41
1178   (const Handle(IFSelect_SessionPilot)& pilot)
1179 {
1180   Handle(IFSelect_WorkSession) WS = pilot->Session();
1181   Standard_Integer argc = pilot->NbWords();
1182   const Standard_CString arg1 = pilot->Arg(1);
1183 //        ****    Modifier           ****
1184   Handle(Message_Messenger) sout = Message::DefaultMessenger();
1185   if (argc < 2) { sout<<"Donner Nom du Modifier"<<endl;  return IFSelect_RetError; }
1186   DeclareAndCast(IFSelect_GeneralModifier,modif,WS->NamedItem(arg1));
1187   if (modif.IsNull())
1188     { sout<<"Pas de Modifier de Nom : "<<arg1<<endl; return IFSelect_RetVoid; }
1189   Handle(IFSelect_IntParam) low,up;
1190
1191   Handle(IFSelect_Dispatch) disp = modif->Dispatch();
1192   sout<<"Modifier : "<<arg1<<" Label : "<<modif->Label()<<endl;
1193   Standard_Integer rank = WS->ModifierRank(modif);
1194   if (modif->IsKind(STANDARD_TYPE(IFSelect_Modifier)))
1195     sout<< "Model Modifier n0." << rank;
1196   else sout<< "File Modifier n0." << rank;
1197   if (disp.IsNull()) sout<<"  Applique a tous les Dispatchs" << endl;
1198   else {
1199     sout << "  Dispatch : "<<disp->Label();
1200     if (WS->HasName(disp)) sout << " - Nom:"<<WS->Name(disp)->ToCString();
1201     sout<<endl;
1202   }
1203
1204   Handle(IFSelect_Selection) sel = modif->Selection();
1205   if (!sel.IsNull()) sout<<"  Selection : "<< sel->Label();
1206   if (WS->HasName(sel)) sout<<" - Nom:"<< WS->Name(sel)->ToCString();
1207   sout<<endl;
1208   return IFSelect_RetVoid;
1209 }
1210
1211 static IFSelect_ReturnStatus fun42
1212   (const Handle(IFSelect_SessionPilot)& pilot)
1213 {
1214   Handle(IFSelect_WorkSession) WS = pilot->Session();
1215   Standard_Integer argc = pilot->NbWords();
1216   const Standard_CString arg1 = pilot->Arg(1);
1217   const Standard_CString arg2 = pilot->Arg(2);
1218 //        ****    ModifSel           ****
1219   Handle(Message_Messenger) sout = Message::DefaultMessenger();
1220   if (argc < 2) { sout<<"Donner Nom Modifier; + Nom Selection optionnel\n"
1221                       <<"Selection pour Mettre une Selection, sinon Annule"<<endl; return IFSelect_RetError; }
1222   DeclareAndCast(IFSelect_GeneralModifier,modif,WS->NamedItem(arg1));
1223   if (modif.IsNull())
1224     { sout<<"Pas un nom de Modifier : "<<arg1<<endl; return IFSelect_RetError;  }
1225   Handle(IFSelect_Selection) sel;
1226   if (arg2[0] != '\0') {
1227     sel = GetCasted(IFSelect_Selection,WS->NamedItem(arg2));
1228     if (sel.IsNull())
1229       { sout<<"Pas un nom de Selection : "<<arg2<<endl;  return IFSelect_RetError;  }
1230   }
1231   if (!WS->SetItemSelection(modif,sel)) return IFSelect_RetFail;
1232   return IFSelect_RetDone;
1233 }
1234
1235 static IFSelect_ReturnStatus fun43
1236   (const Handle(IFSelect_SessionPilot)& pilot)
1237 {
1238   Handle(IFSelect_WorkSession) WS = pilot->Session();
1239   Standard_Integer argc = pilot->NbWords();
1240   const Standard_CString arg1 = pilot->Arg(1);
1241   const Standard_CString arg2 = pilot->Arg(2);
1242 //        ****    SetAppliedModifier           ****
1243   Handle(Message_Messenger) sout = Message::DefaultMessenger();
1244   if (argc < 2) { sout<<"Donner Nom Modifier; + Nom Dispatch ou Transformer optionnel :\n"
1245                       <<" - rien : tous Dispatches\n - Dispatch : ce Dispatch seul\n"
1246                       <<" - Transformer : pas un Dispatch mais un Transformer"<<endl;
1247                   return IFSelect_RetError;  }
1248   DeclareAndCast(IFSelect_GeneralModifier,modif,WS->NamedItem(arg1));
1249   if (modif.IsNull())
1250     { sout<<"Pas un nom de Modifier : "<<arg1<<endl;  return IFSelect_RetError;  }
1251   Handle(Standard_Transient) item;
1252   if (arg2[0] != '\0') {
1253     item = WS->NamedItem(arg2);
1254     if (item.IsNull())
1255       { sout<<"Pas un nom connu : "<<arg2<<endl;  return IFSelect_RetError;  }
1256   }
1257   else item = WS->ShareOut();
1258   if (!WS->SetAppliedModifier(modif,item)) return IFSelect_RetFail;
1259   return IFSelect_RetDone;
1260 }
1261
1262 static IFSelect_ReturnStatus fun44
1263   (const Handle(IFSelect_SessionPilot)& pilot)
1264 {
1265   Handle(IFSelect_WorkSession) WS = pilot->Session();
1266   Standard_Integer argc = pilot->NbWords();
1267   const Standard_CString arg1 = pilot->Arg(1);
1268 //        ****    ResetApplied (modifier)    ****
1269   Handle(Message_Messenger) sout = Message::DefaultMessenger();
1270   if (argc < 2) { sout<<"Designer un modifier"<<endl; return IFSelect_RetError; }
1271   DeclareAndCast(IFSelect_GeneralModifier,modif,WS->NamedItem(arg1));
1272   if (modif.IsNull())
1273     { sout<<"Pas un nom de Modifier : "<<arg1<<endl;  return IFSelect_RetError;  }
1274   if (!WS->ResetAppliedModifier(modif)) return IFSelect_RetFail;
1275   return IFSelect_RetDone;
1276 }
1277
1278 static IFSelect_ReturnStatus fun45
1279   (const Handle(IFSelect_SessionPilot)& pilot)
1280 {
1281   Handle(IFSelect_WorkSession) WS = pilot->Session();
1282   Standard_Integer argc = pilot->NbWords();
1283   const Standard_CString arg1 = pilot->Arg(1);
1284   const Standard_CString arg2 = pilot->Arg(2);
1285   const Standard_CString arg3 = pilot->Arg(3);
1286 //        ****    ModifMove         ****
1287   Handle(Message_Messenger) sout = Message::DefaultMessenger();
1288   if (argc < 4) { sout<<"modifmove MF rang1 rang2, M pour Model F pour File"<<endl; return IFSelect_RetError; }
1289   Standard_Boolean formodel;
1290   if      (arg1[0] == 'm' || arg1[0] == 'M') formodel = Standard_True;
1291   else if (arg1[0] == 'f' || arg1[0] == 'F') formodel = Standard_False;
1292   else { sout<<"preciser M pour Model, F pour File"<<endl; return IFSelect_RetError; }
1293   Standard_Integer before = atoi(arg2);
1294   Standard_Integer after  = atoi(arg3);
1295   if (before == 0 || after == 0) { sout<<"Donner 2 Entiers Positifs"<<endl; return IFSelect_RetError; }
1296   if (!WS->ChangeModifierRank(formodel,before,after)) return IFSelect_RetFail;
1297   return IFSelect_RetDone;
1298 }
1299
1300 static IFSelect_ReturnStatus fun51
1301   (const Handle(IFSelect_SessionPilot)& pilot)
1302 {
1303   Handle(IFSelect_WorkSession) WS = pilot->Session();
1304   Standard_Integer argc = pilot->NbWords();
1305   const Standard_CString arg1 = pilot->Arg(1);
1306   const Standard_CString arg2 = pilot->Arg(2);
1307 //        ****    DispSel           ****
1308   Handle(Message_Messenger) sout = Message::DefaultMessenger();
1309   if (argc < 3) { sout<<"Donner Noms Dispatch et Selection Finale"<<endl; return IFSelect_RetError; }
1310   DeclareAndCast(IFSelect_Dispatch,disp,WS->NamedItem(arg1));
1311   if (disp.IsNull())
1312     { sout<<"Pas un nom de Dispatch : "<<arg1<<endl;  return IFSelect_RetError;  }
1313   DeclareAndCast(IFSelect_Selection,sel,WS->NamedItem(arg2));
1314   if (sel.IsNull())
1315     { sout<<"Pas un nom de Selection : "<<arg2<<endl;  return IFSelect_RetError;  }
1316   if (!WS->SetItemSelection(disp,sel)) return IFSelect_RetFail;
1317   return IFSelect_RetDone;
1318 }
1319
1320 static IFSelect_ReturnStatus fun_dispone
1321   (const Handle(IFSelect_SessionPilot)& pilot)
1322 {
1323   Handle(IFSelect_WorkSession) WS = pilot->Session();
1324 //        ****    DispOne           ****
1325   Handle(IFSelect_DispPerOne) disp = new IFSelect_DispPerOne;
1326   return pilot->RecordItem(disp);
1327 }
1328
1329 static IFSelect_ReturnStatus fun_dispglob
1330   (const Handle(IFSelect_SessionPilot)& pilot)
1331 {
1332   Handle(IFSelect_WorkSession) WS = pilot->Session();
1333 //        ****    DispGlob          ****
1334   Handle(IFSelect_DispGlobal) disp = new IFSelect_DispGlobal;
1335   return pilot->RecordItem(disp);
1336 }
1337
1338 static IFSelect_ReturnStatus fun_dispcount
1339   (const Handle(IFSelect_SessionPilot)& pilot)
1340 {
1341   Handle(IFSelect_WorkSession) WS = pilot->Session();
1342   Standard_Integer argc = pilot->NbWords();
1343   const Standard_CString arg1 = pilot->Arg(1);
1344 //        ****    DispCount         ****
1345   Handle(Message_Messenger) sout = Message::DefaultMessenger();
1346   if (argc < 2) { sout<<"Donner Nom IntParam pour Count"<<endl;  return IFSelect_RetError; }
1347   DeclareAndCast(IFSelect_IntParam,par,WS->NamedItem(arg1));
1348   if (par.IsNull())
1349     { sout<<"Pas un nom de IntParam : "<<arg1<<endl;  return IFSelect_RetError;  }
1350   Handle(IFSelect_DispPerCount) disp = new IFSelect_DispPerCount;
1351   disp->SetCount (par);
1352   return pilot->RecordItem(disp);
1353 }
1354
1355 static IFSelect_ReturnStatus fun_dispfiles
1356   (const Handle(IFSelect_SessionPilot)& pilot)
1357 {
1358   Handle(IFSelect_WorkSession) WS = pilot->Session();
1359   Standard_Integer argc = pilot->NbWords();
1360   const Standard_CString arg1 = pilot->Arg(1);
1361 //        ****    DispFiles         ****
1362   Handle(Message_Messenger) sout = Message::DefaultMessenger();
1363   if (argc < 2) { sout<<"Donner Nom IntParam pour NbFiles"<<endl;  return IFSelect_RetError; }
1364   DeclareAndCast(IFSelect_IntParam,par,WS->NamedItem(arg1));
1365   if (par.IsNull())
1366     { sout<<"Pas un nom de IntParam : "<<arg1<<endl;  return IFSelect_RetError;  }
1367   Handle(IFSelect_DispPerFiles) disp = new IFSelect_DispPerFiles;
1368   disp->SetCount (par);
1369   return pilot->RecordItem(disp);
1370 }
1371
1372
1373 static IFSelect_ReturnStatus fun_dispsign
1374   (const Handle(IFSelect_SessionPilot)& pilot)
1375 {
1376   Handle(IFSelect_WorkSession) WS = pilot->Session();
1377   Standard_Integer argc = pilot->NbWords();
1378   const Standard_CString arg1 = pilot->Arg(1);
1379 //        ****    DispFiles         ****
1380   Handle(Message_Messenger) sout = Message::DefaultMessenger();
1381   if (argc < 2) { sout<<"Donner Nom Signature"<<endl;  return IFSelect_RetError; }
1382   DeclareAndCast(IFSelect_Signature,sig,WS->NamedItem(arg1));
1383   if (sig.IsNull())
1384     { sout<<"Pas un nom de Signature : "<<arg1<<endl;  return IFSelect_RetError;  }
1385   Handle(IFSelect_DispPerSignature) disp = new IFSelect_DispPerSignature;
1386   disp->SetSignCounter (new IFSelect_SignCounter(sig));
1387   return pilot->RecordItem(disp);
1388 }
1389
1390
1391 static IFSelect_ReturnStatus fun56
1392   (const Handle(IFSelect_SessionPilot)& pilot)
1393 {
1394   Handle(IFSelect_WorkSession) WS = pilot->Session();
1395   Standard_Integer argc = pilot->NbWords();
1396   const Standard_CString arg1 = pilot->Arg(1);
1397 //        ****    Dispatch           ****
1398   Handle(Message_Messenger) sout = Message::DefaultMessenger();
1399   if (argc < 2) { sout<<"Donner Nom du Dispatch"<<endl;  return IFSelect_RetError; }
1400   DeclareAndCast(IFSelect_Dispatch,disp,WS->NamedItem(arg1));
1401   if (disp.IsNull()) { sout<<"Pas un dispatch : "<<arg1<<endl; return IFSelect_RetError;  }
1402   Standard_Integer num = WS->DispatchRank(disp);
1403   sout<<"Dispatch de Nom : "<<arg1<<" , en ShareOut, Numero "<<num<<" : ";
1404   Handle(IFSelect_Selection) sel = WS->ItemSelection(disp);
1405   Handle(TCollection_HAsciiString) selname = WS->Name(sel);
1406   if (sel.IsNull())  sout<<"Pas de Selection Finale"<<endl;
1407   else if (selname.IsNull()) sout<<"Selection Finale : #"<<WS->ItemIdent(sel)<<endl;
1408   else sout<<"Selection Finale : "<<selname->ToCString()<<endl;
1409   if (disp->HasRootName()) sout<<"-- Racine nom de fichier : "
1410     <<disp->RootName()->ToCString()<<endl;
1411   return IFSelect_RetVoid;
1412 }
1413
1414 static IFSelect_ReturnStatus fun57
1415   (const Handle(IFSelect_SessionPilot)& pilot)
1416 {
1417   Handle(IFSelect_WorkSession) WS = pilot->Session();
1418   Standard_Integer argc = pilot->NbWords();
1419   const Standard_CString arg1 = pilot->Arg(1);
1420 //        ****    Remove           ****
1421   Handle(Message_Messenger) sout = Message::DefaultMessenger();
1422   if (argc < 2) { sout<<"Give Name to Remove !"<<endl;  return IFSelect_RetError; }
1423   if (!WS->RemoveNamedItem(arg1)) return IFSelect_RetFail;
1424   return IFSelect_RetDone;
1425 }
1426
1427 static IFSelect_ReturnStatus fun58
1428   (const Handle(IFSelect_SessionPilot)& pilot)
1429 {
1430   Handle(IFSelect_WorkSession) WS = pilot->Session();
1431   Standard_Integer argc = pilot->NbWords();
1432   const Standard_CString arg1 = pilot->Arg(1);
1433 //        ****    EvalDisp          ****
1434   Handle(Message_Messenger) sout = Message::DefaultMessenger();
1435   if (argc < 3) { sout<<"evaldisp mode disp [disp ...] :  Mode + Name(s) of Dispatch(es). Mode:\n"
1436                     <<"  0 brief  1 +forgotten ents  2 +duplicata  3 1+2"<<endl
1437                     <<"See also : evaladisp  writedisp  xsplit"<<endl;
1438                   return IFSelect_RetVoid;  }
1439   Standard_Boolean OK = Standard_True;
1440   Standard_Integer i , mode = atoi(arg1);  sout<<" Mode "<<mode<<"\n";
1441   for (i = 2; i < argc; i ++) {
1442     DeclareAndCast(IFSelect_Dispatch,disp,WS->NamedItem(pilot->Arg(i)));
1443     if (disp.IsNull())
1444       { sout<<"Not a dispatch:"<<pilot->Arg(i)<<endl; OK = Standard_False; }
1445   }
1446   if (!OK) {
1447     sout<<"Some of the parameters are not correct"<<endl;
1448     return IFSelect_RetError;
1449   }
1450
1451   WS->ClearShareOut(Standard_True);
1452   for (i = 2; i < argc; i ++) {
1453     DeclareAndCast(IFSelect_Dispatch,disp,WS->NamedItem(pilot->Arg(i)));
1454     WS->SetActive(disp,Standard_True);
1455   }
1456 //      WS->EvaluateDispatch(disp,mode);
1457   WS->EvaluateComplete(mode);
1458   return IFSelect_RetVoid;
1459 }
1460
1461
1462 static IFSelect_ReturnStatus fun_evaladisp
1463   (const Handle(IFSelect_SessionPilot)& pilot)
1464 {
1465   Handle(IFSelect_WorkSession) WS = pilot->Session();
1466   Standard_Integer argc = pilot->NbWords();
1467   const Standard_CString arg1 = pilot->Arg(1);
1468 //        ****    EvalADisp [GiveList]         ****
1469   Handle(Message_Messenger) sout = Message::DefaultMessenger();
1470   if (argc < 3) { sout<<"evaladisp mode(=0-1-2-3) disp [givelist] :  Mode + Dispatch [+ GiveList]\n  If GiveList not given, computed from Selection of the Dispatch. Mode:\n"
1471                     <<"  0 brief  1 +forgotten ents  2 +duplicata  3 1+2"<<endl
1472                     <<"See also : writedisp"<<endl;
1473                   return IFSelect_RetVoid;  }
1474   if (arg1[1] != '\0') { sout<<"first parameter : mode, must be a number between 0 and 3"<<endl; return IFSelect_RetError; }
1475   Standard_Integer mode = atoi(arg1);  sout<<" Mode "<<mode<<"\n";
1476 //  DeclareAndCast(IFSelect_Dispatch,disp,WS->NamedItem(pilot->Arg(2)));
1477   Handle(IFSelect_Dispatch) disp = IFSelect_Functions::GiveDispatch (WS,pilot->Arg(2),Standard_True);
1478   if (disp.IsNull())
1479     { sout<<"Not a dispatch:"<<pilot->Arg(2)<<endl; return IFSelect_RetError; }
1480   Handle(IFSelect_Selection) selsav = disp->FinalSelection();
1481   Handle(IFSelect_Selection) sel;
1482   if (argc > 3) {
1483     Handle(IFSelect_SelectPointed) sp = new IFSelect_SelectPointed;
1484     Handle(TColStd_HSequenceOfTransient) list = IFSelect_Functions::GiveList
1485       (pilot->Session(),pilot->CommandPart(3));
1486     Standard_Integer nb = (list.IsNull() ? 0 : list->Length());
1487     if (nb > 0)  {  sp->AddList (list);  sel = sp;  }
1488   }
1489
1490   if (sel.IsNull() && selsav.IsNull())
1491     { sout<<"No Selection nor GiveList defined"<<endl; return IFSelect_RetError; }
1492   if (sel.IsNull() && !selsav.IsNull()) {
1493     if (argc > 3) sout<<"GiveList is empty, hence computed from the Selection of the Dispatch"<<endl;
1494     sel = selsav;
1495   }
1496   disp->SetFinalSelection(sel);
1497 //  WS->ClearShareOut(Standard_True);
1498 //  WS->SetActive(disp,Standard_True);
1499   WS->EvaluateDispatch(disp,mode);
1500   disp->SetFinalSelection(selsav);
1501
1502   return IFSelect_RetVoid;
1503 }
1504
1505 static IFSelect_ReturnStatus fun_writedisp
1506   (const Handle(IFSelect_SessionPilot)& pilot)
1507 {
1508   Handle(IFSelect_WorkSession) WS = pilot->Session();
1509   Standard_Integer argc = pilot->NbWords();
1510   const Standard_CString arg1 = pilot->Arg(1);
1511 //        ****    EvalADisp [GiveList]         ****
1512   Handle(Message_Messenger) sout = Message::DefaultMessenger();
1513   if (argc < 3) { sout<<"writedisp filename disp [givelist] :  FileName + Dispatch [+ GiveList]\n  If GiveList not given, computed from Selection of the Dispatch.\n"
1514                     <<"FileName : rootname.ext will gives rootname_1.ext etc...\n"
1515                     <<"  path/rootname.ext gives  path/rootname_1.ext etc...\n"
1516                     <<"See also : evaladisp"<<endl;
1517                   return IFSelect_RetVoid;  }
1518   TCollection_AsciiString prefix,rootname,suffix;
1519   SplitFileName (arg1,prefix,rootname,suffix);
1520   if (rootname.Length() == 0 || suffix.Length() == 0) {
1521     sout<<"Empty Root Name or Extension"<<endl;
1522     return IFSelect_RetError;
1523   }
1524
1525 //  DeclareAndCast(IFSelect_Dispatch,disp,WS->NamedItem(pilot->Arg(2)));
1526   Handle(IFSelect_Dispatch) disp = IFSelect_Functions::GiveDispatch (WS,pilot->Arg(2),Standard_True);
1527   if (disp.IsNull())
1528     { sout<<"Not a dispatch:"<<pilot->Arg(2)<<endl; return IFSelect_RetError; }
1529   Handle(IFSelect_Selection) selsav = disp->FinalSelection();
1530   Handle(IFSelect_Selection) sel;
1531   if (argc > 3) {
1532     Handle(IFSelect_SelectPointed) sp = new IFSelect_SelectPointed;
1533     Handle(TColStd_HSequenceOfTransient) list = IFSelect_Functions::GiveList
1534       (pilot->Session(),pilot->CommandPart(3));
1535     Standard_Integer nb = (list.IsNull() ? 0 : list->Length());
1536     if (nb > 0)  {  sp->AddList (list);  sel = sp;  }
1537   }
1538
1539   if (sel.IsNull() && selsav.IsNull())
1540     { sout<<"No Selection nor GiveList defined"<<endl; return IFSelect_RetError; }
1541   if (sel.IsNull() && !selsav.IsNull()) {
1542     if (argc > 3) sout<<"GiveList is empty, hence computed from the Selection of the Dispatch"<<endl;
1543     sel = selsav;
1544   }
1545
1546   WS->ClearShareOut(Standard_True);
1547   disp->SetFinalSelection(sel);
1548   WS->SetActive(disp,Standard_True);
1549   WS->BeginSentFiles(Standard_True);
1550
1551   WS->SetFilePrefix    (prefix.ToCString());
1552   WS->SetFileExtension (suffix.ToCString());
1553   WS->SetFileRoot(disp,rootname.ToCString());
1554
1555   Standard_Boolean OK = WS->SendSplit();
1556   disp->SetFinalSelection(selsav);
1557   return (OK ? IFSelect_RetDone : IFSelect_RetFail);
1558 }
1559
1560
1561 static IFSelect_ReturnStatus fun59
1562   (const Handle(IFSelect_SessionPilot)& pilot)
1563 {
1564   Handle(IFSelect_WorkSession) WS = pilot->Session();
1565   Standard_Integer argc = pilot->NbWords();
1566   const Standard_CString arg1 = pilot->Arg(1);
1567 //        ****    EvalComplete      ****
1568   Standard_Integer mode = 0;
1569   Handle(Message_Messenger) sout = Message::DefaultMessenger();
1570   if (argc < 2) sout << " -- mode par defaut 0\n";
1571   else { mode = atoi(arg1); sout << " -- mode : " << mode << endl;  }
1572   WS->EvaluateComplete(mode);  return IFSelect_RetVoid;
1573 }
1574
1575 static IFSelect_ReturnStatus fun60
1576   (const Handle(IFSelect_SessionPilot)& pilot)
1577 {
1578   Handle(IFSelect_WorkSession) WS = pilot->Session();
1579 //        ****    LastRunCheckList    ****
1580   Interface_CheckIterator chlist = WS->LastRunCheckList();
1581   Handle(IFSelect_CheckCounter) counter = new IFSelect_CheckCounter(0);
1582   counter->Analyse(chlist,WS->Model(),Standard_False);
1583   counter->PrintCount (Message::DefaultMessenger());
1584   return IFSelect_RetVoid;
1585 }
1586
1587 static IFSelect_ReturnStatus fun61
1588   (const Handle(IFSelect_SessionPilot)& pilot)
1589 {
1590   Handle(IFSelect_WorkSession) WS = pilot->Session();
1591   Standard_Integer argc = pilot->NbWords();
1592   const Standard_CString arg1 = pilot->Arg(1);
1593 //        ****    RunTransformer    ****
1594   Handle(Message_Messenger) sout = Message::DefaultMessenger();
1595   if (argc < 2) { sout<<"Donner Nom de Transformer"<<endl; return IFSelect_RetError;  }
1596   DeclareAndCast(IFSelect_Transformer,tsf,WS->NamedItem(arg1));
1597   Standard_Integer effect = WS->RunTransformer(tsf);
1598   switch (effect) {
1599     case -4 : sout<<"Edition sur place, nouveau Protocole, erreur recalcul graphe"<<endl; break;
1600     case -3 : sout<<"Erreur, Transformation ignoree"<<endl; break;
1601     case -2 : sout<<"Erreur sur edition sur place, risque de corruption (verifier)"<<endl; break;
1602     case -1 : sout<<"Erreur sur edition locale, risque de corruption (verifier)"<<endl; break;
1603     case  0 :
1604       if   (tsf.IsNull()) sout<<"Erreur, pas un Transformer: "<<arg1<<endl;
1605       else sout<<"Execution non faite"<<endl;
1606               break;
1607     case  1 : sout<<"Transformation locale (graphe non touche)"<<endl; break;
1608     case  2 : sout<<"Edition sur place (graphe recalcule)"<<endl;  break;
1609     case  3 : sout<<"Modele reconstruit"<<endl; break;
1610     case  4 : sout<<"Edition sur place, nouveau Protocole"<<endl;  break;
1611     case  5 : sout<<"Nouveau Modele avec nouveau Protocole"<<endl; break;
1612     default : break;
1613   }
1614   return ((effect > 0) ? IFSelect_RetDone : IFSelect_RetFail);
1615 }
1616
1617 static IFSelect_ReturnStatus fun62
1618   (const Handle(IFSelect_SessionPilot)& pilot)
1619 {
1620   Handle(IFSelect_WorkSession) WS = pilot->Session();
1621 //        ****    TransformStandard Copy         ****
1622   return pilot->RecordItem(WS->NewTransformStandard(Standard_True));
1623 }
1624
1625 static IFSelect_ReturnStatus fun63
1626   (const Handle(IFSelect_SessionPilot)& pilot)
1627 {
1628   Handle(IFSelect_WorkSession) WS = pilot->Session();
1629 //        ****    TransformStandard OntheSpot         ****
1630   return pilot->RecordItem(WS->NewTransformStandard(Standard_False));
1631 }
1632
1633 static IFSelect_ReturnStatus fun6465
1634   (const Handle(IFSelect_SessionPilot)& pilot)
1635 {
1636   Handle(IFSelect_WorkSession) WS = pilot->Session();
1637   Standard_Integer argc = pilot->NbWords();
1638   const Standard_CString arg1 = pilot->Arg(1);
1639 //        ****    Run Modifier avec Standard Copy     ****
1640 //        ****    Run Modifier avec OnTheSpot         ****
1641   Standard_Boolean runcopy = (pilot->Arg(0)[3] == 'c');
1642 //  soit c est un nom, sinon c est une commande
1643   Handle(IFSelect_Modifier) modif;
1644   if (WS->NameIdent(arg1) > 0)
1645     modif = GetCasted(IFSelect_Modifier,WS->NamedItem(arg1));
1646   else {
1647     pilot->RemoveWord(0);    // c etait la commande run
1648     pilot->Perform();
1649     modif = GetCasted(IFSelect_Modifier,pilot->RecordedItem());
1650   }
1651   Handle(Message_Messenger) sout = Message::DefaultMessenger();
1652   if (modif.IsNull())
1653     { sout<<"Pas un nom de Modifier : "<<arg1<<endl;  return IFSelect_RetError;  }
1654
1655   Handle(TColStd_HSequenceOfTransient) list;
1656   Handle(IFSelect_SelectPointed) sp;
1657   if (argc > 2) {
1658     list = IFSelect_Functions::GiveList (WS,pilot->CommandPart(2));
1659     sp = new IFSelect_SelectPointed;
1660     sp->SetList (list);
1661   }
1662
1663   Standard_Integer effect = 0;
1664   effect = WS->RunModifierSelected (modif,sp,runcopy);
1665 //      sout<<"Modifier applique sur TransformStandard #"<<WS->ItemIdent(tsf)<<endl;
1666   switch (effect) {
1667     case -4 : sout<<"Edition sur place, nouveau Protocole, erreur recalcul graphe"<<endl; break;
1668     case -3 : sout<<"Erreur, Transformation ignoree"<<endl; break;
1669     case -2 : sout<<"Erreur sur edition sur place, risque de corruption (verifier)"<<endl; break;
1670     case -1 : sout<<"Erreur sur edition locale, risque de corruption (verifier)"<<endl; break;
1671     case  0 :
1672       if   (modif.IsNull()) sout<<"Erreur, pas un Modifier: "<<arg1<<endl;
1673       else sout<<"Execution non faite"<<endl;
1674               break;
1675     case  1 : sout<<"Transformation locale (graphe non touche)"<<endl; break;
1676     case  2 : sout<<"Edition sur place (graphe recalcule)"<<endl;  break;
1677     case  3 : sout<<"Modele reconstruit"<<endl; break;
1678     case  4 : sout<<"Edition sur place, nouveau Protocole"<<endl;  break;
1679     case  5 : sout<<"Nouveau Modele avec nouveau Protocole"<<endl; break;
1680     default : break;
1681   }
1682   return ((effect > 0) ? IFSelect_RetDone : IFSelect_RetFail);
1683 }
1684
1685 static IFSelect_ReturnStatus fun66
1686   (const Handle(IFSelect_SessionPilot)& pilot)
1687 {
1688 //        ****    (xset) ModifReorder         ****
1689   char opt = ' ';
1690   Standard_Integer argc = pilot->NbWords();
1691   if (argc >= 2) opt = pilot->Word(1).Value(1);
1692   Handle(Message_Messenger) sout = Message::DefaultMessenger();
1693   if (opt != 'f' && opt != 'l')
1694     { sout<<"Donner option : f -> root-first  l -> root-last"<<endl; return IFSelect_RetError; }
1695   return pilot->RecordItem(new IFSelect_ModifReorder(opt == 'l'));
1696 }
1697
1698 static IFSelect_ReturnStatus fun70
1699   (const Handle(IFSelect_SessionPilot)& pilot)
1700 {
1701   Handle(IFSelect_WorkSession) WS = pilot->Session();
1702   Standard_Integer argc = pilot->NbWords();
1703   const Standard_CString arg1 = pilot->Arg(1);
1704 //        ****    SelToggle         ****
1705   Handle(Message_Messenger) sout = Message::DefaultMessenger();
1706   if (argc < 2) { sout<<"Donner Nom de Selection"<<endl; return IFSelect_RetError;  }
1707   DeclareAndCast(IFSelect_Selection,sel,WS->NamedItem(arg1));
1708   if (!WS->ToggleSelectExtract(sel))
1709     { sout<<"Pas une SelectExtract : "<<arg1<<endl; return IFSelect_RetFail;  }
1710   if (WS->IsReversedSelectExtract(sel)) sout<<arg1<<" a present Reversed"<<endl;
1711   else sout<<arg1<<" a present Directe"<<endl;
1712   return IFSelect_RetDone;
1713 }
1714
1715 static IFSelect_ReturnStatus fun71
1716   (const Handle(IFSelect_SessionPilot)& pilot)
1717 {
1718   Handle(IFSelect_WorkSession) WS = pilot->Session();
1719   Standard_Integer argc = pilot->NbWords();
1720   const Standard_CString arg1 = pilot->Arg(1);
1721   const Standard_CString arg2 = pilot->Arg(2);
1722 //        ****    SelInput          ****
1723   Handle(Message_Messenger) sout = Message::DefaultMessenger();
1724   if (argc < 3) { sout<<"Donner Noms Selections cible et input"<<endl; return IFSelect_RetError; }
1725   DeclareAndCast(IFSelect_Selection,sel,WS->NamedItem(arg1));
1726   DeclareAndCast(IFSelect_Selection,sou,WS->NamedItem(arg2));
1727   if (sel.IsNull() || sou.IsNull())
1728     {  sout<<"Incorrect : "<<arg1<<","<<arg2<<endl;  return IFSelect_RetError;  }
1729   if (!WS->SetInputSelection(sel,sou)) { 
1730     sout<<"Nom incorrect ou Selection "<<arg1<<" ni Extract ni Deduct"<<endl;
1731     return IFSelect_RetFail;
1732   }
1733   return IFSelect_RetDone;
1734 }
1735
1736 static IFSelect_ReturnStatus fun72
1737   (const Handle(IFSelect_SessionPilot)& pilot)
1738 {
1739   Handle(IFSelect_WorkSession) WS = pilot->Session();
1740 //        ****    SelModelRoots     ****
1741   return pilot->RecordItem (new IFSelect_SelectModelRoots);
1742 }
1743
1744 static IFSelect_ReturnStatus fun73
1745   (const Handle(IFSelect_SessionPilot)& pilot)
1746 {
1747   Handle(IFSelect_WorkSession) WS = pilot->Session();
1748   Standard_Integer argc = pilot->NbWords();
1749   const Standard_CString arg1 = pilot->Arg(1);
1750   const Standard_CString arg2 = pilot->Arg(2);
1751 //        ****    SelRange          ****
1752   Handle(Message_Messenger) sout = Message::DefaultMessenger();
1753   if (argc >= 2 && arg1[0] == '?') argc = 1;
1754   if (argc < 2) {
1755     sout<<"Donner la description du SelectRange"
1756       <<"    Formes admises :\n <n1> <n2>  : Range de <n1> a <n2>\n"
1757       <<" <n1> tout seul : Range n0 <n1>\n  from <n1>  : Range From <n1>\n"
1758       <<"  until <n2> : Range Until <n2>"<<endl;
1759     return IFSelect_RetVoid;
1760   }
1761
1762   Handle(IFSelect_IntParam) low,up;
1763   Handle(IFSelect_SelectRange) sel;
1764 //                                         Range From
1765   if (pilot->Word(1).IsEqual("from")) {
1766     if (argc < 3) { sout<<"Forme admise : from <i>"<<endl; return IFSelect_RetError; }
1767     low = GetCasted(IFSelect_IntParam,WS->NamedItem(arg2));
1768     sel = new IFSelect_SelectRange;
1769     sel->SetFrom (low);
1770 //                                         Range Until
1771   } else if (pilot->Word(1).IsEqual("until")) {
1772     if (argc < 3) { sout<<"Forme admise : until <i>"<<endl; return IFSelect_RetError; }
1773     up  = GetCasted(IFSelect_IntParam,WS->NamedItem(arg2));
1774     sel = new IFSelect_SelectRange;
1775     sel->SetUntil (up);
1776 //                                         Range One (n-th)
1777   } else if (argc < 3) {
1778     low = GetCasted(IFSelect_IntParam,WS->NamedItem(arg1));
1779     sel = new IFSelect_SelectRange;
1780     sel->SetOne (low);
1781 //                                         Range (from-to)
1782   } else {
1783     low = GetCasted(IFSelect_IntParam,WS->NamedItem(arg1));
1784     up  = GetCasted(IFSelect_IntParam,WS->NamedItem(arg2));
1785     sel = new IFSelect_SelectRange;
1786     sel->SetRange (low,up);
1787   }
1788   return pilot->RecordItem (sel);
1789 }
1790
1791 static IFSelect_ReturnStatus fun74
1792   (const Handle(IFSelect_SessionPilot)& pilot)
1793 {
1794   Handle(IFSelect_WorkSession) WS = pilot->Session();
1795 //        ****    SelRoots          ****
1796   return pilot->RecordItem (new IFSelect_SelectRoots);
1797 }
1798
1799 static IFSelect_ReturnStatus fun75
1800   (const Handle(IFSelect_SessionPilot)& pilot)
1801 {
1802   Handle(IFSelect_WorkSession) WS = pilot->Session();
1803 //        ****    SelShared         ****
1804   return pilot->RecordItem (new IFSelect_SelectShared);
1805 }
1806
1807 static IFSelect_ReturnStatus fun76
1808   (const Handle(IFSelect_SessionPilot)& pilot)
1809 {
1810   Handle(IFSelect_WorkSession) WS = pilot->Session();
1811   Standard_Integer argc = pilot->NbWords();
1812   const Standard_CString arg1 = pilot->Arg(1);
1813   const Standard_CString arg2 = pilot->Arg(2);
1814 //        ****    SelDiff           ****
1815   Handle(IFSelect_Selection) sel = new IFSelect_SelectDiff;
1816   if (sel.IsNull()) return IFSelect_RetFail;
1817   Handle(Message_Messenger) sout = Message::DefaultMessenger();
1818   if (argc < 3) sout<<"Diff sans input : ne pas oublier de les definir (ctlmain, ctlsec)!"<<endl;
1819   DeclareAndCast(IFSelect_Selection,selmain,WS->NamedItem(arg1));
1820   DeclareAndCast(IFSelect_Selection,selsec ,WS->NamedItem(arg2));
1821   if (argc >= 2)
1822     if (!WS->SetControl(sel,selmain,Standard_True))
1823       sout<<"Echec ControlMain:"<<arg1<<" , a refaire (ctlmain)"<<endl;
1824   if (argc >= 3)
1825     if (!WS->SetControl(sel,selsec,Standard_False))
1826       sout<<"Echec ControlSecond:"<<arg2<<" , a refaire (ctlsec)"<<endl;
1827   return pilot->RecordItem (sel);
1828 }
1829
1830 static IFSelect_ReturnStatus fun77
1831   (const Handle(IFSelect_SessionPilot)& pilot)
1832 {
1833   Handle(IFSelect_WorkSession) WS = pilot->Session();
1834   Standard_Integer argc = pilot->NbWords();
1835   const Standard_CString arg1 = pilot->Arg(1);
1836   const Standard_CString arg2 = pilot->Arg(2);
1837 //        ****    SelControlMain       ****
1838   Handle(Message_Messenger) sout = Message::DefaultMessenger();
1839   if (argc < 3) { sout<<"Donner Noms de Control et MainInput"<<endl; return IFSelect_RetError; }
1840   DeclareAndCast(IFSelect_Selection,sel,WS->NamedItem(arg1));
1841   DeclareAndCast(IFSelect_Selection,selmain,WS->NamedItem(arg2));
1842   if (WS->SetControl(sel,selmain,Standard_True)) return IFSelect_RetDone;
1843   sout<<"Nom incorrect ou Selection "<<arg1<<" pas de type Control"<<endl;
1844   return IFSelect_RetFail;
1845 }
1846
1847 static IFSelect_ReturnStatus fun78
1848   (const Handle(IFSelect_SessionPilot)& pilot)
1849 {
1850   Handle(IFSelect_WorkSession) WS = pilot->Session();
1851   Standard_Integer argc = pilot->NbWords();
1852   const Standard_CString arg1 = pilot->Arg(1);
1853   const Standard_CString arg2 = pilot->Arg(2);
1854 //        ****    SelControlSecond       ****
1855   Handle(Message_Messenger) sout = Message::DefaultMessenger();
1856   if (argc < 3) { sout<<"Donner Noms de Control et SecondInput"<<endl; return IFSelect_RetError; }
1857   DeclareAndCast(IFSelect_Selection,sel,WS->NamedItem(arg1));
1858   DeclareAndCast(IFSelect_Selection,seldif,WS->NamedItem(arg2));
1859   if (WS->SetControl(sel,seldif,Standard_False))  return IFSelect_RetDone;
1860   sout<<"Nom incorrect ou Selection "<<arg1<<" pas de type Control"<<endl;
1861   return IFSelect_RetFail;
1862 }
1863
1864 static IFSelect_ReturnStatus fun79
1865   (const Handle(IFSelect_SessionPilot)& pilot)
1866 {
1867   Handle(IFSelect_WorkSession) WS = pilot->Session();
1868 //        ****    SelModelAll       ****
1869   return pilot->RecordItem (new IFSelect_SelectModelEntities);
1870 }
1871
1872 static IFSelect_ReturnStatus fun80
1873   (const Handle(IFSelect_SessionPilot)& pilot)
1874 {
1875   Handle(IFSelect_WorkSession) WS = pilot->Session();
1876   Standard_Integer argc = pilot->NbWords();
1877   const Standard_CString arg1 = pilot->Arg(1);
1878   const Standard_CString arg2 = pilot->Arg(2);
1879 //        ****    SelCombAdd        ****
1880   Handle(Message_Messenger) sout = Message::DefaultMessenger();
1881   if (argc < 3) { sout<<"Donner n0 Combine et une Input"<<endl; return IFSelect_RetError; }
1882   DeclareAndCast(IFSelect_Selection,sel,WS->NamedItem(arg1));
1883   DeclareAndCast(IFSelect_Selection,seladd,WS->NamedItem(arg2));
1884   if (WS->CombineAdd(sel,seladd)) return IFSelect_RetDone;
1885   sout<<"Nom incorrect ou Selection "<<arg1<<" pas Combine"<<endl;
1886   return IFSelect_RetFail;
1887 }
1888
1889 static IFSelect_ReturnStatus fun81
1890   (const Handle(IFSelect_SessionPilot)& pilot)
1891 {
1892   Handle(IFSelect_WorkSession) WS = pilot->Session();
1893   Standard_Integer argc = pilot->NbWords();
1894   const Standard_CString arg1 = pilot->Arg(1);
1895   const Standard_CString arg2 = pilot->Arg(2);
1896 //        ****    SelCombRem        ****
1897   Handle(Message_Messenger) sout = Message::DefaultMessenger();
1898   if (argc < 3) { sout<<"Donner n0 Combine et RANG a supprimer"<<endl; return IFSelect_RetError; }
1899   DeclareAndCast(IFSelect_Selection,sel,WS->NamedItem(arg1));
1900   DeclareAndCast(IFSelect_Selection,inp,WS->NamedItem(arg2));
1901   if (WS->CombineRemove(sel,inp)) return IFSelect_RetDone;
1902   sout<<"Nom incorrect ou Selection "<<arg1<<" ni Union ni Intersection"<<endl;
1903   return IFSelect_RetFail;
1904 }
1905
1906 static IFSelect_ReturnStatus fun82
1907   (const Handle(IFSelect_SessionPilot)& pilot)
1908 {
1909   Handle(IFSelect_WorkSession) WS = pilot->Session();
1910   Standard_Integer argc = pilot->NbWords();
1911   const Standard_CString arg1 = pilot->Arg(1);
1912 //        ****    SelEntNumber      ****
1913   Handle(Message_Messenger) sout = Message::DefaultMessenger();
1914   if (argc < 2) { sout<<"Donner Nom IntParam pour n0 Entite"<<endl; return IFSelect_RetError; }
1915   DeclareAndCast(IFSelect_IntParam,par,WS->NamedItem(arg1));
1916   Handle(IFSelect_SelectEntityNumber) sel = new IFSelect_SelectEntityNumber;
1917   sel->SetNumber(par);
1918   return pilot->RecordItem (sel);
1919 }
1920
1921 static IFSelect_ReturnStatus fun83
1922   (const Handle(IFSelect_SessionPilot)& pilot)
1923 {
1924   Handle(IFSelect_WorkSession) WS = pilot->Session();
1925 //        ****    SelUnion          ****
1926   return pilot->RecordItem (new IFSelect_SelectUnion);
1927 }
1928
1929 static IFSelect_ReturnStatus fun84
1930   (const Handle(IFSelect_SessionPilot)& pilot)
1931 {
1932   Handle(IFSelect_WorkSession) WS = pilot->Session();
1933 //        ****    SelIntersection   ****
1934   return pilot->RecordItem (new IFSelect_SelectIntersection);
1935 }
1936
1937 static IFSelect_ReturnStatus fun85
1938   (const Handle(IFSelect_SessionPilot)& pilot)
1939 {
1940   Standard_Integer argc = pilot->NbWords();
1941   const Standard_CString arg1 = pilot->Arg(1);
1942 //        ****    SelTextType Exact ****
1943   Handle(Message_Messenger) sout = Message::DefaultMessenger();
1944   if (argc < 2) { sout<<"Donner le TYPE a selectionner"<<endl; return IFSelect_RetError; }
1945   return pilot->RecordItem (new IFSelect_SelectSignature
1946                             (new IFSelect_SignType,arg1,Standard_True));
1947 }
1948
1949 static IFSelect_ReturnStatus fun86
1950   (const Handle(IFSelect_SessionPilot)& pilot)
1951 {
1952 //        ****    SelErrorEntities  ****
1953   return pilot->RecordItem (new IFSelect_SelectErrorEntities);
1954 }
1955       
1956 static IFSelect_ReturnStatus fun87
1957   (const Handle(IFSelect_SessionPilot)& pilot)
1958 {
1959 //        ****    SelUnknownEntities  **
1960   return pilot->RecordItem (new IFSelect_SelectUnknownEntities);
1961 }
1962
1963 static IFSelect_ReturnStatus fun88
1964   (const Handle(IFSelect_SessionPilot)& pilot)
1965 {
1966 //        ****    SelSharing        ****
1967   return pilot->RecordItem (new IFSelect_SelectSharing);
1968 }
1969
1970 static IFSelect_ReturnStatus fun89
1971   (const Handle(IFSelect_SessionPilot)& pilot)
1972 {
1973   Standard_Integer argc = pilot->NbWords();
1974   const Standard_CString arg1 = pilot->Arg(1);
1975 //        ****    SelTextType Contain **
1976   Handle(Message_Messenger) sout = Message::DefaultMessenger();
1977   if (argc < 2) { sout<<"Donner le TYPE a selectionner"<<endl; return IFSelect_RetError; }
1978   return pilot->RecordItem (new IFSelect_SelectSignature
1979                             (new IFSelect_SignType,arg1,Standard_False));
1980 }
1981
1982 static IFSelect_ReturnStatus fun90
1983   (const Handle(IFSelect_SessionPilot)& pilot)
1984 {
1985 //        ****    SelPointed        ****
1986   Handle(IFSelect_SelectPointed) sp = new IFSelect_SelectPointed;
1987   if (pilot->NbWords() > 1) {
1988     Handle(TColStd_HSequenceOfTransient) list = IFSelect_Functions::GiveList
1989     (pilot->Session(),pilot->CommandPart(1));
1990     if (list.IsNull()) return IFSelect_RetFail;
1991     Handle(Message_Messenger) sout = Message::DefaultMessenger();
1992     sout<<"SelectPointed : "<<list->Length()<<" entities"<<endl;
1993     sp->AddList (list);
1994   }
1995   return pilot->RecordItem (sp);
1996 }
1997
1998 static IFSelect_ReturnStatus fun91
1999   (const Handle(IFSelect_SessionPilot)& pilot)
2000 {
2001   Handle(IFSelect_WorkSession) WS = pilot->Session();
2002   Standard_Integer argc = pilot->NbWords();
2003   const Standard_CString arg1 = pilot->Arg(1);
2004 //        ****    SetPointed (edit) / SetList (edit)    ****
2005   Handle(Message_Messenger) sout = Message::DefaultMessenger();
2006   if (argc < 2) {
2007     sout<<"Donner NOM SelectPointed + Option(s) :\n"
2008         <<" aucune : liste des entites pointees\n"
2009         <<" 0: Clear  +nn ajout entite nn  -nn enleve nn  /nn toggle nn"<<endl;
2010         return IFSelect_RetError;
2011   }
2012   DeclareAndCast(IFSelect_SelectPointed,sp,WS->NamedItem(arg1));
2013   if (sp.IsNull()) { sout<<"Pas une SelectPointed:"<<arg1<<endl; return IFSelect_RetError; }
2014   Handle(Interface_InterfaceModel) model = WS->Model();  // pour Print
2015   if (argc == 2) {    // listage simple
2016     Standard_Integer nb = sp->NbItems();
2017     sout<<" SelectPointed : "<<arg1<<" : "<<nb<<" Items :"<<endl;
2018     for (Standard_Integer i = 1; i <= nb; i ++) {
2019       Handle(Standard_Transient) pointed = sp->Item(i);
2020       Standard_Integer id = WS->StartingNumber(pointed);
2021       if (id == 0) sout <<" (inconnu)";
2022       else  {  sout<<"  "; model->Print(pointed,sout);  }
2023     }
2024     if (nb > 0) sout<<endl;
2025     return IFSelect_RetDone;
2026   }
2027
2028   for (Standard_Integer ia = 2; ia < argc ; ia ++) {
2029     const TCollection_AsciiString argi = pilot->Word(ia);
2030     Standard_Integer id = pilot->Number(&(argi.ToCString())[1]);
2031     if (id == 0) {
2032       if (!argi.IsEqual("0")) sout<<"Incorrect,ignore:"<<argi<<endl;
2033       else {  sout<<"Clear SelectPointed"<<endl; sp->Clear(); }
2034     } else if (argi.Value(1) == '-') {
2035       Handle(Standard_Transient) item = WS->StartingEntity(id);
2036       if (sp->Remove(item)) sout<<"Removed:no."<<id;
2037       else sout<<" Echec Remove "<<id;
2038       sout<<": "; model->Print(item,sout);  sout<<endl;
2039     } else if (argi.Value(1) == '/') {
2040       Handle(Standard_Transient) item = WS->StartingEntity(id);
2041       if (sp->Remove(item)) sout<<"Toggled:n0."<<id;
2042       else sout<<" Echec Toggle "<<id;
2043       sout<<": "; model->Print(item,sout);  sout<<endl;
2044     } else if (argi.Value(1) == '+') {
2045       Handle(Standard_Transient) item = WS->StartingEntity(id);
2046       if (sp->Add(item)) sout<<"Added:no."<<id;
2047       else sout<<" Echec Add "<<id;
2048       sout<<": "; model->Print(item,sout);  sout<<endl;
2049     } else {
2050       sout<<"Ignore:"<<argi<<" , donner n0 PRECEDE de + ou - ou /"<<endl;
2051     }
2052   }
2053   return IFSelect_RetDone;
2054 }
2055
2056 static IFSelect_ReturnStatus fun92
2057   (const Handle(IFSelect_SessionPilot)& pilot)
2058 {
2059   Handle(IFSelect_WorkSession) WS = pilot->Session();
2060 //        ****    SelIncorrectEntities  ****
2061   WS->ComputeCheck();
2062   return pilot->RecordItem (new IFSelect_SelectIncorrectEntities);
2063 }
2064
2065 static IFSelect_ReturnStatus fun93
2066   (const Handle(IFSelect_SessionPilot)& pilot)
2067 {
2068   Standard_Integer argc = pilot->NbWords();
2069   const Standard_CString arg1 = pilot->Arg(1);
2070   const Standard_CString arg2 = pilot->Arg(2);
2071   Handle(IFSelect_WorkSession) WS = pilot->Session();
2072 //        ****    SelSignature        ****
2073   Handle(Message_Messenger) sout = Message::DefaultMessenger();
2074   if (argc < 3) { sout<<"Give name of Signature or Counter, text + option exact(D) else contains"<<endl; return IFSelect_RetError; }
2075   Standard_Boolean exact = Standard_True;
2076   if (argc > 3) { if (pilot->Arg(3)[0] == 'c') exact = Standard_False; }
2077
2078   DeclareAndCast(IFSelect_Signature,sign,WS->NamedItem(arg1));
2079   DeclareAndCast(IFSelect_SignCounter,cnt,WS->NamedItem(arg1));
2080   Handle(IFSelect_SelectSignature) sel;
2081
2082   if (!sign.IsNull())     sel = new IFSelect_SelectSignature (sign,arg2,exact);
2083   else if (!cnt.IsNull()) sel = new IFSelect_SelectSignature (cnt,arg2,exact);
2084   else { sout<<arg1<<":neither Signature nor Counter"<<endl; return IFSelect_RetError; }
2085
2086   return pilot->RecordItem(sel);
2087 }
2088
2089 static IFSelect_ReturnStatus fun94
2090   (const Handle(IFSelect_SessionPilot)& pilot)
2091 {
2092   Standard_Integer argc = pilot->NbWords();
2093   const Standard_CString arg1 = pilot->Arg(1);
2094   Handle(IFSelect_WorkSession) WS = pilot->Session();
2095 //        ****    SignCounter        ****
2096   Handle(Message_Messenger) sout = Message::DefaultMessenger();
2097   if (argc < 2) { sout<<"Donner nom signature"<<endl; return IFSelect_RetError; }
2098   DeclareAndCast(IFSelect_Signature,sign,WS->NamedItem(arg1));
2099   if (sign.IsNull()) { sout<<arg1<<":pas une signature"<<endl; return IFSelect_RetError; }
2100   Handle(IFSelect_SignCounter) cnt = new IFSelect_SignCounter (sign,Standard_True,Standard_True);
2101   return pilot->RecordItem(cnt);
2102 }
2103
2104 static IFSelect_ReturnStatus funbselected
2105   (const Handle(IFSelect_SessionPilot)& pilot)
2106 {
2107   Standard_Integer argc = pilot->NbWords();
2108   const Standard_CString arg1 = pilot->Arg(1);
2109   Handle(IFSelect_WorkSession) WS = pilot->Session();
2110 //        ****    NbSelected = GraphCounter        ****
2111   Handle(Message_Messenger) sout = Message::DefaultMessenger();
2112   if (argc < 2) { sout<<"Donner nom selection (deduction) a appliquer"<<endl; return IFSelect_RetError; }
2113   DeclareAndCast(IFSelect_SelectDeduct,applied,WS->GiveSelection(arg1));
2114   if (applied.IsNull()) { sout<<arg1<<":pas une SelectDeduct"<<endl; return IFSelect_RetError; }
2115   Handle(IFSelect_GraphCounter) cnt = new IFSelect_GraphCounter (Standard_True,Standard_True);
2116   cnt->SetApplied (applied);
2117   return pilot->RecordItem(cnt);
2118 }
2119
2120 //  #########################################
2121 //  ####    EDITOR  -  EDITFORM          ####
2122 //  #########################################
2123
2124 static IFSelect_ReturnStatus fun_editlist
2125   (const Handle(IFSelect_SessionPilot)& pilot)
2126 {
2127   Standard_Integer argc = pilot->NbWords();
2128   Handle(Message_Messenger) sout = Message::DefaultMessenger();
2129   if (argc < 2) { sout<<"Give the name of an EditForm or an Editor"<<endl;
2130                   return IFSelect_RetError;  }
2131   const Standard_CString arg1 = pilot->Arg(1);
2132   const Standard_CString arg2 = pilot->Arg(2);
2133   Handle(IFSelect_WorkSession) WS = pilot->Session();
2134
2135 //  EditForm
2136
2137   DeclareAndCast(IFSelect_EditForm,edf,WS->NamedItem(arg1));
2138   Handle(IFSelect_Editor) edt;
2139   if (!edf.IsNull()) {
2140     sout<<"Print EditForm "<<arg1<<endl;
2141     edt = edf->Editor();
2142     if (argc < 3) {
2143
2144 //       DEFINITIONS : Editor (direct ou via EditForm)
2145
2146       if (edt.IsNull()) edt = GetCasted(IFSelect_Editor,WS->NamedItem(arg1));
2147       if (edt.IsNull()) return IFSelect_RetVoid;
2148
2149       sout<<"Editor, Label : "<<edt->Label()<<endl;
2150       sout<<endl<<" --  Names (short - complete) + Labels of Values"<<endl;
2151       edt->PrintNames(sout);
2152       sout<<endl<<" --  Definitions  --"<<endl;
2153       edt->PrintDefs (sout);
2154       if (!edf.IsNull()) {
2155         edf->PrintDefs(sout);
2156         sout<<endl<<"To display values, add an option : o original  f final  m modified"<<endl;
2157       }
2158
2159       return IFSelect_RetVoid;
2160
2161     } else {
2162       char opt = arg2[0];
2163       Standard_Integer what = 0;
2164       if (opt == 'o') what = -1;
2165       else if (opt == 'f') what = 1;
2166
2167       edf->PrintValues (sout,what,Standard_False);
2168     }
2169   }
2170
2171   return IFSelect_RetVoid;
2172 }
2173
2174 static IFSelect_ReturnStatus fun_editvalue
2175   (const Handle(IFSelect_SessionPilot)& pilot)
2176 {
2177   Standard_Integer argc = pilot->NbWords();
2178   Handle(Message_Messenger) sout = Message::DefaultMessenger();
2179   if (argc < 3) { sout<<"Give the name of an EditForm + name of Value [+ newvalue or . to nullify]"<<endl;
2180                   return IFSelect_RetError;  }
2181   const Standard_CString arg1 = pilot->Arg(1);
2182   const Standard_CString arg2 = pilot->Arg(2);
2183   Handle(IFSelect_WorkSession) WS = pilot->Session();
2184   DeclareAndCast(IFSelect_EditForm,edf,WS->NamedItem(arg1));
2185   if (edf.IsNull())
2186     {  sout<<"Not an EditForm : "<<arg1<<endl; return IFSelect_RetError;  }
2187   Standard_Integer num = edf->NameNumber (arg2);
2188   if (num == 0) sout<<"Unknown Value Name : "<<arg2<<endl;
2189   if (num <  0) sout<<"Not Extracted Value Name : "<<arg2<<endl;
2190   if (num <= 0) return IFSelect_RetError;
2191
2192   Standard_Boolean islist = edf->Editor()->IsList(num);
2193   Standard_CString name = edf->Editor()->Name(num,Standard_True); // vrai nom
2194   Handle(TColStd_HSequenceOfHAsciiString) listr;
2195   Handle(TCollection_HAsciiString) str;
2196   sout<<"Value Name : "<<name<<(edf->IsModified(num) ? "(already edited) : " : " : ");
2197
2198   if (islist) {
2199     listr = edf->EditedList(num);
2200     if (listr.IsNull()) sout<<"(NULL LIST)"<<endl;
2201     else {
2202       Standard_Integer ilist,nblist = listr->Length();
2203       sout<<"(List : "<<nblist<<" Items)"<<endl;
2204       for (ilist = 1; ilist <= nblist; ilist ++) {
2205         str = listr->Value(ilist);
2206         sout<<"  ["<<ilist<<"]  "<< (str.IsNull() ? "(NULL)" : str->ToCString())<<endl;
2207       }
2208     }
2209     if (argc < 4) sout<<"To Edit, options by editval edit-form value-name ?"<<endl;
2210   } else {
2211     str = edf->EditedValue (num);
2212     sout<<(str.IsNull() ? "(NULL)" : str->ToCString())<<endl;
2213   }
2214   if (argc < 4) return IFSelect_RetVoid;
2215
2216 //  Valeur simple ou liste ?
2217   Standard_Integer numarg = 3;
2218   str.Nullify();
2219
2220   const Standard_CString argval = pilot->Arg(numarg);
2221   if (islist) {
2222     if (argval[0] == '?') {
2223       sout<<"To Edit, options"<<endl<<" + val : add value at end (blanks allowed)"
2224         <<endl<<" +nn text : insert val before item nn"<<endl
2225         <<" nn text : replace item nn with a new value"<<endl
2226         <<" -nn : remove item nn"<<endl<<" . : clear the list"<<endl;
2227       return IFSelect_RetVoid;
2228     }
2229     Standard_Boolean stated = Standard_False;
2230     Handle(IFSelect_ListEditor) listed = edf->ListEditor (num);
2231     if (listed.IsNull()) return IFSelect_RetError;
2232     if (argval[0] == '.') { listr.Nullify();  stated = listed->LoadEdited(listr); }
2233     else if (argval[0] == '+') {
2234       Standard_Integer numadd = 0;
2235       if (argval[1] != '\0') numadd = atoi(argval);
2236       stated = listed->AddValue (new TCollection_HAsciiString(pilot->CommandPart(numarg+1)),numadd);
2237     }
2238     else if (argval[0] == '-') {
2239       Standard_Integer numrem = atoi(argval);
2240       stated = listed->Remove(numrem);
2241     }
2242     else {
2243       Standard_Integer numset = atoi(argval);
2244       if (numset > 0) stated = listed->AddValue
2245         (new TCollection_HAsciiString(pilot->CommandPart(numarg+1)),numset);
2246     }
2247     if (stated) stated = edf->ModifyList (num,listed,Standard_True);
2248     if (stated) sout<<"List Edition done"<<endl;
2249     else sout<<"List Edition not done, option"<<argval<<endl;
2250   } else {
2251     if (argval[0] == '.' && argval[1] == '\0') str.Nullify();
2252     else str = new TCollection_HAsciiString (pilot->CommandPart(numarg));
2253     if (edf->Modify (num,str,Standard_True)) {
2254       sout<<"Now set to "<<(str.IsNull() ? "(NULL)" : str->ToCString())<<endl;
2255     } else {
2256       sout<<"Modify not done"<<endl;  return IFSelect_RetFail;
2257     }
2258   }
2259   return IFSelect_RetDone;
2260 }
2261
2262 static IFSelect_ReturnStatus fun_editclear
2263   (const Handle(IFSelect_SessionPilot)& pilot)
2264 {
2265   Standard_Integer argc = pilot->NbWords();
2266   Handle(Message_Messenger) sout = Message::DefaultMessenger();
2267   if (argc < 2) { sout<<"Give the name of an EditForm [+ name of Value  else all]"<<endl;
2268                   return IFSelect_RetError;  }
2269   const Standard_CString arg1 = pilot->Arg(1);
2270   const Standard_CString arg2 = pilot->Arg(2);
2271   Handle(IFSelect_WorkSession) WS = pilot->Session();
2272   DeclareAndCast(IFSelect_EditForm,edf,WS->NamedItem(arg1));
2273   if (edf.IsNull())
2274     {  sout<<"Not an EditForm : "<<arg1<<endl; return IFSelect_RetError;  }
2275   if (argc < 3) { edf->ClearEdit(); sout<<"All Modifications Cleared"<<endl; }
2276   else {
2277     Standard_Integer num = edf->NameNumber (arg2);
2278     if (num == 0) sout<<"Unknown Value Name : "<<arg2<<endl;
2279     if (num <  0) sout<<"Not Extracted Value Name : "<<arg2<<endl;
2280     if (num <= 0) return IFSelect_RetError;
2281     if (!edf->IsModified(num))
2282       { sout<<"Value "<<arg2<<" was not modified"<<endl; return IFSelect_RetVoid; }
2283     edf->ClearEdit (num);
2284     sout<<"Modification on Value "<<arg2<<" Cleared"<<endl;
2285   }
2286   return IFSelect_RetDone;
2287 }
2288
2289 static IFSelect_ReturnStatus fun_editapply
2290   (const Handle(IFSelect_SessionPilot)& pilot)
2291 {
2292   Standard_Integer argc = pilot->NbWords();
2293   Handle(Message_Messenger) sout = Message::DefaultMessenger();
2294   if (argc < 2) { sout<<"Give the name of an EditForm [+ option keep to re-apply edited values]"<<endl;
2295                   return IFSelect_RetError;  }
2296   const Standard_CString arg1 = pilot->Arg(1);
2297   const Standard_CString arg2 = pilot->Arg(2);
2298   Handle(IFSelect_WorkSession) WS = pilot->Session();
2299   DeclareAndCast(IFSelect_EditForm,edf,WS->NamedItem(arg1));
2300   if (edf.IsNull())
2301     {  sout<<"Not an EditForm : "<<arg1<<endl; return IFSelect_RetError;  }
2302
2303   Handle(Standard_Transient) ent = edf->Entity();
2304   Handle(Interface_InterfaceModel) model = edf->Model();
2305   if (!model.IsNull()) {
2306     if (ent.IsNull()) sout<<"Applying modifications on loaded model"<<endl;
2307     else {
2308       sout<<"Applying modifications on loaded entity : ";
2309       model->PrintLabel (ent,sout);
2310     }
2311   }
2312   else sout<<"Applying modifications"<<endl;
2313
2314   if (!edf->ApplyData (edf->Entity(),edf->Model())) {
2315     sout<<"Modifications could not be applied"<<endl;
2316     return IFSelect_RetFail;
2317   }
2318   sout<<"Modifications have been applied"<<endl;
2319
2320   Standard_Boolean stat = Standard_True;
2321   if (argc > 2 && arg2[0] == 'k') stat = Standard_False;
2322   if (stat) {
2323     edf->ClearEdit();
2324     sout<<"Edited values are cleared"<<endl;
2325   }
2326   else sout<<"Edited values are kept for another loading/applying"<<endl;
2327
2328   return IFSelect_RetDone;
2329 }
2330
2331 static IFSelect_ReturnStatus fun_editload
2332   (const Handle(IFSelect_SessionPilot)& pilot)
2333 {
2334   Standard_Integer argc = pilot->NbWords();
2335   Handle(Message_Messenger) sout = Message::DefaultMessenger();
2336   if (argc < 2) { sout<<"Give the name of an EditForm [+ Entity-Ident]"<<endl;
2337                   return IFSelect_RetError;  }
2338   const Standard_CString arg1 = pilot->Arg(1);
2339   const Standard_CString arg2 = pilot->Arg(2);
2340   Handle(IFSelect_WorkSession) WS = pilot->Session();
2341   DeclareAndCast(IFSelect_EditForm,edf,WS->NamedItem(arg1));
2342   if (edf.IsNull())
2343     {  sout<<"Not an EditForm : "<<arg1<<endl; return IFSelect_RetError;  }
2344
2345   Standard_Integer num = (argc < 3 ? 0 : pilot->Number (arg2));
2346   Standard_Boolean stat = Standard_False;
2347   if (argc < 3) {
2348     sout<<"EditForm "<<arg1<<" : Loading Model"<<endl;
2349     stat = edf->LoadModel(WS->Model());
2350   } else if (num <= 0) {
2351     sout<<"Not an entity ident : "<<arg2<<endl;
2352     return IFSelect_RetError;
2353   } else {
2354     sout<<"EditForm "<<arg1<<" : Loading Entity "<<arg2<<endl;
2355     stat = edf->LoadData (WS->StartingEntity(num),WS->Model());
2356   }
2357
2358   if (!stat) {
2359     sout<<"Loading not done"<<endl;
2360     return IFSelect_RetFail;
2361   }
2362   sout<<"Loading done"<<endl;
2363   return IFSelect_RetDone;
2364 }
2365
2366 //  #########################################
2367 //  ####    FONCTIONS COMPLEMENTAIRES    ####
2368 //  #########################################
2369
2370     Handle(Standard_Transient)  IFSelect_Functions::GiveEntity
2371   (const Handle(IFSelect_WorkSession)& WS,
2372    const Standard_CString name)
2373 {
2374   Handle(Standard_Transient) ent;  // demarre a Null
2375   Standard_Integer num = GiveEntityNumber(WS,name);
2376   if (num > 0) ent = WS->StartingEntity(num);
2377   return ent;
2378 }
2379
2380     Standard_Integer  IFSelect_Functions::GiveEntityNumber
2381   (const Handle(IFSelect_WorkSession)& WS,
2382    const Standard_CString name)
2383 {
2384   Standard_Integer num = 0;
2385   if (!name || name[0] == '\0') {
2386     char ligne[80];  ligne[0] = '\0';
2387     cin >> ligne;
2388 //    cin.clear();  cin.getline (ligne,79);
2389     if (ligne[0] == '\0') return 0;
2390     num    = WS->NumberFromLabel (ligne);
2391   }
2392   else num = WS->NumberFromLabel (name);
2393   return num;
2394 }
2395
2396     Handle(TColStd_HSequenceOfTransient)  IFSelect_Functions::GiveList
2397   (const Handle(IFSelect_WorkSession)& WS,
2398    const Standard_CString first, const Standard_CString second)
2399 {
2400   return WS->GiveList (first,second);
2401 }
2402
2403
2404 //  Function which returns an EVALUATED DISPATCH
2405 //   (could be added in WorkSession.cdl ...)
2406 //  Two modes : returns dispatch as it is, or return with edition
2407 //  Dispatch Name can be : an immediate name of already recorded Dispatch
2408 //  Or a name of dispatch + a parameter :  dispatch-name(param-value)
2409 //  According to type of Dispatch : integer , signature name
2410
2411 Handle(IFSelect_Dispatch)  IFSelect_Functions::GiveDispatch
2412   (const Handle(IFSelect_WorkSession)& WS,
2413    const Standard_CString name, const Standard_Boolean mode)
2414 {
2415   DeclareAndCast(IFSelect_Dispatch,disp,WS->NamedItem(name));
2416   if (!disp.IsNull()) return disp;    // OK as it is given
2417
2418 //   Else, let s try special cases
2419   TCollection_AsciiString nam(name);
2420   Standard_Integer paro = nam.Location(1,'(',1,nam.Length());
2421   Standard_Integer parf = nam.Location(1,')',1,nam.Length());
2422   nam.SetValue(paro,'\0'); nam.SetValue(parf,'\0');
2423   if (paro <= 0 &&parf <= 0) return disp;
2424   disp = GetCasted(IFSelect_Dispatch,WS->NamedItem(nam.ToCString()));
2425   if (disp.IsNull()) return disp;     // KO anyway
2426
2427 //  According to the type of dispatch :
2428   Handle(Message_Messenger) sout = Message::DefaultMessenger();
2429   DeclareAndCast(IFSelect_DispPerCount,dc,disp);
2430   if (!dc.IsNull()) {
2431     Standard_Integer nb = atoi( &(nam.ToCString())[paro]);
2432     if (nb <= 0) {
2433       sout<<" DispPerCount, count is not positive"<<endl;
2434       disp.Nullify();
2435       return disp;
2436     }
2437     if (mode) {
2438       Handle(IFSelect_IntParam) val = new IFSelect_IntParam;
2439       val->SetValue(nb);
2440       dc->SetCount (val);
2441     }
2442     return dc;
2443   }
2444   DeclareAndCast(IFSelect_DispPerFiles,dp,disp);
2445   if (!dp.IsNull()) {
2446     Standard_Integer nb = atoi( &(nam.ToCString())[paro]);
2447     if (nb <= 0) {
2448       sout<<" DispPerFiles, count is not positive"<<endl;
2449       disp.Nullify();
2450       return disp;
2451     }
2452     if (mode) {
2453       Handle(IFSelect_IntParam) val = new IFSelect_IntParam;
2454       val->SetValue(nb);
2455       dp->SetCount (val);
2456     }
2457     return dp;
2458   }
2459   DeclareAndCast(IFSelect_DispPerSignature,ds,disp);
2460   if (!ds.IsNull()) {
2461     DeclareAndCast(IFSelect_Signature,sg,WS->NamedItem( &(nam.ToCString())[paro]));
2462     if (sg.IsNull()) {
2463       sout<<"DispPerSignature "<<nam<<" , Signature not valid : "<<&(nam.ToCString())[paro]<<endl;
2464       disp.Nullify();
2465       return disp;
2466     }
2467     if (mode) ds->SetSignCounter (new IFSelect_SignCounter(sg));
2468     return ds;
2469   }
2470   sout<<"Dispatch : "<<name<<" , Parameter : "<<&(nam.ToCString())[paro]<<endl;
2471   return disp;
2472 }
2473
2474
2475 //  #########################################
2476 //  ####    INITIALISATIONS              ####
2477 //  #########################################
2478
2479 static int initactor = 0;
2480
2481
2482     void  IFSelect_Functions::Init ()
2483 {
2484   if (initactor) return;  initactor = 1;
2485   IFSelect_Act::SetGroup("DE: General");
2486   IFSelect_Act::AddFunc("xstatus","Lists XSTEP Status : Version, System Name ...",funstatus);
2487   IFSelect_Act::AddFunc("handler","Toggle status catch Handler Error of the session",fun1);
2488   IFSelect_Act::AddFunc("xtrace",". -> stdout or file:string or level:integer  -> File/Level Trace XSTEP",fun2);
2489   IFSelect_Act::AddFunc("xload","file:string  : Read File -> Load Model",fun3);
2490 // IFSelect_Act::AddFunc("load","file:string  : Read File -> Load Model",fun3);
2491   IFSelect_Act::AddFunc("xread","file:string  : Read File -> Load Model",fun3);
2492   IFSelect_Act::AddFunc("whatfile"," -> analyses a file (specific per norm)",fun_whatfile);
2493   IFSelect_Act::AddFunc("writeall","file:string  : Write all model (no split)",fun4);
2494   IFSelect_Act::AddFunc("writesel","file:string sel:Selection : Write Selected (no split)",fun5);
2495   IFSelect_Act::AddFunc("writeent","file:string  n1ent n2ent...:integer : Write Entite(s) (no split)",fun6);
2496   IFSelect_Act::AddFunc("writent", "file:string  n1ent n2ent...:integer : Write Entite(s) (no split)",fun6);
2497   IFSelect_Act::AddFunc("elabel","nument:integer   : Displays Label Model of an entity",fun7);
2498   IFSelect_Act::AddFunc("enum","label:string  : Displays entities n0.s of which Label Model ends by..",fun8);
2499
2500   IFSelect_Act::AddFunc("listtypes","List nb entities per type. Optional selection name  else all model",fun9);
2501   IFSelect_Act::AddFunc("count","Count : counter [selection]",funcount);
2502   IFSelect_Act::AddFunc("listcount","List Counted : counter [selection [nument]]",funcount);
2503   IFSelect_Act::AddFunc("sumcount","Summary Counted : counter [selection [nument]]",funcount);
2504   IFSelect_Act::AddFunc("signtype","Sign Type [newone]",funsigntype);
2505   IFSelect_Act::AddFunc("signcase","signature : displays possible cases",funsigncase);
2506
2507   IFSelect_Act::AddFunc("estatus","ent/nument : displays status of an entity",fun10);
2508   IFSelect_Act::AddFunc("data","Data (DumpModel); whole help : data tout court",fun11);
2509   IFSelect_Act::AddFunc("entity","give n0 ou id of entity [+ level]",fundumpent);
2510   IFSelect_Act::AddFunc("signature","signature name + n0/ident entity",funsign);
2511   IFSelect_Act::AddFunc("queryparent"," give 2 n0s/labels of entities : dad son",funqp);
2512
2513   IFSelect_Act::AddFunc("dumpshare","Dump Share (dispatches, IntParams)",fun12);
2514   IFSelect_Act::AddFunc("listitems","List Items [label else all]  ->Type,Label[,Name]",fun13);
2515   IFSelect_Act::AddFSet("integer","value:integer : cree un IntParam",fun14);
2516   IFSelect_Act::AddFunc("setint","name:IntParam   newValue:integer  : Change valeur IntParam",fun15);
2517   IFSelect_Act::AddFSet("text","value:string  : cree un TextParam",fun16);
2518   IFSelect_Act::AddFunc("settext","Name:TextParam  newValue:string   : Change valeur TextParam",fun17);
2519   IFSelect_Act::AddFunc("dumpsel","Dump Selection suivi du Nom de la Selection a dumper",fun19);
2520   IFSelect_Act::AddFunc("evalsel","name:Selection [num/sel]  : Evalue une Selection",fun20);
2521   IFSelect_Act::AddFunc("givelist","num/sel [num/sel ...]  : Evaluates GiveList",fun20);
2522   IFSelect_Act::AddFunc("giveshort","num/sel [num/sel ...]  : GiveList in short form",fun20);
2523   IFSelect_Act::AddFunc("givepointed","num/sel [num/sel ...]  : GiveList to fill a SelectPointed",fun20);
2524   IFSelect_Act::AddFunc("makelist","listname [givelist] : Makes a List(SelectPointed) from GiveList",fun20);
2525   IFSelect_Act::AddFunc("givecount","num/sel [num/sel ...]  : Counts GiveList",fun20c);
2526   IFSelect_Act::AddFSet("selsuite","sel sel ...  : Creates a SelectSuite",funselsuite);
2527   IFSelect_Act::AddFunc("clearitems","Clears all items (selections, dispatches, etc)",fun21);
2528   IFSelect_Act::AddFunc("cleardata","mode:a-g-c-p  : Clears all or some data (model, check...)",fun22);
2529
2530   IFSelect_Act::AddFunc("itemlabel","xxx xxx : liste items having this label",fun24);
2531   IFSelect_Act::AddFunc("xsave","filename:string  : sauve items-session",fun25);
2532   IFSelect_Act::AddFunc("xrestore","filename:string  : restaure items-session",fun26);
2533   IFSelect_Act::AddFunc("param","nompar:string : displays parameter value; + nompar val : changes it",fun27);
2534   IFSelect_Act::AddFunc("defparam","nompar:string : display def. param; also : nompar edit, nompar init",fun28);
2535
2536   IFSelect_Act::AddFunc("sentfiles","Lists files sent from last Load",fun29);
2537   IFSelect_Act::AddFunc("fileprefix","prefix:string    : definit File Prefix",fun30);
2538   IFSelect_Act::AddFunc("fileext","extent:string    : definit File Extension",fun31);
2539   IFSelect_Act::AddFunc("fileroot","disp:Dispatch  root:string  : definit File Root sur un Dispatch",fun32);
2540   IFSelect_Act::AddFunc("filedef","defroot:string   : definit File DefaultRoot",fun33);
2541   IFSelect_Act::AddFunc("evalfile","Evaluation du FileNaming et memorisation",fun34);
2542   IFSelect_Act::AddFunc("clearfile","Efface la liste d'EvalFile",fun35);
2543   IFSelect_Act::AddFunc("xsplit","[disp:Dispatch  sinon tout]  : Split, la grande affaire !",fun36);
2544   IFSelect_Act::AddFunc("remaining","options... : Remaining Entities, help complet par  remaining ?",fun37);
2545   IFSelect_Act::AddFunc("setcontent","sel:Selection mode:k ou r  : Restreint contenu du modele",fun38);
2546
2547   IFSelect_Act::AddFunc("listmodif","List Final Modifiers",fun40);
2548   IFSelect_Act::AddFunc("dumpmodif","modif:Modifier  : Affiche le Statut d'un Modifier",fun41);
2549   IFSelect_Act::AddFunc("modifsel","modif:Modifier [sel:Selection]  : Change/Annule Selection de Modifier",fun42);
2550   IFSelect_Act::AddFunc("setapplied","modif:Modifier [name:un item sinon sortie fichier]  : Applique un Modifier",fun43);
2551   IFSelect_Act::AddFunc("resetapplied","modif:Modifier  : Enleve un Modifier de la sortie fichier",fun44);
2552   IFSelect_Act::AddFunc("modifmove","modif:Modifier M(model)/F(file) avant,apres:integer  : Deplace un Modifier (sortie fichier)",fun45);
2553
2554   IFSelect_Act::AddFunc("dispsel","disp:Dispatch sel:Selection  -> Selection Finale de Dispatch",fun51);
2555   IFSelect_Act::AddFSet("dispone","cree DispPerOne",fun_dispone);
2556   IFSelect_Act::AddFSet("dispglob","cree DispGlobal",fun_dispglob);
2557   IFSelect_Act::AddFSet("dispcount","count:IntParam  : cree DispPerCount",fun_dispcount);
2558   IFSelect_Act::AddFSet("dispfile","files:IntParam  : cree DispPerFiles",fun_dispfiles);
2559   IFSelect_Act::AddFSet("dispsign","sign:Signature  : cree DispPerSignature",fun_dispsign);
2560   IFSelect_Act::AddFunc("dumpdisp","disp:Dispatch   : Affiche le Statut d'un Dispatch",fun56);
2561
2562   IFSelect_Act::AddFunc("xremove","nom  : Remove a Control Item de la Session",fun57);
2563   IFSelect_Act::AddFunc("evaldisp","mode=[0-3]  disp:Dispatch  : Evaluates one or more Dispatch(es)",fun58);
2564   IFSelect_Act::AddFunc("evaladisp","mode=[0-3]  disp:Dispatch [givelist]  : Evaluates a Dispatch (on a GiveList)",fun_evaladisp);
2565   IFSelect_Act::AddFunc("writedisp","filepattern  disp:Dispatch [givelist]  : Writes Entities by Splitting by a Dispatch",fun_writedisp);
2566   IFSelect_Act::AddFunc("evalcomplete","Evaluation Complete de la Repartition",fun59);
2567
2568   IFSelect_Act::AddFunc("runcheck","affiche LastRunCheckList (write,modif)",fun60);
2569   IFSelect_Act::AddFunc("runtranformer","transf:Transformer  : Applique un Transformer",fun61);
2570   IFSelect_Act::AddFSet("copy","cree TransformStandard, option Copy, vide",fun62);
2571   IFSelect_Act::AddFSet("onthespot","cree TransformStandard, option OntheSpot, vide",fun63);
2572   IFSelect_Act::AddFunc("runcopy","modif:ModelModifier [givelist] : Run <modif> via TransformStandard option Copy",fun6465);
2573   IFSelect_Act::AddFunc("runonthespot","modif:ModelModifier [givelist] : Run <modif> via TransformStandard option OnTheSpot",fun6465);
2574   IFSelect_Act::AddFSet("reorder","[f ou t] reordonne le modele",fun66);
2575
2576   IFSelect_Act::AddFunc("toggle","sel:Selection genre Extract  : Toggle Direct/Reverse",fun70);
2577   IFSelect_Act::AddFunc("input","sel:Selection genre Deduct ou Extract  input:Selection  : Set Input",fun71);
2578   IFSelect_Act::AddFSet("modelroots","cree SelectModelRoots",fun72);
2579   IFSelect_Act::AddFSet("range","options... : cree SelectRange ...; tout court pour help",fun73);
2580   IFSelect_Act::AddFSet("roots","cree SelectRoots (local roots)",fun74);
2581   IFSelect_Act::AddFSet("shared","cree SelectShared",fun75);
2582   IFSelect_Act::AddFSet("diff","[main:Selection diff:Selection]  : cree SelectDiff",fun76);
2583   IFSelect_Act::AddFunc("selmain","sel:Selection genre Control  main:Selection  : Set Main Input",fun77);
2584   IFSelect_Act::AddFunc("selsecond","sel:Selection genre Control  sec:Selection   : Set Second Input",fun78);
2585   IFSelect_Act::AddFSet("modelall","cree SelectModelAll",fun79);
2586   IFSelect_Act::AddFunc("seladd","sel:Selection genre Combine  input:Selection  : Add Selection",fun80);
2587   IFSelect_Act::AddFunc("selrem","sel:Selection genre Combine  input:Selection  : Remove Selection",fun81);
2588   IFSelect_Act::AddFSet("number","num:IntParam  : Cree SelectEntityNumber",fun82);
2589
2590   IFSelect_Act::AddFSet("union","cree SelectUnion (vide), cf aussi combadd, combrem",fun83);
2591   IFSelect_Act::AddFSet("intersect","cree SelectIntersection (vide), cf aussi combadd, combrem",fun84);
2592   IFSelect_Act::AddFSet("typexact","type:string  : cree SelectTextType Exact",fun85);
2593   IFSelect_Act::AddFSet("errors","cree SelectErrorEntities (from file)",fun86);
2594   IFSelect_Act::AddFSet("unknown","cree SelectUnknownEntities",fun87);
2595   IFSelect_Act::AddFSet("sharing","cree SelectSharing",fun88);
2596   IFSelect_Act::AddFSet("typecontain","type:string  : cree SelectTextType Contains",fun89);
2597   IFSelect_Act::AddFSet("pointed","cree SelectPointed [num/sel num/sel]",fun90);
2598   IFSelect_Act::AddFunc("setpointed","sel:SelectPointed  : edition SelectPointed. tout court pour help",fun91);
2599   IFSelect_Act::AddFunc("setlist","sel:SelectPointed  : edition SelectPointed. tout court pour help",fun91);
2600   IFSelect_Act::AddFSet("incorrect","cree SelectIncorrectEntities (computed)",fun92);
2601
2602   IFSelect_Act::AddFSet("signsel","sign:Signature|cnt:Counter text:string [e(D)|c] : cree SelectSignature",fun93);
2603   IFSelect_Act::AddFSet("signcounter","sign:Signature : cree SignCounter",fun94);
2604   IFSelect_Act::AddFSet("nbselected","applied:Selection : cree GraphCounter(=NbSelected)",funbselected);
2605
2606   IFSelect_Act::AddFunc("editlist","editor or editform : lists defs + values",fun_editlist);
2607   IFSelect_Act::AddFunc("editvalue","editform paramname [newval or .] : lists-changes a value",fun_editvalue);
2608   IFSelect_Act::AddFunc("editclear","editform [paramname] : clears edition on all or one param",fun_editclear);
2609   IFSelect_Act::AddFunc("editload","editform [entity-id] : loads from model or an entity",fun_editload);
2610   IFSelect_Act::AddFunc("editapply","editform [keep] : applies on loaded data",fun_editapply);
2611 }