3df9402d3fe2476aea7bea8dbc2e85d919629b16
[occt.git] / src / XSControl / XSControl_Controller.cxx
1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
2 //
3 // This file is part of Open CASCADE Technology software library.
4 //
5 // This library is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU Lesser General Public License version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
10 //
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
13
14
15 #include <Dico_DictionaryOfTransient.hxx>
16 #include <Dico_IteratorOfDictionaryOfInteger.hxx>
17 #include <Dico_IteratorOfDictionaryOfTransient.hxx>
18 #include <IFSelect_DispPerCount.hxx>
19 #include <IFSelect_DispPerFiles.hxx>
20 #include <IFSelect_DispPerOne.hxx>
21 #include <IFSelect_DispPerSignature.hxx>
22 #include <IFSelect_EditForm.hxx>
23 #include <IFSelect_GeneralModifier.hxx>
24 #include <IFSelect_GraphCounter.hxx>
25 #include <IFSelect_IntParam.hxx>
26 #include <IFSelect_ParamEditor.hxx>
27 #include <IFSelect_SelectModelEntities.hxx>
28 #include <IFSelect_SelectModelRoots.hxx>
29 #include <IFSelect_SelectPointed.hxx>
30 #include <IFSelect_SelectShared.hxx>
31 #include <IFSelect_SelectSharing.hxx>
32 #include <IFSelect_ShareOut.hxx>
33 #include <IFSelect_SignAncestor.hxx>
34 #include <IFSelect_Signature.hxx>
35 #include <IFSelect_SignCategory.hxx>
36 #include <IFSelect_SignCounter.hxx>
37 #include <IFSelect_SignType.hxx>
38 #include <IFSelect_SignValidity.hxx>
39 #include <IFSelect_WorkLibrary.hxx>
40 #include <Interface_CheckIterator.hxx>
41 #include <Interface_InterfaceModel.hxx>
42 #include <Interface_Macros.hxx>
43 #include <Interface_Protocol.hxx>
44 #include <Interface_Static.hxx>
45 #include <Message.hxx>
46 #include <Message_Messenger.hxx>
47 #include <MoniTool_Option.hxx>
48 #include <MoniTool_Profile.hxx>
49 #include <Standard_DomainError.hxx>
50 #include <Standard_Transient.hxx>
51 #include <Standard_Type.hxx>
52 #include <TCollection_HAsciiString.hxx>
53 #include <TColStd_HSequenceOfHAsciiString.hxx>
54 #include <TColStd_IndexedMapOfTransient.hxx>
55 #include <TopoDS_Shape.hxx>
56 #include <Transfer_ActorOfFinderProcess.hxx>
57 #include <Transfer_ActorOfTransientProcess.hxx>
58 #include <Transfer_Binder.hxx>
59 #include <Transfer_FinderProcess.hxx>
60 #include <Transfer_SimpleBinderOfTransient.hxx>
61 #include <Transfer_TransientMapper.hxx>
62 #include <TransferBRep_ShapeMapper.hxx>
63 #include <XSControl_ConnectedShapes.hxx>
64 #include <XSControl_Controller.hxx>
65 #include <XSControl_SelectForTransfer.hxx>
66 #include <XSControl_SignTransferStatus.hxx>
67 #include <XSControl_TransferReader.hxx>
68 #include <XSControl_WorkSession.hxx>
69
70 IMPLEMENT_STANDARD_RTTIEXT(XSControl_Controller,MMgt_TShared)
71
72 //  ParamEditor
73 //  Transferts
74 static Handle(Dico_DictionaryOfTransient)& listadapt()
75 {
76   static Handle(Dico_DictionaryOfTransient) listad;
77   if (listad.IsNull()) listad = new Dico_DictionaryOfTransient;
78   return listad;
79 }
80
81 static TColStd_IndexedMapOfTransient&      mapadapt()
82 {
83   static TColStd_IndexedMapOfTransient     mapad;
84   return mapad;
85 }
86
87
88     XSControl_Controller::XSControl_Controller
89   (const Standard_CString longname, const Standard_CString shortname)
90     : theShortName (shortname) , theLongName (longname) 
91 {
92   theAdaptorApplied.Clear();
93   theAdaptorHooks = new TColStd_HSequenceOfHAsciiString();
94
95   //  Parametres Standard
96
97   Interface_Static::Standards();
98 //  TraceStatic ("read.stdsameparameter.mode",5);
99   TraceStatic ("read.precision.mode" , 5);
100   TraceStatic ("read.precision.val"  , 5);
101   TraceStatic ("write.precision.mode" , 6);
102   TraceStatic ("write.precision.val"  , 6);
103
104   //  Initialisation du Profile
105
106   theProfile = new MoniTool_Profile;
107
108 /*  essai option sur parametre
109   Handle(MoniTool_Option) optrdprec = new MoniTool_Option
110     (Interface_Static::Static ("read.precision.mode"),"readprecision.mode");
111   optrdprec->AddBasic("default","File");
112   optrdprec->AddBasic("Session");
113   optrdprec->Switch ("default");
114   theProfile->AddOption (optrdprec);
115 */
116
117 //  Handle(MoniTool_Option) optproto = new MoniTool_Option
118 //    (STANDARD_TYPE(Interface_Protocol),"protocol");
119 //  theProfile->AddOption (optproto);
120
121   Handle(MoniTool_Option) optsign  = new MoniTool_Option
122     (STANDARD_TYPE(IFSelect_Signature),"sign-type");
123   optsign->Add ("default",theSignType);
124   theProfile->AddOption (optsign);
125
126 //  Handle(MoniTool_Option) optwlib  = new MoniTool_Option
127 //    (STANDARD_TYPE(IFSelect_WorkLibrary),"access");
128 //  theProfile->AddOption (optwlib);
129
130   Handle(MoniTool_Option) optactrd = new MoniTool_Option
131     (STANDARD_TYPE(Transfer_ActorOfTransientProcess),"tr-read");
132   theProfile->AddOption (optactrd);
133
134   Handle(MoniTool_Option) optactwr = new MoniTool_Option
135     (STANDARD_TYPE(Transfer_ActorOfFinderProcess),"tr-write");
136   theProfile->AddOption (optactwr);
137
138 //    Definition de la config de base : suite a la customisation
139 }
140
141     void  XSControl_Controller::SetNames
142   (const Standard_CString longname, const Standard_CString shortname)
143 {
144   if (longname && longname[0] != '\0') {
145     theLongName.Clear();   theLongName.AssignCat  (longname);
146   }
147   if (shortname && shortname[0] != '\0') {
148     theShortName.Clear();  theShortName.AssignCat (shortname);
149   }
150 }
151
152     void  XSControl_Controller::AutoRecord () const
153 {
154   Record (Name(Standard_True));
155   Record (Name(Standard_False));
156 }
157
158     void  XSControl_Controller::Record (const Standard_CString name) const
159 {
160   Standard_Boolean deja;
161   Handle(Standard_Transient)& newadapt = listadapt()->NewItem (name,deja);
162   if (deja) {
163     Handle(Standard_Transient) thisadapt (this);
164     if (newadapt->IsKind(thisadapt->DynamicType())) 
165       {
166       }
167     else if  (thisadapt->IsKind(newadapt->DynamicType()))
168       {
169         newadapt = this;
170         if (mapadapt().FindIndex(newadapt) == 0) mapadapt().Add(newadapt);
171       }
172     else 
173       if (thisadapt != newadapt) Standard_DomainError::Raise
174       ("XSControl_Controller : Record");
175   }
176   else {
177     newadapt = this;
178     if (mapadapt().FindIndex(newadapt) == 0) mapadapt().Add(newadapt);
179   }
180 }
181
182     Handle(XSControl_Controller)  XSControl_Controller::Recorded
183   (const Standard_CString name)
184 {
185   Handle(Standard_Transient) recorded;
186   if (!listadapt()->GetItem (name,recorded)) recorded.Nullify();
187   return Handle(XSControl_Controller)::DownCast (recorded);
188 }
189
190     Handle(TColStd_HSequenceOfHAsciiString)  XSControl_Controller::ListRecorded
191   (const Standard_Integer mode)
192 {
193   Handle(TColStd_HSequenceOfHAsciiString) list = new TColStd_HSequenceOfHAsciiString();
194   if (mode == 0) {
195     Dico_IteratorOfDictionaryOfTransient iter (listadapt());
196     for (; iter.More(); iter.Next()) {
197       Handle(TCollection_HAsciiString) name = new TCollection_HAsciiString
198         (iter.Name());
199       list->Append(name);
200     }
201   } else {
202     Standard_Integer i, nb = mapadapt().Extent();
203     for (i = 1; i <= nb; i ++) {
204       DeclareAndCast(XSControl_Controller,ctl,mapadapt().FindKey(i));
205       if (ctl.IsNull()) continue;
206       Handle(TCollection_HAsciiString) name = new TCollection_HAsciiString
207         (ctl->Name( (mode < 0) ));
208       list->Append(name);
209     }
210   }
211   return list;
212 }
213
214     Standard_CString  XSControl_Controller::Name (const Standard_Boolean rsc) const
215       {  return (rsc ? theShortName.ToCString() : theLongName.ToCString());  }
216
217 //    ####    PROFILE    ####
218
219     Handle(MoniTool_Profile)  XSControl_Controller::Profile () const
220       {  return theProfile;  }
221
222     void  XSControl_Controller::DefineProfile
223   (const Standard_CString confname)
224 {
225   if (!theProfile->HasConf(confname)) theProfile->AddConf (confname);
226   theProfile->SetFromCurrent (confname);
227 }
228
229     Standard_Boolean  XSControl_Controller::SetProfile
230   (const Standard_CString confname)
231 {
232   if (!theProfile->SetCurrent (confname)) return Standard_False;
233
234   Handle(Standard_Transient) anItem;
235 //  theProfile->Value("protocol",theAdaptorProtocol);
236   if (theProfile->Value("sign-type",anItem))
237     theSignType = Handle(IFSelect_Signature)::DownCast (anItem);
238 //  theProfile->Value("access",theAdaptorLibrary);
239   if (theProfile->Value("tr-read",anItem))
240     theAdaptorRead = Handle(Transfer_ActorOfTransientProcess)::DownCast (anItem);
241   if (theProfile->Value("tr-write",anItem))
242     theAdaptorWrite = Handle(Transfer_ActorOfFinderProcess)::DownCast (anItem);
243
244   return SettingProfile (confname);
245 }
246
247     Standard_Boolean  XSControl_Controller::SettingProfile
248   (const Standard_CString )
249       {  return Standard_True;  }
250
251     Standard_Boolean  XSControl_Controller::ApplyProfile
252   (const Handle(XSControl_WorkSession)& WS, const Standard_CString confname)
253 {
254   if (!SetProfile (confname)) return Standard_False;
255
256 //   Typed Values : toutes
257
258   theProfile->SetTypedValues();
259
260 //   SignType
261   Handle(Standard_Transient) signtype;
262   theProfile->Value ("sign-type",signtype);
263   WS->SetSignType (Handle(IFSelect_Signature)::DownCast (signtype));
264
265 //   ActorRead
266
267   Handle(Standard_Transient) actrd;
268   theProfile->Value ("tr-read",actrd);
269   WS->TransferReader()->SetActor (Handle(Transfer_ActorOfTransientProcess)::DownCast (actrd));
270
271 //   ActorWrite : dans le Controller meme
272
273   Handle(Standard_Transient) actwr;
274   theProfile->Value ("tr-write",actwr);
275   theAdaptorWrite = Handle (Transfer_ActorOfFinderProcess)::DownCast (actwr);
276
277   return ApplyingProfile (WS,confname);
278 }
279
280     Standard_Boolean  XSControl_Controller::ApplyingProfile
281   (const Handle(XSControl_WorkSession)& , const Standard_CString )
282     {  return Standard_True;  }
283
284 //    ####    DEFINITION    ####
285
286     Handle(Interface_Protocol)  XSControl_Controller::Protocol () const
287       {  return theAdaptorProtocol;  }
288
289     Handle(IFSelect_Signature)  XSControl_Controller::SignType () const
290       {  return theSignType;  }
291
292     Handle(IFSelect_WorkLibrary)  XSControl_Controller::WorkLibrary () const
293       {  return theAdaptorLibrary;  }
294
295     Handle(Transfer_ActorOfFinderProcess)  XSControl_Controller::ActorWrite () const
296       {  return theAdaptorWrite;  }
297
298     void  XSControl_Controller::UpdateStatics
299   (const Standard_Integer, const Standard_CString ) const
300       {  }    // a redefinir si besoin
301
302 // ###########################
303 //  Help du Transfer : controle de valeur + help
304
305     void  XSControl_Controller::SetModeWrite
306   (const Standard_Integer modemin, const Standard_Integer modemax,
307    const Standard_Boolean )
308 {
309   if (modemin > modemax)  {  theModeWriteShapeN.Nullify(); return;  }
310   theModeWriteShapeN = new Interface_HArray1OfHAsciiString (modemin,modemax);
311 }
312
313     void  XSControl_Controller::SetModeWriteHelp
314   (const Standard_Integer modetrans, const Standard_CString help,
315    const Standard_Boolean )
316 {
317   if (theModeWriteShapeN.IsNull()) return;
318   if (modetrans < theModeWriteShapeN->Lower() ||
319       modetrans > theModeWriteShapeN->Upper()) return;
320   Handle(TCollection_HAsciiString) hl = new TCollection_HAsciiString (help);
321   theModeWriteShapeN->SetValue (modetrans,hl);
322 }
323
324     Standard_Boolean  XSControl_Controller::ModeWriteBounds
325   (Standard_Integer& modemin, Standard_Integer& modemax,
326    const Standard_Boolean ) const
327 {
328   modemin = modemax = 0;
329   if (theModeWriteShapeN.IsNull()) return Standard_False;
330   modemin = theModeWriteShapeN->Lower();
331   modemax = theModeWriteShapeN->Upper();
332   return Standard_True;
333 }
334
335     Standard_Boolean  XSControl_Controller::IsModeWrite
336   (const Standard_Integer modetrans, const Standard_Boolean ) const
337 {
338   if (theModeWriteShapeN.IsNull()) return Standard_True;
339   if (modetrans < theModeWriteShapeN->Lower()) return Standard_False;
340   if (modetrans > theModeWriteShapeN->Upper()) return Standard_False;
341   return Standard_True;
342 }
343
344     Standard_CString  XSControl_Controller::ModeWriteHelp
345   (const Standard_Integer modetrans, const Standard_Boolean ) const
346 {
347   if (theModeWriteShapeN.IsNull()) return "";
348   if (modetrans < theModeWriteShapeN->Lower()) return "";
349   if (modetrans > theModeWriteShapeN->Upper()) return "";
350   Handle(TCollection_HAsciiString) str = theModeWriteShapeN->Value(modetrans);
351   if (str.IsNull()) return "";
352   return str->ToCString();
353 }
354
355
356 // ###########################
357 //  Transfer : on fait ce qu il faut par defaut (avec ActorWrite)
358 //    peut etre redefini ...
359
360     Standard_Boolean  XSControl_Controller::RecognizeWriteTransient
361   (const Handle(Standard_Transient)& obj,
362    const Standard_Integer modetrans) const
363 {
364   if (theAdaptorWrite.IsNull()) return Standard_False;
365   theAdaptorWrite->ModeTrans() = modetrans;
366   return theAdaptorWrite->Recognize (new Transfer_TransientMapper(obj));
367 }
368
369 //    Fonction interne
370
371 static IFSelect_ReturnStatus TransferFinder
372   (const Handle(Transfer_ActorOfFinderProcess)& actor,
373    const Handle(Transfer_Finder)& mapper,
374    const Handle(Transfer_FinderProcess)& FP,
375    const Handle(Interface_InterfaceModel)& model,
376    const Standard_Integer modetrans)
377 {
378   if (actor.IsNull()) return IFSelect_RetError;
379   if (model.IsNull()) return IFSelect_RetError;
380   actor->ModeTrans() = modetrans;
381   FP->SetModel (model);
382   FP->SetActor (actor);
383   FP->Transfer (mapper);
384
385   IFSelect_ReturnStatus stat = IFSelect_RetFail;
386   Handle(Transfer_Binder) binder = FP->Find (mapper);
387   Handle(Transfer_SimpleBinderOfTransient) bindtr;
388   while (!binder.IsNull()) {
389     bindtr = Handle(Transfer_SimpleBinderOfTransient)::DownCast (binder);
390     if (!bindtr.IsNull()) {
391       Handle(Standard_Transient) ent = bindtr->Result();
392       if (!ent.IsNull()) {
393         stat = IFSelect_RetDone;
394         model->AddWithRefs (ent);
395       }
396     }
397     binder = binder->NextResult();
398   }
399   return stat;
400 }
401
402
403     IFSelect_ReturnStatus  XSControl_Controller::TransferWriteTransient
404   (const Handle(Standard_Transient)& obj,
405    const Handle(Transfer_FinderProcess)& FP,
406    const Handle(Interface_InterfaceModel)& model,
407    const Standard_Integer modetrans) const
408 {
409   if (obj.IsNull()) return IFSelect_RetVoid;
410   return TransferFinder
411     (theAdaptorWrite,new Transfer_TransientMapper(obj), FP,model,modetrans);
412 }
413
414     Standard_Boolean  XSControl_Controller::RecognizeWriteShape
415   (const TopoDS_Shape& shape,
416    const Standard_Integer modetrans) const
417 {
418   if (theAdaptorWrite.IsNull()) return Standard_False;
419   theAdaptorWrite->ModeTrans() = modetrans;
420   return theAdaptorWrite->Recognize (new TransferBRep_ShapeMapper(shape));
421 }
422
423     IFSelect_ReturnStatus  XSControl_Controller::TransferWriteShape
424   (const TopoDS_Shape& shape,
425    const Handle(Transfer_FinderProcess)& FP,
426    const Handle(Interface_InterfaceModel)& model,
427    const Standard_Integer modetrans) const
428 {
429   if (shape.IsNull()) return IFSelect_RetVoid;
430
431   IFSelect_ReturnStatus theReturnStat = TransferFinder
432     (theAdaptorWrite,new TransferBRep_ShapeMapper(shape), FP,model,modetrans);
433   return theReturnStat;
434 }
435
436 // ###########################
437 //  File Cluster : quand un ensemble de donnees n est pas envoye d un coup mais
438 //    en plusieurs petits paquets ...
439 //  D abord, on detecte la chose et on prepare un contexte de resolution
440 //    specifique du cas a traiter. Null Handle si rien a faire (par defaut)
441 //  Ensuite on resoud
442 //    Les formules par defaut ne font rien (redefinissables)
443
444     Handle(Standard_Transient)  XSControl_Controller::ClusterContext
445   (const Handle(XSControl_WorkSession)& ) const
446       {  Handle(Standard_Transient) nulctx;  return nulctx;  }
447
448     Interface_CheckIterator  XSControl_Controller::ResolveCluster
449   (const Handle(XSControl_WorkSession)& , const Handle(Standard_Transient)& ) const
450       {  Interface_CheckIterator nulist;  return nulist;  }
451
452
453 // ###########################
454 //  ControlItems : si ActorWrite etc... ne suffisent meme plus, on peut en
455 //    rajouter, Controller ne fait alors que les accueillir
456
457     void  XSControl_Controller::AddControlItem
458   (const Handle(Standard_Transient)& item, const Standard_CString name)
459 {
460   if (item.IsNull() || name[0] == '\0') return;
461   if (theItems.IsNull()) theItems = new Dico_DictionaryOfTransient;
462   theItems->SetItem (name,item);
463 }
464
465     Handle(Standard_Transient)  XSControl_Controller::ControlItem
466   (const Standard_CString name) const
467 {
468   Handle(Standard_Transient) item;
469   if (theItems.IsNull()) return item;
470   theItems->GetItem (name,item);
471   return item;
472 }
473
474 // ###########################
475 //  Cutomisation ! On enregistre des Items pour une WorkSession
476 //     (annule et remplace)
477 //     Ensuite, on les remet en place a la demande
478
479     void  XSControl_Controller::TraceStatic
480   (const Standard_CString name, const Standard_Integer use)
481 {
482   Handle(Interface_Static) val = Interface_Static::Static(name);
483   if (val.IsNull()) return;
484   theParams.Append (val);
485   theParamUses.Append(use);
486 }
487
488     void  XSControl_Controller::AddSessionItem
489   (const Handle(Standard_Transient)& item, const Standard_CString name,
490    const Standard_CString setapplied)
491 {
492   if (item.IsNull() || name[0] == '\0') return;
493   if (theAdaptorSession.IsNull()) theAdaptorSession =
494     new Dico_DictionaryOfTransient;
495   theAdaptorSession->SetItem (name,item);
496   if (!setapplied || setapplied[0] == '\0') return;
497   if (item->IsKind(STANDARD_TYPE(IFSelect_GeneralModifier))) {
498 //    cout<<" -- Xstep Controller : SetApplied n0."<<theAdaptorApplied.Length()+1
499 //      <<" Name:"<<name<<endl;
500     theAdaptorApplied.Append(item);
501     Handle(TCollection_HAsciiString) hook = new TCollection_HAsciiString(setapplied);
502     theAdaptorHooks->Append (hook);
503   }
504 }
505
506     Handle(Standard_Transient)  XSControl_Controller::SessionItem
507   (const Standard_CString name) const
508 {
509   Handle(Standard_Transient) item;
510   if (theAdaptorSession.IsNull()) return item;
511   theAdaptorSession->GetItem (name,item);
512   return item;
513 }
514
515     Standard_Boolean  XSControl_Controller::IsApplied
516   (const Handle(Standard_Transient)& item) const
517 {
518   if (item.IsNull()) return Standard_False;
519   for (Standard_Integer i = theAdaptorApplied.Length(); i >= 1; i --)
520     if (item == theAdaptorApplied.Value(i)) return Standard_True;
521   return Standard_False;
522 }
523
524     void  XSControl_Controller::Customise
525   ( Handle(XSControl_WorkSession)& WS) 
526 {
527   WS->SetParams (theParams,theParamUses);
528
529
530 //  General
531   if(!theAdaptorSession.IsNull()) {
532     Dico_IteratorOfDictionaryOfTransient iter(theAdaptorSession);
533     for (iter.Start(); iter.More(); iter.Next()) {
534       WS->AddNamedItem (iter.Name().ToCString() , iter.Value());
535     }
536   }
537   Customising(WS);
538 //  Applied Modifiers
539   Standard_Integer i, nb = theAdaptorApplied.Length();
540   for (i = 1; i <= nb; i ++) {
541     Handle(Standard_Transient) anitem = theAdaptorApplied.Value(i);
542     Handle(TCollection_HAsciiString) name = WS->Name(anitem);
543 //    Handle(Message_Messenger) sout = Message::DefaultMessenger();
544 //    sout<<" --  Customise applied n0."<<i<<" type:"<<anitem->DynamicType()->Name();
545 //    if (name.IsNull()) sout<<" no name"<<endl;
546 //    else sout<<" name:"<<name->ToCString()<<endl;
547     WS->SetAppliedModifier
548       (GetCasted(IFSelect_GeneralModifier,theAdaptorApplied.Value(i)),
549        WS->ShareOut() );
550   }
551
552 //  Editeurs de Parametres
553 //  Ici car les constructeurs specifiques des controlleurs ont pu creer des
554 //  Parametres : attendre donc ici
555
556   Handle(TColStd_HSequenceOfHAsciiString) listat = Interface_Static::Items();
557   Handle(IFSelect_ParamEditor) paramed =
558     IFSelect_ParamEditor::StaticEditor (listat,"All Static Parameters");
559   WS->AddNamedItem ("xst-static-params-edit",paramed);
560   Handle(IFSelect_EditForm) paramform = paramed->Form(Standard_False);
561   WS->AddNamedItem ("xst-static-params",paramform);
562   
563 //   Norm Specific
564   //Customising (WS);
565
566 //   Loading Options of the Profile
567
568 //   Available Signatures
569   Handle(MoniTool_Option) optsign  = theProfile->Option ("sign-type");
570 //  Handle(TColStd_HSequenceOfHAsciiString) signs =
571 //    WS->ItemNames (STANDARD_TYPE(IFSelect_Signature));
572 //  Standard_Integer isign, nbsign = (signs.IsNull() ? 0 : signs->Length());
573 //  for (isign = 1; isign <= nbsign; isign ++) {
574 //    Handle(TCollection_HAsciiString) signame = signs->Value(isign);
575 //    Handle(Standard_Transient) asign = WS->NamedItem (signame);
576 //    optsign->Add (signame->ToCString(),asign);
577 //  }
578   optsign->Add ("default",theSignType);   // defaut specifique
579   optsign->Switch ("default");  // garder courante la definition par defaut !
580
581 //   Actor Read
582   Handle(MoniTool_Option) optacrd  = theProfile->Option ("tr-read");
583   optacrd->Add ("default",theAdaptorRead);
584   optacrd->Switch ("default");
585
586 //   Actor Write
587   Handle(MoniTool_Option) optacwr  = theProfile->Option ("tr-write");
588   optacwr->Add ("default",theAdaptorWrite);
589   optacwr->Switch ("default");
590
591 //   Basic configuration
592
593   theProfile->AddConf ("Base");
594   theProfile->AddSwitch ("Base","sign-type","default");
595   theProfile->AddSwitch ("Base","tr-read","default");
596   theProfile->AddSwitch ("Base","tr-write","default");
597   theProfile->SetCurrent ("Base");
598 }
599
600     void  XSControl_Controller::Customising
601   ( Handle(XSControl_WorkSession)& WS)    
602 {
603    //ndle(IFSelect_SelectModelRoots)    slr = new IFSelect_SelectModelRoots;
604  ///WS->AddNamedItem ("xst-model-roots",slr);
605   if(!WS->NamedItem("xst-model-all").IsNull()) return;
606   Handle(IFSelect_SelectModelEntities) sle = new IFSelect_SelectModelEntities;
607   WS->AddNamedItem ("xst-model-all",sle);
608   Handle(IFSelect_SelectModelRoots)    slr;
609   slr = new IFSelect_SelectModelRoots;
610   WS->AddNamedItem ("xst-model-roots",slr);
611   if(strcasecmp(WS->SelectedNorm(),"STEP")) {
612     Handle(XSControl_SelectForTransfer) st1 = new XSControl_SelectForTransfer;
613     st1->SetInput (slr);
614     st1->SetReader (WS->TransferReader());
615     WS->AddNamedItem ("xst-transferrable-roots",st1);
616     
617   }
618   //else slr = Handle(IFSelect_SelectModelRoots)::DownCast(WS->NamedItem("xst-model-roots"));
619   Handle(XSControl_SelectForTransfer) st2 = new XSControl_SelectForTransfer;
620   st2->SetInput (sle);
621   st2->SetReader (WS->TransferReader());
622   WS->AddNamedItem ("xst-transferrable-all",st2);
623    
624   Handle(XSControl_SignTransferStatus) strs = new XSControl_SignTransferStatus;
625    strs->SetReader (WS->TransferReader());
626   WS->AddNamedItem ("xst-transfer-status",strs);
627   
628   Handle(XSControl_ConnectedShapes) scs = new XSControl_ConnectedShapes;
629   scs->SetReader (WS->TransferReader());
630   WS->AddNamedItem ("xst-connected-faces",scs);
631
632   Handle(IFSelect_SignType) stp = new IFSelect_SignType (Standard_False);
633   WS->AddNamedItem ("xst-long-type",stp);
634   Handle(IFSelect_SignType) stc = new IFSelect_SignType (Standard_True);
635   WS->AddNamedItem ("xst-type",stc);
636   Handle(IFSelect_SignAncestor) sta = new IFSelect_SignAncestor;
637   WS->AddNamedItem ("xst-ancestor-type",sta);
638   Handle(IFSelect_SignCounter) tc1 =
639     new IFSelect_SignCounter(stp,Standard_False,Standard_True);
640   WS->AddNamedItem ("xst-types",tc1);
641   Handle(IFSelect_SignCategory) sca = new IFSelect_SignCategory;
642   WS->AddNamedItem ("xst-category",sca);
643   Handle(IFSelect_SignValidity) sva = new IFSelect_SignValidity;
644   WS->AddNamedItem ("xst-validity",sva);
645
646   Handle(IFSelect_DispPerOne) dispone = new IFSelect_DispPerOne;
647   dispone->SetFinalSelection(slr);
648   WS->AddNamedItem ("xst-disp-one",dispone);
649   Handle(IFSelect_DispPerCount) dispcount = new IFSelect_DispPerCount;
650   Handle(IFSelect_IntParam) intcount = new IFSelect_IntParam;
651   intcount->SetValue(5);
652   dispcount->SetCount(intcount);
653   dispcount->SetFinalSelection(slr);
654   WS->AddNamedItem ("xst-disp-count",dispcount);
655   Handle(IFSelect_DispPerFiles) dispfiles = new IFSelect_DispPerFiles;
656   Handle(IFSelect_IntParam) intfiles = new IFSelect_IntParam;
657   intfiles->SetValue(10);
658   dispfiles->SetCount(intfiles);
659   dispfiles->SetFinalSelection(slr);
660   WS->AddNamedItem ("xst-disp-files",dispfiles);
661   Handle(IFSelect_DispPerSignature) dispsign = new IFSelect_DispPerSignature;
662   dispsign->SetSignCounter(new IFSelect_SignCounter(stc));
663   dispsign->SetFinalSelection(slr);
664   WS->AddNamedItem ("xst-disp-sign",dispsign);
665
666 //   Pas utilisables directement mais bien utiles quand meme
667   WS->AddNamedItem ("xst-pointed",new IFSelect_SelectPointed);
668   WS->AddNamedItem ("xst-sharing",new IFSelect_SelectSharing);
669   WS->AddNamedItem ("xst-shared",new IFSelect_SelectShared);
670   WS->AddNamedItem ("xst-nb-selected",new IFSelect_GraphCounter);
671   theSignType      = stp;
672     // au moins cela
673 }
674  Handle(Dico_DictionaryOfTransient) XSControl_Controller::AdaptorSession() const
675 {
676   return theAdaptorSession;
677 }