Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4UIcontrolMessenger Class Reference

#include <G4UIcontrolMessenger.hh>

+ Inheritance diagram for G4UIcontrolMessenger:

Public Member Functions

 G4UIcontrolMessenger ()
 
 ~G4UIcontrolMessenger ()
 
void SetNewValue (G4UIcommand *command, G4String newValue)
 
G4String GetCurrentValue (G4UIcommand *command)
 
- Public Member Functions inherited from G4UImessenger
 G4UImessenger ()
 
 G4UImessenger (const G4String &path, const G4String &dsc, G4bool commandsToBeBroadcasted=true)
 
virtual ~G4UImessenger ()
 
virtual G4String GetCurrentValue (G4UIcommand *command)
 
virtual void SetNewValue (G4UIcommand *command, G4String newValue)
 
G4bool operator== (const G4UImessenger &messenger) const
 
G4bool operator!= (const G4UImessenger &messenger) const
 
G4bool CommandsShouldBeInMaster () const
 

Additional Inherited Members

- Protected Member Functions inherited from G4UImessenger
G4String ItoS (G4int i)
 
G4String DtoS (G4double a)
 
G4String BtoS (G4bool b)
 
G4int StoI (G4String s)
 
G4long StoL (G4String s)
 
G4double StoD (G4String s)
 
G4bool StoB (G4String s)
 
void AddUIcommand (G4UIcommand *newCommand)
 
void CreateDirectory (const G4String &path, const G4String &dsc, G4bool commandsToBeBroadcasted=true)
 
template<typename T >
T * CreateCommand (const G4String &cname, const G4String &dsc)
 
- Protected Attributes inherited from G4UImessenger
G4UIdirectorybaseDir = nullptr
 
G4String baseDirName = ""
 
G4bool commandsShouldBeInMaster = false
 

Detailed Description

Definition at line 80 of file G4UIcontrolMessenger.hh.

Constructor & Destructor Documentation

◆ G4UIcontrolMessenger()

G4UIcontrolMessenger::G4UIcontrolMessenger ( )

Definition at line 49 of file G4UIcontrolMessenger.cc.

50{
51 controlDirectory = new G4UIdirectory("/control/");
52 controlDirectory->SetGuidance("UI control commands.");
53
54 macroPathCommand = new G4UIcmdWithAString("/control/macroPath", this);
55 macroPathCommand->SetGuidance("Set macro search path"
56 " with colon-separated list.");
57 macroPathCommand->SetParameterName("path", false);
58
59 ExecuteCommand = new G4UIcmdWithAString("/control/execute", this);
60 ExecuteCommand->SetGuidance("Execute a macro file.");
61 ExecuteCommand->SetParameterName("fileName", false);
62 ExecuteCommand->SetToBeBroadcasted(false);
63
64 loopCommand = new G4UIcommand("/control/loop", this);
65 loopCommand->SetGuidance("Execute a macro file more than once.");
66 loopCommand->SetGuidance("Loop counter can be used as an aliased variable.");
67 G4UIparameter* param1 = new G4UIparameter("macroFile", 's', false);
68 loopCommand->SetParameter(param1);
69 G4UIparameter* param2 = new G4UIparameter("counterName", 's', false);
70 loopCommand->SetParameter(param2);
71 G4UIparameter* param3 = new G4UIparameter("initialValue", 'd', false);
72 loopCommand->SetParameter(param3);
73 G4UIparameter* param4 = new G4UIparameter("finalValue", 'd', false);
74 loopCommand->SetParameter(param4);
75 G4UIparameter* param5 = new G4UIparameter("stepSize", 'd', true);
76 param5->SetDefaultValue(1.0);
77 loopCommand->SetParameter(param5);
78 loopCommand->SetToBeBroadcasted(false);
79
80 foreachCommand = new G4UIcommand("/control/foreach", this);
81 foreachCommand->SetGuidance("Execute a macro file more than once.");
82 foreachCommand->SetGuidance(
83 "Loop counter can be used as an aliased variable.");
84 foreachCommand->SetGuidance("Values must be separated by a space.");
85 G4UIparameter* param6 = new G4UIparameter("macroFile", 's', false);
86 foreachCommand->SetParameter(param6);
87 G4UIparameter* param7 = new G4UIparameter("counterName", 's', false);
88 foreachCommand->SetParameter(param7);
89 G4UIparameter* param8 = new G4UIparameter("valueList", 's', false);
90 foreachCommand->SetParameter(param8);
91 foreachCommand->SetToBeBroadcasted(false);
92
93 suppressAbortionCommand =
94 new G4UIcmdWithAnInteger("/control/suppressAbortion", this);
95 suppressAbortionCommand->SetGuidance(
96 "Suppress the program abortion caused by G4Exception.");
97 suppressAbortionCommand->SetGuidance(
98 "Suppression level = 0 : no suppression");
99 suppressAbortionCommand->SetGuidance(
100 " = 1 : suppress during EventProc state");
101 suppressAbortionCommand->SetGuidance(
102 " = 2 : full suppression, i.e. no abortion by "
103 "G4Exception");
104 suppressAbortionCommand->SetGuidance(
105 "When abortion is suppressed, you will get error messages issued by "
106 "G4Exception,");
107 suppressAbortionCommand->SetGuidance(
108 "and there is NO guarantee for the correct result after the G4Exception "
109 "error message.");
110 suppressAbortionCommand->SetParameterName("level", true);
111 suppressAbortionCommand->SetRange("level >= 0 && level <= 2");
112 suppressAbortionCommand->SetDefaultValue(0);
113
114 verboseCommand = new G4UIcmdWithAnInteger("/control/verbose", this);
115 verboseCommand->SetGuidance("Applied command will also be shown on screen.");
116 verboseCommand->SetGuidance("This command is useful with MACRO file.");
117 verboseCommand->SetGuidance(" 0 : silent");
118 verboseCommand->SetGuidance(" 1 : only the valid commands are shown.");
119 verboseCommand->SetGuidance(" 2 : comment lines are also shown (default).");
120 verboseCommand->SetParameterName("switch", true);
121 verboseCommand->SetRange("switch >= 0 && switch <=2");
122 verboseCommand->SetDefaultValue(2);
123
124 doublePrecCommand = new G4UIcmdWithABool("/control/useDoublePrecision", this);
125 doublePrecCommand->SetGuidance(
126 "Use double precision for printing out the current parameter value(s).");
127 doublePrecCommand->SetParameterName("useDoublePrecision", true);
128 doublePrecCommand->SetDefaultValue(true);
129
130 historyCommand = new G4UIcmdWithAString("/control/saveHistory", this);
131 historyCommand->SetGuidance("Store command history to a file.");
132 historyCommand->SetGuidance("Defaul file name is G4history.macro.");
133 historyCommand->SetParameterName("fileName", true);
134 historyCommand->SetDefaultValue("G4History.macro");
135
136 stopStoreHistoryCommand =
137 new G4UIcmdWithoutParameter("/control/stopSavingHistory", this);
138 stopStoreHistoryCommand->SetGuidance("Stop saving history file.");
139
140 aliasCommand = new G4UIcommand("/control/alias", this);
141 aliasCommand->SetGuidance("Set an alias.");
142 aliasCommand->SetGuidance("String can be aliased by this command.");
143 aliasCommand->SetGuidance("The string may contain one or more spaces,");
144 aliasCommand->SetGuidance(
145 "the string must be enclosed by double quotes (\").");
146 aliasCommand->SetGuidance("To use an alias, enclose the alias name with");
147 aliasCommand->SetGuidance("parenthesis \"{\" and \"}\".");
148 G4UIparameter* aliasNameParam = new G4UIparameter("aliasName", 's', false);
149 aliasCommand->SetParameter(aliasNameParam);
150 G4UIparameter* aliasValueParam = new G4UIparameter("aliasValue", 's', false);
151 aliasCommand->SetParameter(aliasValueParam);
152
153 unaliasCommand = new G4UIcmdWithAString("/control/unalias", this);
154 unaliasCommand->SetGuidance("Remove an alias.");
155 unaliasCommand->SetParameterName("aliasName", false);
156
157 listAliasCommand = new G4UIcmdWithoutParameter("/control/listAlias", this);
158 listAliasCommand->SetGuidance("List aliases.");
159
160 getEnvCmd = new G4UIcmdWithAString("/control/getEnv", this);
161 getEnvCmd->SetGuidance(
162 "Get a shell environment variable and define it as an alias.");
163
164 getValCmd = new G4UIcommand("/control/getVal", this);
165 getValCmd->SetGuidance(
166 "Get the current value of the UI command and define it as an alias.");
167 getValCmd->SetGuidance(
168 "Command is ignored if the UI command does not support GetCurrentValue().");
169 getValCmd->SetGuidance(" Syntax : <alias_name> <UI_command> <iIdx>");
170 G4UIparameter* aliName = new G4UIparameter("alias_name", 's', false);
171 getValCmd->SetParameter(aliName);
172 G4UIparameter* comName = new G4UIparameter("UI_command", 's', false);
173 getValCmd->SetParameter(comName);
174 G4UIparameter* iIdxParam = new G4UIparameter("iIdx", 'i', true);
175 iIdxParam->SetDefaultValue(0);
176 getValCmd->SetParameter(iIdxParam);
177
178 echoCmd = new G4UIcmdWithAString("/control/echo", this);
179 echoCmd->SetGuidance("Display the aliased value.");
180
181 shellCommand = new G4UIcmdWithAString("/control/shell", this);
182 shellCommand->SetGuidance("Execute a (Unix) SHELL command.");
183
184 ManualCommand = new G4UIcmdWithAString("/control/manual", this);
185 ManualCommand->SetGuidance("Display all of sub-directories and commands.");
186 ManualCommand->SetGuidance("Directory path should be given by FULL-PATH.");
187 ManualCommand->SetParameterName("dirPath", true);
188 ManualCommand->SetDefaultValue("/");
189 ManualCommand->SetToBeBroadcasted(false);
190
191 HTMLCommand = new G4UIcmdWithAString("/control/createHTML", this);
192 HTMLCommand->SetGuidance(
193 "Generate HTML files for all of sub-directories and commands.");
194 HTMLCommand->SetGuidance("Directory path should be given by FULL-PATH.");
195 HTMLCommand->SetParameterName("dirPath", true);
196 HTMLCommand->SetDefaultValue("/");
197 HTMLCommand->SetToBeBroadcasted(false);
198
199 maxStoredHistCommand =
200 new G4UIcmdWithAnInteger("/control/maximumStoredHistory", this);
201 maxStoredHistCommand->SetGuidance(
202 "Set maximum number of stored UI commands.");
203 maxStoredHistCommand->SetParameterName("max", true);
204 maxStoredHistCommand->SetDefaultValue(20);
205
206 ifCommand = new G4UIcommand("/control/if", this);
207 ifCommand->SetGuidance("Execute a macro file if the expression is true.");
208 ifCommand->SetGuidance(" Syntax : <double> <comp> <double> <macro_file>");
209 G4UIparameter* leftParam = new G4UIparameter("left", 'd', false);
210 ifCommand->SetParameter(leftParam);
211 G4UIparameter* compParam = new G4UIparameter("comp", 's', false);
212 compParam->SetParameterCandidates("> >= < <= == !=");
213 ifCommand->SetParameter(compParam);
214 G4UIparameter* rightParam = new G4UIparameter("right", 'd', false);
215 ifCommand->SetParameter(rightParam);
216 G4UIparameter* macroFileParam = new G4UIparameter("macroFile", 's', false);
217 ifCommand->SetParameter(macroFileParam);
218 ifCommand->SetToBeBroadcasted(false);
219
220 doifCommand = new G4UIcommand("/control/doif", this);
221 doifCommand->SetGuidance("Execute a UI command if the expression is true.");
222 doifCommand->SetGuidance(" Syntax : <double> <comp> <double> <UI_command>");
223 G4UIparameter* doleftParam = new G4UIparameter("left", 'd', false);
224 doifCommand->SetParameter(doleftParam);
225 G4UIparameter* docompParam = new G4UIparameter("comp", 's', false);
226 docompParam->SetParameterCandidates("> >= < <= == !=");
227 doifCommand->SetParameter(docompParam);
228 G4UIparameter* dorightParam = new G4UIparameter("right", 'd', false);
229 doifCommand->SetParameter(dorightParam);
230 G4UIparameter* comParam = new G4UIparameter("UI_command", 's', false);
231 doifCommand->SetParameter(comParam);
232 doifCommand->SetToBeBroadcasted(false);
233
234 addCommand = new G4UIcommand("/control/add", this);
235 addCommand->SetGuidance("Define a new alias as the sum of two values.");
236 addCommand->SetGuidance(" Syntax : <new_alias> <value1> <value2>");
237 addCommand->SetGuidance(
238 " <new_alias> may be an already existing alias. If it is the case,");
239 addCommand->SetGuidance(" aliased value is alternated.");
240 G4UIparameter* newAlias1 = new G4UIparameter("new_alias", 's', false);
241 addCommand->SetParameter(newAlias1);
242 G4UIparameter* val1a = new G4UIparameter("value1", 'd', false);
243 addCommand->SetParameter(val1a);
244 G4UIparameter* val1b = new G4UIparameter("value2", 'd', false);
245 addCommand->SetParameter(val1b);
246 addCommand->SetToBeBroadcasted(false);
247
248 subtractCommand = new G4UIcommand("/control/subtract", this);
249 subtractCommand->SetGuidance(
250 "Define a new alias as the subtraction of two values.");
251 subtractCommand->SetGuidance(" Syntax : <new_alias> <value1> <value2>");
252 subtractCommand->SetGuidance(
253 " <new_alias> may be an already existing alias. If it is the case,");
254 subtractCommand->SetGuidance(" aliased value is alternated.");
255 G4UIparameter* newAlias2 = new G4UIparameter("new_alias", 's', false);
256 subtractCommand->SetParameter(newAlias2);
257 G4UIparameter* val2a = new G4UIparameter("value1", 'd', false);
258 subtractCommand->SetParameter(val2a);
259 G4UIparameter* val2b = new G4UIparameter("value2", 'd', false);
260 subtractCommand->SetParameter(val2b);
261 subtractCommand->SetToBeBroadcasted(false);
262
263 multiplyCommand = new G4UIcommand("/control/multiply", this);
264 multiplyCommand->SetGuidance(
265 "Define a new alias as the multiplication of two values.");
266 multiplyCommand->SetGuidance(" Syntax : <new_alias> <value1> <value2>");
267 multiplyCommand->SetGuidance(
268 " <new_alias> may be an already existing alias. If it is the case,");
269 multiplyCommand->SetGuidance(" aliased value is alternated.");
270 G4UIparameter* newAlias3 = new G4UIparameter("new_alias", 's', false);
271 multiplyCommand->SetParameter(newAlias3);
272 G4UIparameter* val3a = new G4UIparameter("value1", 'd', false);
273 multiplyCommand->SetParameter(val3a);
274 G4UIparameter* val3b = new G4UIparameter("value2", 'd', false);
275 multiplyCommand->SetParameter(val3b);
276 multiplyCommand->SetToBeBroadcasted(false);
277
278 divideCommand = new G4UIcommand("/control/divide", this);
279 divideCommand->SetGuidance(
280 "Define a new alias as the division of two values.");
281 divideCommand->SetGuidance(" Syntax : <new_alias> <value1> <value2>");
282 divideCommand->SetGuidance(
283 " <new_alias> may be an already existing alias. If it is the case,");
284 divideCommand->SetGuidance(" aliased value is alternated.");
285 G4UIparameter* newAlias4 = new G4UIparameter("new_alias", 's', false);
286 divideCommand->SetParameter(newAlias4);
287 G4UIparameter* val4a = new G4UIparameter("value1", 'd', false);
288 divideCommand->SetParameter(val4a);
289 G4UIparameter* val4b = new G4UIparameter("value2", 'd', false);
290 val4b->SetParameterRange("value2 != 0.");
291 divideCommand->SetParameter(val4b);
292 divideCommand->SetToBeBroadcasted(false);
293
294 remainderCommand = new G4UIcommand("/control/remainder", this);
295 remainderCommand->SetGuidance(
296 "Define a new alias as the remainder of two values.");
297 remainderCommand->SetGuidance(" Syntax : <new_alias> <value1> <value2>");
298 remainderCommand->SetGuidance(
299 " <new_alias> may be an already existing alias. If it is the case,");
300 remainderCommand->SetGuidance(" aliased value is alternated.");
301 G4UIparameter* newAlias5 = new G4UIparameter("new_alias", 's', false);
302 remainderCommand->SetParameter(newAlias5);
303 G4UIparameter* val5a = new G4UIparameter("value1", 'i', false);
304 remainderCommand->SetParameter(val5a);
305 G4UIparameter* val5b = new G4UIparameter("value2", 'i', false);
306 val4b->SetParameterRange("value2 != 0");
307 remainderCommand->SetParameter(val5b);
308 remainderCommand->SetToBeBroadcasted(false);
309
310 strifCommand = new G4UIcommand("/control/strif", this);
311 strifCommand->SetGuidance("Execute a macro file if the expression is true.");
312 strifCommand->SetGuidance(" Syntax : <string> <comp> <string> <macro_file>");
313 G4UIparameter* strleftParam = new G4UIparameter("left", 's', false);
314 strifCommand->SetParameter(strleftParam);
315 G4UIparameter* strcompParam = new G4UIparameter("comp", 's', false);
316 strcompParam->SetParameterCandidates("== !=");
317 strifCommand->SetParameter(strcompParam);
318 G4UIparameter* strrightParam = new G4UIparameter("right", 's', false);
319 strifCommand->SetParameter(strrightParam);
320 G4UIparameter* strmacroFileParam = new G4UIparameter("macroFile", 's', false);
321 strifCommand->SetParameter(strmacroFileParam);
322 strifCommand->SetToBeBroadcasted(false);
323
324 strdoifCommand = new G4UIcommand("/control/strdoif", this);
325 strdoifCommand->SetGuidance(
326 "Execute a UI command if the expression is true.");
327 strdoifCommand->SetGuidance(
328 " Syntax : <string> <comp> <string> <UI_command>");
329 G4UIparameter* strdoleftParam = new G4UIparameter("left", 's', false);
330 strdoifCommand->SetParameter(strdoleftParam);
331 G4UIparameter* strdocompParam = new G4UIparameter("comp", 's', false);
332 strdocompParam->SetParameterCandidates("== !=");
333 strdoifCommand->SetParameter(strdocompParam);
334 G4UIparameter* strdorightParam = new G4UIparameter("right", 's', false);
335 strdoifCommand->SetParameter(strdorightParam);
336 G4UIparameter* strdomacroFileParam =
337 new G4UIparameter("UI_command", 's', false);
338 strdoifCommand->SetParameter(strdomacroFileParam);
339 strdoifCommand->SetToBeBroadcasted(false);
340
341 ifBatchCommand = new G4UIcmdWithAString("/control/ifBatch", this);
342 ifBatchCommand->SetGuidance(
343 "Execute a macro file if program is running in batch mode.");
344 ifBatchCommand->SetParameterName("macroFile", false);
345 ifBatchCommand->SetToBeBroadcasted(false);
346
347 ifInteractiveCommand = new G4UIcmdWithAString("/control/ifInteractive", this);
348 ifInteractiveCommand->SetGuidance(
349 "Execute a macro file if program is running in interactive mode.");
350 ifInteractiveCommand->SetParameterName("macroFile", false);
351 ifInteractiveCommand->SetToBeBroadcasted(false);
352
353 doifBatchCommand = new G4UIcmdWithAString("/control/doifBatch", this);
354 doifBatchCommand->SetGuidance(
355 "Execute a UI command if program is running in batch mode.");
356 doifBatchCommand->SetParameterName("UIcommand", false);
357 doifBatchCommand->SetToBeBroadcasted(false);
358
359 doifInteractiveCommand =
360 new G4UIcmdWithAString("/control/doifInteractive", this);
361 doifInteractiveCommand->SetGuidance(
362 "Execute a UI command if program is running in interactive mode.");
363 doifInteractiveCommand->SetParameterName("UIcommand", false);
364 doifInteractiveCommand->SetToBeBroadcasted(false);
365}
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
void SetDefaultValue(G4bool defVal)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
void SetDefaultValue(const char *defVal)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
void SetDefaultValue(G4int defVal)
void SetToBeBroadcasted(G4bool val)
Definition: G4UIcommand.hh:172
void SetParameter(G4UIparameter *const newParameter)
Definition: G4UIcommand.hh:146
void SetGuidance(const char *aGuidance)
Definition: G4UIcommand.hh:156
void SetRange(const char *rs)
Definition: G4UIcommand.hh:120
void SetDefaultValue(const char *theDefaultValue)
void SetParameterRange(const char *theRange)
void SetParameterCandidates(const char *theString)

