From 358b7d254e07d4eae0cb1350b580783a82c1638f Mon Sep 17 00:00:00 2001 From: srit Date: Mon, 14 Mar 2011 23:13:13 +0000 Subject: [PATCH] Added VF color option and corresponding button --- vv/qt_ui/vvOverlayPanel.ui | 10 ++++++++++ vv/vvMainWindow.cxx | 5 +++-- vv/vvMainWindow.h | 2 +- vv/vvOverlayPanel.cxx | 15 ++++++++++++++- vv/vvOverlayPanel.h | 4 ++-- vv/vvSlicer.cxx | 32 ++++++++++++++++++++++++++++---- vv/vvSlicer.h | 8 ++++++++ 7 files changed, 66 insertions(+), 10 deletions(-) diff --git a/vv/qt_ui/vvOverlayPanel.ui b/vv/qt_ui/vvOverlayPanel.ui index 62a43f5..60a6803 100644 --- a/vv/qt_ui/vvOverlayPanel.ui +++ b/vv/qt_ui/vvOverlayPanel.ui @@ -169,6 +169,16 @@ p, li { white-space: pre-wrap; } + + + + + background-color: rgb(0, 255, 0); + border: 0px; + + + + diff --git a/vv/vvMainWindow.cxx b/vv/vvMainWindow.cxx index e1da8fa..0673eae 100644 --- a/vv/vvMainWindow.cxx +++ b/vv/vvMainWindow.cxx @@ -279,7 +279,7 @@ vvMainWindow::vvMainWindow():vvMainWindowBase() connect(linkPanel,SIGNAL(addLink(QString,QString)),this,SLOT(AddLink(QString,QString))); connect(linkPanel,SIGNAL(removeLink(QString,QString)),this,SLOT(RemoveLink(QString,QString))); - connect(overlayPanel,SIGNAL(VFPropertyUpdated(int,int,int,int)),this,SLOT(SetVFProperty(int,int,int,int))); + connect(overlayPanel,SIGNAL(VFPropertyUpdated(int,int,int,int,double,double,double)),this,SLOT(SetVFProperty(int,int,int,int,double,double,double))); connect(overlayPanel,SIGNAL(OverlayPropertyUpdated(int)),this,SLOT(SetOverlayProperty(int))); connect(overlayPanel,SIGNAL(FusionPropertyUpdated(int,int,double,double)), this,SLOT(SetFusionProperty(int,int,double,double))); @@ -2087,7 +2087,7 @@ void vvMainWindow::AddField(QString file,int index) //------------------------------------------------------------------------------ -void vvMainWindow::SetVFProperty(int subsampling, int scale, int log, int width) +void vvMainWindow::SetVFProperty(int subsampling, int scale, int log, int width, double r, double g, double b) { int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]); if (mSlicerManagers[index]->GetSlicer(0)->GetVF()) { @@ -2095,6 +2095,7 @@ void vvMainWindow::SetVFProperty(int subsampling, int scale, int log, int width) mSlicerManagers[index]->GetSlicer(i)->SetVFSubSampling(subsampling); mSlicerManagers[index]->GetSlicer(i)->SetVFScale(scale); mSlicerManagers[index]->GetSlicer(i)->SetVFWidth(width); + mSlicerManagers[index]->GetSlicer(i)->SetVFColor(r,g,b); if (log > 0) mSlicerManagers[index]->GetSlicer(i)->SetVFLog(1); else diff --git a/vv/vvMainWindow.h b/vv/vvMainWindow.h index b3cd6cd..3625923 100644 --- a/vv/vvMainWindow.h +++ b/vv/vvMainWindow.h @@ -140,7 +140,7 @@ public slots: void SelectOverlayImage(); void SelectFusionImage(); - void SetVFProperty(int subsampling,int scale,int lut, int width); + void SetVFProperty(int subsampling,int scale,int lut, int width, double r, double g, double b); void SetOverlayProperty(int color); void SetFusionProperty(int opacity,int colormap,double window,double level); diff --git a/vv/vvOverlayPanel.cxx b/vv/vvOverlayPanel.cxx index 425fd34..7611623 100644 --- a/vv/vvOverlayPanel.cxx +++ b/vv/vvOverlayPanel.cxx @@ -22,6 +22,7 @@ #include #include #include "QTreePushButton.h" +#include #include @@ -41,6 +42,7 @@ vvOverlayPanel::vvOverlayPanel(QWidget * parent):QWidget(parent) connect(scaleSpinBox,SIGNAL(editingFinished()),this,SLOT(setVFProperty())); connect(lutCheckBox,SIGNAL(clicked()),this,SLOT(setVFProperty())); connect(vfWidthSpinBox,SIGNAL(editingFinished()),this,SLOT(setVFProperty())); + connect(vfColorButton,SIGNAL(clicked()),this,SLOT(VFColorChangeRequest())); connect(colorHorizontalSlider,SIGNAL(valueChanged(int)),this,SLOT(setOverlayProperty())); connect(opacityHorizontalSlider,SIGNAL(valueChanged(int)),this,SLOT(setFusionProperty())); connect(fusionColorMapComboBox,SIGNAL(currentIndexChanged(int)),this,SLOT(setFusionProperty())); @@ -90,10 +92,12 @@ void vvOverlayPanel::getVFName(QString name) void vvOverlayPanel::setVFProperty() { + QColor color(vfColorButton->palette().color(QPalette::Background)); emit VFPropertyUpdated(subSamplingSpinBox->value(), scaleSpinBox->value(), lutCheckBox->checkState(), - vfWidthSpinBox->value()); + vfWidthSpinBox->value(), + color.redF(), color.greenF(), color.blueF()); } void vvOverlayPanel::getCurrentVectorInfo(int visibility, double x,double y,double z, double value) @@ -199,5 +203,14 @@ void vvOverlayPanel::getCurrentFusionInfo(int visibility,double value) valueFusionnedLabel->setText(fusionValue); } +void vvOverlayPanel::VFColorChangeRequest() +{ + QColor color(vfColorButton->palette().color(QPalette::Background)); + color = QColorDialog::getColor(color, this, "Choose the new color of the vector field"); + //vfColorButton->palette().setColor(QPalette::Background, color); SR: Not working? + vfColorButton->setStyleSheet("* { background-color: " + color.name() + "; border: 0px }"); + this->setVFProperty(); +} + #endif /* end #define _vvOverlayPanel_CXX */ diff --git a/vv/vvOverlayPanel.h b/vv/vvOverlayPanel.h index 2d6b6b5..71a7297 100644 --- a/vv/vvOverlayPanel.h +++ b/vv/vvOverlayPanel.h @@ -52,12 +52,12 @@ public slots: void setVFProperty(); void setOverlayProperty(); void setFusionProperty(); + void VFColorChangeRequest(); signals: - void VFPropertyUpdated(int subsampling, int scale, int log, int width); + void VFPropertyUpdated(int subsampling, int scale, int log, int width, double r, double g, double b); void OverlayPropertyUpdated(int color); void FusionPropertyUpdated(int opacity, int colormap, double window, double level); - }; // end class vvOverlayPanel //==================================================================== diff --git a/vv/vvSlicer.cxx b/vv/vvSlicer.cxx index c9b50a7..24a552b 100644 --- a/vv/vvSlicer.cxx +++ b/vv/vvSlicer.cxx @@ -91,6 +91,9 @@ vvSlicer::vvSlicer() mScale = 1; mVFLog = 0; mVFWidth = 1; + mVFColor[0] = 0; + mVFColor[1] = 1; + mVFColor[2] = 0; std::string text = "F1 = sagital; F2 = coronal; F3 = axial\n"; text += "F5 = horizontal flip; F6 = vertical flip\n\n"; @@ -428,11 +431,20 @@ void vvSlicer::SetVF(vvImage::Pointer vf) mGlyphFilter->SetVectorModeToUseVector(); mGlyphFilter->SetColorModeToColorByVector(); + if (!mVFColorLUT) + mVFColorLUT = vtkSmartPointer::New(); + + double mVFColorHSV[3]; + vtkMath::RGBToHSV(mVFColor, mVFColorHSV); + mVFColorLUT->SetHueRange(mVFColorHSV[0], mVFColorHSV[0]); + mVFColorLUT->SetSaturationRange(mVFColorHSV[1],mVFColorHSV[1]); + mVFColorLUT->SetValueRange(mVFColorHSV[2], mVFColorHSV[2]); + if (!mVFMapper) mVFMapper = vtkSmartPointer::New(); - //mVFMapper->SetInputConnection(mGlyphFilter->GetOutputPort()); mVFMapper->SetInput(mGlyphFilter->GetOutput()); mVFMapper->ImmediateModeRenderingOn(); + mVFMapper->SetLookupTable(mVFColorLUT); if (!mVFActor) mVFActor = vtkSmartPointer::New(); @@ -1391,7 +1403,19 @@ void vvSlicer::PrintSelf(ostream& os, vtkIndent indent) } //---------------------------------------------------------------------------- - - - +//---------------------------------------------------------------------------- +void vvSlicer::SetVFColor(double r, double g, double b) +{ + double mVFColorHSV[3]; + mVFColor[0] = r; + mVFColor[1] = g; + mVFColor[2] = b; + + vtkMath::RGBToHSV(mVFColor, mVFColorHSV); + mVFColorLUT->SetHueRange(mVFColorHSV[0], mVFColorHSV[0]); + mVFColorLUT->SetSaturationRange(mVFColorHSV[1],mVFColorHSV[1]); + mVFColorLUT->SetValueRange(mVFColorHSV[2], mVFColorHSV[2]); + + this->Render(); +} diff --git a/vv/vvSlicer.h b/vv/vvSlicer.h index 4b7d169..7a1ee02 100644 --- a/vv/vvSlicer.h +++ b/vv/vvSlicer.h @@ -27,6 +27,7 @@ #include #include +#include class vtkActor; class vtkActor2D; @@ -168,6 +169,11 @@ public: int GetOrientation(); int * GetExtent(); + double* GetVFColor() { + return mVFColor; + } + void SetVFColor(double r, double g, double b); + protected: vvSlicer(); ~vvSlicer(); @@ -193,6 +199,7 @@ protected: vtkSmartPointer mVOIFilter; vtkSmartPointer mGlyphFilter; vtkSmartPointer mVFMapper; + vtkSmartPointer mVFColorLUT; vtkSmartPointer mVFActor; vtkSmartPointer mLandGlyph; vtkSmartPointer mCross; @@ -210,6 +217,7 @@ protected: int mScale; int mVFLog; int mVFWidth; + double mVFColor[3]; bool mUseReducedExtent; int * mReducedExtent; int * mInitialExtent; -- 2.47.1