Geant4-11
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// G4UIcontrolMessenger
27//
28// Author: Makoto Asai, SLAC - 2001
29// --------------------------------------------------------------------
30
31#include <stdlib.h>
33#include "G4UImanager.hh"
34#include "G4UIdirectory.hh"
35#include "G4UIcommand.hh"
36#include "G4UIparameter.hh"
37#include "G4UIcmdWithAString.hh"
38#include "G4UIcmdWithABool.hh"
41#include "G4UIaliasList.hh"
42#include "G4StateManager.hh"
43#include "G4UIsession.hh"
44#include "G4Tokenizer.hh"
45
46#include "G4ios.hh"
47
48// --------------------------------------------------------------------
50{
51 controlDirectory = new G4UIdirectory("/control/");
52 controlDirectory->SetGuidance("UI control commands.");
53
54 macroPathCommand = new G4UIcmdWithAString("/control/macroPath", this);
55 macroPathCommand->SetGuidance("Set macro search path"
56 " with colon-separated list.");
57 macroPathCommand->SetParameterName("path", false);
58
59 ExecuteCommand = new G4UIcmdWithAString("/control/execute", this);
60 ExecuteCommand->SetGuidance("Execute a macro file.");
61 ExecuteCommand->SetParameterName("fileName", false);
63
64 loopCommand = new G4UIcommand("/control/loop", this);
65 loopCommand->SetGuidance("Execute a macro file more than once.");
66 loopCommand->SetGuidance("Loop counter can be used as an aliased variable.");
67 G4UIparameter* param1 = new G4UIparameter("macroFile", 's', false);
69 G4UIparameter* param2 = new G4UIparameter("counterName", 's', false);
71 G4UIparameter* param3 = new G4UIparameter("initialValue", 'd', false);
73 G4UIparameter* param4 = new G4UIparameter("finalValue", 'd', false);
75 G4UIparameter* param5 = new G4UIparameter("stepSize", 'd', true);
76 param5->SetDefaultValue(1.0);
79
80 foreachCommand = new G4UIcommand("/control/foreach", this);
81 foreachCommand->SetGuidance("Execute a macro file more than once.");
83 "Loop counter can be used as an aliased variable.");
84 foreachCommand->SetGuidance("Values must be separated by a space.");
85 G4UIparameter* param6 = new G4UIparameter("macroFile", 's', false);
87 G4UIparameter* param7 = new G4UIparameter("counterName", 's', false);
89 G4UIparameter* param8 = new G4UIparameter("valueList", 's', false);
92
94 new G4UIcmdWithAnInteger("/control/suppressAbortion", this);
96 "Suppress the program abortion caused by G4Exception.");
98 "Suppression level = 0 : no suppression");
100 " = 1 : suppress during EventProc state");
102 " = 2 : full suppression, i.e. no abortion by "
103 "G4Exception");
105 "When abortion is suppressed, you will get error messages issued by "
106 "G4Exception,");
108 "and there is NO guarantee for the correct result after the G4Exception "
109 "error message.");
111 suppressAbortionCommand->SetRange("level >= 0 && level <= 2");
113
114 verboseCommand = new G4UIcmdWithAnInteger("/control/verbose", this);
115 verboseCommand->SetGuidance("Applied command will also be shown on screen.");
116 verboseCommand->SetGuidance("This command is useful with MACRO file.");
117 verboseCommand->SetGuidance(" 0 : silent");
118 verboseCommand->SetGuidance(" 1 : only the valid commands are shown.");
119 verboseCommand->SetGuidance(" 2 : comment lines are also shown (default).");
120 verboseCommand->SetParameterName("switch", true);
121 verboseCommand->SetRange("switch >= 0 && switch <=2");
123
124 doublePrecCommand = new G4UIcmdWithABool("/control/useDoublePrecision", this);
126 "Use double precision for printing out the current parameter value(s).");
127 doublePrecCommand->SetParameterName("useDoublePrecision", true);
129
130 historyCommand = new G4UIcmdWithAString("/control/saveHistory", this);
131 historyCommand->SetGuidance("Store command history to a file.");
132 historyCommand->SetGuidance("Defaul file name is G4history.macro.");
133 historyCommand->SetParameterName("fileName", true);
134 historyCommand->SetDefaultValue("G4History.macro");
136
138 new G4UIcmdWithoutParameter("/control/stopSavingHistory", this);
139 stopStoreHistoryCommand->SetGuidance("Stop saving history file.");
141
142 aliasCommand = new G4UIcommand("/control/alias", this);
143 aliasCommand->SetGuidance("Set an alias.");
144 aliasCommand->SetGuidance("String can be aliased by this command.");
145 aliasCommand->SetGuidance("The string may contain one or more spaces,");
147 "the string must be enclosed by double quotes (\").");
148 aliasCommand->SetGuidance("To use an alias, enclose the alias name with");
149 aliasCommand->SetGuidance("parenthesis \"{\" and \"}\".");
150 G4UIparameter* aliasNameParam = new G4UIparameter("aliasName", 's', false);
151 aliasCommand->SetParameter(aliasNameParam);
152 G4UIparameter* aliasValueParam = new G4UIparameter("aliasValue", 's', false);
153 aliasCommand->SetParameter(aliasValueParam);
154
155 unaliasCommand = new G4UIcmdWithAString("/control/unalias", this);
156 unaliasCommand->SetGuidance("Remove an alias.");
157 unaliasCommand->SetParameterName("aliasName", false);
158
159 listAliasCommand = new G4UIcmdWithoutParameter("/control/listAlias", this);
160 listAliasCommand->SetGuidance("List aliases.");
161
162 getEnvCmd = new G4UIcmdWithAString("/control/getEnv", this);
164 "Get a shell environment variable and define it as an alias.");
166
167 getValCmd = new G4UIcommand("/control/getVal", this);
169 "Get the current value of the UI command and define it as an alias.");
171 "Command is ignored if the UI command does not support GetCurrentValue().");
172 getValCmd->SetGuidance(" Syntax : <alias_name> <UI_command> <iIdx>");
173 G4UIparameter* aliName = new G4UIparameter("alias_name", 's', false);
174 getValCmd->SetParameter(aliName);
175 G4UIparameter* comName = new G4UIparameter("UI_command", 's', false);
176 getValCmd->SetParameter(comName);
177 G4UIparameter* iIdxParam = new G4UIparameter("iIdx", 'i', true);
178 iIdxParam->SetDefaultValue(0);
179 getValCmd->SetParameter(iIdxParam);
181
182 echoCmd = new G4UIcmdWithAString("/control/echo", this);
183 echoCmd->SetGuidance("Display the valuerameter string.");
184 echoCmd->SetGuidance("If alias is contained, it is converted to the aliased value.");
185
186 shellCommand = new G4UIcmdWithAString("/control/shell", this);
187 shellCommand->SetGuidance("Execute a (Unix) SHELL command.");
189
190 ManualCommand = new G4UIcmdWithAString("/control/manual", this);
191 ManualCommand->SetGuidance("Display all of sub-directories and commands.");
192 ManualCommand->SetGuidance("Directory path should be given by FULL-PATH.");
193 ManualCommand->SetParameterName("dirPath", true);
196
197 HTMLCommand = new G4UIcmdWithAString("/control/createHTML", this);
199 "Generate HTML files for all of sub-directories and commands.");
200 HTMLCommand->SetGuidance("Directory path should be given by FULL-PATH.");
201 HTMLCommand->SetParameterName("dirPath", true);
204
206 new G4UIcmdWithAnInteger("/control/maximumStoredHistory", this);
208 "Set maximum number of stored UI commands.");
211
212 ifCommand = new G4UIcommand("/control/if", this);
213 ifCommand->SetGuidance("Execute a macro file if the expression is true.");
214 ifCommand->SetGuidance(" Syntax : <double> <comp> <double> <macro_file>");
215 G4UIparameter* leftParam = new G4UIparameter("left", 'd', false);
216 ifCommand->SetParameter(leftParam);
217 G4UIparameter* compParam = new G4UIparameter("comp", 's', false);
218 compParam->SetParameterCandidates("> >= < <= == !=");
219 ifCommand->SetParameter(compParam);
220 G4UIparameter* rightParam = new G4UIparameter("right", 'd', false);
221 ifCommand->SetParameter(rightParam);
222 G4UIparameter* macroFileParam = new G4UIparameter("macroFile", 's', false);
223 ifCommand->SetParameter(macroFileParam);
225
226 doifCommand = new G4UIcommand("/control/doif", this);
227 doifCommand->SetGuidance("Execute a UI command if the expression is true.");
228 doifCommand->SetGuidance(" Syntax : <double> <comp> <double> <UI_command>");
229 G4UIparameter* doleftParam = new G4UIparameter("left", 'd', false);
230 doifCommand->SetParameter(doleftParam);
231 G4UIparameter* docompParam = new G4UIparameter("comp", 's', false);
232 docompParam->SetParameterCandidates("> >= < <= == !=");
233 doifCommand->SetParameter(docompParam);
234 G4UIparameter* dorightParam = new G4UIparameter("right", 'd', false);
235 doifCommand->SetParameter(dorightParam);
236 G4UIparameter* comParam = new G4UIparameter("UI_command", 's', false);
237 doifCommand->SetParameter(comParam);
239
240 addCommand = new G4UIcommand("/control/add", this);
241 addCommand->SetGuidance("Define a new alias as the sum of two values.");
242 addCommand->SetGuidance(" Syntax : <new_alias> <value1> <value2>");
244 " <new_alias> may be an already existing alias. If it is the case,");
245 addCommand->SetGuidance(" aliased value is alternated.");
246 G4UIparameter* newAlias1 = new G4UIparameter("new_alias", 's', false);
247 addCommand->SetParameter(newAlias1);
248 G4UIparameter* val1a = new G4UIparameter("value1", 'd', false);
249 addCommand->SetParameter(val1a);
250 G4UIparameter* val1b = new G4UIparameter("value2", 'd', false);
251 addCommand->SetParameter(val1b);
253
254 subtractCommand = new G4UIcommand("/control/subtract", this);
256 "Define a new alias as the subtraction of two values.");
257 subtractCommand->SetGuidance(" Syntax : <new_alias> <value1> <value2>");
259 " <new_alias> may be an already existing alias. If it is the case,");
260 subtractCommand->SetGuidance(" aliased value is alternated.");
261 G4UIparameter* newAlias2 = new G4UIparameter("new_alias", 's', false);
262 subtractCommand->SetParameter(newAlias2);
263 G4UIparameter* val2a = new G4UIparameter("value1", 'd', false);
265 G4UIparameter* val2b = new G4UIparameter("value2", 'd', false);
268
269 multiplyCommand = new G4UIcommand("/control/multiply", this);
271 "Define a new alias as the multiplication of two values.");
272 multiplyCommand->SetGuidance(" Syntax : <new_alias> <value1> <value2>");
274 " <new_alias> may be an already existing alias. If it is the case,");
275 multiplyCommand->SetGuidance(" aliased value is alternated.");
276 G4UIparameter* newAlias3 = new G4UIparameter("new_alias", 's', false);
277 multiplyCommand->SetParameter(newAlias3);
278 G4UIparameter* val3a = new G4UIparameter("value1", 'd', false);
280 G4UIparameter* val3b = new G4UIparameter("value2", 'd', false);
283
284 divideCommand = new G4UIcommand("/control/divide", this);
286 "Define a new alias as the division of two values.");
287 divideCommand->SetGuidance(" Syntax : <new_alias> <value1> <value2>");
289 " <new_alias> may be an already existing alias. If it is the case,");
290 divideCommand->SetGuidance(" aliased value is alternated.");
291 G4UIparameter* newAlias4 = new G4UIparameter("new_alias", 's', false);
292 divideCommand->SetParameter(newAlias4);
293 G4UIparameter* val4a = new G4UIparameter("value1", 'd', false);
295 G4UIparameter* val4b = new G4UIparameter("value2", 'd', false);
296 val4b->SetParameterRange("value2 != 0.");
299
300 remainderCommand = new G4UIcommand("/control/remainder", this);
302 "Define a new alias as the remainder of two values.");
303 remainderCommand->SetGuidance(" Syntax : <new_alias> <value1> <value2>");
305 " <new_alias> may be an already existing alias. If it is the case,");
306 remainderCommand->SetGuidance(" aliased value is alternated.");
307 G4UIparameter* newAlias5 = new G4UIparameter("new_alias", 's', false);
308 remainderCommand->SetParameter(newAlias5);
309 G4UIparameter* val5a = new G4UIparameter("value1", 'i', false);
311 G4UIparameter* val5b = new G4UIparameter("value2", 'i', false);
312 val4b->SetParameterRange("value2 != 0");
315
316 strifCommand = new G4UIcommand("/control/strif", this);
317 strifCommand->SetGuidance("Execute a macro file if the expression is true.");
318 strifCommand->SetGuidance(" Syntax : <string> <comp> <string> <macro_file>");
319 G4UIparameter* strleftParam = new G4UIparameter("left", 's', false);
320 strifCommand->SetParameter(strleftParam);
321 G4UIparameter* strcompParam = new G4UIparameter("comp", 's', false);
322 strcompParam->SetParameterCandidates("== !=");
323 strifCommand->SetParameter(strcompParam);
324 G4UIparameter* strrightParam = new G4UIparameter("right", 's', false);
325 strifCommand->SetParameter(strrightParam);
326 G4UIparameter* strmacroFileParam = new G4UIparameter("macroFile", 's', false);
327 strifCommand->SetParameter(strmacroFileParam);
329
330 strdoifCommand = new G4UIcommand("/control/strdoif", this);
332 "Execute a UI command if the expression is true.");
334 " Syntax : <string> <comp> <string> <UI_command>");
335 G4UIparameter* strdoleftParam = new G4UIparameter("left", 's', false);
336 strdoifCommand->SetParameter(strdoleftParam);
337 G4UIparameter* strdocompParam = new G4UIparameter("comp", 's', false);
338 strdocompParam->SetParameterCandidates("== !=");
339 strdoifCommand->SetParameter(strdocompParam);
340 G4UIparameter* strdorightParam = new G4UIparameter("right", 's', false);
341 strdoifCommand->SetParameter(strdorightParam);
342 G4UIparameter* strdomacroFileParam =
343 new G4UIparameter("UI_command", 's', false);
344 strdoifCommand->SetParameter(strdomacroFileParam);
346
347 ifBatchCommand = new G4UIcmdWithAString("/control/ifBatch", this);
349 "Execute a macro file if program is running in batch mode.");
350 ifBatchCommand->SetParameterName("macroFile", false);
352
353 ifInteractiveCommand = new G4UIcmdWithAString("/control/ifInteractive", this);
355 "Execute a macro file if program is running in interactive mode.");
356 ifInteractiveCommand->SetParameterName("macroFile", false);
358
359 doifBatchCommand = new G4UIcmdWithAString("/control/doifBatch", this);
361 "Execute a UI command if program is running in batch mode.");
362 doifBatchCommand->SetParameterName("UIcommand", false);
364
366 new G4UIcmdWithAString("/control/doifInteractive", this);
368 "Execute a UI command if program is running in interactive mode.");
369 doifInteractiveCommand->SetParameterName("UIcommand", false);
371}
372
373// --------------------------------------------------------------------
375{
376 delete macroPathCommand;
377 delete ExecuteCommand;
379 delete verboseCommand;
380 delete doublePrecCommand;
381 delete historyCommand;
383 delete ManualCommand;
384 delete aliasCommand;
385 delete unaliasCommand;
386 delete listAliasCommand;
387 delete getEnvCmd;
388 delete getValCmd;
389 delete echoCmd;
390 delete shellCommand;
391 delete loopCommand;
392 delete foreachCommand;
393 delete HTMLCommand;
395 delete ifCommand;
396 delete doifCommand;
397 delete addCommand;
398 delete subtractCommand;
399 delete multiplyCommand;
400 delete divideCommand;
401 delete remainderCommand;
402 delete strifCommand;
403 delete strdoifCommand;
404 delete ifBatchCommand;
406 delete doifBatchCommand;
408 delete controlDirectory;
409}
410
411// --------------------------------------------------------------------
413{
415
416 if(command == macroPathCommand)
417 {
418 UI->SetMacroSearchPath(newValue);
420 }
421 if(command == ExecuteCommand)
422 {
423 command->ResetFailure();
424 UI->ExecuteMacroFile(UI->FindMacroPath(newValue));
425 if(UI->GetLastReturnCode() != 0)
426 {
428 ed << "Command aborted (" << UI->GetLastReturnCode() << ")";
429 command->CommandFailed(UI->GetLastReturnCode(), ed);
430 }
431 }
432 if(command == suppressAbortionCommand)
433 {
436 }
437 if(command == verboseCommand)
438 {
440 }
441 if(command == doublePrecCommand)
442 {
445 }
446 if(command == historyCommand)
447 {
448 UI->StoreHistory(newValue);
449 }
450 if(command == stopStoreHistoryCommand)
451 {
452 UI->StoreHistory(false);
453 }
454 if(command == ManualCommand)
455 {
456 UI->ListCommands(newValue);
457 }
458 if(command == aliasCommand)
459 {
460 UI->SetAlias(newValue);
461 }
462 if(command == unaliasCommand)
463 {
464 UI->RemoveAlias(newValue);
465 }
466 if(command == listAliasCommand)
467 {
468 UI->ListAlias();
469 }
470 if(command == getEnvCmd)
471 {
472 command->ResetFailure();
473 if(std::getenv(newValue))
474 {
475 G4String st = newValue;
476 st += " ";
477 st += std::getenv(newValue);
478 UI->SetAlias(st.c_str());
479 }
480 else
481 {
483 ed << "<" << newValue
484 << "> is not defined as a shell variable. Command ignored.";
485 command->CommandFailed(ed);
486 }
487 }
488 if(command == getValCmd)
489 {
490 G4Tokenizer next(newValue);
491 G4String aliName = next();
492 G4String com = next();
493 G4String curVal = UI->GetCurrentValues(com);
494 if(!(curVal.empty()))
495 {
496 G4String theValue = curVal;
497 G4String iIdx = next();
498 if(!(iIdx.empty()))
499 {
500 G4int idx = StoI(iIdx);
501 G4Tokenizer nextVal(curVal);
502 for(G4int i = 0; i <= idx; i++)
503 {
504 theValue = nextVal();
505 }
506 }
507 G4String st = "/control/alias ";
508 st += aliName + " " + theValue;
509 UI->ApplyCommand(st);
510 }
511 }
512 if(command == echoCmd)
513 {
514 G4cout << UI->SolveAlias(newValue) << G4endl;
515 }
516 if(command == shellCommand)
517 {
518 command->ResetFailure();
519 int rc = system(newValue);
520 if(rc < 0)
521 {
523 ed << "<" << newValue
524 << "> is not a valid shell command. Command ignored.";
525 command->CommandFailed(ed);
526 }
527 }
528 if(command == loopCommand)
529 {
530 command->ResetFailure();
531 UI->LoopS(newValue);
532 if(UI->GetLastReturnCode() != 0)
533 {
535 ed << "Command aborted (" << UI->GetLastReturnCode() << ")";
536 command->CommandFailed(UI->GetLastReturnCode(), ed);
537 }
538 }
539 if(command == foreachCommand)
540 {
541 command->ResetFailure();
542 UI->ForeachS(newValue);
543 if(UI->GetLastReturnCode() != 0)
544 {
546 ed << "Command aborted (" << UI->GetLastReturnCode() << ")";
547 command->CommandFailed(UI->GetLastReturnCode(), ed);
548 }
549 }
550 if(command == HTMLCommand)
551 {
552 UI->CreateHTML(newValue);
553 }
554 if(command == maxStoredHistCommand)
555 {
557 }
558 if(command == ifCommand)
559 {
560 G4Tokenizer next(newValue);
561 G4double l = StoD(next());
562 G4String comp = next();
563 G4double r = StoD(next());
564 G4String mac = next();
565 G4bool x = false;
566 if(comp == ">")
567 x = (l > r);
568 else if(comp == ">=")
569 x = (l >= r);
570 else if(comp == "<")
571 x = (l < r);
572 else if(comp == "<=")
573 x = (l <= r);
574 else if(comp == "==")
575 x = (l == r);
576 else if(comp == "!=")
577 x = (l != r);
578 if(x)
579 UI->ExecuteMacroFile(mac);
580 }
581 if(command == doifCommand)
582 {
583 G4Tokenizer next(newValue);
584 G4double l = StoD(next());
585 G4String comp = next();
586 G4double r = StoD(next());
587
588 G4String c1 = next();
589 G4String ca;
590 while(!((ca = next()).empty()))
591 {
592 c1 += " ";
593 c1 += ca;
594 }
595 if(c1[0] == '"')
596 {
597 G4String strippedValue;
598 if(c1.back() == '"')
599 {
600 strippedValue = c1.substr(1, c1.length() - 2);
601 }
602 else
603 {
604 strippedValue = c1.substr(1, c1.length() - 1);
605 }
606 c1 = strippedValue;
607 }
608
609 G4bool x = false;
610 if(comp == ">")
611 x = (l > r);
612 else if(comp == ">=")
613 x = (l >= r);
614 else if(comp == "<")
615 x = (l < r);
616 else if(comp == "<=")
617 x = (l <= r);
618 else if(comp == "==")
619 x = (l == r);
620 else if(comp == "!=")
621 x = (l != r);
622 if(x)
623 UI->ApplyCommand(c1);
624 }
625 if(command == addCommand)
626 {
627 G4Tokenizer next(newValue);
628 G4String newA = next();
629 G4double l = StoD(next());
630 G4double r = StoD(next());
631 G4String st = "/control/alias ";
632 st += newA;
633 st += " ";
634 st += DtoS(l + r);
635 UI->ApplyCommand(st);
636 }
637 if(command == subtractCommand)
638 {
639 G4Tokenizer next(newValue);
640 G4String newA = next();
641 G4double l = StoD(next());
642 G4double r = StoD(next());
643 G4String st = "/control/alias ";
644 st += newA;
645 st += " ";
646 st += DtoS(l - r);
647 UI->ApplyCommand(st);
648 }
649 if(command == multiplyCommand)
650 {
651 G4Tokenizer next(newValue);
652 G4String newA = next();
653 G4double l = StoD(next());
654 G4double r = StoD(next());
655 G4String st = "/control/alias ";
656 st += newA;
657 st += " ";
658 st += DtoS(l * r);
659 UI->ApplyCommand(st);
660 }
661 if(command == divideCommand)
662 {
663 G4Tokenizer next(newValue);
664 G4String newA = next();
665 G4double l = StoD(next());
666 G4double r = StoD(next());
667 G4String st = "/control/alias ";
668 st += newA;
669 st += " ";
670 st += DtoS(l / r);
671 UI->ApplyCommand(st);
672 }
673 if(command == remainderCommand)
674 {
675 G4Tokenizer next(newValue);
676 G4String newA = next();
677 G4int l = StoI(next());
678 G4int r = StoI(next());
679 G4String st = "/control/alias ";
680 st += newA;
681 st += " ";
682 st += DtoS(l % r);
683 UI->ApplyCommand(st);
684 }
685 if(command == strifCommand)
686 {
687 G4Tokenizer next(newValue);
688 G4String l = next();
689 G4String comp = next();
690 G4String r = next();
691 G4String mac = next();
692 G4bool x = false;
693 if(comp == "==")
694 {
695 x = (l == r);
696 }
697 else if(comp == "!=")
698 {
699 x = (l != r);
700 }
701 if(x)
702 UI->ExecuteMacroFile(mac);
703 }
704 if(command == strdoifCommand)
705 {
706 G4Tokenizer next(newValue);
707 G4String l = next();
708 G4String comp = next();
709 G4String r = next();
710
711 G4String c1 = next();
712 G4String ca;
713 while(!((ca = next()).empty()))
714 {
715 c1 += " ";
716 c1 += ca;
717 }
718 if(c1[0] == '"')
719 {
720 G4String strippedValue;
721 if(c1.back() == '"')
722 {
723 strippedValue = c1.substr(1, c1.length() - 2);
724 }
725 else
726 {
727 strippedValue = c1.substr(1, c1.length() - 1);
728 }
729 c1 = strippedValue;
730 }
731
732 G4bool x = false;
733 if(comp == "==")
734 {
735 x = (l == r);
736 }
737 else if(comp == "!=")
738 {
739 x = (l != r);
740 }
741 if(x)
742 UI->ApplyCommand(c1);
743 }
744 if(command == ifBatchCommand)
745 {
746 if(G4UIsession::InSession() == 0)
747 UI->ExecuteMacroFile(UI->FindMacroPath(newValue));
748 }
749 if(command == ifInteractiveCommand)
750 {
751 if(G4UIsession::InSession() > 0)
752 UI->ExecuteMacroFile(UI->FindMacroPath(newValue));
753 }
754 if(command == doifBatchCommand)
755 {
756 if(G4UIsession::InSession() == 0)
757 UI->ApplyCommand(newValue);
758 }
759 if(command == doifInteractiveCommand)
760 {
761 if(G4UIsession::InSession() > 0)
762 UI->ApplyCommand(newValue);
763 }
764}
765
766// --------------------------------------------------------------------
768{
770 G4String currentValue;
771
772 if(command == macroPathCommand)
773 {
774 currentValue = UI->GetMacroSearchPath();
775 }
776 if(command == verboseCommand)
777 {
778 currentValue = verboseCommand->ConvertToString(UI->GetVerboseLevel());
779 }
780 if(command == doublePrecCommand)
781 {
782 currentValue =
784 }
785 if(command == suppressAbortionCommand)
786 {
788 G4StateManager::GetStateManager()->GetSuppressAbortion());
789 }
790 if(command == maxStoredHistCommand)
791 {
793 }
794
795 return currentValue;
796}
std::ostringstream G4ExceptionDescription
Definition: G4Exception.hh:40
double G4double
Definition: G4Types.hh:83
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
void SetSuppressAbortion(G4int i)
static G4StateManager * GetStateManager()
static G4bool GetNewBoolValue(const char *paramString)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
void SetDefaultValue(G4bool defVal)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
void SetDefaultValue(const char *defVal)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
static G4int GetNewIntValue(const char *paramString)
void SetDefaultValue(G4int defVal)
void SetToBeBroadcasted(G4bool val)
Definition: G4UIcommand.hh:172
static G4String ConvertToString(G4bool boolVal)
Definition: G4UIcommand.cc:445
void SetParameter(G4UIparameter *const newParameter)
Definition: G4UIcommand.hh:146
void SetGuidance(const char *aGuidance)
Definition: G4UIcommand.hh:156
void ResetFailure()
Definition: G4UIcommand.hh:191
void CommandFailed(G4int errCode, G4ExceptionDescription &ed)
Definition: G4UIcommand.hh:179
void SetRange(const char *rs)
Definition: G4UIcommand.hh:120
G4UIcmdWithAnInteger * maxStoredHistCommand
G4UIcmdWithoutParameter * stopStoreHistoryCommand
G4UIcmdWithAString * ExecuteCommand
G4UIcmdWithAString * unaliasCommand
G4UIcmdWithAString * doifBatchCommand
G4UIcmdWithAString * shellCommand
void SetNewValue(G4UIcommand *command, G4String newValue)
G4UIdirectory * controlDirectory
G4UIcmdWithoutParameter * listAliasCommand
G4UIcmdWithAString * doifInteractiveCommand
G4UIcmdWithAnInteger * verboseCommand
G4UIcmdWithAString * ifBatchCommand
G4UIcmdWithAString * ifInteractiveCommand
G4UIcmdWithAString * HTMLCommand
G4UIcmdWithAString * echoCmd
G4UIcmdWithAString * ManualCommand
G4UIcmdWithABool * doublePrecCommand
G4String GetCurrentValue(G4UIcommand *command)
G4UIcmdWithAString * historyCommand
G4UIcmdWithAString * getEnvCmd
G4UIcmdWithAnInteger * suppressAbortionCommand
G4UIcmdWithAString * macroPathCommand
static G4bool DoublePrecisionStr()
Definition: G4UImanager.cc:158
static void UseDoublePrecisionStr(G4bool val)
Definition: G4UImanager.cc:152
const G4String & GetMacroSearchPath() const
Definition: G4UImanager.hh:215
void ForeachS(const char *valueList)
Definition: G4UImanager.cc:365
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:485
void CreateHTML(const char *dir="/")
Definition: G4UImanager.cc:772
void LoopS(const char *valueList)
Definition: G4UImanager.cc:315
void StoreHistory(const char *fileName="G4history.macro")
Definition: G4UImanager.cc:627
void ListCommands(const char *direc)
Definition: G4UImanager.cc:660
void ExecuteMacroFile(const char *fileName)
Definition: G4UImanager.cc:303
void SetMacroSearchPath(const G4String &path)
Definition: G4UImanager.hh:214
void SetMaxHistSize(G4int mx)
Definition: G4UImanager.hh:211
G4int GetVerboseLevel() const
Definition: G4UImanager.hh:200
G4int GetLastReturnCode() const
Definition: G4UImanager.hh:254
G4String GetCurrentValues(const char *aCommand)
Definition: G4UImanager.cc:164
void SetAlias(const char *aliasLine)
Definition: G4UImanager.cc:734
G4String FindMacroPath(const G4String &fname) const
Definition: G4UImanager.cc:821
void RemoveAlias(const char *aliasName)
Definition: G4UImanager.cc:758
G4String SolveAlias(const char *aCmd)
Definition: G4UImanager.cc:424
void ListAlias()
Definition: G4UImanager.cc:766
void ParseMacroSearchPath()
Definition: G4UImanager.cc:786
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:77
G4int GetMaxHistSize() const
Definition: G4UImanager.hh:212
void SetVerboseLevel(G4int val)
Definition: G4UImanager.hh:199
G4int StoI(G4String s)
G4String DtoS(G4double a)
G4double StoD(G4String s)
void SetDefaultValue(const char *theDefaultValue)
void SetParameterRange(const char *theRange)
void SetParameterCandidates(const char *theString)
static G4int InSession()
Definition: G4UIsession.cc:68