gui
Loading...
Searching...
No Matches
rightContent.cc
Go to the documentation of this file.
1// gui
2#include "gui.h"
3
4// gemc
5#include "g4display.h"
7#include "g4dialog.h"
8#include "dbselectView.h"
9#include "gtree.h"
10#include "pmakerView.h"
11#ifdef GEMC_HAS_QTCHARTS
12#include "gAnalysisView.h"
13#endif
14#include "gemc/actions/gaction.h"
15
16// geant4
17#include "G4RunManager.hh"
18
19void GemcGUI::createRightContent(std::shared_ptr<GOptions> gopts,
21 GBoard* gb) {
22 // The stacked widget hosts all right-side pages. The left button bar selects the current index.
23 rightContent = new QStackedWidget;
24
25
26
27 // Page order must match the left button bar order so indexes remain consistent.
28 auto* setupView = new DBSelectView(gopts, dc);
29
30 // display controls
31 auto* g4display = new G4Display(gopts);
32 rightContent->addWidget(g4display);
33 auto* displayUtilities = g4display->findChild<G4DisplayUtilities*>();
34 if (displayUtilities) {
35 connect(displayUtilities, &G4DisplayUtilities::sceneOptionsChanged,
36 this, &GemcGUI::refreshVisualizationFromOptions);
37 }
38
39 // setup/systems controls
40 rightContent->addWidget(setupView);
41 connect(setupView, &DBSelectView::geometryAboutToReload,
42 this, &GemcGUI::resetVisualizationBeforeGeometryReload);
43 connect(setupView, &DBSelectView::geometryReloaded, this, &GemcGUI::refreshGeometryTree);
44
45 // gvolume controls
46 geometryTree = new GTree(gopts,
47 dc && dc->has_built_geometry()
48 ? dc->get_g4volumes_map()
49 : std::unordered_map<std::string, G4Volume*>{},
50 dc && dc->has_built_geometry()
52 : std::unordered_map<std::string, const GVolume*>{},
53 nullptr,
54 dc && dc->has_built_geometry()
56 : std::unordered_map<std::string, const GMirror*>{});
57 rightContent->addWidget(geometryTree);
58
59 // g4dialog
60 rightContent->addWidget(new G4Dialog(gopts, gb));
61
62 // generator / particle maker — share the exact same GparticlePtr objects as the generator
63 std::shared_ptr<std::vector<GparticlePtr>> sharedParticles;
64 if (auto* rm = G4RunManager::GetRunManager()) {
65 if (auto* ga = dynamic_cast<GAction*>(
66 const_cast<G4VUserActionInitialization*>(rm->GetUserActionInitialization())))
67 sharedParticles = ga->getSharedParticles();
68 }
69 rightContent->addWidget(new PmakerView(sharedParticles, gopts));
70
71 // Analyzer variables are populated from runtime records after the first GUI beamOn.
72#ifdef GEMC_HAS_QTCHARTS
73 analysisView = new GAnalysisView(analysisAccumulator, ganalysis::getOptions(gopts));
74 rightContent->addWidget(analysisView);
75#else
76 // Built without Qt6 Charts: keep the page index stable by showing a placeholder instead of the
77 // histogram view. analysisView stays nullptr, and every caller already guards on that.
78 auto* analysisPlaceholder = new QLabel(
79 QStringLiteral("The analysis view requires Qt6 Charts, which was not available when GEMC was "
80 "built.\nInstall the Qt6 Charts package and rebuild GEMC to enable live "
81 "histograms."));
82 analysisPlaceholder->setAlignment(Qt::AlignCenter);
83 analysisPlaceholder->setWordWrap(true);
84 rightContent->addWidget(analysisPlaceholder);
85#endif
86
87 // Default to the first page and update the left bar visual highlight accordingly.
88 rightContent->setCurrentIndex(0);
89 leftButtons->press_button(0);
90}
void geometryReloaded()
void geometryAboutToReload()
void sceneOptionsChanged()
std::unordered_map< std::string, const GVolume * > get_gvolumes_flat_map() const
std::unordered_map< std::string, G4Volume * > get_g4volumes_map() const
std::unordered_map< std::string, const GMirror * > get_gmirrors_flat_map() const
bool has_built_geometry() const