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->setToolTip(
"Run events");
25 runButton->setIcon(style()->standardIcon(QStyle::SP_MediaPlay));
29 auto grunNumberOfEvents = std::to_string(eventDispenser->getTotalNumberOfEvents());
30 nEvents =
new QLineEdit(tr(grunNumberOfEvents.c_str()));
31 nEvents->setMaximumWidth(50);
33 auto* cycleButton =
new QPushButton(tr(
"Cycle"));
34 cycleButton->setToolTip(
"Run 1 event every 2 seconds");
35 cycleButton->setIcon(style()->standardIcon(QStyle::SP_BrowserReload));
37 auto* stopButton =
new QPushButton(tr(
"Stop"));
38 stopButton->setToolTip(
"Stops running events");
39 stopButton->setIcon(style()->standardIcon(QStyle::SP_MediaStop));
41 auto* closeButton =
new QPushButton(tr(
"Exit"));
42 closeButton->setToolTip(
"Quit GEMC");
43 closeButton->setIcon(style()->standardIcon(QStyle::SP_TitleBarCloseButton));
46 eventNumberLabel =
new QLabel(tr(
"Event Number: 0"));
48 topLayout->addWidget(nEventsLabel);
49 topLayout->addWidget(nEvents);
50 topLayout->addWidget(runButton);
51 topLayout->addWidget(cycleButton);
52 topLayout->addWidget(stopButton);
53 topLayout->addStretch(1);
54 topLayout->addWidget(eventNumberLabel);
55 topLayout->addStretch(40);
56 topLayout->addWidget(closeButton);
61 connect(nEvents, &QLineEdit::textChanged,
this, &GemcGUI::neventsChanged);
62 connect(closeButton, &QPushButton::clicked,
this, &GemcGUI::gquit);
63 connect(runButton, &QPushButton::clicked,
this, &GemcGUI::beamOn);
64 connect(cycleButton, &QPushButton::clicked,
this, &GemcGUI::cycleBeamOn);
65 connect(stopButton, &QPushButton::clicked,
this, &GemcGUI::stopCycleBeamOn);
69void GemcGUI::gquit() {
75void GemcGUI::neventsChanged() {
77 int newNevents = nEvents->text().toInt();
78 eventDispenser->setNumberOfEvents(newNevents);
81void GemcGUI::beamOn() {
83 prepareGeometryForBeamOn();
84 if (analysisAccumulator !=
nullptr) {
85#ifdef GEMC_HAS_QTCHARTS
86 analysisAccumulator->beginBeamOn(analysisView !=
nullptr && analysisView->accumulateEnabled());
88 analysisAccumulator->beginBeamOn(
false);
91 eventDispenser->processEvents();
92#ifdef GEMC_HAS_QTCHARTS
93 if (analysisView !=
nullptr) { analysisView->refresh(); }
99void GemcGUI::cycleBeamOn() {
101 if (!gtimer->isActive()) {
104 prepareGeometryForBeamOn();
105 if (analysisAccumulator !=
nullptr) {
106#ifdef GEMC_HAS_QTCHARTS
107 analysisAccumulator->beginBeamOn(analysisView !=
nullptr && analysisView->accumulateEnabled());
109 analysisAccumulator->beginBeamOn(
false);
112 eventDispenser->processEvents();
113#ifdef GEMC_HAS_QTCHARTS
114 if (analysisView !=
nullptr) { analysisView->refresh(); }
119void GemcGUI::stopCycleBeamOn() { gtimer->stop(); }