#include #include "VRichPropertiesWidget.h" VRichPropertiesWidget::VRichPropertiesWidget(VRichScene* richScene) { fNofToDrawChBoxes = 5; fNofRingTypeChBoxes = 4; fRichScene = richScene; fColorBtnSignalMapper = new QSignalMapper(this); fCheckBoxSignalMapper = new QSignalMapper(this); fTopLayout = new QVBoxLayout; fTopLayout->addWidget(CreateToDrawGroupBox()); fTopLayout->addWidget(CreateRingTypeGroupBox()); fTopLayout->addWidget(CreateSBGroupBox()); fTopLayout->addStretch(); connect(fCheckBoxSignalMapper, SIGNAL(mapped(QWidget *)), this, SLOT(CheckBoxChanged(QWidget*))); connect(fColorBtnSignalMapper, SIGNAL(mapped(QWidget *)), this, SLOT(ColorBtnClicked(QWidget*))); setLayout(fTopLayout); } QGroupBox* VRichPropertiesWidget::CreateToDrawGroupBox() { QGroupBox* groupBox = new QGroupBox("To Draw"); QGridLayout* gridLayout = new QGridLayout; QString text[] = {"Rings", "Ellipses", "Hits","Projections", "Points"}; fToDrawChBoxAr.resize(fNofToDrawChBoxes); fToDrawBtnAr.resize(fNofToDrawChBoxes); for (int i = 0; i < fNofToDrawChBoxes; i++){ fToDrawChBoxAr[i] = new QCheckBox(text[i]); fToDrawChBoxAr[i]->setCheckState(Qt::Checked); connect(fToDrawChBoxAr[i], SIGNAL(stateChanged(int)), fCheckBoxSignalMapper, SLOT(map())); fCheckBoxSignalMapper->setMapping(fToDrawChBoxAr[i], fToDrawChBoxAr[i]); gridLayout->addWidget(fToDrawChBoxAr[i], i, 0); fToDrawBtnAr[i] = new QPushButton(); fToDrawBtnAr[i]->setStatusTip("Click to change "+ text[i]+ " color"); fToDrawBtnAr[i]->setToolTip("Click to change "+ text[i]+ " color"); fToDrawBtnAr[i]->setMaximumWidth(30); connect(fToDrawBtnAr[i], SIGNAL(clicked()), fColorBtnSignalMapper, SLOT(map())); fColorBtnSignalMapper->setMapping(fToDrawBtnAr[i], fToDrawBtnAr[i]); gridLayout->addWidget(fToDrawBtnAr[i], i, 1); } ///Set Check Box state if (!fRichScene->GetItemsVisible(kRichRing)) fToDrawChBoxAr[0]->setCheckState(Qt::Unchecked); if (!fRichScene->GetItemsVisible(kRichEllipse)) fToDrawChBoxAr[1]->setCheckState(Qt::Unchecked); if (!fRichScene->GetItemsVisible(kRichHit)) fToDrawChBoxAr[2]->setCheckState(Qt::Unchecked); if (!fRichScene->GetItemsVisible(kRichProj)) fToDrawChBoxAr[3]->setCheckState(Qt::Unchecked); if (!fRichScene->GetItemsVisible(kRichPoint)) fToDrawChBoxAr[4]->setCheckState(Qt::Unchecked); ///Set Items colors fToDrawBtnAr[0]->setPalette(QPalette(fRichScene->GetItemsColor(kRichRing))); fToDrawBtnAr[1]->setPalette(QPalette(fRichScene->GetItemsColor(kRichEllipse))); fToDrawBtnAr[2]->setPalette(QPalette(fRichScene->GetItemsColor(kRichHit))); fToDrawBtnAr[3]->setPalette(QPalette(fRichScene->GetItemsColor(kRichProj))); fToDrawBtnAr[4]->setPalette(QPalette(fRichScene->GetItemsColor(kRichPoint))); groupBox->setLayout(gridLayout); return groupBox; } QGroupBox* VRichPropertiesWidget::CreateRingTypeGroupBox() { QGroupBox* groupBox = new QGroupBox("Ring Type"); QGridLayout *gridLayout = new QGridLayout; QString text[] = {"Electrons", "Pions","Fakes", "Clones"}; fRingTypeChBoxAr.resize(fNofRingTypeChBoxes); fRingTypeBtnAr.resize(fNofRingTypeChBoxes); for (int i = 0; i < fNofRingTypeChBoxes; i++){ fRingTypeChBoxAr[i] = new QCheckBox(text[i]); fRingTypeChBoxAr[i]->setCheckState(Qt::Checked); connect(fRingTypeChBoxAr[i], SIGNAL(stateChanged(int)), fCheckBoxSignalMapper, SLOT(map())); fCheckBoxSignalMapper->setMapping(fRingTypeChBoxAr[i], fRingTypeChBoxAr[i]); gridLayout->addWidget(fRingTypeChBoxAr[i],i,0); fRingTypeBtnAr[i] = new QPushButton(); fRingTypeBtnAr[i]->setStatusTip("Click to change " + text[i] + " color"); fRingTypeBtnAr[i]->setToolTip("Click to change " + text[i] + " color"); fRingTypeBtnAr[i]->setMaximumWidth(30); connect(fRingTypeBtnAr[i], SIGNAL(clicked()), fColorBtnSignalMapper, SLOT(map())); fColorBtnSignalMapper->setMapping(fRingTypeBtnAr[i], fRingTypeBtnAr[i]); gridLayout->addWidget(fRingTypeBtnAr[i],i, 1); } ///Set Check Box state if (!fRichScene->GetRingsVisible(kRichElRing)) fRingTypeChBoxAr[0]->setCheckState(Qt::Unchecked);; if (!fRichScene->GetRingsVisible(kRichPiRing)) fRingTypeChBoxAr[1]->setCheckState(Qt::Unchecked);; if (!fRichScene->GetRingsVisible(kRichFakeRing)) fRingTypeChBoxAr[2]->setCheckState(Qt::Unchecked);; if (!fRichScene->GetRingsVisible(kRichCloneRing)) fRingTypeChBoxAr[3]->setCheckState(Qt::Unchecked);; ///Set Rings colors fRingTypeBtnAr[0]->setPalette(QPalette(fRichScene->GetRingsColor(kRichElRing))); fRingTypeBtnAr[1]->setPalette(QPalette(fRichScene->GetRingsColor(kRichPiRing))); fRingTypeBtnAr[2]->setPalette(QPalette(fRichScene->GetRingsColor(kRichFakeRing))); fRingTypeBtnAr[3]->setPalette(QPalette(fRichScene->GetRingsColor(kRichCloneRing))); groupBox->setLayout(gridLayout); return groupBox; } QGroupBox* VRichPropertiesWidget::CreateSBGroupBox() { QGroupBox* groupBox = new QGroupBox("Draw properties"); QGridLayout *gridLayout = new QGridLayout; QLabel* label1 = new QLabel("Line width"); QLabel* label2 = new QLabel("Hit size"); fLineWidthSpinBox = new QDoubleSpinBox(); fHitSizeSpinBox = new QDoubleSpinBox(); fLineWidthSpinBox->setStatusTip("Change lines width"); fLineWidthSpinBox->setToolTip("Change lines width"); fHitSizeSpinBox->setStatusTip("Change hits size"); fHitSizeSpinBox->setToolTip("Change hits size"); fLineWidthSpinBox->setRange(0.2, 5.); fHitSizeSpinBox->setRange(0.2, 5.); fLineWidthSpinBox->setSingleStep(0.02); fHitSizeSpinBox->setSingleStep(0.02); fLineWidthSpinBox->setValue(0.5); fHitSizeSpinBox->setValue(0.5); connect(fLineWidthSpinBox, SIGNAL(valueChanged(double)), this, SLOT(LineWidthSpinBoxChanged(double))); connect(fHitSizeSpinBox, SIGNAL(valueChanged(double)), this, SLOT(HitSizeSpinBoxChanged(double))); gridLayout->addWidget(label1,0, 0); gridLayout->addWidget(fLineWidthSpinBox,0, 1); gridLayout->addWidget(label2,1, 0); gridLayout->addWidget(fHitSizeSpinBox,1, 1); groupBox->setLayout(gridLayout); return groupBox; } void VRichPropertiesWidget::CheckBoxChanged(QWidget* widget){ for (int i = 0; i < fNofToDrawChBoxes; i ++) if (widget == fToDrawChBoxAr[i]){ if (i==0 && fToDrawChBoxAr[i]->isChecked() )fRichScene->SetItemsVisible(kRichRing,true); if (i==0 && !fToDrawChBoxAr[i]->isChecked() )fRichScene->SetItemsVisible(kRichRing, false); if (i==1 && fToDrawChBoxAr[i]->isChecked() )fRichScene->SetItemsVisible(kRichEllipse,true); if (i==1 && !fToDrawChBoxAr[i]->isChecked() )fRichScene->SetItemsVisible(kRichEllipse, false); if (i==2 && fToDrawChBoxAr[i]->isChecked() )fRichScene->SetItemsVisible(kRichHit, true); if (i==2 && !fToDrawChBoxAr[i]->isChecked() )fRichScene->SetItemsVisible(kRichHit, false); if (i==3 && fToDrawChBoxAr[i]->isChecked() )fRichScene->SetItemsVisible(kRichProj, true); if (i==3 && !fToDrawChBoxAr[i]->isChecked() )fRichScene->SetItemsVisible(kRichProj, false); if (i==4 && fToDrawChBoxAr[i]->isChecked() )fRichScene->SetItemsVisible(kRichPoint, true); if (i==4 && !fToDrawChBoxAr[i]->isChecked() )fRichScene->SetItemsVisible(kRichPoint, false); fRichScene->ChangeItemsVisibility(); break; } for (int i = 0; i < fNofRingTypeChBoxes; i ++) if (widget == fRingTypeChBoxAr[i]){ if (i==0 && fRingTypeChBoxAr[i]->isChecked() )fRichScene->SetRingsVisible(kRichElRing, true); if (i==0 && !fRingTypeChBoxAr[i]->isChecked() )fRichScene->SetRingsVisible(kRichElRing, false); if (i==1 && fRingTypeChBoxAr[i]->isChecked() )fRichScene->SetRingsVisible(kRichPiRing, true); if (i==1 && !fRingTypeChBoxAr[i]->isChecked() )fRichScene->SetRingsVisible(kRichPiRing, false); if (i==2 && fRingTypeChBoxAr[i]->isChecked() )fRichScene->SetRingsVisible(kRichFakeRing, true); if (i==2 && !fRingTypeChBoxAr[i]->isChecked() )fRichScene->SetRingsVisible(kRichFakeRing, false); if (i==3 && fRingTypeChBoxAr[i]->isChecked() )fRichScene->SetRingsVisible(kRichCloneRing, true); if (i==3 && !fRingTypeChBoxAr[i]->isChecked() )fRichScene->SetRingsVisible(kRichCloneRing, false); fRichScene->ChangeRingsVisibility(); break; } } void VRichPropertiesWidget::ColorBtnClicked(QWidget* widget){ QColor color = QColorDialog::getColor(); for (int i = 0; i < fNofToDrawChBoxes; i ++) if (widget == (QWidget*)fToDrawBtnAr[i]){ fToDrawBtnAr[i]->setPalette(QPalette(color)); if (i==0)fRichScene->SetItemsColor(kRichRing, color); if (i==1)fRichScene->SetItemsColor(kRichHit, color); if (i==2)fRichScene->SetItemsColor(kRichProj, color); if (i==3)fRichScene->SetItemsColor(kRichPoint, color); if (i==0)fRichScene->ChangeItemsColor(kRichRing); if (i==1)fRichScene->ChangeItemsColor(kRichHit); if (i==2)fRichScene->ChangeItemsColor(kRichProj); if (i==3)fRichScene->ChangeItemsColor(kRichPoint); break; } for (int i = 0; i < fNofRingTypeChBoxes; i ++) if (widget == fRingTypeBtnAr[i]){ fRingTypeBtnAr[i]->setPalette(QPalette(color)); if (i==0)fRichScene->SetRingsColor(kRichElRing, color); if (i==1)fRichScene->SetRingsColor(kRichPiRing, color); if (i==2)fRichScene->SetRingsColor(kRichFakeRing, color); if (i==3)fRichScene->SetRingsColor(kRichCloneRing, color); if (i==0)fRichScene->ChangeRingsColor(kRichElRing); if (i==1)fRichScene->ChangeRingsColor(kRichPiRing); if (i==2)fRichScene->ChangeRingsColor(kRichFakeRing); if (i==3)fRichScene->ChangeRingsColor(kRichCloneRing); break; } } void VRichPropertiesWidget::LineWidthSpinBoxChanged(double d) { fRichScene->ChangeLineWidth(d); } void VRichPropertiesWidget::HitSizeSpinBoxChanged(double d) { fRichScene->ChangeHitSize(d); }