1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
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.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
15 #include <Dico_IteratorOfDictionaryOfInteger.hxx>
16 #include <IFSelect_Act.hxx>
17 #include <IFSelect_CheckCounter.hxx>
18 #include <IFSelect_Functions.hxx>
19 #include <IFSelect_SessionPilot.hxx>
20 #include <Interface_CheckIterator.hxx>
21 #include <Interface_InterfaceModel.hxx>
22 #include <Interface_Macros.hxx>
23 #include <Interface_Static.hxx>
24 #include <Message.hxx>
25 #include <Message_Messenger.hxx>
26 #include <MoniTool_Option.hxx>
27 #include <MoniTool_Profile.hxx>
28 #include <MoniTool_TypedValue.hxx>
29 #include <TCollection_HAsciiString.hxx>
30 #include <TColStd_HSequenceOfAsciiString.hxx>
31 #include <TColStd_HSequenceOfHAsciiString.hxx>
32 #include <TColStd_HSequenceOfTransient.hxx>
33 #include <Transfer_Binder.hxx>
34 #include <Transfer_FinderProcess.hxx>
35 #include <Transfer_IteratorOfProcessForTransient.hxx>
36 #include <Transfer_ResultFromModel.hxx>
37 #include <Transfer_TransferIterator.hxx>
38 #include <Transfer_TransientProcess.hxx>
39 #include <XSControl.hxx>
40 #include <XSControl_Controller.hxx>
41 #include <XSControl_Functions.hxx>
42 #include <XSControl_SelectForTransfer.hxx>
43 #include <XSControl_TransferReader.hxx>
44 #include <XSControl_TransferWriter.hxx>
45 #include <XSControl_WorkSession.hxx>
47 //#include <TransferBRep_ShapeBinder.hxx>
48 //#include <TransferBRep_ShapeListBinder.hxx>
49 //#include <TransferBRep_ShapeMapper.hxx>
50 //#include <TransferBRep_OrientedShapeMapper.hxx>
51 // #######################################################################
57 // #######################################################################
58 //=======================================================================
60 //=======================================================================
61 static IFSelect_ReturnStatus XSControl_xinit(const Handle(IFSelect_SessionPilot)& pilot)
63 Standard_Integer argc = pilot->NbWords();
64 const Standard_CString arg1 = pilot->Arg(1);
66 if (argc > 1) return (XSControl::Session(pilot)->SelectNorm(arg1) ?
67 IFSelect_RetDone : IFSelect_RetFail);
68 Handle(Message_Messenger) sout = Message::DefaultMessenger();
69 sout<<"Selected Norm:"<<XSControl::Session(pilot)->SelectedNorm()<<endl;
70 return IFSelect_RetVoid;
74 //=======================================================================
76 //=======================================================================
77 static IFSelect_ReturnStatus XSControl_xnorm(const Handle(IFSelect_SessionPilot)& pilot)
79 Standard_Integer argc = pilot->NbWords();
80 const Standard_CString arg1 = pilot->Arg(1);
82 Handle(XSControl_WorkSession) WS = XSControl::Session(pilot);
83 Handle(XSControl_Controller) control = WS->NormAdaptor();
84 Handle(Message_Messenger) sout = Message::DefaultMessenger();
86 sout<<"Current Norm. xnorm newnorm [profile] to change , xnorm ? for the list"<<endl;
87 else sout<<"Current Norm :"<<endl;
88 if (control.IsNull()) sout<<"no norm currently defined"<<endl;
90 sout<<" Long Name (complete) : "<<control->Name(Standard_False)<<endl
91 << " Short name (resource) : "<<control->Name(Standard_True)<<endl;
92 if (argc == 1) return IFSelect_RetVoid;
95 sout<<"List of available norms"<<endl;
96 Standard_Integer i,nb;
97 Handle(TColStd_HSequenceOfHAsciiString) norms = XSControl_Controller::ListRecorded(-1);
99 sout<<"Short Proper Names (complete names) : "<<nb<<" :";
100 for (i = 1; i <= nb; i ++) sout<<" "<<norms->Value(i)->ToCString();
102 norms = XSControl_Controller::ListRecorded(1);
103 nb = norms->Length();
104 sout<<"Long Proper Names (resource names) : "<<nb<<" :";
105 for (i = 1; i <= nb; i ++) sout<<" "<<norms->Value(i)->ToCString();
107 norms = XSControl_Controller::ListRecorded(0);
108 nb = norms->Length();
109 sout<<"All Norm Names (short, long and aliases) "<<nb<<" :";
110 for (i = 1; i <= nb; i ++) sout<<" "<<norms->Value(i)->ToCString();
112 sout<<"To change, xnorm newnorm"<<endl;
113 return IFSelect_RetVoid;
116 control = XSControl_Controller::Recorded(arg1);
117 if (control.IsNull()) { sout<<" No norm named : "<<arg1<<endl; return IFSelect_RetError; }
119 WS->SetController(control);
120 sout<<"new norm : "<<control->Name()<<endl;
122 const Standard_CString arg2 = pilot->Arg(2);
123 if (!control->Profile()->SetCurrent (arg2))
124 sout<<"profile could not be set to "<<arg2<<endl;
126 sout<<"current profile : "<<control->Profile()->Current()<<endl;
128 IFSelect_Activator::SetCurrentAlias (WS->SelectedNorm(Standard_True));
129 return IFSelect_RetDone;
134 //=======================================================================
135 //function : xprofile
136 //=======================================================================
137 static IFSelect_ReturnStatus XSControl_xprofile(const Handle(IFSelect_SessionPilot)& pilot)
139 Standard_Integer argc = pilot->NbWords();
140 const Standard_CString arg1 = pilot->Arg(1);
141 // **** xprofile ****
142 Handle(XSControl_WorkSession) WS = XSControl::Session(pilot);
143 Handle(XSControl_Controller) control = WS->NormAdaptor();
144 if (control.IsNull()) return IFSelect_RetFail;
145 Handle(MoniTool_Profile) prof = control->Profile();
146 Handle(Message_Messenger) sout = Message::DefaultMessenger();
147 sout<<"Current Profile : "<<prof->Current().ToCString()<<endl;
150 sout<<"xprofile ? for list of profile confs"<<endl
151 << "xprofile . to apply the current profile (after editing)"<<endl
152 << "xprofile profname to select one and apply it"<<endl
153 << "xprofile profname . to record current profile as profname"<<endl
154 <<" (in followings, profname may be replaced by . for current profile)"<<endl
155 << "xprofile profname ? to list its definition"<<endl
156 << "xprofile profname - to clear it completely"<<endl
157 << "xprofile profname optname casename to edit an option of it"<<endl
158 << "xprofile profname - optname to clear an option from it"<<endl;
159 return IFSelect_RetVoid;
163 if (arg1[0] == '?') {
164 Handle(TColStd_HSequenceOfAsciiString) confs = prof->ConfList();
165 Standard_Integer i, nb = confs->Length();
166 sout<<"List of Available Profile Configurations : "<<nb<<" Items"<<endl;
167 for (i = 1; i <= nb; i ++) sout<<confs->Value(i).ToCString()<<endl;
168 return IFSelect_RetVoid;
169 } else if (arg1[0] == '.' && arg1[1] == '\0') {
170 if (!control->ApplyProfile(WS,".")) {
171 sout<<"Applying current profile has failed"<<endl;
172 return IFSelect_RetFail;
174 return IFSelect_RetDone;
178 if (!control->ApplyProfile(WS,arg1)) {
179 sout<<"Setting "<<arg1<<" as current has failed"<<endl;
180 return IFSelect_RetFail;
182 sout<<"Setting "<<arg1<<" as current"<<endl;
183 return IFSelect_RetDone;
188 const Standard_CString arg2 = pilot->Arg(2);
190 // List the definition of a profile
191 if (arg2[0] == '?') {
192 Handle(TColStd_HSequenceOfAsciiString) opts, cases;
193 prof->SwitchList (arg1,opts,cases);
194 Standard_Integer i,nb = opts->Length();
195 sout<<"Option -- Case -- ("<<nb<<" switches on configuration "<<arg1<<")"<<endl;
196 for (i = 1; i <= nb; i ++) {
197 sout<<opts->Value(i).ToCString()<<" "<<cases->Value(i).ToCString()<<endl;
199 return IFSelect_RetVoid;
202 } else if (arg2[0] == '-' && arg2[1] == '\0') {
203 if (!prof->ClearConf(arg1)) {
204 sout<<"Clearing profile "<<arg2<<" has failed"<<endl;
205 return IFSelect_RetFail;
207 return IFSelect_RetDone;
209 // Merge Profile arg2 to arg1
211 if (!prof->HasConf (arg1)) prof->AddConf (arg1);
212 if (!prof->AddFromOtherConf (arg1,arg2)) {
213 sout<<"Merging profile "<<arg2<<" to "<<arg1<<" has failed"<<endl;
214 return IFSelect_RetFail;
216 return IFSelect_RetDone;
220 // Editing / Adding a switch in a profile
222 const Standard_CString arg2 = pilot->Arg(2);
223 const Standard_CString arg3 = pilot->Arg(3);
226 if (arg2[0] == '-' && arg2[1] == '\0') {
227 if (!prof->RemoveSwitch (arg1,arg3)) {
228 sout<<"Removing switch on option "<<arg3<<" in profile "<<arg1<<" has failed"<<endl;
229 return IFSelect_RetFail;
231 sout<<"Edition of profile "<<arg1<<" done. To apply it : xprofile "<<arg1<<endl;
232 return IFSelect_RetDone;
236 if (!prof->AddSwitch (arg1,arg2,arg3)) {
237 sout<<"Setting profile "<<arg1<<" for option "<<arg2<<" to case "<<arg3<<" has failed"<<endl;
238 return IFSelect_RetFail;
240 sout<<"Edition of profile "<<arg1<<" done. To apply it : xprofile "<<arg1<<endl;
241 return IFSelect_RetDone;
245 return IFSelect_RetVoid;
249 //=======================================================================
251 //=======================================================================
252 static IFSelect_ReturnStatus XSControl_xoption(const Handle(IFSelect_SessionPilot)& pilot)
254 Standard_Integer argc = pilot->NbWords();
255 const Standard_CString arg1 = pilot->Arg(1);
256 const Standard_CString arg2 = pilot->Arg(2);
257 const Standard_CString arg3 = pilot->Arg(3);
259 Handle(XSControl_WorkSession) WS = XSControl::Session(pilot);
260 Handle(XSControl_Controller) control = WS->NormAdaptor();
261 if (control.IsNull()) return IFSelect_RetFail;
262 Handle(MoniTool_Profile) prof = control->Profile();
263 Handle(Message_Messenger) sout = Message::DefaultMessenger();
264 sout<<"Current Profile : "<<prof->Current().ToCString()<<endl;
267 sout<<"xoption anopt : query an option"<<endl
268 << "xoption anopt newcase : switch (basic definition)"
269 <<" (but is superseded by current configuration)"<<endl
270 <<"xoption + optname [param] : create an option on a parameter"<<endl
271 <<" (param absent is taken param=optname)"
272 <<"xoption anopt + casename [value] : add a case for a parameter"<<endl
273 <<" (value absent is taken value=casename)"<<endl;
275 Handle(TColStd_HSequenceOfAsciiString) optlist = prof->OptionList();
276 Standard_Integer iopt, nbopt = optlist->Length();
277 sout<<"Total : "<<nbopt<<" Options"<<endl;
278 for (iopt = 1; iopt <= nbopt; iopt ++) {
279 TCollection_AsciiString optname = optlist->Value(iopt);
280 Handle(MoniTool_Option) opt = prof->Option (optname.ToCString());
281 sout<<optname.ToCString()<<" : "<<opt->CaseName()<<endl;
283 return IFSelect_RetVoid;
286 // xoption optname : description
289 Handle(MoniTool_Option) opt = prof->Option (arg1);
290 if (opt.IsNull()) { sout<<"Not a recorded Option : "<<arg1<<endl; return IFSelect_RetError; }
292 // On va lister les valeurs admises
293 Handle(TColStd_HSequenceOfAsciiString) caselist = opt->ItemList();
294 Standard_Integer icase, nbcase = caselist->Length();
295 Handle(MoniTool_TypedValue) tv = opt->TypedValue();
296 if (tv.IsNull()) sout<<"Option : "<<arg1<<" Type : "<<opt->Type()->Name();
297 else sout<<"Option : "<<arg1<<" TypedValue. Name : "<<tv->Name()<<endl<<" Definition : "<<tv->Definition();
299 sout<<endl<<" Current Case (basic) : "<<opt->CaseName()<<" Total : "<<nbcase<<" Cases :"<<endl;
300 for (icase = 1; icase <= nbcase; icase ++) {
301 const TCollection_AsciiString& acase = caselist->Value(icase);
302 sout<<acase.ToCString();
305 Handle(TColStd_HSequenceOfAsciiString) aliases = opt->Aliases(acase.ToCString());
306 Standard_Integer ial, nbal = (aliases.IsNull() ? 0 : aliases->Length());
307 if (nbal > 0) sout<<" - Alias:";
308 for (ial = 1; ial <= nbal; ial ++) sout<<" "<<aliases->Value(ial);
310 // TypedValue : on peut afficher la valeur
311 Handle(Standard_Transient) str;
312 opt->Item (acase.ToCString(),str);
313 if (!str.IsNull()) sout<<" - Value:"<< Handle(TCollection_HAsciiString)::DownCast(str)->ToCString();
318 return IFSelect_RetVoid;
321 // xoption + optname [paramname]
322 if (argc >= 3 && arg1[0] == '+' && arg1[1] == '\0') {
323 Standard_CString parname = pilot->Arg(argc-1);
324 Handle(Interface_Static) param = Interface_Static::Static(parname);
325 if (param.IsNull()) { sout<<"No static parameter is named "<<parname<<endl;
326 return IFSelect_RetError; }
327 const Handle(MoniTool_TypedValue)& aparam = param; // to avoid ambiguity
328 Handle(MoniTool_Option) opt = new MoniTool_Option(aparam,arg2);
329 prof->AddOption (opt);
330 return IFSelect_RetDone;
333 // xoption optname + case [val]
334 if (argc >= 4 && arg2[0] == '+' && arg2[1] == '\0') {
335 Handle(MoniTool_Option) opt = prof->Option (arg1);
336 if (opt.IsNull()) { sout<<"Not a recorded Option : "<<arg1<<endl; return IFSelect_RetError; }
337 Handle(MoniTool_TypedValue) tv = opt->TypedValue();
338 if (tv.IsNull()) { sout<<"Option not for a Parameter : "<<arg1<<endl; return IFSelect_RetError; }
339 Standard_CString valname = pilot->Arg(argc-1);
340 if (!opt->AddBasic (arg3,valname)) {
341 sout<<"Option "<<arg1<<" : not an allowed value : "<<valname<<endl;
342 return IFSelect_RetError;
344 return IFSelect_RetDone;
347 // xoption optname newcase : edition
349 Handle(MoniTool_Option) opt = prof->Option (arg1);
350 if (opt.IsNull()) { sout<<"Not a recorded Option : "<<arg1<<endl; return IFSelect_RetError; }
351 if (!opt->Switch (arg2)) {
352 sout<<"Option : "<<arg1<<" , Not a suitable case : "<<arg2<<endl;
353 return IFSelect_RetFail;
355 sout<<"Option : "<<arg1<<" switched to case : "<<arg2<<endl;
356 return IFSelect_RetDone;
360 return IFSelect_RetVoid;
364 //=======================================================================
365 //function : newmodel
366 //=======================================================================
367 static IFSelect_ReturnStatus XSControl_newmodel(const Handle(IFSelect_SessionPilot)& pilot)
369 // **** newmodel ****
370 if (!XSControl::Session(pilot)->NewModel().IsNull()) return IFSelect_RetDone;
371 Handle(Message_Messenger) sout = Message::DefaultMessenger();
372 sout<<"No new Model produced"<<endl;
373 return IFSelect_RetFail;
377 //=======================================================================
379 //=======================================================================
380 static IFSelect_ReturnStatus XSControl_tpclear(const Handle(IFSelect_SessionPilot)& pilot)
382 // **** tpclear/twclear ****
383 Standard_Boolean modew = Standard_False;
384 if (pilot->Word(0).Value(2) == 'w') modew = Standard_True;
385 Handle(Transfer_FinderProcess) FP = XSControl::Session(pilot)->MapWriter();
386 Handle(Transfer_TransientProcess) TP = XSControl::Session(pilot)->MapReader();
387 Handle(Message_Messenger) sout = Message::DefaultMessenger();
388 if ( modew) { if(!FP.IsNull()) FP->Clear(); else sout<<"No Transfer Write"<<endl; }
389 else { if(!TP.IsNull()) TP->Clear(); else sout<<"No Transfer Read"<<endl; }
390 return IFSelect_RetDone;
394 //=======================================================================
396 //=======================================================================
397 static IFSelect_ReturnStatus XSControl_tpstat(const Handle(IFSelect_SessionPilot)& pilot)
399 Standard_Integer argc = pilot->NbWords();
400 const Standard_CString arg1 = pilot->Arg(1);
401 //const Standard_CString arg2 = pilot->Arg(2);
402 Handle(Transfer_TransientProcess) TP= XSControl::Session(pilot)->MapReader();
403 Handle(Message_Messenger) sout = Message::DefaultMessenger();
404 if (TP.IsNull()) { sout<<"No Transfer Read"<<endl; return IFSelect_RetError;}
407 Standard_Integer mod1 = -1;
408 Standard_Integer mod2 = 0;
409 // g : general c : check (compte) C (liste) f : fails(compte) F (liste)
410 // resultats racines : n : n0s entites s : status b : binders
411 // t : compte par type r : compte par resultat l : liste(type-resultat)
412 // *n *s *b *t *r *l : idem sur tout
413 // ?n etc.. : idem sur resultats anormaux
414 // ? tout court pour help
417 char a2 = arg1[1]; if (a2 == '\0') a2 = '!';
419 case 'g' : mod1 = 0; break;
420 case 'c' : mod1 = 4; mod2 = 4; break;
421 case 'C' : mod1 = 4; mod2 = 2; break;
422 case 'f' : mod1 = 5; mod2 = 4; break;
423 case 'F' : mod1 = 5; mod2 = 2; break;
424 case '*' : mod1 = 2; break;
425 case '?' : mod1 = 3; break;
426 default : mod1 = 1; if (argc > 2) mod1 = 2; a2 = arg1[0]; break;
428 if (mod1 < 1 || mod1 > 3) a2 = '!';
430 case 'n' : mod2 = 0; break;
431 case 's' : mod2 = 1; break;
432 case 'b' : mod2 = 2; break;
433 case 't' : mod2 = 3; break;
434 case 'r' : mod2 = 4; break;
435 case 'l' : mod2 = 5; break;
436 case 'L' : mod2 = 6; break;
438 case '?' : mod1 = -1; break;
439 default : mod1 = -2; break;
442 // A present help eventuel
443 if (mod1 < -1) sout<<"Unknown Mode"<<endl;
445 sout<<"Modes available :\n"
446 <<"g : general c : checks (count) C (list)\n"
447 <<" f : fails (count) F (list)\n"
448 <<" n : numbers of transferred entities (on TRANSFER ROOTS)\n"
449 <<" s : their status (type entity-result , presence checks)\n"
450 <<" b : detail of binders\n"
451 <<" t : count per entity type r : per type/status result\n"
452 <<" l : count per couple type entity/result\n"
453 <<" L : list per couple type entity/result\n"
454 <<" *n *s *b *t *r *l *L : idem on ALL recorded items\n"
455 <<" ?n ?s ?b ?t ... : idem on abnormal items\n"
456 <<" n select : n applied on a selection idem for s b t r l"<<endl;
457 if (mod1 < -1) return IFSelect_RetError;
458 return IFSelect_RetVoid;
462 sout<<"TransferRead :";
463 if (TP->Model() != pilot->Session()->Model()) sout<<"Model differs from the session";
464 Handle(TColStd_HSequenceOfTransient) list =
465 IFSelect_Functions::GiveList(pilot->Session(),pilot->CommandPart(2));
466 XSControl_TransferReader::PrintStatsOnList (TP,list,mod1,mod2);
467 // TP->PrintStats (1,sout);
469 else sout<<"TransferRead : not defined"<<endl;
470 return IFSelect_RetVoid;
474 //=======================================================================
476 //=======================================================================
477 static IFSelect_ReturnStatus XSControl_tpent(const Handle(IFSelect_SessionPilot)& pilot)
479 Standard_Integer argc = pilot->NbWords();
480 const Standard_CString arg1 = pilot->Arg(1);
481 Handle(Transfer_TransientProcess) TP= XSControl::Session(pilot)->MapReader();
483 Handle(Message_Messenger) sout = Message::DefaultMessenger();
484 if (TP.IsNull()) { sout<<"No Transfer Read"<<endl; return IFSelect_RetError;}
485 Handle(Interface_InterfaceModel) model = TP->Model();
486 if (model.IsNull()) return IFSelect_RetFail;
488 if (argc < 2) { sout<<"Give ENTITY NUMBER (IN MODEL TransferProcess)"<<endl; return IFSelect_RetError; }
489 Standard_Integer num = atoi(arg1);
490 if (num <= 0 || num > model->NbEntities()) { sout<<"Number not in [1 - "<<model->NbEntities()<<"]"<<endl; return IFSelect_RetError; }
491 Handle(Standard_Transient) ent = model->Value(num);
492 Standard_Integer index = TP->MapIndex (ent);
493 if (index == 0) sout<<"Entity "<<num<<" not recorded in transfer"<<endl;
494 else XSControl::Session(pilot)->PrintTransferStatus (index,Standard_False,sout);
495 return IFSelect_RetVoid;
499 //=======================================================================
501 //=======================================================================
502 static IFSelect_ReturnStatus XSControl_tpitem(const Handle(IFSelect_SessionPilot)& pilot)
504 Standard_Integer argc = pilot->NbWords();
505 const Standard_CString arg1 = pilot->Arg(1);
506 // **** tpitem/tproot/twitem/twroot ****
507 Handle(Message_Messenger) sout = Message::DefaultMessenger();
508 if (argc < 2) { sout<<"Give ITEM NUMBER (in TransferProcess)"<<endl; return IFSelect_RetError; }
509 Standard_Integer num = atoi(arg1);
510 if (pilot->Word(0).Value(3) == 'r') num = -num;
511 Standard_Boolean modew = Standard_False;
512 if (pilot->Word(0).Value(2) == 'w') modew = Standard_True;
513 Handle(Transfer_Binder) binder;
514 Handle(Transfer_Finder) finder;
515 Handle(Standard_Transient) ent;
516 if (!XSControl::Session(pilot)->PrintTransferStatus(num,modew,sout))
517 sout<<" - Num="<<num<<" incorrect"<<endl;
518 return IFSelect_RetVoid;
522 //=======================================================================
524 //=======================================================================
525 static IFSelect_ReturnStatus XSControl_tpatr(const Handle(IFSelect_SessionPilot)& /*pilot*/)
528 Standard_Integer argc = pilot->NbWords();
529 const Standard_CString arg1 = pilot->Arg(1);
530 Handle(XSControl_WorkSession) WS = XSControl::Session(pilot);
531 Handle(Transfer_TransientProcess) TP = WS->MapReader();
533 Handle(Message_Messenger) sout = Message::DefaultMessenger();
534 // tpatr tout court : liste tous les attributs
535 // tpatr nomatr : sur cet attribut, liste les valeurs par entite
538 Handle(Dico_DictionaryOfInteger) list = TP->Attributes();
539 for (Dico_IteratorOfDictionaryOfInteger iter(list); iter.More(); iter.Next()) {
540 TCollection_AsciiString name = iter.Name();
541 Standard_Integer nbatr = iter.Value();
542 Interface_ParamType aty = TP->AttributeType (name.ToCString());
543 sout<<"Name : "<<name<<" Count="<<nbatr<<" Type : ";
545 case Interface_ParamInteger : sout<<"Integer"; break;
546 case Interface_ParamReal : sout<<"Real"; break;
547 case Interface_ParamIdent : sout<<"Object"; break;
548 case Interface_ParamText : sout<<"String"; break;
549 default : sout<<"(Mixed)";
557 Standard_Integer num , nb = 0;
558 sout<<"Attribute Name : "<<arg1<<endl;
559 for (num = TP->NextItemWithAttribute(arg1,0); num > 0;
560 num = TP->NextItemWithAttribute(arg1,num)) {
562 sout<<"Item "<<num<<" , Entity ";
563 WS->Model()->Print(TP->Mapped(num),sout);
564 Handle(Transfer_Binder) bnd = TP->MapItem (num);
565 Interface_ParamType aty = bnd->AttributeType(arg1);
567 case Interface_ParamInteger : sout<<" Integer="<<bnd->IntegerAttribute(arg1); break;
568 case Interface_ParamReal : sout<<" Real="<<bnd->RealAttribute(arg1); break;
569 case Interface_ParamIdent : sout<<" Object,Type:"<<bnd->Attribute(arg1)->DynamicType()->Name(); break;
570 case Interface_ParamText : sout<<" String="<<bnd->StringAttribute(arg1);
571 default : sout<<"(none)"; break;
575 sout<<"Attribute Name : "<<arg1<<" on "<<nb<<" Items"<<endl;
579 return IFSelect_RetVoid;
583 //=======================================================================
585 //=======================================================================
586 static IFSelect_ReturnStatus XSControl_trecord(const Handle(IFSelect_SessionPilot)& pilot)
588 Standard_Integer argc = pilot->NbWords();
589 const Standard_CString arg1 = pilot->Arg(1);
590 Handle(Transfer_TransientProcess) TP = XSControl::Session(pilot)->MapReader();
591 // **** trecord : TransferReader ****
592 Standard_Boolean tous = (argc == 1);
593 Standard_Integer num = -1;
594 Handle(Interface_InterfaceModel) mdl = XSControl::Session(pilot)->Model();
595 Handle(XSControl_TransferReader) TR = XSControl::Session(pilot)->TransferReader();
596 Handle(Standard_Transient) ent;
597 Handle(Message_Messenger) sout = Message::DefaultMessenger();
598 if (mdl.IsNull() || TR.IsNull() || TP.IsNull())
599 { sout<<" init not done"<<endl; return IFSelect_RetError; }
600 if (!tous) num = atoi(arg1);
601 // Enregistrer les racines
603 Standard_Integer nb = TP->NbRoots();
604 sout<<" Recording "<<nb<<" Roots"<<endl;
605 for (Standard_Integer i = 1; i <= nb; i ++) {
607 if (TR->RecordResult (ent)) sout<<" Root n0."<<i<<endl;
608 else sout<<" Root n0."<<i<<" not recorded"<<endl;
611 if (num < 1 || num > mdl->NbEntities()) sout<<"incorrect number:"<<num<<endl;
612 else if (TR->RecordResult(mdl->Value(num))) sout<<" Entity n0."<<num<<endl;
613 else sout<<" Entity n0."<<num<<" not recorded"<<endl;
615 return IFSelect_RetDone;
619 //=======================================================================
621 //=======================================================================
622 static IFSelect_ReturnStatus XSControl_trstat(const Handle(IFSelect_SessionPilot)& pilot)
624 Standard_Integer argc = pilot->NbWords();
625 const Standard_CString arg1 = pilot->Arg(1);
626 Handle(Message_Messenger) sout = Message::DefaultMessenger();
627 // **** trstat : TransferReader ****
628 Handle(XSControl_TransferReader) TR = XSControl::Session(pilot)->TransferReader();
629 if (TR.IsNull()) { sout<<" init not done"<<endl; return IFSelect_RetError; }
630 Handle(Interface_InterfaceModel) mdl = TR->Model();
631 if (mdl.IsNull()) { sout<<" No model"<<endl; return IFSelect_RetError; }
632 sout<<" Statistics : FileName : "<<TR->FileName()<<endl;
635 TR->PrintStats(10,0);
638 Standard_Integer num = atoi(arg1);
639 if (num < 1 || num > mdl->NbEntities()) { sout<<" incorrect number:"<<arg1<<endl; return IFSelect_RetError; }
640 Handle(Standard_Transient) ent = mdl->Value(num);
641 if (!TR->IsRecorded(ent)) { sout<<" Entity "<<num<<" not recorded"<<endl; return IFSelect_RetError; }
642 Handle(Transfer_ResultFromModel) RM = TR->FinalResult(ent);
643 Handle(TColStd_HSequenceOfTransient) list = TR->CheckedList(ent);
644 Standard_Integer i, nb = list->Length();
645 if (nb > 0) sout<<" Entities implied by Check/Result :"<<nb<<" i.e.:";
646 for (i = 1; i <= nb; i ++) { sout<<" "; mdl->Print(list->Value(i),sout); }
648 if (RM.IsNull()) { sout<<" no other info"<<endl; return IFSelect_RetVoid; }
649 Interface_CheckIterator chl = RM->CheckList(Standard_False);
650 pilot->Session()->PrintCheckList(chl,Standard_False,IFSelect_EntitiesByItem);
652 return IFSelect_RetVoid;
656 //=======================================================================
658 //=======================================================================
659 static IFSelect_ReturnStatus XSControl_trbegin(const Handle(IFSelect_SessionPilot)& pilot)
661 // **** trbegin : TransferReader ****
662 Handle(XSControl_TransferReader) TR = XSControl::Session(pilot)->TransferReader();
663 Standard_Boolean init = TR.IsNull();
664 if (pilot->NbWords() > 1) { if (pilot->Arg(1)[0] == 'i') init = Standard_True; }
666 XSControl::Session(pilot)->InitTransferReader (0);
667 TR = XSControl::Session(pilot)->TransferReader();
669 Handle(Message_Messenger) sout = Message::DefaultMessenger();
670 sout<<" init not done or failed"<<endl;
671 return IFSelect_RetError;
675 return IFSelect_RetDone;
679 //=======================================================================
681 //=======================================================================
682 static IFSelect_ReturnStatus XSControl_tread(const Handle(IFSelect_SessionPilot)& pilot)
684 Standard_Integer argc = pilot->NbWords();
685 //const Standard_CString arg1 = pilot->Arg(1);
686 // **** tread : TransferReader ****
687 Handle(Message_Messenger) sout = Message::DefaultMessenger();
688 Handle(XSControl_TransferReader) TR = XSControl::Session(pilot)->TransferReader();
689 if (TR.IsNull()) { sout<<" init not done"<<endl; return IFSelect_RetError; }
690 Handle(Interface_InterfaceModel) mdl = TR->Model();
691 if (mdl.IsNull()) { sout<<" No model"<<endl; return IFSelect_RetError; }
693 // DeclareAndCast(IFSelect_Selection,sel,pilot->Session()->NamedItem("xst-model-roots"));
694 Handle(Standard_Transient) sel = pilot->Session()->NamedItem("xst-model-roots");
695 if (sel.IsNull()) { sout<<"Select Roots absent"<<endl; return IFSelect_RetError; }
696 Handle(TColStd_HSequenceOfTransient) list = pilot->Session()->GiveList(sel);
697 sout<<" Transferring all roots i.e. : "<<TR->TransferList(list)<<endl;
699 Handle(TColStd_HSequenceOfTransient) list =
700 IFSelect_Functions::GiveList(pilot->Session(),pilot->CommandPart(1));
701 sout<<" Transfer of "<<list->Length()<<" entities"<<endl;
702 Standard_Integer nb = TR->TransferList(list);
703 sout<<" Gives "<<nb<<" results"<<endl;
705 return IFSelect_RetDone;
709 //=======================================================================
711 //=======================================================================
712 static IFSelect_ReturnStatus XSControl_trtp(const Handle(IFSelect_SessionPilot)& pilot)
714 // **** TReader -> TProcess ****
715 Handle(XSControl_TransferReader) TR = XSControl::Session(pilot)->TransferReader();
716 Handle(Message_Messenger) sout = Message::DefaultMessenger();
717 if (TR.IsNull()) sout<<" No TransferReader"<<endl;
718 else if (TR->TransientProcess().IsNull()) sout<<" Transfer Reader without Process"<<endl;
719 ////else { XSDRAW::SetTransferProcess(TR->TransientProcess()); return IFSelect_RetDone; }
720 return IFSelect_RetVoid;
724 //=======================================================================
726 //=======================================================================
727 static IFSelect_ReturnStatus XSControl_tptr(const Handle(IFSelect_SessionPilot)& pilot)
729 // **** TProcess -> TReader ****
730 XSControl::Session(pilot)->InitTransferReader (3);
731 return IFSelect_RetDone;
735 //=======================================================================
737 //=======================================================================
738 static IFSelect_ReturnStatus XSControl_twmode(const Handle(IFSelect_SessionPilot)& pilot)
740 Standard_Integer argc = pilot->NbWords();
741 const Standard_CString arg1 = pilot->Arg(1);
743 Handle(XSControl_TransferWriter) TW = XSControl::Session(pilot)->TransferWriter();
744 Handle(XSControl_Controller) control = XSControl::Session(pilot)->NormAdaptor();
745 Standard_Integer modemin,modemax;
746 Handle(Message_Messenger) sout = Message::DefaultMessenger();
747 if (control->ModeWriteBounds (modemin,modemax)) {
748 sout<<"Write Mode : allowed values "<<modemin<<" to "<<modemax<<endl;
749 for (Standard_Integer modd = modemin; modd <= modemax; modd ++) {
750 sout<<modd<<" : "<<control->ModeWriteHelp (modd)<<endl;;
753 sout<<"Write Mode : actual = "<<TW->TransferMode()<<endl;
754 if (argc <= 1) return IFSelect_RetVoid;
755 Standard_Integer mod = atoi(arg1);
756 sout<<"New value -> "<<arg1<<endl;
757 TW->SetTransferMode(mod);
758 if (!control->IsModeWrite (mod)) sout<<"Warning : this new value is not supported"<<endl;
759 return IFSelect_RetDone;
763 //=======================================================================
765 //=======================================================================
766 static IFSelect_ReturnStatus XSControl_twstat(const Handle(IFSelect_SessionPilot)& pilot)
768 //Standard_Integer argc = pilot->NbWords();
769 //const Standard_CString arg1 = pilot->Arg(1);
770 //const Standard_CString arg2 = pilot->Arg(2);
771 Handle(Transfer_FinderProcess) FP = XSControl::Session(pilot)->MapWriter();
774 Handle(Message_Messenger) sout = Message::DefaultMessenger();
776 sout<<"TransferWrite:";
777 // XSControl_TransferWriter::PrintStatsProcess (FP,mod1,mod2);
778 FP->PrintStats (1,sout);
780 else sout<<"TransferWrite: not defined"<<endl;
781 return IFSelect_RetVoid;
785 //=======================================================================
786 //function : settransfert
787 //=======================================================================
788 static IFSelect_ReturnStatus XSControl_settransfert(const Handle(IFSelect_SessionPilot)& pilot)
790 // **** SelectForTransfer ****
791 return pilot->RecordItem(new XSControl_SelectForTransfer(XSControl::Session(pilot)->TransferReader()));
796 static int initactor = 0;
798 //=======================================================================
801 //=======================================================================
803 void XSControl_Functions::Init ()
805 if (initactor) return; initactor = 1;
806 IFSelect_Act::SetGroup("DE: General");
808 IFSelect_Act::AddFunc ("xinit","[norm:string to change norme] reinitialises according to the norm",XSControl_xinit);
809 IFSelect_Act::AddFunc ("xnorm","displays current norm +norm : changes it",XSControl_xnorm);
810 IFSelect_Act::AddFunc ("xprofile","displays current profile +prof : changes it",XSControl_xprofile);
811 IFSelect_Act::AddFunc ("xoption","lists options +opt : lists cases +case : changes current case",XSControl_xoption);
813 IFSelect_Act::AddFunc ("newmodel","produces a new empty model, for the session",XSControl_newmodel);
815 IFSelect_Act::AddFunc ("tpclear","Clears TransferProcess (READ)",XSControl_tpclear);
816 IFSelect_Act::AddFunc ("twclear","Clears TransferProcess (WRITE)",XSControl_tpclear);
818 IFSelect_Act::AddFunc ("tpstat","Statistics on TransferProcess (READ)",XSControl_tpstat);
820 IFSelect_Act::AddFunc ("tpent","[num:integer] Statistics on an entity of the model (READ)",XSControl_tpent);
822 IFSelect_Act::AddFunc ("tpitem","[num:integer] Statistics on ITEM of transfer (READ)" ,XSControl_tpitem);
823 IFSelect_Act::AddFunc ("tproot","[num:integer] Statistics on a ROOT of transfert (READ)" ,XSControl_tpitem);
824 IFSelect_Act::AddFunc ("twitem","[num:integer] Statistics on an ITEM of transfer (WRITE)" ,XSControl_tpitem);
825 IFSelect_Act::AddFunc ("twroot","[num:integer] Statistics on a ROOT of transfer (WRITE)",XSControl_tpitem);
826 IFSelect_Act::AddFunc ("tpatr","[name] List all Attributes, or values for a Name",XSControl_tpatr);
828 IFSelect_Act::AddFunc ("trecord","record : all root results; or num : for entity n0.num",XSControl_trecord);
829 IFSelect_Act::AddFunc ("trstat","general statistics; or num : stats on entity n0 num",XSControl_trstat);
830 IFSelect_Act::AddFunc ("trbegin","begin-transfer-reader [init]",XSControl_trbegin);
831 IFSelect_Act::AddFunc ("tread","transfers all roots, or num|sel|sel num : entity list, by transfer-reader",XSControl_tread);
833 IFSelect_Act::AddFunc ("trtp","feeds commands tp... with results from tr...",XSControl_trtp);
834 IFSelect_Act::AddFunc ("tptr","feeds tr... from tp... (may be incomplete)",XSControl_tptr);
836 IFSelect_Act::AddFunc ("twmode","displays mode transfer write, + num changes it",XSControl_twmode);
837 IFSelect_Act::AddFunc ("twstat","Statistics on TransferProcess (WRITE)",XSControl_twstat);
839 IFSelect_Act::AddFSet ("selecttransfer","selection (recognize from transfer actor)",XSControl_settransfert);