3#ifdef GEMC_HAS_QTCHARTS
4#include "gAnalysisView.h"
10#include <QCoreApplication>
13void GemcGUI::createTopButtons(QHBoxLayout* topLayout) {
18 topLayout->setContentsMargins(0, 0, 0, 0);
19 topLayout->setSpacing(6);
21 auto* nEventsLabel =
new QLabel(tr(
"N. Events:"));
23 auto* runButton =
new QPushButton(tr(
"Run"));
24 runButton->setObjectName(
"gemcRun");
25 runButton->setToolTip(tr(
"Run events"));
26 runButton->setIcon(style()->standardIcon(QStyle::SP_MediaPlay));
30 auto grunNumberOfEvents = std::to_string(eventDispenser->getTotalNumberOfEvents());
31 nEvents =
new QLineEdit(QString::fromStdString(grunNumberOfEvents));
32 nEvents->setObjectName(
"gemcNumberOfEvents");
33 nEvents->setMaximumWidth(50);
35 auto* cycleButton =
new QPushButton(tr(
"Cycle"));
36 cycleButton->setToolTip(tr(
"Run 1 event every 2 seconds"));
37 cycleButton->setIcon(style()->standardIcon(QStyle::SP_BrowserReload));
39 auto* stopButton =
new QPushButton(tr(
"Stop"));
40 stopButton->setToolTip(tr(
"Stops running events"));
41 stopButton->setIcon(style()->standardIcon(QStyle::SP_MediaStop));
43 auto* closeButton =
new QPushButton(tr(
"Exit"));
44 closeButton->setToolTip(tr(
"Quit GEMC"));
45 closeButton->setIcon(style()->standardIcon(QStyle::SP_TitleBarCloseButton));
48 eventNumberLabel =
new QLabel(tr(
"Event Number: %1").arg(displayedEventCount));
49 eventNumberLabel->setObjectName(
"gemcEventNumber");
51 topLayout->addWidget(nEventsLabel);
52 topLayout->addWidget(nEvents);
53 topLayout->addWidget(runButton);
54 topLayout->addWidget(cycleButton);
55 topLayout->addWidget(stopButton);
56 topLayout->addStretch(1);
57 topLayout->addWidget(eventNumberLabel);
58 topLayout->addStretch(40);
59 topLayout->addWidget(closeButton);
64 connect(nEvents, &QLineEdit::textChanged,
this, &GemcGUI::neventsChanged);
65 connect(closeButton, &QPushButton::clicked,
this, &GemcGUI::gquit);
66 connect(runButton, &QPushButton::clicked,
this, &GemcGUI::beamOn);
67 connect(cycleButton, &QPushButton::clicked,
this, &GemcGUI::cycleBeamOn);
68 connect(stopButton, &QPushButton::clicked,
this, &GemcGUI::stopCycleBeamOn);
72void GemcGUI::gquit() {
78void GemcGUI::neventsChanged() {
80 int newNevents = nEvents->text().toInt();
81 eventDispenser->setNumberOfEvents(newNevents);
84void GemcGUI::beamOn() {
86 prepareGeometryForBeamOn();
87 if (analysisAccumulator !=
nullptr) {
88#ifdef GEMC_HAS_QTCHARTS
89 analysisAccumulator->beginBeamOn(analysisView !=
nullptr && analysisView->accumulateEnabled());
91 analysisAccumulator->beginBeamOn(
false);
94 eventDispenser->processEvents();
95#ifdef GEMC_HAS_QTCHARTS
96 if (analysisView !=
nullptr) { analysisView->refresh(); }
102void GemcGUI::cycleBeamOn() {
104 if (!gtimer->isActive()) {
107 prepareGeometryForBeamOn();
108 if (analysisAccumulator !=
nullptr) {
109#ifdef GEMC_HAS_QTCHARTS
110 analysisAccumulator->beginBeamOn(analysisView !=
nullptr && analysisView->accumulateEnabled());
112 analysisAccumulator->beginBeamOn(
false);
115 eventDispenser->processEvents();
116#ifdef GEMC_HAS_QTCHARTS
117 if (analysisView !=
nullptr) { analysisView->refresh(); }
122void GemcGUI::stopCycleBeamOn() { gtimer->stop(); }