53 controlDirectory->SetGuidance(
"UI control commands.");
56 macroPathCommand->SetGuidance(
57 "Set macro search path"
58 " with colon-separated list.");
59 macroPathCommand->SetParameterName(
"path",
false);
62 ExecuteCommand->SetGuidance(
"Execute a macro file.");
63 ExecuteCommand->SetParameterName(
"fileName",
false);
64 ExecuteCommand->SetToBeBroadcasted(
false);
66 loopCommand =
new G4UIcommand(
"/control/loop",
this);
67 loopCommand->SetGuidance(
"Execute a macro file more than once.");
68 loopCommand->SetGuidance(
"Loop counter can be used as an aliased variable.");
70 loopCommand->SetParameter(param1);
72 loopCommand->SetParameter(param2);
74 loopCommand->SetParameter(param3);
76 loopCommand->SetParameter(param4);
78 param5->SetDefaultValue(1.0);
79 loopCommand->SetParameter(param5);
80 loopCommand->SetToBeBroadcasted(
false);
82 foreachCommand =
new G4UIcommand(
"/control/foreach",
this);
83 foreachCommand->SetGuidance(
"Execute a macro file more than once.");
84 foreachCommand->SetGuidance(
"Loop counter can be used as an aliased variable.");
85 foreachCommand->SetGuidance(
"Values must be separated by a space.");
87 foreachCommand->SetParameter(param6);
89 foreachCommand->SetParameter(param7);
91 foreachCommand->SetParameter(param8);
92 foreachCommand->SetToBeBroadcasted(
false);
95 suppressAbortionCommand->SetGuidance(
"Suppress the program abortion caused by G4Exception.");
96 suppressAbortionCommand->SetGuidance(
"Suppression level = 0 : no suppression");
97 suppressAbortionCommand->SetGuidance(
" = 1 : suppress during EventProc state");
98 suppressAbortionCommand->SetGuidance(
99 " = 2 : full suppression, i.e. no abortion by "
101 suppressAbortionCommand->SetGuidance(
102 "When abortion is suppressed, you will get error messages issued by "
104 suppressAbortionCommand->SetGuidance(
105 "and there is NO guarantee for the correct result after the G4Exception "
107 suppressAbortionCommand->SetParameterName(
"level",
true);
108 suppressAbortionCommand->SetRange(
"level >= 0 && level <= 2");
109 suppressAbortionCommand->SetDefaultValue(0);
112 verboseCommand->SetGuidance(
"Applied command will also be shown on screen.");
113 verboseCommand->SetGuidance(
"This command is useful with MACRO file.");
114 verboseCommand->SetGuidance(
" 0 : silent");
115 verboseCommand->SetGuidance(
" 1 : only the valid commands are shown.");
116 verboseCommand->SetGuidance(
" 2 : comment lines are also shown (default).");
117 verboseCommand->SetParameterName(
"switch",
true);
118 verboseCommand->SetRange(
"switch >= 0 && switch <=2");
119 verboseCommand->SetDefaultValue(2);
121 doublePrecCommand =
new G4UIcmdWithABool(
"/control/useDoublePrecision",
this);
122 doublePrecCommand->SetGuidance(
123 "Use double precision for printing out the current parameter value(s).");
124 doublePrecCommand->SetParameterName(
"useDoublePrecision",
true);
125 doublePrecCommand->SetDefaultValue(
true);
128 historyCommand->SetGuidance(
"Store command history to a file.");
129 historyCommand->SetGuidance(
"Defaul file name is G4history.macro.");
130 historyCommand->SetParameterName(
"fileName",
true);
131 historyCommand->SetDefaultValue(
"G4History.macro");
132 historyCommand->SetToBeBroadcasted(
false);
135 stopStoreHistoryCommand->SetGuidance(
"Stop saving history file.");
136 stopStoreHistoryCommand->SetToBeBroadcasted(
false);
138 aliasCommand =
new G4UIcommand(
"/control/alias",
this);
139 aliasCommand->SetGuidance(
"Set an alias.");
140 aliasCommand->SetGuidance(
"String can be aliased by this command.");
141 aliasCommand->SetGuidance(
"The string may contain one or more spaces,");
142 aliasCommand->SetGuidance(
"the string must be enclosed by double quotes (\").");
143 aliasCommand->SetGuidance(
"To use an alias, enclose the alias name with");
144 aliasCommand->SetGuidance(
"parenthesis \"{\" and \"}\".");
145 auto* aliasNameParam =
new G4UIparameter(
"aliasName",
's',
false);
146 aliasCommand->SetParameter(aliasNameParam);
147 auto* aliasValueParam =
new G4UIparameter(
"aliasValue",
's',
false);
148 aliasCommand->SetParameter(aliasValueParam);
151 unaliasCommand->SetGuidance(
"Remove an alias.");
152 unaliasCommand->SetParameterName(
"aliasName",
false);
155 listAliasCommand->SetGuidance(
"List aliases.");
158 getEnvCmd->SetGuidance(
"Get a shell environment variable and define it as an alias.");
159 getEnvCmd->SetToBeBroadcasted(
false);
161 getValCmd =
new G4UIcommand(
"/control/getVal",
this);
162 getValCmd->SetGuidance(
"Get the current value of the UI command and define it as an alias.");
163 getValCmd->SetGuidance(
164 "Command is ignored if the UI command does not support GetCurrentValue().");
165 getValCmd->SetGuidance(
" Syntax : <alias_name> <UI_command> <iIdx>");
167 getValCmd->SetParameter(aliName);
169 getValCmd->SetParameter(comName);
171 iIdxParam->SetDefaultValue(0);
172 getValCmd->SetParameter(iIdxParam);
173 getValCmd->SetToBeBroadcasted(
false);
176 echoCmd->SetGuidance(
"Display the valuerameter string.");
177 echoCmd->SetGuidance(
"If alias is contained, it is converted to the aliased value.");
180 shellCommand->SetGuidance(
"Execute a (Unix) SHELL command.");
181 shellCommand->SetToBeBroadcasted(
false);
184 ManualCommand->SetGuidance(
"Display all of sub-directories and commands.");
185 ManualCommand->SetGuidance(
"Directory path should be given by FULL-PATH.");
186 ManualCommand->SetParameterName(
"dirPath",
true);
187 ManualCommand->SetDefaultValue(
"/");
188 ManualCommand->SetToBeBroadcasted(
false);
191 HTMLCommand->SetGuidance(
"Generate HTML files for all of sub-directories and commands.");
192 HTMLCommand->SetGuidance(
"Directory path should be given by FULL-PATH.");
193 HTMLCommand->SetParameterName(
"dirPath",
true);
194 HTMLCommand->SetDefaultValue(
"/");
195 HTMLCommand->SetToBeBroadcasted(
false);
198 maxStoredHistCommand->SetGuidance(
"Set maximum number of stored UI commands.");
199 maxStoredHistCommand->SetParameterName(
"max",
true);
200 maxStoredHistCommand->SetDefaultValue(20);
203 ifCommand->SetGuidance(
"Execute a macro file if the expression is true.");
204 ifCommand->SetGuidance(
" Syntax : <double> <comp> <double> <macro_file>");
206 ifCommand->SetParameter(leftParam);
208 compParam->SetParameterCandidates(
"> >= < <= == !=");
209 ifCommand->SetParameter(compParam);
211 ifCommand->SetParameter(rightParam);
212 auto* macroFileParam =
new G4UIparameter(
"macroFile",
's',
false);
213 ifCommand->SetParameter(macroFileParam);
214 ifCommand->SetToBeBroadcasted(
false);
216 doifCommand =
new G4UIcommand(
"/control/doif",
this);
217 doifCommand->SetGuidance(
"Execute a UI command if the expression is true.");
218 doifCommand->SetGuidance(
" Syntax : <double> <comp> <double> <UI_command>");
220 doifCommand->SetParameter(doleftParam);
222 docompParam->SetParameterCandidates(
"> >= < <= == !=");
223 doifCommand->SetParameter(docompParam);
225 doifCommand->SetParameter(dorightParam);
226 auto* comParam =
new G4UIparameter(
"UI_command",
's',
false);
227 doifCommand->SetParameter(comParam);
228 doifCommand->SetToBeBroadcasted(
false);
230 addCommand =
new G4UIcommand(
"/control/add",
this);
231 addCommand->SetGuidance(
"Define a new alias as the sum of two values.");
232 addCommand->SetGuidance(
" Syntax : <new_alias> <value1> <value2>");
233 addCommand->SetGuidance(
" <new_alias> may be an already existing alias. If it is the case,");
234 addCommand->SetGuidance(
" aliased value is alternated.");
235 auto* newAlias1 =
new G4UIparameter(
"new_alias",
's',
false);
236 addCommand->SetParameter(newAlias1);
238 addCommand->SetParameter(val1a);
240 addCommand->SetParameter(val1b);
241 addCommand->SetToBeBroadcasted(
false);
243 subtractCommand =
new G4UIcommand(
"/control/subtract",
this);
244 subtractCommand->SetGuidance(
"Define a new alias as the subtraction of two values.");
245 subtractCommand->SetGuidance(
" Syntax : <new_alias> <value1> <value2>");
246 subtractCommand->SetGuidance(
" <new_alias> may be an already existing alias. If it is the case,");
247 subtractCommand->SetGuidance(
" aliased value is alternated.");
248 auto* newAlias2 =
new G4UIparameter(
"new_alias",
's',
false);
249 subtractCommand->SetParameter(newAlias2);
251 subtractCommand->SetParameter(val2a);
253 subtractCommand->SetParameter(val2b);
254 subtractCommand->SetToBeBroadcasted(
false);
256 multiplyCommand =
new G4UIcommand(
"/control/multiply",
this);
257 multiplyCommand->SetGuidance(
"Define a new alias as the multiplication of two values.");
258 multiplyCommand->SetGuidance(
" Syntax : <new_alias> <value1> <value2>");
259 multiplyCommand->SetGuidance(
" <new_alias> may be an already existing alias. If it is the case,");
260 multiplyCommand->SetGuidance(
" aliased value is alternated.");
261 auto* newAlias3 =
new G4UIparameter(
"new_alias",
's',
false);
262 multiplyCommand->SetParameter(newAlias3);
264 multiplyCommand->SetParameter(val3a);
266 multiplyCommand->SetParameter(val3b);
267 multiplyCommand->SetToBeBroadcasted(
false);
269 divideCommand =
new G4UIcommand(
"/control/divide",
this);
270 divideCommand->SetGuidance(
"Define a new alias as the division of two values.");
271 divideCommand->SetGuidance(
" Syntax : <new_alias> <value1> <value2>");
272 divideCommand->SetGuidance(
" <new_alias> may be an already existing alias. If it is the case,");
273 divideCommand->SetGuidance(
" aliased value is alternated.");
274 auto* newAlias4 =
new G4UIparameter(
"new_alias",
's',
false);
275 divideCommand->SetParameter(newAlias4);
277 divideCommand->SetParameter(val4a);
279 val4b->SetParameterRange(
"value2 != 0.");
280 divideCommand->SetParameter(val4b);
281 divideCommand->SetToBeBroadcasted(
false);
283 remainderCommand =
new G4UIcommand(
"/control/remainder",
this);
284 remainderCommand->SetGuidance(
"Define a new alias as the remainder of two values.");
285 remainderCommand->SetGuidance(
" Syntax : <new_alias> <value1> <value2>");
286 remainderCommand->SetGuidance(
287 " <new_alias> may be an already existing alias. If it is the case,");
288 remainderCommand->SetGuidance(
" aliased value is alternated.");
289 auto* newAlias5 =
new G4UIparameter(
"new_alias",
's',
false);
290 remainderCommand->SetParameter(newAlias5);
292 remainderCommand->SetParameter(val5a);
294 val4b->SetParameterRange(
"value2 != 0");
295 remainderCommand->SetParameter(val5b);
296 remainderCommand->SetToBeBroadcasted(
false);
298 strifCommand =
new G4UIcommand(
"/control/strif",
this);
299 strifCommand->SetGuidance(
"Execute a macro file if the expression is true.");
300 strifCommand->SetGuidance(
" Syntax : <string> <comp> <string> <macro_file>");
302 strifCommand->SetParameter(strleftParam);
304 strcompParam->SetParameterCandidates(
"== !=");
305 strifCommand->SetParameter(strcompParam);
306 auto* strrightParam =
new G4UIparameter(
"right",
's',
false);
307 strifCommand->SetParameter(strrightParam);
308 auto* strmacroFileParam =
new G4UIparameter(
"macroFile",
's',
false);
309 strifCommand->SetParameter(strmacroFileParam);
310 strifCommand->SetToBeBroadcasted(
false);
312 strdoifCommand =
new G4UIcommand(
"/control/strdoif",
this);
313 strdoifCommand->SetGuidance(
"Execute a UI command if the expression is true.");
314 strdoifCommand->SetGuidance(
" Syntax : <string> <comp> <string> <UI_command>");
315 auto* strdoleftParam =
new G4UIparameter(
"left",
's',
false);
316 strdoifCommand->SetParameter(strdoleftParam);
317 auto* strdocompParam =
new G4UIparameter(
"comp",
's',
false);
318 strdocompParam->SetParameterCandidates(
"== !=");
319 strdoifCommand->SetParameter(strdocompParam);
320 auto* strdorightParam =
new G4UIparameter(
"right",
's',
false);
321 strdoifCommand->SetParameter(strdorightParam);
322 auto* strdomacroFileParam =
new G4UIparameter(
"UI_command",
's',
false);
323 strdoifCommand->SetParameter(strdomacroFileParam);
324 strdoifCommand->SetToBeBroadcasted(
false);
327 ifBatchCommand->SetGuidance(
"Execute a macro file if program is running in batch mode.");
328 ifBatchCommand->SetParameterName(
"macroFile",
false);
329 ifBatchCommand->SetToBeBroadcasted(
false);
332 ifInteractiveCommand->SetGuidance(
333 "Execute a macro file if program is running in interactive mode.");
334 ifInteractiveCommand->SetParameterName(
"macroFile",
false);
335 ifInteractiveCommand->SetToBeBroadcasted(
false);
338 doifBatchCommand->SetGuidance(
"Execute a UI command if program is running in batch mode.");
339 doifBatchCommand->SetParameterName(
"UIcommand",
false);
340 doifBatchCommand->SetToBeBroadcasted(
false);
343 doifInteractiveCommand->SetGuidance(
344 "Execute a UI command if program is running in interactive mode.");
345 doifInteractiveCommand->SetParameterName(
"UIcommand",
false);
346 doifInteractiveCommand->SetToBeBroadcasted(
false);
392 if (command == macroPathCommand) {
396 if (command == ExecuteCommand) {
405 if (command == suppressAbortionCommand) {
407 suppressAbortionCommand->GetNewIntValue(newValue));
409 if (command == verboseCommand) {
412 if (command == doublePrecCommand) {
415 if (command == historyCommand) {
418 if (command == stopStoreHistoryCommand) {
421 if (command == ManualCommand) {
424 if (command == aliasCommand) {
427 if (command == unaliasCommand) {
430 if (command == listAliasCommand) {
433 if (command == getEnvCmd) {
435 if (std::getenv(newValue) !=
nullptr) {
438 st += std::getenv(newValue);
443 ed <<
"<" << newValue <<
"> is not defined as a shell variable. Command ignored.";
447 if (command == getValCmd) {
452 if (!(curVal.empty())) {
455 if (!(iIdx.empty())) {
458 for (
G4int i = 0; i <= idx; i++) {
459 theValue = nextVal();
463 st += aliName +
" " + theValue;
467 if (command == echoCmd) {
470 if (command == shellCommand) {
472 G4int rc = system(newValue);
475 ed <<
"<" << newValue <<
"> is not a valid shell command. Command ignored.";
479 if (command == loopCommand) {
488 if (command == foreachCommand) {
497 if (command == HTMLCommand) {
500 if (command == maxStoredHistCommand) {
501 UI->
SetMaxHistSize(maxStoredHistCommand->GetNewIntValue(newValue));
503 if (command == ifCommand) {
513 else if (comp ==
">=") {
516 else if (comp ==
"<") {
519 else if (comp ==
"<=") {
522 else if (comp ==
"==") {
525 else if (comp ==
"!=") {
532 if (command == doifCommand) {
540 while (!((ca = next()).empty())) {
546 if (c1.back() ==
'"') {
547 strippedValue = c1.substr(1, c1.length() - 2);
550 strippedValue = c1.substr(1, c1.length() - 1);
552 c1 = std::move(strippedValue);
559 else if (comp ==
">=") {
562 else if (comp ==
"<") {
565 else if (comp ==
"<=") {
568 else if (comp ==
"==") {
571 else if (comp ==
"!=") {
578 if (command == addCommand) {
589 if (command == subtractCommand) {
600 if (command == multiplyCommand) {
611 if (command == divideCommand) {
622 if (command == remainderCommand) {
633 if (command == strifCommand) {
643 else if (comp ==
"!=") {
650 if (command == strdoifCommand) {
658 while (!((ca = next()).empty())) {
664 if (c1.back() ==
'"') {
665 strippedValue = c1.substr(1, c1.length() - 2);
668 strippedValue = c1.substr(1, c1.length() - 1);
670 c1 = std::move(strippedValue);
677 else if (comp ==
"!=") {
684 if (command == ifBatchCommand) {
689 if (command == ifInteractiveCommand) {
694 if (command == doifBatchCommand) {
699 if (command == doifInteractiveCommand) {