Geant4 11.2.2
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 ReceiveG4debug (const G4String &) override
 
G4int ReceiveG4cout (const G4String &) override
 
G4int ReceiveG4cerr (const G4String &) override
 
G4String GetCommand (G4int)
 
- Public Member Functions inherited from G4VBasicShell
 G4VBasicShell ()
 
 ~G4VBasicShell () override
 
- Public Member Functions inherited from G4UIsession
 G4UIsession ()
 
 G4UIsession (G4int iBatch)
 
 ~G4UIsession () override
 
G4int GetLastReturnCode () const
 
- Public Member Functions inherited from G4coutDestination
 G4coutDestination ()=default
 
virtual ~G4coutDestination ()=default
 
void AddDebugTransformer (const Transformer &t)
 
void AddDebugTransformer (Transformer &&t)
 
void AddCoutTransformer (const Transformer &t)
 
void AddCoutTransformer (Transformer &&t)
 
void AddCerrTransformer (const Transformer &t)
 
void AddCerrTransformer (Transformer &&t)
 
virtual void ResetTransformers ()
 
G4int ReceiveG4debug_ (const G4String &msg)
 
G4int ReceiveG4cout_ (const G4String &msg)
 
G4int ReceiveG4cerr_ (const G4String &msg)
 
- Public Member Functions inherited from G4VInteractiveSession
 G4VInteractiveSession ()
 
virtual ~G4VInteractiveSession ()
 
virtual void AddIcon (const char *, const char *, const char *, const char *)
 
virtual void DefaultIcons (bool)
 
virtual void SetOutputStyle (const char *, const char *)
 
virtual void NativeMenu (bool)
 
virtual void ClearMenu ()
 
virtual void UpdateSceneTree (const G4SceneTreeItem &)
 
void AddInteractor (G4String, G4Interactor)
 
G4Interactor GetInteractor (G4String)
 
const std::map< G4String, OutputStyle > & GetOutputStyles () const
 

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 &)
 
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 Member Functions inherited from G4VInteractiveSession
void SetStyleUtility (const G4String &destination, const G4String &style)
 
- Protected Attributes inherited from G4UIsession
G4int ifBatch = 0
 
G4int lastRC = 0
 
- Protected Attributes inherited from G4coutDestination
std::vector< TransformertransformersDebug
 
std::vector< TransformertransformersCout
 
std::vector< TransformertransformersCerr
 
- Protected Attributes inherited from G4VInteractiveSession
std::map< G4String, OutputStylefOutputStyles
 
- 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 62 of file G4UIWin32.cc.

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

◆ ~G4UIWin32()

G4UIWin32::~G4UIWin32 ( )
override

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

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

Definition at line 180 of file G4UIWin32.cc.

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

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 374 of file G4UIWin32.cc.

375{
376 if ((a_menu != nullptr) && (a_label != nullptr) && (a_command != nullptr)) {
377 HMENU hMenu = (HMENU)GetInteractor(a_menu);
378 actionIdentifier++;
379 commands[actionIdentifier] = a_command;
380 AppendMenuA(hMenu, MF_STRING, actionIdentifier, a_label);
381 }
382}
G4Interactor GetInteractor(G4String)

◆ AddMenu()

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

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

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

Reimplemented from G4VInteractiveSession.

Definition at line 360 of file G4UIWin32.cc.

361{
362 if (a_name != nullptr) {
363 HMENU hMenu = CreatePopupMenu();
364 AppendMenuA(menuBar, MF_POPUP, (UINT_PTR)hMenu, a_label);
365 AddInteractor(a_name, (G4Interactor)hMenu);
366 DrawMenuBar(fHWndMainWindow);
367 }
368}

◆ GetCommand()

G4String G4UIWin32::GetCommand ( G4int a_id)

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

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

Definition at line 388 of file G4UIWin32.cc.

388{ return commands[a_id]; }

◆ PauseSessionStart()

void G4UIWin32::PauseSessionStart ( const G4String & a_state)
overridevirtual

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

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

Implements G4VBasicShell.

Definition at line 248 of file G4UIWin32.cc.

249{
250 if (a_state == "G4_pause> ") {
251 SecondaryLoop("Pause, type continue to exit this state");
252 }
253
254 if (a_state == "EndOfEvent") {
255 // Picking with feed back in event data Done here !!!
256 SecondaryLoop("End of event, type continue to exit this state");
257 }
258}

◆ Prompt()

void G4UIWin32::Prompt ( const G4String & a_prompt)

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

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

Definition at line 236 of file G4UIWin32.cc.

236{}

Referenced by SessionStart().

◆ ReceiveG4cerr()

G4int G4UIWin32::ReceiveG4cerr ( const G4String & a_string)
overridevirtual

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

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

Reimplemented from G4UIsession.

Definition at line 312 of file G4UIWin32.cc.

313{
314 // Geant4 uses UNIX's style for new lines (\n)
315 // we must convert them to Windows' style (\r\n)
316 G4String str = ConvertNewLines(a_string);
317
318 AddText((LPSTR)str.data());
319
320 return 0;
321}

◆ ReceiveG4cout()

G4int G4UIWin32::ReceiveG4cout ( const G4String & a_string)
overridevirtual

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

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

Reimplemented from G4UIsession.

Definition at line 297 of file G4UIWin32.cc.

298{
299 // Geant4 uses UNIX's style for new lines (\n)
300 // we must convert them to Windows' style (\r\n)
301 G4String str = ConvertNewLines(a_string);
302
303 AddText((LPSTR)str.data());
304
305 return 0;
306}

◆ ReceiveG4debug()

G4int G4UIWin32::ReceiveG4debug ( const G4String & a_string)
overridevirtual

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

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

Reimplemented from G4UIsession.

Definition at line 282 of file G4UIWin32.cc.

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

◆ SessionStart()

G4UIsession * G4UIWin32::SessionStart ( )
overridevirtual

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

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

Implements G4VBasicShell.

Definition at line 209 of file G4UIWin32.cc.

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

◆ SessionTerminate()

void G4UIWin32::SessionTerminate ( )

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

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

Definition at line 242 of file G4UIWin32.cc.

242{}

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