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