Integration of OCCT 6.5.0 from SVN
[occt.git] / src / StepSelect / StepSelect_Activator.cxx
CommitLineData
7fd59977 1#include <Standard_ErrorHandler.hxx>
2#include <StepSelect_Activator.ixx>
3#include <Interface_Macros.hxx>
4#include <Standard_Failure.hxx>
5
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>
11
12#include <StepSelect_FloatFormat.hxx>
13
14
15static int initActivator = 0;
16
17
18StepSelect_Activator::StepSelect_Activator ()
19{
20 if (initActivator) return; initActivator = 1;
21// Add ( 0,"load");
22// Add ( 0,"loadstep"); // homonyme
23// Add ( 1,"entity");
24// Add ( 2,"liststep");
25
26// AddSet (10,"steptype");
27
28 Add ( 1,"stepschema");
29 AddSet (40,"floatformat");
30}
31
32
33IFSelect_ReturnStatus StepSelect_Activator::Do
34 (const Standard_Integer number,
35 const Handle(IFSelect_SessionPilot)& pilot)
36{
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();
41
42 switch (number) {
43
44 case 1 : { // **** StepSchema
45 if (argc < 2) {
46 cout<<"Identify an entity"<<endl;
47 return IFSelect_RetError;
48 }
49 Standard_Integer num = pilot->Number(arg1);
50 if (num <= 0) {
51 cout<<"Not an entity : "<<arg2<<endl;
52 return IFSelect_RetError;
53 }
54 Handle(Standard_Transient) ent = pilot->Session()->StartingEntity(num);
55 DeclareAndCast(StepData_UndefinedEntity,und,ent);
56 if (!und.IsNull()) {
57 cout<<"Entity "<<arg2<<" : No Binding known"<<endl;
58 return IFSelect_RetVoid;
59 }
60 DeclareAndCast(StepData_Simple,sim,ent);
61 if (!sim.IsNull()) {
62 cout<<"Entity "<<arg2<<" : Late Binding"<<endl;
63 cout<<"Simple Type : "<<sim->StepType()<<endl;
64 return IFSelect_RetVoid;
65 }
66 DeclareAndCast(StepData_Plex,plx,ent);
67 if (!plx.IsNull()) {
68 cout<<"Entity "<<arg2<<" : Late Binding"<<endl;
69 cout<<"Complex Type"<<endl;
70 }
71// reste Early Binding
72 cout<<"Entity "<<arg2<<" : Early Binding"<<endl;
73 cout<<"CDL Type : "<<ent->DynamicType()->Name()<<endl;
74 return IFSelect_RetVoid;
75 }
76
77 case 40 : { // **** FloatFormat
78 char prem = ' ';
79 if (argc < 2) prem = '?';
80 else if (argc == 5) { cout<<"floatformat tout court donne les formes admises"<<endl; return IFSelect_RetError; }
81 else prem = arg1[0];
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);
87 else {
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"
95 <<flush;
96 return (prem == '?' ? IFSelect_RetVoid : IFSelect_RetError);
97 }
98 Standard_Real Rmin=0., Rmax=0.;
99 if (argc > 4) {
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; }
103 }
104 Handle(StepSelect_FloatFormat) fm = new StepSelect_FloatFormat;
105 if (argc == 2) fm->SetDefault(digits);
106 else {
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("");
112 }
113 return pilot->RecordItem(fm);
114 }
115
116 default : break;
117 }
118 return IFSelect_RetVoid;
119
120}
121
122
123Standard_CString StepSelect_Activator::Help
124 (const Standard_Integer number) const
125{
126 switch (number) {
127
128 case 40 : return "options... : cree FloatFormat ... floatformat tout court->help";
129 default : break;
130 }
131 return "";
132}