ATLAS Offline Software
VP1ControllerHelper.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 // //
7 // Implementation of class VP1ControllerHelper //
8 // //
9 // Author: Thomas Kittelmann <Thomas.Kittelmann@cern.ch> //
10 // //
11 // Initial version: April 2007 //
12 // //
14 
16 #include "VP1Base/IVP1System.h"
17 #include "VP1Base/VP1TabWidget.h"
19 
20 #include <QCheckBox>
21 #include <QHBoxLayout>
22 #include <QLabel>
23 #include <QSpacerItem>
24 #include <QVBoxLayout>
25 
26 
27 //_____________________________________________________________________________________________________________
28 QWidget * VP1ControllerHelper::compositionController( const QList<IVP1System*>& systemsWithControllersAllowed,
29  QMap<IVP1System*,QWidget*>& sys2tabpage,
30  VP1TabWidget*&tabWidget,
31  const QList<QPair<IVP1System*,bool> >& system2switchable,
32  QMap<QCheckBox*,IVP1System*>& checkbox2system,
33  VP1ColorSelectButton* & colorselectbutton,
34  QWidget * extrawidget, bool nobgdcolorsel)
35 {
36  tabWidget = 0;
37 
38  //First we figure out which system controllers we should add:
39  QList<QPair<QWidget*,QString> > controllerTabs;
40  for (IVP1System* s : systemsWithControllersAllowed) {
41  QWidget* w = s->controllerWidget();
42  if (w) {
43  controllerTabs << QPair<QWidget*,QString>(w,s->name());
44  sys2tabpage.insert(s,w);
45  }
46  }
47 
48  //Setup the general tab which switches controllers on and off.
49  QWidget * tab_general = new QWidget(0);
50  QVBoxLayout * vboxLayout1 = new QVBoxLayout(tab_general);
51  vboxLayout1->setSpacing(6);
52  vboxLayout1->setMargin(9);
53  QHBoxLayout * hboxLayout = new QHBoxLayout();
54  hboxLayout->setSpacing(6);
55  hboxLayout->setMargin(0);
56  QLabel * tab_general_label = new QLabel(tab_general);
57  tab_general_label->setText("No systems can be switched on/off in this channel.");
58  hboxLayout->addWidget(tab_general_label);
59  QSpacerItem * spacerItem = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
60  hboxLayout->addItem(spacerItem);
61  vboxLayout1->addLayout(hboxLayout);
62  QHBoxLayout * hboxLayout1 = new QHBoxLayout();
63  hboxLayout1->setSpacing(0);
64  hboxLayout1->setMargin(0);
65  QSpacerItem * spacerItem1 = new QSpacerItem(25, 2, QSizePolicy::Fixed, QSizePolicy::Fixed);
66  hboxLayout1->addItem(spacerItem1);
67  QVBoxLayout *vboxLayout_checkboxes = new QVBoxLayout();
68  vboxLayout_checkboxes->setSpacing(6);
69  vboxLayout_checkboxes->setMargin(0);
70  hboxLayout1->addLayout(vboxLayout_checkboxes);
71  QSpacerItem * spacerItem2 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
72  hboxLayout1->addItem(spacerItem2);
73  vboxLayout1->addLayout(hboxLayout1);
74 
75  //Add checkboxes for switching systems on/off
76  for (int i = 0; i < system2switchable.count(); ++i) {
77  QCheckBox * checkBox = new QCheckBox(tab_general);
78  checkBox->setText(system2switchable.at(i).first->name());
79  QString info(system2switchable.at(i).first->information());
80  if (!info.isEmpty())
81  checkBox->setToolTip(info);
82  checkBox->setChecked(true);
83  vboxLayout_checkboxes->addWidget(checkBox);
84  if (system2switchable.at(i).second) {
85  tab_general_label->setText("Select active systems:");
86  checkbox2system.insert(checkBox,system2switchable.at(i).first);
87  } else {
88  checkBox->setEnabled(false);
89  }
90  }
91 
92  //Add pushbutton for choosing background color:
93  if (!nobgdcolorsel) {
94  colorselectbutton = new VP1ColorSelectButton(tab_general,Qt::black);
95  QHBoxLayout * hboxLayout2 = new QHBoxLayout();
96  hboxLayout2->setSpacing(6);
97  hboxLayout2->setMargin(0);
98  hboxLayout2->addWidget(colorselectbutton);
99  hboxLayout2->addWidget(new QLabel("Set background"));
100  QSpacerItem * spacerItem4 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
101  hboxLayout2->addItem(spacerItem4);
102  QSpacerItem * spacerItem5 = new QSpacerItem(10, 10, QSizePolicy::Minimum,QSizePolicy::Fixed);
103  vboxLayout1->addItem(spacerItem5);
104  vboxLayout1->addLayout(hboxLayout2);
105  }
106 
107  //Maybe add another custom widget:
108  if (extrawidget) {
109  extrawidget->setParent(tab_general);
110  QHBoxLayout * hboxLayout_extra = new QHBoxLayout();
111  hboxLayout_extra->setSpacing(6);
112  hboxLayout_extra->setMargin(0);
113  hboxLayout_extra->addWidget(extrawidget);
114  QSpacerItem * spacerItem_extra1 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
115  hboxLayout_extra->addItem(spacerItem_extra1);
116  QSpacerItem * spacerItem_extra2 = new QSpacerItem(10, 10, QSizePolicy::Minimum,QSizePolicy::Fixed);
117  vboxLayout1->addItem(spacerItem_extra2);
118  vboxLayout1->addLayout(hboxLayout_extra);
119  QSpacerItem * spacerItem_extra3 = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);
120  vboxLayout1->addItem(spacerItem_extra3);
121  }
122 
123  QSpacerItem * spacerItem3 = new QSpacerItem(1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding);
124  vboxLayout1->addItem(spacerItem3);
125 
126  //If we dont have any system controllers to add, that tab is the whole controller:
127  if (controllerTabs.empty()) {
128  return tab_general;
129  }
130 
131  //Let us make an actual tab widget:
132  tabWidget = new VP1TabWidget(0);
133  tabWidget->addTab(tab_general, "General");
134 
135  //Add system tabs:
136  for (int i = 0; i<controllerTabs.count();++i) {
137  controllerTabs.at(i).first->setParent(tabWidget);//We assume ownership of the system controller.
138  tabWidget->addTab(controllerTabs.at(i).first,controllerTabs.at(i).second);
139  }
140 
141  //Show first tab:
142  tabWidget->setCurrentIndex(0);
143 
144  return tabWidget;
145 }
146 
grepfile.info
info
Definition: grepfile.py:38
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
VP1ColorSelectButton
Definition: VP1ColorSelectButton.h:20
VP1TabWidget
Definition: VP1TabWidget.h:45
IVP1System
Definition: IVP1System.h:36
lumiFormat.i
int i
Definition: lumiFormat.py:85
VP1ColorSelectButton.h
VP1TabWidget.h
VP1ControllerHelper::compositionController
static QWidget * compositionController(const QList< IVP1System * > &systemsWithControllersAllowed, QMap< IVP1System *, QWidget * > &sys2tabpage, VP1TabWidget *&tabwidget, const QList< QPair< IVP1System *, bool > > &system2switchable, QMap< QCheckBox *, IVP1System * > &checkbox2system, VP1ColorSelectButton *&colorselectbutton, QWidget *extrawidget=0, bool nobgdcolorsel=false)
Definition: VP1ControllerHelper.cxx:28
python.IoTestsLib.w
def w
Definition: IoTestsLib.py:200
VP1ControllerHelper.h
IVP1System.h