ATLAS Offline Software
AODSystemController.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 AODSystemController //
8 // //
9 // Author: Thomas H. Kittelmann (Thomas.Kittelmann@cern.ch) //
10 // Initial version: February 2008 //
11 // //
13 
14 #include <Inventor/C/errors/debugerror.h>
15 #include <Inventor/nodes/SoSelection.h>
16 
17 // Local
20 #include "AODSysCommonData.h"
21 #include "AODCollWidget.h"
22 #include "AODHandleBase.h"
23 #include "ui_vp1aodcontrollerform.h"
24 #include "ui_settings_cuts_form.h"
25 #include "ui_objectbrowser.h"
26 
27 // VP1
29 #ifndef BUILDVP1LIGHT
33 #endif
34 #include "VP1Base/VP1QtUtils.h"
35 #include "VP1Base/IVP1System.h"
36 #include "VP1Base/VP1Serialise.h"
37 #include "VP1Base/VP1Deserialise.h"
41 
42 // SoCoin
43 #include "Inventor/nodes/SoMaterial.h"
44 #include "Inventor/nodes/SoDrawStyle.h"
45 #include "Inventor/nodes/SoComplexity.h"
46 #include "Inventor/nodes/SoLightModel.h"
47 #include <Inventor/nodes/SoSeparator.h>
48 #include <Inventor/actions/SoSearchAction.h>
49 
50 // Qt
51 #include <QTreeWidget>
52 #include <QTreeWidgetItem>
53 
54 #include <typeinfo>
55 //____________________________________________________________________
57 public:
59  Ui::VP1AODControllerForm ui;
61  bool updateComboBoxContents(QComboBox*cb,QStringList l,QString& restoredSelection);
62  static const QString noneAvailString;
63 
64  // Ui::AODSysSettingsColouringForm ui_col;
65  // Ui::AODSysSettingsExtrapolationsForm ui_extrap;
66  // Ui::AODSysSettingsInteractionsForm ui_int;
67  // Ui::AODSysSettingsCutsForm ui_cuts;
68  Ui::AODObjectBrowser ui_objBrowser;
69 
70  QTreeWidget* objBrowserWidget;
72 };
73 
74 const QString AODSystemController::Imp::noneAvailString = QString("None available");
75 
76 
77 // //____________________________________________________________________
78 // QString AODSystemController::toString( const QList<unsigned>& l )
79 // {
80 // QString s;
81 // for(unsigned i :l) {
82 // if (!s.isEmpty()) s+=", ";
83 // s+=QString::number(i);
84 // }
85 // return "["+s+"]";
86 // }
87 //
88 // //____________________________________________________________________
89 // QString AODSystemController::toString( const QList<int>& l )
90 // {
91 // QString s;
92 // for(int i : l) {
93 // if (!s.isEmpty()) s+=", ";
94 // s+=QString::number(i);
95 // }
96 // return "["+s+"]";
97 // }
98 
99 //____________________________________________________________________
100 
101 
102 //____________________________________________________________________
104  : VP1Controller(sys,"AODSystemController"), m_d(new Imp)
105 {
106  m_d->theclass = this;
107  //Stuff with tools waits until ::initTools() is called:
108  m_d->ui.setupUi(this);
110  setupCollWidgetInScrollArea(m_d->ui.collWidgetScrollArea,m_d->collwidget);
111 
112  initDialog(m_d->ui_objBrowser, m_d->ui.pushButton_ObjectBrowser);
113 
114  //init:
115  // m_d->initMaterials();
116 
117 
118 
119  //Disable elements based on job configuration:
120 
121 
122 
124  // Setup connections which monitor changes in the controller so that we may emit signals as appropriate: //
126 
127 
128  // TrackObjBrowser
129  messageVerbose("Enabling object browser");
130  m_d->objBrowserWidget = m_d->ui_objBrowser.treeWidget;
131  m_d->objBrowserWidget->setSortingEnabled(false);
132  QStringList l;
133  l<<"Object"<<"Information";
134  m_d->objBrowserWidget->setHeaderLabels(l);
135  connect(m_d->objBrowserWidget,SIGNAL(itemClicked(QTreeWidgetItem *, int)),this,SLOT(objectBrowserClicked(QTreeWidgetItem *, int)));
136 
137  // Hide interactions until we're ready.
138  m_d->ui.pushButton_interactions->hide();
139 
140  // Tell system to dump to JSON
141  connect(m_d->ui.pushButton_dumpToJSON,SIGNAL(pressed()),systemBase(),SLOT(dumpToJSON()));
142 
143  if (VP1QtUtils::environmentVariableIsSet("VP1_DUMPTOJSON")){
144  messageVerbose("AODSystemController enable dumping to JSON");
145  m_d->ui.pushButton_dumpToJSON->setMaximumHeight(static_cast<int>(0.5+QFontMetricsF(m_d->ui.pushButton_dumpToJSON->font()).height()*1.05+2));
146  m_d->ui.pushButton_dumpToJSON->setMinimumHeight(m_d->ui.pushButton_dumpToJSON->maximumHeight());
147  m_d->ui.pushButton_dumpToJSON->setCheckable(true);
148 
149  QSizePolicy sizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
150  sizePolicy.setHorizontalStretch(0);
151  sizePolicy.setVerticalStretch(0);
152  sizePolicy.setHeightForWidth(m_d->ui.pushButton_dumpToJSON->sizePolicy().hasHeightForWidth());
153  m_d->ui.pushButton_dumpToJSON->setSizePolicy(sizePolicy);
154  m_d->ui.pushButton_dumpToJSON->setFocusPolicy(Qt::NoFocus);
155  } else {
156  m_d->ui.pushButton_dumpToJSON->hide();
157  }
158 
159  // we want "Print information" on single track selection turned ON by default
160  // //m_d->ui_int.checkBox_selsingle_printinfo->setChecked(true);
161 
162  initLastVars();
163 }
164 
165 //____________________________________________________________________
167 {
168  messageVerbose("~AODSystemController begin");
169  delete m_d;
170  messageVerbose("~AODSystemController end");
171 }
172 
173 //____________________________________________________________________
175 {
176  int version = 1;
177  messageVerbose("AODSystemController::currentSettingsVersion() - current version: " + QString::number(version));
178  return version;
179 }
180 
181 //____________________________________________________________________
183 {
184  messageVerbose("AODSystemController::actualSaveSettings()");
185  messageDebug("version: " + QString::number(s.version()));
186 
187 }
188 
189 //____________________________________________________________________
191 {
192  messageVerbose("AODSystemController::actualRestoreSettings()");
193 }
194 
195 //____________________________________________________________________
197 {
198  return m_d->collwidget;
199 }
200 
201 //Access methods:
202 
203 //____________________________________________________________________
204 //Returns false if "none available"
205 bool AODSystemController::Imp::updateComboBoxContents(QComboBox*cb,QStringList l,QString& restoredSelection)
206 {
207  //current selection:
208  QString ct = cb->currentText();
210  ct = "";
211 
212  bool save = cb->blockSignals(true);
213 
214  cb->clear();
215 
216  bool enabled = false;
217  if (l.isEmpty()) {
218  cb->addItem(Imp::noneAvailString);
219  cb->setEnabled(false);
220  } else {
221  cb->addItems(l);
222 
223  int i = restoredSelection.isEmpty() ? -1 : cb->findText(restoredSelection);
224  if (i<0)
225  i = ct.isEmpty() ? -1 : cb->findText(ct);
226  restoredSelection = "";
227 
228  if (i>=0) {
229  cb->setCurrentIndex(i);
230  } else {
231  //Let's try to pick the default to be VP1Extrapolater over
232  //AtlasExtrapolater over... whatever (same for fitters):
233  int i_vp1(-1), i_atlas(-1);
234  for (int j = 0; j <cb->count();++j) {
235  if (i_vp1==-1&&cb->itemText(j).contains("vp1",Qt::CaseInsensitive))
236  i_vp1 = j;
237  if (i_atlas==-1&&cb->itemText(j).contains("atlas",Qt::CaseInsensitive))
238  i_atlas = j;
239  }
240  if (i_vp1>=0)
241  cb->setCurrentIndex(i_vp1);
242  else if (i_atlas>=0)
243  cb->setCurrentIndex(i_atlas);
244  }
246  enabled = true;
247  cb->setEnabled(true);
248  }
249 
250  if (!save)
251  cb->blockSignals(false);
252  return enabled;
253 }
254 
255 //____________________________________________________________________
257 {
258  return false;
259  // return m_d->ui_int.checkBox_selsingle_orientzoom->isChecked();
260 }
261 
262 //____________________________________________________________________
264 {
265  return false;
266  // return m_d->ui_int.checkBox_selsingle_printinfo->isChecked();
267 }
268 
269 //____________________________________________________________________
271 {
272  return false;
273  // return printInfoOnSingleSelection() && m_d->ui_int.checkBox_selsingle_printinfo_verbose->isChecked();
274 }
275 
276 //____________________________________________________________________
278 {
279  return false;
280  // return m_d->ui_int.checkBox_sel_printtotmom->isChecked();
281 }
282 
283 //____________________________________________________________________
285 {
286  return false;
287  // return m_d->ui_int.checkBox_sel_showtotmom->isChecked();
288 }
289 
291 {
292  return m_d->objBrowserWidget;
293 }
294 
296  return m_d->common;
297 }
299  m_d->common=common;
300 }
301 
302 void AODSystemController::objectBrowserClicked(QTreeWidgetItem * item, int){
303  messageVerbose("objectBrowserClicked for "+item->text(0));
304  //
305  IVP1System* sysBase = systemBase();
306  if (!sysBase){
307  messageVerbose("AODSystemController::objectBrowserClicked: Couldn't get system base pointer");
308  return;
309  }
310 
311  VP1AODSystem* sys = dynamic_cast<VP1AODSystem*>(sysBase);
312  if (!sys){
313  messageVerbose("AODSystemController::objectBrowserClicked: Couldn't get VP1AODSystem pointer");
314  std::cout<<"Pointer value = "<<sysBase<<" and type = "<<typeid(sysBase).name()<<std::endl;
315  return;
316  }
317 
318 
319  sys->deselectAll(); // FIXME. necessary?
320  //
321  SoNode* node = common()->getNodeFromBrowser(item);
322  if (node) {
323  std::cout<< "Have node from browser: "<<node<<std::endl;
324 
326  handle->clicked();
327  // okay, have object
328 
329  SoCooperativeSelection * sel = sys->selObjects();
330  std::cout<< "sel->select(node): "<<node<<std::endl;
331 
332  sel->select(node);
333  }
334  messageVerbose("end objectBrowserClicked ");
335 }
336 
338 // Test for possible changes in values and emit signals as appropriate:
339 // (possibleChange_XXX() slots code provided by macros)
340 #define VP1CONTROLLERCLASSNAME AODSystemController
342 
VP1Serialise.h
AODSystemController::setCommonData
void setCommonData(AODSysCommonData *)
set pointer to the common data
Definition: AODSystemController.cxx:298
AODSysCommonData::getHandleFromNode
AODHandleBase * getHandleFromNode(SoNode *node)
Definition: AODSysCommonData.cxx:79
AODSystemController::Imp
Definition: AODSystemController.cxx:56
VP1Controller::setupCollWidgetInScrollArea
void setupCollWidgetInScrollArea(QScrollArea *scrollarea, VP1CollectionWidget *collWidget)
Definition: VP1Controller.cxx:255
AODSystemController::objBrowser
QTreeWidget * objBrowser() const
Returns a pointer to the Track Object Browser (if it exists)
Definition: AODSystemController.cxx:290
AODSystemController::Imp::ui
Ui::VP1AODControllerForm ui
Definition: AODSystemController.cxx:59
VP1AvailableToolsHelper.h
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
VP1Deserialise.h
VP1Serialise
Definition: VP1Serialise.h:45
AODHandleBase
Definition: AODHandleBase.h:43
VP1AODSystem
Definition: VP1AODSystem.h:34
AODSysCommonData
Definition: AODSysCommonData.h:42
AODSystemController::AODSystemController
AODSystemController(IVP1System *sys)
Definition: AODSystemController.cxx:103
VP1HelperClassBase::messageVerbose
void messageVerbose(const QString &) const
Definition: VP1HelperClassBase.cxx:78
AODSystemController::m_d
Imp * m_d
Definition: AODSystemController.h:80
AODCollWidget.h
fillPileUpNoiseLumi.connect
string connect
Definition: fillPileUpNoiseLumi.py:70
VP1Controller::initDialog
void initDialog(T &theUI, QPushButton *launchbutton, QAbstractButton *enabledButton=0)
Definition: VP1Controller.h:144
CSV_InDetExporter.new
new
Definition: CSV_InDetExporter.py:145
AODSystemController.h
VP1QtUtils.h
VP1ParticleData.h
UploadAMITag.l
list l
Definition: UploadAMITag.larcaf.py:158
AODSystemController::Imp::updateComboBoxContents
bool updateComboBoxContents(QComboBox *cb, QStringList l, QString &restoredSelection)
Definition: AODSystemController.cxx:205
VP1HelperClassBase::messageDebug
void messageDebug(const QString &) const
Definition: VP1HelperClassBase.cxx:65
mapkey::sys
@ sys
Definition: TElectronEfficiencyCorrectionTool.cxx:42
AODSystemController::showTotMomentumOnMultiTrackSelection
bool showTotMomentumOnMultiTrackSelection() const
Definition: AODSystemController.cxx:284
VP1QtInventorUtils.h
AODSystemController::currentSettingsVersion
int currentSettingsVersion() const
Definition: AODSystemController.cxx:174
AODSystemController::Imp::theclass
AODSystemController * theclass
Definition: AODSystemController.cxx:58
checkTP.save
def save(self, fileName="./columbo.out")
Definition: checkTP.py:178
IVP1System
Definition: IVP1System.h:36
lumiFormat.i
int i
Definition: lumiFormat.py:85
VP1SoMaterialMixer.h
AODSystemController
Definition: AODSystemController.h:43
AODSystemController::~AODSystemController
virtual ~AODSystemController()
Definition: AODSystemController.cxx:166
sel
sel
Definition: SUSYToolsTester.cxx:97
AODSystemController::printTotMomentumOnMultiTrackSelection
bool printTotMomentumOnMultiTrackSelection() const
Definition: AODSystemController.cxx:277
AODSystemController::common
AODSysCommonData * common() const
Returns a pointer to the common data (if it exists)
Definition: AODSystemController.cxx:295
AODSystemController::Imp::noneAvailString
static const QString noneAvailString
Definition: AODSystemController.cxx:62
VP1QtUtils::environmentVariableIsSet
static bool environmentVariableIsSet(const QString &name)
Definition: VP1QtUtils.cxx:108
VP1AODSystem.h
AODCollWidget
Definition: AODCollWidget.h:23
VP1Deserialise
Definition: VP1Deserialise.h:44
AODSysCommonData.h
calibdata.ct
ct
Definition: calibdata.py:418
VP1Controller
Definition: VP1Controller.h:45
AODSystemController::actualRestoreSettings
void actualRestoreSettings(VP1Deserialise &)
Definition: AODSystemController.cxx:190
AODSystemController::actualSaveSettings
void actualSaveSettings(VP1Serialise &) const
Definition: AODSystemController.cxx:182
SoCooperativeSelection.h
VP1HelperClassBase::systemBase
IVP1System * systemBase() const
Definition: VP1HelperClassBase.h:50
python.selection.number
number
Definition: selection.py:20
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
AODSysCommonData::getNodeFromBrowser
SoNode * getNodeFromBrowser(QTreeWidgetItem *item)
Definition: AODSysCommonData.cxx:104
item
Definition: ItemListSvc.h:43
AODHandleBase::clicked
virtual QStringList clicked() const =0
Called when user selects the node (stringlist is displayed in messagebox).
AODSystemController::Imp::ui_objBrowser
Ui::AODObjectBrowser ui_objBrowser
Definition: AODSystemController.cxx:68
AODSystemController::Imp::objBrowserWidget
QTreeWidget * objBrowserWidget
Definition: AODSystemController.cxx:70
AODSystemController::Imp::common
AODSysCommonData * common
Definition: AODSystemController.cxx:71
AODSystemController::printInfoOnSingleSelection
bool printInfoOnSingleSelection() const
Definition: AODSystemController.cxx:263
AODSystemController::Imp::collwidget
AODCollWidget * collwidget
Definition: AODSystemController.cxx:60
get_generator_info.version
version
Definition: get_generator_info.py:33
AODSystemController::printVerboseInfoOnSingleSelection
bool printVerboseInfoOnSingleSelection() const
Definition: AODSystemController.cxx:270
AODSystemController::objectBrowserClicked
void objectBrowserClicked(QTreeWidgetItem *item, int)
Definition: AODSystemController.cxx:302
VP1ToolAccessHelper.h
AODHandleBase.h
AODSystemController::orientAndZoomOnSingleSelection
bool orientAndZoomOnSingleSelection() const
Definition: AODSystemController.cxx:256
VP1JobConfigInfo.h
VP1Controller::initLastVars
void initLastVars()
Definition: VP1Controller.cxx:68
IVP1System.h
node
Definition: memory_hooks-stdcmalloc.h:74
AODSystemController::collWidget
AODCollWidget * collWidget() const
Return widget which fills the collection selection list in the GUI (i.e. which finds and lists the av...
Definition: AODSystemController.cxx:196
common
Definition: common.py:1
SoCooperativeSelection
Definition: SoCooperativeSelection.h:29
VP1ControllerMacros.h