#include <G4UIcontrolMessenger.hh>
Inheritance diagram for G4UIcontrolMessenger:
Public Member Functions | |
G4UIcontrolMessenger () | |
~G4UIcontrolMessenger () | |
void | SetNewValue (G4UIcommand *command, G4String newValue) |
G4String | GetCurrentValue (G4UIcommand *command) |
Definition at line 69 of file G4UIcontrolMessenger.hh.
G4UIcontrolMessenger::G4UIcontrolMessenger | ( | ) |
Definition at line 45 of file G4UIcontrolMessenger.cc.
References G4UIcmdWithAString::SetDefaultValue(), G4UIcmdWithAnInteger::SetDefaultValue(), G4UIparameter::SetDefaultValue(), G4UIcommand::SetGuidance(), G4UIcommand::SetParameter(), G4UIparameter::SetParameterCandidates(), G4UIcmdWithAnInteger::SetParameterName(), G4UIcmdWithAString::SetParameterName(), G4UIparameter::SetParameterRange(), and G4UIcommand::SetRange().
00046 { 00047 controlDirectory = new G4UIdirectory("/control/"); 00048 controlDirectory->SetGuidance("UI control commands."); 00049 00050 macroPathCommand = new G4UIcmdWithAString("/control/macroPath",this); 00051 macroPathCommand->SetGuidance("Set macro search path" 00052 "with colon-separated list."); 00053 macroPathCommand->SetParameterName("path",false); 00054 00055 ExecuteCommand = new G4UIcmdWithAString("/control/execute",this); 00056 ExecuteCommand->SetGuidance("Execute a macro file."); 00057 ExecuteCommand->SetParameterName("fileName",false); 00058 00059 loopCommand = new G4UIcommand("/control/loop",this); 00060 loopCommand->SetGuidance("Execute a macro file more than once."); 00061 loopCommand->SetGuidance("Loop counter can be used as an aliased variable."); 00062 G4UIparameter* param1 = new G4UIparameter("macroFile",'s',false); 00063 loopCommand->SetParameter(param1); 00064 G4UIparameter* param2 = new G4UIparameter("counterName",'s',false); 00065 loopCommand->SetParameter(param2); 00066 G4UIparameter* param3 = new G4UIparameter("initialValue",'d',false); 00067 loopCommand->SetParameter(param3); 00068 G4UIparameter* param4 = new G4UIparameter("finalValue",'d',false); 00069 loopCommand->SetParameter(param4); 00070 G4UIparameter* param5 = new G4UIparameter("stepSize",'d',true); 00071 param5->SetDefaultValue(1.0); 00072 loopCommand->SetParameter(param5); 00073 00074 foreachCommand = new G4UIcommand("/control/foreach",this); 00075 foreachCommand->SetGuidance("Execute a macro file more than once."); 00076 foreachCommand->SetGuidance("Loop counter can be used as an aliased variable."); 00077 foreachCommand->SetGuidance("Values must be separated by a space."); 00078 G4UIparameter* param6 = new G4UIparameter("macroFile",'s',false); 00079 foreachCommand->SetParameter(param6); 00080 G4UIparameter* param7 = new G4UIparameter("counterName",'s',false); 00081 foreachCommand->SetParameter(param7); 00082 G4UIparameter* param8 = new G4UIparameter("valueList",'s',false); 00083 foreachCommand->SetParameter(param8); 00084 00085 suppressAbortionCommand = new G4UIcmdWithAnInteger("/control/suppressAbortion",this); 00086 suppressAbortionCommand->SetGuidance("Suppress the program abortion caused by G4Exception."); 00087 suppressAbortionCommand->SetGuidance("Suppression level = 0 : no suppression"); 00088 suppressAbortionCommand->SetGuidance(" = 1 : suppress during EventProc state"); 00089 suppressAbortionCommand->SetGuidance(" = 2 : full suppression, i.e. no abortion by G4Exception"); 00090 suppressAbortionCommand->SetGuidance("When abortion is suppressed, you will get error messages issued by G4Exception,"); 00091 suppressAbortionCommand->SetGuidance("and there is NO guarantee for the correct result after the G4Exception error message."); 00092 suppressAbortionCommand->SetParameterName("level",true); 00093 suppressAbortionCommand->SetRange("level >= 0 && level <= 2"); 00094 suppressAbortionCommand->SetDefaultValue(0); 00095 00096 verboseCommand = new G4UIcmdWithAnInteger("/control/verbose",this); 00097 verboseCommand->SetGuidance("Applied command will also be shown on screen."); 00098 verboseCommand->SetGuidance("This command is useful with MACRO file."); 00099 verboseCommand->SetGuidance(" 0 : silent"); 00100 verboseCommand->SetGuidance(" 1 : only the valid commands are shown."); 00101 verboseCommand->SetGuidance(" 2 : comment lines are also shown (default)."); 00102 verboseCommand->SetParameterName("switch",true); 00103 verboseCommand->SetRange("switch >= 0 && switch <=2"); 00104 verboseCommand->SetDefaultValue(2); 00105 00106 historyCommand = new G4UIcmdWithAString("/control/saveHistory",this); 00107 historyCommand->SetGuidance("Store command history to a file."); 00108 historyCommand->SetGuidance("Defaul file name is G4history.macro."); 00109 historyCommand->SetParameterName("fileName",true); 00110 historyCommand->SetDefaultValue("G4History.macro"); 00111 00112 stopStoreHistoryCommand 00113 = new G4UIcmdWithoutParameter("/control/stopSavingHistory",this); 00114 stopStoreHistoryCommand->SetGuidance("Stop saving history file."); 00115 00116 aliasCommand = new G4UIcommand("/control/alias",this); 00117 aliasCommand->SetGuidance("Set an alias."); 00118 aliasCommand->SetGuidance("String can be aliased by this command."); 00119 aliasCommand->SetGuidance("The string may contain one or more spaces,"); 00120 aliasCommand->SetGuidance("the string must be enclosed by double quotes (\")."); 00121 aliasCommand->SetGuidance("To use an alias, enclose the alias name with"); 00122 aliasCommand->SetGuidance("parenthis \"{\" and \"}\"."); 00123 G4UIparameter* aliasNameParam = new G4UIparameter("aliasName",'s',false); 00124 aliasCommand->SetParameter(aliasNameParam); 00125 G4UIparameter* aliasValueParam = new G4UIparameter("aliasValue",'s',false); 00126 aliasCommand->SetParameter(aliasValueParam); 00127 00128 unaliasCommand = new G4UIcmdWithAString("/control/unalias",this); 00129 unaliasCommand->SetGuidance("Remove an alias."); 00130 unaliasCommand->SetParameterName("aliasName",false); 00131 00132 listAliasCommand = new G4UIcmdWithoutParameter("/control/listAlias",this); 00133 listAliasCommand->SetGuidance("List aliases."); 00134 00135 getEnvCmd = new G4UIcmdWithAString("/control/getEnv",this); 00136 getEnvCmd->SetGuidance("Get a shell environment variable and define it as an alias."); 00137 00138 echoCmd = new G4UIcmdWithAString("/control/echo",this); 00139 echoCmd->SetGuidance("Display the aliased value."); 00140 00141 shellCommand = new G4UIcmdWithAString("/control/shell",this); 00142 shellCommand->SetGuidance("Execute a (Unix) SHELL command."); 00143 00144 ManualCommand = new G4UIcmdWithAString("/control/manual",this); 00145 ManualCommand->SetGuidance("Display all of sub-directories and commands."); 00146 ManualCommand->SetGuidance("Directory path should be given by FULL-PATH."); 00147 ManualCommand->SetParameterName("dirPath",true); 00148 ManualCommand->SetDefaultValue("/"); 00149 00150 HTMLCommand = new G4UIcmdWithAString("/control/createHTML",this); 00151 HTMLCommand->SetGuidance("Generate HTML files for all of sub-directories and commands."); 00152 HTMLCommand->SetGuidance("Directory path should be given by FULL-PATH."); 00153 HTMLCommand->SetParameterName("dirPath",true); 00154 HTMLCommand->SetDefaultValue("/"); 00155 00156 maxStoredHistCommand = new G4UIcmdWithAnInteger("/control/maximumStoredHistory",this); 00157 maxStoredHistCommand->SetGuidance("Set maximum number of stored UI commands."); 00158 maxStoredHistCommand->SetParameterName("max",true); 00159 maxStoredHistCommand->SetDefaultValue(20); 00160 00161 ifCommand = new G4UIcommand("/control/if",this); 00162 ifCommand->SetGuidance("Execute a macro file if the expression is true."); 00163 ifCommand->SetGuidance(" Syntax : <double> <comp> <double> <macro_file>"); 00164 G4UIparameter* leftParam = new G4UIparameter("left",'d',false); 00165 ifCommand->SetParameter(leftParam); 00166 G4UIparameter* compParam = new G4UIparameter("comp",'s',false); 00167 compParam->SetParameterCandidates("> >= < <= == !="); 00168 ifCommand->SetParameter(compParam); 00169 G4UIparameter* rightParam = new G4UIparameter("right",'d',false); 00170 ifCommand->SetParameter(rightParam); 00171 G4UIparameter* macroFileParam = new G4UIparameter("aliasValue",'s',false); 00172 ifCommand->SetParameter(macroFileParam); 00173 00174 addCommand = new G4UIcommand("/control/add",this); 00175 addCommand->SetGuidance("Define a new alias as the sum of two values."); 00176 addCommand->SetGuidance(" Syntax : <new_alias> <value1> <value2>"); 00177 addCommand->SetGuidance(" <new_alias> may be an already existing alias. If it is the case,"); 00178 addCommand->SetGuidance(" aliased value is alternated."); 00179 G4UIparameter* newAlias1 = new G4UIparameter("new_alias",'s',false); 00180 addCommand->SetParameter(newAlias1); 00181 G4UIparameter* val1a = new G4UIparameter("value1",'d',false); 00182 addCommand->SetParameter(val1a); 00183 G4UIparameter* val1b = new G4UIparameter("value2",'d',false); 00184 addCommand->SetParameter(val1b); 00185 00186 subtractCommand = new G4UIcommand("/control/subtract",this); 00187 subtractCommand->SetGuidance("Define a new alias as the subtraction of two values."); 00188 subtractCommand->SetGuidance(" Syntax : <new_alias> <value1> <value2>"); 00189 subtractCommand->SetGuidance(" <new_alias> may be an already existing alias. If it is the case,"); 00190 subtractCommand->SetGuidance(" aliased value is alternated."); 00191 G4UIparameter* newAlias2 = new G4UIparameter("new_alias",'s',false); 00192 subtractCommand->SetParameter(newAlias2); 00193 G4UIparameter* val2a = new G4UIparameter("value1",'d',false); 00194 subtractCommand->SetParameter(val2a); 00195 G4UIparameter* val2b = new G4UIparameter("value2",'d',false); 00196 subtractCommand->SetParameter(val2b); 00197 00198 multiplyCommand = new G4UIcommand("/control/multiply",this); 00199 multiplyCommand->SetGuidance("Define a new alias as the multiplification of two values."); 00200 multiplyCommand->SetGuidance(" Syntax : <new_alias> <value1> <value2>"); 00201 multiplyCommand->SetGuidance(" <new_alias> may be an already existing alias. If it is the case,"); 00202 multiplyCommand->SetGuidance(" aliased value is alternated."); 00203 G4UIparameter* newAlias3 = new G4UIparameter("new_alias",'s',false); 00204 multiplyCommand->SetParameter(newAlias3); 00205 G4UIparameter* val3a = new G4UIparameter("value1",'d',false); 00206 multiplyCommand->SetParameter(val3a); 00207 G4UIparameter* val3b = new G4UIparameter("value2",'d',false); 00208 multiplyCommand->SetParameter(val3b); 00209 00210 divideCommand = new G4UIcommand("/control/divide",this); 00211 divideCommand->SetGuidance("Define a new alias as the division of two values."); 00212 divideCommand->SetGuidance(" Syntax : <new_alias> <value1> <value2>"); 00213 divideCommand->SetGuidance(" <new_alias> may be an already existing alias. If it is the case,"); 00214 divideCommand->SetGuidance(" aliased value is alternated."); 00215 G4UIparameter* newAlias4 = new G4UIparameter("new_alias",'s',false); 00216 divideCommand->SetParameter(newAlias4); 00217 G4UIparameter* val4a = new G4UIparameter("value1",'d',false); 00218 divideCommand->SetParameter(val4a); 00219 G4UIparameter* val4b = new G4UIparameter("value2",'d',false); 00220 val4b->SetParameterRange("value2 != 0."); 00221 divideCommand->SetParameter(val4b); 00222 00223 remainderCommand = new G4UIcommand("/control/remainder",this); 00224 remainderCommand->SetGuidance("Define a new alias as the remainder of two values."); 00225 remainderCommand->SetGuidance(" Syntax : <new_alias> <value1> <value2>"); 00226 remainderCommand->SetGuidance(" <new_alias> may be an already existing alias. If it is the case,"); 00227 remainderCommand->SetGuidance(" aliased value is alternated."); 00228 G4UIparameter* newAlias5 = new G4UIparameter("new_alias",'s',false); 00229 remainderCommand->SetParameter(newAlias5); 00230 G4UIparameter* val5a = new G4UIparameter("value1",'i',false); 00231 remainderCommand->SetParameter(val5a); 00232 G4UIparameter* val5b = new G4UIparameter("value2",'i',false); 00233 val4b->SetParameterRange("value2 != 0"); 00234 remainderCommand->SetParameter(val5b); 00235 00236 }
G4UIcontrolMessenger::~G4UIcontrolMessenger | ( | ) |
Definition at line 238 of file G4UIcontrolMessenger.cc.
00239 { 00240 delete macroPathCommand; 00241 delete ExecuteCommand; 00242 delete suppressAbortionCommand; 00243 delete verboseCommand; 00244 delete historyCommand; 00245 delete stopStoreHistoryCommand; 00246 delete ManualCommand; 00247 delete aliasCommand; 00248 delete unaliasCommand; 00249 delete listAliasCommand; 00250 delete getEnvCmd; 00251 delete echoCmd; 00252 delete shellCommand; 00253 delete loopCommand; 00254 delete foreachCommand; 00255 delete HTMLCommand; 00256 delete maxStoredHistCommand; 00257 delete ifCommand; 00258 delete addCommand; 00259 delete subtractCommand; 00260 delete multiplyCommand; 00261 delete divideCommand; 00262 delete remainderCommand; 00263 00264 delete controlDirectory; 00265 }
G4String G4UIcontrolMessenger::GetCurrentValue | ( | G4UIcommand * | command | ) | [virtual] |
Reimplemented from G4UImessenger.
Definition at line 424 of file G4UIcontrolMessenger.cc.
References G4UIcommand::ConvertToString(), G4UImanager::GetMaxHistSize(), G4StateManager::GetStateManager(), G4UImanager::GetUIpointer(), and G4UImanager::GetVerboseLevel().
00425 { 00426 G4UImanager * UI = G4UImanager::GetUIpointer(); 00427 G4String currentValue; 00428 00429 if( command == macroPathCommand ) { 00430 currentValue = UI-> GetMacroSearchPath(); 00431 } 00432 if(command==verboseCommand) 00433 { 00434 currentValue = verboseCommand->ConvertToString(UI->GetVerboseLevel()); 00435 } 00436 if(command==suppressAbortionCommand) 00437 { 00438 currentValue = suppressAbortionCommand->ConvertToString(G4StateManager::GetStateManager()->GetSuppressAbortion()); 00439 } 00440 if(command==maxStoredHistCommand) 00441 { 00442 currentValue = maxStoredHistCommand->ConvertToString(UI->GetMaxHistSize()); 00443 } 00444 00445 return currentValue; 00446 }
void G4UIcontrolMessenger::SetNewValue | ( | G4UIcommand * | command, | |
G4String | newValue | |||
) | [virtual] |
Reimplemented from G4UImessenger.
Definition at line 267 of file G4UIcontrolMessenger.cc.
References G4UImanager::ApplyCommand(), G4UImanager::CreateHTML(), G4UImessenger::DtoS(), G4UImanager::ExecuteMacroFile(), G4UImanager::ForeachS(), G4cerr, G4cout, G4endl, G4UIcmdWithAnInteger::GetNewIntValue(), G4StateManager::GetStateManager(), G4UImanager::GetUIpointer(), G4UImanager::ListAlias(), G4UImanager::ListCommands(), G4UImanager::LoopS(), G4UImanager::RemoveAlias(), G4UImanager::SetAlias(), G4UImanager::SetMaxHistSize(), G4StateManager::SetSuppressAbortion(), G4UImanager::SetVerboseLevel(), G4UImanager::SolveAlias(), G4UImessenger::StoD(), G4UImessenger::StoI(), and G4UImanager::StoreHistory().
00268 { 00269 G4UImanager * UI = G4UImanager::GetUIpointer(); 00270 00271 if( command == macroPathCommand) { 00272 UI-> SetMacroSearchPath(newValue); 00273 UI-> ParseMacroSearchPath(); 00274 } 00275 if(command==ExecuteCommand) 00276 { 00277 UI-> ExecuteMacroFile(UI-> FindMacroPath(newValue)); 00278 } 00279 if(command==suppressAbortionCommand) 00280 { 00281 G4StateManager::GetStateManager()->SetSuppressAbortion(suppressAbortionCommand->GetNewIntValue(newValue)); 00282 } 00283 if(command==verboseCommand) 00284 { 00285 UI->SetVerboseLevel(verboseCommand->GetNewIntValue(newValue)); 00286 } 00287 if(command==historyCommand) 00288 { 00289 UI->StoreHistory(newValue); 00290 } 00291 if(command==stopStoreHistoryCommand) 00292 { 00293 UI->StoreHistory(false); 00294 } 00295 if(command==ManualCommand) 00296 { 00297 UI->ListCommands(newValue); 00298 } 00299 if(command==aliasCommand) 00300 { 00301 UI->SetAlias(newValue); 00302 } 00303 if(command==unaliasCommand) 00304 { 00305 UI->RemoveAlias(newValue); 00306 } 00307 if(command==listAliasCommand) 00308 { 00309 UI->ListAlias(); 00310 } 00311 if(command==getEnvCmd) 00312 { 00313 if(getenv(newValue)) 00314 { 00315 G4String st = "/control/alias "; 00316 st += newValue; 00317 st += " "; 00318 st += getenv(newValue); 00319 UI->ApplyCommand(st); 00320 } 00321 else 00322 { G4cerr << "<" << newValue << "> is not defined as a shell variable. Command ignored." << G4endl; } 00323 } 00324 if(command==echoCmd) 00325 { G4cout << UI->SolveAlias(newValue) << G4endl; } 00326 if(command==shellCommand) 00327 { 00328 system(newValue); 00329 } 00330 if(command==loopCommand) 00331 { 00332 UI->LoopS(newValue); 00333 } 00334 if(command==foreachCommand) 00335 { 00336 UI->ForeachS(newValue); 00337 } 00338 if(command==HTMLCommand) 00339 { 00340 UI->CreateHTML(newValue); 00341 } 00342 if(command==maxStoredHistCommand) 00343 { 00344 UI->SetMaxHistSize(maxStoredHistCommand->GetNewIntValue(newValue)); 00345 } 00346 if(command==ifCommand) 00347 { 00348 G4Tokenizer next(newValue); 00349 G4double l = StoD(next()); 00350 G4String comp = next(); 00351 G4double r = StoD(next()); 00352 G4String mac = next(); 00353 G4bool x = false; 00354 if(comp==">") x = (l>r); 00355 else if(comp==">=") x = (l>=r); 00356 else if(comp=="<") x = (l<r); 00357 else if(comp=="<=") x = (l<=r); 00358 else if(comp=="==") x = (l==r); 00359 else if(comp=="!=") x = (l!=r); 00360 if(x) UI->ExecuteMacroFile(mac); 00361 } 00362 if(command==addCommand) 00363 { 00364 G4Tokenizer next(newValue); 00365 G4String newA = next(); 00366 G4double l = StoD(next()); 00367 G4double r = StoD(next()); 00368 G4String st = "/control/alias "; 00369 st += newA; 00370 st += " "; 00371 st += DtoS(l+r); 00372 UI->ApplyCommand(st); 00373 } 00374 if(command==subtractCommand) 00375 { 00376 G4Tokenizer next(newValue); 00377 G4String newA = next(); 00378 G4double l = StoD(next()); 00379 G4double r = StoD(next()); 00380 G4String st = "/control/alias "; 00381 st += newA; 00382 st += " "; 00383 st += DtoS(l-r); 00384 UI->ApplyCommand(st); 00385 } 00386 if(command==multiplyCommand) 00387 { 00388 G4Tokenizer next(newValue); 00389 G4String newA = next(); 00390 G4double l = StoD(next()); 00391 G4double r = StoD(next()); 00392 G4String st = "/control/alias "; 00393 st += newA; 00394 st += " "; 00395 st += DtoS(l*r); 00396 UI->ApplyCommand(st); 00397 } 00398 if(command==divideCommand) 00399 { 00400 G4Tokenizer next(newValue); 00401 G4String newA = next(); 00402 G4double l = StoD(next()); 00403 G4double r = StoD(next()); 00404 G4String st = "/control/alias "; 00405 st += newA; 00406 st += " "; 00407 st += DtoS(l/r); 00408 UI->ApplyCommand(st); 00409 } 00410 if(command==remainderCommand) 00411 { 00412 G4Tokenizer next(newValue); 00413 G4String newA = next(); 00414 G4int l = StoI(next()); 00415 G4int r = StoI(next()); 00416 G4String st = "/control/alias "; 00417 st += newA; 00418 st += " "; 00419 st += DtoS(l%r); 00420 UI->ApplyCommand(st); 00421 } 00422 }