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

#include <G4UIWin32.hh>

+ Inheritance diagram for G4UIWin32:

Public Member Functions

 G4UIWin32 ()
 
 ~G4UIWin32 () override
 
G4UIsessionSessionStart () override
 
void AddMenu (const char *, const char *) override
 
void AddButton (const char *, const char *, const char *) override
 
void Prompt (const G4String &)
 
void SessionTerminate ()
 
void PauseSessionStart (const G4String &) override
 
G4int ReceiveG4cout (const G4String &) override
 
G4int ReceiveG4cerr (const G4String &) override
 
G4String GetCommand (G4int)
 
- Public Member Functions inherited from G4VBasicShell
 G4VBasicShell ()
 
virtual ~G4VBasicShell ()
 
virtual G4UIsessionSessionStart ()=0
 
virtual void PauseSessionStart (const G4String &Prompt)=0
 
- Public Member Functions inherited from G4UIsession
 G4UIsession ()
 
 G4UIsession (G4int iBatch)
 
 ~G4UIsession () override
 
virtual G4UIsessionSessionStart ()
 
virtual void PauseSessionStart (const G4String &Prompt)
 
G4int ReceiveG4cout (const G4String &coutString) override
 
G4int ReceiveG4cerr (const G4String &cerrString) override
 
G4int GetLastReturnCode () const
 
- Public Member Functions inherited from G4coutDestination
 G4coutDestination ()=default
 
virtual ~G4coutDestination ()=default
 
void AddCoutTransformer (const Transformer &t)
 
void AddCoutTransformer (Transformer &&t)
 
void AddCerrTransformer (const Transformer &t)
 
void AddCerrTransformer (Transformer &&t)
 
virtual void ResetTransformers ()
 
virtual G4int ReceiveG4cout (const G4String &msg)
 
virtual G4int ReceiveG4cerr (const G4String &msg)
 
G4int ReceiveG4cout_ (const G4String &msg)
 
G4int ReceiveG4cerr_ (const G4String &msg)
 
- Public Member Functions inherited from G4VInteractiveSession
 G4VInteractiveSession ()
 
virtual ~G4VInteractiveSession ()
 
virtual void AddMenu (const char *, const char *)
 
virtual void AddButton (const char *, const char *, const char *)
 
virtual void AddIcon (const char *, const char *, const char *, const char *)
 
virtual void DefaultIcons (bool)
 
virtual void OutputStyle (const char *, const char *, const char *)
 
virtual void NativeMenu (bool)
 
virtual void ClearMenu ()
 
void AddInteractor (G4String, G4Interactor)
 
G4Interactor GetInteractor (G4String)
 

Additional Inherited Members

- Public Types inherited from G4coutDestination
using Transformer = std::function< G4bool(G4String &)>
 
- Static Public Member Functions inherited from G4UIsession
static G4int InSession ()
 
- Protected Member Functions inherited from G4VBasicShell
G4String ModifyToFullPathCommand (const char *aCommandLine) const
 
G4String GetCurrentWorkingDirectory () const
 
G4bool ChangeDirectory (const char *newDir)
 
G4UIcommandTreeFindDirectory (const char *dirName) const
 
G4UIcommandFindCommand (const char *commandName) const
 
G4String Complete (const G4String &)
 
G4String FindMatchingPath (G4UIcommandTree *, const G4String &)
 
virtual void ExecuteCommand (const G4String &)
 
virtual G4bool GetHelpChoice (G4int &)=0
 
virtual void ExitHelp () const =0
 
void ApplyShellCommand (const G4String &, G4bool &, G4bool &)
 
void ShowCurrent (const G4String &) const
 
void ChangeDirectoryCommand (const G4String &)
 
void ListDirectory (const G4String &) const
 
void TerminalHelp (const G4String &)
 
- Protected Attributes inherited from G4UIsession
G4int ifBatch = 0
 
G4int lastRC = 0
 
- Protected Attributes inherited from G4coutDestination
std::vector< TransformertransformersCout
 
std::vector< TransformertransformersCerr
 
- Static Protected Attributes inherited from G4UIsession
static G4ICOMS_DLL G4int inSession = 0
 
- Static Protected Attributes inherited from G4coutDestination
static G4MTGLOB_DLL G4coutDestinationmasterG4coutDestination = nullptr
 

Detailed Description

Definition at line 91 of file G4UIWin32.hh.

Constructor & Destructor Documentation

◆ G4UIWin32()

G4UIWin32::G4UIWin32 ( )

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Definition at line 64 of file G4UIWin32.cc.

65 : fHWndMainWindow(nullptr), fHWndEditor(nullptr),
66 fHWndToolBar(nullptr), fHWndComboBox(nullptr),
67 fHWndComboEditor(nullptr), fHWndHelpTree(nullptr),
68 fHWndStatus(nullptr), menuBar(nullptr),
69 fHelp(false), fHelpChoice(0), fHistoryPos(-1) {
70
72 if (UI != nullptr) {
73 UI->SetSession(this);
74 UI->SetG4UIWindow(this);
75 }
76
77 // Ensure that the common control DLL is loaded
78 INITCOMMONCONTROLSEX commCtrls;
79 commCtrls.dwSize = sizeof(INITCOMMONCONTROLSEX);
80 commCtrls.dwICC = ICC_BAR_CLASSES | ICC_LISTVIEW_CLASSES;
81 // this loads list-view and toolbar classes.
82 InitCommonControlsEx(&commCtrls);
83
84 interactorManager = G4Win32::getInstance();
85
86 static G4bool Done = false;
87 if (!Done) {
88 WNDCLASS wc;
89 wc.style = 0;
90 wc.lpfnWndProc = (WNDPROC) G4UIWin32::MainWindowProc;
91 wc.cbClsExtra = 0;
92 wc.cbWndExtra = 0;
93 wc.hInstance = ::GetModuleHandle(nullptr);
94 wc.hIcon = LoadIcon(nullptr, IDI_APPLICATION);
95 wc.hCursor = LoadCursor(nullptr, IDC_ARROW);
96 wc.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1);
97 wc.lpszMenuName = mainClassName;
98 wc.lpszClassName = mainClassName;
99
100 if (!RegisterClass(&wc)) {
101 MessageBox(nullptr, "G4UIWin32: Win32 window registration failed!", "Error!", MB_ICONEXCLAMATION | MB_OK);
102 G4cout << "G4UIWin32: Win32 window registration failed!" << G4endl;
103 return;
104 }
105
106 Done = true;
107 }
108
109 menuBar = CreateMenu();
110
111 // Add some initial options to the menu
112 HMENU hMenu = CreatePopupMenu();
113 AppendMenu(menuBar, MF_POPUP, (UINT_PTR) hMenu, "&Geant4");
114 AddInteractor("Geant4", (G4Interactor) hMenu);
115
116 AppendMenu(hMenu, MF_STRING, ID_OPEN_MACRO, "&Open macro...");
117 AppendMenu(hMenu, MF_STRING, ID_SAVE_VIEWER_STATE, "&Save viewer state...");
118 AppendMenu(hMenu, MF_SEPARATOR, -1, "");
119 AppendMenu(hMenu, MF_STRING, ID_RUN_BEAMON, "&Beam On");
120 AppendMenu(hMenu, MF_SEPARATOR, -1, "");
121 AppendMenu(hMenu, MF_STRING, ID_EXIT_APP, "E&xit");
122
123 hMenu = CreatePopupMenu();
124 AppendMenu(menuBar, MF_POPUP, (UINT_PTR) hMenu, "&View");
125 AddInteractor("View", (G4Interactor) hMenu);
126
127 AppendMenu(hMenu, MF_STRING, ID_VIEW_SOLID, "S&olid");
128 AppendMenu(hMenu, MF_STRING, ID_VIEW_WIREFRAME, "&Wireframe");
129 AppendMenu(hMenu, MF_SEPARATOR, -1, "");
130 AppendMenu(hMenu, MF_STRING, ID_PROJ_ORTHOGRAPHIC, "&Orthographic");
131 AppendMenu(hMenu, MF_STRING, ID_PROJ_PERSPECTIVE, "P&erspective");
132 AppendMenu(hMenu, MF_SEPARATOR, -1, "");
133 AppendMenu(hMenu, MF_STRING, ID_ORIENTATION_XY, "&X-Y Plane");
134 AppendMenu(hMenu, MF_STRING, ID_ORIENTATION_XZ, "X-&Z Plane");
135 AppendMenu(hMenu, MF_STRING, ID_ORIENTATION_YZ, "&Y-Z Plane");
136 AppendMenu(hMenu, MF_STRING, ID_ORIENTATION_OBLIQUE, "&Oblique");
137
138 hMenu = CreatePopupMenu();
139 AppendMenu(menuBar, MF_POPUP, (UINT_PTR) hMenu, "&Zoom");
140 AddInteractor("Zoom", (G4Interactor) hMenu);
141
142 AppendMenu(hMenu, MF_STRING, ID_ZOOM_IN, "Zoom &In");
143 AppendMenu(hMenu, MF_STRING, ID_ZOOM_OUT, "Zoom &Out");
144
145 tmpSession = this;
146 fHWndMainWindow = ::CreateWindowEx(WS_EX_CLIENTEDGE, mainClassName, "Geant4",
147 WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
148 CW_USEDEFAULT, CW_USEDEFAULT,
149 CW_USEDEFAULT, CW_USEDEFAULT,
150 nullptr, menuBar,
151 ::GetModuleHandle(nullptr), nullptr);
152
153 if (fHWndMainWindow == nullptr) {
154 MessageBox(nullptr, "Window Creation Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK);
155 return;
156 }
157 tmpSession = nullptr;
158 ::SetWindowLongPtr(fHWndMainWindow, GWLP_USERDATA, (LONG_PTR) this);
159
160 ::SetForegroundWindow(fHWndMainWindow);
161 ::ShowWindow(fHWndMainWindow, SW_SHOWDEFAULT);
162 ::UpdateWindow(fHWndMainWindow);
163
164 if (UI != nullptr) UI->SetCoutDestination(this);
165
166// TODO: Manage multithreaded output
167//#ifdef G4MULTITHREADED
168 // explicitly request that cout/cerr messages from threads are ALSO propagated to the master.
169 //masterG4coutDestination = this;
170//#endif
171}
bool G4bool
Definition: G4Types.hh:86
#define ID_ORIENTATION_YZ
Definition: G4UIWin32.hh:65
#define ID_RUN_BEAMON
Definition: G4UIWin32.hh:55
#define ID_ORIENTATION_OBLIQUE
Definition: G4UIWin32.hh:66
#define ID_OPEN_MACRO
Definition: G4UIWin32.hh:53
#define ID_EXIT_APP
Definition: G4UIWin32.hh:52
#define ID_ZOOM_IN
Definition: G4UIWin32.hh:61
#define ID_VIEW_SOLID
Definition: G4UIWin32.hh:57
#define ID_SAVE_VIEWER_STATE
Definition: G4UIWin32.hh:54
#define ID_PROJ_ORTHOGRAPHIC
Definition: G4UIWin32.hh:59
#define ID_ZOOM_OUT
Definition: G4UIWin32.hh:62
#define ID_ORIENTATION_XY
Definition: G4UIWin32.hh:63
#define ID_PROJ_PERSPECTIVE
Definition: G4UIWin32.hh:60
#define ID_ORIENTATION_XZ
Definition: G4UIWin32.hh:64
#define ID_VIEW_WIREFRAME
Definition: G4UIWin32.hh:58
void * G4Interactor
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
void SetCoutDestination(G4UIsession *const value)
Definition: G4UImanager.cc:747
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:77
void SetSession(G4UIsession *const value)
Definition: G4UImanager.hh:190
void SetG4UIWindow(G4UIsession *const value)
Definition: G4UImanager.hh:191
void AddInteractor(G4String, G4Interactor)
static G4Win32 * getInstance()
Definition: G4Win32.cc:43

