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