3#include "gAnalysisView.h"
8#include <QCoreApplication>
11void GemcGUI::createTopButtons(QHBoxLayout* topLayout) {
16 topLayout->setContentsMargins(0, 0, 0, 0);
17 topLayout->setSpacing(6);
19 auto* nEventsLabel =
new QLabel(tr(
"N. Events:"));
21 auto* runButton =
new QPushButton(tr(
"Run"));
22 runButton->setToolTip(
"Run events");
23 runButton->setIcon(style()->standardIcon(QStyle::SP_MediaPlay));
27 auto grunNumberOfEvents = std::to_string(eventDispenser->getTotalNumberOfEvents());
28 nEvents =
new QLineEdit(tr(grunNumberOfEvents.c_str()));
29 nEvents->setMaximumWidth(50);
31 auto* cycleButton =
new QPushButton(tr(
"Cycle"));
32 cycleButton->setToolTip(
"Run 1 event every 2 seconds");
33 cycleButton->setIcon(style()->standardIcon(QStyle::SP_BrowserReload));
35 auto* stopButton =
new QPushButton(tr(
"Stop"));
36 stopButton->setToolTip(
"Stops running events");
37 stopButton->setIcon(style()->standardIcon(QStyle::SP_MediaStop));
39 auto* closeButton =
new QPushButton(tr(
"Exit"));
40 closeButton->setToolTip(
"Quit GEMC");
41 closeButton->setIcon(style()->standardIcon(QStyle::SP_TitleBarCloseButton));
44 eventNumberLabel =
new QLabel(tr(
"Event Number: 0"));
46 topLayout->addWidget(nEventsLabel);
47 topLayout->addWidget(nEvents);
48 topLayout->addWidget(runButton);
49 topLayout->addWidget(cycleButton);
50 topLayout->addWidget(stopButton);
51 topLayout->addStretch(1);
52 topLayout->addWidget(eventNumberLabel);
53 topLayout->addStretch(40);
54 topLayout->addWidget(closeButton);
59 connect(nEvents, &QLineEdit::textChanged,
this, &GemcGUI::neventsChanged);
60 connect(closeButton, &QPushButton::clicked,
this, &GemcGUI::gquit);
61 connect(runButton, &QPushButton::clicked,
this, &GemcGUI::beamOn);
62 connect(cycleButton, &QPushButton::clicked,
this, &GemcGUI::cycleBeamOn);
63 connect(stopButton, &QPushButton::clicked,
this, &GemcGUI::stopCycleBeamOn);
67void GemcGUI::gquit() {
73void GemcGUI::neventsChanged() {
75 int newNevents = nEvents->text().toInt();
76 eventDispenser->setNumberOfEvents(newNevents);
79void GemcGUI::beamOn() {
81 prepareGeometryForBeamOn();
82 if (analysisAccumulator !=
nullptr) {
83 analysisAccumulator->beginBeamOn(analysisView !=
nullptr && analysisView->accumulateEnabled());
85 eventDispenser->processEvents();
86 if (analysisView !=
nullptr) { analysisView->refresh(); }
91void GemcGUI::cycleBeamOn() {
93 if (!gtimer->isActive()) {
96 prepareGeometryForBeamOn();
97 if (analysisAccumulator !=
nullptr) {
98 analysisAccumulator->beginBeamOn(analysisView !=
nullptr && analysisView->accumulateEnabled());
100 eventDispenser->processEvents();
101 if (analysisView !=
nullptr) { analysisView->refresh(); }
105void GemcGUI::stopCycleBeamOn() { gtimer->stop(); }