0031687: Draw Harness, ViewerTest - extend command vrenderparams with option updating...
[occt.git] / src / StepSelect / StepSelect_Activator.cxx
CommitLineData
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 27IMPLEMENT_STANDARD_RTTIEXT(StepSelect_Activator,IFSelect_Activator)
28
c48e2889 29static int THE_StepSelect_Activator_initActivator = 0;
7fd59977 30
31StepSelect_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
51IFSelect_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) {
04232180 64 std::cout<<"Identify an entity"<<std::endl;
7fd59977 65 return IFSelect_RetError;
66 }
67 Standard_Integer num = pilot->Number(arg1);
68 if (num <= 0) {
04232180 69 std::cout<<"Not an entity : "<<arg2<<std::endl;
7fd59977 70 return IFSelect_RetError;
71 }
72 Handle(Standard_Transient) ent = pilot->Session()->StartingEntity(num);
73 DeclareAndCast(StepData_UndefinedEntity,und,ent);
74 if (!und.IsNull()) {
04232180 75 std::cout<<"Entity "<<arg2<<" : No Binding known"<<std::endl;
7fd59977 76 return IFSelect_RetVoid;
77 }
78 DeclareAndCast(StepData_Simple,sim,ent);
79 if (!sim.IsNull()) {
04232180 80 std::cout<<"Entity "<<arg2<<" : Late Binding"<<std::endl;
81 std::cout<<"Simple Type : "<<sim->StepType()<<std::endl;
7fd59977 82 return IFSelect_RetVoid;
83 }
84 DeclareAndCast(StepData_Plex,plx,ent);
85 if (!plx.IsNull()) {
04232180 86 std::cout<<"Entity "<<arg2<<" : Late Binding"<<std::endl;
87 std::cout<<"Complex Type"<<std::endl;
7fd59977 88 }
89// reste Early Binding
04232180 90 std::cout<<"Entity "<<arg2<<" : Early Binding"<<std::endl;
91 std::cout<<"CDL Type : "<<ent->DynamicType()->Name()<<std::endl;
7fd59977 92 return IFSelect_RetVoid;
93 }
94
95 case 40 : { // **** FloatFormat
96 char prem = ' ';
97 if (argc < 2) prem = '?';
04232180 98 else if (argc == 5) { std::cout<<"floatformat tout court donne les formes admises"<<std::endl; return IFSelect_RetError; }
7fd59977 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 {
04232180 106 std::cout<<"floatformat digits, digits=nb de chiffres signifiants, ou\n"
7fd59977 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"
04232180 113 <<std::flush;
7fd59977 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());
04232180 120 if (Rmin <= 0 || Rmax <= 0) { std::cout<<"intervalle : donner reels > 0"<<std::endl; return IFSelect_RetError; }
7fd59977 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
141Standard_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}