◆ ~G4UIcontrolMessenger()

G4UIcontrolMessenger::~G4UIcontrolMessenger ( )

Definition at line 368 of file G4UIcontrolMessenger.cc.

369{
370 delete macroPathCommand;
371 delete ExecuteCommand;
372 delete suppressAbortionCommand;
373 delete verboseCommand;
374 delete doublePrecCommand;
375 delete historyCommand;
376 delete stopStoreHistoryCommand;
377 delete ManualCommand;
378 delete aliasCommand;
379 delete unaliasCommand;
380 delete listAliasCommand;
381 delete getEnvCmd;
382 delete getValCmd;
383 delete echoCmd;
384 delete shellCommand;
385 delete loopCommand;
386 delete foreachCommand;
387 delete HTMLCommand;
388 delete maxStoredHistCommand;
389 delete ifCommand;
390 delete doifCommand;
391 delete addCommand;
392 delete subtractCommand;
393 delete multiplyCommand;
394 delete divideCommand;
395 delete remainderCommand;
396 delete strifCommand;
397 delete strdoifCommand;
398 delete ifBatchCommand;
399 delete ifInteractiveCommand;
400 delete doifBatchCommand;
401 delete doifInteractiveCommand;
402 delete controlDirectory;
403}

Member Function Documentation

