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