Skip to content

Commit a633eca

Browse files
committed
board separate module, filter updated and dark background for log
1 parent 9911de9 commit a633eca

19 files changed

Lines changed: 330 additions & 264 deletions

g4dialog/g4dialog.cc

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,44 +2,19 @@
22
#include "g4dialog.h"
33
#include "g4dialog_options.h" // Provides G4DIALOG_LOGGER constant and option definitions
44
#include "tabs/gcommands.h"
5-
#include "gui_session.h"
65

7-
// geant4
8-
#include "G4UImanager.hh"
96

107

118
G4Dialog::G4Dialog(const std::shared_ptr<GOptions>& gopt, QWidget* parent) :
129
GBase(gopt, G4DIALOG_LOGGER),
1310
QWidget(parent) {
1411
auto dialogTabs = new QTabWidget;
1512

16-
gboard = new GBoard(gopt, this);
17-
auto UIM = G4UImanager::GetUIpointer();
18-
19-
gui_session = std::make_unique<GUI_Session>(gopt, gboard);
20-
UIM->SetCoutDestination(gui_session.get());
21-
2213
dialogTabs->addTab(new G4Commands(this), "Geant4 Commands");
23-
dialogTabs->addTab(gboard, "Log");
2414

2515
auto* mainLayout = new QVBoxLayout;
2616
mainLayout->addWidget(dialogTabs);
2717
setLayout(mainLayout);
2818

2919
log->debug(NORMAL, "View and Utilities tabs added.");
3020
}
31-
32-
33-
G4Dialog::~G4Dialog() {
34-
35-
// Detach G4 cout/cerr from our GUI session (avoid dangling callback)
36-
if (auto* UIM = G4UImanager::GetUIpointer()) {
37-
// If available in your G4 version, prefer checking current destination:
38-
// if (UIM->GetCoutDestination() == gui_session.get()) { ... }
39-
UIM->SetCoutDestination(nullptr);
40-
}
41-
42-
// Destroy the session *now*, before member teardown sequence
43-
gui_session.reset();
44-
45-
}

g4dialog/g4dialog.h

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
#pragma once
22

3-
// g4dialog
4-
#include "tabs/gboard.h"
5-
#include "gui_session.h"
6-
#include "g4dialog_options.h"
7-
83
// qt
94
#include <QtWidgets>
105

@@ -15,11 +10,6 @@ class G4Dialog : public GBase<G4Dialog>, public QWidget {
1510

1611
public:
1712
explicit G4Dialog(const std::shared_ptr<GOptions>& gopt, QWidget* parent = nullptr);
13+
~G4Dialog() override = default;
1814

19-
~G4Dialog() override;
20-
21-
22-
private:
23-
GBoard* gboard;
24-
std::unique_ptr<GUI_Session> gui_session;
2515
};

g4dialog/g4dialog_options.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ namespace g4dialog {
88
GOptions defineOptions() {
99

1010
GOptions goptions(G4DIALOG_LOGGER);
11-
goptions += GOptions(GBOARD_LOGGER);
1211

1312
return goptions;
1413
}

g4dialog/g4dialog_options.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
#pragma once
22

3-
// glibrary
3+
// gemc
44
#include "goptions.h"
55

66
constexpr const char* G4DIALOG_LOGGER = "g4dialog";
7-
constexpr const char* GBOARD_LOGGER = "gboard";
8-
//constexpr const char* GBOARD_LOGGER = "gboard";
97

108
namespace g4dialog {
119

g4dialog/meson.build

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,22 @@ example_source = files('examples/g4dialog_example.cc')
99

1010
verbosities = [
1111
'-verbosity.g4dialog=2',
12-
'-debug.g4dialog=true',
13-
'-verbosity.gboard=2',
14-
'-debug.gboard=true']
12+
'-debug.g4dialog=true'
13+
]
1514

1615
sources = files(
1716
'g4dialog.cc',
1817
'g4dialog_options.cc',
19-
'gui_session.cc',
2018
'tabs/gcommands.cc',
21-
'tabs/gboard.cc',
2219
)
2320

2421
headers = files(
2522
'g4dialog.h',
2623
'g4dialog_options.h',
27-
'gui_session.h',
2824
)
2925

3026
moc_headers = files(
3127
'tabs/gcommands.h',
32-
'tabs/gboard.h',
3328
)
3429

3530
examples = {

g4dialog/tabs/gboard.cc

Lines changed: 0 additions & 190 deletions
This file was deleted.

gboard/examples/gboard_example.cc

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// geant4
2+
#include "G4VisExecutive.hh"
3+
#include "G4RunManagerFactory.hh"
4+
5+
// gboard
6+
#include "gboard.h"
7+
#include "gui_session.h"
8+
9+
// qt
10+
#include <QApplication>
11+
#include <QMainWindow>
12+
#include <QTimer>
13+
14+
int main(int argc, char* argv[]) {
15+
16+
QApplication app(argc, argv);
17+
18+
auto gopts =std::make_shared<GOptions>(argc, argv, gboard::defineOptions());
19+
auto log = std::make_shared<GLogger>(gopts, SFUNCTION_NAME, GBOARD_LOGGER);
20+
21+
auto visManager = new G4VisExecutive;
22+
visManager->Initialize();
23+
24+
// main window and controls
25+
auto window = new QMainWindow();
26+
window->setWindowTitle(QString::fromUtf8("displayUI example"));
27+
28+
auto* gboard = new GBoard(gopts, window);
29+
window->setCentralWidget(gboard);
30+
31+
auto gui_session = std::make_unique<GUI_Session>(gopts, gboard);
32+
33+
log->info(0, "gboard example started");
34+
int ret = EXIT_SUCCESS;
35+
36+
if (gopts->getSwitch("gui")) {
37+
window->show();
38+
39+
// --- quit after 0.5 s ---
40+
QTimer::singleShot(500, &app, &QCoreApplication::quit); // ⬅️ key line :contentReference[oaicite:0]{index=0}
41+
42+
ret = QApplication::exec(); // returns when the timer fires
43+
}
44+
45+
delete gboard;
46+
delete window;
47+
delete visManager;
48+
49+
return ret;
50+
51+
}

0 commit comments

Comments
 (0)