ATLAS Offline Software
Loading...
Searching...
No Matches
VP1SelectEvent.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
6// //
7// Source file for class VP1SelectEvent //
8// //
9// Description: Dialog for the selection of a specific event in a file //
10// //
11// Author: Sebastian Andreas Merkt (sebastian.andreas.merkt@cern.ch) //
12// Initial version: August 2018 //
13// //
15
17
18#include <QPushButton>
19#include <QGridLayout>
20
21#if __GNUC__ >= 14
22// suppress warning seen in qfutureinterface.h
23# pragma GCC diagnostic push
24# pragma GCC diagnostic ignored "-Wtemplate-id-cdtor"
25#endif
26#include <QtWidgets>
27#if __GNUC__ >= 14
28# pragma GCC diagnostic pop
29#endif
30#include <QString>
31
32VP1SelectEvent::VP1SelectEvent(int totEvtNr, int evtNr, QWidget *parent) : QDialog(parent)
33{
34 //Set default dialog size
35 int nWidth = 400;
36 int nHeight = 200;
37 if (parent != NULL)
38 setGeometry(parent->x() + parent->width()/2 - nWidth/2,
39 parent->y() + parent->height()/2 - nHeight/2,
40 nWidth, nHeight);
41 else
42 resize(nWidth, nHeight);
43
44 //Buttonbox to set Open, Cancel buttons
45 m_buttonBox = new QDialogButtonBox(this);
46 m_openButton = m_buttonBox->addButton(tr("&Select"), QDialogButtonBox::AcceptRole);
47 m_cancelButton = m_buttonBox->addButton(tr("&Cancel"),QDialogButtonBox::RejectRole);
48 connect(m_openButton, &QPushButton::clicked, this, &VP1SelectEvent::passEvtNr);
49 connect(m_cancelButton, &QPushButton::clicked, this, &VP1SelectEvent::reject);
50
51
52 m_spinBox = new QSpinBox();
53 m_spinBox->setRange(1, totEvtNr);
54 m_spinBox->setSingleStep(1);
55 m_spinBox->setValue(evtNr+1);
56
57 const QString line2 = QString::number(totEvtNr) + " events in file.";
58
59 //Create the main layout
60 QGridLayout *mainLayout = new QGridLayout(this);
61 mainLayout->addWidget(new QLabel(tr("Select event:")), 0, 0);
62 mainLayout->addWidget(m_spinBox, 0, 1);
63 mainLayout->addWidget(new QLabel(line2), 1, 0);
64 mainLayout->addWidget(m_buttonBox, 2, 1);
65
66}
67
69 if( m_spinBox->value() != 0 ) {
70 VP1SelectEvent::done(m_spinBox->value());
71 }
72}
73
75 VP1SelectEvent::done(-1);
76}
QPushButton * m_openButton
VP1SelectEvent(int totEvtNr, int evtNr, QWidget *parent=0)
QDialogButtonBox * m_buttonBox
QPushButton * m_cancelButton
QSpinBox * m_spinBox