Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
G4UIcontrolMessenger.cc
이 파일의 문서화 페이지로 가기
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 110932 2018-06-26 08:06:51Z 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);
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);
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);
84  G4UIparameter* param7 = new G4UIparameter("counterName",'s',false);
86  G4UIparameter* param8 = new G4UIparameter("valueList",'s',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.");
98  suppressAbortionCommand->SetRange("level >= 0 && level <= 2");
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");
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);
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 
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);
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);
179 
180  maxStoredHistCommand = new G4UIcmdWithAnInteger("/control/maximumStoredHistory",this);
181  maxStoredHistCommand->SetGuidance("Set maximum number of stored UI commands.");
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);
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);
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);
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);
235  G4UIparameter* val2b = new G4UIparameter("value2",'d',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);
248  G4UIparameter* val3b = new G4UIparameter("value2",'d',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);
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);
275  G4UIparameter* val5b = new G4UIparameter("value2",'i',false);
276  val4b->SetParameterRange("value2 != 0");
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);
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);
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);
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);
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);
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);
327 
328 }
329 
331 {
332  delete macroPathCommand;
333  delete ExecuteCommand;
335  delete verboseCommand;
336  delete doublePrecCommand;
337  delete historyCommand;
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  {
383  }
384  if(command==verboseCommand)
385  {
387  }
388  if(command==doublePrecCommand)
389  {
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  int rc = system(newValue);
456  if ( rc < 0 ) {}
457  }
458  if(command==loopCommand)
459  {
460  UI->LoopS(newValue);
461  }
462  if(command==foreachCommand)
463  {
464  UI->ForeachS(newValue);
465  }
466  if(command==HTMLCommand)
467  {
468  UI->CreateHTML(newValue);
469  }
470  if(command==maxStoredHistCommand)
471  {
473  }
474  if(command==ifCommand)
475  {
476  G4Tokenizer next(newValue);
477  G4double l = StoD(next());
478  G4String comp = next();
479  G4double r = StoD(next());
480  G4String mac = next();
481  G4bool x = false;
482  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  else if(comp=="!=") x = (l!=r);
488  if(x) UI->ExecuteMacroFile(mac);
489  }
490  if(command==doifCommand)
491  {
492  G4Tokenizer next(newValue);
493  G4double l = StoD(next());
494  G4String comp = next();
495  G4double r = StoD(next());
496 
497  G4String c1 = next();
498  G4String ca;
499  while(!((ca=next()).isNull()))
500  {
501  c1 += " ";
502  c1 += ca;
503  }
504  if(c1(0)=='"')
505  {
506  G4String strippedValue;
507  if(c1(c1.length()-1)=='"')
508  { strippedValue = c1(1,c1.length()-2); }
509  else
510  { strippedValue = c1(1,c1.length()-1); }
511  c1 = strippedValue;
512  }
513 
514  G4bool x = false;
515  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  else if(comp=="!=") x = (l!=r);
521  if(x) UI->ApplyCommand(c1);
522  }
523  if(command==addCommand)
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==subtractCommand)
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==multiplyCommand)
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==divideCommand)
560  {
561  G4Tokenizer next(newValue);
562  G4String newA = next();
563  G4double l = StoD(next());
564  G4double r = StoD(next());
565  G4String st = "/control/alias ";
566  st += newA;
567  st += " ";
568  st += DtoS(l/r);
569  UI->ApplyCommand(st);
570  }
571  if(command==remainderCommand)
572  {
573  G4Tokenizer next(newValue);
574  G4String newA = next();
575  G4int l = StoI(next());
576  G4int r = StoI(next());
577  G4String st = "/control/alias ";
578  st += newA;
579  st += " ";
580  st += DtoS(l%r);
581  UI->ApplyCommand(st);
582  }
583  if(command==strifCommand)
584  {
585  G4Tokenizer next(newValue);
586  G4String l = next();
587  G4String comp = next();
588  G4String r = next();
589  G4String mac = next();
590  G4bool x = false;
591  if(comp=="==") { x = (l==r); }
592  else if(comp=="!=") { x = (l!=r); }
593  if(x) UI->ExecuteMacroFile(mac);
594  }
595  if(command==strdoifCommand)
596  {
597  G4Tokenizer next(newValue);
598  G4String l = next();
599  G4String comp = next();
600  G4String r = next();
601 
602  G4String c1 = next();
603  G4String ca;
604  while(!((ca=next()).isNull()))
605  {
606  c1 += " ";
607  c1 += ca;
608  }
609  if(c1(0)=='"')
610  {
611  G4String strippedValue;
612  if(c1(c1.length()-1)=='"')
613  { strippedValue = c1(1,c1.length()-2); }
614  else
615  { strippedValue = c1(1,c1.length()-1); }
616  c1 = strippedValue;
617  }
618 
619  G4bool x = false;
620  if(comp=="==") { x = (l==r); }
621  else if(comp=="!=") { x = (l!=r); }
622  if(x) UI->ApplyCommand(c1);
623  }
624  if(command==ifBatchCommand)
625  {
626  if(G4UIsession::InSession()==0) UI->ExecuteMacroFile(UI->FindMacroPath(newValue));
627  }
628  if(command==ifInteractiveCommand)
629  {
630  if(G4UIsession::InSession()>0) UI->ExecuteMacroFile(UI->FindMacroPath(newValue));
631  }
632  if(command==doifBatchCommand)
633  {
634  if(G4UIsession::InSession()==0) UI->ApplyCommand(newValue);
635  }
636  if(command==doifInteractiveCommand)
637  {
638  if(G4UIsession::InSession()>0) UI->ApplyCommand(newValue);
639  }
640 }
641 
643 {
645  G4String currentValue;
646 
647  if( command == macroPathCommand ) {
648  currentValue = UI-> GetMacroSearchPath();
649  }
650  if(command==verboseCommand)
651  {
652  currentValue = verboseCommand->ConvertToString(UI->GetVerboseLevel());
653  }
654  if(command==doublePrecCommand)
655  {
657  }
658  if(command==suppressAbortionCommand)
659  {
660  currentValue = suppressAbortionCommand->ConvertToString(G4StateManager::GetStateManager()->GetSuppressAbortion());
661  }
662  if(command==maxStoredHistCommand)
663  {
664  currentValue = maxStoredHistCommand->ConvertToString(UI->GetMaxHistSize());
665  }
666 
667  return currentValue;
668 }
669 
670 
Float_t x
Definition: compare.C:6
G4UIcmdWithoutParameter * stopStoreHistoryCommand
G4int StoI(G4String s)
void SetGuidance(const char *aGuidance)
Definition: G4UIcommand.hh:161
void RemoveAlias(const char *aliasName)
Definition: G4UImanager.cc:678
static G4bool DoublePrecisionStr()
Definition: G4UImanager.cc:187
void CreateHTML(const char *dir="/")
Definition: G4UImanager.cc:690
G4bool isNull() const
G4UIcmdWithAString * ifBatchCommand
system("rm -rf microbeam.root")
void SetMaxHistSize(G4int mx)
Definition: G4UImanager.hh:240
void StoreHistory(const char *fileName="G4history.macro")
Definition: G4UImanager.cc:561
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:466
void SetDefaultValue(G4bool defVal)
G4UIcmdWithAString * ManualCommand
G4UIcmdWithoutParameter * listAliasCommand
void SetDefaultValue(G4int defVal)
#define G4endl
Definition: G4ios.hh:61
G4UIcmdWithAString * echoCmd
G4String GetCurrentValue(G4UIcommand *command)
G4UIcmdWithAString * HTMLCommand
G4String FindMacroPath(const G4String &fname) const
Definition: G4UImanager.cc:729
void SetRange(const char *rs)
Definition: G4UIcommand.hh:125
void SetDefaultValue(const char *defVal)
void SetVerboseLevel(G4int val)
Definition: G4UImanager.hh:227
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:73
static G4bool GetNewBoolValue(const char *paramString)
void SetParameterRange(const char *theRange)
void SetParameter(G4UIparameter *const newParameter)
Definition: G4UIcommand.hh:152
G4UIcmdWithAString * unaliasCommand
G4String SolveAlias(const char *aCmd)
Definition: G4UImanager.cc:411
void SetDefaultValue(const char *theDefaultValue)
G4int GetMaxHistSize() const
Definition: G4UImanager.hh:242
G4UIcmdWithAnInteger * verboseCommand
double G4double
Definition: G4Types.hh:76
bool G4bool
Definition: G4Types.hh:79
G4String GetCurrentValues(const char *aCommand)
Definition: G4UImanager.cc:190
G4UIcmdWithAString * doifBatchCommand
G4UIcmdWithAString * macroPathCommand
void SetSuppressAbortion(G4int i)
void SetAlias(const char *aliasLine)
Definition: G4UImanager.cc:659
G4GLOB_DLL std::ostream G4cerr
void ListAlias()
Definition: G4UImanager.cc:685
static G4String ConvertToString(G4bool boolVal)
Definition: G4UIcommand.cc:374
void ListCommands(const char *direc)
Definition: G4UImanager.cc:586
G4UIcmdWithAnInteger * suppressAbortionCommand
int G4int
Definition: G4Types.hh:78
G4UIcmdWithAString * doifInteractiveCommand
static G4int InSession()
Definition: G4UIsession.hh:69
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
G4UIcmdWithABool * doublePrecCommand
G4int GetVerboseLevel() const
Definition: G4UImanager.hh:229
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
static G4int GetNewIntValue(const char *paramString)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
G4UIcmdWithAString * shellCommand
void ForeachS(const char *valueList)
Definition: G4UImanager.cc:365
G4UIcmdWithAString * ifInteractiveCommand
G4UIcmdWithAString * getEnvCmd
G4double StoD(G4String s)
G4UIcmdWithAString * historyCommand
G4GLOB_DLL std::ostream G4cout
G4UIcmdWithAString * ExecuteCommand
G4UIcmdWithAnInteger * maxStoredHistCommand
void SetParameterCandidates(const char *theString)
G4UIdirectory * controlDirectory
static void UseDoublePrecisionStr(G4bool val)
Definition: G4UImanager.cc:185
void ExecuteMacroFile(const char *fileName)
Definition: G4UImanager.cc:312
void LoopS(const char *valueList)
Definition: G4UImanager.cc:321
void SetToBeBroadcasted(G4bool val)
Definition: G4UIcommand.hh:184
void SetNewValue(G4UIcommand *command, G4String newValue)
G4String DtoS(G4double a)
static G4StateManager * GetStateManager()