ATLAS Offline Software
Loading...
Searching...
No Matches
JetCollectionSettingsButton.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
5// Local
8// UIs
9#include "ui_periparticlecollectionsettings_form.h"
10#include "ui_jet_settings_display_form.h"
11
12//VP1
16#include "VP1Base/VP1Msg.h"
17
18//Coin3D
19#include "Inventor/nodes/SoDrawStyle.h"
20#include "Inventor/nodes/SoLightModel.h"
21#include "Inventor/nodes/SoMaterial.h"
22
23// Qt
24#include <QTimer>
25#include <QByteArray>
26#include <QBuffer>
27#include <QDataStream>
28#include <QMouseEvent>
29#include <QDragEnterEvent>
30#include <QDropEvent>
31#include <QShortcut>
32#include <QMimeData>
33#include <QDrag>
34
35// Misc
36#include <iostream>
37
38//____________________________________________________________________
40public:
41
42// Imp():theclass(0),editwindow(0),matButton(0), trackDrawStyle(0), trackLightModel(0){}
48
49 // the main class
51
52 // setup the UI
53 QWidget * editwindow; // the main window
54 Ui::IParticleCollectionSettingsForm editwindow_ui{}; // the common main UI window
55 Ui::JetSysSettingsDisplayForm ui_disp{}; // the custom jet cuts
56
57 VP1MaterialButton* matButton;// main collection colour
58// VP1MaterialButton* defaultParametersMatButton;
59
60// QList<VP1MaterialButton*> parameterTypeMatButtons;// enum used to access the specific button
61
62// SoDrawStyle * trackDrawStyle;
63// SoLightModel * trackLightModel;
64
65 //GUI - last values
69 QList<VP1Interval> last_cutAllowedPhi;
70 double last_scale;
74 double last_maxR;
75// double last_trackTubeRadius;
76// QList<unsigned> last_cutRequiredNHits;
77// bool last_cutOnlyVertexAssocTracks;
78
79 // GUI b-tagging
84// SoMaterial* last_bTaggingMaterial; // not needed...
87
88 // jet material
90
91 // b-tagging material
92 SoMaterial * materialFallback;
93
94 // material functions
95 SoMaterial * getMat(VP1MaterialButton*) const;
96 SoMaterial * createMaterial(int r, int g, int b) const;
97 SoMaterial * createMaterial(int r, int g, int b, float brightness, float transparency) const;
98
99
100 int dim;
101 QString name;
103
104 void initEditWindow();
105};
106
107
108//____________________________________________________________________
109SoMaterial * JetCollectionSettingsButton::Imp::createMaterial(int r, int g, int b) const
110{
111 return VP1MaterialButton::createMaterial(r/255.0,g/255.0,b/255.0,0.2/*brightness*/);
112}
113//____________________________________________________________________
115 float brightness,
116 float transparency) const
117{
118 return VP1MaterialButton::createMaterial(r/255.0,g/255.0,b/255.0, brightness, transparency);
119}
120
121//____________________________________________________________________
123{
124 if (editwindow)
125 return;
126 theclass->messageVerbose("Initialising material editor dialog");
127
128 // create a parent widget
129 editwindow = new QWidget(0,Qt::WindowStaysOnTopHint); // parent widget
130
131
132
133 // init the different UIs
134 editwindow_ui.setupUi(editwindow); //IParticleCollectionSettingsForm
135 auto jetsettings = new QWidget();
136 editwindow_ui.verticalLayout_additional_widgets->addWidget(jetsettings);
137 ui_disp.setupUi(jetsettings); //JetSysSettingsDisplayForm
138
140 // change labels to match jets' nomenclature
141 editwindow_ui.groupBox_cuts_momentum->setTitle("Energy cuts");
142 editwindow_ui.checkBox_cut_minpt->setText("Min Energy");
143 editwindow_ui.checkBox_cut_maxpt->setText("Max Energy");
144 editwindow_ui.comboBox_momtype->setItemText(0, "Et");
145 editwindow_ui.comboBox_momtype->setItemText(1, "E");
146 // change initial values to match jets' typical values
147 editwindow_ui.doubleSpinBox_cut_minpt_gev->setValue(10.00);
148 editwindow_ui.doubleSpinBox_cut_maxpt_gev->setValue(100.00);
149
150 // get a handle on the material button
151 matButton = editwindow_ui.pushButton_matButton;
152
153 // compose UI: adding to the default GUI the "display" custom cuts for jets
154 editwindow_ui.verticalLayout_additional_widgets->layout()->addWidget( ui_disp.groupBox_jet_display );
155
156 // set b-tagging taggers
157 ui_disp.bTaggingComboBox->clear(); // remove all taggers defined in the .ui file
158
159 QStringList bTagList;
160 //bTagList << "MV2c20" << "MV2c10" << "MV1" << "JetFitterCombNN_pb" << "JetFitterCombNN_pc" << "JetFitterCombNN_pu";
161 //bTagList << "MV2c20" << "MV2c10" << "MV2c00" << "MV1" << "JetFitterCombNN_pb" << "JetFitterCombNN_pc" << "JetFitterCombNN_pu"; // the JetFitter helpers have been removed in xAODBTagging-00-00-35
162// bTagList << "MV2c20" << "MV2c10" << "MV2c00" << "MV1"; // (cfr. SVN changesets 797165 + 801102)
163 bTagList << "MV2c20" << "MV2c10" << "MV2c00"; // 28 Sep 2017
164 ui_disp.bTaggingComboBox->insertItems(0, bTagList);
165
166 // set b-tagging "Material" checked by default ("Skin" will be optional)
167 ui_disp.radioButton_material->setChecked(true);
168
169 // x-y projection
170 ui_disp.groupBox_IDprojection->setEnabled(false); // TODO: check what it did in previous versions and fix it!
171
172 // when creating a new controller, check if b-tagging checkbox is enabled,
173 // for example from a config file or from a drag&drop from another collection
174 if (ui_disp.bTaggingCheckBox->isChecked())
175 theclass->possibleChange_bTaggingEnabled(true); // init the b-tagging toolbox as active
176 else
177 theclass->possibleChange_bTaggingEnabled(false); // init the b-tagging toolbox as not-active
178}
179
180//____________________________________________________________________
182{
183 VP1Msg::messageVerbose("JetCollectionSettingsButton::setMaterialText()");
184 if (m_d->editwindow)
185 m_d->editwindow->setWindowTitle(t);
186 setToolTip(t);
187}
188
189
190
191//____________________________________________________________________
193{
194 double val = m_d->ui_disp.doubleSpinBox_lengthOf100GeV->value();
195 bool isEt = m_d->ui_disp.comboBox_energytype->currentText()=="Et";
196 val = val * ( isEt ? 1:-1);
197 VP1Msg::messageVerbose("JetCollectionSettingsButton::lengthOf100GeV() - value: " + QString::number(val));
198 return val;
199}
200
201//____________________________________________________________________
203{
204 double val = m_d->ui_disp.checkBox_maxR->isChecked() ? (m_d->ui_disp.doubleSpinBox_maxR->value() ) : -1; //m_d->ui_disp.doubleSpinBox_maxR->value();
205 VP1Msg::messageVerbose("JetCollectionSettingsButton::maxR() - value: " + QString::number(val));
206 return val;
207}
208
209
210//____________________________________________________________________
212 return m_d->ui_disp.bTaggingSpinBox->value();
213}
214//____________________________________________________________________
216 return m_d->ui_disp.bTaggingComboBox->currentText();
217}
218//____________________________________________________________________
220 return m_d->ui_disp.skinsComboBox->currentText();
221}
222//____________________________________________________________________
224 return getMaterial(m_d->ui_disp.matButton_btaggedJets);
225}
226//____________________________________________________________________
228 return m_d->ui_disp.bTaggingCheckBox->isChecked();
229}
230//____________________________________________________________________
232 return m_d->ui_disp.radioButton_skins->isChecked();
233}
234//____________________________________________________________________
236 return m_d->ui_disp.radioButton_material->isChecked();
237}
238
239//____________________________________________________________________
241{
242 return m_d->ui_disp.radioButton_skins->isChecked();
243}
244
245//____________________________________________________________________
247{
248 return m_d->ui_disp.radioButton_material->isChecked();
249}
250
251
252
253
254
255//____________________________________________________________________
256JetCollectionSettingsButton::JetCollectionSettingsButton(QWidget * parent,int dim, const QString& name)
258//: VP1CollectionSettingsButtonBase(parent,0,"VP1MaterialButton"), m_d(new Imp)
259{
260 m_d->dim = dim;
261 m_d->name = name;
262
263 m_d->theclass = this;
264 m_d->initEditWindow();
265
266
268 // Setup connections which monitor changes in the controller so that we may emit signals as appropriate: //
270
271
272
273// //Draw Styles / Complexity:
274// VP1QtInventorUtils::setLimitsLineWidthSlider(m_d->editwindow_ui.horizontalSlider_trackWidth);
275// VP1QtInventorUtils::setValueLineWidthSlider(m_d->editwindow_ui.horizontalSlider_trackWidth,1.0);
276
277// m_d->trackDrawStyle = new SoDrawStyle;
278// m_d->trackDrawStyle->setName("JetDrawStyle");
279// m_d->trackDrawStyle->pointSize=5.0;
280// m_d->trackDrawStyle->ref();
281// updateTrackDrawStyle();
282// connect(m_d->editwindow_ui.horizontalSlider_trackWidth,SIGNAL(valueChanged(int)),this,SLOT(updateTrackDrawStyle()));
283
284// m_d->trackLightModel = new SoLightModel;
285// m_d->trackLightModel->setName("JetLightModel");
286// m_d->trackLightModel->ref();
287// updateTrackLightModel(false);
288// connect(m_d->editwindow_ui.checkBox_tracksUseBaseLightModel,SIGNAL(toggled(bool)),this,SLOT(updateTrackLightModel(bool)));
289//
290// m_d->last_trackTubeRadius=trackTubeRadius();
291// connect(m_d->editwindow_ui.checkBox_trackTubes,SIGNAL(toggled(bool)),this,SLOT(updateTrackTubeRadius()));
292// connect(m_d->editwindow_ui.doubleSpinBox_trackTubesRadiusMM,SIGNAL(valueChanged(double)),this,SLOT(updateTrackTubeRadius()));
293//
294// connect(m_d->editwindow_ui.checkBox_hideactualpaths,SIGNAL(toggled(bool)),this,SLOT(updateHideActualTrackPath(bool)));
295
296// // -> parameters
297// connect(m_d->editwindow_ui.checkBox_showparameters,SIGNAL(toggled(bool)),this,SLOT(possibleChange_showParameters()));
298// connect(m_d->editwindow_ui.checkBox_parameters_colourByType,SIGNAL(toggled(bool)),this,SLOT(possibleChange_parameterColours()));
299
300
301 // -> scale
302 connect(m_d->ui_disp.doubleSpinBox_lengthOf100GeV,SIGNAL(valueChanged(double)),this,SLOT(possibleChange_scale()));
303 connect(m_d->ui_disp.comboBox_energytype,SIGNAL(currentIndexChanged(int)),this,SLOT(possibleChange_scale()));
304
305 // -> cutAllowedP/Pt
306 connect(m_d->editwindow_ui.checkBox_cut_minpt,SIGNAL(toggled(bool)),this,SLOT(possibleChange_cutAllowedPt()));
307 connect(m_d->editwindow_ui.checkBox_cut_maxpt,SIGNAL(toggled(bool)),this,SLOT(possibleChange_cutAllowedPt()));
308 connect(m_d->editwindow_ui.doubleSpinBox_cut_minpt_gev,SIGNAL(valueChanged(double)),this,SLOT(possibleChange_cutAllowedPt()));
309 connect(m_d->editwindow_ui.doubleSpinBox_cut_maxpt_gev,SIGNAL(valueChanged(double)),this,SLOT(possibleChange_cutAllowedPt()));
310 connect(m_d->editwindow_ui.checkBox_cut_minpt,SIGNAL(toggled(bool)),this,SLOT(possibleChange_cutAllowedPt()));
311 connect(m_d->editwindow_ui.comboBox_momtype,SIGNAL(currentIndexChanged(int)),this,SLOT(possibleChange_cutAllowedPt()));
312
313 // -> cutAllowedEta
314 connect(m_d->editwindow_ui.etaPhiCutWidget,SIGNAL(allowedEtaChanged(const VP1Interval&)),this,SLOT(possibleChange_cutAllowedEta()));
315
316 // -> cutAllowedPhi
317 connect(m_d->editwindow_ui.etaPhiCutWidget,SIGNAL(allowedPhiChanged(const QList<VP1Interval>&)),this,SLOT(possibleChange_cutAllowedPhi()));
318
319 // random colors
320 connect(m_d->ui_disp.checkBox_randomColours, SIGNAL(toggled(bool)), this, SLOT(enableRandomColours(bool)));
321 connect(m_d->ui_disp.checkBox_randomColours, SIGNAL(toggled(bool)), this, SLOT(possibleChange_randomJetColours()));
322 connect(m_d->ui_disp.pushButton_colourbyrandom_rerandomise,SIGNAL(clicked()),this,SLOT(emitRerandomise()));
323 this->enableRandomColours(false);
324
325 // maxR
326 connect(m_d->ui_disp.checkBox_maxR, SIGNAL(toggled(bool)), this, SLOT(enableMaxR(bool)));
327 connect(m_d->ui_disp.checkBox_maxR, SIGNAL(toggled(bool)), this, SLOT(possibleChange_maxR()));
328 connect(m_d->ui_disp.doubleSpinBox_maxR, SIGNAL(valueChanged(double)), this, SLOT(possibleChange_maxR()));
329 this->enableMaxR(false); // init
330
331 // BTagging
332 connect(m_d->ui_disp.bTaggingCheckBox, SIGNAL(toggled(bool)), this, SLOT(possibleChange_bTaggingEnabled(bool)) );
333
334 connect(m_d->ui_disp.bTaggingComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(possibleChange_bTaggingTagger()) );
335
336 connect(m_d->ui_disp.bTaggingSpinBox, SIGNAL(valueChanged(double)), this, SLOT(possibleChange_bTaggingCut()) );
337
338 connect(m_d->ui_disp.radioButton_material, SIGNAL(toggled(bool)), this, SLOT(possibleChange_bTaggingRenderingMaterial(bool)) );
339
340 // not needed...
341 //connect(m_d->ui_disp.matButton_btaggedJets, SIGNAL(lastAppliedChanged()), this, SLOT(possibleChange_bTaggingMaterial()) );
342
343 connect(m_d->ui_disp.radioButton_skins, SIGNAL(toggled(bool)), this, SLOT(possibleChange_bTaggingRenderingSkin(bool)) );
344
345
346 // Material button
347 connect(this,SIGNAL(clicked()),this,SLOT(showEditMaterialDialog()));
348 connect(m_d->editwindow_ui.pushButton_close,SIGNAL(clicked()),this,SLOT(showEditMaterialDialog()));
349 connect(m_d->matButton,SIGNAL(lastAppliedChanged()),this,SLOT(updateButton()));
350 connect(m_d->matButton,SIGNAL(lastAppliedChanged()),this,SIGNAL(lastAppliedChanged()));
351 setAcceptDrops(true);
352
353 QTimer::singleShot(0, this, SLOT(updateButton()));
354
356 // Custom Materials //
358
359
360 // create default material for b-jets
361 m_d->materialFallback = m_d->createMaterial(116,255,228, 0.2, 0.3); // light greenish-blue (R,G,B, brightness, transparency)
362 m_d->materialFallback->ref();
363
364
365
366 // init material for b-tagged jet
367 m_d->ui_disp.matButton_btaggedJets->setMaterial(m_d->materialFallback);
368
369// updateButton();
370
371
372}
373
374// QWidget& JetCollectionSettingsButton::editWindow() {
375// if (!m_d->editwindow)
376// initEditWindow();
377// return *(m_d->editwindow);
378// }
380{
381 delete m_d->editwindow;
382// m_d->trackDrawStyle->unref();
383// m_d->trackLightModel->unref();
384 delete m_d;
385}
386
388{
389 if (objectName().isEmpty())
390 setObjectName("JetCollectionSettingsButton");
391 messageVerbose("jet - setColButtonProperties: color=" + str(m_d->matButton->lastAppliedDiffuseColour()));
392 VP1ColorSelectButton::setColButtonProperties(this,m_d->matButton->lastAppliedDiffuseColour(),m_d->dim);
393}
394
396{
397 if (m_d->dim == dim)
398 return;
399 m_d->dim = dim;
400 updateButton();
401}
402
404{
405 if (!m_d->editwindow)
406 m_d->initEditWindow();
407
408 if (m_d->editwindow->isHidden())
409 m_d->editwindow->show();
410 else
411 m_d->editwindow->hide();
412}
413
415{
416 // std::cout<<"JetCollectionSettingsButton::setMaterial with mat="<<mat<<std::endl;
417 if (!m_d->matButton) m_d->initEditWindow();
418 m_d->matButton->setMaterial(mat);
419 return true;
420}
421
426
428{
429 if (!m_d->matButton) m_d->initEditWindow();
430 m_d->matButton->setMaterial(mat);
431}
433{
434 if (!m_d->matButton) m_d->initEditWindow();
435 return m_d->matButton->lastAppliedTransparency();
436}
438{
439 if (!m_d->matButton) m_d->initEditWindow();
440 return m_d->matButton->lastAppliedShininess();
441}
443{
444 if (!m_d->matButton) m_d->initEditWindow();
445 return m_d->matButton->lastAppliedBrightness();
446}
447
448//double JetCollectionSettingsButton::trackTubeRadius() const
449//{
450// return m_d->editwindow_ui.checkBox_trackTubes->isChecked() ?
451// m_d->editwindow_ui.doubleSpinBox_trackTubesRadiusMM->value() : 0.0;
452//}
453//
454//void JetCollectionSettingsButton::updateTrackTubeRadius()
455//{
456// if (m_d->last_trackTubeRadius==trackTubeRadius()) return;
457// m_d->last_trackTubeRadius=trackTubeRadius();
458// messageVerbose("TrackTubeRadius changed to "+str(m_d->last_trackTubeRadius));
459// emit trackTubeRadiusChanged(m_d->last_trackTubeRadius);
460// return;
461//}
462//
463//void JetCollectionSettingsButton::updateTrackDrawStyle()
464//{
465// double val = VP1QtInventorUtils::getValueLineWidthSlider(m_d->editwindow_ui.horizontalSlider_trackWidth);
466// if (m_d->trackDrawStyle->lineWidth.getValue()!=val)
467// m_d->trackDrawStyle->lineWidth = val;
468//}
469//
470//void JetCollectionSettingsButton::updateTrackLightModel(bool base)
471//{
472// if (m_d->trackLightModel->model.getValue()!=(base?SoLightModel::BASE_COLOR:SoLightModel::PHONG)) {
473// messageVerbose("TrackLightModel changed (base = "+str(base));
474// if (base)
475// m_d->trackLightModel->model.setValue(SoLightModel::BASE_COLOR);
476// else
477// m_d->trackLightModel->model.setValue(SoLightModel::PHONG);
478// }
479//}
480//
481//void JetCollectionSettingsButton::updateHideActualTrackPath(bool hide)
482//{
483// emit hideActualTrackPathChanged(hide);
484//}
485//
486//
487//SoDrawStyle * JetCollectionSettingsButton::trackDrawStyle() const
488//{
489// return m_d->trackDrawStyle;
490//}
491//
492//SoLightModel * JetCollectionSettingsButton::trackLightModel() const
493//{
494// return m_d->trackLightModel;
495//}
496//
497//SoMaterial* JetCollectionSettingsButton::defaultParameterMaterial() const {
498// return m_d->defaultParametersMatButton->handledMaterials().at(0);// Only have one material per button.
499//}
500//SoMaterial* JetCollectionSettingsButton::parameterMaterial( xAOD::ParameterPosition position) const{
501// return (m_d->parameterTypeMatButtons.at(static_cast<unsigned int>(position)))->handledMaterials().at(0);// Only have one material per button.
502//}
503
504// void setDefaultParameterMaterial(SoMaterial* mat) {
505// // m_d->defaultParametersMatButton->setObjectName("matButton_default");
506// // m_d->defaultParametersMatButton->setToolTip(matButtonToolTip());
507// m_d->defaultParametersMatButton->setMaterial(mat);
508// // connect(m_d->matButton,SIGNAL(lastAppliedChanged()),this,SLOT(possibleChangeMatTranspOrBrightness()));
509// }
510//
511// void JetCollectionSettingsButton::setParameterMaterial(SoMaterial*, xAOD::ParameterPosition){
512// // FIXME!
513// }
514
515//bool JetCollectionSettingsButton::hideActualTrackPath() const
516//{
517// if (!m_d->editwindow)
518// m_d->initEditWindow();
519// return m_d->editwindow_ui.checkBox_hideactualpaths->isChecked();
520//}
521//
522//bool JetCollectionSettingsButton::showParameters() const
523//{
524// if (!m_d->editwindow)
525// m_d->initEditWindow();
526// messageVerbose("JetCollectionSettingsButton::showParameters returning "+str(m_d->editwindow_ui.checkBox_showparameters->isChecked()));
527// return m_d->editwindow_ui.checkBox_showparameters->isChecked();
528//}
529//
530//bool JetCollectionSettingsButton::colourParametersByType() const
531//{
532// if (!m_d->editwindow)
533// m_d->initEditWindow();
534// messageVerbose("JetCollectionSettingsButton::colourParametersByType returning "+str(m_d->editwindow_ui.checkBox_parameters_colourByType->isChecked()));
535// return m_d->editwindow_ui.checkBox_parameters_colourByType->isChecked();
536//}
537//
538//
539//bool JetCollectionSettingsButton::cutOnlyVertexAssocTracks() const
540//{
541// if (!m_d->editwindow)
542// m_d->initEditWindow();
543// return m_d->editwindow_ui.checkBox_vertexAssociated->isChecked();
544//}
545
546//____________________________________________________________________
548{
549 if (event->button() == Qt::LeftButton)
550 m_d->dragStartPosition = event->pos();
551 QPushButton::mousePressEvent(event);
552}
553
554//____________________________________________________________________
556{
557 if (event->source()!=this && event->mimeData()->hasFormat("vp1/material"))
558 event->acceptProposedAction();
559}
560
561//____________________________________________________________________
563{
564 if (!(event->buttons() & Qt::LeftButton))
565 return;
566 if ((event->pos() - m_d->dragStartPosition).manhattanLength()
567 < QApplication::startDragDistance())
568 return;
569
570 QDrag *drag = new QDrag(this);
571 QMimeData *mimeData = new QMimeData;
572
574 // For dragging state onto other material buttons: //
576
577 QByteArray byteArray = saveState();
578
579 // buffer.close();
580 mimeData->setData("vp1/material", byteArray);
581
582 // ////////////////////////////////////////////////////////
583 // // For dragging c++ code for defining this material //
584 // // into e.g. an editor: //
585 // ////////////////////////////////////////////////////////
586 //
587 // QString s = "SoMaterial * mat = new SoMaterial;\n";
588 // QString str_ambient = m_d->toSbColTxt(m_d->lastapplied_ambient);
589 // if (str_ambient!="SbColor(0.2,0.2,0.2)")
590 // s += "mat->ambientColor.setValue("+str_ambient+");\n";
591 // QString str_diffuse = m_d->toSbColTxt(m_d->lastapplied_diffuse);
592 // if (str_diffuse!="SbColor(0.8,0.8,0.8)")
593 // s += "mat->diffuseColor.setValue("+str_diffuse+");\n";
594 // QString str_specular = m_d->toSbColTxt(m_d->lastapplied_specular);
595 // if (str_specular!="SbColor(0,0,0)")
596 // s += "mat->specularColor.setValue("+str_specular+");\n";
597 // QString str_emissive = m_d->toSbColTxt(m_d->lastapplied_emissive);
598 // if (str_emissive!="SbColor(0,0,0)")
599 // s += "mat->emissiveColor.setValue("+str_emissive+");\n";
600 // QString str_shininess = m_d->printFloat(m_d->lastapplied_shininess/100.0);
601 // if (str_shininess!="0.2")
602 // s += "mat->shininess.setValue("+str_shininess+");\n";
603 // QString str_transparency = m_d->printFloat(m_d->lastapplied_transparency/100.0);
604 // if (str_transparency!="0")
605 // s += "mat->transparency.setValue("+str_transparency+");\n";
606 // mimeData->setText(s);
607
608 //Execute drag:
609 drag->setMimeData(mimeData);//drag assumes ownership of mimeData
610 drag->exec(Qt::CopyAction | Qt::MoveAction);
611}
612
613//____________________________________________________________________
615{
616 QByteArray data = event->mimeData()->data("vp1/material");
617 event->acceptProposedAction();
619}
620
621
623
624 messageDebug("JetCollectionSettingsButton::saveState()");
625
626 // messageVerbose("getState");
627 // if (m_d->editwindow_ui.checkBox_tracksUseBaseLightModel->isChecked()) messageVerbose("checked!");
628 VP1Serialise serialise(1/*version*/);
629
630
631 serialise.save(m_d->matButton);
632 //serialise.disableUnsavedChecks(); // TODO: what this does??
633
634 // COMMON SETTINGS
635 serialise.save(m_d->editwindow_ui.checkBox_tracksUseBaseLightModel);
636 serialise.save(m_d->editwindow_ui.checkBox_cut_minpt);
637 serialise.save(m_d->editwindow_ui.doubleSpinBox_cut_minpt_gev);
638 serialise.save(m_d->editwindow_ui.checkBox_cut_maxpt);
639 serialise.save(m_d->editwindow_ui.doubleSpinBox_cut_maxpt_gev);
640 serialise.save(m_d->editwindow_ui.comboBox_momtype);
641
642 // ETA-PHI CUTS (from VP1Base/VP1EtaPhiCutWidget.cxx)
643 serialise.save(m_d->editwindow_ui.etaPhiCutWidget);
644
645 // JET SETTINGS
646 serialise.save(m_d->ui_disp.checkBox_randomColours);
647 serialise.save(m_d->ui_disp.doubleSpinBox_lengthOf100GeV);
648 serialise.save(m_d->ui_disp.comboBox_energytype);
649 serialise.save(m_d->ui_disp.checkBox_maxR);
650 serialise.save(m_d->ui_disp.doubleSpinBox_maxR);
651
652 serialise.save(m_d->ui_disp.groupBox_IDprojection);
653 serialise.save(m_d->ui_disp.checkBox_radialScale);
654 serialise.save(m_d->ui_disp.doubleSpinBox_radialScale);
655
656 serialise.save(m_d->ui_disp.bTaggingCheckBox);
657 serialise.save(m_d->ui_disp.bTaggingComboBox);
658 serialise.save(m_d->ui_disp.bTaggingSpinBox);
659 serialise.save(m_d->ui_disp.radioButton_material, m_d->ui_disp.radioButton_skins);
660 serialise.save(m_d->ui_disp.matButton_btaggedJets);
661 serialise.save(m_d->ui_disp.skinsComboBox);
662
663 // Parameters
664// serialise.save(m_d->editwindow_ui.checkBox_showparameters);
665// serialise.save(m_d->editwindow_ui.checkBox_parameters_colourByType);
666
667 serialise.widgetHandled(this);
668 serialise.warnUnsaved(this);
669 return serialise.result();
670}
671
673
674 messageDebug("JetCollectionSettingsButton::restoreFromState()");
675
676 VP1Deserialise state(ba,systemBase());
677 if (state.version()<0||state.version()>1) {
678 messageDebug("restoreFromState() - ignoring...");
679 return;//Ignore silently
680 }
681 state.restore(m_d->matButton);
682
683
684 // COMMON SETTINGS
685 state.restore(m_d->editwindow_ui.checkBox_tracksUseBaseLightModel);
686 state.restore(m_d->editwindow_ui.checkBox_cut_minpt);
687 state.restore(m_d->editwindow_ui.doubleSpinBox_cut_minpt_gev);
688 state.restore(m_d->editwindow_ui.checkBox_cut_maxpt);
689 state.restore(m_d->editwindow_ui.doubleSpinBox_cut_maxpt_gev);
690 state.restore(m_d->editwindow_ui.comboBox_momtype);
691
692 // ETA-PHI CUTS (from VP1Base/VP1EtaPhiCutWidget.cxx)
693 state.restore(m_d->editwindow_ui.etaPhiCutWidget);
694
695 // JET SETTINGS
696 state.restore(m_d->ui_disp.checkBox_randomColours);
697 state.restore(m_d->ui_disp.doubleSpinBox_lengthOf100GeV);
698 state.restore(m_d->ui_disp.comboBox_energytype);
699 state.restore(m_d->ui_disp.checkBox_maxR);
700 state.restore(m_d->ui_disp.doubleSpinBox_maxR);
701
702 state.restore(m_d->ui_disp.groupBox_IDprojection);
703 state.restore(m_d->ui_disp.checkBox_radialScale);
704 state.restore(m_d->ui_disp.doubleSpinBox_radialScale);
705
706 state.restore(m_d->ui_disp.bTaggingCheckBox);
707 state.restore(m_d->ui_disp.bTaggingComboBox);
708 state.restore(m_d->ui_disp.bTaggingSpinBox);
709 state.restore(m_d->ui_disp.radioButton_material, m_d->ui_disp.radioButton_skins);
710 state.restore(m_d->ui_disp.matButton_btaggedJets);
711 state.restore(m_d->ui_disp.skinsComboBox);
712
713
714 // // Parameters
715// state.restore(m_d->editwindow_ui.checkBox_showparameters);
716// state.restore(m_d->editwindow_ui.checkBox_parameters_colourByType);
717
718 state.widgetHandled(this);
719 state.warnUnrestored(this);
720
721// updateTrackTubeRadius();
722// updateTrackLightModel(m_d->editwindow_ui.checkBox_tracksUseBaseLightModel);
723
724 updateButton();
725
726 // after restoring the state, check status of selection cuts
728
729
730}
731
732//____________________________________________________________________
734{
735 messageDebug("JetCollectionSettingsButton::checkSelection()");
736
737 // -- b-tagging settings/cuts
738 messageDebug("updating b-tagging status for collection " + m_d->name + "...");
739 if (m_d->ui_disp.bTaggingCheckBox->isChecked()) {
740 possibleChange_bTaggingEnabled(true); // init the b-tagging toolbox as active
742 if (m_d->ui_disp.radioButton_material->isChecked())
744 else if (m_d->ui_disp.radioButton_skins->isChecked())
747 }
748 else
749 possibleChange_bTaggingEnabled(false); // init the b-tagging toolbox as not-active
750
751 // -- other cuts
752 messageDebug("updating other selection cuts for collection " + m_d->name + "...");
759 //FIXME - anything else need updating?
760}
761
762//____________________________________________________________________
764{
765 if (!m_d->editwindow)
766 m_d->initEditWindow();
767 if (!m_d->editwindow_ui.checkBox_cut_minpt)
768 return VP1Interval();
769
770 // will set range to negative if we have momcut=P
771 // if minCut unset then min=-inf
772 // if minCut set, and Pt selected, then min=-minCut
773 // if minCut set, and P selected, then min=-maxCut
774 // etc
775 bool isPCut = m_d->editwindow_ui.comboBox_momtype->currentText()=="P";
776
777 const double minFromInterface=m_d->editwindow_ui.doubleSpinBox_cut_minpt_gev->value()*1000;
778 const double maxFromInterface=m_d->editwindow_ui.doubleSpinBox_cut_maxpt_gev->value()*1000;
779
780 double min=0.0,max=0.0;
781 if (!isPCut) {
782 //Pt cut
783 min = (m_d->editwindow_ui.checkBox_cut_minpt->isChecked() ? minFromInterface : -std::numeric_limits<double>::infinity());
784 max = (m_d->editwindow_ui.checkBox_cut_maxpt->isChecked() ? maxFromInterface : std::numeric_limits<double>::infinity());
785 } else {
786 min = (m_d->editwindow_ui.checkBox_cut_maxpt->isChecked() ? -maxFromInterface : -std::numeric_limits<double>::infinity());
787 max = (m_d->editwindow_ui.checkBox_cut_minpt->isChecked() ? -minFromInterface : std::numeric_limits<double>::infinity());
788 }
789
790 //message("cutAllowedPt: min,max="+QString::number(min)+","+QString::number(max));
791
792 if (max<min)
793 return VP1Interval();
794
795 return VP1Interval( min, max );//fixme: closed interval??
796}
797
798//____________________________________________________________________
800{
801 if (!m_d->editwindow)
802 m_d->initEditWindow();
803 return m_d->editwindow_ui.etaPhiCutWidget->allowedEta();
804}
805
806//____________________________________________________________________
808{
809 if (!m_d->editwindow)
810 m_d->initEditWindow();
811 return m_d->editwindow_ui.etaPhiCutWidget->allowedPhi();
812}
813
814
815
817{
818 messageVerbose("possibleChange_cutAllowedPt() ");
819
820 if (m_d->last_cutAllowedPt==cutAllowedPt()) return;
821 messageVerbose("cutAllowedPt() changed");
822 m_d->last_cutAllowedPt= cutAllowedPt();
823 emit cutAllowedPtChanged(m_d->last_cutAllowedPt);
824}
825
827{
828 if (m_d->last_cutAllowedEta==cutAllowedEta()) return;
829 messageVerbose("cutAllowedEta() changed");
830 m_d->last_cutAllowedEta=cutAllowedEta();
831 emit cutAllowedEtaChanged(m_d->last_cutAllowedEta);
832}
833
835{
836 if (m_d->last_cutAllowedPhi==cutAllowedPhi()) return;
837 messageVerbose("cutAllowedPhi() changed");
838 m_d->last_cutAllowedPhi=cutAllowedPhi();
839 emit cutAllowedPhiChanged(m_d->last_cutAllowedPhi);
840}
841
843{
844 messageVerbose("possibleChange_scale() ");
845 if (m_d->last_scale == lengthOf100GeV()) return;
846
847 messageVerbose("lengthOf100GeV changed");
848 m_d->last_scale = lengthOf100GeV();
849 emit scaleChanged(m_d->last_scale);
850}
851
852
854{
855 messageVerbose("possibleChange_randomJetColours() ");
856
857 if (m_d->last_randomJetColours == randomJetColours() ) return;
858 messageVerbose("checkBox_randomColours changed");
859 m_d->last_randomJetColours = randomJetColours();
860 emit randomJetColoursChanged(m_d->last_randomJetColours);
861}
862
863
864//____________________________________________________________________
866{
867 m_d->ui_disp.pushButton_colourbyrandom_rerandomise->setEnabled(bb);
868}
869
870//____________________________________________________________________
872{
873 return m_d->ui_disp.checkBox_randomColours->isChecked();
874}
875
876
877//____________________________________________________________________
879{
880 messageVerbose("JetCollectionSettingsButton - Emitting rerandomise");
881 emit rerandomise();
882}
883
885//void JetCollectionSettingsButton::emitMaxR()
886//{
887// messageVerbose("JetCollectionSettingsButton - Emitting signalMaxR");
888// emit signalMaxR();
889//}
890
891//____________________________________________________________________
893{
894 m_d->ui_disp.doubleSpinBox_maxR->setEnabled(bb);
895}
896
897//____________________________________________________________________
899{
900 messageVerbose("possibleChange_maxR() ");
901
902 if ( ! m_d->ui_disp.checkBox_maxR->isChecked() ) {
903 messageVerbose("maxR unchecked --> setting maxR=0.0 and returning");
904 emit maxRChanged(0.0); // setting marR=0.0 disables the maxR option in handleJet
905 return;
906 }
907
908 messageDebug("setting maxR: "+QString::number(maxR()));
909 m_d->last_maxR = maxR();
910 emit maxRChanged(m_d->last_maxR);
911}
912
913//____________________________________________________________________
915{
916 messageVerbose("possibleChange_bTaggingEnabled() - "+str(bb));
917
918 m_d->ui_disp.bTaggingAlgLabel->setEnabled(bb);
919 m_d->ui_disp.bTagginWeightCutLabel->setEnabled(bb);
920 m_d->ui_disp.bTaggingComboBox->setEnabled(bb);
921 m_d->ui_disp.bTaggingSpinBox->setEnabled(bb);
922 m_d->ui_disp.groupBox_btagging_render->setEnabled(bb);
923 m_d->ui_disp.matButton_btaggedJets->setEnabled(bb);
924 emit bTaggingEnabledChanged(bb);
925}
926
927//____________________________________________________________________
929{
930 messageVerbose("possibleChange_bTaggingTagger() - " + bTaggingTagger() );
932}
933//____________________________________________________________________
935{
936 messageVerbose("possibleChange_bTaggingCut() - " + QString::number(bTaggingCut()) );
937
938 if (m_d->last_bTaggingCut == bTaggingCut() ) return;
939
940 messageVerbose("bTaggingSpinBox changed");
941 m_d->last_bTaggingCut = bTaggingCut();
942
944}
945
946
947// called when user clicks on "Material" checkbox
948//____________________________________________________________________
950{
951 messageVerbose("possibleChange_bTaggingRenderingMaterial()");
952 messageVerbose("radioButton_material changed - " + QString::number(ok) );
953
955}
956
957// not needed...
960//void JetCollectionSettingsButton::possibleChange_bTaggingMaterial()
961//{
962// messageVerbose("possibleChange_bTaggingMaterial()");
963//
964// if (m_d->last_bTaggingMaterial == bTaggingMaterial() ) {
965// messageVerbose("material not changed. Returning...");
966// return;
967// }
968//
969// messageVerbose("matButton_btaggedJets changed");
970// m_d->last_bTaggingMaterial = bTaggingMaterial();
971//
972// emit bTaggingMaterialChanged();
973//}
974
975
976
977
978// called when user clicks on "Skin" checkbox
979//____________________________________________________________________
981{
982 messageVerbose("possibleChange_bTaggingRenderingSkin()");
983 messageVerbose("radioButton_skins changed - " + QString::number(ok) );
984
986}
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
#define min(a, b)
Definition cfImp.cxx:40
#define max(a, b)
Definition cfImp.cxx:41
SoMaterial * createMaterial(int r, int g, int b) const
SoMaterial * getMat(VP1MaterialButton *) const
Ui::IParticleCollectionSettingsForm editwindow_ui
void cutAllowedPtChanged(const VP1Interval &)
void scaleChanged(const double &scale)
QByteArray saveState() const
fill out with the state of the object (used for drag and drop etc)
void bTaggingTaggerChanged(const QString &)
void cutAllowedEtaChanged(const VP1Interval &)
void bTaggingEnabledChanged(const bool &)
void randomJetColoursChanged(const bool &ra)
void maxRChanged(const double &maxR)
double maxR()
Returns -1 if disabled in GUI, or value in m if enabled.
void dragEnterEvent(QDragEnterEvent *event)
void bTaggingRenderingMaterialChanged(const bool &)
void cutAllowedPhiChanged(const QList< VP1Interval > &)
void bTaggingRenderingSkinChanged(bool)
QList< VP1Interval > cutAllowedPhi() const
VP1MaterialButton * getMaterialButton() const
JetCollectionSettingsButton(QWidget *parent=0, int dim=25, const QString &name="")
void bTaggingCutChanged(const double &)
virtual void copyValuesFromMaterial(SoMaterial *)
VP1CollectionSettingsButtonBase(QWidget *parent=0, int dim=25)
SoMaterial * getMaterial(VP1MaterialButton *) const
static void setColButtonProperties(QPushButton *, const QColor &col, int dim)
void restore(QCheckBox *sb)
void warnUnrestored(QObject *)
void widgetHandled(QWidget *)
qint32 version() const
void messageVerbose(const QString &) const
IVP1System * systemBase() const
void messageDebug(const QString &) const
static SoMaterial * createMaterial(const QColor &, const double &brightness=0.0, const double &transp=0.0)
static void messageVerbose(const QString &)
Definition VP1Msg.cxx:84
int r
Definition globals.cxx:22