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