1 #include <Standard_ErrorHandler.hxx>
2 #include <StepSelect_Activator.ixx>
3 #include <Interface_Macros.hxx>
4 #include <Standard_Failure.hxx>
6 #include <IFSelect_WorkSession.hxx>
7 #include <Interface_Macros.hxx>
8 #include <StepData_UndefinedEntity.hxx>
9 #include <StepData_Simple.hxx>
10 #include <StepData_Plex.hxx>
12 #include <StepSelect_FloatFormat.hxx>
15 static int initActivator = 0;
18 StepSelect_Activator::StepSelect_Activator ()
20 if (initActivator) return; initActivator = 1;
22 // Add ( 0,"loadstep"); // homonyme
24 // Add ( 2,"liststep");
26 // AddSet (10,"steptype");
28 Add ( 1,"stepschema");
29 AddSet (40,"floatformat");
33 IFSelect_ReturnStatus StepSelect_Activator::Do
34 (const Standard_Integer number,
35 const Handle(IFSelect_SessionPilot)& pilot)
37 Standard_Integer argc = pilot->NbWords();
38 const Standard_CString arg1 = pilot->Word(1).ToCString();
39 const Standard_CString arg2 = pilot->Word(2).ToCString();
40 // const Standard_CString arg3 = pilot->Word(3).ToCString();
44 case 1 : { // **** StepSchema
46 cout<<"Identify an entity"<<endl;
47 return IFSelect_RetError;
49 Standard_Integer num = pilot->Number(arg1);
51 cout<<"Not an entity : "<<arg2<<endl;
52 return IFSelect_RetError;
54 Handle(Standard_Transient) ent = pilot->Session()->StartingEntity(num);
55 DeclareAndCast(StepData_UndefinedEntity,und,ent);
57 cout<<"Entity "<<arg2<<" : No Binding known"<<endl;
58 return IFSelect_RetVoid;
60 DeclareAndCast(StepData_Simple,sim,ent);
62 cout<<"Entity "<<arg2<<" : Late Binding"<<endl;
63 cout<<"Simple Type : "<<sim->StepType()<<endl;
64 return IFSelect_RetVoid;
66 DeclareAndCast(StepData_Plex,plx,ent);
68 cout<<"Entity "<<arg2<<" : Late Binding"<<endl;
69 cout<<"Complex Type"<<endl;
71 // reste Early Binding
72 cout<<"Entity "<<arg2<<" : Early Binding"<<endl;
73 cout<<"CDL Type : "<<ent->DynamicType()->Name()<<endl;
74 return IFSelect_RetVoid;
77 case 40 : { // **** FloatFormat
79 if (argc < 2) prem = '?';
80 else if (argc == 5) { cout<<"floatformat tout court donne les formes admises"<<endl; return IFSelect_RetError; }
82 Standard_Boolean zerosup=Standard_False;
83 Standard_Integer digits = 0;
84 if (prem == 'N' || prem == 'n') zerosup = Standard_False;
85 else if (prem == 'Z' || prem == 'z') zerosup = Standard_True;
86 else if (prem >= 48 && prem <= 57) digits = atoi(arg1);
88 cout<<"floatformat digits, digits=nb de chiffres signifiants, ou\n"
89 << "floatformat NZ %mainformat [%rangeformat [Rmin Rmax]]\n"
90 <<" NZ : N ou n pour Non-zero-suppress, Z ou z pour zero-suppress\n"
91 <<" %mainformat : format principal type printf, ex,: %E\n"
92 <<" + optionnel : format secondaire (flottants autour de 1.) :\n"
93 <<" %rangeformat Rmin Rmax : format type printf entre Rmin et Rmax\n"
94 <<" %rangeformat tout seul : format type printf entre 0.1 et 1000.\n"
96 return (prem == '?' ? IFSelect_RetVoid : IFSelect_RetError);
98 Standard_Real Rmin=0., Rmax=0.;
100 Rmin = atof(pilot->Word(4).ToCString());
101 Rmax = atof(pilot->Word(5).ToCString());
102 if (Rmin <= 0 || Rmax <= 0) { cout<<"intervalle : donner reels > 0"<<endl; return IFSelect_RetError; }
104 Handle(StepSelect_FloatFormat) fm = new StepSelect_FloatFormat;
105 if (argc == 2) fm->SetDefault(digits);
107 fm->SetZeroSuppress(zerosup);
108 fm->SetFormat (arg2);
109 if (argc == 4) fm->SetFormatForRange(pilot->Word(3).ToCString());
110 else if (argc >= 6) fm->SetFormatForRange(pilot->Word(3).ToCString(),Rmin,Rmax);
111 else fm->SetFormatForRange("");
113 return pilot->RecordItem(fm);
118 return IFSelect_RetVoid;
123 Standard_CString StepSelect_Activator::Help
124 (const Standard_Integer number) const
128 case 40 : return "options... : cree FloatFormat ... floatformat tout court->help";