52 controlDirectory->
SetGuidance(
"UI control commands.");
55 macroPathCommand->
SetGuidance(
"Set macro search path"
56 " with colon-separated list.");
60 ExecuteCommand->
SetGuidance(
"Execute a macro file.");
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.");
76 param5->SetDefaultValue(1.0);
80 foreachCommand =
new G4UIcommand(
"/control/foreach",
this);
81 foreachCommand->
SetGuidance(
"Execute a macro file more than once.");
83 "Loop counter can be used as an aliased variable.");
84 foreachCommand->
SetGuidance(
"Values must be separated by a space.");
93 suppressAbortionCommand =
96 "Suppress the program abortion caused by G4Exception.");
98 "Suppression level = 0 : no suppression");
100 " = 1 : suppress during EventProc state");
102 " = 2 : full suppression, i.e. no abortion by "
105 "When abortion is suppressed, you will get error messages issued by "
108 "and there is NO guarantee for the correct result after the G4Exception "
111 suppressAbortionCommand->
SetRange(
"level >= 0 && level <= 2");
115 verboseCommand->
SetGuidance(
"Applied command will also be shown on screen.");
116 verboseCommand->
SetGuidance(
"This command is useful with MACRO file.");
118 verboseCommand->
SetGuidance(
" 1 : only the valid commands are shown.");
119 verboseCommand->
SetGuidance(
" 2 : comment lines are also shown (default).");
121 verboseCommand->
SetRange(
"switch >= 0 && switch <=2");
124 doublePrecCommand =
new G4UIcmdWithABool(
"/control/useDoublePrecision",
this);
126 "Use double precision for printing out the current parameter value(s).");
131 historyCommand->
SetGuidance(
"Store command history to a file.");
132 historyCommand->
SetGuidance(
"Defaul file name is G4history.macro.");
137 stopStoreHistoryCommand =
139 stopStoreHistoryCommand->
SetGuidance(
"Stop saving history file.");
142 aliasCommand =
new G4UIcommand(
"/control/alias",
this);
144 aliasCommand->
SetGuidance(
"String can be aliased by this command.");
145 aliasCommand->
SetGuidance(
"The string may contain one or more spaces,");
147 "the string must be enclosed by double quotes (\").");
148 aliasCommand->
SetGuidance(
"To use an alias, enclose the alias name with");
149 aliasCommand->
SetGuidance(
"parenthesis \"{\" and \"}\".");
150 auto* aliasNameParam =
new G4UIparameter(
"aliasName",
's',
false);
152 auto* aliasValueParam =
new G4UIparameter(
"aliasValue",
's',
false);
164 "Get a shell environment variable and define it as an alias.");
167 getValCmd =
new G4UIcommand(
"/control/getVal",
this);
169 "Get the current value of the UI command and define it as an alias.");
171 "Command is ignored if the UI command does not support GetCurrentValue().");
172 getValCmd->
SetGuidance(
" Syntax : <alias_name> <UI_command> <iIdx>");
178 iIdxParam->SetDefaultValue(0);
183 echoCmd->
SetGuidance(
"Display the valuerameter string.");
184 echoCmd->
SetGuidance(
"If alias is contained, it is converted to the aliased value.");
187 shellCommand->
SetGuidance(
"Execute a (Unix) SHELL command.");
191 ManualCommand->
SetGuidance(
"Display all of sub-directories and commands.");
192 ManualCommand->
SetGuidance(
"Directory path should be given by FULL-PATH.");
199 "Generate HTML files for all of sub-directories and commands.");
200 HTMLCommand->
SetGuidance(
"Directory path should be given by FULL-PATH.");
205 maxStoredHistCommand =
208 "Set maximum number of stored UI commands.");
213 ifCommand->
SetGuidance(
"Execute a macro file if the expression is true.");
214 ifCommand->
SetGuidance(
" Syntax : <double> <comp> <double> <macro_file>");
218 compParam->SetParameterCandidates(
"> >= < <= == !=");
222 auto* macroFileParam =
new G4UIparameter(
"macroFile",
's',
false);
226 doifCommand =
new G4UIcommand(
"/control/doif",
this);
227 doifCommand->
SetGuidance(
"Execute a UI command if the expression is true.");
228 doifCommand->
SetGuidance(
" Syntax : <double> <comp> <double> <UI_command>");
232 docompParam->SetParameterCandidates(
"> >= < <= == !=");
236 auto* comParam =
new G4UIparameter(
"UI_command",
's',
false);
240 addCommand =
new G4UIcommand(
"/control/add",
this);
241 addCommand->
SetGuidance(
"Define a new alias as the sum of two values.");
242 addCommand->
SetGuidance(
" Syntax : <new_alias> <value1> <value2>");
244 " <new_alias> may be an already existing alias. If it is the case,");
245 addCommand->
SetGuidance(
" aliased value is alternated.");
246 auto* newAlias1 =
new G4UIparameter(
"new_alias",
's',
false);
254 subtractCommand =
new G4UIcommand(
"/control/subtract",
this);
256 "Define a new alias as the subtraction of two values.");
257 subtractCommand->
SetGuidance(
" Syntax : <new_alias> <value1> <value2>");
259 " <new_alias> may be an already existing alias. If it is the case,");
260 subtractCommand->
SetGuidance(
" aliased value is alternated.");
261 auto* newAlias2 =
new G4UIparameter(
"new_alias",
's',
false);
269 multiplyCommand =
new G4UIcommand(
"/control/multiply",
this);
271 "Define a new alias as the multiplication of two values.");
272 multiplyCommand->
SetGuidance(
" Syntax : <new_alias> <value1> <value2>");
274 " <new_alias> may be an already existing alias. If it is the case,");
275 multiplyCommand->
SetGuidance(
" aliased value is alternated.");
276 auto* newAlias3 =
new G4UIparameter(
"new_alias",
's',
false);
284 divideCommand =
new G4UIcommand(
"/control/divide",
this);
286 "Define a new alias as the division of two values.");
287 divideCommand->
SetGuidance(
" Syntax : <new_alias> <value1> <value2>");
289 " <new_alias> may be an already existing alias. If it is the case,");
290 divideCommand->
SetGuidance(
" aliased value is alternated.");
291 auto* newAlias4 =
new G4UIparameter(
"new_alias",
's',
false);
296 val4b->SetParameterRange(
"value2 != 0.");
300 remainderCommand =
new G4UIcommand(
"/control/remainder",
this);
302 "Define a new alias as the remainder of two values.");
303 remainderCommand->
SetGuidance(
" Syntax : <new_alias> <value1> <value2>");
305 " <new_alias> may be an already existing alias. If it is the case,");
306 remainderCommand->
SetGuidance(
" aliased value is alternated.");
307 auto* newAlias5 =
new G4UIparameter(
"new_alias",
's',
false);
312 val4b->SetParameterRange(
"value2 != 0");
316 strifCommand =
new G4UIcommand(
"/control/strif",
this);
317 strifCommand->
SetGuidance(
"Execute a macro file if the expression is true.");
318 strifCommand->
SetGuidance(
" Syntax : <string> <comp> <string> <macro_file>");
322 strcompParam->SetParameterCandidates(
"== !=");
324 auto* strrightParam =
new G4UIparameter(
"right",
's',
false);
326 auto* strmacroFileParam =
new G4UIparameter(
"macroFile",
's',
false);
330 strdoifCommand =
new G4UIcommand(
"/control/strdoif",
this);
332 "Execute a UI command if the expression is true.");
334 " Syntax : <string> <comp> <string> <UI_command>");
335 auto* strdoleftParam =
new G4UIparameter(
"left",
's',
false);
337 auto* strdocompParam =
new G4UIparameter(
"comp",
's',
false);
338 strdocompParam->SetParameterCandidates(
"== !=");
340 auto* strdorightParam =
new G4UIparameter(
"right",
's',
false);
342 auto* strdomacroFileParam =
new G4UIparameter(
"UI_command",
's',
false);
348 "Execute a macro file if program is running in batch mode.");
354 "Execute a macro file if program is running in interactive mode.");
360 "Execute a UI command if program is running in batch mode.");
364 doifInteractiveCommand =
367 "Execute a UI command if program is running in interactive mode.");
375 delete macroPathCommand;
376 delete ExecuteCommand;
377 delete suppressAbortionCommand;
378 delete verboseCommand;
379 delete doublePrecCommand;
380 delete historyCommand;
381 delete stopStoreHistoryCommand;
382 delete ManualCommand;
384 delete unaliasCommand;
385 delete listAliasCommand;
391 delete foreachCommand;
393 delete maxStoredHistCommand;
397 delete subtractCommand;
398 delete multiplyCommand;
399 delete divideCommand;
400 delete remainderCommand;
402 delete strdoifCommand;
403 delete ifBatchCommand;
404 delete ifInteractiveCommand;
405 delete doifBatchCommand;
406 delete doifInteractiveCommand;
407 delete controlDirectory;
415 if(command == macroPathCommand)
420 if(command == ExecuteCommand)
431 if(command == suppressAbortionCommand)
436 if(command == verboseCommand)
440 if(command == doublePrecCommand)
445 if(command == historyCommand)
449 if(command == stopStoreHistoryCommand)
453 if(command == ManualCommand)
457 if(command == aliasCommand)
461 if(command == unaliasCommand)
465 if(command == listAliasCommand)
469 if(command == getEnvCmd)
472 if(std::getenv(newValue) !=
nullptr)
476 st += std::getenv(newValue);
482 ed <<
"<" << newValue
483 <<
"> is not defined as a shell variable. Command ignored.";
487 if(command == getValCmd)
493 if(!(curVal.empty()))
501 for(
G4int i = 0; i <= idx; i++)
503 theValue = nextVal();
507 st += aliName +
" " + theValue;
511 if(command == echoCmd)
515 if(command == shellCommand)
518 int rc = system(newValue);
522 ed <<
"<" << newValue
523 <<
"> is not a valid shell command. Command ignored.";
527 if(command == loopCommand)
538 if(command == foreachCommand)
549 if(command == HTMLCommand)
553 if(command == maxStoredHistCommand)
557 if(command == ifCommand)
569 else if(comp ==
">=")
577 else if(comp ==
"<=")
581 else if(comp ==
"==")
585 else if(comp ==
"!=")
594 if(command == doifCommand)
603 while(!((ca = next()).empty()))
613 strippedValue = c1.substr(1, c1.length() - 2);
617 strippedValue = c1.substr(1, c1.length() - 1);
627 else if(comp ==
">=")
635 else if(comp ==
"<=")
639 else if(comp ==
"==")
643 else if(comp ==
"!=")
652 if(command == addCommand)
664 if(command == subtractCommand)
676 if(command == multiplyCommand)
688 if(command == divideCommand)
700 if(command == remainderCommand)
712 if(command == strifCommand)
724 else if(comp ==
"!=")
733 if(command == strdoifCommand)
742 while(!((ca = next()).empty()))
752 strippedValue = c1.substr(1, c1.length() - 2);
756 strippedValue = c1.substr(1, c1.length() - 1);
766 else if(comp ==
"!=")
775 if(command == ifBatchCommand)
782 if(command == ifInteractiveCommand)
789 if(command == doifBatchCommand)
796 if(command == doifInteractiveCommand)
811 if(command == macroPathCommand)
815 if(command == verboseCommand)
819 if(command == doublePrecCommand)
824 if(command == suppressAbortionCommand)
829 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)