Geant4 10.7.0
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 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 90 of file G4UIExecutive.cc.

91 : selected(kNone), session(NULL), shell(NULL), isGUI(false)
92{
93 G4cout << "Available UI session types: [ ";
94 if ( qt_build ) G4cout << "Qt, ";
95 if ( xm_build ) G4cout << "Xm, ";
96 if ( win32_build) G4cout << "Win32, ";
97 if ( wt_build ) G4cout << "Wt, ";
98 G4cout << "GAG, ";
99 if (tcsh_build ) G4cout << "tcsh, ";
100 G4cout << "csh ]" << G4endl;
101
102 // selecting session type...
103 // 1st priority : in case argumant specified
104 G4String stype = type;
105 stype.toLower(); // session type is case-insensitive.
106 if (type != "") SelectSessionByArg(stype);
107
108 // 2nd priority : refer environment variables (as backword compatibility)
109 if ( selected == kNone ) SelectSessionByEnv();
110
111 // 3rd priority : refer $HOME/.g4session
112 if ( selected == kNone ) {
113 G4String appinput = argv[0];
114 G4String appname = "";
115 size_t islash = appinput.find_last_of("/\\");
116 if (islash == G4String::npos)
117 appname = appinput;
118 else
119 appname = appinput(islash+1, appinput.size()-islash-1);
120
121 SelectSessionByFile(appname);
122 }
123
124 // 4th, best guess of session type
125 if ( selected == kNone) SelectSessionByBestGuess();
126
127 // instantiate a session...
128 switch ( selected ) {
129 case kQt:
130#if defined(G4UI_BUILD_QT_SESSION)
131 session = new G4UIQt(argc, argv);
132 isGUI = true;
133#endif
134 break;
135 case kXm:
136#if defined(G4UI_BUILD_XM_SESSION)
137 session = new G4UIXm(argc, argv);
138 isGUI = true;
139#endif
140 break;
141 case kWin32:
142#if defined(G4UI_BUILD_WIN32_SESSION)
143 DISCARD_PARAMETER(argc);
144 DISCARD_PARAMETER(argv);
145 session = new G4UIWin32();
146 isGUI = true;
147#endif
148 break;
149 case kWt:
150#if defined(G4UI_BUILD_WT_SESSION)
151 session = new G4UIWt(argc, argv);
152 isGUI = true;
153#endif
154 break;
155 case kGag:
156 DISCARD_PARAMETER(argc);
157 DISCARD_PARAMETER(argv);
158 session = new G4UIGAG();
159 isGUI = true;
160 break;
161 case kTcsh:
162#ifndef WIN32
163 DISCARD_PARAMETER(argc);
164 DISCARD_PARAMETER(argv);
165 shell = new G4UItcsh;
166 session = new G4UIterminal(shell);
167#endif
168 break;
169 case kCsh:
170 DISCARD_PARAMETER(argc);
171 DISCARD_PARAMETER(argv);
172 shell = new G4UIcsh;
173 session = new G4UIterminal(shell);
174 default:
175 break;
176 }
177
178 // fallback (csh)
179 if ( session == NULL ) {
180 G4Exception("G4UIExecutive::G4UIExecutive()",
181 "UI0002",
183 "Specified session type is not build in your system,\n"
184 "or no session type is specified.\n"
185 "A fallback session type is used.");
186
187 selected = kCsh;
188 DISCARD_PARAMETER(argc);
189 DISCARD_PARAMETER(argv);
190 shell = new G4UIcsh;
191 session = new G4UIterminal(shell);
192 }
193
194 TIMEMORY_INIT(argc, argv);
195}
@ JustWarning
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
#define TIMEMORY_INIT(...)
Definition: G4TiMemory.hh:108
#define DISCARD_PARAMETER(p)
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
void toLower()

◆ ~G4UIExecutive()

G4UIExecutive::~G4UIExecutive ( )

Definition at line 198 of file G4UIExecutive.cc.

199{
200 if ( selected != kWt ) delete session;
201}

Member Function Documentation

◆ GetSession()

G4UIsession * G4UIExecutive::GetSession ( ) const
inline

Definition at line 91 of file G4UIExecutive.hh.

92{
93 return session;
94}

◆ IsGUI()

G4bool G4UIExecutive::IsGUI ( ) const
inline

Definition at line 96 of file G4UIExecutive.hh.

97{
98 return isGUI;
99}

◆ SessionStart()

void G4UIExecutive::SessionStart ( )

Definition at line 307 of file G4UIExecutive.cc.

308{
309 session-> SessionStart();
310}

Referenced by SessionStart().

◆ SetLsColor()

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

Definition at line 300 of file G4UIExecutive.cc.

302{
303 if(shell) shell-> SetLsColor(dirColor, cmdColor);
304}
void SetLsColor(TermColorIndex dirColor, TermColorIndex cmdColor)

Referenced by SetLsColor().

◆ SetPrompt()

void G4UIExecutive::SetPrompt ( const G4String prompt)

Definition at line 294 of file G4UIExecutive.cc.

295{
296 if(shell) shell-> SetPrompt(prompt);
297}
void SetPrompt(const G4String &prompt)

Referenced by SetPrompt().


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