0023024: Update headers of OCCT files
[occt.git] / src / StepSelect / StepSelect_Activator.cxx
CommitLineData
b311480e 1// Copyright (c) 1999-2012 OPEN CASCADE SAS
2//
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.
7//
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.
10//
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.
17
7fd59977 18#include <Standard_ErrorHandler.hxx>
19#include <StepSelect_Activator.ixx>
20#include <Interface_Macros.hxx>
21#include <Standard_Failure.hxx>
22
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>
28
29#include <StepSelect_FloatFormat.hxx>
30
31
32static int initActivator = 0;
33
34
35StepSelect_Activator::StepSelect_Activator ()
36{
37 if (initActivator) return; initActivator = 1;
38// Add ( 0,"load");
39// Add ( 0,"loadstep"); // homonyme
40// Add ( 1,"entity");
41// Add ( 2,"liststep");
42
43// AddSet (10,"steptype");
44
45 Add ( 1,"stepschema");
46 AddSet (40,"floatformat");
47}
48
49
50IFSelect_ReturnStatus StepSelect_Activator::Do
51 (const Standard_Integer number,
52 const Handle(IFSelect_SessionPilot)& pilot)
53{
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();
58
59 switch (number) {
60
61 case 1 : { // **** StepSchema
62 if (argc < 2) {
63 cout<<"Identify an entity"<<endl;
64 return IFSelect_RetError;
65 }
66 Standard_Integer num = pilot->Number(arg1);
67 if (num <= 0) {
68 cout<<"Not an entity : "<<arg2<<endl;
69 return IFSelect_RetError;
70 }
71 Handle(Standard_Transient) ent = pilot->Session()->StartingEntity(num);
72 DeclareAndCast(StepData_UndefinedEntity,und,ent);
73 if (!und.IsNull()) {
74 cout<<"Entity "<<arg2<<" : No Binding known"<<endl;
75 return IFSelect_RetVoid;
76 }
77 DeclareAndCast(StepData_Simple,sim,ent);
78 if (!sim.IsNull()) {
79 cout<<"Entity "<<arg2<<" : Late Binding"<<endl;
80 cout<<"Simple Type : "<<sim->StepType()<<endl;
81 return IFSelect_RetVoid;
82 }
83 DeclareAndCast(StepData_Plex,plx,ent);
84 if (!plx.IsNull()) {
85 cout<<"Entity "<<arg2<<" : Late Binding"<<endl;
86 cout<<"Complex Type"<<endl;
87 }
88// reste Early Binding
89 cout<<"Entity "<<arg2<<" : Early Binding"<<endl;
90 cout<<"CDL Type : "<<ent->DynamicType()->Name()<<endl;
91 return IFSelect_RetVoid;
92 }
93
94 case 40 : { // **** FloatFormat
95 char prem = ' ';
96 if (argc < 2) prem = '?';
97 else if (argc == 5) { cout<<"floatformat tout court donne les formes admises"<<endl; return IFSelect_RetError; }
98 else prem = arg1[0];
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);
104 else {
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"
112 <<flush;
113 return (prem == '?' ? IFSelect_RetVoid : IFSelect_RetError);
114 }
115 Standard_Real Rmin=0., Rmax=0.;
116 if (argc > 4) {
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; }
120 }
121 Handle(StepSelect_FloatFormat) fm = new StepSelect_FloatFormat;
122 if (argc == 2) fm->SetDefault(digits);
123 else {
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("");
129 }
130 return pilot->RecordItem(fm);
131 }
132
133 default : break;
134 }
135 return IFSelect_RetVoid;
136
137}
138
139
140Standard_CString StepSelect_Activator::Help
141 (const Standard_Integer number) const
142{
143 switch (number) {
144
145 case 40 : return "options... : cree FloatFormat ... floatformat tout court->help";
146 default : break;
147 }
148 return "";
149}