Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4UIExecutive Class Reference

#include <G4UIExecutive.hh>

Public Member Functions

 G4UIExecutive (G4int argc, char **argv, const G4String &type="")
 
 ~G4UIExecutive ()
 
G4UIsessionGetSession () const
 
G4bool IsGUI () const
 
void SetVerbose (G4bool val)
 
void SetPrompt (const G4String &prompt)
 
void SetLsColor (TermColorIndex dirColor, TermColorIndex cmdColor)
 
void SessionStart ()
 

Detailed Description

Definition at line 59 of file G4UIExecutive.hh.

Constructor & Destructor Documentation

◆ G4UIExecutive()

G4UIExecutive::G4UIExecutive ( G4int  argc,
char **  argv,
const G4String type = "" 
)

Definition at line 78 of file G4UIExecutive.cc.

79 : selected(kNone), session(NULL), shell(NULL), isGUI(false), verbose(true)
80{
81 if ( verbose ) {
82 G4cout << "Available UI session types: [ ";
83 if ( qt_build ) G4cout << "Qt, ";
84 if ( xm_build ) G4cout << "Xm, ";
85 if ( win32_build) G4cout << "Win32, ";
86 if (tcsh_build ) G4cout << "tcsh, ";
87 G4cout << "csh ]" << G4endl;
88 }
89
90 // selecting session type...
91 // 1st priority : in case argumant specified
92 G4String stype = G4StrUtil::to_lower_copy(type); // session type is case-insensitive.
93 if (type != "") SelectSessionByArg(stype);
94
95 // 2nd priority : refer environment variables (as backword compatibility)
96 if ( selected == kNone ) SelectSessionByEnv();
97
98 // 3rd priority : refer $HOME/.g4session
99 if ( selected == kNone ) {
100 G4String appinput = argv[0];
101 G4String appname = "";
102 size_t islash = appinput.find_last_of("/\\");
103 if (islash == G4String::npos)
104 appname = appinput;
105 else
106 appname = appinput.substr(islash+1, appinput.size()-islash-1);
107
108 SelectSessionByFile(appname);
109 }
110
111 // 4th, best guess of session type
112 if ( selected == kNone) SelectSessionByBestGuess();
113
114 // instantiate a session...
115 switch ( selected ) {
116 case kQt:
117#if defined(G4UI_BUILD_QT_SESSION)
118 session = new G4UIQt(argc, argv);
119 isGUI = true;
120#endif
121 break;
122 case kXm:
123#if defined(G4UI_BUILD_XM_SESSION)
124 session = new G4UIXm(argc, argv);
125 isGUI = true;
126#endif
127 break;
128 case kWin32:
129#if defined(G4UI_BUILD_WIN32_SESSION)
130 DISCARD_PARAMETER(argc);
131 DISCARD_PARAMETER(argv);
132 session = new G4UIWin32();
133 isGUI = true;
134#endif
135 break;
136 case kTcsh:
137#if !(defined(WIN32) || defined(__MINGW32__))
138 DISCARD_PARAMETER(argc);
139 DISCARD_PARAMETER(argv);
140 shell = new G4UItcsh;
141 session = new G4UIterminal(shell);
142#endif
143 break;
144 case kCsh:
145 DISCARD_PARAMETER(argc);
146 DISCARD_PARAMETER(argv);
147 shell = new G4UIcsh;
148 session = new G4UIterminal(shell);
149 default:
150 break;
151 }
152
153 // fallback (csh)
154 if ( session == NULL ) {
155 G4Exception("G4UIExecutive::G4UIExecutive()",
156 "UI0002",
158 "Specified session type is not build in your system,\n"
159 "or no session type is specified.\n"
160 "A fallback session type is used.");
161
162 selected = kCsh;
163 DISCARD_PARAMETER(argc);
164 DISCARD_PARAMETER(argv);
165 shell = new G4UIcsh;
166 session = new G4UIterminal(shell);
167 }
168
169 TIMEMORY_INIT(argc, argv);
170}
@ JustWarning
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:59
#define TIMEMORY_INIT(...)
Definition: G4TiMemory.hh:108
#define DISCARD_PARAMETER(p)
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
Definition: G4UIXm.hh:60
G4String to_lower_copy(G4String str)
Return lowercased copy of string.

◆ ~G4UIExecutive()

G4UIExecutive::~G4UIExecutive ( )

Definition at line 173 of file G4UIExecutive.cc.

174{
175 delete session;
176}

Member Function Documentation

◆ GetSession()

G4UIsession * G4UIExecutive::GetSession ( ) const
inline

Definition at line 95 of file G4UIExecutive.hh.

96{
97 return session;
98}

◆ IsGUI()

G4bool G4UIExecutive::IsGUI ( ) const
inline

Definition at line 100 of file G4UIExecutive.hh.

101{
102 return isGUI;
103}

◆ SessionStart()

void G4UIExecutive::SessionStart ( )

Definition at line 276 of file G4UIExecutive.cc.

277{
279}

Referenced by SessionStart().

◆ SetLsColor()

void G4UIExecutive::SetLsColor ( TermColorIndex  dirColor,
TermColorIndex  cmdColor 
)

Definition at line 269 of file G4UIExecutive.cc.

271{
272 if(shell) shell-> SetLsColor(dirColor, cmdColor);
273}
void SetLsColor(TermColorIndex dirColor, TermColorIndex cmdColor)

Referenced by SetLsColor().

◆ SetPrompt()

void G4UIExecutive::SetPrompt ( const G4String prompt)

Definition at line 263 of file G4UIExecutive.cc.

264{
265 if(shell) shell-> SetPrompt(prompt);
266}
void SetPrompt(const G4String &prompt)

Referenced by SetPrompt().

◆ SetVerbose()

void G4UIExecutive::SetVerbose ( G4bool  val)
inline

Definition at line 105 of file G4UIExecutive.hh.

106{
107 verbose = val;
108}

The documentation for this class was generated from the following files: