ATLAS Offline Software
Loading...
Searching...
No Matches
AODSystemController.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 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
32#endif
33#include "VP1Base/VP1QtUtils.h"
34#include "VP1Base/IVP1System.h"
40
41// SoCoin
42#include "Inventor/nodes/SoMaterial.h"
43#include "Inventor/nodes/SoDrawStyle.h"
44#include "Inventor/nodes/SoComplexity.h"
45#include "Inventor/nodes/SoLightModel.h"
46#include <Inventor/nodes/SoSeparator.h>
47#include <Inventor/actions/SoSearchAction.h>
48
49// Qt
50#include <QTreeWidget>
51#include <QTreeWidgetItem>
52
53#include <typeinfo>
54//____________________________________________________________________
56public:
58 Ui::VP1AODControllerForm ui;
60 bool updateComboBoxContents(QComboBox*cb,QStringList l,QString& restoredSelection);
61 static const QString noneAvailString;
62
63 // Ui::AODSysSettingsColouringForm ui_col;
64 // Ui::AODSysSettingsExtrapolationsForm ui_extrap;
65 // Ui::AODSysSettingsInteractionsForm ui_int;
66 // Ui::AODSysSettingsCutsForm ui_cuts;
67 Ui::AODObjectBrowser ui_objBrowser;
68
69 QTreeWidget* objBrowserWidget = nullptr;
71};
72
73const QString AODSystemController::Imp::noneAvailString = QString("None available");
74
75
76// //____________________________________________________________________
77// QString AODSystemController::toString( const QList<unsigned>& l )
78// {
79// QString s;
80// for(unsigned i :l) {
81// if (!s.isEmpty()) s+=", ";
82// s+=QString::number(i);
83// }
84// return "["+s+"]";
85// }
86//
87// //____________________________________________________________________
88// QString AODSystemController::toString( const QList<int>& l )
89// {
90// QString s;
91// for(int i : l) {
92// if (!s.isEmpty()) s+=", ";
93// s+=QString::number(i);
94// }
95// return "["+s+"]";
96// }
97
98//____________________________________________________________________
99
100
101//____________________________________________________________________
103 : VP1Controller(sys,"AODSystemController"), m_d(new Imp)
104{
105 m_d->theclass = this;
106 //Stuff with tools waits until ::initTools() is called:
107 m_d->ui.setupUi(this);
108 m_d->collwidget = new AODCollWidget;
109 setupCollWidgetInScrollArea(m_d->ui.collWidgetScrollArea,m_d->collwidget);
110
111 initDialog(m_d->ui_objBrowser, m_d->ui.pushButton_ObjectBrowser);
112
113 //init:
114 // m_d->initMaterials();
115
116
117
118 //Disable elements based on job configuration:
119
120
121
123 // Setup connections which monitor changes in the controller so that we may emit signals as appropriate: //
125
126
127 // TrackObjBrowser
128 messageVerbose("Enabling object browser");
129 m_d->objBrowserWidget = m_d->ui_objBrowser.treeWidget;
130 m_d->objBrowserWidget->setSortingEnabled(false);
131 QStringList l;
132 l<<"Object"<<"Information";
133 m_d->objBrowserWidget->setHeaderLabels(l);
134 connect(m_d->objBrowserWidget,SIGNAL(itemClicked(QTreeWidgetItem *, int)),this,SLOT(objectBrowserClicked(QTreeWidgetItem *, int)));
135
136 // Hide interactions until we're ready.
137 m_d->ui.pushButton_interactions->hide();
138
139 // Tell system to dump to JSON
140 connect(m_d->ui.pushButton_dumpToJSON,SIGNAL(pressed()),systemBase(),SLOT(dumpToJSON()));
141
142 if (VP1QtUtils::environmentVariableIsSet("VP1_DUMPTOJSON")){
143 messageVerbose("AODSystemController enable dumping to JSON");
144 m_d->ui.pushButton_dumpToJSON->setMaximumHeight(static_cast<int>(0.5+QFontMetricsF(m_d->ui.pushButton_dumpToJSON->font()).height()*1.05+2));
145 m_d->ui.pushButton_dumpToJSON->setMinimumHeight(m_d->ui.pushButton_dumpToJSON->maximumHeight());
146 m_d->ui.pushButton_dumpToJSON->setCheckable(true);
147
148 QSizePolicy sizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
149 sizePolicy.setHorizontalStretch(0);
150 sizePolicy.setVerticalStretch(0);
151 sizePolicy.setHeightForWidth(m_d->ui.pushButton_dumpToJSON->sizePolicy().hasHeightForWidth());
152 m_d->ui.pushButton_dumpToJSON->setSizePolicy(sizePolicy);
153 m_d->ui.pushButton_dumpToJSON->setFocusPolicy(Qt::NoFocus);
154 } else {
155 m_d->ui.pushButton_dumpToJSON->hide();
156 }
157
158 // we want "Print information" on single track selection turned ON by default
159 // //m_d->ui_int.checkBox_selsingle_printinfo->setChecked(true);
160
161 initLastVars();
162}
163
164//____________________________________________________________________
166{
167 messageVerbose("~AODSystemController begin");
168 delete m_d;
169 messageVerbose("~AODSystemController end");
170}
171
172//____________________________________________________________________
174{
175 int version = 1;
176 messageVerbose("AODSystemController::currentSettingsVersion() - current version: " + QString::number(version));
177 return version;
178}
179
180//____________________________________________________________________
182{
183 messageVerbose("AODSystemController::actualSaveSettings()");
184 messageDebug("version: " + QString::number(s.version()));
185
186}
187
188//____________________________________________________________________
190{
191 messageVerbose("AODSystemController::actualRestoreSettings()");
192}
193
194//____________________________________________________________________
196{
197 return m_d->collwidget;
198}
199
200//Access methods:
201
202//____________________________________________________________________
203//Returns false if "none available"
204bool AODSystemController::Imp::updateComboBoxContents(QComboBox*cb,QStringList l,QString& restoredSelection)
205{
206 //current selection:
207 QString ct = cb->currentText();
208 if (ct==Imp::noneAvailString)
209 ct = "";
210
211 bool save = cb->blockSignals(true);
212
213 cb->clear();
214
215 bool enabled = false;
216 if (l.isEmpty()) {
217 cb->addItem(Imp::noneAvailString);
218 cb->setEnabled(false);
219 } else {
220 cb->addItems(l);
221
222 int i = restoredSelection.isEmpty() ? -1 : cb->findText(restoredSelection);
223 if (i<0)
224 i = ct.isEmpty() ? -1 : cb->findText(ct);
225 restoredSelection = "";
226
227 if (i>=0) {
228 cb->setCurrentIndex(i);
229 } else {
230 //Let's try to pick the default to be VP1Extrapolater over
231 //AtlasExtrapolater over... whatever (same for fitters):
232 int i_vp1(-1), i_atlas(-1);
233 for (int j = 0; j <cb->count();++j) {
234 if (i_vp1==-1&&cb->itemText(j).contains("vp1",Qt::CaseInsensitive))
235 i_vp1 = j;
236 if (i_atlas==-1&&cb->itemText(j).contains("atlas",Qt::CaseInsensitive))
237 i_atlas = j;
238 }
239 if (i_vp1>=0)
240 cb->setCurrentIndex(i_vp1);
241 else if (i_atlas>=0)
242 cb->setCurrentIndex(i_atlas);
243 }
245 enabled = true;
246 cb->setEnabled(true);
247 }
248
249 if (!save)
250 cb->blockSignals(false);
251 return enabled;
252}
253
254//____________________________________________________________________
256{
257 return false;
258 // return m_d->ui_int.checkBox_selsingle_orientzoom->isChecked();
259}
260
261//____________________________________________________________________
263{
264 return false;
265 // return m_d->ui_int.checkBox_selsingle_printinfo->isChecked();
266}
267
268//____________________________________________________________________
270{
271 return false;
272 // return printInfoOnSingleSelection() && m_d->ui_int.checkBox_selsingle_printinfo_verbose->isChecked();
273}
274
275//____________________________________________________________________
277{
278 return false;
279 // return m_d->ui_int.checkBox_sel_printtotmom->isChecked();
280}
281
282//____________________________________________________________________
284{
285 return false;
286 // return m_d->ui_int.checkBox_sel_showtotmom->isChecked();
287}
288
290{
291 return m_d->objBrowserWidget;
292}
293
295 return m_d->common;
296}
300
301void AODSystemController::objectBrowserClicked(QTreeWidgetItem * item, int){
302 messageVerbose("objectBrowserClicked for "+item->text(0));
303 //
304 IVP1System* sysBase = systemBase();
305 if (!sysBase){
306 messageVerbose("AODSystemController::objectBrowserClicked: Couldn't get system base pointer");
307 return;
308 }
309
310 VP1AODSystem* sys = dynamic_cast<VP1AODSystem*>(sysBase);
311 if (!sys){
312 messageVerbose("AODSystemController::objectBrowserClicked: Couldn't get VP1AODSystem pointer");
313 std::cout<<"Pointer value = "<<sysBase<<" and type = "<<typeid(sysBase).name()<<std::endl;
314 return;
315 }
316
317
318 sys->deselectAll(); // FIXME. necessary?
319 //
320 SoNode* node = common()->getNodeFromBrowser(item);
321 if (node) {
322 std::cout<< "Have node from browser: "<<node<<std::endl;
323
325 handle->clicked();
326 // okay, have object
327
328 SoCooperativeSelection * sel = sys->selObjects();
329 std::cout<< "sel->select(node): "<<node<<std::endl;
330
331 sel->select(node);
332 }
333 messageVerbose("end objectBrowserClicked ");
334}
335
337// Test for possible changes in values and emit signals as appropriate:
338// (possibleChange_XXX() slots code provided by macros)
339#define VP1CONTROLLERCLASSNAME AODSystemController
341
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