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 IMPLEMENT_STANDARD_RTTIEXT(StepSelect_Activator,IFSelect_Activator)
29 static int THE_StepSelect_Activator_initActivator = 0;
31 StepSelect_Activator::StepSelect_Activator ()
33 if (THE_StepSelect_Activator_initActivator)
38 THE_StepSelect_Activator_initActivator = 1;
40 // Add ( 0,"loadstep"); // homonyme
42 // Add ( 2,"liststep");
44 // AddSet (10,"steptype");
46 Add ( 1,"stepschema");
47 AddSet (40,"floatformat");
51 IFSelect_ReturnStatus StepSelect_Activator::Do
52 (const Standard_Integer number,
53 const Handle(IFSelect_SessionPilot)& pilot)
55 Standard_Integer argc = pilot->NbWords();
56 const Standard_CString arg1 = pilot->Word(1).ToCString();
57 const Standard_CString arg2 = pilot->Word(2).ToCString();
58 // const Standard_CString arg3 = pilot->Word(3).ToCString();
62 case 1 : { // **** StepSchema
64 std::cout<<"Identify an entity"<<std::endl;
65 return IFSelect_RetError;
67 Standard_Integer num = pilot->Number(arg1);
69 std::cout<<"Not an entity : "<<arg2<<std::endl;
70 return IFSelect_RetError;
72 Handle(Standard_Transient) ent = pilot->Session()->StartingEntity(num);
73 DeclareAndCast(StepData_UndefinedEntity,und,ent);
75 std::cout<<"Entity "<<arg2<<" : No Binding known"<<std::endl;
76 return IFSelect_RetVoid;
78 DeclareAndCast(StepData_Simple,sim,ent);
80 std::cout<<"Entity "<<arg2<<" : Late Binding"<<std::endl;
81 std::cout<<"Simple Type : "<<sim->StepType()<<std::endl;
82 return IFSelect_RetVoid;
84 DeclareAndCast(StepData_Plex,plx,ent);
86 std::cout<<"Entity "<<arg2<<" : Late Binding"<<std::endl;
87 std::cout<<"Complex Type"<<std::endl;
89 // reste Early Binding
90 std::cout<<"Entity "<<arg2<<" : Early Binding"<<std::endl;
91 std::cout<<"CDL Type : "<<ent->DynamicType()->Name()<<std::endl;
92 return IFSelect_RetVoid;
95 case 40 : { // **** FloatFormat
97 if (argc < 2) prem = '?';
98 else if (argc == 5) { std::cout<<"floatformat tout court donne les formes admises"<<std::endl; return IFSelect_RetError; }
100 Standard_Boolean zerosup=Standard_False;
101 Standard_Integer digits = 0;
102 if (prem == 'N' || prem == 'n') zerosup = Standard_False;
103 else if (prem == 'Z' || prem == 'z') zerosup = Standard_True;
104 else if (prem >= 48 && prem <= 57) digits = atoi(arg1);
106 std::cout<<"floatformat digits, digits=nb de chiffres signifiants, ou\n"
107 << "floatformat NZ %mainformat [%rangeformat [Rmin Rmax]]\n"
108 <<" NZ : N ou n pour Non-zero-suppress, Z ou z pour zero-suppress\n"
109 <<" %mainformat : format principal type printf, ex,: %E\n"
110 <<" + optionnel : format secondaire (flottants autour de 1.) :\n"
111 <<" %rangeformat Rmin Rmax : format type printf entre Rmin et Rmax\n"
112 <<" %rangeformat tout seul : format type printf entre 0.1 et 1000.\n"
114 return (prem == '?' ? IFSelect_RetVoid : IFSelect_RetError);
116 Standard_Real Rmin=0., Rmax=0.;
118 Rmin = Atof(pilot->Word(4).ToCString());
119 Rmax = Atof(pilot->Word(5).ToCString());
120 if (Rmin <= 0 || Rmax <= 0) { std::cout<<"intervalle : donner reels > 0"<<std::endl; return IFSelect_RetError; }
122 Handle(StepSelect_FloatFormat) fm = new StepSelect_FloatFormat;
123 if (argc == 2) fm->SetDefault(digits);
125 fm->SetZeroSuppress(zerosup);
126 fm->SetFormat (arg2);
127 if (argc == 4) fm->SetFormatForRange(pilot->Word(3).ToCString());
128 else if (argc >= 6) fm->SetFormatForRange(pilot->Word(3).ToCString(),Rmin,Rmax);
129 else fm->SetFormatForRange("");
131 return pilot->RecordItem(fm);
136 return IFSelect_RetVoid;
141 Standard_CString StepSelect_Activator::Help
142 (const Standard_Integer number) const
146 case 40 : return "options... : cree FloatFormat ... floatformat tout court->help";