ATLAS Offline Software
VP1Controller.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 
7 // //
8 // Header file for class VP1Controller //
9 // //
10 // Description: Common base class for VP1 controllers. //
11 // //
12 // Author: Thomas H. Kittelmann (Thomas.Kittelmann@cern.ch) //
13 // Initial version: August 2008 //
14 // //
16 
17 #ifndef VP1CONTROLLER_H
18 #define VP1CONTROLLER_H
19 
21 #include "VP1Base/VP1Interval.h"
22 
23 #include <QWidget>
24 
25 class QPushButton;
26 class QAbstractButton;
27 class QCheckBox;
28 class QComboBox;
29 class QGroupBox;
30 class QSpinBox;
31 class QDoubleSpinBox;
32 class QRadioButton;
33 class QSlider;
34 class QScrollArea;
35 class QButtonGroup;
36 class SbColor4f;
39 class VP1Serialise;
40 class VP1Deserialise;
41 class SoMaterial;
42 class VP1MaterialButton;
44 
45 class VP1Controller : public QWidget, public VP1HelperClassBase {
46 
47  Q_OBJECT
48 
49 public:
50 
51  VP1Controller(IVP1System * sys,const QString& classname);
52  virtual ~VP1Controller();
53 
54  void initLastVars(); //call at end of derived controller (after all addUpdateSlot calls & connection setups)
55 
56  QByteArray saveSettings() const;
57  void restoreSettings(const QByteArray&);
58 
59  // Need to be able to pass signals from customtoureditor to
62 
63 
64 protected:
65 
66  template <class T>
67  bool changed( T&lastval, const T& newval );
68 
69  template <class T>
70  static QString toString( const T& par );
71  static QString toString( const bool& par );
72  static QString toString( const QList<VP1Interval>& l );
73  static QString toString( SbColor4f );
74 
75  template <class T>
76  void initDialog(T& theUI, QPushButton* launchbutton, QAbstractButton* enabledButton = 0);
77  void initDialog(QWidget * dialog, QPushButton* launchbutton, QPushButton* closebutton, QAbstractButton* enabledButton = 0);
78 
79  void setupCollWidgetInScrollArea(QScrollArea * scrollarea, VP1CollectionWidget* collWidget);
80 
82  virtual int currentSettingsVersion() const = 0;
83  virtual void actualSaveSettings(VP1Serialise&) const = 0;
84 
85  const char * addUpdateSlot(const char * slot);//simply returns the argument slot for convenience
86  void connectToLastUpdateSlot(QObject* sender,const char * signal);
87  void connectToLastUpdateSlot(QCheckBox*);
88  void connectToLastUpdateSlot(QComboBox*);
89  void connectToLastUpdateSlot(QGroupBox*);
90  void connectToLastUpdateSlot(QSpinBox*);
91  void connectToLastUpdateSlot(QDoubleSpinBox*);
92  void connectToLastUpdateSlot(QRadioButton*);
93  void connectToLastUpdateSlot(QButtonGroup*);
94  void connectToLastUpdateSlot(QSlider*);
96 
97  bool initVarsMode() const { return m_initVarsMode; }
98 
99  //Convenient way to setup radio button groups (when multiple groups inside same group box):
100  QButtonGroup * defineRadioButtonGroup( QRadioButton * rb0, QRadioButton * rb1,QRadioButton * rb2 = 0,
101  QRadioButton * rb3 = 0,QRadioButton * rb4 = 0,QRadioButton * rb5 = 0,
102  QRadioButton * rb6 = 0,QRadioButton * rb7 = 0,QRadioButton * rb8 = 0,
103  QRadioButton * rb9 = 0 );
104  QButtonGroup * defineRadioButtonGroup( const QList<QRadioButton *>&);
105 
106  //convenience:
107  SoMaterial * getMaterial(VP1MaterialButton*) const;
108  SoMaterial * fallBackMaterial() const;
109 
110 
111  protected Q_SLOTS:
113 
114  public Q_SLOTS:
115  void toggleDialogState(QObject* widget=0);
118 
119 
120  signals:
122 
123 
124 private:
126 
127  class Imp;
128  Imp * m_d;
130 
131 };
132 
134 // INLINES //
136 
137 template <class T>
138 QString VP1Controller::toString( const T& par )
139 {
140  return VP1String::str(par);
141 }
142 
143 template <class T>
144 void VP1Controller::initDialog(T& theUI, QPushButton* launchbutton,QAbstractButton* enabledButton) {
145  QWidget * w = new QWidget(0,Qt::WindowStaysOnTopHint);
146  theUI.setupUi(w);
147  initDialog(w, launchbutton, theUI.pushButton_close,enabledButton);
148 }
149 
150 template <class T>
151 bool VP1Controller::changed( T&lastval, const T& newval )
152 {
153  if (initVarsMode()) {
154  lastval=newval;
155  return false;
156  }
157  if (lastval==newval)
158  return false;
159  lastval = newval;
160  return true;
161 }
162 
163 
164 #endif
VP1Controller::defineRadioButtonGroup
QButtonGroup * defineRadioButtonGroup(QRadioButton *rb0, QRadioButton *rb1, QRadioButton *rb2=0, QRadioButton *rb3=0, QRadioButton *rb4=0, QRadioButton *rb5=0, QRadioButton *rb6=0, QRadioButton *rb7=0, QRadioButton *rb8=0, QRadioButton *rb9=0)
Definition: VP1Controller.cxx:288
VP1Controller::addUpdateSlot
const char * addUpdateSlot(const char *slot)
Definition: VP1Controller.cxx:318
VP1Controller::setupCollWidgetInScrollArea
void setupCollWidgetInScrollArea(QScrollArea *scrollarea, VP1CollectionWidget *collWidget)
Definition: VP1Controller.cxx:255
VP1Controller::toString
static QString toString(const T &par)
Definition: VP1Controller.h:138
VP1Serialise
Definition: VP1Serialise.h:45
VP1Controller::dummyUpdateTrigger
void dummyUpdateTrigger()
VP1Controller::VP1Controller
VP1Controller(IVP1System *sys, const QString &classname)
Definition: VP1Controller.cxx:76
VP1MaterialButton
Definition: VP1MaterialButton.h:46
VP1Controller::fallBackMaterial
SoMaterial * fallBackMaterial() const
Definition: VP1Controller.cxx:427
VP1Controller::initDialog
void initDialog(T &theUI, QPushButton *launchbutton, QAbstractButton *enabledButton=0)
Definition: VP1Controller.h:144
VP1Controller::restoreSettings
void restoreSettings(const QByteArray &)
Definition: VP1Controller.cxx:387
VP1Controller::actualSaveSettings
virtual void actualSaveSettings(VP1Serialise &) const =0
UploadAMITag.l
list l
Definition: UploadAMITag.larcaf.py:158
VP1String::str
static QString str(const QString &s)
Definition: VP1String.h:49
VP1Controller::saveSettings
QByteArray saveSettings() const
Definition: VP1Controller.cxx:405
VP1ColorSelectButton
Definition: VP1ColorSelectButton.h:20
VP1Controller::connectToLastUpdateSlot
void connectToLastUpdateSlot(QObject *sender, const char *signal)
Definition: VP1Controller.cxx:327
mapkey::sys
@ sys
Definition: TElectronEfficiencyCorrectionTool.cxx:42
VP1Controller::initVarsMode
bool initVarsMode() const
Definition: VP1Controller.h:97
VP1Controller::customTourEditor
static VP1CustomTourEditor * customTourEditor()
Definition: VP1Controller.h:61
Cut::signal
@ signal
Definition: SUSYToolsAlg.cxx:67
IVP1System
Definition: IVP1System.h:36
VP1Controller::changed
bool changed(T &lastval, const T &newval)
Definition: VP1Controller.h:151
VP1Controller::m_d
Imp * m_d
Definition: VP1Controller.h:127
VP1Controller::m_initVarsMode
bool m_initVarsMode
Definition: VP1Controller.h:129
VP1CustomTourEditor
Definition: VP1CustomTourEditor.h:26
VP1Controller::~VP1Controller
virtual ~VP1Controller()
Definition: VP1Controller.cxx:90
VP1Deserialise
Definition: VP1Deserialise.h:44
VP1Interval.h
python.L1.Config.LegacyTopoMergerMap.signals
signals
Definition: LegacyTopoMergerMap.py:13
VP1HelperClassBase
Definition: VP1HelperClassBase.h:28
VP1Controller::Imp
Definition: VP1Controller.cxx:46
VP1Controller
Definition: VP1Controller.h:45
createCoolChannelIdFile.par
par
Definition: createCoolChannelIdFile.py:29
VP1Controller::getMaterial
SoMaterial * getMaterial(VP1MaterialButton *) const
Definition: VP1Controller.cxx:437
VP1HelperClassBase.h
VP1Controller::actualRestoreSettings
virtual void actualRestoreSettings(VP1Deserialise &)=0
VP1CollectionWidget
Definition: VP1CollectionWidget.h:32
VP1Controller::testForChanges
void testForChanges()
Definition: VP1Controller.h:112
VP1Controller::collWidgetContentChanged
void collWidgetContentChanged()
Definition: VP1Controller.cxx:232
VP1Controller::enabledButtonStateChanged
void enabledButtonStateChanged()
Definition: VP1Controller.cxx:167
VP1Controller::setCustomTourEditor
static void setCustomTourEditor(VP1CustomTourEditor *editor)
Definition: VP1Controller.h:60
python.IoTestsLib.w
def w
Definition: IoTestsLib.py:200
VP1Controller::toggleDialogState
void toggleDialogState(QObject *widget=0)
Definition: VP1Controller.cxx:194
VP1Controller::initLastVars
void initLastVars()
Definition: VP1Controller.cxx:68
VP1Controller::m_customTourEditor
static VP1CustomTourEditor * m_customTourEditor
Definition: VP1Controller.h:125
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35
VP1Controller::currentSettingsVersion
virtual int currentSettingsVersion() const =0