#include "VTrackingPropertiesWidget.h" #include "VTrackingScene.h" VTrackingPropertiesWidget::VTrackingPropertiesWidget( VTrackingScene* scene) { fScene = scene; fNofItemTypes = 3; fSizeSignalMapper = new QSignalMapper(this); fColorSignalMapper = new QSignalMapper(this); fIsDrawSignalMapper = new QSignalMapper(this); fUpdateBtn = new QPushButton(tr("Update")); connect(fUpdateBtn, SIGNAL(clicked()), this, SLOT(UpdateScene())); fTopLayout = new QVBoxLayout(); fTopLayout->addWidget(CreateStyleGroupBox()); fTopLayout->addWidget(CreateDrawProjectionsGroupBox()); fTopLayout->addWidget(CreateLabelGroupBox()); fTopLayout->addWidget(fUpdateBtn); fTopLayout->addStretch(); connect(fSizeSignalMapper, SIGNAL(mapped(QWidget *)), this, SLOT(SizeSpinBoxChanged(QWidget*))); connect(fColorSignalMapper, SIGNAL(mapped(QWidget *)), this, SLOT(ColorBtnClicked(QWidget*))); connect(fIsDrawSignalMapper, SIGNAL(mapped(QWidget *)), this, SLOT(VisibilityCheckBoxChanged(QWidget*))); setLayout(fTopLayout); } VTrackingPropertiesWidget::~VTrackingPropertiesWidget() { } QGroupBox* VTrackingPropertiesWidget::CreateStyleGroupBox() { QGroupBox* groupBox = new QGroupBox(tr("Drawing style")); QGridLayout *gridLayout = new QGridLayout(); QString text[] = {"Point", "Hit", "Track"}; fSizeSpinBox.resize(fNofItemTypes); fIsDrawCheckBox.resize(fNofItemTypes); fColorBtn.resize(fNofItemTypes); for (int i = 0; i < fNofItemTypes; i++) { fSizeSpinBox[i] = new QDoubleSpinBox(); fSizeSpinBox[i]->setStatusTip(tr("Change size")); fSizeSpinBox[i]->setToolTip(tr("Change size")); fSizeSpinBox[i]->setRange(0.1, 5.); fSizeSpinBox[i]->setSingleStep(0.1); fSizeSpinBox[i]->setValue(fScene->GetSize(TrackingGraphicsItem(i))); connect(fSizeSpinBox[i], SIGNAL(valueChanged(double)), fSizeSignalMapper, SLOT(map())); fSizeSignalMapper->setMapping(fSizeSpinBox[i], fSizeSpinBox[i]); fIsDrawCheckBox[i] = new QCheckBox(text[i]); fIsDrawCheckBox[i]->setStatusTip(tr("Check to draw")); fIsDrawCheckBox[i]->setToolTip(tr("Check to draw")); Qt::CheckState state = fScene->IsDraw(TrackingGraphicsItem(i)) ? Qt::Checked : Qt::Unchecked; fIsDrawCheckBox[i]->setCheckState(state); connect(fIsDrawCheckBox[i], SIGNAL(stateChanged(int)), fIsDrawSignalMapper, SLOT(map())); fIsDrawSignalMapper->setMapping(fIsDrawCheckBox[i], fIsDrawCheckBox[i]); fColorBtn[i] = new QPushButton(); fColorBtn[i]->setStatusTip(tr("Click to change color")); fColorBtn[i]->setToolTip(tr("Click to change color")); fColorBtn[i]->setMaximumWidth(30); fColorBtn[i]->setAutoFillBackground(true); fColorBtn[i]->setFlat(true); fColorBtn[i]->setPalette(QPalette(fScene->GetColor(TrackingGraphicsItem(i)))); connect(fColorBtn[i], SIGNAL(clicked()), fColorSignalMapper, SLOT(map())); fColorSignalMapper->setMapping(fColorBtn[i], fColorBtn[i]); gridLayout->addWidget(fIsDrawCheckBox[i], i, 0); gridLayout->addWidget(fSizeSpinBox[i], i, 1); gridLayout->addWidget(fColorBtn[i], i, 2); } groupBox->setLayout(gridLayout); return groupBox; } QGroupBox* VTrackingPropertiesWidget::CreateDrawProjectionsGroupBox() { QGroupBox* groupBox = new QGroupBox(tr("Projections")); QVBoxLayout *layout = new QVBoxLayout(); fDrawXYProjectionCheckBox = new QCheckBox(tr("XY")); fDrawXYProjectionCheckBox->setStatusTip(tr("Check to draw")); fDrawXYProjectionCheckBox->setToolTip(tr("Check to draw")); Qt::CheckState state = fScene->IsDrawXYProjection() ? Qt::Checked : Qt::Unchecked; fDrawXYProjectionCheckBox->setCheckState(state); connect(fDrawXYProjectionCheckBox, SIGNAL(stateChanged(int)), this, SLOT(IsDrawXYProjectionChanged(int))); layout->addWidget(fDrawXYProjectionCheckBox); fDrawXZProjectionCheckBox = new QCheckBox(tr("XZ")); fDrawXZProjectionCheckBox->setStatusTip(tr("Check to draw")); fDrawXZProjectionCheckBox->setToolTip(tr("Check to draw")); state = fScene->IsDrawXZProjection() ? Qt::Checked : Qt::Unchecked; fDrawXZProjectionCheckBox->setCheckState(state); connect(fDrawXZProjectionCheckBox, SIGNAL(stateChanged(int)), this, SLOT(IsDrawXZProjectionChanged(int))); layout->addWidget(fDrawXZProjectionCheckBox); fDrawYZProjectionCheckBox = new QCheckBox(tr("YZ")); fDrawYZProjectionCheckBox->setStatusTip(tr("Check to draw")); fDrawYZProjectionCheckBox->setToolTip(tr("Check to draw")); state = fScene->IsDrawYZProjection() ? Qt::Checked : Qt::Unchecked; fDrawYZProjectionCheckBox->setCheckState(state); connect(fDrawYZProjectionCheckBox, SIGNAL(stateChanged(int)), this, SLOT(IsDrawYZProjectionChanged(int))); layout->addWidget(fDrawYZProjectionCheckBox); groupBox->setLayout(layout); return groupBox; } QGroupBox* VTrackingPropertiesWidget::CreateLabelGroupBox() { QGroupBox* gBox=new QGroupBox("Track label"); QVBoxLayout* layout=new QVBoxLayout(); QLabel* label1=new QLabel("Track title"); layout->addWidget(label1); fTrackTitleEdit=new QLineEdit(fScene->GetTrackTitle()); fTrackTitleEdit->setStatusTip("Text displayed on canvas for each track."); fTrackTitleEdit->setToolTip("Text displayed on canvas for each track."); connect(fTrackTitleEdit, SIGNAL(editingFinished()), this, SLOT(DoneTrackTitleEdit())); layout->addWidget(fTrackTitleEdit); QLabel* label2=new QLabel("Track caption"); layout->addWidget(label2); fTrackCaptionEdit=new QLineEdit(fScene->GetTrackCaption()); fTrackCaptionEdit->setStatusTip("Text displayed in the status bar for track under cursor."); fTrackCaptionEdit->setToolTip("Text displayed in the status bar for track under cursor."); connect(fTrackCaptionEdit, SIGNAL(editingFinished()), this, SLOT(DoneTrackCaptionEdit())); layout->addWidget(fTrackCaptionEdit); gBox->setLayout(layout); return gBox; } void VTrackingPropertiesWidget::SizeSpinBoxChanged( QWidget* widget) { TrackingGraphicsItem type; if (widget == fSizeSpinBox[kVPOINT]) { type = kVPOINT; } else if (widget == fSizeSpinBox[kVHIT]) { type = kVHIT; } else if (widget == fSizeSpinBox[kVTRACK]) { type = kVTRACK; } else { return; } double size = ((QDoubleSpinBox*)widget)->value(); fScene->SetSize(type, size); } void VTrackingPropertiesWidget::VisibilityCheckBoxChanged( QWidget* widget) { TrackingGraphicsItem type; if (widget == fIsDrawCheckBox[kVPOINT]) { type = kVPOINT; } else if (widget == fIsDrawCheckBox[kVHIT]) { type = kVHIT; } else if (widget == fIsDrawCheckBox[kVTRACK]) { type = kVTRACK; } else { return; } bool isDraw = ((QCheckBox*)widget)->isChecked(); fScene->IsDraw(type, isDraw); } void VTrackingPropertiesWidget::ColorBtnClicked( QWidget* widget) { QColor color = QColorDialog::getColor(); TrackingGraphicsItem type; if (widget == fColorBtn[kVPOINT]) { type = kVPOINT; } else if (widget == fColorBtn[kVHIT]) { type = kVHIT; } else if (widget == fColorBtn[kVTRACK]) { type = kVTRACK; } else { return; } ((QPushButton*)widget)->setPalette(QPalette(color)); fScene->SetColor(type, color); } void VTrackingPropertiesWidget::IsDrawXYProjectionChanged( int state) { if (state == Qt::Checked) fScene->IsDrawXYProjection(true); else fScene->IsDrawXYProjection(false); } void VTrackingPropertiesWidget::IsDrawXZProjectionChanged( int state) { if (state == Qt::Checked) fScene->IsDrawXZProjection(true); else fScene->IsDrawXZProjection(false); } void VTrackingPropertiesWidget::IsDrawYZProjectionChanged( int state) { if (state == Qt::Checked) fScene->IsDrawYZProjection(true); else fScene->IsDrawYZProjection(false); } void VTrackingPropertiesWidget::DoneTrackTitleEdit() { fScene->SetTrackTitle(fTrackTitleEdit->text()); } void VTrackingPropertiesWidget::DoneTrackCaptionEdit() { fScene->SetTrackCaption(fTrackCaptionEdit->text()); } void VTrackingPropertiesWidget::UpdateScene() { fScene->Update(); }