◆ GetCurrentValue()

G4String G4UIcontrolMessenger::GetCurrentValue ( G4UIcommand command)
virtual

Reimplemented from G4UImessenger.

Definition at line 761 of file G4UIcontrolMessenger.cc.

762{
764 G4String currentValue;
765
766 if(command == macroPathCommand)
767 {
768 currentValue = UI->GetMacroSearchPath();
769 }
770 if(command == verboseCommand)
771 {
772 currentValue = verboseCommand->ConvertToString(UI->GetVerboseLevel());
773 }
774 if(command == doublePrecCommand)
775 {
776 currentValue =
778 }
779 if(command == suppressAbortionCommand)
780 {
781 currentValue = suppressAbortionCommand->ConvertToString(
782 G4StateManager::GetStateManager()->GetSuppressAbortion());
783 }
784 if(command == maxStoredHistCommand)
785 {
786 currentValue = maxStoredHistCommand->ConvertToString(UI->GetMaxHistSize());
787 }
788
789 return currentValue;
790}
static G4StateManager * GetStateManager()
static G4String ConvertToString(G4bool boolVal)
Definition: G4UIcommand.cc:430
static G4bool DoublePrecisionStr()
Definition: G4UImanager.cc:158
const G4String & GetMacroSearchPath() const
Definition: G4UImanager.hh:208
G4int GetVerboseLevel() const
Definition: G4UImanager.hh:193
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:77
G4int GetMaxHistSize() const
Definition: G4UImanager.hh:205

