7#include <QCoreApplication>
10void GemcGUI::createTopButtons(QHBoxLayout* topLayout) {
15 topLayout->setContentsMargins(0, 0, 0, 0);
16 topLayout->setSpacing(6);
18 auto* nEventsLabel =
new QLabel(tr(
"N. Events:"));
20 auto* runButton =
new QPushButton(tr(
"Run"));
21 runButton->setToolTip(
"Run events");
22 runButton->setIcon(style()->standardIcon(QStyle::SP_MediaPlay));
26 auto grunNumberOfEvents = std::to_string(
eventDispenser->getTotalNumberOfEvents());
27 nEvents =
new QLineEdit(tr(grunNumberOfEvents.c_str()));
28 nEvents->setMaximumWidth(50);
30 auto* cycleButton =
new QPushButton(tr(
"Cycle"));
31 cycleButton->setToolTip(
"Run 1 event every 2 seconds");
32 cycleButton->setIcon(style()->standardIcon(QStyle::SP_BrowserReload));
34 auto* stopButton =
new QPushButton(tr(
"Stop"));
35 stopButton->setToolTip(
"Stops running events");
36 stopButton->setIcon(style()->standardIcon(QStyle::SP_MediaStop));
38 auto* closeButton =
new QPushButton(tr(
"Exit"));
39 closeButton->setToolTip(
"Quit GEMC");
40 closeButton->setIcon(style()->standardIcon(QStyle::SP_TitleBarCloseButton));
43 eventNumberLabel =
new QLabel(tr(
"Event Number: 0"));
45 topLayout->addWidget(nEventsLabel);
46 topLayout->addWidget(nEvents);
47 topLayout->addWidget(runButton);
48 topLayout->addWidget(cycleButton);
49 topLayout->addWidget(stopButton);
50 topLayout->addStretch(1);
51 topLayout->addWidget(eventNumberLabel);
52 topLayout->addStretch(40);
53 topLayout->addWidget(closeButton);
58 connect(nEvents, &QLineEdit::textChanged,
this, &GemcGUI::neventsChanged);
59 connect(closeButton, &QPushButton::clicked,
this, &GemcGUI::gquit);
60 connect(runButton, &QPushButton::clicked,
this, &GemcGUI::beamOn);
61 connect(cycleButton, &QPushButton::clicked,
this, &GemcGUI::cycleBeamOn);
62 connect(stopButton, &QPushButton::clicked,
this, &GemcGUI::stopCycleBeamOn);
66void GemcGUI::gquit() {
72void GemcGUI::neventsChanged() {
74 int newNevents = nEvents->text().toInt();
78void GemcGUI::beamOn() {
80 prepareGeometryForBeamOn();
86void GemcGUI::cycleBeamOn() {
88 if (!gtimer->isActive()) {
91 prepareGeometryForBeamOn();
96void GemcGUI::stopCycleBeamOn() { gtimer->stop(); }