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.
14 #include <XSControl_Functions.ixx>
16 #include <XSControl.hxx>
17 #include <XSControl_Controller.hxx>
18 #include <MoniTool_Profile.hxx>
19 #include <MoniTool_Option.hxx>
20 #include <MoniTool_TypedValue.hxx>
21 #include <Interface_Static.hxx>
22 #include <TColStd_HSequenceOfAsciiString.hxx>
24 #include <XSControl_WorkSession.hxx>
25 #include <IFSelect_Act.hxx>
26 #include <IFSelect_SessionPilot.hxx>
27 #include <IFSelect_Functions.hxx>
28 #include <TCollection_HAsciiString.hxx>
29 #include <TColStd_HSequenceOfHAsciiString.hxx>
31 #include <Interface_InterfaceModel.hxx>
32 #include <Transfer_TransientProcess.hxx>
33 #include <Transfer_FinderProcess.hxx>
34 #include <Transfer_Binder.hxx>
35 #include <Interface_CheckIterator.hxx>
36 #include <IFSelect_CheckCounter.hxx>
37 #include <Transfer_TransferIterator.hxx>
38 #include <Transfer_IteratorOfProcessForTransient.hxx>
40 #include <Dico_IteratorOfDictionaryOfInteger.hxx>
42 //#include <TransferBRep_ShapeBinder.hxx>
43 //#include <TransferBRep_ShapeListBinder.hxx>
44 //#include <TransferBRep_ShapeMapper.hxx>
45 //#include <TransferBRep_OrientedShapeMapper.hxx>
47 #include <XSControl_TransferWriter.hxx>
48 #include <XSControl_TransferReader.hxx>
49 #include <TColStd_HSequenceOfTransient.hxx>
50 #include <Transfer_ResultFromModel.hxx>
51 #include <XSControl_SelectForTransfer.hxx>
53 #include <Interface_Macros.hxx>
54 #include <Message_Messenger.hxx>
55 #include <Message.hxx>
57 // #######################################################################
63 // #######################################################################
66 //=======================================================================
68 //=======================================================================
69 static IFSelect_ReturnStatus XSControl_xinit(const Handle(IFSelect_SessionPilot)& pilot)
71 Standard_Integer argc = pilot->NbWords();
72 const Standard_CString arg1 = pilot->Arg(1);
74 if (argc > 1) return (XSControl::Session(pilot)->SelectNorm(arg1) ?
75 IFSelect_RetDone : IFSelect_RetFail);
76 Handle(Message_Messenger) sout = Message::DefaultMessenger();
77 sout<<"Selected Norm:"<<XSControl::Session(pilot)->SelectedNorm()<<endl;
78 return IFSelect_RetVoid;
82 //=======================================================================
84 //=======================================================================
85 static IFSelect_ReturnStatus XSControl_xnorm(const Handle(IFSelect_SessionPilot)& pilot)
87 Standard_Integer argc = pilot->NbWords();
88 const Standard_CString arg1 = pilot->Arg(1);
90 Handle(XSControl_WorkSession) WS = XSControl::Session(pilot);
91 Handle(XSControl_Controller) control = WS->NormAdaptor();
92 Handle(Message_Messenger) sout = Message::DefaultMessenger();
94 sout<<"Current Norm. xnorm newnorm [profile] to change , xnorm ? for the list"<<endl;
95 else sout<<"Current Norm :"<<endl;
96 if (control.IsNull()) sout<<"no norm currently defined"<<endl;
98 sout<<" Long Name (complete) : "<<control->Name(Standard_False)<<endl
99 << " Short name (resource) : "<<control->Name(Standard_True)<<endl;
100 if (argc == 1) return IFSelect_RetVoid;
102 if (arg1[0] == '?') {
103 sout<<"List of available norms"<<endl;
104 Standard_Integer i,nb;
105 Handle(TColStd_HSequenceOfHAsciiString) norms = XSControl_Controller::ListRecorded(-1);
106 nb = norms->Length();
107 sout<<"Short Proper Names (complete names) : "<<nb<<" :";
108 for (i = 1; i <= nb; i ++) sout<<" "<<norms->Value(i)->ToCString();
110 norms = XSControl_Controller::ListRecorded(1);
111 nb = norms->Length();
112 sout<<"Long Proper Names (resource names) : "<<nb<<" :";
113 for (i = 1; i <= nb; i ++) sout<<" "<<norms->Value(i)->ToCString();
115 norms = XSControl_Controller::ListRecorded(0);
116 nb = norms->Length();
117 sout<<"All Norm Names (short, long and aliases) "<<nb<<" :";
118 for (i = 1; i <= nb; i ++) sout<<" "<<norms->Value(i)->ToCString();
120 sout<<"To change, xnorm newnorm"<<endl;
121 return IFSelect_RetVoid;
124 control = XSControl_Controller::Recorded(arg1);
125 if (control.IsNull()) { sout<<" No norm named : "<<arg1<<endl; return IFSelect_RetError; }
127 WS->SetController(control);
128 sout<<"new norm : "<<control->Name()<<endl;
130 const Standard_CString arg2 = pilot->Arg(2);
131 if (!control->Profile()->SetCurrent (arg2))
132 sout<<"profile could not be set to "<<arg2<<endl;
134 sout<<"current profile : "<<control->Profile()->Current()<<endl;
136 IFSelect_Activator::SetCurrentAlias (WS->SelectedNorm(Standard_True));
137 return IFSelect_RetDone;
142 //=======================================================================
143 //function : xprofile
144 //=======================================================================
145 static IFSelect_ReturnStatus XSControl_xprofile(const Handle(IFSelect_SessionPilot)& pilot)
147 Standard_Integer argc = pilot->NbWords();
148 const Standard_CString arg1 = pilot->Arg(1);
149 // **** xprofile ****
150 Handle(XSControl_WorkSession) WS = XSControl::Session(pilot);
151 Handle(XSControl_Controller) control = WS->NormAdaptor();
152 if (control.IsNull()) return IFSelect_RetFail;
153 Handle(MoniTool_Profile) prof = control->Profile();
154 Handle(Message_Messenger) sout = Message::DefaultMessenger();
155 sout<<"Current Profile : "<<prof->Current().ToCString()<<endl;
158 sout<<"xprofile ? for list of profile confs"<<endl
159 << "xprofile . to apply the current profile (after editing)"<<endl
160 << "xprofile profname to select one and apply it"<<endl
161 << "xprofile profname . to record current profile as profname"<<endl
162 <<" (in followings, profname may be replaced by . for current profile)"<<endl
163 << "xprofile profname ? to list its definition"<<endl
164 << "xprofile profname - to clear it completely"<<endl
165 << "xprofile profname optname casename to edit an option of it"<<endl
166 << "xprofile profname - optname to clear an option from it"<<endl;
167 return IFSelect_RetVoid;
171 if (arg1[0] == '?') {
172 Handle(TColStd_HSequenceOfAsciiString) confs = prof->ConfList();
173 Standard_Integer i, nb = confs->Length();
174 sout<<"List of Available Profile Configurations : "<<nb<<" Items"<<endl;
175 for (i = 1; i <= nb; i ++) sout<<confs->Value(i).ToCString()<<endl;
176 return IFSelect_RetVoid;
177 } else if (arg1[0] == '.' && arg1[1] == '\0') {
178 if (!control->ApplyProfile(WS,".")) {
179 sout<<"Applying current profile has failed"<<endl;
180 return IFSelect_RetFail;
182 return IFSelect_RetDone;
186 if (!control->ApplyProfile(WS,arg1)) {
187 sout<<"Setting "<<arg1<<" as current has failed"<<endl;
188 return IFSelect_RetFail;
190 sout<<"Setting "<<arg1<<" as current"<<endl;
191 return IFSelect_RetDone;
196 const Standard_CString arg2 = pilot->Arg(2);
198 // List the definition of a profile
199 if (arg2[0] == '?') {
200 Handle(TColStd_HSequenceOfAsciiString) opts, cases;
201 prof->SwitchList (arg1,opts,cases);
202 Standard_Integer i,nb = opts->Length();
203 sout<<"Option -- Case -- ("<<nb<<" switches on configuration "<<arg1<<")"<<endl;
204 for (i = 1; i <= nb; i ++) {
205 sout<<opts->Value(i).ToCString()<<" "<<cases->Value(i).ToCString()<<endl;
207 return IFSelect_RetVoid;
210 } else if (arg2[0] == '-' && arg2[1] == '\0') {
211 if (!prof->ClearConf(arg1)) {
212 sout<<"Clearing profile "<<arg2<<" has failed"<<endl;
213 return IFSelect_RetFail;
215 return IFSelect_RetDone;
217 // Merge Profile arg2 to arg1
219 if (!prof->HasConf (arg1)) prof->AddConf (arg1);
220 if (!prof->AddFromOtherConf (arg1,arg2)) {
221 sout<<"Merging profile "<<arg2<<" to "<<arg1<<" has failed"<<endl;
222 return IFSelect_RetFail;
224 return IFSelect_RetDone;
228 // Editing / Adding a switch in a profile
230 const Standard_CString arg2 = pilot->Arg(2);
231 const Standard_CString arg3 = pilot->Arg(3);
234 if (arg2[0] == '-' && arg2[1] == '\0') {
235 if (!prof->RemoveSwitch (arg1,arg3)) {
236 sout<<"Removing switch on option "<<arg3<<" in profile "<<arg1<<" has failed"<<endl;
237 return IFSelect_RetFail;
239 sout<<"Edition of profile "<<arg1<<" done. To apply it : xprofile "<<arg1<<endl;
240 return IFSelect_RetDone;
244 if (!prof->AddSwitch (arg1,arg2,arg3)) {
245 sout<<"Setting profile "<<arg1<<" for option "<<arg2<<" to case "<<arg3<<" has failed"<<endl;
246 return IFSelect_RetFail;
248 sout<<"Edition of profile "<<arg1<<" done. To apply it : xprofile "<<arg1<<endl;
249 return IFSelect_RetDone;
253 return IFSelect_RetVoid;
257 //=======================================================================
259 //=======================================================================
260 static IFSelect_ReturnStatus XSControl_xoption(const Handle(IFSelect_SessionPilot)& pilot)
262 Standard_Integer argc = pilot->NbWords();
263 const Standard_CString arg1 = pilot->Arg(1);
264 const Standard_CString arg2 = pilot->Arg(2);
265 const Standard_CString arg3 = pilot->Arg(3);
267 Handle(XSControl_WorkSession) WS = XSControl::Session(pilot);
268 Handle(XSControl_Controller) control = WS->NormAdaptor();
269 if (control.IsNull()) return IFSelect_RetFail;
270 Handle(MoniTool_Profile) prof = control->Profile();
271 Handle(Message_Messenger) sout = Message::DefaultMessenger();
272 sout<<"Current Profile : "<<prof->Current().ToCString()<<endl;
275 sout<<"xoption anopt : query an option"<<endl
276 << "xoption anopt newcase : switch (basic definition)"
277 <<" (but is superseded by current configuration)"<<endl
278 <<"xoption + optname [param] : create an option on a parameter"<<endl
279 <<" (param absent is taken param=optname)"
280 <<"xoption anopt + casename [value] : add a case for a parameter"<<endl
281 <<" (value absent is taken value=casename)"<<endl;
283 Handle(TColStd_HSequenceOfAsciiString) optlist = prof->OptionList();
284 Standard_Integer iopt, nbopt = optlist->Length();
285 sout<<"Total : "<<nbopt<<" Options"<<endl;
286 for (iopt = 1; iopt <= nbopt; iopt ++) {
287 TCollection_AsciiString optname = optlist->Value(iopt);
288 Handle(MoniTool_Option) opt = prof->Option (optname.ToCString());
289 sout<<optname.ToCString()<<" : "<<opt->CaseName()<<endl;
291 return IFSelect_RetVoid;
294 // xoption optname : description
297 Handle(MoniTool_Option) opt = prof->Option (arg1);
298 if (opt.IsNull()) { sout<<"Not a recorded Option : "<<arg1<<endl; return IFSelect_RetError; }
300 // On va lister les valeurs admises
301 Handle(TColStd_HSequenceOfAsciiString) caselist = opt->ItemList();
302 Standard_Integer icase, nbcase = caselist->Length();
303 Handle(MoniTool_TypedValue) tv = opt->TypedValue();
304 if (tv.IsNull()) sout<<"Option : "<<arg1<<" Type : "<<opt->Type()->Name();
305 else sout<<"Option : "<<arg1<<" TypedValue. Name : "<<tv->Name()<<endl<<" Definition : "<<tv->Definition();
307 sout<<endl<<" Current Case (basic) : "<<opt->CaseName()<<" Total : "<<nbcase<<" Cases :"<<endl;
308 for (icase = 1; icase <= nbcase; icase ++) {
309 const TCollection_AsciiString& acase = caselist->Value(icase);
310 sout<<acase.ToCString();
313 Handle(TColStd_HSequenceOfAsciiString) aliases = opt->Aliases(acase.ToCString());
314 Standard_Integer ial, nbal = (aliases.IsNull() ? 0 : aliases->Length());
315 if (nbal > 0) sout<<" - Alias:";
316 for (ial = 1; ial <= nbal; ial ++) sout<<" "<<aliases->Value(ial);
318 // TypedValue : on peut afficher la valeur
319 Handle(Standard_Transient) str;
320 opt->Item (acase.ToCString(),str);
321 if (!str.IsNull()) sout<<" - Value:"<< Handle(TCollection_HAsciiString)::DownCast(str)->ToCString();
326 return IFSelect_RetVoid;
329 // xoption + optname [paramname]
330 if (argc >= 3 && arg1[0] == '+' && arg1[1] == '\0') {
331 Standard_CString parname = pilot->Arg(argc-1);
332 Handle(Interface_Static) param = Interface_Static::Static(parname);
333 if (param.IsNull()) { sout<<"No static parameter is named "<<parname<<endl;
334 return IFSelect_RetError; }
335 Handle(MoniTool_Option) opt = new MoniTool_Option(param,arg2);
336 prof->AddOption (opt);
337 return IFSelect_RetDone;
340 // xoption optname + case [val]
341 if (argc >= 4 && arg2[0] == '+' && arg2[1] == '\0') {
342 Handle(MoniTool_Option) opt = prof->Option (arg1);
343 if (opt.IsNull()) { sout<<"Not a recorded Option : "<<arg1<<endl; return IFSelect_RetError; }
344 Handle(MoniTool_TypedValue) tv = opt->TypedValue();
345 if (tv.IsNull()) { sout<<"Option not for a Parameter : "<<arg1<<endl; return IFSelect_RetError; }
346 Standard_CString valname = pilot->Arg(argc-1);
347 if (!opt->AddBasic (arg3,valname)) {
348 sout<<"Option "<<arg1<<" : not an allowed value : "<<valname<<endl;
349 return IFSelect_RetError;
351 return IFSelect_RetDone;
354 // xoption optname newcase : edition
356 Handle(MoniTool_Option) opt = prof->Option (arg1);
357 if (opt.IsNull()) { sout<<"Not a recorded Option : "<<arg1<<endl; return IFSelect_RetError; }
358 if (!opt->Switch (arg2)) {
359 sout<<"Option : "<<arg1<<" , Not a suitable case : "<<arg2<<endl;
360 return IFSelect_RetFail;
362 sout<<"Option : "<<arg1<<" switched to case : "<<arg2<<endl;
363 return IFSelect_RetDone;
367 return IFSelect_RetVoid;
371 //=======================================================================
372 //function : newmodel
373 //=======================================================================
374 static IFSelect_ReturnStatus XSControl_newmodel(const Handle(IFSelect_SessionPilot)& pilot)
376 // **** newmodel ****
377 if (!XSControl::Session(pilot)->NewModel().IsNull()) return IFSelect_RetDone;
378 Handle(Message_Messenger) sout = Message::DefaultMessenger();
379 sout<<"No new Model produced"<<endl;
380 return IFSelect_RetFail;
384 //=======================================================================
386 //=======================================================================
387 static IFSelect_ReturnStatus XSControl_tpclear(const Handle(IFSelect_SessionPilot)& pilot)
389 // **** tpclear/twclear ****
390 Standard_Boolean modew = Standard_False;
391 if (pilot->Word(0).Value(2) == 'w') modew = Standard_True;
392 Handle(Transfer_FinderProcess) FP = XSControl::Session(pilot)->MapWriter();
393 Handle(Transfer_TransientProcess) TP = XSControl::Session(pilot)->MapReader();
394 Handle(Message_Messenger) sout = Message::DefaultMessenger();
395 if ( modew) { if(!FP.IsNull()) FP->Clear(); else sout<<"No Transfer Write"<<endl; }
396 else { if(!TP.IsNull()) TP->Clear(); else sout<<"No Transfer Read"<<endl; }
397 return IFSelect_RetDone;
401 //=======================================================================
403 //=======================================================================
404 static IFSelect_ReturnStatus XSControl_tpstat(const Handle(IFSelect_SessionPilot)& pilot)
406 Standard_Integer argc = pilot->NbWords();
407 const Standard_CString arg1 = pilot->Arg(1);
408 //const Standard_CString arg2 = pilot->Arg(2);
409 Handle(Transfer_TransientProcess) TP= XSControl::Session(pilot)->MapReader();
410 Handle(Message_Messenger) sout = Message::DefaultMessenger();
411 if (TP.IsNull()) { sout<<"No Transfer Read"<<endl; return IFSelect_RetError;}
414 Standard_Integer mod1 = -1;
415 Standard_Integer mod2 = 0;
416 // g : general c : check (compte) C (liste) f : fails(compte) F (liste)
417 // resultats racines : n : n0s entites s : status b : binders
418 // t : compte par type r : compte par resultat l : liste(type-resultat)
419 // *n *s *b *t *r *l : idem sur tout
420 // ?n etc.. : idem sur resultats anormaux
421 // ? tout court pour help
424 char a2 = arg1[1]; if (a2 == '\0') a2 = '!';
426 case 'g' : mod1 = 0; break;
427 case 'c' : mod1 = 4; mod2 = 4; break;
428 case 'C' : mod1 = 4; mod2 = 2; break;
429 case 'f' : mod1 = 5; mod2 = 4; break;
430 case 'F' : mod1 = 5; mod2 = 2; break;
431 case '*' : mod1 = 2; break;
432 case '?' : mod1 = 3; break;
433 default : mod1 = 1; if (argc > 2) mod1 = 2; a2 = arg1[0]; break;
435 if (mod1 < 1 || mod1 > 3) a2 = '!';
437 case 'n' : mod2 = 0; break;
438 case 's' : mod2 = 1; break;
439 case 'b' : mod2 = 2; break;
440 case 't' : mod2 = 3; break;
441 case 'r' : mod2 = 4; break;
442 case 'l' : mod2 = 5; break;
443 case 'L' : mod2 = 6; break;
445 case '?' : mod1 = -1; break;
446 default : mod1 = -2; break;
449 // A present help eventuel
450 if (mod1 < -1) sout<<"Unknown Mode"<<endl;
452 sout<<"Modes available :\n"
453 <<"g : general c : checks (count) C (list)"<<"\n"
454 <<" f : fails (count) F (list)"<<"\n"
455 <<" n : numbers of transferred entities (on TRANSFER ROOTS)"<<"\n"
456 <<" s : their status (type entity-result , presence checks)"<<"\n"
457 <<" b : detail of binders"<<"\n"
458 <<" t : count per entity type r : per type/status result"<<"\n"
459 <<" l : count per couple type entity/result"<<"\n"
460 <<" L : list per couple type entity/result"<<"\n"
461 <<" *n *s *b *t *r *l *L : idem on ALL recorded items"<<"\n"
462 <<" ?n ?s ?b ?t ... : idem on abnormal items"<<"\n"
463 <<" n select : n applied on a selection idem for s b t r l"<<endl;
464 if (mod1 < -1) return IFSelect_RetError;
465 return IFSelect_RetVoid;
469 sout<<"TransferRead :";
470 if (TP->Model() != pilot->Session()->Model()) sout<<"Model differs from the session";
471 Handle(TColStd_HSequenceOfTransient) list =
472 IFSelect_Functions::GiveList(pilot->Session(),pilot->CommandPart(2));
473 XSControl_TransferReader::PrintStatsOnList (TP,list,mod1,mod2);
474 // TP->PrintStats (1,sout);
476 else sout<<"TransferRead : not defined"<<endl;
477 return IFSelect_RetVoid;
481 //=======================================================================
483 //=======================================================================
484 static IFSelect_ReturnStatus XSControl_tpent(const Handle(IFSelect_SessionPilot)& pilot)
486 Standard_Integer argc = pilot->NbWords();
487 const Standard_CString arg1 = pilot->Arg(1);
488 Handle(Transfer_TransientProcess) TP= XSControl::Session(pilot)->MapReader();
490 Handle(Message_Messenger) sout = Message::DefaultMessenger();
491 if (TP.IsNull()) { sout<<"No Transfer Read"<<endl; return IFSelect_RetError;}
492 Handle(Interface_InterfaceModel) model = TP->Model();
493 if (model.IsNull()) return IFSelect_RetFail;
495 if (argc < 2) { sout<<"Give ENTITY NUMBER (IN MODEL TransferProcess)"<<endl; return IFSelect_RetError; }
496 Standard_Integer num = atoi(arg1);
497 if (num <= 0 || num > model->NbEntities()) { sout<<"Number not in [1 - "<<model->NbEntities()<<"]"<<endl; return IFSelect_RetError; }
498 Handle(Standard_Transient) ent = model->Value(num);
499 Standard_Integer index = TP->MapIndex (ent);
500 if (index == 0) sout<<"Entity "<<num<<" not recorded in transfer"<<endl;
501 else XSControl::Session(pilot)->PrintTransferStatus (index,Standard_False,sout);
502 return IFSelect_RetVoid;
506 //=======================================================================
508 //=======================================================================
509 static IFSelect_ReturnStatus XSControl_tpitem(const Handle(IFSelect_SessionPilot)& pilot)
511 Standard_Integer argc = pilot->NbWords();
512 const Standard_CString arg1 = pilot->Arg(1);
513 // **** tpitem/tproot/twitem/twroot ****
514 Handle(Message_Messenger) sout = Message::DefaultMessenger();
515 if (argc < 2) { sout<<"Give ITEM NUMBER (in TransferProcess)"<<endl; return IFSelect_RetError; }
516 Standard_Integer num = atoi(arg1);
517 if (pilot->Word(0).Value(3) == 'r') num = -num;
518 Standard_Boolean modew = Standard_False;
519 if (pilot->Word(0).Value(2) == 'w') modew = Standard_True;
520 Handle(Transfer_Binder) binder;
521 Handle(Transfer_Finder) finder;
522 Handle(Standard_Transient) ent;
523 if (!XSControl::Session(pilot)->PrintTransferStatus(num,modew,sout))
524 sout<<" - Num="<<num<<" incorrect"<<endl;
525 return IFSelect_RetVoid;
529 //=======================================================================
531 //=======================================================================
532 static IFSelect_ReturnStatus XSControl_tpatr(const Handle(IFSelect_SessionPilot)& /*pilot*/)
535 Standard_Integer argc = pilot->NbWords();
536 const Standard_CString arg1 = pilot->Arg(1);
537 Handle(XSControl_WorkSession) WS = XSControl::Session(pilot);
538 Handle(Transfer_TransientProcess) TP = WS->MapReader();
540 Handle(Message_Messenger) sout = Message::DefaultMessenger();
541 // tpatr tout court : liste tous les attributs
542 // tpatr nomatr : sur cet attribut, liste les valeurs par entite
545 Handle(Dico_DictionaryOfInteger) list = TP->Attributes();
546 for (Dico_IteratorOfDictionaryOfInteger iter(list); iter.More(); iter.Next()) {
547 TCollection_AsciiString name = iter.Name();
548 Standard_Integer nbatr = iter.Value();
549 Interface_ParamType aty = TP->AttributeType (name.ToCString());
550 sout<<"Name : "<<name<<" Count="<<nbatr<<" Type : ";
552 case Interface_ParamInteger : sout<<"Integer"; break;
553 case Interface_ParamReal : sout<<"Real"; break;
554 case Interface_ParamIdent : sout<<"Object"; break;
555 case Interface_ParamText : sout<<"String"; break;
556 default : sout<<"(Mixed)";
564 Standard_Integer num , nb = 0;
565 sout<<"Attribute Name : "<<arg1<<endl;
566 for (num = TP->NextItemWithAttribute(arg1,0); num > 0;
567 num = TP->NextItemWithAttribute(arg1,num)) {
569 sout<<"Item "<<num<<" , Entity ";
570 WS->Model()->Print(TP->Mapped(num),sout);
571 Handle(Transfer_Binder) bnd = TP->MapItem (num);
572 Interface_ParamType aty = bnd->AttributeType(arg1);
574 case Interface_ParamInteger : sout<<" Integer="<<bnd->IntegerAttribute(arg1); break;
575 case Interface_ParamReal : sout<<" Real="<<bnd->RealAttribute(arg1); break;
576 case Interface_ParamIdent : sout<<" Object,Type:"<<bnd->Attribute(arg1)->DynamicType()->Name(); break;
577 case Interface_ParamText : sout<<" String="<<bnd->StringAttribute(arg1);
578 default : sout<<"(none)"; break;
582 sout<<"Attribute Name : "<<arg1<<" on "<<nb<<" Items"<<endl;
586 return IFSelect_RetVoid;
590 //=======================================================================
592 //=======================================================================
593 static IFSelect_ReturnStatus XSControl_trecord(const Handle(IFSelect_SessionPilot)& pilot)
595 Standard_Integer argc = pilot->NbWords();
596 const Standard_CString arg1 = pilot->Arg(1);
597 Handle(Transfer_TransientProcess) TP = XSControl::Session(pilot)->MapReader();
598 // **** trecord : TransferReader ****
599 Standard_Boolean tous = (argc == 1);
600 Standard_Integer num = -1;
601 Handle(Interface_InterfaceModel) mdl = XSControl::Session(pilot)->Model();
602 Handle(XSControl_TransferReader) TR = XSControl::Session(pilot)->TransferReader();
603 Handle(Standard_Transient) ent;
604 Handle(Message_Messenger) sout = Message::DefaultMessenger();
605 if (mdl.IsNull() || TR.IsNull() || TP.IsNull())
606 { sout<<" init not done"<<endl; return IFSelect_RetError; }
607 if (!tous) num = atoi(arg1);
608 // Enregistrer les racines
610 Standard_Integer nb = TP->NbRoots();
611 sout<<" Recording "<<nb<<" Roots"<<endl;
612 for (Standard_Integer i = 1; i <= nb; i ++) {
614 if (TR->RecordResult (ent)) sout<<" Root n0."<<i<<endl;
615 else sout<<" Root n0."<<i<<" not recorded"<<endl;
618 if (num < 1 || num > mdl->NbEntities()) sout<<"incorrect number:"<<num<<endl;
619 else if (TR->RecordResult(mdl->Value(num))) sout<<" Entity n0."<<num<<endl;
620 else sout<<" Entity n0."<<num<<" not recorded"<<endl;
622 return IFSelect_RetDone;
626 //=======================================================================
628 //=======================================================================
629 static IFSelect_ReturnStatus XSControl_trstat(const Handle(IFSelect_SessionPilot)& pilot)
631 Standard_Integer argc = pilot->NbWords();
632 const Standard_CString arg1 = pilot->Arg(1);
633 Handle(Message_Messenger) sout = Message::DefaultMessenger();
634 // **** trstat : TransferReader ****
635 Handle(XSControl_TransferReader) TR = XSControl::Session(pilot)->TransferReader();
636 if (TR.IsNull()) { sout<<" init not done"<<endl; return IFSelect_RetError; }
637 Handle(Interface_InterfaceModel) mdl = TR->Model();
638 if (mdl.IsNull()) { sout<<" No model"<<endl; return IFSelect_RetError; }
639 sout<<" Statistics : FileName : "<<TR->FileName()<<endl;
642 TR->PrintStats(10,0);
645 Standard_Integer num = atoi(arg1);
646 if (num < 1 || num > mdl->NbEntities()) { sout<<" incorrect number:"<<arg1<<endl; return IFSelect_RetError; }
647 Handle(Standard_Transient) ent = mdl->Value(num);
648 if (!TR->IsRecorded(ent)) { sout<<" Entity "<<num<<" not recorded"<<endl; return IFSelect_RetError; }
649 Handle(Transfer_ResultFromModel) RM = TR->FinalResult(ent);
650 Handle(TColStd_HSequenceOfTransient) list = TR->CheckedList(ent);
651 Standard_Integer i, nb = list->Length();
652 if (nb > 0) sout<<" Entities implied by Check/Result :"<<nb<<" i.e.:";
653 for (i = 1; i <= nb; i ++) { sout<<" "; mdl->Print(list->Value(i),sout); }
655 if (RM.IsNull()) { sout<<" no other info"<<endl; return IFSelect_RetVoid; }
656 Interface_CheckIterator chl = RM->CheckList(Standard_False);
657 pilot->Session()->PrintCheckList(chl,Standard_False,IFSelect_EntitiesByItem);
659 return IFSelect_RetVoid;
663 //=======================================================================
665 //=======================================================================
666 static IFSelect_ReturnStatus XSControl_trbegin(const Handle(IFSelect_SessionPilot)& pilot)
668 // **** trbegin : TransferReader ****
669 Handle(XSControl_TransferReader) TR = XSControl::Session(pilot)->TransferReader();
670 Standard_Boolean init = TR.IsNull();
671 if (pilot->NbWords() > 1) { if (pilot->Arg(1)[0] == 'i') init = Standard_True; }
673 XSControl::Session(pilot)->InitTransferReader (0);
674 TR = XSControl::Session(pilot)->TransferReader();
676 Handle(Message_Messenger) sout = Message::DefaultMessenger();
677 sout<<" init not done or failed"<<endl;
678 return IFSelect_RetError;
682 return IFSelect_RetDone;
686 //=======================================================================
688 //=======================================================================
689 static IFSelect_ReturnStatus XSControl_tread(const Handle(IFSelect_SessionPilot)& pilot)
691 Standard_Integer argc = pilot->NbWords();
692 //const Standard_CString arg1 = pilot->Arg(1);
693 // **** tread : TransferReader ****
694 Handle(Message_Messenger) sout = Message::DefaultMessenger();
695 Handle(XSControl_TransferReader) TR = XSControl::Session(pilot)->TransferReader();
696 if (TR.IsNull()) { sout<<" init not done"<<endl; return IFSelect_RetError; }
697 Handle(Interface_InterfaceModel) mdl = TR->Model();
698 if (mdl.IsNull()) { sout<<" No model"<<endl; return IFSelect_RetError; }
700 // DeclareAndCast(IFSelect_Selection,sel,pilot->Session()->NamedItem("xst-model-roots"));
701 Handle(Standard_Transient) sel = pilot->Session()->NamedItem("xst-model-roots");
702 if (sel.IsNull()) { sout<<"Select Roots absent"<<endl; return IFSelect_RetError; }
703 Handle(TColStd_HSequenceOfTransient) list = pilot->Session()->GiveList(sel);
704 sout<<" Transferring all roots i.e. : "<<TR->TransferList(list)<<endl;
706 Handle(TColStd_HSequenceOfTransient) list =
707 IFSelect_Functions::GiveList(pilot->Session(),pilot->CommandPart(1));
708 sout<<" Transfer of "<<list->Length()<<" entities"<<endl;
709 Standard_Integer nb = TR->TransferList(list);
710 sout<<" Gives "<<nb<<" results"<<endl;
712 return IFSelect_RetDone;
716 //=======================================================================
718 //=======================================================================
719 static IFSelect_ReturnStatus XSControl_trtp(const Handle(IFSelect_SessionPilot)& pilot)
721 // **** TReader -> TProcess ****
722 Handle(XSControl_TransferReader) TR = XSControl::Session(pilot)->TransferReader();
723 Handle(Message_Messenger) sout = Message::DefaultMessenger();
724 if (TR.IsNull()) sout<<" No TransferReader"<<endl;
725 else if (TR->TransientProcess().IsNull()) sout<<" Transfer Reader without Process"<<endl;
726 ////else { XSDRAW::SetTransferProcess(TR->TransientProcess()); return IFSelect_RetDone; }
727 return IFSelect_RetVoid;
731 //=======================================================================
733 //=======================================================================
734 static IFSelect_ReturnStatus XSControl_tptr(const Handle(IFSelect_SessionPilot)& pilot)
736 // **** TProcess -> TReader ****
737 XSControl::Session(pilot)->InitTransferReader (3);
738 return IFSelect_RetDone;
742 //=======================================================================
744 //=======================================================================
745 static IFSelect_ReturnStatus XSControl_twmode(const Handle(IFSelect_SessionPilot)& pilot)
747 Standard_Integer argc = pilot->NbWords();
748 const Standard_CString arg1 = pilot->Arg(1);
750 Handle(XSControl_TransferWriter) TW = XSControl::Session(pilot)->TransferWriter();
751 Handle(XSControl_Controller) control = XSControl::Session(pilot)->NormAdaptor();
752 Standard_Integer modemin,modemax;
753 Handle(Message_Messenger) sout = Message::DefaultMessenger();
754 if (control->ModeWriteBounds (modemin,modemax)) {
755 sout<<"Write Mode : allowed values "<<modemin<<" to "<<modemax<<endl;
756 for (Standard_Integer modd = modemin; modd <= modemax; modd ++) {
757 sout<<modd<<" : "<<control->ModeWriteHelp (modd)<<endl;;
760 sout<<"Write Mode : actual = "<<TW->TransferMode()<<endl;
761 if (argc <= 1) return IFSelect_RetVoid;
762 Standard_Integer mod = atoi(arg1);
763 sout<<"New value -> "<<arg1<<endl;
764 TW->SetTransferMode(mod);
765 if (!control->IsModeWrite (mod)) sout<<"Warning : this new value is not supported"<<endl;
766 return IFSelect_RetDone;
770 //=======================================================================
772 //=======================================================================
773 static IFSelect_ReturnStatus XSControl_twstat(const Handle(IFSelect_SessionPilot)& pilot)
775 //Standard_Integer argc = pilot->NbWords();
776 //const Standard_CString arg1 = pilot->Arg(1);
777 //const Standard_CString arg2 = pilot->Arg(2);
778 Handle(Transfer_FinderProcess) FP = XSControl::Session(pilot)->MapWriter();
781 Handle(Message_Messenger) sout = Message::DefaultMessenger();
783 sout<<"TransferWrite:";
784 // XSControl_TransferWriter::PrintStatsProcess (FP,mod1,mod2);
785 FP->PrintStats (1,sout);
787 else sout<<"TransferWrite: not defined"<<endl;
788 return IFSelect_RetVoid;
792 //=======================================================================
793 //function : settransfert
794 //=======================================================================
795 static IFSelect_ReturnStatus XSControl_settransfert(const Handle(IFSelect_SessionPilot)& pilot)
797 // **** SelectForTransfer ****
798 return pilot->RecordItem(new XSControl_SelectForTransfer(XSControl::Session(pilot)->TransferReader()));
803 static int initactor = 0;
805 //=======================================================================
808 //=======================================================================
810 void XSControl_Functions::Init ()
812 if (initactor) return; initactor = 1;
813 IFSelect_Act::SetGroup("DE: General");
815 IFSelect_Act::AddFunc ("xinit","[norm:string to change norme] reinitialises according to the norm",XSControl_xinit);
816 IFSelect_Act::AddFunc ("xnorm","displays current norm +norm : changes it",XSControl_xnorm);
817 IFSelect_Act::AddFunc ("xprofile","displays current profile +prof : changes it",XSControl_xprofile);
818 IFSelect_Act::AddFunc ("xoption","lists options +opt : lists cases +case : changes current case",XSControl_xoption);
820 IFSelect_Act::AddFunc ("newmodel","produces a new empty model, for the session",XSControl_newmodel);
822 IFSelect_Act::AddFunc ("tpclear","Clears TransferProcess (READ)",XSControl_tpclear);
823 IFSelect_Act::AddFunc ("twclear","Clears TransferProcess (WRITE)",XSControl_tpclear);
825 IFSelect_Act::AddFunc ("tpstat","Statistics on TransferProcess (READ)",XSControl_tpstat);
827 IFSelect_Act::AddFunc ("tpent","[num:integer] Statistics on an entity of the model (READ)",XSControl_tpent);
829 IFSelect_Act::AddFunc ("tpitem","[num:integer] Statistics on ITEM of transfer (READ)" ,XSControl_tpitem);
830 IFSelect_Act::AddFunc ("tproot","[num:integer] Statistics on a ROOT of transfert (READ)" ,XSControl_tpitem);
831 IFSelect_Act::AddFunc ("twitem","[num:integer] Statistics on an ITEM of transfer (WRITE)" ,XSControl_tpitem);
832 IFSelect_Act::AddFunc ("twroot","[num:integer] Statistics on a ROOT of transfer (WRITE)",XSControl_tpitem);
833 IFSelect_Act::AddFunc ("tpatr","[name] List all Attributes, or values for a Name",XSControl_tpatr);
835 IFSelect_Act::AddFunc ("trecord","record : all root results; or num : for entity n0.num",XSControl_trecord);
836 IFSelect_Act::AddFunc ("trstat","general statistics; or num : stats on entity n0 num",XSControl_trstat);
837 IFSelect_Act::AddFunc ("trbegin","begin-transfer-reader [init]",XSControl_trbegin);
838 IFSelect_Act::AddFunc ("tread","transfers all roots, or num|sel|sel num : entity list, by transfer-reader",XSControl_tread);
840 IFSelect_Act::AddFunc ("trtp","feeds commands tp... with results from tr...",XSControl_trtp);
841 IFSelect_Act::AddFunc ("tptr","feeds tr... from tp... (may be incomplete)",XSControl_tptr);
843 IFSelect_Act::AddFunc ("twmode","displays mode transfer write, + num changes it",XSControl_twmode);
844 IFSelect_Act::AddFunc ("twstat","Statistics on TransferProcess (WRITE)",XSControl_twstat);
846 IFSelect_Act::AddFSet ("selecttransfer","selection (recognize from transfer actor)",XSControl_settransfert);