◆ SetNewValue()

void G4UIcontrolMessenger::SetNewValue ( G4UIcommand command,
G4String  newValue 
)
virtual

Reimplemented from G4UImessenger.

Definition at line 406 of file G4UIcontrolMessenger.cc.

407{
409
410 if(command == macroPathCommand)
411 {
412 UI->SetMacroSearchPath(newValue);
414 }
415 if(command == ExecuteCommand)
416 {
417 command->ResetFailure();
418 UI->ExecuteMacroFile(UI->FindMacroPath(newValue));
419 if(UI->GetLastReturnCode() != 0)
420 {
422 ed << "Command aborted (" << UI->GetLastReturnCode() << ")";
423 command->CommandFailed(UI->GetLastReturnCode(), ed);
424 }
425 }
426 if(command == suppressAbortionCommand)
427 {
429 suppressAbortionCommand->GetNewIntValue(newValue));
430 }
431 if(command == verboseCommand)
432 {
433 UI->SetVerboseLevel(verboseCommand->GetNewIntValue(newValue));
434 }
435 if(command == doublePrecCommand)
436 {
438 doublePrecCommand->GetNewBoolValue(newValue));
439 }
440 if(command == historyCommand)
441 {
442 UI->StoreHistory(newValue);
443 }
444 if(command == stopStoreHistoryCommand)
445 {
446 UI->StoreHistory(false);
447 }
448 if(command == ManualCommand)
449 {
450 UI->ListCommands(newValue);
451 }
452 if(command == aliasCommand)
453 {
454 UI->SetAlias(newValue);
455 }
456 if(command == unaliasCommand)
457 {
458 UI->RemoveAlias(newValue);
459 }
460 if(command == listAliasCommand)
461 {
462 UI->ListAlias();
463 }
464 if(command == getEnvCmd)
465 {
466 command->ResetFailure();
467 if(std::getenv(newValue))
468 {
469 G4String st = newValue;
470 st += " ";
471 st += std::getenv(newValue);
472 UI->SetAlias(st.c_str());
473 }
474 else
475 {
477 ed << "<" << newValue
478 << "> is not defined as a shell variable. Command ignored.";
479 command->CommandFailed(ed);
480 }
481 }
482 if(command == getValCmd)
483 {
484 G4Tokenizer next(newValue);
485 G4String aliName = next();
486 G4String com = next();
487 G4String curVal = UI->GetCurrentValues(com);
488 if(!(curVal.isNull()))
489 {
490 G4String theValue = curVal;
491 G4String iIdx = next();
492 if(!(iIdx.isNull()))
493 {
494 G4int idx = StoI(iIdx);
495 G4Tokenizer nextVal(curVal);
496 for(G4int i = 0; i <= idx; i++)
497 {
498 theValue = nextVal();
499 }
500 }
501 G4String st = "/control/alias ";
502 st += aliName + " " + theValue;
503 UI->ApplyCommand(st);
504 }
505 }
506 if(command == echoCmd)
507 {
508 G4cout << UI->SolveAlias(newValue) << G4endl;
509 }
510 if(command == shellCommand)
511 {
512 command->ResetFailure();
513 int rc = system(newValue);
514 if(rc < 0)
515 {
517 ed << "<" << newValue
518 << "> is not a valid shell command. Command ignored.";
519 command->CommandFailed(ed);
520 }
521 }
522 if(command == loopCommand)
523 {
524 command->ResetFailure();
525 UI->LoopS(newValue);
526 if(UI->GetLastReturnCode() != 0)
527 {
529 ed << "Command aborted (" << UI->GetLastReturnCode() << ")";
530 command->CommandFailed(UI->GetLastReturnCode(), ed);
531 }
532 }
533 if(command == foreachCommand)
534 {
535 command->ResetFailure();
536 UI->ForeachS(newValue);
537 if(UI->GetLastReturnCode() != 0)
538 {
540 ed << "Command aborted (" << UI->GetLastReturnCode() << ")";
541 command->CommandFailed(UI->GetLastReturnCode(), ed);
542 }
543 }
544 if(command == HTMLCommand)
545 {
546 UI->CreateHTML(newValue);
547 }
548 if(command == maxStoredHistCommand)
549 {
550 UI->SetMaxHistSize(maxStoredHistCommand->GetNewIntValue(newValue));
551 }
552 if(command == ifCommand)
553 {
554 G4Tokenizer next(newValue);
555 G4double l = StoD(next());
556 G4String comp = next();
557 G4double r = StoD(next());
558 G4String mac = next();
559 G4bool x = false;
560 if(comp == ">")
561 x = (l > r);
562 else if(comp == ">=")
563 x = (l >= r);
564 else if(comp == "<")
565 x = (l < r);
566 else if(comp == "<=")
567 x = (l <= r);
568 else if(comp == "==")
569 x = (l == r);
570 else if(comp == "!=")
571 x = (l != r);
572 if(x)
573 UI->ExecuteMacroFile(mac);
574 }
575 if(command == doifCommand)
576 {
577 G4Tokenizer next(newValue);
578 G4double l = StoD(next());
579 G4String comp = next();
580 G4double r = StoD(next());
581
582 G4String c1 = next();
583 G4String ca;
584 while(!((ca = next()).isNull()))
585 {
586 c1 += " ";
587 c1 += ca;
588 }
589 if(c1(0) == '"')
590 {
591 G4String strippedValue;
592 if(c1(c1.length() - 1) == '"')
593 {
594 strippedValue = c1(1, c1.length() - 2);
595 }
596 else
597 {
598 strippedValue = c1(1, c1.length() - 1);
599 }
600 c1 = strippedValue;
601 }
602
603 G4bool x = false;
604 if(comp == ">")
605 x = (l > r);
606 else if(comp == ">=")
607 x = (l >= r);
608 else if(comp == "<")
609 x = (l < r);
610 else if(comp == "<=")
611 x = (l <= r);
612 else if(comp == "==")
613 x = (l == r);
614 else if(comp == "!=")
615 x = (l != r);
616 if(x)
617 UI->ApplyCommand(c1);
618 }
619 if(command == addCommand)
620 {
621 G4Tokenizer next(newValue);
622 G4String newA = next();
623 G4double l = StoD(next());
624 G4double r = StoD(next());
625 G4String st = "/control/alias ";
626 st += newA;
627 st += " ";
628 st += DtoS(l + r);
629 UI->ApplyCommand(st);
630 }
631 if(command == subtractCommand)
632 {
633 G4Tokenizer next(newValue);
634 G4String newA = next();
635 G4double l = StoD(next());
636 G4double r = StoD(next());
637 G4String st = "/control/alias ";
638 st += newA;
639 st += " ";
640 st += DtoS(l - r);
641 UI->ApplyCommand(st);
642 }
643 if(command == multiplyCommand)
644 {
645 G4Tokenizer next(newValue);
646 G4String newA = next();
647 G4double l = StoD(next());
648 G4double r = StoD(next());
649 G4String st = "/control/alias ";
650 st += newA;
651 st += " ";
652 st += DtoS(l * r);
653 UI->ApplyCommand(st);
654 }
655 if(command == divideCommand)
656 {
657 G4Tokenizer next(newValue);
658 G4String newA = next();
659 G4double l = StoD(next());
660 G4double r = StoD(next());
661 G4String st = "/control/alias ";
662 st += newA;
663 st += " ";
664 st += DtoS(l / r);
665 UI->ApplyCommand(st);
666 }
667 if(command == remainderCommand)
668 {
669 G4Tokenizer next(newValue);
670 G4String newA = next();
671 G4int l = StoI(next());
672 G4int r = StoI(next());
673 G4String st = "/control/alias ";
674 st += newA;
675 st += " ";
676 st += DtoS(l % r);
677 UI->ApplyCommand(st);
678 }
679 if(command == strifCommand)
680 {
681 G4Tokenizer next(newValue);
682 G4String l = next();
683 G4String comp = next();
684 G4String r = next();
685 G4String mac = next();
686 G4bool x = false;
687 if(comp == "==")
688 {
689 x = (l == r);
690 }
691 else if(comp == "!=")
692 {
693 x = (l != r);
694 }
695 if(x)
696 UI->ExecuteMacroFile(mac);
697 }
698 if(command == strdoifCommand)
699 {
700 G4Tokenizer next(newValue);
701 G4String l = next();
702 G4String comp = next();
703 G4String r = next();
704
705 G4String c1 = next();
706 G4String ca;
707 while(!((ca = next()).isNull()))
708 {
709 c1 += " ";
710 c1 += ca;
711 }
712 if(c1(0) == '"')
713 {
714 G4String strippedValue;
715 if(c1(c1.length() - 1) == '"')
716 {
717 strippedValue = c1(1, c1.length() - 2);
718 }
719 else
720 {
721 strippedValue = c1(1, c1.length() - 1);
722 }
723 c1 = strippedValue;
724 }
725
726 G4bool x = false;
727 if(comp == "==")
728 {
729 x = (l == r);
730 }
731 else if(comp == "!=")
732 {
733 x = (l != r);
734 }
735 if(x)
736 UI->ApplyCommand(c1);
737 }
738 if(command == ifBatchCommand)
739 {
740 if(G4UIsession::InSession() == 0)
741 UI->ExecuteMacroFile(UI->FindMacroPath(newValue));
742 }
743 if(command == ifInteractiveCommand)
744 {
745 if(G4UIsession::InSession() > 0)
746 UI->ExecuteMacroFile(UI->FindMacroPath(newValue));
747 }
748 if(command == doifBatchCommand)
749 {
750 if(G4UIsession::InSession() == 0)
751 UI->ApplyCommand(newValue);
752 }
753 if(command == doifInteractiveCommand)
754 {
755 if(G4UIsession::InSession() > 0)
756 UI->ApplyCommand(newValue);
757 }
758}
std::ostringstream G4ExceptionDescription
Definition: G4Exception.hh:40
double G4double
Definition: G4Types.hh:83
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
void SetSuppressAbortion(G4int i)
G4bool isNull() const
static G4bool GetNewBoolValue(const char *paramString)
static G4int GetNewIntValue(const char *paramString)
void ResetFailure()
Definition: G4UIcommand.hh:191
void CommandFailed(G4int errCode, G4ExceptionDescription &ed)
Definition: G4UIcommand.hh:179
static void UseDoublePrecisionStr(G4bool val)
Definition: G4UImanager.cc:152
void ForeachS(const char *valueList)
Definition: G4UImanager.cc:365
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:485
void CreateHTML(const char *dir="/")
Definition: G4UImanager.cc:744
void LoopS(const char *valueList)
Definition: G4UImanager.cc:315
void StoreHistory(const char *fileName="G4history.macro")
Definition: G4UImanager.cc:599
void ListCommands(const char *direc)
Definition: G4UImanager.cc:632
void ExecuteMacroFile(const char *fileName)
Definition: G4UImanager.cc:303
void SetMacroSearchPath(const G4String &path)
Definition: G4UImanager.hh:207
void SetMaxHistSize(G4int mx)
Definition: G4UImanager.hh:204
G4int GetLastReturnCode() const
Definition: G4UImanager.hh:247
G4String GetCurrentValues(const char *aCommand)
Definition: G4UImanager.cc:164
void SetAlias(const char *aliasLine)
Definition: G4UImanager.cc:706
G4String FindMacroPath(const G4String &fname) const
Definition: G4UImanager.cc:793
void RemoveAlias(const char *aliasName)
Definition: G4UImanager.cc:730
G4String SolveAlias(const char *aCmd)
Definition: G4UImanager.cc:424
void ListAlias()
Definition: G4UImanager.cc:738
void ParseMacroSearchPath()
Definition: G4UImanager.cc:758
void SetVerboseLevel(G4int val)
Definition: G4UImanager.hh:192
G4int StoI(G4String s)
G4String DtoS(G4double a)
G4double StoD(G4String s)
static G4int InSession()
Definition: G4UIsession.cc:68

The documentation for this class was generated from the following files: