ATLAS Offline Software
Loading...
Searching...
No Matches
PhiSectionWidget Class Reference

#include <PhiSectionWidget.h>

Inheritance diagram for PhiSectionWidget:
Collaboration diagram for PhiSectionWidget:

Classes

class  Imp

Signals

void enabledPhiRangesChanged (const QList< VP1Interval > &)

Public Member Functions

 PhiSectionWidget (QWidget *parent, IVP1System *sys=0)
virtual ~PhiSectionWidget ()
int numberOfSectors () const
void setNumberOfSectors (int, bool forceAllEnabled=false)
bool allSectorsOn () const
bool allSectorsOff () const
QList< VP1IntervalenabledPhiRanges () const
QString enabledRangesToString () const
QList< VP1IntervalenabledPhiRanges (double phi_min, double phi_max) const
QByteArray state () const
void setState (QByteArray)
void launchContextMenu (QPoint)
void setSectorStatus (int, bool)
bool virtualSectorEnabled (int iSector, int nSectors) const
QVector< bool > virtualSectorsEnabled (int nSectors) const
void setAllowedNumberOfSectors (QList< int > allowedNSectors, bool allowCustom=false)
void setSystemBasePointer (IVP1System *sys)
void message (const QString &) const
void message (const QStringList &, const QString &addtoend="") const
void message (const QString &addtostart, const QStringList &, const QString &addtoend="") const
void messageDebug (const QString &) const
void messageDebug (const QStringList &, const QString &addtoend="") const
void messageDebug (const QString &addtostart, const QStringList &, const QString &addtoend="") const
void messageVerbose (const QString &) const
void messageVerbose (const QStringList &, const QString &addtoend="") const
void messageVerbose (const QString &addtostart, const QStringList &, const QString &addtoend="") const
IVP1SystemsystemBase () const
const QString & helperClassName () const

Static Public Member Functions

static int phiToVirtualSectorIndex (double phi, int nSectors)
static bool verbose ()
static void warnUndeletedInstances ()
static QString str (const QString &s)
static QString str (const char *c)
static QString str (const bool b)
static QString str (const QColor &)
static QString str (const SbColor &)
static QString str (const VP1Interval &)
static QString str (const SbVec2d &)
static QString str (const SbVec2f &)
static QString str (const SbVec2s &)
static QString str (const SbVec3d &)
static QString str (const SbVec3f &)
static QString str (const SbVec3s &)
static QString str (const SbVec4d &)
static QString str (const SbVec4f &)
static QString str (short int n)
static QString str (unsigned short int n)
static QString str (long n)
static QString str (ulong n)
static QString str (int n)
static QString str (uint n)
static QString str (qlonglong n)
static QString str (qulonglong n)
static QString str (const double &d)
static QString str (const float &f)
static QString str (const void *)
template<class T>
static QString str (const T *t)
template<class T>
static QString str (const QFlags< T > &f)
template<class T>
static QString str (const HepGeom::BasicVector3D< T > &t)
static QString str (const Amg::Vector3D &t)
template<class T>
static QString str (const QList< T > &t)

Protected Member Functions

void mousePressEvent (QMouseEvent *)
void resizeEvent (QResizeEvent *)
void mouseMoveEvent (QMouseEvent *event)
void dropEvent (QDropEvent *event)
void dragEnterEvent (QDragEnterEvent *event)
void dragLeaveEvent (QDragLeaveEvent *event)
void dragMoveEvent (QDragMoveEvent *event)
void setHelperClassName (const QString &n)

Private Attributes

Impm_d
QString m_helpername
IVP1Systemm_system

Static Private Attributes

static const bool s_vp1verbose = VP1QtUtils::environmentVariableIsOn("VP1_VERBOSE_OUTPUT")

Detailed Description

Definition at line 26 of file PhiSectionWidget.h.

Constructor & Destructor Documentation

◆ PhiSectionWidget()

PhiSectionWidget::PhiSectionWidget ( QWidget * parent,
IVP1System * sys = 0 )

Definition at line 95 of file PhiSectionWidget.cxx.

96 : QGraphicsView(parent),
97 VP1HelperClassBase(sys,"PhiSectionWidget"),
98 m_d(new Imp)
99{
100 if(VP1Msg::verbose()){
101 messageVerbose("PhiSectionWidget constr");
102 }
103
104 m_d->theclass = this;
105 m_d->popup_menu = 0;
106 m_d->popup_enableAllAction = 0;
107 m_d->popup_disableAllAction = 0;
108 m_d->popup_invertAction = 0;
109 m_d->popup_copyAction = 0;
110 m_d->popup_pasteAction = 0;
111 m_d->popup_setNPhiSubMenu = 0;
112
113 setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
114 setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
115 setRenderHint(QPainter::Antialiasing,true);
116
117 m_d->pen_on.setWidth(0);
118 m_d->pen_on.setBrush(Qt::red);
119 m_d->pen_off.setWidth(0);
120 m_d->pen_off.setBrush(Qt::gray);
121 m_d->brush_on.setColor(Qt::red);
122 m_d->brush_on.setStyle(Qt::SolidPattern);
123 m_d->brush_off.setColor(Qt::gray);
124 m_d->brush_off.setStyle(Qt::SolidPattern);
125
126 m_d->cacheValid = false;
127
128 setFocusPolicy(Qt::NoFocus);
129 setAcceptDrops(true);
130
131 //The following is the way to init N sectors:
132 m_d->allowCustomNSectors = true;
133 QList<int> defaultAllowedNSectors;
134 defaultAllowedNSectors << 4 << 5 << 6 << 8 << 9 << 10
135 << 12 << 16 << 24 << 32 << 36 << 48 << 64;
136 m_d->allowedNSectors << 12; // default number of sectors, at start
137 setNumberOfSectors(12,true);
138 setAllowedNumberOfSectors(std::move(defaultAllowedNSectors),true);
139}
void setAllowedNumberOfSectors(QList< int > allowedNSectors, bool allowCustom=false)
void setNumberOfSectors(int, bool forceAllEnabled=false)
VP1HelperClassBase(IVP1System *sys=0, QString helpername="")
void messageVerbose(const QString &) const
static bool verbose()
Definition VP1Msg.h:31

◆ ~PhiSectionWidget()

PhiSectionWidget::~PhiSectionWidget ( )
virtual

Definition at line 142 of file PhiSectionWidget.cxx.

143{
144 QGraphicsScene * oldscene = scene();
145 if (oldscene) {
146 setScene(0);
147 delete oldscene;
148 }
149 delete m_d;
150}

Member Function Documentation

◆ allSectorsOff()

bool PhiSectionWidget::allSectorsOff ( ) const

Definition at line 492 of file PhiSectionWidget.cxx.

493{
494 if (!m_d->cacheValid)
495 m_d->checkForChanges();
496 return m_d->cachedAllOff;
497}

◆ allSectorsOn()

bool PhiSectionWidget::allSectorsOn ( ) const

Definition at line 483 of file PhiSectionWidget.cxx.

484{
485 if (!m_d->cacheValid)
486 m_d->checkForChanges();
487 return m_d->cachedAllOn;
488}

◆ dragEnterEvent()

void PhiSectionWidget::dragEnterEvent ( QDragEnterEvent * event)
protected

Definition at line 461 of file PhiSectionWidget.cxx.

462{
463 if (event->source()!=this && event->mimeData()->hasFormat("vp1/enabledphisectors"))
464 event->acceptProposedAction();
465}

◆ dragLeaveEvent()

void PhiSectionWidget::dragLeaveEvent ( QDragLeaveEvent * event)
protected

Definition at line 825 of file PhiSectionWidget.cxx.

826{
827 //Reimplement to avoid interference by the QGraphicsView implementation.
828}

◆ dragMoveEvent()

void PhiSectionWidget::dragMoveEvent ( QDragMoveEvent * event)
protected

Definition at line 818 of file PhiSectionWidget.cxx.

819{
820 //Reimplement to avoid interference by the QGraphicsView implementation.
821 event->acceptProposedAction();
822}

◆ dropEvent()

void PhiSectionWidget::dropEvent ( QDropEvent * event)
protected

Definition at line 468 of file PhiSectionWidget.cxx.

469{
470 QByteArray data = event->mimeData()->data("vp1/enabledphisectors");
471 event->acceptProposedAction();
472 setState(std::move(data));
473}
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
void setState(QByteArray)

◆ enabledPhiRanges() [1/2]

QList< VP1Interval > PhiSectionWidget::enabledPhiRanges ( ) const

Definition at line 560 of file PhiSectionWidget.cxx.

561{
562 if(VP1Msg::debug()){
563 messageDebug("enabledPhiRanges()");
564 }
565
566 if (!m_d->cacheValid) {
567 if(VP1Msg::debug()){
568 messageDebug("Cache not valid. Checking for changes...");
569 }
570 m_d->checkForChanges();
571 }
572 return m_d->cachedRanges;
573}
void messageDebug(const QString &) const
static bool debug()
Definition VP1Msg.h:32

◆ enabledPhiRanges() [2/2]

QList< VP1Interval > PhiSectionWidget::enabledPhiRanges ( double phi_min,
double phi_max ) const

Definition at line 576 of file PhiSectionWidget.cxx.

577{
578 if(VP1Msg::debug()){
579 messageDebug("enabledPhiRanges(double phi_min,double phi_max)");
580 }
581
582 if (phi_min>=phi_max)
583 return QList<VP1Interval>();
584 if (phi_max-phi_min>=(2*M_PI))
585 return enabledPhiRanges();
586 while (phi_min<0) {
587 phi_min += (2*M_PI);
588 phi_max += (2*M_PI);
589 }
590
591 //For ranges such as -310deg->10deg, phi_max might now be larger
592 //than 2pi. We handle this as a special case, merging the result of
593 //two calls to this method:
594 if (phi_max>(2*M_PI)) {
595 QList<VP1Interval> l1 = enabledPhiRanges(phi_min,(2*M_PI));
596 QList<VP1Interval> l2 = enabledPhiRanges(0,phi_max-(2*M_PI));
597 // if (!l1.empty()&&!l2.empty()&&l1.front()
598 l2 << l1;
599 Imp::wrap(l2);
600 return l2;
601 }
602
603 QList<VP1Interval> l = enabledPhiRanges();
604 if (l.empty())
605 return l;
606
607 //In case one of the ranges wraps around at phi=0, we first unwrap
608 //the list:
609 if (l.front().lower()<0.0) {
610 l.append(VP1Interval(l.front().lower()+(2*M_PI),(2*M_PI)));
611 l.front().setLower(0.0);
612 }
613
614
615 //Now, phi_min<phi_max and both are in [0,2pi]. Now, loop over all
616 //ranges and constrain them to [phi_min,phi_max], removing those
617 //that fall outside:
618 double a,b;
619 for ( int i = 0; i < l.count(); ) {
620 a = l[i].lower();
621 b = l[i].upper();
622 if (b <= phi_min||a >= phi_max) {
623 l.removeAt(i);
624 } else {
625 if (a<phi_min)
626 l[i].setLower(phi_min);
627 if (b>phi_max)
628 l[i].setUpper(phi_max);
629 ++i;
630 }
631 }
632
633 Imp::wrap(l);
634
635 return l;
636}
#define M_PI
static Double_t a
static void wrap(QList< VP1Interval > &)
QList< VP1Interval > enabledPhiRanges() const
l
Printing final latex table to .tex output file.

◆ enabledPhiRangesChanged

void PhiSectionWidget::enabledPhiRangesChanged ( const QList< VP1Interval > & )
signal

◆ enabledRangesToString()

QString PhiSectionWidget::enabledRangesToString ( ) const

Definition at line 639 of file PhiSectionWidget.cxx.

640{
641 if (!m_d->cacheValid)
642 m_d->checkForChanges();
643 QString s;
644 for(int i=0;i<m_d->cachedRanges.count();++i)
645 s+= m_d->cachedRanges.at(i).toString()+(i==m_d->cachedRanges.count()-1?"":", ");
646 return s;
647}

◆ helperClassName()

const QString & VP1HelperClassBase::helperClassName ( ) const
inlineinherited

Definition at line 51 of file VP1HelperClassBase.h.

51{ return m_helpername; }

◆ launchContextMenu()

void PhiSectionWidget::launchContextMenu ( QPoint p)

Definition at line 324 of file PhiSectionWidget.cxx.

325{
326 //Prepare:
327 m_d->ensureMenuInit();
328 m_d->popup_enableAllAction->setEnabled(!allSectorsOn());
329 m_d->popup_disableAllAction->setEnabled(!allSectorsOff());
330
331 QClipboard * clipboard = QApplication::clipboard();
332 m_d->popup_pasteAction->setEnabled(clipboard
333 &&clipboard->mimeData()->hasFormat("vp1/enabledphisectors"));
334
335 for(QAction * setNPhiAct : m_d->popuplist_setNPhi) {
336 bool ok;
337 int nSectors = setNPhiAct->data().toInt(&ok);
338 setNPhiAct->setEnabled(ok&&nSectors!=m_d->sectorstatus.count());
339 }
340
341 //Launch
342 QAction * selAct = m_d->popup_menu->exec(p);
343
344 //React
345 if (selAct==m_d->popup_copyAction) {
346 QMimeData *mimeData = new QMimeData;
347 mimeData->setData("vp1/enabledphisectors", state());
348 mimeData->setText(enabledRangesToString());
349 clipboard->setMimeData(mimeData);
350 return;
351 }
352 if (selAct==m_d->popup_pasteAction) {
353 QByteArray data = clipboard->mimeData()->data("vp1/enabledphisectors");
354 setState(std::move(data));
355 return;
356 }
357 if (selAct==m_d->popup_enableAllAction) {
358 for (int i = 0; i < m_d->sectorstatus.count(); ++i)
359 m_d->sectorstatus[i] = true;
360 m_d->cacheValid = false;
361 m_d->checkForChanges();
362 return;
363 }
364 if (selAct==m_d->popup_disableAllAction) {
365 for (int i = 0; i < m_d->sectorstatus.count(); ++i)
366 m_d->sectorstatus[i] = false;
367 m_d->cacheValid = false;
368 m_d->checkForChanges();
369 return;
370 }
371 if (selAct==m_d->popup_invertAction) {
372 for (int i = 0; i < m_d->sectorstatus.count(); ++i)
373 m_d->sectorstatus[i] = !m_d->sectorstatus[i];
374 m_d->cacheValid = false;
375 m_d->checkForChanges();
376 return;
377 }
378 if (selAct==m_d->popup_setCustomNPhi) {
379 bool ok;
380 // int nCustomSectors = QInputDialog::getInteger(this, "Set number of phi sectors",
381 int nCustomSectors = QInputDialog::getInt(this, "Set number of phi sectors",
382 "Set number of phi sectors", m_d->sectorstatus.count(),4,99,1,&ok);
383 if (ok && nCustomSectors >= 4 && nCustomSectors <= 99 )
384 setNumberOfSectors(nCustomSectors);
385 return;
386 }
387 if (m_d->popuplist_setNPhi.contains(selAct)) {
388 bool ok;
389 int nSectors = selAct->data().toInt(&ok);
390 if (ok)
391 setNumberOfSectors(nSectors);
392 return;
393 }
394}
bool allSectorsOn() const
bool allSectorsOff() const
QString enabledRangesToString() const
QByteArray state() const

◆ message() [1/3]

void VP1HelperClassBase::message ( const QString & str) const
inherited

Definition at line 49 of file VP1HelperClassBase.cxx.

50{
51 if (m_helpername.isEmpty()) {
52 if (m_system)
53 m_system->message(str);
54 else
55 std::cout<<VP1Msg::prefix_msg()<<" [nameless helper class]: "<<str.toStdString()<<std::endl;
56 } else {
57 if (m_system)
58 m_system->message("["+m_helpername+"] " + str);
59 else
60 std::cout<<VP1Msg::prefix_msg()<<" ["<<m_helpername.toStdString()<<"]: "<<str.toStdString()<<std::endl;
61 }
62}
static const char * prefix_msg()
Definition VP1Msg.h:56
static QString str(const QString &s)
Definition VP1String.h:49

◆ message() [2/3]

void VP1HelperClassBase::message ( const QString & addtostart,
const QStringList & l,
const QString & addtoend = "" ) const
inherited

Definition at line 131 of file VP1HelperClassBase.cxx.

132{
133 if (addtostart.isEmpty()) {
134 message(l,addtoend);
135 return;
136 }
137 if (addtoend.isEmpty()) {
138 for (const QString& s : l)
139 message(addtostart+s);
140 } else {
141 for (const QString& s : l)
142 message(addtostart+s+addtoend);
143 }
144}
void message(const QString &) const

◆ message() [3/3]

void VP1HelperClassBase::message ( const QStringList & l,
const QString & addtoend = "" ) const
inherited

Definition at line 91 of file VP1HelperClassBase.cxx.

92{
93 if (addtoend.isEmpty()) {
94 for (const QString& s : l)
95 message(s);
96 } else {
97 for (const QString& s : l)
98 message(s+addtoend);
99 }
100}

◆ messageDebug() [1/3]

void VP1HelperClassBase::messageDebug ( const QString & str) const
inherited

Definition at line 65 of file VP1HelperClassBase.cxx.

66{
67 if (!VP1Msg::debug())
68 return;
69 std::string sysstring(m_system ? " in "+m_system->name().toStdString() : std::string(""));
70 if (m_helpername.isEmpty()) {
71 std::cout<<VP1Msg::prefix_debug()<<" [helper"<<sysstring<<"]: "<<str.toStdString()<<std::endl;
72 } else {
73 std::cout<<VP1Msg::prefix_debug()<<" ["<<m_helpername.toStdString()<<sysstring<<"]: "<<str.toStdString()<<std::endl;
74 }
75}
static const char * prefix_debug()
Definition VP1Msg.h:57

◆ messageDebug() [2/3]

void VP1HelperClassBase::messageDebug ( const QString & addtostart,
const QStringList & l,
const QString & addtoend = "" ) const
inherited

Definition at line 147 of file VP1HelperClassBase.cxx.

148{
149 if (!VP1Msg::debug())
150 return;
151 if (addtostart.isEmpty()) {
152 messageDebug(l,addtoend);
153 return;
154 }
155 if (addtoend.isEmpty()) {
156 for (const QString& s : l)
157 messageDebug(addtostart+s);
158 } else {
159 for (const QString& s : l)
160 messageDebug(addtostart+s+addtoend);
161 }
162}

◆ messageDebug() [3/3]

void VP1HelperClassBase::messageDebug ( const QStringList & l,
const QString & addtoend = "" ) const
inherited

Definition at line 103 of file VP1HelperClassBase.cxx.

104{
105 if (!VP1Msg::debug())
106 return;
107 if (addtoend.isEmpty()) {
108 for (const QString& s : l)
109 messageDebug(s);
110 } else {
111 for (const QString& s : l)
112 messageDebug(s+addtoend);
113 }
114}

◆ messageVerbose() [1/3]

void VP1HelperClassBase::messageVerbose ( const QString & str) const
inherited

Definition at line 78 of file VP1HelperClassBase.cxx.

79{
80 if (!VP1Msg::verbose())
81 return;
82 std::string sysstring(m_system ? " in "+m_system->name().toStdString() : std::string(""));
83 if (m_helpername.isEmpty()) {
84 std::cout<<VP1Msg::prefix_verbose()<<" [helper"<<sysstring<<"]: "<<str.toStdString()<<std::endl;
85 } else {
86 std::cout<<VP1Msg::prefix_verbose()<<" ["<<m_helpername.toStdString()<<sysstring<<"]: "<<str.toStdString()<<std::endl;
87 }
88}
static const char * prefix_verbose()
Definition VP1Msg.h:59

◆ messageVerbose() [2/3]

void VP1HelperClassBase::messageVerbose ( const QString & addtostart,
const QStringList & l,
const QString & addtoend = "" ) const
inherited

Definition at line 165 of file VP1HelperClassBase.cxx.

166{
167 if (!VP1Msg::verbose())
168 return;
169 if (addtostart.isEmpty()) {
170 messageVerbose(l,addtoend);
171 return;
172 }
173 if (addtoend.isEmpty()) {
174 for (const QString& s : l)
175 messageVerbose(addtostart+s);
176 } else {
177 for (const QString& s : l)
178 messageVerbose(addtostart+s+addtoend);
179 }
180}

◆ messageVerbose() [3/3]

void VP1HelperClassBase::messageVerbose ( const QStringList & l,
const QString & addtoend = "" ) const
inherited

Definition at line 117 of file VP1HelperClassBase.cxx.

118{
119 if (!VP1Msg::verbose())
120 return;
121 if (addtoend.isEmpty()) {
122 for (const QString& s : l)
124 } else {
125 for (const QString& s : l)
126 messageVerbose(s+addtoend);
127 }
128}

◆ mouseMoveEvent()

void PhiSectionWidget::mouseMoveEvent ( QMouseEvent * event)
protected

Definition at line 431 of file PhiSectionWidget.cxx.

432{
433 if (!(event->buttons() & Qt::LeftButton))
434 return;
435 if ((event->pos() - m_d->dragStartPosition).manhattanLength()
436 < QApplication::startDragDistance())
437 return;
438
439 QDrag *drag = new QDrag(this);
440 QMimeData *mimeData = new QMimeData;
441
443 // For dragging state onto other phi section widgets: //
445
446 mimeData->setData("vp1/enabledphisectors", state());
447
449 // For dragging a readable version of the enabled phi-ranges //
450 // into e.g. an editor or email program: //
452
453 mimeData->setText(enabledRangesToString());
454
455 //Execute drag:
456 drag->setMimeData(mimeData);//drag assumes ownership of mimeData
457 drag->exec(Qt::CopyAction | Qt::MoveAction);
458}

◆ mousePressEvent()

void PhiSectionWidget::mousePressEvent ( QMouseEvent * event)
protected

Definition at line 397 of file PhiSectionWidget.cxx.

398{
399 if (event->buttons()==Qt::RightButton) {
400 launchContextMenu(QCursor::pos());
401 return;
402 }
403
404 if (event->button() == Qt::LeftButton)
405 m_d->dragStartPosition = event->pos();
406
407 if (event->buttons()!=Qt::LeftButton) {
408 QGraphicsView::mousePressEvent(event);
409 return;
410 }
411 QGraphicsItem *item_ = itemAt(event->pos());
412 QGraphicsEllipseItem * item = static_cast<QGraphicsEllipseItem*>(item_);
413 if (!item||m_d->item2sector.find(item)==m_d->item2sector.end()) {
414 QGraphicsView::mousePressEvent(event);
415 return;
416 }
417 int isector = m_d->item2sector[item];
418 if (isector<0||isector>=static_cast<int>(m_d->sectorstatus.count())) {
419 QGraphicsView::mousePressEvent(event);
420 return;
421 }
422 m_d->sectorstatus[isector]=!(m_d->sectorstatus.at(isector));
423 if(VP1Msg::verbose()){
424 messageVerbose("Turning on sector"+QString::number(isector));
425 }
426 m_d->cacheValid=false;
427 m_d->checkForChanges();
428}
void launchContextMenu(QPoint)

◆ numberOfSectors()

int PhiSectionWidget::numberOfSectors ( ) const

Definition at line 252 of file PhiSectionWidget.cxx.

253{
254 return m_d->sectorstatus.count();
255}

◆ phiToVirtualSectorIndex()

int PhiSectionWidget::phiToVirtualSectorIndex ( double phi,
int nSectors )
static

Definition at line 716 of file PhiSectionWidget.cxx.

717{
718 //Constrain phi to [0,2*pi[
719 while (phi<0) phi+=(2*M_PI);
720 while (phi>=(2*M_PI)) phi-=(2*M_PI);
721 if (phi<0.0) phi=0.0;
722
723 int iphi = static_cast<int>(nSectors*phi/((2*M_PI)));
724 return iphi;
725}
Scalar phi() const
phi method

◆ resizeEvent()

void PhiSectionWidget::resizeEvent ( QResizeEvent * )
protected

Definition at line 476 of file PhiSectionWidget.cxx.

477{
478 if (scene())
479 fitInView(scene()->sceneRect());
480}

◆ setAllowedNumberOfSectors()

void PhiSectionWidget::setAllowedNumberOfSectors ( QList< int > allowedNSectors,
bool allowCustom = false )

Definition at line 831 of file PhiSectionWidget.cxx.

832{
833 if(VP1Msg::verbose()){
834 messageVerbose("setAllowedNumberOfSectors()");
835 }
836
837 //Check validity:
838 if (allowedNSectors.isEmpty()) {
839 if(VP1Msg::verbose()){
840 messageVerbose("allowedNSectors empty. Returning.");
841 }
842 return;
843 }
844 for(int s : allowedNSectors) {
845 if (s<4) {
846 if(VP1Msg::verbose()){
847 messageVerbose("allowedNSectors s < 4. Returning.");
848 }
849 return;
850 }
851 }
852
853 if (allowCustom&&!allowedNSectors.contains(m_d->sectorstatus.count())) {
854 allowedNSectors << m_d->sectorstatus.count();
855 }
856
857 m_d->allowCustomNSectors = allowCustom;
858
859 std::sort(allowedNSectors.begin(), allowedNSectors.end());
860 if (m_d->allowedNSectors==allowedNSectors) {
861 return;
862 }
863 m_d->allowedNSectors=std::move(allowedNSectors);
864 if (m_d->popup_menu) {
865 m_d->addMenuEntriesForSetNPhi();
866 }
867
868 if (!m_d->allowedNSectors.contains(m_d->sectorstatus.count())) {
869 setNumberOfSectors(m_d->sectorstatus.count());
870 }
871
872 int checkA = m_d->sectorstatus.isEmpty();
873 int checkB = m_d->sectorstatus.count();
874 if(VP1Msg::debug()){
875 messageDebug("check - sectorstatus.isEmpty? " + str(checkA + checkB) );
876 }
877
878}
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.

◆ setHelperClassName()

void VP1HelperClassBase::setHelperClassName ( const QString & n)
inlineprotectedinherited

Definition at line 59 of file VP1HelperClassBase.h.

◆ setNumberOfSectors()

void PhiSectionWidget::setNumberOfSectors ( int nsectors,
bool forceAllEnabled = false )

Definition at line 153 of file PhiSectionWidget.cxx.

154{
155 if(VP1Msg::debug()){
156 messageDebug("setNumberOfSectors()");
157 }
158
159
160 if (nsectors<4||nsectors>99) {
161 if(VP1Msg::debug()){
162 messageDebug("nsectors<4||nsectors>99. Returning.");
163 }
164 return;
165 }
166
167 if (!m_d->allowedNSectors.contains(nsectors) && !m_d->allowCustomNSectors) {
168 //Oups! Let us try first to pick something among the allowed
169 //values which would allow us to preserve the ranges exactly;
170 int n(-1);
171 for(int i = 2; i < 100; ++i) {
172 if (m_d->allowedNSectors.contains(i*nsectors)) {
173 n = i*nsectors;
174 break;
175 }
176 }
177 nsectors = n>0 ? n : m_d->allowedNSectors.back();
178 } else if (!m_d->sectorstatus.isEmpty() && nsectors==static_cast<int>(m_d->sectorstatus.count())) {
179 if(VP1Msg::debug()){
180 messageDebug("!sectorstatus.isEmpty() && nsectors==sectorstatus.count(). Returning...");
181 }
182 return;
183 }
184
185 if ( m_d->sectorstatus.isEmpty() ) {
186 if(VP1Msg::debug()){
187 messageDebug("m_d->sectorstatus is Empty.");
188 }
189 }
190
191 // check if sectors have already been defined
192 QList<VP1Interval> oldEnabledRanges;
193 if ( !m_d->sectorstatus.isEmpty() ) {
194 oldEnabledRanges = enabledPhiRanges();
195 }
196
197 //Update new graphics objects with the new settings
198
199 // first clear everything...
200 m_d->item2sector.clear();
201 m_d->sectorstatus.clear();
202 QGraphicsScene * oldscene = scene();
203 setScene(new QGraphicsScene);
204 delete oldscene;
205
206 // ...then build new variables with the new settings of 'nsectors'
207 const double R = 10.0;
208 const double r = (2*M_PI)*R / nsectors / 1.2;
209
210 for (int isector = 0; isector < nsectors; ++isector) {
211 double phi = (isector+0.5)*(2*M_PI)/nsectors;
212 double x(R*cos(phi)), y(-R*sin(phi));
213 QGraphicsEllipseItem * ellipse = scene()->addEllipse(x,y,r,r);
214 m_d->item2sector[ellipse]=isector;
215 }
216
217 m_d->sectorstatus.fill(forceAllEnabled,m_d->item2sector.size());
218
219 if (!forceAllEnabled)
220 m_d->approximateSectorStatusFromRanges(oldEnabledRanges,m_d->sectorstatus);
221 m_d->updateColors();
222 fitInView(scene()->sceneRect());
223 m_d->checkForChanges();
224
225
226 // resize the widget based on the number of sectors
227 // we need to make it larger as the number of sectors increases
228 // otherwise the 'red dots' are difficult to see and pick with the mouse
229 // Note: numbers of sectors are not continuos: after 12, 16 comes, then 24, ...
230 if (nsectors <= 12) {
231 setFixedSize(60,60);
232 } else if(nsectors >= 16 && nsectors < 24) {
233 setFixedSize(120,120);
234 } else if(nsectors >= 24 && nsectors < 32) {
235 setFixedSize(200,200);
236 } else if (nsectors >= 32 && nsectors <= 36) {
237 setFixedSize(300,300);
238 } else if (nsectors > 36) {
239 setFixedSize(400,400);
240 }
241
242
243 if ( m_d->sectorstatus.isEmpty() ) {
244 if(VP1Msg::debug()){
245 messageDebug("WARNING. m_d->sectorstatus is still Empty...");
246 }
247 }
248}
#define y
#define x
int r
Definition globals.cxx:22
double R(const INavigable4Momentum *p1, const double v_eta, const double v_phi)

◆ setSectorStatus()

void PhiSectionWidget::setSectorStatus ( int isector,
bool status )

Definition at line 273 of file PhiSectionWidget.cxx.

274{
275 if (isector<0||isector>=static_cast<int>(m_d->sectorstatus.count()))
276 return;
277 if (m_d->sectorstatus.at(isector)==status)
278 return;
279 m_d->sectorstatus[isector]=status;
280 m_d->cacheValid=false;
281 m_d->checkForChanges();
282}
status
Definition merge.py:16

◆ setState()

void PhiSectionWidget::setState ( QByteArray ba)

Definition at line 747 of file PhiSectionWidget.cxx.

748{
749 if(VP1Msg::verbose()){
750 this->messageVerbose("setState()");
751 }
752 // ===> Setup stream for getting the contents of the byteArray:
753 QBuffer buffer(&ba);
754 buffer.open(QIODevice::ReadOnly);
755 QDataStream state(&buffer);
756
757 qint32 version;
758 state >> version;
759 if (version!=0)
760 return;
761
762 QVector<bool> restored_sectorstatus;
763 state >> restored_sectorstatus;
764 buffer.close();
765
766 bool save = blockSignals(true);
767 if (restored_sectorstatus.count()!=m_d->sectorstatus.count())
768 setNumberOfSectors(restored_sectorstatus.count(),true);
769 if (restored_sectorstatus.count()==m_d->sectorstatus.count()) {
770 m_d->sectorstatus = std::move(restored_sectorstatus);
771 } else {
772 bool allon, alloff;
773 QList<VP1Interval> r = m_d->enabledPhiRangesNoCache(restored_sectorstatus,allon, alloff);
774 if (allon) {
775 m_d->sectorstatus.fill(true);
776 }
777 else if (alloff) {
778 m_d->sectorstatus.fill(true);
779 }
780 else {
781 m_d->approximateSectorStatusFromRanges(r,m_d->sectorstatus);
782 }
783 }
784 if (!save)
785 blockSignals(false);
786 m_d->cacheValid=false;
787 m_d->checkForChanges();
788}

◆ setSystemBasePointer()

void VP1HelperClassBase::setSystemBasePointer ( IVP1System * sys)
inherited

Definition at line 197 of file VP1HelperClassBase.cxx.

198{
199 m_system = sys;
200 if (VP1Msg::verbose()){
201 vp1helperclassbase_instanceMap[this] = (m_system?m_system->name():QString(""));
202 }
203}
static std::map< VP1HelperClassBase *, QString > vp1helperclassbase_instanceMap

◆ state()

QByteArray PhiSectionWidget::state ( ) const

Definition at line 728 of file PhiSectionWidget.cxx.

729{
730 // ===> Setup stream writing to a byteArray:
731 QByteArray byteArray;
732 QBuffer buffer(&byteArray);
733 buffer.open(QIODevice::WriteOnly);
734 QDataStream out(&buffer);
735 out << qint32(0);//version
736 out << m_d->sectorstatus;//This is all the data we output,
737 //allowing for applicability of the data
738 //between different widgets, even if they are
739 //being used differently.
740 buffer.close();
741 return byteArray;
742
743
744}

◆ str() [1/30]

QString VP1String::str ( const Amg::Vector3D & t)
inlinestaticinherited

Definition at line 98 of file VP1String.h.

98{ return "("+str(t.x())+", "+str(t.y())+", "+str(t.z())+")"; }

◆ str() [2/30]

QString VP1String::str ( const bool b)
inlinestaticinherited

Definition at line 53 of file VP1String.h.

53{ return b?"True":"False"; }

◆ str() [3/30]

QString VP1String::str ( const char * c)
inlinestaticinherited

Definition at line 50 of file VP1String.h.

50{ return c; }

◆ str() [4/30]

QString VP1String::str ( const double & d)
inlinestaticinherited

Definition at line 81 of file VP1String.h.

81{ return QString::number(d); }

◆ str() [5/30]

QString VP1String::str ( const float & f)
inlinestaticinherited

Definition at line 82 of file VP1String.h.

82{ return QString::number(f); }

◆ str() [6/30]

template<class T>
QString VP1String::str ( const HepGeom::BasicVector3D< T > & t)
inlinestaticinherited

Definition at line 95 of file VP1String.h.

95{ return "("+str(t.x())+", "+str(t.y())+", "+str(t.z())+")"; }

◆ str() [7/30]

QString VP1String::str ( const QColor & c)
staticinherited

Definition at line 30 of file VP1String.cxx.

31{
32 return c.isValid() ? c.name() : "Invalid";
33}

◆ str() [8/30]

template<class T>
QString VP1String::str ( const QFlags< T > & f)
inlinestaticinherited

Definition at line 91 of file VP1String.h.

91{ return "0x"+QString::number(f, 16).toUpper().rightJustified(8,'0'); }

◆ str() [9/30]

template<class T>
QString VP1String::str ( const QList< T > & t)
inlinestaticinherited

Definition at line 102 of file VP1String.h.

102{ return "QList of size"+QString::number(t.size()); }

◆ str() [10/30]

QString VP1String::str ( const QString & s)
inlinestaticinherited

Definition at line 49 of file VP1String.h.

49{ return s; }

◆ str() [11/30]

QString VP1String::str ( const SbColor & c)
staticinherited

Definition at line 36 of file VP1String.cxx.

37{
39}
static QColor sbcol2qcol(const SbColor &)

◆ str() [12/30]

QString VP1String::str ( const SbVec2d & v)
staticinherited

Definition at line 61 of file VP1String.cxx.

61{ double x,y; v.getValue(x,y); return "("+str(x)+", "+str(y)+")"; }

◆ str() [13/30]

QString VP1String::str ( const SbVec2f & v)
staticinherited

Definition at line 62 of file VP1String.cxx.

62{ float x,y; v.getValue(x,y); return "("+str(x)+", "+str(y)+")"; }

◆ str() [14/30]

QString VP1String::str ( const SbVec2s & v)
staticinherited

Definition at line 63 of file VP1String.cxx.

63{ short x,y; v.getValue(x,y); return "("+str(x)+", "+str(y)+")"; }

◆ str() [15/30]

QString VP1String::str ( const SbVec3d & v)
staticinherited

Definition at line 64 of file VP1String.cxx.

64{ double x,y,z; v.getValue(x,y,z); return "("+str(x)+", "+str(y)+", "+str(z)+")"; }
#define z

◆ str() [16/30]

QString VP1String::str ( const SbVec3f & v)
staticinherited

Definition at line 65 of file VP1String.cxx.

65{ float x,y,z; v.getValue(x,y,z); return "("+str(x)+", "+str(y)+", "+str(z)+")"; }

◆ str() [17/30]

QString VP1String::str ( const SbVec3s & v)
staticinherited

Definition at line 66 of file VP1String.cxx.

66{ short x,y,z; v.getValue(x,y,z); return "("+str(x)+", "+str(y)+", "+str(z)+")"; }

◆ str() [18/30]

QString VP1String::str ( const SbVec4d & v)
staticinherited

Definition at line 67 of file VP1String.cxx.

67{ double x,y,z,t; v.getValue(x,y,z,t); return "("+str(x)+", "+str(y)+", "+str(z)+", "+str(t)+")"; }

◆ str() [19/30]

QString VP1String::str ( const SbVec4f & v)
staticinherited

Definition at line 68 of file VP1String.cxx.

68{ float x,y,z,t; v.getValue(x,y,z,t); return "("+str(x)+", "+str(y)+", "+str(z)+", "+str(t)+")"; }

◆ str() [20/30]

template<class T>
QString VP1String::str ( const T * t)
inlinestaticinherited

Definition at line 87 of file VP1String.h.

87{ return str(static_cast<const void* >(t)); }

◆ str() [21/30]

QString VP1String::str ( const void * p)
staticinherited

Definition at line 48 of file VP1String.cxx.

49{
50 if (p) {
51 std::ostringstream s;
52 s << p;
53 // Explicitly naming QString here avoids a cppcheck warning.
54 return QString (s.str().c_str());
55 } else {
56 return "NULL";
57 }
58}

◆ str() [22/30]

QString VP1String::str ( const VP1Interval & i)
staticinherited

Definition at line 42 of file VP1String.cxx.

43{
44 return i.toString();
45}

◆ str() [23/30]

QString VP1String::str ( int n)
inlinestaticinherited

Definition at line 77 of file VP1String.h.

77{ return QString::number(n); }

◆ str() [24/30]

QString VP1String::str ( long n)
inlinestaticinherited

Definition at line 75 of file VP1String.h.

75{ return QString::number(n); }

◆ str() [25/30]

QString VP1String::str ( qlonglong n)
inlinestaticinherited

Definition at line 79 of file VP1String.h.

79{ return QString::number(n); }

◆ str() [26/30]

QString VP1String::str ( qulonglong n)
inlinestaticinherited

Definition at line 80 of file VP1String.h.

80{ return QString::number(n); }

◆ str() [27/30]

QString VP1String::str ( short int n)
inlinestaticinherited

Definition at line 73 of file VP1String.h.

73{ return QString::number(n); }

◆ str() [28/30]

QString VP1String::str ( uint n)
inlinestaticinherited

Definition at line 78 of file VP1String.h.

78{ return QString::number(n); }

◆ str() [29/30]

QString VP1String::str ( ulong n)
inlinestaticinherited

Definition at line 76 of file VP1String.h.

76{ return QString::number(n); }

◆ str() [30/30]

QString VP1String::str ( unsigned short int n)
inlinestaticinherited

Definition at line 74 of file VP1String.h.

74{ return QString::number(n); }

◆ systemBase()

IVP1System * VP1HelperClassBase::systemBase ( ) const
inlineinherited

Definition at line 50 of file VP1HelperClassBase.h.

50{ return m_system; }

◆ verbose()

bool VP1HelperClassBase::verbose ( )
inlinestaticinherited

Definition at line 32 of file VP1HelperClassBase.h.

32{ return s_vp1verbose; } // Returns true if env var VP1_VERBOSE_OUTPUT=1
static const bool s_vp1verbose

◆ virtualSectorEnabled()

bool PhiSectionWidget::virtualSectorEnabled ( int iSector,
int nSectors ) const

Definition at line 677 of file PhiSectionWidget.cxx.

678{
679// this->messageDebug("virtualSectorEnabled()");
680
681 if (iSector<0||iSector>=nSectors||nSectors<1)
682 return false;
683 if (!m_d->cacheValid)
684 m_d->checkForChanges();
685 if (m_d->cachedAllOn)
686 return true;
687 if (m_d->cachedAllOff)
688 return false;
689
690 //Phi-range of virtual sector:
691 const double dphi = (2*M_PI)/nSectors;
692 const double epsilon(dphi*1.0e-9);
693 VP1Interval phirange(dphi*iSector+epsilon,dphi*(iSector+1)-epsilon);
694
695 //Compare with enabled ranges:
696 for(const VP1Interval& enabledrange : m_d->cachedRanges) {
697 if (phirange.hasOverlap(enabledrange,2*M_PI))
698 return true;
699 }
700 return false;
701}

◆ virtualSectorsEnabled()

QVector< bool > PhiSectionWidget::virtualSectorsEnabled ( int nSectors) const

Definition at line 704 of file PhiSectionWidget.cxx.

705{
706 if (nSectors<1)
707 return QVector<bool>();
708 QVector<bool> v(nSectors,false);
709 for (int i = 0; i < nSectors; ++i)
710 if (virtualSectorEnabled(i,nSectors))
711 v[i] = true;
712 return v;
713}
bool virtualSectorEnabled(int iSector, int nSectors) const

◆ warnUndeletedInstances()

void VP1HelperClassBase::warnUndeletedInstances ( )
staticinherited

Definition at line 183 of file VP1HelperClassBase.cxx.

184{
186 return;
187 std::cout << "WARNING: Detected "<<vp1helperclassbase_instanceMap.size()<<" undeleted helper class instances:"<<std::endl;
188
189 std::map<VP1HelperClassBase*,QString>::iterator it,itE(vp1helperclassbase_instanceMap.end());
190 for (it = vp1helperclassbase_instanceMap.begin();it!=itE;++it) {
191 std::cout << " ==> "<<it->first<<": "<<it->first->m_helpername.toStdString()
192 << (it->second.isEmpty()?QString(""):" (in system "+it->second+")").toStdString()<<std::endl;
193 }
194}

Member Data Documentation

◆ m_d

Imp* PhiSectionWidget::m_d
private

Definition at line 83 of file PhiSectionWidget.h.

◆ m_helpername

QString VP1HelperClassBase::m_helpername
privateinherited

Definition at line 67 of file VP1HelperClassBase.h.

◆ m_system

IVP1System* VP1HelperClassBase::m_system
privateinherited

Definition at line 68 of file VP1HelperClassBase.h.

◆ s_vp1verbose

const bool VP1HelperClassBase::s_vp1verbose = VP1QtUtils::environmentVariableIsOn("VP1_VERBOSE_OUTPUT")
staticprivateinherited

Definition at line 69 of file VP1HelperClassBase.h.


The documentation for this class was generated from the following files: