Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 // G4UIcontrolMessenger << 27 // 26 // 28 // Author: Makoto Asai, SLAC - 2001 << 27 // 29 // ------------------------------------------- << 30 28 >> 29 #include <stdlib.h> 31 #include "G4UIcontrolMessenger.hh" 30 #include "G4UIcontrolMessenger.hh" 32 << 31 #include "G4UImanager.hh" 33 #include "G4StateManager.hh" << 32 #include "G4UIdirectory.hh" 34 #include "G4Tokenizer.hh" << 33 #include "G4UIcommand.hh" 35 #include "G4UIaliasList.hh" << 34 #include "G4UIparameter.hh" 36 #include "G4UIcmdWithABool.hh" << 37 #include "G4UIcmdWithAString.hh" 35 #include "G4UIcmdWithAString.hh" >> 36 #include "G4UIcmdWithABool.hh" 38 #include "G4UIcmdWithAnInteger.hh" 37 #include "G4UIcmdWithAnInteger.hh" 39 #include "G4UIcmdWithoutParameter.hh" 38 #include "G4UIcmdWithoutParameter.hh" 40 #include "G4UIcommand.hh" << 39 #include "G4UIaliasList.hh" 41 #include "G4UIdirectory.hh" << 40 #include "G4StateManager.hh" 42 #include "G4UImanager.hh" << 43 #include "G4UIparameter.hh" << 44 #include "G4UIsession.hh" 41 #include "G4UIsession.hh" 45 #include "G4ios.hh" << 42 #include "G4Tokenizer.hh" 46 43 47 #include <cstdlib> << 44 #include "G4ios.hh" 48 45 49 // ------------------------------------------- << 50 G4UIcontrolMessenger::G4UIcontrolMessenger() 46 G4UIcontrolMessenger::G4UIcontrolMessenger() 51 { 47 { 52 controlDirectory = new G4UIdirectory("/contr 48 controlDirectory = new G4UIdirectory("/control/"); 53 controlDirectory->SetGuidance("UI control co 49 controlDirectory->SetGuidance("UI control commands."); 54 50 55 macroPathCommand = new G4UIcmdWithAString("/ << 51 macroPathCommand = new G4UIcmdWithAString("/control/macroPath",this); 56 macroPathCommand->SetGuidance( << 52 macroPathCommand->SetGuidance("Set macro search path" 57 "Set macro search path" << 53 " with colon-separated list."); 58 " with colon-separated list."); << 54 macroPathCommand->SetParameterName("path",false); 59 macroPathCommand->SetParameterName("path", f << 60 55 61 ExecuteCommand = new G4UIcmdWithAString("/co << 56 ExecuteCommand = new G4UIcmdWithAString("/control/execute",this); 62 ExecuteCommand->SetGuidance("Execute a macro 57 ExecuteCommand->SetGuidance("Execute a macro file."); 63 ExecuteCommand->SetParameterName("fileName", << 58 ExecuteCommand->SetParameterName("fileName",false); 64 ExecuteCommand->SetToBeBroadcasted(false); 59 ExecuteCommand->SetToBeBroadcasted(false); 65 60 66 loopCommand = new G4UIcommand("/control/loop << 61 loopCommand = new G4UIcommand("/control/loop",this); 67 loopCommand->SetGuidance("Execute a macro fi 62 loopCommand->SetGuidance("Execute a macro file more than once."); 68 loopCommand->SetGuidance("Loop counter can b 63 loopCommand->SetGuidance("Loop counter can be used as an aliased variable."); 69 auto* param1 = new G4UIparameter("macroFile" << 64 G4UIparameter* param1 = new G4UIparameter("macroFile",'s',false); 70 loopCommand->SetParameter(param1); 65 loopCommand->SetParameter(param1); 71 auto* param2 = new G4UIparameter("counterNam << 66 G4UIparameter* param2 = new G4UIparameter("counterName",'s',false); 72 loopCommand->SetParameter(param2); 67 loopCommand->SetParameter(param2); 73 auto* param3 = new G4UIparameter("initialVal << 68 G4UIparameter* param3 = new G4UIparameter("initialValue",'d',false); 74 loopCommand->SetParameter(param3); 69 loopCommand->SetParameter(param3); 75 auto* param4 = new G4UIparameter("finalValue << 70 G4UIparameter* param4 = new G4UIparameter("finalValue",'d',false); 76 loopCommand->SetParameter(param4); 71 loopCommand->SetParameter(param4); 77 auto* param5 = new G4UIparameter("stepSize", << 72 G4UIparameter* param5 = new G4UIparameter("stepSize",'d',true); 78 param5->SetDefaultValue(1.0); 73 param5->SetDefaultValue(1.0); 79 loopCommand->SetParameter(param5); 74 loopCommand->SetParameter(param5); 80 loopCommand->SetToBeBroadcasted(false); 75 loopCommand->SetToBeBroadcasted(false); 81 76 82 foreachCommand = new G4UIcommand("/control/f << 77 foreachCommand = new G4UIcommand("/control/foreach",this); 83 foreachCommand->SetGuidance("Execute a macro 78 foreachCommand->SetGuidance("Execute a macro file more than once."); 84 foreachCommand->SetGuidance("Loop counter ca 79 foreachCommand->SetGuidance("Loop counter can be used as an aliased variable."); 85 foreachCommand->SetGuidance("Values must be 80 foreachCommand->SetGuidance("Values must be separated by a space."); 86 auto* param6 = new G4UIparameter("macroFile" << 81 G4UIparameter* param6 = new G4UIparameter("macroFile",'s',false); 87 foreachCommand->SetParameter(param6); 82 foreachCommand->SetParameter(param6); 88 auto* param7 = new G4UIparameter("counterNam << 83 G4UIparameter* param7 = new G4UIparameter("counterName",'s',false); 89 foreachCommand->SetParameter(param7); 84 foreachCommand->SetParameter(param7); 90 auto* param8 = new G4UIparameter("valueList" << 85 G4UIparameter* param8 = new G4UIparameter("valueList",'s',false); 91 foreachCommand->SetParameter(param8); 86 foreachCommand->SetParameter(param8); 92 foreachCommand->SetToBeBroadcasted(false); 87 foreachCommand->SetToBeBroadcasted(false); 93 << 88 94 suppressAbortionCommand = new G4UIcmdWithAnI << 89 suppressAbortionCommand = new G4UIcmdWithAnInteger("/control/suppressAbortion",this); 95 suppressAbortionCommand->SetGuidance("Suppre 90 suppressAbortionCommand->SetGuidance("Suppress the program abortion caused by G4Exception."); 96 suppressAbortionCommand->SetGuidance("Suppre 91 suppressAbortionCommand->SetGuidance("Suppression level = 0 : no suppression"); 97 suppressAbortionCommand->SetGuidance(" 92 suppressAbortionCommand->SetGuidance(" = 1 : suppress during EventProc state"); 98 suppressAbortionCommand->SetGuidance( << 93 suppressAbortionCommand->SetGuidance(" = 2 : full suppression, i.e. no abortion by G4Exception"); 99 " = 2 : full suppression, << 94 suppressAbortionCommand->SetGuidance("When abortion is suppressed, you will get error messages issued by G4Exception,"); 100 "G4Exception"); << 95 suppressAbortionCommand->SetGuidance("and there is NO guarantee for the correct result after the G4Exception error message."); 101 suppressAbortionCommand->SetGuidance( << 96 suppressAbortionCommand->SetParameterName("level",true); 102 "When abortion is suppressed, you will get << 103 "G4Exception,"); << 104 suppressAbortionCommand->SetGuidance( << 105 "and there is NO guarantee for the correct << 106 "error message."); << 107 suppressAbortionCommand->SetParameterName("l << 108 suppressAbortionCommand->SetRange("level >= 97 suppressAbortionCommand->SetRange("level >= 0 && level <= 2"); 109 suppressAbortionCommand->SetDefaultValue(0); 98 suppressAbortionCommand->SetDefaultValue(0); 110 99 111 verboseCommand = new G4UIcmdWithAnInteger("/ << 100 verboseCommand = new G4UIcmdWithAnInteger("/control/verbose",this); 112 verboseCommand->SetGuidance("Applied command 101 verboseCommand->SetGuidance("Applied command will also be shown on screen."); 113 verboseCommand->SetGuidance("This command is 102 verboseCommand->SetGuidance("This command is useful with MACRO file."); 114 verboseCommand->SetGuidance(" 0 : silent"); 103 verboseCommand->SetGuidance(" 0 : silent"); 115 verboseCommand->SetGuidance(" 1 : only the 104 verboseCommand->SetGuidance(" 1 : only the valid commands are shown."); 116 verboseCommand->SetGuidance(" 2 : comment l 105 verboseCommand->SetGuidance(" 2 : comment lines are also shown (default)."); 117 verboseCommand->SetParameterName("switch", t << 106 verboseCommand->SetParameterName("switch",true); 118 verboseCommand->SetRange("switch >= 0 && swi 107 verboseCommand->SetRange("switch >= 0 && switch <=2"); 119 verboseCommand->SetDefaultValue(2); 108 verboseCommand->SetDefaultValue(2); 120 << 109 121 doublePrecCommand = new G4UIcmdWithABool("/c << 110 doublePrecCommand = new G4UIcmdWithABool("/control/useDoublePrecision",this); 122 doublePrecCommand->SetGuidance( << 111 doublePrecCommand->SetGuidance("Use double precision for printing out the current parameter value(s)."); 123 "Use double precision for printing out the << 112 doublePrecCommand->SetParameterName("useDoublePrecision",true); 124 doublePrecCommand->SetParameterName("useDoub << 125 doublePrecCommand->SetDefaultValue(true); 113 doublePrecCommand->SetDefaultValue(true); 126 114 127 historyCommand = new G4UIcmdWithAString("/co << 115 historyCommand = new G4UIcmdWithAString("/control/saveHistory",this); 128 historyCommand->SetGuidance("Store command h 116 historyCommand->SetGuidance("Store command history to a file."); 129 historyCommand->SetGuidance("Defaul file nam 117 historyCommand->SetGuidance("Defaul file name is G4history.macro."); 130 historyCommand->SetParameterName("fileName", << 118 historyCommand->SetParameterName("fileName",true); 131 historyCommand->SetDefaultValue("G4History.m 119 historyCommand->SetDefaultValue("G4History.macro"); 132 historyCommand->SetToBeBroadcasted(false); << 120 133 << 121 stopStoreHistoryCommand 134 stopStoreHistoryCommand = new G4UIcmdWithout << 122 = new G4UIcmdWithoutParameter("/control/stopSavingHistory",this); 135 stopStoreHistoryCommand->SetGuidance("Stop s 123 stopStoreHistoryCommand->SetGuidance("Stop saving history file."); 136 stopStoreHistoryCommand->SetToBeBroadcasted( << 137 124 138 aliasCommand = new G4UIcommand("/control/ali << 125 aliasCommand = new G4UIcommand("/control/alias",this); 139 aliasCommand->SetGuidance("Set an alias."); 126 aliasCommand->SetGuidance("Set an alias."); 140 aliasCommand->SetGuidance("String can be ali 127 aliasCommand->SetGuidance("String can be aliased by this command."); 141 aliasCommand->SetGuidance("The string may co 128 aliasCommand->SetGuidance("The string may contain one or more spaces,"); 142 aliasCommand->SetGuidance("the string must b 129 aliasCommand->SetGuidance("the string must be enclosed by double quotes (\")."); 143 aliasCommand->SetGuidance("To use an alias, 130 aliasCommand->SetGuidance("To use an alias, enclose the alias name with"); 144 aliasCommand->SetGuidance("parenthesis \"{\" 131 aliasCommand->SetGuidance("parenthesis \"{\" and \"}\"."); 145 auto* aliasNameParam = new G4UIparameter("al << 132 G4UIparameter* aliasNameParam = new G4UIparameter("aliasName",'s',false); 146 aliasCommand->SetParameter(aliasNameParam); 133 aliasCommand->SetParameter(aliasNameParam); 147 auto* aliasValueParam = new G4UIparameter("a << 134 G4UIparameter* aliasValueParam = new G4UIparameter("aliasValue",'s',false); 148 aliasCommand->SetParameter(aliasValueParam); 135 aliasCommand->SetParameter(aliasValueParam); 149 136 150 unaliasCommand = new G4UIcmdWithAString("/co << 137 unaliasCommand = new G4UIcmdWithAString("/control/unalias",this); 151 unaliasCommand->SetGuidance("Remove an alias 138 unaliasCommand->SetGuidance("Remove an alias."); 152 unaliasCommand->SetParameterName("aliasName" << 139 unaliasCommand->SetParameterName("aliasName",false); 153 140 154 listAliasCommand = new G4UIcmdWithoutParamet << 141 listAliasCommand = new G4UIcmdWithoutParameter("/control/listAlias",this); 155 listAliasCommand->SetGuidance("List aliases. 142 listAliasCommand->SetGuidance("List aliases."); 156 143 157 getEnvCmd = new G4UIcmdWithAString("/control << 144 getEnvCmd = new G4UIcmdWithAString("/control/getEnv",this); 158 getEnvCmd->SetGuidance("Get a shell environm 145 getEnvCmd->SetGuidance("Get a shell environment variable and define it as an alias."); 159 getEnvCmd->SetToBeBroadcasted(false); << 160 146 161 getValCmd = new G4UIcommand("/control/getVal << 147 getValCmd = new G4UIcommand("/control/getVal",this); 162 getValCmd->SetGuidance("Get the current valu 148 getValCmd->SetGuidance("Get the current value of the UI command and define it as an alias."); 163 getValCmd->SetGuidance( << 149 getValCmd->SetGuidance("Command is ignored if the UI command does not support GetCurrentValue()."); 164 "Command is ignored if the UI command does << 165 getValCmd->SetGuidance(" Syntax : <alias_nam 150 getValCmd->SetGuidance(" Syntax : <alias_name> <UI_command> <iIdx>"); 166 auto* aliName = new G4UIparameter("alias_nam << 151 G4UIparameter* aliName = new G4UIparameter("alias_name",'s',false); 167 getValCmd->SetParameter(aliName); 152 getValCmd->SetParameter(aliName); 168 auto* comName = new G4UIparameter("UI_comman << 153 G4UIparameter* comName = new G4UIparameter("UI_command",'s',false); 169 getValCmd->SetParameter(comName); 154 getValCmd->SetParameter(comName); 170 auto* iIdxParam = new G4UIparameter("iIdx", << 155 G4UIparameter* iIdxParam = new G4UIparameter("iIdx",'i',true); 171 iIdxParam->SetDefaultValue(0); 156 iIdxParam->SetDefaultValue(0); 172 getValCmd->SetParameter(iIdxParam); 157 getValCmd->SetParameter(iIdxParam); 173 getValCmd->SetToBeBroadcasted(false); << 174 158 175 echoCmd = new G4UIcmdWithAString("/control/e << 159 echoCmd = new G4UIcmdWithAString("/control/echo",this); 176 echoCmd->SetGuidance("Display the valueramet << 160 echoCmd->SetGuidance("Display the aliased value."); 177 echoCmd->SetGuidance("If alias is contained, << 178 161 179 shellCommand = new G4UIcmdWithAString("/cont << 162 shellCommand = new G4UIcmdWithAString("/control/shell",this); 180 shellCommand->SetGuidance("Execute a (Unix) 163 shellCommand->SetGuidance("Execute a (Unix) SHELL command."); 181 shellCommand->SetToBeBroadcasted(false); << 182 164 183 ManualCommand = new G4UIcmdWithAString("/con << 165 ManualCommand = new G4UIcmdWithAString("/control/manual",this); 184 ManualCommand->SetGuidance("Display all of s 166 ManualCommand->SetGuidance("Display all of sub-directories and commands."); 185 ManualCommand->SetGuidance("Directory path s 167 ManualCommand->SetGuidance("Directory path should be given by FULL-PATH."); 186 ManualCommand->SetParameterName("dirPath", t << 168 ManualCommand->SetParameterName("dirPath",true); 187 ManualCommand->SetDefaultValue("/"); 169 ManualCommand->SetDefaultValue("/"); 188 ManualCommand->SetToBeBroadcasted(false); 170 ManualCommand->SetToBeBroadcasted(false); 189 171 190 HTMLCommand = new G4UIcmdWithAString("/contr << 172 HTMLCommand = new G4UIcmdWithAString("/control/createHTML",this); 191 HTMLCommand->SetGuidance("Generate HTML file 173 HTMLCommand->SetGuidance("Generate HTML files for all of sub-directories and commands."); 192 HTMLCommand->SetGuidance("Directory path sho 174 HTMLCommand->SetGuidance("Directory path should be given by FULL-PATH."); 193 HTMLCommand->SetParameterName("dirPath", tru << 175 HTMLCommand->SetParameterName("dirPath",true); 194 HTMLCommand->SetDefaultValue("/"); 176 HTMLCommand->SetDefaultValue("/"); 195 HTMLCommand->SetToBeBroadcasted(false); 177 HTMLCommand->SetToBeBroadcasted(false); 196 178 197 maxStoredHistCommand = new G4UIcmdWithAnInte << 179 maxStoredHistCommand = new G4UIcmdWithAnInteger("/control/maximumStoredHistory",this); 198 maxStoredHistCommand->SetGuidance("Set maxim 180 maxStoredHistCommand->SetGuidance("Set maximum number of stored UI commands."); 199 maxStoredHistCommand->SetParameterName("max" << 181 maxStoredHistCommand->SetParameterName("max",true); 200 maxStoredHistCommand->SetDefaultValue(20); 182 maxStoredHistCommand->SetDefaultValue(20); 201 183 202 ifCommand = new G4UIcommand("/control/if", t << 184 ifCommand = new G4UIcommand("/control/if",this); 203 ifCommand->SetGuidance("Execute a macro file 185 ifCommand->SetGuidance("Execute a macro file if the expression is true."); 204 ifCommand->SetGuidance(" Syntax : <double> < 186 ifCommand->SetGuidance(" Syntax : <double> <comp> <double> <macro_file>"); 205 auto* leftParam = new G4UIparameter("left", << 187 G4UIparameter* leftParam = new G4UIparameter("left",'d',false); 206 ifCommand->SetParameter(leftParam); 188 ifCommand->SetParameter(leftParam); 207 auto* compParam = new G4UIparameter("comp", << 189 G4UIparameter* compParam = new G4UIparameter("comp",'s',false); 208 compParam->SetParameterCandidates("> >= < <= 190 compParam->SetParameterCandidates("> >= < <= == !="); 209 ifCommand->SetParameter(compParam); 191 ifCommand->SetParameter(compParam); 210 auto* rightParam = new G4UIparameter("right" << 192 G4UIparameter* rightParam = new G4UIparameter("right",'d',false); 211 ifCommand->SetParameter(rightParam); 193 ifCommand->SetParameter(rightParam); 212 auto* macroFileParam = new G4UIparameter("ma << 194 G4UIparameter* macroFileParam = new G4UIparameter("macroFile",'s',false); 213 ifCommand->SetParameter(macroFileParam); 195 ifCommand->SetParameter(macroFileParam); 214 ifCommand->SetToBeBroadcasted(false); 196 ifCommand->SetToBeBroadcasted(false); 215 197 216 doifCommand = new G4UIcommand("/control/doif << 198 doifCommand = new G4UIcommand("/control/doif",this); 217 doifCommand->SetGuidance("Execute a UI comma 199 doifCommand->SetGuidance("Execute a UI command if the expression is true."); 218 doifCommand->SetGuidance(" Syntax : <double> 200 doifCommand->SetGuidance(" Syntax : <double> <comp> <double> <UI_command>"); 219 auto* doleftParam = new G4UIparameter("left" << 201 G4UIparameter* doleftParam = new G4UIparameter("left",'d',false); 220 doifCommand->SetParameter(doleftParam); 202 doifCommand->SetParameter(doleftParam); 221 auto* docompParam = new G4UIparameter("comp" << 203 G4UIparameter* docompParam = new G4UIparameter("comp",'s',false); 222 docompParam->SetParameterCandidates("> >= < 204 docompParam->SetParameterCandidates("> >= < <= == !="); 223 doifCommand->SetParameter(docompParam); 205 doifCommand->SetParameter(docompParam); 224 auto* dorightParam = new G4UIparameter("righ << 206 G4UIparameter* dorightParam = new G4UIparameter("right",'d',false); 225 doifCommand->SetParameter(dorightParam); 207 doifCommand->SetParameter(dorightParam); 226 auto* comParam = new G4UIparameter("UI_comma << 208 G4UIparameter* comParam = new G4UIparameter("UI_command",'s',false); 227 doifCommand->SetParameter(comParam); 209 doifCommand->SetParameter(comParam); 228 doifCommand->SetToBeBroadcasted(false); 210 doifCommand->SetToBeBroadcasted(false); 229 211 230 addCommand = new G4UIcommand("/control/add", << 212 addCommand = new G4UIcommand("/control/add",this); 231 addCommand->SetGuidance("Define a new alias 213 addCommand->SetGuidance("Define a new alias as the sum of two values."); 232 addCommand->SetGuidance(" Syntax : <new_alia 214 addCommand->SetGuidance(" Syntax : <new_alias> <value1> <value2>"); 233 addCommand->SetGuidance(" <new_alias> may be 215 addCommand->SetGuidance(" <new_alias> may be an already existing alias. If it is the case,"); 234 addCommand->SetGuidance(" aliased value is a 216 addCommand->SetGuidance(" aliased value is alternated."); 235 auto* newAlias1 = new G4UIparameter("new_ali << 217 G4UIparameter* newAlias1 = new G4UIparameter("new_alias",'s',false); 236 addCommand->SetParameter(newAlias1); 218 addCommand->SetParameter(newAlias1); 237 auto* val1a = new G4UIparameter("value1", 'd << 219 G4UIparameter* val1a = new G4UIparameter("value1",'d',false); 238 addCommand->SetParameter(val1a); 220 addCommand->SetParameter(val1a); 239 auto* val1b = new G4UIparameter("value2", 'd << 221 G4UIparameter* val1b = new G4UIparameter("value2",'d',false); 240 addCommand->SetParameter(val1b); 222 addCommand->SetParameter(val1b); 241 addCommand->SetToBeBroadcasted(false); 223 addCommand->SetToBeBroadcasted(false); 242 224 243 subtractCommand = new G4UIcommand("/control/ << 225 subtractCommand = new G4UIcommand("/control/subtract",this); 244 subtractCommand->SetGuidance("Define a new a 226 subtractCommand->SetGuidance("Define a new alias as the subtraction of two values."); 245 subtractCommand->SetGuidance(" Syntax : <new 227 subtractCommand->SetGuidance(" Syntax : <new_alias> <value1> <value2>"); 246 subtractCommand->SetGuidance(" <new_alias> m 228 subtractCommand->SetGuidance(" <new_alias> may be an already existing alias. If it is the case,"); 247 subtractCommand->SetGuidance(" aliased value 229 subtractCommand->SetGuidance(" aliased value is alternated."); 248 auto* newAlias2 = new G4UIparameter("new_ali << 230 G4UIparameter* newAlias2 = new G4UIparameter("new_alias",'s',false); 249 subtractCommand->SetParameter(newAlias2); 231 subtractCommand->SetParameter(newAlias2); 250 auto* val2a = new G4UIparameter("value1", 'd << 232 G4UIparameter* val2a = new G4UIparameter("value1",'d',false); 251 subtractCommand->SetParameter(val2a); 233 subtractCommand->SetParameter(val2a); 252 auto* val2b = new G4UIparameter("value2", 'd << 234 G4UIparameter* val2b = new G4UIparameter("value2",'d',false); 253 subtractCommand->SetParameter(val2b); 235 subtractCommand->SetParameter(val2b); 254 subtractCommand->SetToBeBroadcasted(false); 236 subtractCommand->SetToBeBroadcasted(false); 255 237 256 multiplyCommand = new G4UIcommand("/control/ << 238 multiplyCommand = new G4UIcommand("/control/multiply",this); 257 multiplyCommand->SetGuidance("Define a new a 239 multiplyCommand->SetGuidance("Define a new alias as the multiplication of two values."); 258 multiplyCommand->SetGuidance(" Syntax : <new 240 multiplyCommand->SetGuidance(" Syntax : <new_alias> <value1> <value2>"); 259 multiplyCommand->SetGuidance(" <new_alias> m 241 multiplyCommand->SetGuidance(" <new_alias> may be an already existing alias. If it is the case,"); 260 multiplyCommand->SetGuidance(" aliased value 242 multiplyCommand->SetGuidance(" aliased value is alternated."); 261 auto* newAlias3 = new G4UIparameter("new_ali << 243 G4UIparameter* newAlias3 = new G4UIparameter("new_alias",'s',false); 262 multiplyCommand->SetParameter(newAlias3); 244 multiplyCommand->SetParameter(newAlias3); 263 auto* val3a = new G4UIparameter("value1", 'd << 245 G4UIparameter* val3a = new G4UIparameter("value1",'d',false); 264 multiplyCommand->SetParameter(val3a); 246 multiplyCommand->SetParameter(val3a); 265 auto* val3b = new G4UIparameter("value2", 'd << 247 G4UIparameter* val3b = new G4UIparameter("value2",'d',false); 266 multiplyCommand->SetParameter(val3b); 248 multiplyCommand->SetParameter(val3b); 267 multiplyCommand->SetToBeBroadcasted(false); 249 multiplyCommand->SetToBeBroadcasted(false); 268 250 269 divideCommand = new G4UIcommand("/control/di << 251 divideCommand = new G4UIcommand("/control/divide",this); 270 divideCommand->SetGuidance("Define a new ali 252 divideCommand->SetGuidance("Define a new alias as the division of two values."); 271 divideCommand->SetGuidance(" Syntax : <new_a 253 divideCommand->SetGuidance(" Syntax : <new_alias> <value1> <value2>"); 272 divideCommand->SetGuidance(" <new_alias> may 254 divideCommand->SetGuidance(" <new_alias> may be an already existing alias. If it is the case,"); 273 divideCommand->SetGuidance(" aliased value i 255 divideCommand->SetGuidance(" aliased value is alternated."); 274 auto* newAlias4 = new G4UIparameter("new_ali << 256 G4UIparameter* newAlias4 = new G4UIparameter("new_alias",'s',false); 275 divideCommand->SetParameter(newAlias4); 257 divideCommand->SetParameter(newAlias4); 276 auto* val4a = new G4UIparameter("value1", 'd << 258 G4UIparameter* val4a = new G4UIparameter("value1",'d',false); 277 divideCommand->SetParameter(val4a); 259 divideCommand->SetParameter(val4a); 278 auto* val4b = new G4UIparameter("value2", 'd << 260 G4UIparameter* val4b = new G4UIparameter("value2",'d',false); 279 val4b->SetParameterRange("value2 != 0."); 261 val4b->SetParameterRange("value2 != 0."); 280 divideCommand->SetParameter(val4b); 262 divideCommand->SetParameter(val4b); 281 divideCommand->SetToBeBroadcasted(false); 263 divideCommand->SetToBeBroadcasted(false); 282 264 283 remainderCommand = new G4UIcommand("/control << 265 remainderCommand = new G4UIcommand("/control/remainder",this); 284 remainderCommand->SetGuidance("Define a new 266 remainderCommand->SetGuidance("Define a new alias as the remainder of two values."); 285 remainderCommand->SetGuidance(" Syntax : <ne 267 remainderCommand->SetGuidance(" Syntax : <new_alias> <value1> <value2>"); 286 remainderCommand->SetGuidance( << 268 remainderCommand->SetGuidance(" <new_alias> may be an already existing alias. If it is the case,"); 287 " <new_alias> may be an already existing a << 288 remainderCommand->SetGuidance(" aliased valu 269 remainderCommand->SetGuidance(" aliased value is alternated."); 289 auto* newAlias5 = new G4UIparameter("new_ali << 270 G4UIparameter* newAlias5 = new G4UIparameter("new_alias",'s',false); 290 remainderCommand->SetParameter(newAlias5); 271 remainderCommand->SetParameter(newAlias5); 291 auto* val5a = new G4UIparameter("value1", 'i << 272 G4UIparameter* val5a = new G4UIparameter("value1",'i',false); 292 remainderCommand->SetParameter(val5a); 273 remainderCommand->SetParameter(val5a); 293 auto* val5b = new G4UIparameter("value2", 'i << 274 G4UIparameter* val5b = new G4UIparameter("value2",'i',false); 294 val4b->SetParameterRange("value2 != 0"); 275 val4b->SetParameterRange("value2 != 0"); 295 remainderCommand->SetParameter(val5b); 276 remainderCommand->SetParameter(val5b); 296 remainderCommand->SetToBeBroadcasted(false); 277 remainderCommand->SetToBeBroadcasted(false); 297 278 298 strifCommand = new G4UIcommand("/control/str << 279 strifCommand = new G4UIcommand("/control/strif",this); 299 strifCommand->SetGuidance("Execute a macro f 280 strifCommand->SetGuidance("Execute a macro file if the expression is true."); 300 strifCommand->SetGuidance(" Syntax : <string 281 strifCommand->SetGuidance(" Syntax : <string> <comp> <string> <macro_file>"); 301 auto* strleftParam = new G4UIparameter("left << 282 G4UIparameter* strleftParam = new G4UIparameter("left",'s',false); 302 strifCommand->SetParameter(strleftParam); 283 strifCommand->SetParameter(strleftParam); 303 auto* strcompParam = new G4UIparameter("comp << 284 G4UIparameter* strcompParam = new G4UIparameter("comp",'s',false); 304 strcompParam->SetParameterCandidates("== !=" 285 strcompParam->SetParameterCandidates("== !="); 305 strifCommand->SetParameter(strcompParam); 286 strifCommand->SetParameter(strcompParam); 306 auto* strrightParam = new G4UIparameter("rig << 287 G4UIparameter* strrightParam = new G4UIparameter("right",'s',false); 307 strifCommand->SetParameter(strrightParam); 288 strifCommand->SetParameter(strrightParam); 308 auto* strmacroFileParam = new G4UIparameter( << 289 G4UIparameter* strmacroFileParam = new G4UIparameter("macroFile",'s',false); 309 strifCommand->SetParameter(strmacroFileParam 290 strifCommand->SetParameter(strmacroFileParam); 310 strifCommand->SetToBeBroadcasted(false); 291 strifCommand->SetToBeBroadcasted(false); 311 292 312 strdoifCommand = new G4UIcommand("/control/s << 293 strdoifCommand = new G4UIcommand("/control/strdoif",this); 313 strdoifCommand->SetGuidance("Execute a UI co 294 strdoifCommand->SetGuidance("Execute a UI command if the expression is true."); 314 strdoifCommand->SetGuidance(" Syntax : <stri 295 strdoifCommand->SetGuidance(" Syntax : <string> <comp> <string> <UI_command>"); 315 auto* strdoleftParam = new G4UIparameter("le << 296 G4UIparameter* strdoleftParam = new G4UIparameter("left",'s',false); 316 strdoifCommand->SetParameter(strdoleftParam) 297 strdoifCommand->SetParameter(strdoleftParam); 317 auto* strdocompParam = new G4UIparameter("co << 298 G4UIparameter* strdocompParam = new G4UIparameter("comp",'s',false); 318 strdocompParam->SetParameterCandidates("== ! 299 strdocompParam->SetParameterCandidates("== !="); 319 strdoifCommand->SetParameter(strdocompParam) 300 strdoifCommand->SetParameter(strdocompParam); 320 auto* strdorightParam = new G4UIparameter("r << 301 G4UIparameter* strdorightParam = new G4UIparameter("right",'s',false); 321 strdoifCommand->SetParameter(strdorightParam 302 strdoifCommand->SetParameter(strdorightParam); 322 auto* strdomacroFileParam = new G4UIparamete << 303 G4UIparameter* strdomacroFileParam = new G4UIparameter("UI_command",'s',false); 323 strdoifCommand->SetParameter(strdomacroFileP 304 strdoifCommand->SetParameter(strdomacroFileParam); 324 strdoifCommand->SetToBeBroadcasted(false); 305 strdoifCommand->SetToBeBroadcasted(false); 325 306 326 ifBatchCommand = new G4UIcmdWithAString("/co << 307 ifBatchCommand = new G4UIcmdWithAString("/control/ifBatch",this); 327 ifBatchCommand->SetGuidance("Execute a macro 308 ifBatchCommand->SetGuidance("Execute a macro file if program is running in batch mode."); 328 ifBatchCommand->SetParameterName("macroFile" << 309 ifBatchCommand->SetParameterName("macroFile",false); 329 ifBatchCommand->SetToBeBroadcasted(false); 310 ifBatchCommand->SetToBeBroadcasted(false); 330 311 331 ifInteractiveCommand = new G4UIcmdWithAStrin << 312 ifInteractiveCommand = new G4UIcmdWithAString("/control/ifInteractive",this); 332 ifInteractiveCommand->SetGuidance( << 313 ifInteractiveCommand->SetGuidance("Execute a macro file if program is running in interactive mode."); 333 "Execute a macro file if program is runnin << 314 ifInteractiveCommand->SetParameterName("macroFile",false); 334 ifInteractiveCommand->SetParameterName("macr << 335 ifInteractiveCommand->SetToBeBroadcasted(fal 315 ifInteractiveCommand->SetToBeBroadcasted(false); 336 316 337 doifBatchCommand = new G4UIcmdWithAString("/ << 317 doifBatchCommand = new G4UIcmdWithAString("/control/doifBatch",this); 338 doifBatchCommand->SetGuidance("Execute a UI 318 doifBatchCommand->SetGuidance("Execute a UI command if program is running in batch mode."); 339 doifBatchCommand->SetParameterName("UIcomman << 319 doifBatchCommand->SetParameterName("UIcommand",false); 340 doifBatchCommand->SetToBeBroadcasted(false); 320 doifBatchCommand->SetToBeBroadcasted(false); 341 321 342 doifInteractiveCommand = new G4UIcmdWithAStr << 322 doifInteractiveCommand = new G4UIcmdWithAString("/control/doifInteractive",this); 343 doifInteractiveCommand->SetGuidance( << 323 doifInteractiveCommand->SetGuidance("Execute a UI command if program is running in interactive mode."); 344 "Execute a UI command if program is runnin << 324 doifInteractiveCommand->SetParameterName("UIcommand",false); 345 doifInteractiveCommand->SetParameterName("UI << 346 doifInteractiveCommand->SetToBeBroadcasted(f 325 doifInteractiveCommand->SetToBeBroadcasted(false); >> 326 347 } 327 } 348 328 349 // ------------------------------------------- << 350 G4UIcontrolMessenger::~G4UIcontrolMessenger() 329 G4UIcontrolMessenger::~G4UIcontrolMessenger() 351 { 330 { 352 delete macroPathCommand; 331 delete macroPathCommand; 353 delete ExecuteCommand; 332 delete ExecuteCommand; 354 delete suppressAbortionCommand; 333 delete suppressAbortionCommand; 355 delete verboseCommand; 334 delete verboseCommand; 356 delete doublePrecCommand; 335 delete doublePrecCommand; 357 delete historyCommand; 336 delete historyCommand; 358 delete stopStoreHistoryCommand; 337 delete stopStoreHistoryCommand; 359 delete ManualCommand; 338 delete ManualCommand; 360 delete aliasCommand; 339 delete aliasCommand; 361 delete unaliasCommand; 340 delete unaliasCommand; 362 delete listAliasCommand; 341 delete listAliasCommand; 363 delete getEnvCmd; 342 delete getEnvCmd; 364 delete getValCmd; 343 delete getValCmd; 365 delete echoCmd; 344 delete echoCmd; 366 delete shellCommand; 345 delete shellCommand; 367 delete loopCommand; 346 delete loopCommand; 368 delete foreachCommand; << 347 delete foreachCommand; 369 delete HTMLCommand; 348 delete HTMLCommand; 370 delete maxStoredHistCommand; 349 delete maxStoredHistCommand; 371 delete ifCommand; 350 delete ifCommand; 372 delete doifCommand; 351 delete doifCommand; 373 delete addCommand; 352 delete addCommand; 374 delete subtractCommand; 353 delete subtractCommand; 375 delete multiplyCommand; 354 delete multiplyCommand; 376 delete divideCommand; 355 delete divideCommand; 377 delete remainderCommand; 356 delete remainderCommand; 378 delete strifCommand; 357 delete strifCommand; 379 delete strdoifCommand; 358 delete strdoifCommand; 380 delete ifBatchCommand; 359 delete ifBatchCommand; 381 delete ifInteractiveCommand; 360 delete ifInteractiveCommand; 382 delete doifBatchCommand; 361 delete doifBatchCommand; 383 delete doifInteractiveCommand; 362 delete doifInteractiveCommand; >> 363 384 delete controlDirectory; 364 delete controlDirectory; 385 } 365 } 386 366 387 // ------------------------------------------- << 367 void G4UIcontrolMessenger::SetNewValue(G4UIcommand * command,G4String newValue) 388 void G4UIcontrolMessenger::SetNewValue(G4UIcom << 389 { 368 { 390 G4UImanager* UI = G4UImanager::GetUIpointer( << 369 G4UImanager * UI = G4UImanager::GetUIpointer(); 391 370 392 if (command == macroPathCommand) { << 371 if( command == macroPathCommand) { 393 UI->SetMacroSearchPath(newValue); << 372 UI-> SetMacroSearchPath(newValue); 394 UI->ParseMacroSearchPath(); << 373 UI-> ParseMacroSearchPath(); 395 } << 374 } 396 if (command == ExecuteCommand) { << 375 if(command==ExecuteCommand) >> 376 { 397 command->ResetFailure(); 377 command->ResetFailure(); 398 UI->ExecuteMacroFile(UI->FindMacroPath(new << 378 UI-> ExecuteMacroFile(UI-> FindMacroPath(newValue)); 399 if (UI->GetLastReturnCode() != 0) { << 379 if(UI->GetLastReturnCode() != 0) >> 380 { 400 G4ExceptionDescription ed; 381 G4ExceptionDescription ed; 401 ed << "Command aborted (" << UI->GetLast 382 ed << "Command aborted (" << UI->GetLastReturnCode() << ")"; 402 command->CommandFailed(UI->GetLastReturn << 383 command->CommandFailed(UI->GetLastReturnCode(),ed); 403 } 384 } 404 } 385 } 405 if (command == suppressAbortionCommand) { << 386 if(command==suppressAbortionCommand) 406 G4StateManager::GetStateManager()->SetSupp << 387 { 407 suppressAbortionCommand->GetNewIntValue( << 388 G4StateManager::GetStateManager()->SetSuppressAbortion(suppressAbortionCommand->GetNewIntValue(newValue)); 408 } 389 } 409 if (command == verboseCommand) { << 390 if(command==verboseCommand) >> 391 { 410 UI->SetVerboseLevel(verboseCommand->GetNew 392 UI->SetVerboseLevel(verboseCommand->GetNewIntValue(newValue)); 411 } 393 } 412 if (command == doublePrecCommand) { << 394 if(command==doublePrecCommand) >> 395 { 413 G4UImanager::UseDoublePrecisionStr(doubleP 396 G4UImanager::UseDoublePrecisionStr(doublePrecCommand->GetNewBoolValue(newValue)); 414 } 397 } 415 if (command == historyCommand) { << 398 if(command==historyCommand) 416 UI->StoreHistory(newValue); << 399 { >> 400 UI->StoreHistory(newValue); >> 401 } >> 402 if(command==stopStoreHistoryCommand) >> 403 { >> 404 UI->StoreHistory(false); 417 } 405 } 418 if (command == stopStoreHistoryCommand) { << 406 if(command==ManualCommand) 419 UI->StoreHistory(false); << 407 { 420 } << 421 if (command == ManualCommand) { << 422 UI->ListCommands(newValue); 408 UI->ListCommands(newValue); 423 } 409 } 424 if (command == aliasCommand) { << 410 if(command==aliasCommand) >> 411 { 425 UI->SetAlias(newValue); 412 UI->SetAlias(newValue); 426 } 413 } 427 if (command == unaliasCommand) { << 414 if(command==unaliasCommand) >> 415 { 428 UI->RemoveAlias(newValue); 416 UI->RemoveAlias(newValue); 429 } 417 } 430 if (command == listAliasCommand) { << 418 if(command==listAliasCommand) >> 419 { 431 UI->ListAlias(); 420 UI->ListAlias(); 432 } 421 } 433 if (command == getEnvCmd) { << 422 if(command==getEnvCmd) >> 423 { 434 command->ResetFailure(); 424 command->ResetFailure(); 435 if (std::getenv(newValue) != nullptr) { << 425 if(std::getenv(newValue)) >> 426 { 436 G4String st = newValue; 427 G4String st = newValue; 437 st += " "; 428 st += " "; 438 st += std::getenv(newValue); 429 st += std::getenv(newValue); 439 UI->SetAlias(st.c_str()); 430 UI->SetAlias(st.c_str()); 440 } 431 } 441 else { << 432 else >> 433 { 442 G4ExceptionDescription ed; 434 G4ExceptionDescription ed; 443 ed << "<" << newValue << "> is not defin 435 ed << "<" << newValue << "> is not defined as a shell variable. Command ignored."; 444 command->CommandFailed(ed); 436 command->CommandFailed(ed); 445 } 437 } 446 } 438 } 447 if (command == getValCmd) { << 439 if(command==getValCmd) >> 440 { 448 G4Tokenizer next(newValue); 441 G4Tokenizer next(newValue); 449 const G4String& aliName = next(); << 442 G4String aliName = next(); 450 const G4String& com = next(); << 443 G4String com = next(); 451 const G4String& curVal = UI->GetCurrentVal << 444 G4String curVal = UI->GetCurrentValues(com); 452 if (!(curVal.empty())) { << 445 if(!(curVal.isNull())) >> 446 { 453 G4String theValue = curVal; 447 G4String theValue = curVal; 454 G4String iIdx = next(); 448 G4String iIdx = next(); 455 if (!(iIdx.empty())) { << 449 if(!(iIdx.isNull())) >> 450 { 456 G4int idx = StoI(iIdx); 451 G4int idx = StoI(iIdx); 457 G4Tokenizer nextVal(curVal); 452 G4Tokenizer nextVal(curVal); 458 for (G4int i = 0; i <= idx; i++) { << 453 for(G4int i = 0;i<=idx;i++) 459 theValue = nextVal(); << 454 { theValue = nextVal(); } 460 } << 461 } 455 } 462 G4String st = "/control/alias "; 456 G4String st = "/control/alias "; 463 st += aliName + " " + theValue; 457 st += aliName + " " + theValue; 464 UI->ApplyCommand(st); 458 UI->ApplyCommand(st); 465 } 459 } 466 } 460 } 467 if (command == echoCmd) { << 461 if(command==echoCmd) 468 G4cout << UI->SolveAlias(newValue) << G4en << 462 { G4cout << UI->SolveAlias(newValue) << G4endl; } 469 } << 463 if(command==shellCommand) 470 if (command == shellCommand) { << 464 { 471 command->ResetFailure(); 465 command->ResetFailure(); 472 G4int rc = system(newValue); << 466 int rc = system(newValue); 473 if (rc < 0) { << 467 if ( rc < 0 ) >> 468 { 474 G4ExceptionDescription ed; 469 G4ExceptionDescription ed; 475 ed << "<" << newValue << "> is not a val 470 ed << "<" << newValue << "> is not a valid shell command. Command ignored."; 476 command->CommandFailed(ed); 471 command->CommandFailed(ed); 477 } 472 } 478 } 473 } 479 if (command == loopCommand) { << 474 if(command==loopCommand) >> 475 { 480 command->ResetFailure(); 476 command->ResetFailure(); 481 UI->LoopS(newValue); 477 UI->LoopS(newValue); 482 if (UI->GetLastReturnCode() != 0) { << 478 if(UI->GetLastReturnCode() != 0) >> 479 { 483 G4ExceptionDescription ed; 480 G4ExceptionDescription ed; 484 ed << "Command aborted (" << UI->GetLast 481 ed << "Command aborted (" << UI->GetLastReturnCode() << ")"; 485 command->CommandFailed(UI->GetLastReturn << 482 command->CommandFailed(UI->GetLastReturnCode(),ed); 486 } 483 } 487 } 484 } 488 if (command == foreachCommand) { << 485 if(command==foreachCommand) >> 486 { 489 command->ResetFailure(); 487 command->ResetFailure(); 490 UI->ForeachS(newValue); 488 UI->ForeachS(newValue); 491 if (UI->GetLastReturnCode() != 0) { << 489 if(UI->GetLastReturnCode() != 0) >> 490 { 492 G4ExceptionDescription ed; 491 G4ExceptionDescription ed; 493 ed << "Command aborted (" << UI->GetLast 492 ed << "Command aborted (" << UI->GetLastReturnCode() << ")"; 494 command->CommandFailed(UI->GetLastReturn << 493 command->CommandFailed(UI->GetLastReturnCode(),ed); 495 } 494 } 496 } 495 } 497 if (command == HTMLCommand) { << 496 if(command==HTMLCommand) >> 497 { 498 UI->CreateHTML(newValue); 498 UI->CreateHTML(newValue); 499 } 499 } 500 if (command == maxStoredHistCommand) { << 500 if(command==maxStoredHistCommand) >> 501 { 501 UI->SetMaxHistSize(maxStoredHistCommand->G 502 UI->SetMaxHistSize(maxStoredHistCommand->GetNewIntValue(newValue)); 502 } 503 } 503 if (command == ifCommand) { << 504 if(command==ifCommand) >> 505 { 504 G4Tokenizer next(newValue); 506 G4Tokenizer next(newValue); 505 G4double l = StoD(next()); 507 G4double l = StoD(next()); 506 const G4String& comp = next(); << 508 G4String comp = next(); 507 G4double r = StoD(next()); 509 G4double r = StoD(next()); 508 const G4String& mac = next(); << 510 G4String mac = next(); 509 G4bool x = false; 511 G4bool x = false; 510 if (comp == ">") { << 512 if(comp==">") x = (l>r); 511 x = (l > r); << 513 else if(comp==">=") x = (l>=r); 512 } << 514 else if(comp=="<") x = (l<r); 513 else if (comp == ">=") { << 515 else if(comp=="<=") x = (l<=r); 514 x = (l >= r); << 516 else if(comp=="==") x = (l==r); 515 } << 517 else if(comp=="!=") x = (l!=r); 516 else if (comp == "<") { << 518 if(x) UI->ExecuteMacroFile(mac); 517 x = (l < r); << 518 } << 519 else if (comp == "<=") { << 520 x = (l <= r); << 521 } << 522 else if (comp == "==") { << 523 x = (l == r); << 524 } << 525 else if (comp == "!=") { << 526 x = (l != r); << 527 } << 528 if (x) { << 529 UI->ExecuteMacroFile(UI->FindMacroPath(m << 530 } << 531 } 519 } 532 if (command == doifCommand) { << 520 if(command==doifCommand) >> 521 { 533 G4Tokenizer next(newValue); 522 G4Tokenizer next(newValue); 534 G4double l = StoD(next()); 523 G4double l = StoD(next()); 535 const G4String& comp = next(); << 524 G4String comp = next(); 536 G4double r = StoD(next()); 525 G4double r = StoD(next()); 537 526 538 G4String c1 = next(); 527 G4String c1 = next(); 539 G4String ca; 528 G4String ca; 540 while (!((ca = next()).empty())) { << 529 while(!((ca=next()).isNull())) >> 530 { 541 c1 += " "; 531 c1 += " "; 542 c1 += ca; 532 c1 += ca; 543 } 533 } 544 if (c1[0] == '"') { << 534 if(c1(0)=='"') >> 535 { 545 G4String strippedValue; 536 G4String strippedValue; 546 if (c1.back() == '"') { << 537 if(c1(c1.length()-1)=='"') 547 strippedValue = c1.substr(1, c1.length << 538 { strippedValue = c1(1,c1.length()-2); } 548 } << 539 else 549 else { << 540 { strippedValue = c1(1,c1.length()-1); } 550 strippedValue = c1.substr(1, c1.length << 541 c1 = strippedValue; 551 } << 552 c1 = std::move(strippedValue); << 553 } 542 } 554 543 555 G4bool x = false; 544 G4bool x = false; 556 if (comp == ">") { << 545 if(comp==">") x = (l>r); 557 x = (l > r); << 546 else if(comp==">=") x = (l>=r); 558 } << 547 else if(comp=="<") x = (l<r); 559 else if (comp == ">=") { << 548 else if(comp=="<=") x = (l<=r); 560 x = (l >= r); << 549 else if(comp=="==") x = (l==r); 561 } << 550 else if(comp=="!=") x = (l!=r); 562 else if (comp == "<") { << 551 if(x) UI->ApplyCommand(c1); 563 x = (l < r); << 564 } << 565 else if (comp == "<=") { << 566 x = (l <= r); << 567 } << 568 else if (comp == "==") { << 569 x = (l == r); << 570 } << 571 else if (comp == "!=") { << 572 x = (l != r); << 573 } << 574 if (x) { << 575 UI->ApplyCommand(c1); << 576 } << 577 } 552 } 578 if (command == addCommand) { << 553 if(command==addCommand) >> 554 { 579 G4Tokenizer next(newValue); 555 G4Tokenizer next(newValue); 580 const G4String& newA = next(); << 556 G4String newA = next(); 581 G4double l = StoD(next()); 557 G4double l = StoD(next()); 582 G4double r = StoD(next()); 558 G4double r = StoD(next()); 583 G4String st = "/control/alias "; 559 G4String st = "/control/alias "; 584 st += newA; 560 st += newA; 585 st += " "; 561 st += " "; 586 st += DtoS(l + r); << 562 st += DtoS(l+r); 587 UI->ApplyCommand(st); 563 UI->ApplyCommand(st); 588 } 564 } 589 if (command == subtractCommand) { << 565 if(command==subtractCommand) >> 566 { 590 G4Tokenizer next(newValue); 567 G4Tokenizer next(newValue); 591 const G4String& newA = next(); << 568 G4String newA = next(); 592 G4double l = StoD(next()); 569 G4double l = StoD(next()); 593 G4double r = StoD(next()); 570 G4double r = StoD(next()); 594 G4String st = "/control/alias "; 571 G4String st = "/control/alias "; 595 st += newA; 572 st += newA; 596 st += " "; 573 st += " "; 597 st += DtoS(l - r); << 574 st += DtoS(l-r); 598 UI->ApplyCommand(st); 575 UI->ApplyCommand(st); 599 } 576 } 600 if (command == multiplyCommand) { << 577 if(command==multiplyCommand) >> 578 { 601 G4Tokenizer next(newValue); 579 G4Tokenizer next(newValue); 602 const G4String& newA = next(); << 580 G4String newA = next(); 603 G4double l = StoD(next()); 581 G4double l = StoD(next()); 604 G4double r = StoD(next()); 582 G4double r = StoD(next()); 605 G4String st = "/control/alias "; 583 G4String st = "/control/alias "; 606 st += newA; 584 st += newA; 607 st += " "; 585 st += " "; 608 st += DtoS(l * r); << 586 st += DtoS(l*r); 609 UI->ApplyCommand(st); 587 UI->ApplyCommand(st); 610 } 588 } 611 if (command == divideCommand) { << 589 if(command==divideCommand) >> 590 { 612 G4Tokenizer next(newValue); 591 G4Tokenizer next(newValue); 613 const G4String& newA = next(); << 592 G4String newA = next(); 614 G4double l = StoD(next()); 593 G4double l = StoD(next()); 615 G4double r = StoD(next()); 594 G4double r = StoD(next()); 616 G4String st = "/control/alias "; 595 G4String st = "/control/alias "; 617 st += newA; 596 st += newA; 618 st += " "; 597 st += " "; 619 st += DtoS(l / r); << 598 st += DtoS(l/r); 620 UI->ApplyCommand(st); 599 UI->ApplyCommand(st); 621 } 600 } 622 if (command == remainderCommand) { << 601 if(command==remainderCommand) >> 602 { 623 G4Tokenizer next(newValue); 603 G4Tokenizer next(newValue); 624 const G4String& newA = next(); << 604 G4String newA = next(); 625 G4int l = StoI(next()); 605 G4int l = StoI(next()); 626 G4int r = StoI(next()); 606 G4int r = StoI(next()); 627 G4String st = "/control/alias "; 607 G4String st = "/control/alias "; 628 st += newA; 608 st += newA; 629 st += " "; 609 st += " "; 630 st += DtoS(l % r); << 610 st += DtoS(l%r); 631 UI->ApplyCommand(st); 611 UI->ApplyCommand(st); 632 } 612 } 633 if (command == strifCommand) { << 613 if(command==strifCommand) >> 614 { 634 G4Tokenizer next(newValue); 615 G4Tokenizer next(newValue); 635 const G4String& l = next(); << 616 G4String l = next(); 636 const G4String& comp = next(); << 617 G4String comp = next(); 637 const G4String& r = next(); << 618 G4String r = next(); 638 const G4String& mac = next(); << 619 G4String mac = next(); 639 G4bool x = false; 620 G4bool x = false; 640 if (comp == "==") { << 621 if(comp=="==") { x = (l==r); } 641 x = (l == r); << 622 else if(comp=="!=") { x = (l!=r); } 642 } << 623 if(x) UI->ExecuteMacroFile(mac); 643 else if (comp == "!=") { << 644 x = (l != r); << 645 } << 646 if (x) { << 647 UI->ExecuteMacroFile(UI->FindMacroPath(m << 648 } << 649 } 624 } 650 if (command == strdoifCommand) { << 625 if(command==strdoifCommand) >> 626 { 651 G4Tokenizer next(newValue); 627 G4Tokenizer next(newValue); 652 const G4String& l = next(); << 628 G4String l = next(); 653 const G4String& comp = next(); << 629 G4String comp = next(); 654 const G4String& r = next(); << 630 G4String r = next(); 655 631 656 G4String c1 = next(); 632 G4String c1 = next(); 657 G4String ca; 633 G4String ca; 658 while (!((ca = next()).empty())) { << 634 while(!((ca=next()).isNull())) >> 635 { 659 c1 += " "; 636 c1 += " "; 660 c1 += ca; 637 c1 += ca; 661 } 638 } 662 if (c1[0] == '"') { << 639 if(c1(0)=='"') >> 640 { 663 G4String strippedValue; 641 G4String strippedValue; 664 if (c1.back() == '"') { << 642 if(c1(c1.length()-1)=='"') 665 strippedValue = c1.substr(1, c1.length << 643 { strippedValue = c1(1,c1.length()-2); } 666 } << 644 else 667 else { << 645 { strippedValue = c1(1,c1.length()-1); } 668 strippedValue = c1.substr(1, c1.length << 646 c1 = strippedValue; 669 } << 670 c1 = std::move(strippedValue); << 671 } 647 } 672 648 673 G4bool x = false; 649 G4bool x = false; 674 if (comp == "==") { << 650 if(comp=="==") { x = (l==r); } 675 x = (l == r); << 651 else if(comp=="!=") { x = (l!=r); } 676 } << 652 if(x) UI->ApplyCommand(c1); 677 else if (comp == "!=") { << 653 } 678 x = (l != r); << 654 if(command==ifBatchCommand) 679 } << 655 { 680 if (x) { << 656 if(G4UIsession::InSession()==0) UI->ExecuteMacroFile(UI->FindMacroPath(newValue)); 681 UI->ApplyCommand(c1); << 657 } 682 } << 658 if(command==ifInteractiveCommand) 683 } << 659 { 684 if (command == ifBatchCommand) { << 660 if(G4UIsession::InSession()>0) UI->ExecuteMacroFile(UI->FindMacroPath(newValue)); 685 if (G4UIsession::InSession() == 0) { << 661 } 686 UI->ExecuteMacroFile(UI->FindMacroPath(n << 662 if(command==doifBatchCommand) 687 } << 663 { 688 } << 664 if(G4UIsession::InSession()==0) UI->ApplyCommand(newValue); 689 if (command == ifInteractiveCommand) { << 665 } 690 if (G4UIsession::InSession() > 0) { << 666 if(command==doifInteractiveCommand) 691 UI->ExecuteMacroFile(UI->FindMacroPath(n << 667 { 692 } << 668 if(G4UIsession::InSession()>0) UI->ApplyCommand(newValue); 693 } << 694 if (command == doifBatchCommand) { << 695 if (G4UIsession::InSession() == 0) { << 696 UI->ApplyCommand(newValue); << 697 } << 698 } << 699 if (command == doifInteractiveCommand) { << 700 if (G4UIsession::InSession() > 0) { << 701 UI->ApplyCommand(newValue); << 702 } << 703 } 669 } 704 } 670 } 705 671 706 // ------------------------------------------- << 672 G4String G4UIcontrolMessenger::GetCurrentValue(G4UIcommand * command) 707 G4String G4UIcontrolMessenger::GetCurrentValue << 708 { 673 { 709 G4UImanager* UI = G4UImanager::GetUIpointer( << 674 G4UImanager * UI = G4UImanager::GetUIpointer(); 710 G4String currentValue; 675 G4String currentValue; 711 << 676 712 if (command == macroPathCommand) { << 677 if( command == macroPathCommand ) { 713 currentValue = UI->GetMacroSearchPath(); << 678 currentValue = UI-> GetMacroSearchPath(); 714 } 679 } 715 if (command == verboseCommand) { << 680 if(command==verboseCommand) >> 681 { 716 currentValue = verboseCommand->ConvertToSt 682 currentValue = verboseCommand->ConvertToString(UI->GetVerboseLevel()); 717 } 683 } 718 if (command == doublePrecCommand) { << 684 if(command==doublePrecCommand) >> 685 { 719 currentValue = doublePrecCommand->ConvertT 686 currentValue = doublePrecCommand->ConvertToString(G4UImanager::DoublePrecisionStr()); 720 } 687 } 721 if (command == suppressAbortionCommand) { << 688 if(command==suppressAbortionCommand) 722 currentValue = suppressAbortionCommand->Co << 689 { 723 G4StateManager::GetStateManager()->GetSu << 690 currentValue = suppressAbortionCommand->ConvertToString(G4StateManager::GetStateManager()->GetSuppressAbortion()); 724 } 691 } 725 if (command == maxStoredHistCommand) { << 692 if(command==maxStoredHistCommand) >> 693 { 726 currentValue = maxStoredHistCommand->Conve 694 currentValue = maxStoredHistCommand->ConvertToString(UI->GetMaxHistSize()); 727 } 695 } 728 << 696 729 return currentValue; 697 return currentValue; 730 } 698 } >> 699 >> 700 731 701