1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
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.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
14 #include <Standard_ErrorHandler.hxx>
15 #include <StepSelect_Activator.ixx>
16 #include <Interface_Macros.hxx>
17 #include <Standard_Failure.hxx>
19 #include <IFSelect_WorkSession.hxx>
20 #include <Interface_Macros.hxx>
21 #include <StepData_UndefinedEntity.hxx>
22 #include <StepData_Simple.hxx>
23 #include <StepData_Plex.hxx>
25 #include <StepSelect_FloatFormat.hxx>
28 static int initActivator = 0;
31 StepSelect_Activator::StepSelect_Activator ()
33 if (initActivator) return; initActivator = 1;
35 // Add ( 0,"loadstep"); // homonyme
37 // Add ( 2,"liststep");
39 // AddSet (10,"steptype");
41 Add ( 1,"stepschema");
42 AddSet (40,"floatformat");
46 IFSelect_ReturnStatus StepSelect_Activator::Do
47 (const Standard_Integer number,
48 const Handle(IFSelect_SessionPilot)& pilot)
50 Standard_Integer argc = pilot->NbWords();
51 const Standard_CString arg1 = pilot->Word(1).ToCString();
52 const Standard_CString arg2 = pilot->Word(2).ToCString();
53 // const Standard_CString arg3 = pilot->Word(3).ToCString();
57 case 1 : { // **** StepSchema
59 cout<<"Identify an entity"<<endl;
60 return IFSelect_RetError;
62 Standard_Integer num = pilot->Number(arg1);
64 cout<<"Not an entity : "<<arg2<<endl;
65 return IFSelect_RetError;
67 Handle(Standard_Transient) ent = pilot->Session()->StartingEntity(num);
68 DeclareAndCast(StepData_UndefinedEntity,und,ent);
70 cout<<"Entity "<<arg2<<" : No Binding known"<<endl;
71 return IFSelect_RetVoid;
73 DeclareAndCast(StepData_Simple,sim,ent);
75 cout<<"Entity "<<arg2<<" : Late Binding"<<endl;
76 cout<<"Simple Type : "<<sim->StepType()<<endl;
77 return IFSelect_RetVoid;
79 DeclareAndCast(StepData_Plex,plx,ent);
81 cout<<"Entity "<<arg2<<" : Late Binding"<<endl;
82 cout<<"Complex Type"<<endl;
84 // reste Early Binding
85 cout<<"Entity "<<arg2<<" : Early Binding"<<endl;
86 cout<<"CDL Type : "<<ent->DynamicType()->Name()<<endl;
87 return IFSelect_RetVoid;
90 case 40 : { // **** FloatFormat
92 if (argc < 2) prem = '?';
93 else if (argc == 5) { cout<<"floatformat tout court donne les formes admises"<<endl; return IFSelect_RetError; }
95 Standard_Boolean zerosup=Standard_False;
96 Standard_Integer digits = 0;
97 if (prem == 'N' || prem == 'n') zerosup = Standard_False;
98 else if (prem == 'Z' || prem == 'z') zerosup = Standard_True;
99 else if (prem >= 48 && prem <= 57) digits = atoi(arg1);
101 cout<<"floatformat digits, digits=nb de chiffres signifiants, ou\n"
102 << "floatformat NZ %mainformat [%rangeformat [Rmin Rmax]]\n"
103 <<" NZ : N ou n pour Non-zero-suppress, Z ou z pour zero-suppress\n"
104 <<" %mainformat : format principal type printf, ex,: %E\n"
105 <<" + optionnel : format secondaire (flottants autour de 1.) :\n"
106 <<" %rangeformat Rmin Rmax : format type printf entre Rmin et Rmax\n"
107 <<" %rangeformat tout seul : format type printf entre 0.1 et 1000.\n"
109 return (prem == '?' ? IFSelect_RetVoid : IFSelect_RetError);
111 Standard_Real Rmin=0., Rmax=0.;
113 Rmin = Atof(pilot->Word(4).ToCString());
114 Rmax = Atof(pilot->Word(5).ToCString());
115 if (Rmin <= 0 || Rmax <= 0) { cout<<"intervalle : donner reels > 0"<<endl; return IFSelect_RetError; }
117 Handle(StepSelect_FloatFormat) fm = new StepSelect_FloatFormat;
118 if (argc == 2) fm->SetDefault(digits);
120 fm->SetZeroSuppress(zerosup);
121 fm->SetFormat (arg2);
122 if (argc == 4) fm->SetFormatForRange(pilot->Word(3).ToCString());
123 else if (argc >= 6) fm->SetFormatForRange(pilot->Word(3).ToCString(),Rmin,Rmax);
124 else fm->SetFormatForRange("");
126 return pilot->RecordItem(fm);
131 return IFSelect_RetVoid;
136 Standard_CString StepSelect_Activator::Help
137 (const Standard_Integer number) const
141 case 40 : return "options... : cree FloatFormat ... floatformat tout court->help";