973c2be1 |
1 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
2 | // |
973c2be1 |
3 | // This file is part of Open CASCADE Technology software library. |
b311480e |
4 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
b311480e |
10 | // |
973c2be1 |
11 | // Alternatively, this file may be used under the terms of Open CASCADE |
12 | // commercial license or contractual agreement. |
b311480e |
13 | |
7fd59977 |
14 | |
42cf5bc1 |
15 | #include <IFSelect_SessionPilot.hxx> |
7fd59977 |
16 | #include <IFSelect_WorkSession.hxx> |
17 | #include <Interface_Macros.hxx> |
42cf5bc1 |
18 | #include <Standard_ErrorHandler.hxx> |
19 | #include <Standard_Failure.hxx> |
20 | #include <Standard_Type.hxx> |
7fd59977 |
21 | #include <StepData_Plex.hxx> |
42cf5bc1 |
22 | #include <StepData_Simple.hxx> |
23 | #include <StepData_UndefinedEntity.hxx> |
24 | #include <StepSelect_Activator.hxx> |
7fd59977 |
25 | #include <StepSelect_FloatFormat.hxx> |
26 | |
92efcf78 |
27 | IMPLEMENT_STANDARD_RTTIEXT(StepSelect_Activator,IFSelect_Activator) |
28 | |
c48e2889 |
29 | static int THE_StepSelect_Activator_initActivator = 0; |
7fd59977 |
30 | |
31 | StepSelect_Activator::StepSelect_Activator () |
32 | { |
c48e2889 |
33 | if (THE_StepSelect_Activator_initActivator) |
34 | { |
35 | return; |
36 | } |
37 | |
38 | THE_StepSelect_Activator_initActivator = 1; |
7fd59977 |
39 | // Add ( 0,"load"); |
40 | // Add ( 0,"loadstep"); // homonyme |
41 | // Add ( 1,"entity"); |
42 | // Add ( 2,"liststep"); |
43 | |
44 | // AddSet (10,"steptype"); |
45 | |
46 | Add ( 1,"stepschema"); |
47 | AddSet (40,"floatformat"); |
48 | } |
49 | |
50 | |
51 | IFSelect_ReturnStatus StepSelect_Activator::Do |
52 | (const Standard_Integer number, |
53 | const Handle(IFSelect_SessionPilot)& pilot) |
54 | { |
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(); |
59 | |
60 | switch (number) { |
61 | |
62 | case 1 : { // **** StepSchema |
63 | if (argc < 2) { |
64 | cout<<"Identify an entity"<<endl; |
65 | return IFSelect_RetError; |
66 | } |
67 | Standard_Integer num = pilot->Number(arg1); |
68 | if (num <= 0) { |
69 | cout<<"Not an entity : "<<arg2<<endl; |
70 | return IFSelect_RetError; |
71 | } |
72 | Handle(Standard_Transient) ent = pilot->Session()->StartingEntity(num); |
73 | DeclareAndCast(StepData_UndefinedEntity,und,ent); |
74 | if (!und.IsNull()) { |
75 | cout<<"Entity "<<arg2<<" : No Binding known"<<endl; |
76 | return IFSelect_RetVoid; |
77 | } |
78 | DeclareAndCast(StepData_Simple,sim,ent); |
79 | if (!sim.IsNull()) { |
80 | cout<<"Entity "<<arg2<<" : Late Binding"<<endl; |
81 | cout<<"Simple Type : "<<sim->StepType()<<endl; |
82 | return IFSelect_RetVoid; |
83 | } |
84 | DeclareAndCast(StepData_Plex,plx,ent); |
85 | if (!plx.IsNull()) { |
86 | cout<<"Entity "<<arg2<<" : Late Binding"<<endl; |
87 | cout<<"Complex Type"<<endl; |
88 | } |
89 | // reste Early Binding |
90 | cout<<"Entity "<<arg2<<" : Early Binding"<<endl; |
91 | cout<<"CDL Type : "<<ent->DynamicType()->Name()<<endl; |
92 | return IFSelect_RetVoid; |
93 | } |
94 | |
95 | case 40 : { // **** FloatFormat |
96 | char prem = ' '; |
97 | if (argc < 2) prem = '?'; |
98 | else if (argc == 5) { cout<<"floatformat tout court donne les formes admises"<<endl; return IFSelect_RetError; } |
99 | else prem = arg1[0]; |
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); |
105 | else { |
106 | 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" |
113 | <<flush; |
114 | return (prem == '?' ? IFSelect_RetVoid : IFSelect_RetError); |
115 | } |
116 | Standard_Real Rmin=0., Rmax=0.; |
117 | if (argc > 4) { |
91322f44 |
118 | Rmin = Atof(pilot->Word(4).ToCString()); |
119 | Rmax = Atof(pilot->Word(5).ToCString()); |
7fd59977 |
120 | if (Rmin <= 0 || Rmax <= 0) { cout<<"intervalle : donner reels > 0"<<endl; return IFSelect_RetError; } |
121 | } |
122 | Handle(StepSelect_FloatFormat) fm = new StepSelect_FloatFormat; |
123 | if (argc == 2) fm->SetDefault(digits); |
124 | else { |
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(""); |
130 | } |
131 | return pilot->RecordItem(fm); |
132 | } |
133 | |
134 | default : break; |
135 | } |
136 | return IFSelect_RetVoid; |
137 | |
138 | } |
139 | |
140 | |
141 | Standard_CString StepSelect_Activator::Help |
142 | (const Standard_Integer number) const |
143 | { |
144 | switch (number) { |
145 | |
146 | case 40 : return "options... : cree FloatFormat ... floatformat tout court->help"; |
147 | default : break; |
148 | } |
149 | return ""; |
150 | } |