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