ATLAS Offline Software
Loading...
Searching...
No Matches
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"
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//____________________________________________________________________
57public:
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
74const 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);
109 m_d->collwidget = new AODCollWidget;
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"
205bool AODSystemController::Imp::updateComboBoxContents(QComboBox*cb,QStringList l,QString& restoredSelection)
206{
207 //current selection:
208 QString ct = cb->currentText();
209 if (ct==Imp::noneAvailString)
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}
301
302void 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
virtual QStringList clicked() const =0
Called when user selects the node (stringlist is displayed in messagebox).
AODHandleBase * getHandleFromNode(SoNode *node)
SoNode * getNodeFromBrowser(QTreeWidgetItem *item)
AODSystemController * theclass
Ui::AODObjectBrowser ui_objBrowser
bool updateComboBoxContents(QComboBox *cb, QStringList l, QString &restoredSelection)
static const QString noneAvailString
Ui::VP1AODControllerForm ui
QTreeWidget * objBrowser() const
Returns a pointer to the Track Object Browser (if it exists)
void actualSaveSettings(VP1Serialise &) const
bool printTotMomentumOnMultiTrackSelection() const
bool orientAndZoomOnSingleSelection() const
bool printVerboseInfoOnSingleSelection() const
void actualRestoreSettings(VP1Deserialise &)
bool showTotMomentumOnMultiTrackSelection() const
AODSysCommonData * common() const
Returns a pointer to the common data (if it exists)
bool printInfoOnSingleSelection() const
AODSystemController(IVP1System *sys)
AODCollWidget * collWidget() const
Return widget which fills the collection selection list in the GUI (i.e. which finds and lists the av...
void setCommonData(AODSysCommonData *)
set pointer to the common data
void objectBrowserClicked(QTreeWidgetItem *item, int)
void initDialog(T &theUI, QPushButton *launchbutton, QAbstractButton *enabledButton=0)
void setupCollWidgetInScrollArea(QScrollArea *scrollarea, VP1CollectionWidget *collWidget)
VP1Controller(IVP1System *sys, const QString &classname)
void messageVerbose(const QString &) const
IVP1System * systemBase() const
void messageDebug(const QString &) const
static bool environmentVariableIsSet(const QString &name)
Definition node.h:24