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 <Standard_ErrorHandler.hxx>
19 #include <StepSelect_Activator.ixx>
20 #include <Interface_Macros.hxx>
21 #include <Standard_Failure.hxx>
23 #include <IFSelect_WorkSession.hxx>
24 #include <Interface_Macros.hxx>
25 #include <StepData_UndefinedEntity.hxx>
26 #include <StepData_Simple.hxx>
27 #include <StepData_Plex.hxx>
29 #include <StepSelect_FloatFormat.hxx>
32 static int initActivator = 0;
35 StepSelect_Activator::StepSelect_Activator ()
37 if (initActivator) return; initActivator = 1;
39 // Add ( 0,"loadstep"); // homonyme
41 // Add ( 2,"liststep");
43 // AddSet (10,"steptype");
45 Add ( 1,"stepschema");
46 AddSet (40,"floatformat");
50 IFSelect_ReturnStatus StepSelect_Activator::Do
51 (const Standard_Integer number,
52 const Handle(IFSelect_SessionPilot)& pilot)
54 Standard_Integer argc = pilot->NbWords();
55 const Standard_CString arg1 = pilot->Word(1).ToCString();
56 const Standard_CString arg2 = pilot->Word(2).ToCString();
57 // const Standard_CString arg3 = pilot->Word(3).ToCString();
61 case 1 : { // **** StepSchema
63 cout<<"Identify an entity"<<endl;
64 return IFSelect_RetError;
66 Standard_Integer num = pilot->Number(arg1);
68 cout<<"Not an entity : "<<arg2<<endl;
69 return IFSelect_RetError;
71 Handle(Standard_Transient) ent = pilot->Session()->StartingEntity(num);
72 DeclareAndCast(StepData_UndefinedEntity,und,ent);
74 cout<<"Entity "<<arg2<<" : No Binding known"<<endl;
75 return IFSelect_RetVoid;
77 DeclareAndCast(StepData_Simple,sim,ent);
79 cout<<"Entity "<<arg2<<" : Late Binding"<<endl;
80 cout<<"Simple Type : "<<sim->StepType()<<endl;
81 return IFSelect_RetVoid;
83 DeclareAndCast(StepData_Plex,plx,ent);
85 cout<<"Entity "<<arg2<<" : Late Binding"<<endl;
86 cout<<"Complex Type"<<endl;
88 // reste Early Binding
89 cout<<"Entity "<<arg2<<" : Early Binding"<<endl;
90 cout<<"CDL Type : "<<ent->DynamicType()->Name()<<endl;
91 return IFSelect_RetVoid;
94 case 40 : { // **** FloatFormat
96 if (argc < 2) prem = '?';
97 else if (argc == 5) { cout<<"floatformat tout court donne les formes admises"<<endl; return IFSelect_RetError; }
99 Standard_Boolean zerosup=Standard_False;
100 Standard_Integer digits = 0;
101 if (prem == 'N' || prem == 'n') zerosup = Standard_False;
102 else if (prem == 'Z' || prem == 'z') zerosup = Standard_True;
103 else if (prem >= 48 && prem <= 57) digits = atoi(arg1);
105 cout<<"floatformat digits, digits=nb de chiffres signifiants, ou\n"
106 << "floatformat NZ %mainformat [%rangeformat [Rmin Rmax]]\n"
107 <<" NZ : N ou n pour Non-zero-suppress, Z ou z pour zero-suppress\n"
108 <<" %mainformat : format principal type printf, ex,: %E\n"
109 <<" + optionnel : format secondaire (flottants autour de 1.) :\n"
110 <<" %rangeformat Rmin Rmax : format type printf entre Rmin et Rmax\n"
111 <<" %rangeformat tout seul : format type printf entre 0.1 et 1000.\n"
113 return (prem == '?' ? IFSelect_RetVoid : IFSelect_RetError);
115 Standard_Real Rmin=0., Rmax=0.;
117 Rmin = Atof(pilot->Word(4).ToCString());
118 Rmax = Atof(pilot->Word(5).ToCString());
119 if (Rmin <= 0 || Rmax <= 0) { cout<<"intervalle : donner reels > 0"<<endl; return IFSelect_RetError; }
121 Handle(StepSelect_FloatFormat) fm = new StepSelect_FloatFormat;
122 if (argc == 2) fm->SetDefault(digits);
124 fm->SetZeroSuppress(zerosup);
125 fm->SetFormat (arg2);
126 if (argc == 4) fm->SetFormatForRange(pilot->Word(3).ToCString());
127 else if (argc >= 6) fm->SetFormatForRange(pilot->Word(3).ToCString(),Rmin,Rmax);
128 else fm->SetFormatForRange("");
130 return pilot->RecordItem(fm);
135 return IFSelect_RetVoid;
140 Standard_CString StepSelect_Activator::Help
141 (const Standard_Integer number) const
145 case 40 : return "options... : cree FloatFormat ... floatformat tout court->help";