]> Creatis software - clitk.git/commitdiff
Added VF color option and corresponding button
authorsrit <srit>
Mon, 14 Mar 2011 23:13:13 +0000 (23:13 +0000)
committersrit <srit>
Mon, 14 Mar 2011 23:13:13 +0000 (23:13 +0000)
vv/qt_ui/vvOverlayPanel.ui
vv/vvMainWindow.cxx
vv/vvMainWindow.h
vv/vvOverlayPanel.cxx
vv/vvOverlayPanel.h
vv/vvSlicer.cxx
vv/vvSlicer.h

index 62a43f5216cd2494840ff496c5112a4f22a503bb..60a6803859eb98011b98a10c9cd2961e5c7ac997 100644 (file)
@@ -169,6 +169,16 @@ p, li { white-space: pre-wrap; }
           </property>
          </widget>
         </item>
+        <item>
+         <widget class="QToolButton" name="vfColorButton">
+           <property name="styleSheet">
+            <string>
+              background-color: rgb(0, 255, 0);
+              border: 0px;
+            </string>
+           </property>
+         </widget>
+        </item>
        </layout>
       </item>
       <item>
index e1da8faaa39ef34bd4beffeb31ec3c50dd6aace8..0673eae896c5dbe7d3f355daa42fcd9e92b5c531 100644 (file)
@@ -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
index b3cd6cd6834228ab2a47d1d5d0931d8a4910ca5c..362592382572171920e87f17c6feaac40bb83c4a 100644 (file)
@@ -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);
 
index 425fd34e6480751f92c7cc73334335b028229ee7..76116236043cc002b8cda0aaf2d8b31c5869d8d6 100644 (file)
@@ -22,6 +22,7 @@
 #include <QtGui>
 #include <Qt>
 #include "QTreePushButton.h"
+#include <QColorDialog>
 
 #include <vtksys/SystemTools.hxx>
 
@@ -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 */
 
index 2d6b6b59fc720e48a28f894bbe4b0161b3c22aea..71a7297d91e667803e419ae4856aeeb5f3d66e4f 100644 (file)
@@ -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
 //====================================================================
 
index c9b50a7973ac827fa396b8ec59e16a976247ffc9..24a552b251486faffaf677ebf989f9174686c883 100644 (file)
@@ -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<vtkLookupTable>::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<vtkPolyDataMapper>::New();
-    //mVFMapper->SetInputConnection(mGlyphFilter->GetOutputPort());
     mVFMapper->SetInput(mGlyphFilter->GetOutput());
     mVFMapper->ImmediateModeRenderingOn();
+    mVFMapper->SetLookupTable(mVFColorLUT);
 
     if (!mVFActor)
       mVFActor = vtkSmartPointer<vtkActor>::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();
+}  
 
index 4b7d1697d14c65d6cbd849ee4d5e4fb6d257e61a..7a1ee02a5857b559cbef3fb30f831b17a8ac241b 100644 (file)
@@ -27,6 +27,7 @@
 
 #include <vtkSmartPointer.h>
 #include <vtkImageViewer2.h>
+#include <vtkColor.h>
 
 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<vtkExtractVOI> mVOIFilter;
   vtkSmartPointer<vvGlyph2D> mGlyphFilter;
   vtkSmartPointer<vtkPolyDataMapper> mVFMapper;
+  vtkSmartPointer<vtkLookupTable> mVFColorLUT;
   vtkSmartPointer<vtkActor> mVFActor;
   vtkSmartPointer<vtkGlyph3D> mLandGlyph;
   vtkSmartPointer<vtkCursor3D> mCross;
@@ -210,6 +217,7 @@ protected:
   int mScale;
   int mVFLog;
   int mVFWidth;
+  double mVFColor[3];
   bool mUseReducedExtent;
   int * mReducedExtent;
   int * mInitialExtent;