53 controlDirectory->
SetGuidance(
"UI control commands.");
57 "Set macro search path"
58 " with colon-separated list.");
62 ExecuteCommand->
SetGuidance(
"Execute a macro file.");
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.");
78 param5->SetDefaultValue(1.0);
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.");
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");
99 " = 2 : full suppression, i.e. no abortion by "
102 "When abortion is suppressed, you will get error messages issued by "
105 "and there is NO guarantee for the correct result after the G4Exception "
108 suppressAbortionCommand->
SetRange(
"level >= 0 && level <= 2");
112 verboseCommand->
SetGuidance(
"Applied command will also be shown on screen.");
113 verboseCommand->
SetGuidance(
"This command is useful with MACRO file.");
115 verboseCommand->
SetGuidance(
" 1 : only the valid commands are shown.");
116 verboseCommand->
SetGuidance(
" 2 : comment lines are also shown (default).");
118 verboseCommand->
SetRange(
"switch >= 0 && switch <=2");
121 doublePrecCommand =
new G4UIcmdWithABool(
"/control/useDoublePrecision",
this);
123 "Use double precision for printing out the current parameter value(s).");
128 historyCommand->
SetGuidance(
"Store command history to a file.");
129 historyCommand->
SetGuidance(
"Defaul file name is G4history.macro.");
135 stopStoreHistoryCommand->
SetGuidance(
"Stop saving history file.");
138 aliasCommand =
new G4UIcommand(
"/control/alias",
this);
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);
147 auto* aliasValueParam =
new G4UIparameter(
"aliasValue",
's',
false);
158 getEnvCmd->
SetGuidance(
"Get a shell environment variable and define it as an alias.");
161 getValCmd =
new G4UIcommand(
"/control/getVal",
this);
162 getValCmd->
SetGuidance(
"Get the current value of the UI command and define it as an alias.");
164 "Command is ignored if the UI command does not support GetCurrentValue().");
165 getValCmd->
SetGuidance(
" Syntax : <alias_name> <UI_command> <iIdx>");
171 iIdxParam->SetDefaultValue(0);
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.");
184 ManualCommand->
SetGuidance(
"Display all of sub-directories and commands.");
185 ManualCommand->
SetGuidance(
"Directory path should be given by FULL-PATH.");
191 HTMLCommand->
SetGuidance(
"Generate HTML files for all of sub-directories and commands.");
192 HTMLCommand->
SetGuidance(
"Directory path should be given by FULL-PATH.");
198 maxStoredHistCommand->
SetGuidance(
"Set maximum number of stored UI commands.");
203 ifCommand->
SetGuidance(
"Execute a macro file if the expression is true.");
204 ifCommand->
SetGuidance(
" Syntax : <double> <comp> <double> <macro_file>");
208 compParam->SetParameterCandidates(
"> >= < <= == !=");
212 auto* macroFileParam =
new G4UIparameter(
"macroFile",
's',
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>");
222 docompParam->SetParameterCandidates(
"> >= < <= == !=");
226 auto* comParam =
new G4UIparameter(
"UI_command",
's',
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);
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);
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);
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);
279 val4b->SetParameterRange(
"value2 != 0.");
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>");
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);
294 val4b->SetParameterRange(
"value2 != 0");
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>");
304 strcompParam->SetParameterCandidates(
"== !=");
306 auto* strrightParam =
new G4UIparameter(
"right",
's',
false);
308 auto* strmacroFileParam =
new G4UIparameter(
"macroFile",
's',
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);
317 auto* strdocompParam =
new G4UIparameter(
"comp",
's',
false);
318 strdocompParam->SetParameterCandidates(
"== !=");
320 auto* strdorightParam =
new G4UIparameter(
"right",
's',
false);
322 auto* strdomacroFileParam =
new G4UIparameter(
"UI_command",
's',
false);
327 ifBatchCommand->
SetGuidance(
"Execute a macro file if program is running in batch mode.");
333 "Execute a macro file if program is running in interactive mode.");
338 doifBatchCommand->
SetGuidance(
"Execute a UI command if program is running in batch mode.");
344 "Execute a UI command if program is running in interactive mode.");
352 delete macroPathCommand;
353 delete ExecuteCommand;
354 delete suppressAbortionCommand;
355 delete verboseCommand;
356 delete doublePrecCommand;
357 delete historyCommand;
358 delete stopStoreHistoryCommand;
359 delete ManualCommand;
361 delete unaliasCommand;
362 delete listAliasCommand;
368 delete foreachCommand;
370 delete maxStoredHistCommand;
374 delete subtractCommand;
375 delete multiplyCommand;
376 delete divideCommand;
377 delete remainderCommand;
379 delete strdoifCommand;
380 delete ifBatchCommand;
381 delete ifInteractiveCommand;
382 delete doifBatchCommand;
383 delete doifInteractiveCommand;
384 delete controlDirectory;
392 if (command == macroPathCommand) {
396 if (command == ExecuteCommand) {
405 if (command == suppressAbortionCommand) {
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 int 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) {
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);
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);
677 else if (comp ==
"!=") {
684 if (command == ifBatchCommand) {
689 if (command == ifInteractiveCommand) {
694 if (command == doifBatchCommand) {
699 if (command == doifInteractiveCommand) {
712 if (command == macroPathCommand) {
715 if (command == verboseCommand) {
718 if (command == doublePrecCommand) {
721 if (command == suppressAbortionCommand) {
725 if (command == maxStoredHistCommand) {
std::ostringstream G4ExceptionDescription
G4GLOB_DLL std::ostream G4cout
void SetSuppressAbortion(G4int i)
static G4StateManager * GetStateManager()
static G4bool GetNewBoolValue(const char *paramString)
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)
static G4int GetNewIntValue(const char *paramString)
void SetDefaultValue(G4int defVal)
void SetToBeBroadcasted(G4bool val)
static G4String ConvertToString(G4bool boolVal)
void SetParameter(G4UIparameter *const newParameter)
void SetGuidance(const char *aGuidance)
void CommandFailed(G4int errCode, G4ExceptionDescription &ed)
void SetRange(const char *rs)
void SetNewValue(G4UIcommand *command, G4String newValue) override
G4String GetCurrentValue(G4UIcommand *command) override
~G4UIcontrolMessenger() override
static G4bool DoublePrecisionStr()
static void UseDoublePrecisionStr(G4bool val)
const G4String & GetMacroSearchPath() const
void ForeachS(const char *valueList)
G4int ApplyCommand(const char *aCommand)
void CreateHTML(const char *dir="/")
void LoopS(const char *valueList)
void StoreHistory(const char *fileName="G4history.macro")
void ListCommands(const char *direc)
void ExecuteMacroFile(const char *fileName)
void SetMacroSearchPath(const G4String &path)
void SetMaxHistSize(G4int mx)
G4int GetVerboseLevel() const
G4int GetLastReturnCode() const
G4String GetCurrentValues(const char *aCommand)
void SetAlias(const char *aliasLine)
G4String FindMacroPath(const G4String &fname) const
void RemoveAlias(const char *aliasName)
G4String SolveAlias(const char *aCmd)
void ParseMacroSearchPath()
static G4UImanager * GetUIpointer()
G4int GetMaxHistSize() const
void SetVerboseLevel(G4int val)
G4double StoD(const G4String &s)
G4String DtoS(G4double a)
G4int StoI(const G4String &s)