4#ifdef GEMC_HAS_QTCHARTS
5#include "gAnalysisView.h"
11#include <QCoreApplication>
14void GemcGUI::createTopButtons(QHBoxLayout* topLayout) {
19 topLayout->setContentsMargins(0, 0, 0, 0);
20 topLayout->setSpacing(6);
22 auto* nEventsLabel =
new QLabel(tr(
"N. Events:"));
24 auto* runButton =
new QPushButton(tr(
"Run"));
25 runButton->setObjectName(
"gemcRun");
26 runButton->setToolTip(tr(
"Run events"));
27 runButton->setIcon(style()->standardIcon(QStyle::SP_MediaPlay));
31 auto grunNumberOfEvents = std::to_string(eventDispenser->getTotalNumberOfEvents());
32 nEvents =
new QLineEdit(QString::fromStdString(grunNumberOfEvents));
33 nEvents->setObjectName(
"gemcNumberOfEvents");
34 nEvents->setMaximumWidth(50);
36 auto* cycleButton =
new QPushButton(tr(
"Cycle"));
37 cycleButton->setToolTip(tr(
"Run 1 event every 2 seconds"));
38 cycleButton->setIcon(style()->standardIcon(QStyle::SP_BrowserReload));
40 auto* stopButton =
new QPushButton(tr(
"Stop"));
41 stopButton->setToolTip(tr(
"Stops running events"));
42 stopButton->setIcon(style()->standardIcon(QStyle::SP_MediaStop));
44 auto* closeButton =
new QPushButton(tr(
"Exit"));
45 closeButton->setToolTip(tr(
"Quit GEMC"));
46 closeButton->setIcon(style()->standardIcon(QStyle::SP_TitleBarCloseButton));
49 eventNumberLabel =
new QLabel(tr(
"Event Number: %1").arg(displayedEventCount));
50 eventNumberLabel->setObjectName(
"gemcEventNumber");
52 topLayout->addWidget(nEventsLabel);
53 topLayout->addWidget(nEvents);
54 topLayout->addWidget(runButton);
55 topLayout->addWidget(cycleButton);
56 topLayout->addWidget(stopButton);
57 topLayout->addStretch(1);
58 topLayout->addWidget(eventNumberLabel);
59 topLayout->addStretch(40);
60 topLayout->addWidget(closeButton);
65 connect(nEvents, &QLineEdit::textChanged,
this, &GemcGUI::neventsChanged);
66 connect(closeButton, &QPushButton::clicked,
this, &GemcGUI::gquit);
67 connect(runButton, &QPushButton::clicked,
this, &GemcGUI::beamOn);
68 connect(cycleButton, &QPushButton::clicked,
this, &GemcGUI::cycleBeamOn);
69 connect(stopButton, &QPushButton::clicked,
this, &GemcGUI::stopCycleBeamOn);
73void GemcGUI::gquit() {
79void GemcGUI::neventsChanged() {
81 int newNevents = nEvents->text().toInt();
82 eventDispenser->setNumberOfEvents(newNevents);
85void GemcGUI::beamOn() {
87 if (physicsView && !physicsView->applyPending()) {
return; }
88 prepareGeometryForBeamOn();
89 if (analysisAccumulator !=
nullptr) {
90#ifdef GEMC_HAS_QTCHARTS
91 analysisAccumulator->beginBeamOn(analysisView !=
nullptr && analysisView->accumulateEnabled());
93 analysisAccumulator->beginBeamOn(
false);
96 eventDispenser->processEvents();
97 if (physicsView) { physicsView->refreshProcesses(); }
98#ifdef GEMC_HAS_QTCHARTS
99 if (analysisView !=
nullptr) { analysisView->refresh(); }
105void GemcGUI::cycleBeamOn() {
107 if (!gtimer->isActive()) {
110 if (physicsView && !physicsView->applyPending()) { gtimer->stop();
return; }
111 prepareGeometryForBeamOn();
112 if (analysisAccumulator !=
nullptr) {
113#ifdef GEMC_HAS_QTCHARTS
114 analysisAccumulator->beginBeamOn(analysisView !=
nullptr && analysisView->accumulateEnabled());
116 analysisAccumulator->beginBeamOn(
false);
119 eventDispenser->processEvents();
120 if (physicsView) { physicsView->refreshProcesses(); }
121#ifdef GEMC_HAS_QTCHARTS
122 if (analysisView !=
nullptr) { analysisView->refresh(); }
127void GemcGUI::stopCycleBeamOn() { gtimer->stop(); }