◆ ~G4UIWin32()

G4UIWin32::~G4UIWin32 ( )
override

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Definition at line 177 of file G4UIWin32.cc.

177 {
179 if (UI != nullptr) {
180 UI->SetSession(nullptr);
181 UI->SetG4UIWindow(nullptr);
182 UI->SetCoutDestination(nullptr);
183 }
184
185// TODO: Manage multithreaded output
186//#ifdef G4MULTITHREADED
187 //masterG4coutDestination = 0; // set to cout when UI is deleted
188//#endif
189
190 if (fHWndStatus != nullptr) ::SetWindowLongPtr(fHWndStatus, GWLP_USERDATA, LONG(NULL));
191 if (fHWndHelpTree != nullptr) ::SetWindowLongPtr(fHWndHelpTree, GWLP_USERDATA, LONG(NULL));
192 if (fHWndComboBox != nullptr) ::SetWindowLongPtr(fHWndComboBox, GWLP_USERDATA, LONG(NULL));
193 if (fHWndToolBar != nullptr) ::SetWindowLongPtr(fHWndToolBar, GWLP_USERDATA, LONG(NULL));
194 if (fHWndEditor != nullptr) ::SetWindowLongPtr(fHWndEditor, GWLP_USERDATA, LONG(NULL));
195 if (fHWndMainWindow != nullptr) {
196 ::SetWindowLongPtr(fHWndMainWindow, GWLP_USERDATA, LONG(NULL));
197 ::DestroyWindow(fHWndMainWindow);
198 }
199}

