1 // Copyright (c) 1999-2012 OPEN CASCADE SAS
3 // The content of this file is subject to the Open CASCADE Technology Public
4 // License Version 6.5 (the "License"). You may not use the content of this file
5 // except in compliance with the License. Please obtain a copy of the License
6 // at http://www.opencascade.org and read it completely before using this file.
8 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
9 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
11 // The Original Code and all software distributed under the License is
12 // distributed on an "AS IS" basis, without warranty of any kind, and the
13 // Initial Developer hereby disclaims all such warranties, including without
14 // limitation, any warranties of merchantability, fitness for a particular
15 // purpose or non-infringement. Please see the License for the specific terms
16 // and conditions governing the rights and limitations under the License.
18 #include <XSControl_Functions.ixx>
20 #include <XSControl.hxx>
21 #include <XSControl_Controller.hxx>
22 #include <IFSelect_Profile.hxx>
23 #include <IFSelect_Option.hxx>
24 #include <MoniTool_TypedValue.hxx>
25 #include <Interface_Static.hxx>
26 #include <TColStd_HSequenceOfAsciiString.hxx>
28 #include <XSControl_WorkSession.hxx>
29 #include <IFSelect_Act.hxx>
30 #include <IFSelect_SessionPilot.hxx>
31 #include <IFSelect_Functions.hxx>
32 #include <TCollection_HAsciiString.hxx>
33 #include <TColStd_HSequenceOfHAsciiString.hxx>
35 #include <Interface_InterfaceModel.hxx>
36 #include <Transfer_TransientProcess.hxx>
37 #include <Transfer_FinderProcess.hxx>
38 #include <Transfer_Binder.hxx>
39 #include <Interface_CheckIterator.hxx>
40 #include <IFSelect_CheckCounter.hxx>
41 #include <Transfer_TransferIterator.hxx>
42 #include <Transfer_IteratorOfProcessForTransient.hxx>
44 #include <Dico_IteratorOfDictionaryOfInteger.hxx>
46 //#include <TransferBRep_ShapeBinder.hxx>
47 //#include <TransferBRep_ShapeListBinder.hxx>
48 //#include <TransferBRep_ShapeMapper.hxx>
49 //#include <TransferBRep_OrientedShapeMapper.hxx>
51 #include <XSControl_TransferWriter.hxx>
52 #include <XSControl_TransferReader.hxx>
53 #include <TColStd_HSequenceOfTransient.hxx>
54 #include <Transfer_ResultFromModel.hxx>
55 #include <XSControl_SelectForTransfer.hxx>
57 #include <Interface_Macros.hxx>
58 #include <Message_Messenger.hxx>
59 #include <Message.hxx>
61 // #######################################################################
67 // #######################################################################
70 //=======================================================================
72 //=======================================================================
73 static IFSelect_ReturnStatus XSControl_xinit(const Handle(IFSelect_SessionPilot)& pilot)
75 Standard_Integer argc = pilot->NbWords();
76 const Standard_CString arg1 = pilot->Arg(1);
78 if (argc > 1) return (XSControl::Session(pilot)->SelectNorm(arg1) ?
79 IFSelect_RetDone : IFSelect_RetFail);
80 Handle(Message_Messenger) sout = Message::DefaultMessenger();
81 sout<<"Selected Norm:"<<XSControl::Session(pilot)->SelectedNorm()<<endl;
82 return IFSelect_RetVoid;
86 //=======================================================================
88 //=======================================================================
89 static IFSelect_ReturnStatus XSControl_xnorm(const Handle(IFSelect_SessionPilot)& pilot)
91 Standard_Integer argc = pilot->NbWords();
92 const Standard_CString arg1 = pilot->Arg(1);
94 Handle(XSControl_WorkSession) WS = XSControl::Session(pilot);
95 Handle(XSControl_Controller) control = WS->NormAdaptor();
96 Handle(Message_Messenger) sout = Message::DefaultMessenger();
98 sout<<"Current Norm. xnorm newnorm [profile] to change , xnorm ? for the list"<<endl;
99 else sout<<"Current Norm :"<<endl;
100 if (control.IsNull()) sout<<"no norm currently defined"<<endl;
102 sout<<" Long Name (complete) : "<<control->Name(Standard_False)<<endl
103 << " Short name (resource) : "<<control->Name(Standard_True)<<endl;
104 if (argc == 1) return IFSelect_RetVoid;
106 if (arg1[0] == '?') {
107 sout<<"List of available norms"<<endl;
108 Standard_Integer i,nb;
109 Handle(TColStd_HSequenceOfHAsciiString) norms = XSControl_Controller::ListRecorded(-1);
110 nb = norms->Length();
111 sout<<"Short Proper Names (complete names) : "<<nb<<" :";
112 for (i = 1; i <= nb; i ++) sout<<" "<<norms->Value(i)->ToCString();
114 norms = XSControl_Controller::ListRecorded(1);
115 nb = norms->Length();
116 sout<<"Long Proper Names (resource names) : "<<nb<<" :";
117 for (i = 1; i <= nb; i ++) sout<<" "<<norms->Value(i)->ToCString();
119 norms = XSControl_Controller::ListRecorded(0);
120 nb = norms->Length();
121 sout<<"All Norm Names (short, long and aliases) "<<nb<<" :";
122 for (i = 1; i <= nb; i ++) sout<<" "<<norms->Value(i)->ToCString();
124 sout<<"To change, xnorm newnorm"<<endl;
125 return IFSelect_RetVoid;
128 control = XSControl_Controller::Recorded(arg1);
129 if (control.IsNull()) { sout<<" No norm named : "<<arg1<<endl; return IFSelect_RetError; }
131 WS->SetController(control);
132 sout<<"new norm : "<<control->Name()<<endl;
134 const Standard_CString arg2 = pilot->Arg(2);
135 if (!control->Profile()->SetCurrent (arg2))
136 sout<<"profile could not be set to "<<arg2<<endl;
138 sout<<"current profile : "<<control->Profile()->Current()<<endl;
140 IFSelect_Activator::SetCurrentAlias (WS->SelectedNorm(Standard_True));
141 return IFSelect_RetDone;
143 return IFSelect_RetVoid;
147 //=======================================================================
148 //function : xprofile
149 //=======================================================================
150 static IFSelect_ReturnStatus XSControl_xprofile(const Handle(IFSelect_SessionPilot)& pilot)
152 Standard_Integer argc = pilot->NbWords();
153 const Standard_CString arg1 = pilot->Arg(1);
154 // **** xprofile ****
155 Handle(XSControl_WorkSession) WS = XSControl::Session(pilot);
156 Handle(XSControl_Controller) control = WS->NormAdaptor();
157 if (control.IsNull()) return IFSelect_RetFail;
158 Handle(IFSelect_Profile) prof = control->Profile();
159 Handle(Message_Messenger) sout = Message::DefaultMessenger();
160 sout<<"Current Profile : "<<prof->Current().ToCString()<<endl;
163 sout<<"xprofile ? for list of profile confs"<<endl
164 << "xprofile . to apply the current profile (after editing)"<<endl
165 << "xprofile profname to select one and apply it"<<endl
166 << "xprofile profname . to record current profile as profname"<<endl
167 <<" (in followings, profname may be replaced by . for current profile)"<<endl
168 << "xprofile profname ? to list its definition"<<endl
169 << "xprofile profname - to clear it completely"<<endl
170 << "xprofile profname optname casename to edit an option of it"<<endl
171 << "xprofile profname - optname to clear an option from it"<<endl;
172 return IFSelect_RetVoid;
176 if (arg1[0] == '?') {
177 Handle(TColStd_HSequenceOfAsciiString) confs = prof->ConfList();
178 Standard_Integer i, nb = confs->Length();
179 sout<<"List of Available Profile Configurations : "<<nb<<" Items"<<endl;
180 for (i = 1; i <= nb; i ++) sout<<confs->Value(i).ToCString()<<endl;
181 return IFSelect_RetVoid;
182 } else if (arg1[0] == '.' && arg1[1] == '\0') {
183 if (!control->ApplyProfile(WS,".")) {
184 sout<<"Applying current profile has failed"<<endl;
185 return IFSelect_RetFail;
187 return IFSelect_RetDone;
191 if (!control->ApplyProfile(WS,arg1)) {
192 sout<<"Setting "<<arg1<<" as current has failed"<<endl;
193 return IFSelect_RetFail;
195 sout<<"Setting "<<arg1<<" as current"<<endl;
196 return IFSelect_RetDone;
201 const Standard_CString arg2 = pilot->Arg(2);
203 // List the definition of a profile
204 if (arg2[0] == '?') {
205 Handle(TColStd_HSequenceOfAsciiString) opts, cases;
206 prof->SwitchList (arg1,opts,cases);
207 Standard_Integer i,nb = opts->Length();
208 sout<<"Option -- Case -- ("<<nb<<" switches on configuration "<<arg1<<")"<<endl;
209 for (i = 1; i <= nb; i ++) {
210 sout<<opts->Value(i).ToCString()<<" "<<cases->Value(i).ToCString()<<endl;
212 return IFSelect_RetVoid;
215 } else if (arg2[0] == '-' && arg2[1] == '\0') {
216 if (!prof->ClearConf(arg1)) {
217 sout<<"Clearing profile "<<arg2<<" has failed"<<endl;
218 return IFSelect_RetFail;
220 return IFSelect_RetDone;
222 // Merge Profile arg2 to arg1
224 if (!prof->HasConf (arg1)) prof->AddConf (arg1);
225 if (!prof->AddFromOtherConf (arg1,arg2)) {
226 sout<<"Merging profile "<<arg2<<" to "<<arg1<<" has failed"<<endl;
227 return IFSelect_RetFail;
229 return IFSelect_RetDone;
233 // Editing / Adding a switch in a profile
235 const Standard_CString arg2 = pilot->Arg(2);
236 const Standard_CString arg3 = pilot->Arg(3);
239 if (arg2[0] == '-' && arg2[1] == '\0') {
240 if (!prof->RemoveSwitch (arg1,arg3)) {
241 sout<<"Removing switch on option "<<arg3<<" in profile "<<arg1<<" has failed"<<endl;
242 return IFSelect_RetFail;
244 sout<<"Edition of profile "<<arg1<<" done. To apply it : xprofile "<<arg1<<endl;
245 return IFSelect_RetDone;
249 if (!prof->AddSwitch (arg1,arg2,arg3)) {
250 sout<<"Setting profile "<<arg1<<" for option "<<arg2<<" to case "<<arg3<<" has failed"<<endl;
251 return IFSelect_RetFail;
253 sout<<"Edition of profile "<<arg1<<" done. To apply it : xprofile "<<arg1<<endl;
254 return IFSelect_RetDone;
258 return IFSelect_RetVoid;
262 //=======================================================================
264 //=======================================================================
265 static IFSelect_ReturnStatus XSControl_xoption(const Handle(IFSelect_SessionPilot)& pilot)
267 Standard_Integer argc = pilot->NbWords();
268 const Standard_CString arg1 = pilot->Arg(1);
269 const Standard_CString arg2 = pilot->Arg(2);
270 const Standard_CString arg3 = pilot->Arg(3);
272 Handle(XSControl_WorkSession) WS = XSControl::Session(pilot);
273 Handle(XSControl_Controller) control = WS->NormAdaptor();
274 if (control.IsNull()) return IFSelect_RetFail;
275 Handle(IFSelect_Profile) prof = control->Profile();
276 Handle(Message_Messenger) sout = Message::DefaultMessenger();
277 sout<<"Current Profile : "<<prof->Current().ToCString()<<endl;
280 sout<<"xoption anopt : query an option"<<endl
281 << "xoption anopt newcase : switch (basic definition)"
282 <<" (but is superseded by current configuration)"<<endl
283 <<"xoption + optname [param] : create an option on a parameter"<<endl
284 <<" (param absent is taken param=optname)"
285 <<"xoption anopt + casename [value] : add a case for a parameter"<<endl
286 <<" (value absent is taken value=casename)"<<endl;
288 Handle(TColStd_HSequenceOfAsciiString) optlist = prof->OptionList();
289 Standard_Integer iopt, nbopt = optlist->Length();
290 sout<<"Total : "<<nbopt<<" Options"<<endl;
291 for (iopt = 1; iopt <= nbopt; iopt ++) {
292 TCollection_AsciiString optname = optlist->Value(iopt);
293 Handle(IFSelect_Option) opt = prof->Option (optname.ToCString());
294 sout<<optname.ToCString()<<" : "<<opt->CaseName()<<endl;
296 return IFSelect_RetVoid;
299 // xoption optname : description
302 Handle(IFSelect_Option) opt = prof->Option (arg1);
303 if (opt.IsNull()) { sout<<"Not a recorded Option : "<<arg1<<endl; return IFSelect_RetError; }
305 // On va lister les valeurs admises
306 Handle(TColStd_HSequenceOfAsciiString) caselist = opt->ItemList();
307 Standard_Integer icase, nbcase = caselist->Length();
308 Handle(MoniTool_TypedValue) tv = opt->TypedValue();
309 if (tv.IsNull()) sout<<"Option : "<<arg1<<" Type : "<<opt->Type()->Name();
310 else sout<<"Option : "<<arg1<<" TypedValue. Name : "<<tv->Name()<<endl<<" Definition : "<<tv->Definition();
312 sout<<endl<<" Current Case (basic) : "<<opt->CaseName()<<" Total : "<<nbcase<<" Cases :"<<endl;
313 for (icase = 1; icase <= nbcase; icase ++) {
314 const TCollection_AsciiString& acase = caselist->Value(icase);
315 sout<<acase.ToCString();
318 Handle(TColStd_HSequenceOfAsciiString) aliases = opt->Aliases(acase.ToCString());
319 Standard_Integer ial, nbal = (aliases.IsNull() ? 0 : aliases->Length());
320 if (nbal > 0) sout<<" - Alias:";
321 for (ial = 1; ial <= nbal; ial ++) sout<<" "<<aliases->Value(ial);
323 // TypedValue : on peut afficher la valeur
324 Handle(TCollection_HAsciiString) str;
325 opt->Item (acase.ToCString(),str);
326 if (!str.IsNull()) sout<<" - Value:"<<str->ToCString();
331 return IFSelect_RetVoid;
334 // xoption + optname [paramname]
335 if (argc >= 3 && arg1[0] == '+' && arg1[1] == '\0') {
336 Standard_CString parname = pilot->Arg(argc-1);
337 Handle(Interface_Static) param = Interface_Static::Static(parname);
338 if (param.IsNull()) { sout<<"No static parameter is named "<<parname<<endl;
339 return IFSelect_RetError; }
340 Handle(IFSelect_Option) opt = new IFSelect_Option(param,arg2);
341 prof->AddOption (opt);
342 return IFSelect_RetDone;
345 // xoption optname + case [val]
346 if (argc >= 4 && arg2[0] == '+' && arg2[1] == '\0') {
347 Handle(IFSelect_Option) opt = prof->Option (arg1);
348 if (opt.IsNull()) { sout<<"Not a recorded Option : "<<arg1<<endl; return IFSelect_RetError; }
349 Handle(MoniTool_TypedValue) tv = opt->TypedValue();
350 if (tv.IsNull()) { sout<<"Option not for a Parameter : "<<arg1<<endl; return IFSelect_RetError; }
351 Standard_CString valname = pilot->Arg(argc-1);
352 if (!opt->AddBasic (arg3,valname)) {
353 sout<<"Option "<<arg1<<" : not an allowed value : "<<valname<<endl;
354 return IFSelect_RetError;
356 return IFSelect_RetDone;
359 // xoption optname newcase : edition
361 Handle(IFSelect_Option) opt = prof->Option (arg1);
362 if (opt.IsNull()) { sout<<"Not a recorded Option : "<<arg1<<endl; return IFSelect_RetError; }
363 if (!opt->Switch (arg2)) {
364 sout<<"Option : "<<arg1<<" , Not a suitable case : "<<arg2<<endl;
365 return IFSelect_RetFail;
367 sout<<"Option : "<<arg1<<" switched to case : "<<arg2<<endl;
368 return IFSelect_RetDone;
372 return IFSelect_RetVoid;
376 //=======================================================================
377 //function : newmodel
378 //=======================================================================
379 static IFSelect_ReturnStatus XSControl_newmodel(const Handle(IFSelect_SessionPilot)& pilot)
381 // **** newmodel ****
382 if (!XSControl::Session(pilot)->NewModel().IsNull()) return IFSelect_RetDone;
383 Handle(Message_Messenger) sout = Message::DefaultMessenger();
384 sout<<"No new Model produced"<<endl;
385 return IFSelect_RetFail;
389 //=======================================================================
391 //=======================================================================
392 static IFSelect_ReturnStatus XSControl_tpclear(const Handle(IFSelect_SessionPilot)& pilot)
394 // **** tpclear/twclear ****
395 Standard_Boolean modew = Standard_False;
396 if (pilot->Word(0).Value(2) == 'w') modew = Standard_True;
397 Handle(Transfer_FinderProcess) FP = XSControl::Session(pilot)->MapWriter();
398 Handle(Transfer_TransientProcess) TP = XSControl::Session(pilot)->MapReader();
399 Handle(Message_Messenger) sout = Message::DefaultMessenger();
400 if ( modew) { if(!FP.IsNull()) FP->Clear(); else sout<<"No Transfer Write"<<endl; }
401 else { if(!TP.IsNull()) TP->Clear(); else sout<<"No Transfer Read"<<endl; }
402 return IFSelect_RetDone;
406 //=======================================================================
408 //=======================================================================
409 static IFSelect_ReturnStatus XSControl_tpstat(const Handle(IFSelect_SessionPilot)& pilot)
411 Standard_Integer argc = pilot->NbWords();
412 const Standard_CString arg1 = pilot->Arg(1);
413 //const Standard_CString arg2 = pilot->Arg(2);
414 Handle(Transfer_TransientProcess) TP= XSControl::Session(pilot)->MapReader();
415 Handle(Message_Messenger) sout = Message::DefaultMessenger();
416 if (TP.IsNull()) { sout<<"No Transfer Read"<<endl; return IFSelect_RetError;}
419 Standard_Integer mod1 = -1;
420 Standard_Integer mod2 = 0;
421 // g : general c : check (compte) C (liste) f : fails(compte) F (liste)
422 // resultats racines : n : n0s entites s : status b : binders
423 // t : compte par type r : compte par resultat l : liste(type-resultat)
424 // *n *s *b *t *r *l : idem sur tout
425 // ?n etc.. : idem sur resultats anormaux
426 // ? tout court pour help
429 char a2 = arg1[1]; if (a2 == '\0') a2 = '!';
431 case 'g' : mod1 = 0; break;
432 case 'c' : mod1 = 4; mod2 = 4; break;
433 case 'C' : mod1 = 4; mod2 = 2; break;
434 case 'f' : mod1 = 5; mod2 = 4; break;
435 case 'F' : mod1 = 5; mod2 = 2; break;
436 case '*' : mod1 = 2; break;
437 case '?' : mod1 = 3; break;
438 default : mod1 = 1; if (argc > 2) mod1 = 2; a2 = arg1[0]; break;
440 if (mod1 < 1 || mod1 > 3) a2 = '!';
442 case 'n' : mod2 = 0; break;
443 case 's' : mod2 = 1; break;
444 case 'b' : mod2 = 2; break;
445 case 't' : mod2 = 3; break;
446 case 'r' : mod2 = 4; break;
447 case 'l' : mod2 = 5; break;
448 case 'L' : mod2 = 6; break;
450 case '?' : mod1 = -1; break;
451 default : mod1 = -2; break;
454 // A present help eventuel
455 if (mod1 < -1) sout<<"Unknown Mode"<<endl;
457 sout<<"Modes available :\n"
458 <<"g : general c : checks (count) C (list)"<<"\n"
459 <<" f : fails (count) F (list)"<<"\n"
460 <<" n : numbers of transferred entities (on TRANSFER ROOTS)"<<"\n"
461 <<" s : their status (type entity-result , presence checks)"<<"\n"
462 <<" b : detail of binders"<<"\n"
463 <<" t : count per entity type r : per type/status result"<<"\n"
464 <<" l : count per couple type entity/result"<<"\n"
465 <<" L : list per couple type entity/result"<<"\n"
466 <<" *n *s *b *t *r *l *L : idem on ALL recorded items"<<"\n"
467 <<" ?n ?s ?b ?t ... : idem on abnormal items"<<"\n"
468 <<" n select : n applied on a selection idem for s b t r l"<<endl;
469 if (mod1 < -1) return IFSelect_RetError;
470 return IFSelect_RetVoid;
474 sout<<"TransferRead :";
475 if (TP->Model() != pilot->Session()->Model()) sout<<"Model differs from the session";
476 Handle(TColStd_HSequenceOfTransient) list =
477 IFSelect_Functions::GiveList(pilot->Session(),pilot->CommandPart(2));
478 XSControl_TransferReader::PrintStatsOnList (TP,list,mod1,mod2);
479 // TP->PrintStats (1,sout);
481 else sout<<"TransferRead : not defined"<<endl;
482 return IFSelect_RetVoid;
486 //=======================================================================
488 //=======================================================================
489 static IFSelect_ReturnStatus XSControl_tpent(const Handle(IFSelect_SessionPilot)& pilot)
491 Standard_Integer argc = pilot->NbWords();
492 const Standard_CString arg1 = pilot->Arg(1);
493 Handle(Transfer_TransientProcess) TP= XSControl::Session(pilot)->MapReader();
495 Handle(Message_Messenger) sout = Message::DefaultMessenger();
496 if (TP.IsNull()) { sout<<"No Transfer Read"<<endl; return IFSelect_RetError;}
497 Handle(Interface_InterfaceModel) model = TP->Model();
498 if (model.IsNull()) return IFSelect_RetFail;
500 if (argc < 2) { sout<<"Give ENTITY NUMBER (IN MODEL TransferProcess)"<<endl; return IFSelect_RetError; }
501 Standard_Integer num = atoi(arg1);
502 if (num <= 0 || num > model->NbEntities()) { sout<<"Number not in [1 - "<<model->NbEntities()<<"]"<<endl; return IFSelect_RetError; }
503 Handle(Standard_Transient) ent = model->Value(num);
504 Standard_Integer index = TP->MapIndex (ent);
505 if (index == 0) sout<<"Entity "<<num<<" not recorded in transfer"<<endl;
506 else XSControl::Session(pilot)->PrintTransferStatus (index,Standard_False,sout);
507 return IFSelect_RetVoid;
511 //=======================================================================
513 //=======================================================================
514 static IFSelect_ReturnStatus XSControl_tpitem(const Handle(IFSelect_SessionPilot)& pilot)
516 Standard_Integer argc = pilot->NbWords();
517 const Standard_CString arg1 = pilot->Arg(1);
518 // **** tpitem/tproot/twitem/twroot ****
519 Handle(Message_Messenger) sout = Message::DefaultMessenger();
520 if (argc < 2) { sout<<"Give ITEM NUMBER (in TransferProcess)"<<endl; return IFSelect_RetError; }
521 Standard_Integer num = atoi(arg1);
522 if (pilot->Word(0).Value(3) == 'r') num = -num;
523 Standard_Boolean modew = Standard_False;
524 if (pilot->Word(0).Value(2) == 'w') modew = Standard_True;
525 Handle(Transfer_Binder) binder;
526 Handle(Transfer_Finder) finder;
527 Handle(Standard_Transient) ent;
528 if (!XSControl::Session(pilot)->PrintTransferStatus(num,modew,sout))
529 sout<<" - Num="<<num<<" incorrect"<<endl;
530 return IFSelect_RetVoid;
534 //=======================================================================
536 //=======================================================================
537 static IFSelect_ReturnStatus XSControl_tpatr(const Handle(IFSelect_SessionPilot)& /*pilot*/)
540 Standard_Integer argc = pilot->NbWords();
541 const Standard_CString arg1 = pilot->Arg(1);
542 Handle(XSControl_WorkSession) WS = XSControl::Session(pilot);
543 Handle(Transfer_TransientProcess) TP = WS->MapReader();
545 Handle(Message_Messenger) sout = Message::DefaultMessenger();
546 // tpatr tout court : liste tous les attributs
547 // tpatr nomatr : sur cet attribut, liste les valeurs par entite
550 Handle(Dico_DictionaryOfInteger) list = TP->Attributes();
551 for (Dico_IteratorOfDictionaryOfInteger iter(list); iter.More(); iter.Next()) {
552 TCollection_AsciiString name = iter.Name();
553 Standard_Integer nbatr = iter.Value();
554 Interface_ParamType aty = TP->AttributeType (name.ToCString());
555 sout<<"Name : "<<name<<" Count="<<nbatr<<" Type : ";
557 case Interface_ParamInteger : sout<<"Integer"; break;
558 case Interface_ParamReal : sout<<"Real"; break;
559 case Interface_ParamIdent : sout<<"Object"; break;
560 case Interface_ParamText : sout<<"String"; break;
561 default : sout<<"(Mixed)";
569 Standard_Integer num , nb = 0;
570 sout<<"Attribute Name : "<<arg1<<endl;
571 for (num = TP->NextItemWithAttribute(arg1,0); num > 0;
572 num = TP->NextItemWithAttribute(arg1,num)) {
574 sout<<"Item "<<num<<" , Entity ";
575 WS->Model()->Print(TP->Mapped(num),sout);
576 Handle(Transfer_Binder) bnd = TP->MapItem (num);
577 Interface_ParamType aty = bnd->AttributeType(arg1);
579 case Interface_ParamInteger : sout<<" Integer="<<bnd->IntegerAttribute(arg1); break;
580 case Interface_ParamReal : sout<<" Real="<<bnd->RealAttribute(arg1); break;
581 case Interface_ParamIdent : sout<<" Object,Type:"<<bnd->Attribute(arg1)->DynamicType()->Name(); break;
582 case Interface_ParamText : sout<<" String="<<bnd->StringAttribute(arg1);
583 default : sout<<"(none)"; break;
587 sout<<"Attribute Name : "<<arg1<<" on "<<nb<<" Items"<<endl;
591 return IFSelect_RetVoid;
595 //=======================================================================
597 //=======================================================================
598 static IFSelect_ReturnStatus XSControl_trecord(const Handle(IFSelect_SessionPilot)& pilot)
600 Standard_Integer argc = pilot->NbWords();
601 const Standard_CString arg1 = pilot->Arg(1);
602 Handle(Transfer_TransientProcess) TP = XSControl::Session(pilot)->MapReader();
603 // **** trecord : TransferReader ****
604 Standard_Boolean tous = (argc == 1);
605 Standard_Integer num = -1;
606 Handle(Interface_InterfaceModel) mdl = XSControl::Session(pilot)->Model();
607 Handle(XSControl_TransferReader) TR = XSControl::Session(pilot)->TransferReader();
608 Handle(Standard_Transient) ent;
609 Handle(Message_Messenger) sout = Message::DefaultMessenger();
610 if (mdl.IsNull() || TR.IsNull() || TP.IsNull())
611 { sout<<" init not done"<<endl; return IFSelect_RetError; }
612 if (!tous) num = atoi(arg1);
613 // Enregistrer les racines
615 Standard_Integer nb = TP->NbRoots();
616 sout<<" Recording "<<nb<<" Roots"<<endl;
617 for (Standard_Integer i = 1; i <= nb; i ++) {
619 if (TR->RecordResult (ent)) sout<<" Root n0."<<i<<endl;
620 else sout<<" Root n0."<<i<<" not recorded"<<endl;
623 if (num < 1 || num > mdl->NbEntities()) sout<<"incorrect number:"<<num<<endl;
624 else if (TR->RecordResult(mdl->Value(num))) sout<<" Entity n0."<<num<<endl;
625 else sout<<" Entity n0."<<num<<" not recorded"<<endl;
627 return IFSelect_RetDone;
631 //=======================================================================
633 //=======================================================================
634 static IFSelect_ReturnStatus XSControl_trstat(const Handle(IFSelect_SessionPilot)& pilot)
636 Standard_Integer argc = pilot->NbWords();
637 const Standard_CString arg1 = pilot->Arg(1);
638 Handle(Message_Messenger) sout = Message::DefaultMessenger();
639 // **** trstat : TransferReader ****
640 Handle(XSControl_TransferReader) TR = XSControl::Session(pilot)->TransferReader();
641 if (TR.IsNull()) { sout<<" init not done"<<endl; return IFSelect_RetError; }
642 Handle(Interface_InterfaceModel) mdl = TR->Model();
643 if (mdl.IsNull()) { sout<<" No model"<<endl; return IFSelect_RetError; }
644 sout<<" Statistics : FileName : "<<TR->FileName()<<endl;
647 TR->PrintStats(10,0);
650 Standard_Integer num = atoi(arg1);
651 if (num < 1 || num > mdl->NbEntities()) { sout<<" incorrect number:"<<arg1<<endl; return IFSelect_RetError; }
652 Handle(Standard_Transient) ent = mdl->Value(num);
653 if (!TR->IsRecorded(ent)) { sout<<" Entity "<<num<<" not recorded"<<endl; return IFSelect_RetError; }
654 Handle(Transfer_ResultFromModel) RM = TR->FinalResult(ent);
655 Handle(TColStd_HSequenceOfTransient) list = TR->CheckedList(ent);
656 Standard_Integer i, nb = list->Length();
657 if (nb > 0) sout<<" Entities implied by Check/Result :"<<nb<<" i.e.:";
658 for (i = 1; i <= nb; i ++) { sout<<" "; mdl->Print(list->Value(i),sout); }
660 if (RM.IsNull()) { sout<<" no other info"<<endl; return IFSelect_RetVoid; }
661 Interface_CheckIterator chl = RM->CheckList(Standard_False);
662 pilot->Session()->PrintCheckList(chl,Standard_False,IFSelect_EntitiesByItem);
664 return IFSelect_RetVoid;
668 //=======================================================================
670 //=======================================================================
671 static IFSelect_ReturnStatus XSControl_trbegin(const Handle(IFSelect_SessionPilot)& pilot)
673 // **** trbegin : TransferReader ****
674 Handle(XSControl_TransferReader) TR = XSControl::Session(pilot)->TransferReader();
675 Standard_Boolean init = TR.IsNull();
676 if (pilot->NbWords() > 1) { if (pilot->Arg(1)[0] == 'i') init = Standard_True; }
678 XSControl::Session(pilot)->InitTransferReader (0);
679 TR = XSControl::Session(pilot)->TransferReader();
681 Handle(Message_Messenger) sout = Message::DefaultMessenger();
682 sout<<" init not done or failed"<<endl;
683 return IFSelect_RetError;
687 return IFSelect_RetDone;
691 //=======================================================================
693 //=======================================================================
694 static IFSelect_ReturnStatus XSControl_tread(const Handle(IFSelect_SessionPilot)& pilot)
696 Standard_Integer argc = pilot->NbWords();
697 //const Standard_CString arg1 = pilot->Arg(1);
698 // **** tread : TransferReader ****
699 Handle(Message_Messenger) sout = Message::DefaultMessenger();
700 Handle(XSControl_TransferReader) TR = XSControl::Session(pilot)->TransferReader();
701 if (TR.IsNull()) { sout<<" init not done"<<endl; return IFSelect_RetError; }
702 Handle(Interface_InterfaceModel) mdl = TR->Model();
703 if (mdl.IsNull()) { sout<<" No model"<<endl; return IFSelect_RetError; }
705 // DeclareAndCast(IFSelect_Selection,sel,pilot->Session()->NamedItem("xst-model-roots"));
706 Handle(Standard_Transient) sel = pilot->Session()->NamedItem("xst-model-roots");
707 if (sel.IsNull()) { sout<<"Select Roots absent"<<endl; return IFSelect_RetError; }
708 Handle(TColStd_HSequenceOfTransient) list = pilot->Session()->GiveList(sel);
709 sout<<" Transferring all roots i.e. : "<<TR->TransferList(list)<<endl;
711 Handle(TColStd_HSequenceOfTransient) list =
712 IFSelect_Functions::GiveList(pilot->Session(),pilot->CommandPart(1));
713 sout<<" Transfer of "<<list->Length()<<" entities"<<endl;
714 Standard_Integer nb = TR->TransferList(list);
715 sout<<" Gives "<<nb<<" results"<<endl;
717 return IFSelect_RetDone;
721 //=======================================================================
723 //=======================================================================
724 static IFSelect_ReturnStatus XSControl_trtp(const Handle(IFSelect_SessionPilot)& pilot)
726 // **** TReader -> TProcess ****
727 Handle(XSControl_TransferReader) TR = XSControl::Session(pilot)->TransferReader();
728 Handle(Message_Messenger) sout = Message::DefaultMessenger();
729 if (TR.IsNull()) sout<<" No TransferReader"<<endl;
730 else if (TR->TransientProcess().IsNull()) sout<<" Transfer Reader without Process"<<endl;
731 ////else { XSDRAW::SetTransferProcess(TR->TransientProcess()); return IFSelect_RetDone; }
732 return IFSelect_RetVoid;
736 //=======================================================================
738 //=======================================================================
739 static IFSelect_ReturnStatus XSControl_tptr(const Handle(IFSelect_SessionPilot)& pilot)
741 // **** TProcess -> TReader ****
742 XSControl::Session(pilot)->InitTransferReader (3);
743 return IFSelect_RetDone;
747 //=======================================================================
749 //=======================================================================
750 static IFSelect_ReturnStatus XSControl_twmode(const Handle(IFSelect_SessionPilot)& pilot)
752 Standard_Integer argc = pilot->NbWords();
753 const Standard_CString arg1 = pilot->Arg(1);
755 Handle(XSControl_TransferWriter) TW = XSControl::Session(pilot)->TransferWriter();
756 Handle(XSControl_Controller) control = XSControl::Session(pilot)->NormAdaptor();
757 Standard_Integer modemin,modemax;
758 Handle(Message_Messenger) sout = Message::DefaultMessenger();
759 if (control->ModeWriteBounds (modemin,modemax)) {
760 sout<<"Write Mode : allowed values "<<modemin<<" to "<<modemax<<endl;
761 for (Standard_Integer modd = modemin; modd <= modemax; modd ++) {
762 sout<<modd<<" : "<<control->ModeWriteHelp (modd)<<endl;;
765 sout<<"Write Mode : actual = "<<TW->TransferMode()<<endl;
766 if (argc <= 1) return IFSelect_RetVoid;
767 Standard_Integer mod = atoi(arg1);
768 sout<<"New value -> "<<arg1<<endl;
769 TW->SetTransferMode(mod);
770 if (!control->IsModeWrite (mod)) sout<<"Warning : this new value is not supported"<<endl;
771 return IFSelect_RetDone;
775 //=======================================================================
777 //=======================================================================
778 static IFSelect_ReturnStatus XSControl_twstat(const Handle(IFSelect_SessionPilot)& pilot)
780 //Standard_Integer argc = pilot->NbWords();
781 //const Standard_CString arg1 = pilot->Arg(1);
782 //const Standard_CString arg2 = pilot->Arg(2);
783 Handle(Transfer_FinderProcess) FP = XSControl::Session(pilot)->MapWriter();
786 Handle(Message_Messenger) sout = Message::DefaultMessenger();
788 sout<<"TransferWrite:";
789 // XSControl_TransferWriter::PrintStatsProcess (FP,mod1,mod2);
790 FP->PrintStats (1,sout);
792 else sout<<"TransferWrite: not defined"<<endl;
793 return IFSelect_RetVoid;
797 //=======================================================================
798 //function : settransfert
799 //=======================================================================
800 static IFSelect_ReturnStatus XSControl_settransfert(const Handle(IFSelect_SessionPilot)& pilot)
802 // **** SelectForTransfer ****
803 return pilot->RecordItem(new XSControl_SelectForTransfer(XSControl::Session(pilot)->TransferReader()));
808 static int initactor = 0;
810 //=======================================================================
813 //=======================================================================
815 void XSControl_Functions::Init ()
817 if (initactor) return; initactor = 1;
818 IFSelect_Act::SetGroup("DE: General");
820 IFSelect_Act::AddFunc ("xinit","[norm:string to change norme] reinitialises according to the norm",XSControl_xinit);
821 IFSelect_Act::AddFunc ("xnorm","displays current norm +norm : changes it",XSControl_xnorm);
822 IFSelect_Act::AddFunc ("xprofile","displays current profile +prof : changes it",XSControl_xprofile);
823 IFSelect_Act::AddFunc ("xoption","lists options +opt : lists cases +case : changes current case",XSControl_xoption);
825 IFSelect_Act::AddFunc ("newmodel","produces a new empty model, for the session",XSControl_newmodel);
827 IFSelect_Act::AddFunc ("tpclear","Clears TransferProcess (READ)",XSControl_tpclear);
828 IFSelect_Act::AddFunc ("twclear","Clears TransferProcess (WRITE)",XSControl_tpclear);
830 IFSelect_Act::AddFunc ("tpstat","Statistics on TransferProcess (READ)",XSControl_tpstat);
832 IFSelect_Act::AddFunc ("tpent","[num:integer] Statistics on an entity of the model (READ)",XSControl_tpent);
834 IFSelect_Act::AddFunc ("tpitem","[num:integer] Statistics on ITEM of transfer (READ)" ,XSControl_tpitem);
835 IFSelect_Act::AddFunc ("tproot","[num:integer] Statistics on a ROOT of transfert (READ)" ,XSControl_tpitem);
836 IFSelect_Act::AddFunc ("twitem","[num:integer] Statistics on an ITEM of transfer (WRITE)" ,XSControl_tpitem);
837 IFSelect_Act::AddFunc ("twroot","[num:integer] Statistics on a ROOT of transfer (WRITE)",XSControl_tpitem);
838 IFSelect_Act::AddFunc ("tpatr","[name] List all Attributes, or values for a Name",XSControl_tpatr);
840 IFSelect_Act::AddFunc ("trecord","record : all root results; or num : for entity n0.num",XSControl_trecord);
841 IFSelect_Act::AddFunc ("trstat","general statistics; or num : stats on entity n0 num",XSControl_trstat);
842 IFSelect_Act::AddFunc ("trbegin","begin-transfer-reader [init]",XSControl_trbegin);
843 IFSelect_Act::AddFunc ("tread","transfers all roots, or num|sel|sel num : entity list, by transfer-reader",XSControl_tread);
845 IFSelect_Act::AddFunc ("trtp","feeds commands tp... with results from tr...",XSControl_trtp);
846 IFSelect_Act::AddFunc ("tptr","feeds tr... from tp... (may be incomplete)",XSControl_tptr);
848 IFSelect_Act::AddFunc ("twmode","displays mode transfer write, + num changes it",XSControl_twmode);
849 IFSelect_Act::AddFunc ("twstat","Statistics on TransferProcess (WRITE)",XSControl_twstat);
851 IFSelect_Act::AddFSet ("selecttransfer","selection (recognize from transfer actor)",XSControl_settransfert);