Member Function Documentation

◆ AddButton()

void G4UIWin32::AddButton ( const char *  a_menu,
const char *  a_label,
const char *  a_command 
)
overridevirtual

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Reimplemented from G4VInteractiveSession.

Definition at line 344 of file G4UIWin32.cc.

346 {
347
348 if ((a_menu != nullptr) && (a_label != nullptr) && (a_command != nullptr)) {
349 HMENU hMenu = (HMENU) GetInteractor(a_menu);
350 actionIdentifier++;
351 commands[actionIdentifier] = a_command;
352 AppendMenu(hMenu, MF_STRING, actionIdentifier, a_label);
353 }
354}
G4Interactor GetInteractor(G4String)

◆ AddMenu()

void G4UIWin32::AddMenu ( const char *  a_name,
const char *  a_label 
)
overridevirtual

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Reimplemented from G4VInteractiveSession.

Definition at line 331 of file G4UIWin32.cc.

331 {
332 if (a_name != nullptr) {
333 HMENU hMenu = CreatePopupMenu();
334 AppendMenu(menuBar, MF_POPUP, (UINT_PTR) hMenu, a_label);
335 AddInteractor(a_name, (G4Interactor) hMenu);
336 DrawMenuBar(fHWndMainWindow);
337 }
338}

◆ GetCommand()

G4String G4UIWin32::GetCommand ( G4int  a_id)

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Definition at line 360 of file G4UIWin32.cc.

360 {
361 return commands[a_id];
362}

◆ PauseSessionStart()

void G4UIWin32::PauseSessionStart ( const G4String a_state)
overridevirtual

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Implements G4VBasicShell.

Definition at line 241 of file G4UIWin32.cc.

241 {
242 if (a_state == "G4_pause> ") {
243 SecondaryLoop("Pause, type continue to exit this state");
244 }
245
246 if (a_state == "EndOfEvent") {
247 // Picking with feed back in event data Done here !!!
248 SecondaryLoop("End of event, type continue to exit this state");
249 }
250}

◆ Prompt()

void G4UIWin32::Prompt ( const G4String a_prompt)

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Definition at line 229 of file G4UIWin32.cc.

229{}

Referenced by SessionStart().

◆ ReceiveG4cerr()

G4int G4UIWin32::ReceiveG4cerr ( const G4String a_string)
overridevirtual

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Reimplemented from G4UIsession.

Definition at line 287 of file G4UIWin32.cc.

287 {
288 // Geant4 uses UNIX's style for new lines (\n)
289 // we must convert them to Windows' style (\r\n)
290 G4String str = ConvertNewLines(a_string);
291
292 AddText((LPSTR) str.data());
293
294 return 0;
295}

◆ ReceiveG4cout()

G4int G4UIWin32::ReceiveG4cout ( const G4String a_string)
overridevirtual

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Reimplemented from G4UIsession.

Definition at line 273 of file G4UIWin32.cc.

273 {
274 // Geant4 uses UNIX's style for new lines (\n)
275 // we must convert them to Windows' style (\r\n)
276 G4String str = ConvertNewLines(a_string);
277
278 AddText((LPSTR) str.data());
279
280 return 0;
281}

◆ SessionStart()

G4UIsession * G4UIWin32::SessionStart ( )
overridevirtual

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Implements G4VBasicShell.

Definition at line 205 of file G4UIWin32.cc.

205 {
206 if (interactorManager != nullptr) {
207 Prompt("session");
208 exitSession = false;
209
210 // TODO: Ensure that the list of commands is updated
211 // Load commands into Help Tree View
212 InitHelpTreeItems();
213
214 interactorManager->DisableSecondaryLoop();
215 void* event;
216 while ((event = interactorManager->GetEvent()) != nullptr) {
217 interactorManager->DispatchEvent(event);
218 if (exitSession) break;
219 }
220 interactorManager->EnableSecondaryLoop();
221 return this;
222 } else return this;
223}
void Prompt(const G4String &)
Definition: G4UIWin32.cc:229
virtual void * GetEvent()=0

◆ SessionTerminate()

void G4UIWin32::SessionTerminate ( )

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Definition at line 235 of file G4UIWin32.cc.

235{}

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