]> Creatis software - clitk.git/commitdiff
- small correction about Render (a bit less unuseful Render)
authordsarrut <dsarrut>
Tue, 11 May 2010 09:07:54 +0000 (09:07 +0000)
committerdsarrut <dsarrut>
Tue, 11 May 2010 09:07:54 +0000 (09:07 +0000)
16 files changed:
vv/vvBinaryImageOverlayActor.cxx
vv/vvBinaryImageOverlayActor.h
vv/vvImageContour.cxx
vv/vvImageContour.h
vv/vvMainWindow.cxx
vv/vvROIActor.cxx
vv/vvROIActor.h
vv/vvSlicer.cxx
vv/vvStructureSetActor.cxx
vv/vvToolBinarize.cxx
vv/vvToolBinarize.h
vv/vvToolCropImage.cxx
vv/vvToolResample.cxx
vv/vvToolResample.h
vv/vvToolStructureSetManager.cxx
vv/vvToolStructureSetManager.h

index 3a448ab708381b4f75a60bb34f61993de17d3b38..7d6d26c5c8569e68c817fef46176db0dbfe16217 100644 (file)
@@ -54,7 +54,7 @@ vvBinaryImageOverlayActor::~vvBinaryImageOverlayActor() {
 
 
 //------------------------------------------------------------------------------
-void vvBinaryImageOverlayActor::setColor(double r, double g, double b) {
+void vvBinaryImageOverlayActor::SetColor(double r, double g, double b) {
   mColor[0] = r;
   mColor[1] = g;
   mColor[2] = b;
@@ -63,14 +63,14 @@ void vvBinaryImageOverlayActor::setColor(double r, double g, double b) {
 
 
 //------------------------------------------------------------------------------
-void vvBinaryImageOverlayActor::setSlicer(vvSlicer * slicer) {
+void vvBinaryImageOverlayActor::SetSlicer(vvSlicer * slicer) {
   mSlicer = slicer;
 }
 //------------------------------------------------------------------------------
 
 
 //------------------------------------------------------------------------------
-void vvBinaryImageOverlayActor::initialize() {
+void vvBinaryImageOverlayActor::Initialize() {
   if (!mSlicer) {
     std::cerr << "ERROR. Please use setSlicer before setSlicer in vvBinaryImageOverlayActor." << std::endl;
     exit(0);
@@ -82,17 +82,13 @@ void vvBinaryImageOverlayActor::initialize() {
   }
   // Create an actor for each time slice
   for (unsigned int numImage = 0; numImage < mSlicer->GetImage()->GetVTKImages().size(); numImage++) {
-    DD(numImage);
-
     // how many intensity ? 
     vtkImageMapToRGBA * mOverlayMapper = vtkImageMapToRGBA::New();
     mOverlayMapper->SetInput(mImage->GetVTKImages()[0]); // DS TODO : to change if it is 4D !!!
-    DD(mColorLUT->IsOpaque ());
     mColorLUT->SetRange(0,1);
     mColorLUT->SetNumberOfTableValues(2);
     mColorLUT->SetTableValue(mBackgroundValue, 0, 0, 0, 0.0);   // BG
     mColorLUT->SetTableValue(1, mColor[0], mColor[1], mColor[2], mAlpha); // FG
-    DD(mColor[0]);
     mOverlayMapper->SetLookupTable(mColorLUT);
     
     vtkImageActor * mOverlayActor = vtkImageActor::New();
@@ -112,27 +108,46 @@ void vvBinaryImageOverlayActor::initialize() {
 //------------------------------------------------------------------------------
 void vvBinaryImageOverlayActor::SetOpacity(double d) {
   mAlpha = d;
-  mColorLUT->SetTableValue(1, mColor[0], mColor[1], mColor[2], mAlpha); // FG
-  for (unsigned int numImage = 0; numImage < mSlicer->GetImage()->GetVTKImages().size(); numImage++) {
-    DD(numImage);
+}
+//------------------------------------------------------------------------------
 
-    // how many intensity ? 
-    vtkImageMapToRGBA * mOverlayMapper = mMapperList[numImage];
-    mOverlayMapper->SetLookupTable(mColorLUT);
+
+//------------------------------------------------------------------------------
+// void vvBinaryImageOverlayActor::UpdateOpacity(double d) {
+//   mAlpha = d;
+//   mColorLUT->SetTableValue(1, mColor[0], mColor[1], mColor[2], mAlpha); // FG
+//   for (unsigned int numImage = 0; numImage < mSlicer->GetImage()->GetVTKImages().size(); numImage++) {
+//     // how many intensity ? 
+//     vtkImageMapToRGBA * mOverlayMapper = mMapperList[numImage];
+//     mOverlayMapper->SetLookupTable(mColorLUT);
     
-    vtkImageActor * mOverlayActor = mImageActorList[numImage];
-    mOverlayActor->SetInput(mOverlayMapper->GetOutput());
-    //mOverlayActor->SetPickable(0);
-    //    mOverlayActor->SetVisibility(true);
-    //mOverlayActor->SetOpacity(1.0);
-  }
-  DD("end SetOpacity");
-}
+//     vtkImageActor * mOverlayActor = mImageActorList[numImage];
+//     mOverlayActor->SetInput(mOverlayMapper->GetOutput());
+//   }
+// }
 //------------------------------------------------------------------------------
 
 
 //------------------------------------------------------------------------------
-void vvBinaryImageOverlayActor::setImage(vvImage::Pointer image, double bg) {
+// void vvBinaryImageOverlayActor::SetColor(double r, double v, double b) {
+//   mColor[0] = r; 
+//   mColor[1] = v; 
+//   mColor[2] = b; 
+//   // mColorLUT->SetTableValue(1, mColor[0], mColor[1], mColor[2], mAlpha); // FG
+//   // for (unsigned int numImage = 0; numImage < mSlicer->GetImage()->GetVTKImages().size(); numImage++) {
+//   //   // how many intensity ? 
+//   //   vtkImageMapToRGBA * mOverlayMapper = mMapperList[numImage];
+//   //   mOverlayMapper->SetLookupTable(mColorLUT);
+    
+//   //   vtkImageActor * mOverlayActor = mImageActorList[numImage];
+//   //   mOverlayActor->SetInput(mOverlayMapper->GetOutput());
+//   // }
+// }
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvBinaryImageOverlayActor::SetImage(vvImage::Pointer image, double bg) {
   mImage = image;
   mBackgroundValue = bg;
 }
@@ -140,31 +155,47 @@ void vvBinaryImageOverlayActor::setImage(vvImage::Pointer image, double bg) {
 
 
 //------------------------------------------------------------------------------
-void vvBinaryImageOverlayActor::hideActors() {
+void vvBinaryImageOverlayActor::HideActors() {
   if (!mSlicer) return;
   mSlice = mSlicer->GetSlice();
   for(unsigned int i=0; i<mImageActorList.size(); i++) {
     mImageActorList[i]->VisibilityOff();
   }
+  mSlicer->Render();
 }
 //------------------------------------------------------------------------------
 
   
 //------------------------------------------------------------------------------
-void vvBinaryImageOverlayActor::showActors() {
+void vvBinaryImageOverlayActor::ShowActors() {
   if (!mSlicer) return;
   mSlice = mSlicer->GetSlice();
   mTSlice = mSlicer->GetTSlice();
   //  for(unsigned int i=0; i<mSquaresActorList.size(); i++) {
   mImageActorList[mTSlice]->VisibilityOn();
-  update(0, mSlice);
+  UpdateSlice(0, mSlice);
   //}
+  mSlicer->Render();
 }
 //------------------------------------------------------------------------------
 
   
 //------------------------------------------------------------------------------
-void vvBinaryImageOverlayActor::update(int slicer, int slice) {
+void vvBinaryImageOverlayActor::UpdateColor() {
+  mColorLUT->SetTableValue(1, mColor[0], mColor[1], mColor[2], mAlpha); // FG
+  for (unsigned int numImage = 0; numImage < mSlicer->GetImage()->GetVTKImages().size(); numImage++) {
+    // how many intensity ? 
+    vtkImageMapToRGBA * mOverlayMapper = mMapperList[numImage];
+    mOverlayMapper->SetLookupTable(mColorLUT);
+    
+    vtkImageActor * mOverlayActor = mImageActorList[numImage];
+    mOverlayActor->SetInput(mOverlayMapper->GetOutput());
+  }
+}
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+void vvBinaryImageOverlayActor::UpdateSlice(int slicer, int slice) {
   if (!mSlicer) return;
 
   if (mPreviousSlice == mSlicer->GetSlice()) {
index 1d05760981e1b8a7cbf286b0566094230b6c2b8c..58512ed3c8a50fd49009c62428f1e69e0fea4711 100644 (file)
@@ -36,14 +36,15 @@ class vvBinaryImageOverlayActor
   vvBinaryImageOverlayActor();
   ~vvBinaryImageOverlayActor();
 
-  void setSlicer(vvSlicer * slicer);
-  void update(int slicer, int slice);
-  void hideActors();
-  void showActors();
-  void setColor(double r, double g, double b);
-  void setImage(vvImage::Pointer image, double bg);
-  void initialize();
+  void SetSlicer(vvSlicer * slicer);
+  void SetColor(double r, double g, double b);
   void SetOpacity(double d);
+  void SetImage(vvImage::Pointer image, double bg);
+  void Initialize();
+  void UpdateColor();
+  void UpdateSlice(int slicer, int slice);
+  void HideActors();
+  void ShowActors();
 
  protected:
   vvSlicer * mSlicer;
index 1c5354eb3d776cb8219a7806bbcf51bf77f1ed65..0ffff620e4496e69fab31e66e9e396e17dc0a7ec 100644 (file)
@@ -105,6 +105,15 @@ void vvImageContour::setColor(double r, double g, double b) {
 //------------------------------------------------------------------------------
 
 
+//------------------------------------------------------------------------------
+void vvImageContour::SetLineWidth(double w) {
+  for(unsigned int i=0; i<mSquaresActorList.size(); i++) {
+    mSquaresActorList[i]->GetProperty()->SetLineWidth(w);
+  }
+}
+//------------------------------------------------------------------------------
+
+
 //------------------------------------------------------------------------------
 void vvImageContour::hideActors() {
   if (!mSlicer) return;
@@ -131,10 +140,12 @@ void vvImageContour::showActors() {
   
 //------------------------------------------------------------------------------
 void vvImageContour::update(double value) {
+  //  DD(value);
   if (!mSlicer) return;
   if (mPreviousValue == value) {
     if (mPreviousSlice == mSlicer->GetSlice()) {
       if (mPreviousTSlice == mSlicer->GetTSlice()) {
+       // DD("vvImageContour::update nothing");
         return; // Nothing to do
       }
     }
@@ -145,14 +156,18 @@ void vvImageContour::update(double value) {
 
   // Get current slice
   mSlice = mSlicer->GetSlice();
-
+  //  DD(mDisplayModeIsPreserveMemory);
   if (mDisplayModeIsPreserveMemory) {
     updateWithPreserveMemoryMode();
   }
   else {
     updateWithFastCacheMode();
   }
-  mSlicer->Render();
+
+
+  mSlicer->Render(); //DS ---> REMOVE ??
+
+
   mPreviousTSlice = mSlicer->GetTSlice();
   mPreviousSlice  = mSlicer->GetSlice();
   mPreviousValue  = value;
@@ -178,6 +193,10 @@ void vvImageContour::updateWithPreserveMemoryMode() {
   vtkImageClip * mClipper = mClipperList[mTSlice];
   vtkActor * mSquaresActor = mSquaresActorList[mTSlice];
   int orientation = computeCurrentOrientation();
+  //  DD(orientation);
+  //DD(mValue);
+  //DD(mSlice);
+  //DD(mPreviousTslice);
   updateActor(mSquaresActor, mSquares, mClipper, mValue, orientation, mSlice);
   mSquaresActorList[mTSlice]->VisibilityOn();
   if (mPreviousTslice != mTSlice) {
index d7cf62cc4db8eb6578996168f16bee03502b7cc6..747ecd89fe927f233297b86f80176a6f078cbe2c 100644 (file)
@@ -39,6 +39,7 @@ class vvImageContour
   void hideActors();
   void showActors();
   void setColor(double r, double g, double b);
+  void SetLineWidth(double w);
   void setImage(vvImage::Pointer image);
   void setPreserveMemoryModeEnabled(bool b);
 
index ef064fad133444f39af74fe0e062a9b1538568e4..6b5a677bc98bbf45d9159c11fa109fb17123c9ca 100644 (file)
@@ -2451,7 +2451,7 @@ void vvMainWindow::NOVerticalSliderChanged() {
         {
           mSlicerManagers[i]->GetSlicer(0)->SetSlice(value);
           mSlicerManagers[i]->VerticalSliderHasChanged(0, value);
-          // mSlicerManagers[i]->UpdateSlice(0);  // <-- DS add this. Not too much update ? YES.
+          mSlicerManagers[i]->UpdateSlice(0);  // <-- DS add this. Not too much update ? YES. but needed for ImageContour ...
          mSlicerManagers[i]->GetSlicer(0)->Render(); // <-- DS add this, needed for contour, seems ok ? not too slow ? 
           break;
         }
@@ -2469,6 +2469,7 @@ void vvMainWindow::NEVerticalSliderChanged() {
         {
           mSlicerManagers[i]->GetSlicer(1)->SetSlice(value);
           mSlicerManagers[i]->VerticalSliderHasChanged(1, value);
+         mSlicerManagers[i]->UpdateSlice(1);
          mSlicerManagers[i]->GetSlicer(1)->Render(); // <-- DS add this, needed for contour, seems ok ? not too slow ? 
           break;
         }
@@ -2486,6 +2487,7 @@ void vvMainWindow::SOVerticalSliderChanged() {
         {
           mSlicerManagers[i]->GetSlicer(2)->SetSlice(value);
           mSlicerManagers[i]->VerticalSliderHasChanged(2, value);
+         mSlicerManagers[i]->UpdateSlice(2);
          mSlicerManagers[i]->GetSlicer(2)->Render(); // <-- DS add this, needed for contour, seems ok ? not too slow ? 
           break;
         }
@@ -2503,6 +2505,7 @@ void vvMainWindow::SEVerticalSliderChanged() {
         {
           mSlicerManagers[i]->GetSlicer(3)->SetSlice(value);
           mSlicerManagers[i]->VerticalSliderHasChanged(3, value);
+         mSlicerManagers[i]->UpdateSlice(3);
          mSlicerManagers[i]->GetSlicer(3)->Render(); // <-- DS add this, needed for contour, seems ok ? not too slow ? 
           break;
         }
index 77dc56a7a1a0afc4fb5968d6bfa1575827eeafcf..1b3585d1081268eab6eaae4d06ec0fb8b247a3e6 100644 (file)
@@ -36,6 +36,7 @@ vvROIActor::vvROIActor() {
   mOverlayActors.clear();
   mIsVisible = true;
   mOpacity = 0.7;
+  mIsSelected = false;
 }
 //------------------------------------------------------------------------------
 
@@ -47,7 +48,7 @@ vvROIActor::~vvROIActor() {
 
 
 //------------------------------------------------------------------------------
-void vvROIActor::SetROI(const clitk::DicomRT_ROI * s) {
+void vvROIActor::SetROI(clitk::DicomRT_ROI * s) {
   mROI = s;
 }
 //------------------------------------------------------------------------------
@@ -65,11 +66,11 @@ void vvROIActor::SetVisible(bool b) {
   mIsVisible = b;
   if (!b) { // remove actor
     for(unsigned int i= 0; i<mOverlayActors.size(); i++) 
-      mOverlayActors[i]->hideActors();
+      mOverlayActors[i]->HideActors();
   }
   else {
     for(unsigned int i= 0; i<mOverlayActors.size(); i++) 
-      mOverlayActors[i]->showActors();
+      mOverlayActors[i]->ShowActors();
   }
   Update();
 }
@@ -92,20 +93,21 @@ void vvROIActor::Initialize() {
       mImageContour.push_back(new vvImageContour);
       mImageContour[i]->setSlicer(mSlicerManager->GetSlicer(i));
       mImageContour[i]->setImage(mROI->GetImage());
-      //      mImageContour[i]->setColor(1.0, 0.0, 0.0);
-      mImageContour[i]->setColor(mROI->GetDisplayColor()[0], 
-                                mROI->GetDisplayColor()[1], 
-                                mROI->GetDisplayColor()[2]);
-      mImageContour[i]->setPreserveMemoryModeEnabled(false);        
+      //mImageContour[i]->setColor(1.0, 0.0, 0.0);
+      mImageContour[i]->setColor(1.0-mROI->GetDisplayColor()[0], 
+                                1.0-mROI->GetDisplayColor()[1], 
+                                1.0-mROI->GetDisplayColor()[2]);
+      mImageContour[i]->setPreserveMemoryModeEnabled(true);
+      mImageContour[i]->setSlicer(mSlicerManager->GetSlicer(i));
       
       mOverlayActors.push_back(new vvBinaryImageOverlayActor);
-      mOverlayActors[i]->setImage(mROI->GetImage(), mROI->GetBackgroundValueLabelImage());
-      mOverlayActors[i]->setColor(mROI->GetDisplayColor()[0], 
+      mOverlayActors[i]->SetImage(mROI->GetImage(), mROI->GetBackgroundValueLabelImage());
+      mOverlayActors[i]->SetColor(mROI->GetDisplayColor()[0], 
                                  mROI->GetDisplayColor()[1], 
                                  mROI->GetDisplayColor()[2]);
       mOverlayActors[i]->SetOpacity(mOpacity);
-      mOverlayActors[i]->setSlicer(mSlicerManager->GetSlicer(i));
-      mOverlayActors[i]->initialize();
+      mOverlayActors[i]->SetSlicer(mSlicerManager->GetSlicer(i));
+      mOverlayActors[i]->Initialize();
     }
     
     connect(mSlicerManager,SIGNAL(UpdateSlice(int,int)),this,SLOT(UpdateSlice(int, int)));
@@ -137,10 +139,17 @@ void vvROIActor::UpdateSlice(int slicer, int slices) {
   }
 
   // CONTOUR HERE 
-  // mImageContour[slicer]->update(1.0); 
+  DD("vvROIActor::UpdateSlice");
+  DD(mROI->GetName());
+  DD(mIsSelected);
+  DD(mROI->GetBackgroundValueLabelImage());
+  if (mIsSelected) {
+    mImageContour[slicer]->update(1.0);//mROI->GetBackgroundValueLabelImage()); 
+    //    mImageContour[slicer]->showActors();
+  }
 
   // Refresh overlays
-  mOverlayActors[slicer]->update(slicer, slices);
+  mOverlayActors[slicer]->UpdateSlice(slicer, slices);
 
   // Do not used the following line : TOO SLOW.
   // mSlicerManager->GetSlicer(slicer)->GetRenderWindow()->Render(); 
@@ -148,16 +157,35 @@ void vvROIActor::UpdateSlice(int slicer, int slices) {
 //------------------------------------------------------------------------------
 
 
+//------------------------------------------------------------------------------
+// void vvROIActor::UpdateOpacity(double d) {
+//   if (d == mOpacity) return;
+//   mOpacity = d; 
+//   for(unsigned int i=0; i<mOverlayActors.size(); i++) {
+//     mOverlayActors[i]->SetOpacity(d);
+//     mOverlayActors[i]->UpdateColor();
+//   }
+//   mSlicerManager->Render(); 
+// }
+//------------------------------------------------------------------------------
+
+
 //------------------------------------------------------------------------------
 void vvROIActor::SetOpacity(double d) {
-  if (d == mOpacity) return;
   mOpacity = d; 
-  DD(mOpacity);
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvROIActor::UpdateColor() {
   for(unsigned int i=0; i<mOverlayActors.size(); i++) {
-    DD(i);
-    mOverlayActors[i]->SetOpacity(d);
+    mOverlayActors[i]->SetOpacity(mOpacity);
+    mOverlayActors[i]->SetColor(mROI->GetDisplayColor()[0], 
+                               mROI->GetDisplayColor()[1], 
+                               mROI->GetDisplayColor()[2]);
+    mOverlayActors[i]->UpdateColor();
   }
-  DD("end vvROIActor::SetOpacity");
 }
 //------------------------------------------------------------------------------
 
@@ -168,3 +196,21 @@ double vvROIActor::GetOpacity() {
 }
 //------------------------------------------------------------------------------
 
+
+//------------------------------------------------------------------------------
+void vvROIActor::SetSelected(bool b) {
+  mIsSelected = b;
+  if (b) {
+    for(int i=0; i<mSlicerManager->NumberOfSlicers(); i++) {
+      mImageContour[i]->SetLineWidth(3.0);
+      mImageContour[i]->showActors();
+    }
+  }
+  else {
+    for(int i=0; i<mSlicerManager->NumberOfSlicers(); i++) {
+      mImageContour[i]->hideActors();
+    }
+  } 
+}
+//------------------------------------------------------------------------------
+
index c3a60b9fa3e25c2ac5172ab13aa923c4a7be1fdb..bb5c16b740c4e8f2d40e5e8b43da729593973b7d 100644 (file)
@@ -34,7 +34,8 @@ class vvROIActor: public QObject {
   vvROIActor();
   ~vvROIActor();
 
-  void SetROI(const clitk::DicomRT_ROI * r);
+  void SetROI(clitk::DicomRT_ROI * r);
+  clitk::DicomRT_ROI * GetROI() { return mROI; }
   void SetSlicerManager(vvSlicerManager * s);
   void Update();
   void Initialize();
@@ -42,18 +43,21 @@ class vvROIActor: public QObject {
   bool IsVisible();
   void SetOpacity(double x);
   double GetOpacity();
+  void SetSelected(bool b);
 
 public slots:
   void UpdateSlice(int slicer, int slices);
+  void UpdateColor();
 
  protected:
-  const clitk::DicomRT_ROI * mROI;
+  clitk::DicomRT_ROI * mROI;
   vvSlicerManager * mSlicerManager;
   std::vector<vvImageContour *> mImageContour;
   std::vector<vvBinaryImageOverlayActor *> mOverlayActors;
   
   bool mIsVisible;
   double mOpacity;
+  bool mIsSelected;
 
 }; // end class vvROIActor
 //------------------------------------------------------------------------------
index 331c236977b12d00ad9785dd5492d6aa685d479a..3b585b21b838d4d6039853f67ee60eb0ea7f369d 100644 (file)
@@ -1255,7 +1255,7 @@ void vvSlicer::GetExtremasAroundMousePointer(double & min, double & max)
 //----------------------------------------------------------------------------
 void vvSlicer::Render()
 {
-  //  DD("Render");
+  //  DD("vvSlicer::Render");
   //DD(SliceOrientation);
   if (this->GetWindowLevel()->GetLookupTable() && !this->mOverlay && !this->mFusion)
     {
index 16df5122c01f4febe138d33f92e6f213c7cc8520..7ea1ef94a4b8cdeffad8bc6994560a31d4b78943 100644 (file)
@@ -48,12 +48,10 @@ void vvStructureSetActor::SetSlicerManager(vvSlicerManager * s) {
 
 //------------------------------------------------------------------------------
 vvROIActor * vvStructureSetActor::GetROIActor(int n) {
-  DD(n);
   if (mMapROIIndex.find(n) == mMapROIIndex.end()) {
     std::cerr << "No ROI number " << n << std::endl;
     return NULL;    
   }
-  DD(mMapROIIndex[n]);
   return mROIActors[mMapROIIndex[n]];
 }
 //------------------------------------------------------------------------------
@@ -61,11 +59,8 @@ vvROIActor * vvStructureSetActor::GetROIActor(int n) {
 
 //------------------------------------------------------------------------------
 void vvStructureSetActor::CreateNewROIActor(int n) {
-  DD("AddROIActor");
-  DD(n);
-
   // Check
-  const clitk::DicomRT_ROI * roi = mStructureSet->GetROI(n);
+  clitk::DicomRT_ROI * roi = mStructureSet->GetROI(n);
   if (roi == NULL) {
     std::cerr << "Error. No ROI number " << n << std::endl;
     exit(0);
index 283428532cb666567c1c7ed11f3859108826e55c..ae067180a5dcf85c2a5cacca54d23e821c1683bb 100644 (file)
@@ -26,6 +26,7 @@
 #include <vtkImageActor.h>
 #include <vtkCamera.h>
 #include <vtkImageClip.h>
+#include <vtkRenderWindow.h>
 
 //------------------------------------------------------------------------------
 // Create the tool and automagically (I like this word) insert it in
@@ -200,10 +201,22 @@ void vvToolBinarize::InputIsSelected(vvSlicerManager * m) {
   connect(mCurrentSlicerManager,SIGNAL(UpdateSlice(int,int)),this,SLOT(UpdateSlice(int, int)));
   connect(mCurrentSlicerManager,SIGNAL(UpdateTSlice(int,int)),this,SLOT(UpdateSlice(int, int)));
 
+  //  connect(mCurrentSlicerManager, SIGNAL(LeftButtonReleaseSignal(int)), SLOT(LeftButtonReleaseEvent(int)));
 }
 //------------------------------------------------------------------------------
 
 
+//------------------------------------------------------------------------------
+// void vvToolBinarize::LeftButtonReleaseEvent(int slicer) {
+//   DD("LeftButtonReleaseEvent");
+//   for(int i=0; i<mCurrentSlicerManager->NumberOfSlicers(); i++) {
+//     if (i == slicer);
+//     mCurrentSlicerManager->GetSlicer(i)->GetRenderWindow()->Render();
+//   }
+// }
+//------------------------------------------------------------------------------
+
+
 //------------------------------------------------------------------------------
 void vvToolBinarize::UpdateSlice(int slicer,int slices) {
   if (!mInteractiveDisplayIsEnabled) return;
index 2332bd4b07b291966fd18a58d0a67ce6b82379c4..fc042d95322173ea9663742d53ddd2dee7c424aa 100644 (file)
@@ -52,6 +52,7 @@ class vvToolBinarize:
   void enableLowerThan(bool b);
   void useFGBGtoggled(bool);
   void InteractiveDisplayToggled(bool b);
+  //  void LeftButtonReleaseEvent(int slicer);
 
  protected:
   void RemoveVTKObjects();
index 74c1e4c43c53207ca6a281c0f594f3fa0a97203b..61923509033f721649288c1261b30f56cdacbf83 100644 (file)
@@ -15,6 +15,7 @@
   - BSD        See included LICENSE.txt file
   - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
 ======================================================================-====*/
+
 #include "vvToolCropImage.h"
 #include <QComboBox>
 #include <QCursor>
@@ -245,6 +246,9 @@ void vvToolCropImage::InputIsSelected(vvSlicerManager * slicer) {
   // connect(tminSlider, SIGNAL(valueChanged(int)), this, SLOT(sliderTMinValueChanged(int)));
   // connect(tmaxSlider, SIGNAL(valueChanged(int)), this, SLOT(sliderTMaxValueChanged(int)));
   
+  //  connect(mCurrentSlicerManager,SIGNAL(UpdateSlice(int,int)),this,SLOT(UpdateExtent()));
+  //connect(mCurrentSlicerManager,SIGNAL(UpdateTSlice(int,int)),this,SLOT(UpdateExtent()));
+
   //  connect(mIntensitySlider, SIGNAL(valueChanged(double)), this, SLOT(autoCropValueChanged(double)));
   UpdateExtent();
 }
index 3ac1701452ff8c5a703bbe569e4e482e994f5d63..531a03b879098dcd7566f68008ed2ea135b98c89 100644 (file)
@@ -14,7 +14,7 @@
 
   - BSD        See included LICENSE.txt file
   - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
-======================================================================-====*/
+  ======================================================================-====*/
 
 #include "vvToolResample.h"
 #include "vvSlicer.h"
 
 ADD_TOOL(vvToolResample);
 
-//====================================================================
+//------------------------------------------------------------------------------
 vvToolResample::vvToolResample(vvMainWindowBase * parent, Qt::WindowFlags f):
-    vvToolWidgetBase(parent,f),
-    vvToolBase<vvToolResample>(parent),
-    Ui::vvToolResample()
-{
-    Ui_vvToolResample::setupUi(mToolWidget);
-
-    mFilter = clitk::ImageResampleGenericFilter::New();
-    mLastError ="";
-
-    mInputFileFormat = "";
-    ComponentType = "";
-    mPixelType = "";
-    mCurrentSlicerManager=NULL;
-
-    mInputSize.resize(0);
-    mInputSpacing.resize(0);
-    mInputOrigin.resize(0);
-    mOutputSize.resize(0);
-    mOutputSpacing.resize(0);
-
-    xSizeLineEdit->setText("");
-    ySizeLineEdit->setText("");
-    zSizeLineEdit->setText("");
-    xSpacingLineEdit->setText("");
-    ySpacingLineEdit->setText("");
-    zSpacingLineEdit->setText("");
-    scaleSizeLineEdit->setText("");
-    scaleSpacingLineEdit->setText("");
-
-    sizeRadioButton->setChecked(0);
-    scaleSizeRadioButton->setChecked(0);
-    isoSizeRadioButton->setChecked(0);
-    spacingRadioButton->setChecked(0);
-    scaleSpacingRadioButton->setChecked(0);
-    isoSpacingRadioButton->setChecked(0);
-
-    gaussianFilterCheckBox->setCheckState(Qt::Unchecked);
-
-    xGaussianLineEdit->hide();
-    yGaussianLineEdit->hide();
-    zGaussianLineEdit->hide();
-    gaussianFilterLabel->hide();
-
-    bSplineLabel->hide();
-    bSplineOrderSpinBox->hide();
-    bLUTFactorLabel->hide();
-    bLUTSpinBox->hide();
-    mDimension = -1;
-
-    QPalette qPalette;
-    qPalette.setColor(QPalette::Foreground, QColor(Qt::blue));
-    mInputFormatLabel->setPalette(qPalette);
-    mInputDimLabel->setPalette(qPalette);
-    mInputPixelTypeLabel->setPalette(qPalette);
-    mInputSizeLabel->setPalette(qPalette);
-    mInputSpacingLabel->setPalette(qPalette);
-
-    // Set how many inputs are needed for this tool
-    AddInputSelector("Select an image to resample", mFilter);
-
-    // Connect signals & slots
-
-    connect(sizeRadioButton, SIGNAL(clicked()), this, SLOT(UpdateControlSizeAndSpacing()));
-    connect(scaleSizeRadioButton, SIGNAL(clicked()), this, SLOT(UpdateControlSizeAndSpacing()));
-    connect(isoSizeRadioButton, SIGNAL(clicked()), this, SLOT(UpdateControlSizeAndSpacing()));
-    connect(spacingRadioButton, SIGNAL(clicked()), this, SLOT(UpdateControlSizeAndSpacing()));
-    connect(scaleSpacingRadioButton, SIGNAL(clicked()), this, SLOT(UpdateControlSizeAndSpacing()));
-    connect(isoSpacingRadioButton, SIGNAL(clicked()), this, SLOT(UpdateControlSizeAndSpacing()));
-
-    connect(xSizeLineEdit, SIGNAL(textEdited(QString)),this,SLOT(ComputeNewSpacingFromSize()));
-    connect(ySizeLineEdit, SIGNAL(textEdited(QString)),this,SLOT(ComputeNewSpacingFromSize()));
-    connect(zSizeLineEdit, SIGNAL(textEdited(QString)),this,SLOT(ComputeNewSpacingFromSize()));
-    connect(xSpacingLineEdit, SIGNAL(textEdited(QString)),this,SLOT(ComputeNewSizeFromSpacing()));
-    connect(ySpacingLineEdit, SIGNAL(textEdited(QString)),this,SLOT(ComputeNewSizeFromSpacing()));
-    connect(zSpacingLineEdit, SIGNAL(textEdited(QString)),this,SLOT(ComputeNewSizeFromSpacing()));
-    connect(scaleSizeLineEdit,SIGNAL(textEdited(QString)),this,SLOT(ComputeNewSizeFromScale()));
-    connect(scaleSpacingLineEdit,SIGNAL(textEdited(QString)),this,SLOT(ComputeNewSpacingFromScale()));
-    connect(isoSizeLineEdit,SIGNAL(textEdited(QString)),this,SLOT(ComputeNewSizeFromIso()));
-    connect(isoSpacingLineEdit,SIGNAL(textEdited(QString)),this,SLOT(ComputeNewSpacingFromIso()));
-
-    connect(gaussianFilterCheckBox,SIGNAL(stateChanged(int)),this,SLOT(UpdateGaussianFilter()));
-    connect(interpolationComboBox,SIGNAL(currentIndexChanged(QString)),this,SLOT(UpdateInterpolation()));
+  vvToolWidgetBase(parent,f),
+  vvToolBase<vvToolResample>(parent),
+  Ui::vvToolResample() {
+  Ui_vvToolResample::setupUi(mToolWidget);
+
+  mFilter = clitk::ImageResampleGenericFilter::New();
+  mLastError ="";
+
+  mInputFileFormat = "";
+  ComponentType = "";
+  mPixelType = "";
+  mCurrentSlicerManager=NULL;
+
+  mInputSize.resize(0);
+  mInputSpacing.resize(0);
+  mInputOrigin.resize(0);
+  mOutputSize.resize(0);
+  mOutputSpacing.resize(0);
+
+  xSizeLineEdit->setText("");
+  ySizeLineEdit->setText("");
+  zSizeLineEdit->setText("");
+  xSpacingLineEdit->setText("");
+  ySpacingLineEdit->setText("");
+  zSpacingLineEdit->setText("");
+  scaleSizeLineEdit->setText("");
+  scaleSpacingLineEdit->setText("");
+
+  sizeRadioButton->setChecked(0);
+  scaleSizeRadioButton->setChecked(0);
+  isoSizeRadioButton->setChecked(0);
+  spacingRadioButton->setChecked(0);
+  scaleSpacingRadioButton->setChecked(0);
+  isoSpacingRadioButton->setChecked(0);
+
+  gaussianFilterCheckBox->setCheckState(Qt::Unchecked);
+
+  xGaussianLineEdit->hide();
+  yGaussianLineEdit->hide();
+  zGaussianLineEdit->hide();
+  gaussianFilterLabel->hide();
+
+  bSplineLabel->hide();
+  bSplineOrderSpinBox->hide();
+  bLUTFactorLabel->hide();
+  bLUTSpinBox->hide();
+  mDimension = -1;
+
+  QPalette qPalette;
+  qPalette.setColor(QPalette::Foreground, QColor(Qt::blue));
+  mInputFormatLabel->setPalette(qPalette);
+  mInputDimLabel->setPalette(qPalette);
+  mInputPixelTypeLabel->setPalette(qPalette);
+  mInputSizeLabel->setPalette(qPalette);
+  mInputSpacingLabel->setPalette(qPalette);
+
+  // Set how many inputs are needed for this tool
+  AddInputSelector("Select an image to resample", mFilter);
+
+  // Connect signals & slots
+
+  connect(sizeRadioButton, SIGNAL(clicked()), this, SLOT(UpdateControlSizeAndSpacing()));
+  connect(scaleSizeRadioButton, SIGNAL(clicked()), this, SLOT(UpdateControlSizeAndSpacing()));
+  connect(isoSizeRadioButton, SIGNAL(clicked()), this, SLOT(UpdateControlSizeAndSpacing()));
+  connect(spacingRadioButton, SIGNAL(clicked()), this, SLOT(UpdateControlSizeAndSpacing()));
+  connect(scaleSpacingRadioButton, SIGNAL(clicked()), this, SLOT(UpdateControlSizeAndSpacing()));
+  connect(isoSpacingRadioButton, SIGNAL(clicked()), this, SLOT(UpdateControlSizeAndSpacing()));
+
+  connect(xSizeLineEdit, SIGNAL(textEdited(QString)),this,SLOT(ComputeNewSpacingFromSize()));
+  connect(ySizeLineEdit, SIGNAL(textEdited(QString)),this,SLOT(ComputeNewSpacingFromSize()));
+  connect(zSizeLineEdit, SIGNAL(textEdited(QString)),this,SLOT(ComputeNewSpacingFromSize()));
+  connect(xSpacingLineEdit, SIGNAL(textEdited(QString)),this,SLOT(ComputeNewSizeFromSpacing()));
+  connect(ySpacingLineEdit, SIGNAL(textEdited(QString)),this,SLOT(ComputeNewSizeFromSpacing()));
+  connect(zSpacingLineEdit, SIGNAL(textEdited(QString)),this,SLOT(ComputeNewSizeFromSpacing()));
+  connect(scaleSizeLineEdit,SIGNAL(textEdited(QString)),this,SLOT(ComputeNewSizeFromScale()));
+  connect(scaleSpacingLineEdit,SIGNAL(textEdited(QString)),this,SLOT(ComputeNewSpacingFromScale()));
+  connect(isoSizeLineEdit,SIGNAL(textEdited(QString)),this,SLOT(ComputeNewSizeFromIso()));
+  connect(isoSpacingLineEdit,SIGNAL(textEdited(QString)),this,SLOT(ComputeNewSpacingFromIso()));
+
+  connect(gaussianFilterCheckBox,SIGNAL(stateChanged(int)),this,SLOT(UpdateGaussianFilter()));
+  connect(interpolationComboBox,SIGNAL(currentIndexChanged(QString)),this,SLOT(UpdateInterpolation()));
 }
-//====================================================================
+//------------------------------------------------------------------------------
+
 
-//====================================================================
+//------------------------------------------------------------------------------
 void vvToolResample::Initialize() {
   SetToolName("Resample Image");
   SetToolMenuName("Resample");
   SetToolIconFilename(":/common/icons/resample.png");
   SetToolTip("Resample image with various interpolation methods.");
 }
-//====================================================================
+//------------------------------------------------------------------------------
 
-//====================================================================
-void vvToolResample::InputIsSelected(vvSlicerManager* m) {
 
-    mCurrentSlicerManager = m;
-    mCurrentImage = mCurrentSlicerManager->GetSlicer(0)->GetImage();
-    if (mCurrentImage.IsNull()) return;
-    mInputFileName = mCurrentSlicerManager->GetFileName().c_str();
-
-    // Set current information
-    mPixelType = mCurrentImage->GetScalarTypeAsString().c_str();
-    //ds      ComponentType = mCurrentImageGetNumberOfScalarComponents();
-    mDimension = mCurrentImage->GetNumberOfDimensions();
-
-    // Copy size, spacing ...
-    mInputOrigin.resize(mDimension);
-    mInputSpacing.resize(mDimension);
-    mInputSize.resize(mDimension);
-    for (int i = 0; i < mDimension;i++) {
-        mInputOrigin[i] = mCurrentImage->GetOrigin()[i];
-        mInputSpacing[i] = mCurrentImage->GetSpacing()[i];
-        mInputSize[i] = mCurrentImage->GetSize()[i];
-    }
+//------------------------------------------------------------------------------
+void vvToolResample::InputIsSelected(vvSlicerManager* m) {
 
-    // Get file format
-    mInputFileFormat = itksys::SystemTools::GetFilenameLastExtension(mInputFileName.toStdString()).c_str();
-
-    // Display infos
-    mInputFormatLabel->setText(mInputFileFormat);
-    mInputSizeLabel->setText(GetVectorIntAsString(mInputSize));
-    mInputDimLabel->setText(QString::number(mDimension)+"D");
-    mInputSpacingLabel->setText(GetVectorDoubleAsString(mInputSpacing));
-    mInputPixelTypeLabel->setText(mPixelType);
-    mInputMemoryLabel->setText(GetSizeInBytes(mInputSize));
-
-    // Set current size
-    scaleSizeRadioButton->setChecked(true);
-    UpdateControlSizeAndSpacing();
-    scaleSizeLineEdit->setText("100");
-    ComputeNewSizeFromScale();
-
-    // Update output
-    UpdateOutputInfo();
+  mCurrentSlicerManager = m;
+  mCurrentImage = mCurrentSlicerManager->GetSlicer(0)->GetImage();
+  if (mCurrentImage.IsNull()) return;
+  mInputFileName = mCurrentSlicerManager->GetFileName().c_str();
+
+  // Set current information
+  mPixelType = mCurrentImage->GetScalarTypeAsString().c_str();
+  //ds      ComponentType = mCurrentImageGetNumberOfScalarComponents();
+  mDimension = mCurrentImage->GetNumberOfDimensions();
+
+  // Copy size, spacing ...
+  mInputOrigin.resize(mDimension);
+  mInputSpacing.resize(mDimension);
+  mInputSize.resize(mDimension);
+  for (int i = 0; i < mDimension;i++) {
+    mInputOrigin[i] = mCurrentImage->GetOrigin()[i];
+    mInputSpacing[i] = mCurrentImage->GetSpacing()[i];
+    mInputSize[i] = mCurrentImage->GetSize()[i];
+  }
+
+  // Get file format
+  mInputFileFormat = itksys::SystemTools::GetFilenameLastExtension(mInputFileName.toStdString()).c_str();
+
+  // Display infos
+  mInputFormatLabel->setText(mInputFileFormat);
+  mInputSizeLabel->setText(GetVectorIntAsString(mInputSize));
+  mInputDimLabel->setText(QString::number(mDimension)+"D");
+  mInputSpacingLabel->setText(GetVectorDoubleAsString(mInputSpacing));
+  mInputPixelTypeLabel->setText(mPixelType);
+  mInputMemoryLabel->setText(GetSizeInBytes(mInputSize));
+
+  // Set current size
+  scaleSizeRadioButton->setChecked(true);
+  UpdateControlSizeAndSpacing();
+  scaleSizeLineEdit->setText("100");
+  ComputeNewSizeFromScale();
+
+  // Update output
+  UpdateOutputInfo();
 }
-//====================================================================
+//------------------------------------------------------------------------------
+
 
-//====================================================================
+//------------------------------------------------------------------------------
 void vvToolResample::UpdateOutputInfo() {
-    mOutputSizeLabel->setText(GetVectorIntAsString(mOutputSize));
-    mOutputSpacingLabel->setText(GetVectorDoubleAsString(mOutputSpacing));
-    mOutputMemoryLabel->setText(GetSizeInBytes(mOutputSize));
+  mOutputSizeLabel->setText(GetVectorIntAsString(mOutputSize));
+  mOutputSpacingLabel->setText(GetVectorDoubleAsString(mOutputSpacing));
+  mOutputMemoryLabel->setText(GetSizeInBytes(mOutputSize));
 }
-//====================================================================
+//------------------------------------------------------------------------------
 
-//====================================================================
+
+//------------------------------------------------------------------------------
 QString vvToolResample::GetSizeInBytes(std::vector<int> & size) {
-    int t = 1;
-    for (unsigned int i=0; i<size.size(); i++) t *= size[i];
-    t *= mCurrentImage->GetScalarSize()*mCurrentImage->GetNumberOfScalarComponents();
-    QString result = QString::number(t);
-    result += " bytes (";
-    if (t > 1000000000) {
-        t /= 1000000000;
-        result += QString::number(t);
-        result += " GB)";
-    }
-    else if (t > 1000000) {
-        t /= 1000000;
-        result += QString::number(t);
-        result += " MB)";
-    }
-    else if (t > 1000) {
-        t /= 1000;
-        result += QString::number(t);
-        result += " KB)";
-    }
-    else result += ")";
-    return result;
+  int t = 1;
+  for (unsigned int i=0; i<size.size(); i++) t *= size[i];
+  t *= mCurrentImage->GetScalarSize()*mCurrentImage->GetNumberOfScalarComponents();
+  QString result = QString::number(t);
+  result += " bytes (";
+  if (t > 1000000000) {
+    t /= 1000000000;
+    result += QString::number(t);
+    result += " GB)";
+  }
+  else if (t > 1000000) {
+    t /= 1000000;
+    result += QString::number(t);
+    result += " MB)";
+  }
+  else if (t > 1000) {
+    t /= 1000;
+    result += QString::number(t);
+    result += " KB)";
+  }
+  else result += ")";
+  return result;
 }
-//====================================================================
+//------------------------------------------------------------------------------
 
-//====================================================================
+
+//------------------------------------------------------------------------------
 QString vvToolResample::GetVectorDoubleAsString(std::vector<double> vectorDouble) {
-    QString result;
-    for (unsigned int i= 0; i<vectorDouble.size(); i++) {
-        if (i != 0)
-            result += " x ";
-        result += QString::number(vectorDouble[i]);
-    }
-    return result;
+  QString result;
+  for (unsigned int i= 0; i<vectorDouble.size(); i++) {
+    if (i != 0)
+      result += " x ";
+    result += QString::number(vectorDouble[i]);
+  }
+  return result;
 }
-//====================================================================
+//------------------------------------------------------------------------------
 
-//====================================================================
+
+//------------------------------------------------------------------------------
 QString vvToolResample::GetVectorIntAsString(std::vector<int> vectorInt) {
-    QString result;
-    for (unsigned int i= 0; i<vectorInt.size(); i++) {
-        if (i != 0)
-            result += " x ";
-        result += QString::number(vectorInt[i]);
-    }
-    return result;
+  QString result;
+  for (unsigned int i= 0; i<vectorInt.size(); i++) {
+    if (i != 0)
+      result += " x ";
+    result += QString::number(vectorInt[i]);
+  }
+  return result;
 }
-//====================================================================
+//------------------------------------------------------------------------------
 
-//====================================================================
+
+//------------------------------------------------------------------------------
 void vvToolResample::FillSizeEdit(std::vector<int> size) {
-    xSizeLineEdit->setText(QString::number(size[0]));
-    ySizeLineEdit->setText(QString::number(size[1]));
-    if (size.size() > 2)
-        zSizeLineEdit->setText(QString::number(size[2]));
+  xSizeLineEdit->setText(QString::number(size[0]));
+  ySizeLineEdit->setText(QString::number(size[1]));
+  if (size.size() > 2)
+    zSizeLineEdit->setText(QString::number(size[2]));
 }
-//====================================================================
+//------------------------------------------------------------------------------
+
 
-//====================================================================
+//------------------------------------------------------------------------------
 void vvToolResample::FillSpacingEdit(std::vector<double> spacing) {
-    xSpacingLineEdit->setText(QString::number(spacing[0]));
-    ySpacingLineEdit->setText(QString::number(spacing[1]));
-    if (spacing.size() > 2)
-        zSpacingLineEdit->setText(QString::number(spacing[2]));
+  xSpacingLineEdit->setText(QString::number(spacing[0]));
+  ySpacingLineEdit->setText(QString::number(spacing[1]));
+  if (spacing.size() > 2)
+    zSpacingLineEdit->setText(QString::number(spacing[2]));
 }
-//====================================================================
+//------------------------------------------------------------------------------
 
-//====================================================================
-void vvToolResample::UpdateOutputSizeAndSpacing() {
-    mOutputSize.resize(mDimension);
-    mOutputSize = mInputSize;
-    mOutputSpacing.resize(mDimension);
-    mOutputSpacing = mInputSpacing;
-    mOutputSize[0] = (int)xSizeLineEdit->text().toDouble();
-    mOutputSize[1] = (int)ySizeLineEdit->text().toDouble();
-    if (mDimension > 2)
-        mOutputSize[2] = (int)zSizeLineEdit->text().toDouble();
-
-    mOutputSpacing[0] = xSpacingLineEdit->text().toDouble();
-    mOutputSpacing[1] = ySpacingLineEdit->text().toDouble();
-    if (mDimension > 2)
-        mOutputSpacing[2] = zSpacingLineEdit->text().toDouble();
 
-    UpdateOutputInfo();
+//------------------------------------------------------------------------------
+void vvToolResample::UpdateOutputSizeAndSpacing() {
+  mOutputSize.resize(mDimension);
+  mOutputSize = mInputSize;
+  mOutputSpacing.resize(mDimension);
+  mOutputSpacing = mInputSpacing;
+  mOutputSize[0] = (int)xSizeLineEdit->text().toDouble();
+  mOutputSize[1] = (int)ySizeLineEdit->text().toDouble();
+  if (mDimension > 2)
+    mOutputSize[2] = (int)zSizeLineEdit->text().toDouble();
+
+  mOutputSpacing[0] = xSpacingLineEdit->text().toDouble();
+  mOutputSpacing[1] = ySpacingLineEdit->text().toDouble();
+  if (mDimension > 2)
+    mOutputSpacing[2] = zSpacingLineEdit->text().toDouble();
+
+  UpdateOutputInfo();
 }
-//====================================================================
+//------------------------------------------------------------------------------
+
 
-//====================================================================
+//------------------------------------------------------------------------------
 void vvToolResample::UpdateControlSizeAndSpacing() {
-    scaleSizeLineEdit->setText("");
-    scaleSpacingLineEdit->setText("");
-    isoSizeLineEdit->setText("");
-    isoSpacingLineEdit->setText("");
-
-    xSizeLineEdit->setReadOnly(1);
-    ySizeLineEdit->setReadOnly(1);
-    zSizeLineEdit->setReadOnly(1);
-    scaleSizeLineEdit->setReadOnly(1);
-    isoSizeLineEdit->setReadOnly(1);
-
-    xSpacingLineEdit->setReadOnly(1);
-    ySpacingLineEdit->setReadOnly(1);
-    zSpacingLineEdit->setReadOnly(1);
-    scaleSpacingLineEdit->setReadOnly(1);
-    isoSpacingLineEdit->setReadOnly(1);
-
-    if (sizeRadioButton->isChecked()) {
-        xSizeLineEdit->setReadOnly(0);
-        ySizeLineEdit->setReadOnly(0);
-        if (mDimension > 2)
-            zSizeLineEdit->setReadOnly(0);
-    }
-    else {
-        if (spacingRadioButton->isChecked()) {
-            xSpacingLineEdit->setReadOnly(0);
-            ySpacingLineEdit->setReadOnly(0);
-            if (mDimension > 2)
-                zSpacingLineEdit->setReadOnly(0);
-        }
-        else if (scaleSizeRadioButton->isChecked())
-            scaleSizeLineEdit->setReadOnly(0);
-        else if (scaleSpacingRadioButton->isChecked())
-            scaleSpacingLineEdit->setReadOnly(0);
-        else if (isoSizeRadioButton->isChecked())
-            isoSizeLineEdit->setReadOnly(0);
-        else if (isoSpacingRadioButton->isChecked())
-            isoSpacingLineEdit->setReadOnly(0);
+  scaleSizeLineEdit->setText("");
+  scaleSpacingLineEdit->setText("");
+  isoSizeLineEdit->setText("");
+  isoSpacingLineEdit->setText("");
+
+  xSizeLineEdit->setReadOnly(1);
+  ySizeLineEdit->setReadOnly(1);
+  zSizeLineEdit->setReadOnly(1);
+  scaleSizeLineEdit->setReadOnly(1);
+  isoSizeLineEdit->setReadOnly(1);
+
+  xSpacingLineEdit->setReadOnly(1);
+  ySpacingLineEdit->setReadOnly(1);
+  zSpacingLineEdit->setReadOnly(1);
+  scaleSpacingLineEdit->setReadOnly(1);
+  isoSpacingLineEdit->setReadOnly(1);
+
+  if (sizeRadioButton->isChecked()) {
+    xSizeLineEdit->setReadOnly(0);
+    ySizeLineEdit->setReadOnly(0);
+    if (mDimension > 2)
+      zSizeLineEdit->setReadOnly(0);
+  }
+  else {
+    if (spacingRadioButton->isChecked()) {
+      xSpacingLineEdit->setReadOnly(0);
+      ySpacingLineEdit->setReadOnly(0);
+      if (mDimension > 2)
+        zSpacingLineEdit->setReadOnly(0);
     }
+    else if (scaleSizeRadioButton->isChecked())
+      scaleSizeLineEdit->setReadOnly(0);
+    else if (scaleSpacingRadioButton->isChecked())
+      scaleSpacingLineEdit->setReadOnly(0);
+    else if (isoSizeRadioButton->isChecked())
+      isoSizeLineEdit->setReadOnly(0);
+    else if (isoSpacingRadioButton->isChecked())
+      isoSpacingLineEdit->setReadOnly(0);
+  }
 }
-//====================================================================
+//------------------------------------------------------------------------------
 
-//====================================================================
+
+//------------------------------------------------------------------------------
 void vvToolResample::ComputeNewSpacingFromSize() {
-    double newSpacing = mInputSpacing[0]*mInputSize[0];
-    xSpacingLineEdit->setText(QString::number(newSpacing/xSizeLineEdit->text().toDouble()));
-    newSpacing = mInputSpacing[1]*mInputSize[1];
-    ySpacingLineEdit->setText(QString::number(newSpacing/ySizeLineEdit->text().toDouble()));
-    if (mDimension > 2)
+  double newSpacing = mInputSpacing[0]*mInputSize[0];
+  xSpacingLineEdit->setText(QString::number(newSpacing/xSizeLineEdit->text().toDouble()));
+  newSpacing = mInputSpacing[1]*mInputSize[1];
+  ySpacingLineEdit->setText(QString::number(newSpacing/ySizeLineEdit->text().toDouble()));
+  if (mDimension > 2)
     {
-        newSpacing = mInputSpacing[2]*mInputSize[2];
-        zSpacingLineEdit->setText(QString::number(newSpacing/zSizeLineEdit->text().toDouble()));
+      newSpacing = mInputSpacing[2]*mInputSize[2];
+      zSpacingLineEdit->setText(QString::number(newSpacing/zSizeLineEdit->text().toDouble()));
     }
-    UpdateOutputSizeAndSpacing();
+  UpdateOutputSizeAndSpacing();
 }
-//====================================================================
+//------------------------------------------------------------------------------
+
 
-//====================================================================
+//------------------------------------------------------------------------------
 void vvToolResample::ComputeNewSizeFromSpacing() {
-    double newSize = mInputSpacing[0]*mInputSize[0];
-    xSizeLineEdit->setText(QString::number(newSize/xSpacingLineEdit->text().toDouble()));
-    newSize = mInputSpacing[1]*mInputSize[1];
-    ySizeLineEdit->setText(QString::number(newSize/ySpacingLineEdit->text().toDouble()));
-    if (mDimension > 2)
+  double newSize = mInputSpacing[0]*mInputSize[0];
+  xSizeLineEdit->setText(QString::number(newSize/xSpacingLineEdit->text().toDouble()));
+  newSize = mInputSpacing[1]*mInputSize[1];
+  ySizeLineEdit->setText(QString::number(newSize/ySpacingLineEdit->text().toDouble()));
+  if (mDimension > 2)
     {
-        newSize = mInputSpacing[2]*mInputSize[2];
-        zSizeLineEdit->setText(QString::number(newSize/zSpacingLineEdit->text().toDouble()));
+      newSize = mInputSpacing[2]*mInputSize[2];
+      zSizeLineEdit->setText(QString::number(newSize/zSpacingLineEdit->text().toDouble()));
     }
-    UpdateOutputSizeAndSpacing();
+  UpdateOutputSizeAndSpacing();
 }
-//====================================================================
+//------------------------------------------------------------------------------
+
 
-//====================================================================
+//------------------------------------------------------------------------------
 void vvToolResample::ComputeNewSpacingFromScale() {
-    xSpacingLineEdit->setText(QString::number(mInputSpacing[0]*scaleSpacingLineEdit->text().toDouble()/100));
-    ySpacingLineEdit->setText(QString::number(mInputSpacing[1]*scaleSpacingLineEdit->text().toDouble()/100));
-    if (mDimension > 2)
-        zSpacingLineEdit->setText(QString::number(mInputSpacing[2]*scaleSpacingLineEdit->text().toDouble()/100));
-    ComputeNewSizeFromSpacing();
+  xSpacingLineEdit->setText(QString::number(mInputSpacing[0]*scaleSpacingLineEdit->text().toDouble()/100));
+  ySpacingLineEdit->setText(QString::number(mInputSpacing[1]*scaleSpacingLineEdit->text().toDouble()/100));
+  if (mDimension > 2)
+    zSpacingLineEdit->setText(QString::number(mInputSpacing[2]*scaleSpacingLineEdit->text().toDouble()/100));
+  ComputeNewSizeFromSpacing();
 }
-//====================================================================
+//------------------------------------------------------------------------------
+
 
-//====================================================================
+//------------------------------------------------------------------------------
 void vvToolResample::ComputeNewSizeFromScale() {
-    xSizeLineEdit->setText(QString::number(mInputSize[0]*scaleSizeLineEdit->text().toDouble()/100));
-    ySizeLineEdit->setText(QString::number(mInputSize[1]*scaleSizeLineEdit->text().toDouble()/100));
-    if (mDimension > 2)
-        zSizeLineEdit->setText(QString::number(mInputSize[2]*scaleSizeLineEdit->text().toDouble()/100));
-    ComputeNewSpacingFromSize();
+  xSizeLineEdit->setText(QString::number(mInputSize[0]*scaleSizeLineEdit->text().toDouble()/100));
+  ySizeLineEdit->setText(QString::number(mInputSize[1]*scaleSizeLineEdit->text().toDouble()/100));
+  if (mDimension > 2)
+    zSizeLineEdit->setText(QString::number(mInputSize[2]*scaleSizeLineEdit->text().toDouble()/100));
+  ComputeNewSpacingFromSize();
 }
-//====================================================================
+//------------------------------------------------------------------------------
+
 
-//====================================================================
+//------------------------------------------------------------------------------
 void vvToolResample::ComputeNewSpacingFromIso() {
-    xSpacingLineEdit->setText(QString::number(isoSpacingLineEdit->text().toDouble()));
-    ySpacingLineEdit->setText(QString::number(isoSpacingLineEdit->text().toDouble()));
-    if (mDimension > 2)
-        zSpacingLineEdit->setText(QString::number(isoSpacingLineEdit->text().toDouble()));
-    ComputeNewSizeFromSpacing();
+  xSpacingLineEdit->setText(QString::number(isoSpacingLineEdit->text().toDouble()));
+  ySpacingLineEdit->setText(QString::number(isoSpacingLineEdit->text().toDouble()));
+  if (mDimension > 2)
+    zSpacingLineEdit->setText(QString::number(isoSpacingLineEdit->text().toDouble()));
+  ComputeNewSizeFromSpacing();
 }
-//====================================================================
+//------------------------------------------------------------------------------
+
 
-//====================================================================
+//------------------------------------------------------------------------------
 void vvToolResample::ComputeNewSizeFromIso() {
-    xSizeLineEdit->setText(QString::number(isoSizeLineEdit->text().toDouble()));
-    ySizeLineEdit->setText(QString::number(isoSizeLineEdit->text().toDouble()));
-    if (mDimension > 2)
-        zSizeLineEdit->setText(QString::number(isoSizeLineEdit->text().toDouble()));
-    ComputeNewSpacingFromSize();
+  xSizeLineEdit->setText(QString::number(isoSizeLineEdit->text().toDouble()));
+  ySizeLineEdit->setText(QString::number(isoSizeLineEdit->text().toDouble()));
+  if (mDimension > 2)
+    zSizeLineEdit->setText(QString::number(isoSizeLineEdit->text().toDouble()));
+  ComputeNewSpacingFromSize();
 }
-//====================================================================
+//------------------------------------------------------------------------------
+
 
-//====================================================================
+//------------------------------------------------------------------------------
 void vvToolResample::UpdateInterpolation() {
-    if (interpolationComboBox->currentText() == "BSpline") {
-        bSplineLabel->show();
-        bSplineOrderSpinBox->show();
-        bLUTFactorLabel->hide();
-        bLUTSpinBox->hide();
-    }
-    else if (interpolationComboBox->currentText() == "Blut (faster BSpline)")   {
-        bSplineLabel->show();
-        bSplineOrderSpinBox->show();
-        bLUTFactorLabel->show();
-        bLUTSpinBox->show();
-    }
-    else {
-        bSplineLabel->hide();
-        bSplineOrderSpinBox->hide();
-        bLUTFactorLabel->hide();
-        bLUTSpinBox->hide();
-    }
+  if (interpolationComboBox->currentText() == "BSpline") {
+    bSplineLabel->show();
+    bSplineOrderSpinBox->show();
+    bLUTFactorLabel->hide();
+    bLUTSpinBox->hide();
+  }
+  else if (interpolationComboBox->currentText() == "B-LUT (faster BSpline)")   {
+    bSplineLabel->show();
+    bSplineOrderSpinBox->show();
+    bLUTFactorLabel->show();
+    bLUTSpinBox->show();
+  }
+  else {
+    bSplineLabel->hide();
+    bSplineOrderSpinBox->hide();
+    bLUTFactorLabel->hide();
+    bLUTSpinBox->hide();
+  }
 }
-//====================================================================
+//------------------------------------------------------------------------------
+
 
-//====================================================================
+//------------------------------------------------------------------------------
 void vvToolResample::UpdateGaussianFilter() {
-    if (gaussianFilterCheckBox->isChecked()) {
-        gaussianFilterLabel->show();
-        xGaussianLineEdit->show();
-        yGaussianLineEdit->show();
-        if (mDimension > 2)
-            zGaussianLineEdit->show();
-    }
-    else {
-        gaussianFilterLabel->hide();
-        xGaussianLineEdit->hide();
-        yGaussianLineEdit->hide();
-        zGaussianLineEdit->hide();
-    }
+  if (gaussianFilterCheckBox->isChecked()) {
+    gaussianFilterLabel->show();
+    xGaussianLineEdit->show();
+    yGaussianLineEdit->show();
+    if (mDimension > 2)
+      zGaussianLineEdit->show();
+  }
+  else {
+    gaussianFilterLabel->hide();
+    xGaussianLineEdit->hide();
+    yGaussianLineEdit->hide();
+    zGaussianLineEdit->hide();
+  }
 }
-//====================================================================
+//------------------------------------------------------------------------------
 
 
-//====================================================================
+//------------------------------------------------------------------------------
 void vvToolResample::apply() {
 
-    // Get resampler options
-    std::vector<double> sigma;
-    sigma.push_back(xGaussianLineEdit->text().toDouble());
-    sigma.push_back(yGaussianLineEdit->text().toDouble());
-    if (mDimension > 2) sigma.push_back(zGaussianLineEdit->text().toDouble());
-    if (mDimension == 4) sigma.push_back(0.01); //FIXME Don't filter along the temporal direction
-
-    mFilter->SetOutputSize(mOutputSize);
-    mFilter->SetOutputSpacing(mOutputSpacing);
-    mFilter->SetInterpolationName(interpolationComboBox->currentText().toLower().toStdString());
-
-    if (interpolationComboBox->currentText() == "BSpline")
-        mFilter->SetBSplineOrder(bSplineOrderSpinBox->value());
-    else if (interpolationComboBox->currentText() == "Blut (faster BSpline)") {
-        mFilter->SetInterpolationName("blut");
-        mFilter->SetBSplineOrder(bSplineOrderSpinBox->value());
-        mFilter->SetBLUTSampling(bLUTSpinBox->value());
-    }
-    if (gaussianFilterCheckBox->isChecked())
-        mFilter->SetGaussianSigma(sigma);
-    //  mFilter->SetOutputFileName(OutputFileName.toStdString());
-    mFilter->SetDefaultPixelValue(defaultPixelValueLineEdit->text().toDouble());
-    mFilter->SetInputVVImage(mCurrentImage);
-
-    // Go !
-    mFilter->Update();
-    mOutput = mFilter->GetOutputVVImage();
-    AddImage(mOutput,GetOutputFileName());
-    close();
+  // Get resampler options
+  std::vector<double> sigma;
+  sigma.push_back(xGaussianLineEdit->text().toDouble());
+  sigma.push_back(yGaussianLineEdit->text().toDouble());
+  if (mDimension > 2) sigma.push_back(zGaussianLineEdit->text().toDouble());
+  if (mDimension == 4) sigma.push_back(0.01); //FIXME Don't filter along the temporal direction
+
+  mFilter->SetOutputSize(mOutputSize);
+  mFilter->SetOutputSpacing(mOutputSpacing);
+  mFilter->SetInterpolationName(interpolationComboBox->currentText().toLower().toStdString());
+
+  if (interpolationComboBox->currentText() == "BSpline")
+    mFilter->SetBSplineOrder(bSplineOrderSpinBox->value());
+  else if (interpolationComboBox->currentText() == "B-LUT (faster BSpline)") {
+    mFilter->SetInterpolationName("blut");
+    mFilter->SetBSplineOrder(bSplineOrderSpinBox->value());
+    mFilter->SetBLUTSampling(bLUTSpinBox->value());
+  }
+  if (gaussianFilterCheckBox->isChecked())
+    mFilter->SetGaussianSigma(sigma);
+  //  mFilter->SetOutputFileName(OutputFileName.toStdString());
+  mFilter->SetDefaultPixelValue(defaultPixelValueLineEdit->text().toDouble());
+  mFilter->SetInputVVImage(mCurrentImage);
+
+  // Go !
+  mFilter->Update();
+  mOutput = mFilter->GetOutputVVImage();
+  AddImage(mOutput,GetOutputFileName());
+  close();
 }
-//====================================================================
-std::string vvToolResample::GetOutputFileName()
-{
-    QFileInfo info(QString(mCurrentSlicerManager->GetFileName().c_str()));
-    return (info.path().toStdString() + "/resampled_" + info.fileName().toStdString());
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+std::string vvToolResample::GetOutputFileName() {
+  QFileInfo info(QString(mCurrentSlicerManager->GetFileName().c_str()));
+  return (info.path().toStdString() + "/resampled_" + info.fileName().toStdString());
 }
+//------------------------------------------------------------------------------
 
index 56801be43d74767b51f67ab4fc9f96c5c00baf8e..b12e940a85f1b88bcda4ddca63b2f9bdb3cecead 100644 (file)
 
   - BSD        See included LICENSE.txt file
   - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
-======================================================================-====*/
-#ifndef _vvToolResample_h
-#define _vvToolResample_h
+  ======================================================================-====*/
+
+#ifndef _VVTOOLRESAMPLE_H
+#define _VVTOOLRESAMPLE_H
+
 #include "ui_vvToolResample.h"
 #include "clitkCommon.h"
+#include "clitkImageResampleGenericFilter.h"
 #include "vvImage.h"
 #include "vvSlicerManager.h"
 #include "vvToolWidgetBase.h"
 #include "vvToolBase.h"
-#include "clitkImageResampleGenericFilter.h"
 
 #include <QtDesigner/QDesignerExportWidget>
 #include <QTreeWidget>
 
-//====================================================================
+//------------------------------------------------------------------------------
 class vvToolResample :  
-    public vvToolWidgetBase,
-    public vvToolBase<vvToolResample>, 
-    private Ui::vvToolResample 
-{
-
-    Q_OBJECT
-
-public:
-    // constructor - destructor
-    vvToolResample(vvMainWindowBase * parent=0, Qt::WindowFlags f=0);
-
-    // Get output result
-    vvImage::Pointer GetOutput() {
-        return mOutput;
-    }
-    std::string GetOutputFileName();
-    static void Initialize();
-    void apply();
+  public vvToolWidgetBase,
+  public vvToolBase<vvToolResample>, 
+  private Ui::vvToolResample {
+
+  Q_OBJECT
+    
+  public:
+  // constructor - destructor
+  vvToolResample(vvMainWindowBase * parent=0, Qt::WindowFlags f=0);
+
+  // Get output result
+  vvImage::Pointer GetOutput() {
+    return mOutput;
+  }
+  std::string GetOutputFileName();
+  static void Initialize();
+  void apply();
 
 public slots:
-//  void SetImagesList(QTreeWidget * tree);
-    void UpdateControlSizeAndSpacing();
-    void ComputeNewSizeFromSpacing();
-    void ComputeNewSizeFromScale();
-    void ComputeNewSizeFromIso();
-    void ComputeNewSpacingFromSize();
-    void ComputeNewSpacingFromScale();
-    void ComputeNewSpacingFromIso();
-    void UpdateInterpolation();
-    void UpdateGaussianFilter();
-    void InputIsSelected(vvSlicerManager* m);
+  //  void SetImagesList(QTreeWidget * tree);
+  void UpdateControlSizeAndSpacing();
+  void ComputeNewSizeFromSpacing();
+  void ComputeNewSizeFromScale();
+  void ComputeNewSizeFromIso();
+  void ComputeNewSpacingFromSize();
+  void ComputeNewSpacingFromScale();
+  void ComputeNewSpacingFromIso();
+  void UpdateInterpolation();
+  void UpdateGaussianFilter();
+  void InputIsSelected(vvSlicerManager* m);
 
 protected:
-    Ui::vvToolResample ui;
-    vvImage::Pointer mOutput;
-    clitk::ImageResampleGenericFilter::Pointer mFilter;
+  Ui::vvToolResample ui;
+  vvImage::Pointer mOutput;
+  clitk::ImageResampleGenericFilter::Pointer mFilter;
 
-    vvSlicerManager* mCurrentSlicerManager;
-    vvImage::Pointer mCurrentImage;
-    int mCurrentIndex;
+  vvSlicerManager* mCurrentSlicerManager;
+  vvImage::Pointer mCurrentImage;
+  int mCurrentIndex;
 
-    std::vector<int> mInputOrigin;
-    std::vector<int> mInputSize;
-    std::vector<double> mInputSpacing;
-    std::vector<int> mOutputSize;
-    std::vector<double> mOutputSpacing;
-    int mDimension;
+  std::vector<int> mInputOrigin;
+  std::vector<int> mInputSize;
+  std::vector<double> mInputSpacing;
+  std::vector<int> mOutputSize;
+  std::vector<double> mOutputSpacing;
+  int mDimension;
 
-    QString mLastError;
+  QString mLastError;
 
-    QString mInputFileName;
+  QString mInputFileName;
 
-    QString mInputFileFormat;
-    QString mPixelType;
-    QString ComponentType;
+  QString mInputFileFormat;
+  QString mPixelType;
+  QString ComponentType;
 
-    QStringList OutputListFormat;
+  QStringList OutputListFormat;
 
-    void UpdateInputInfo();
-    void UpdateOutputInfo();
-    void UpdateOutputFormat();
-    void FillSizeEdit(std::vector<int> size);
-    void FillSpacingEdit(std::vector<double> spacing);
-    void UpdateOutputSizeAndSpacing();
+  void UpdateInputInfo();
+  void UpdateOutputInfo();
+  void UpdateOutputFormat();
+  void FillSizeEdit(std::vector<int> size);
+  void FillSpacingEdit(std::vector<double> spacing);
+  void UpdateOutputSizeAndSpacing();
 
-    QString GetSizeInBytes(std::vector<int> & size);
-    QString GetVectorDoubleAsString(std::vector<double> vectorDouble);
-    QString GetVectorIntAsString(std::vector<int> vectorInt);
+  QString GetSizeInBytes(std::vector<int> & size);
+  QString GetVectorDoubleAsString(std::vector<double> vectorDouble);
+  QString GetVectorIntAsString(std::vector<int> vectorInt);
 
 }; // end class vvToolResample
-//====================================================================
+//------------------------------------------------------------------------------
+
 
 #endif
 
index fc20be913ad39012cf7333f7b773bccf165f2e0c..ea24ca6c06d3b8ecc924423b85d68170a1ddbc59 100644 (file)
 #include "vvStructureSetActor.h"
 #include "vvSlicer.h"
 #include "vvROIActor.h"
+
 #include <QFileDialog>
 #include <QMessageBox>
+#include <QColorDialog>
+
 #include <vtkLookupTable.h>
 #include <vtkRenderWindow.h>
 
@@ -41,6 +44,9 @@ vvToolStructureSetManager::vvToolStructureSetManager(vvMainWindowBase * parent,
   Ui_vvToolStructureSetManager::setupUi(mToolWidget);
   mTree->clear();
   mCurrentStructureSet = NULL;
+  mCurrentStructureSetIndex = -1;
+  mGroupBoxROI->setEnabled(false);
+  mCurrentROIActor = NULL;
   
   mDefaultLUTColor = vtkLookupTable::New();
   for(unsigned int i=0; i<mDefaultLUTColor->GetNumberOfTableValues(); i++) {
@@ -96,6 +102,7 @@ void vvToolStructureSetManager::InputIsSelected(vvSlicerManager *m) {
   connect(mTree, SIGNAL(itemSelectionChanged()), this, SLOT(selectedItemChangedInTree()));
   connect(mCheckBoxShow, SIGNAL(toggled(bool)), this, SLOT(visibleROIToggled(bool)));
   connect(mOpacitySlider, SIGNAL(valueChanged(int)), this, SLOT(opacityChanged(int)));
+  connect(mChangeColorButton, SIGNAL(clicked()), this, SLOT(changeColor()));
 }
 //------------------------------------------------------------------------------
 
@@ -315,56 +322,92 @@ void vvToolStructureSetManager::apply() {
 //------------------------------------------------------------------------------
 void vvToolStructureSetManager::selectedItemChangedInTree() {
   DD("selectedItemChangedInTree");
+  
+  // Search which roi is selected
   QList<QTreeWidgetItem *> l = mTree->selectedItems();
   DD(l.size());
   QTreeWidgetItem * w = l[0];
-  if (mMapTreeWidgetToROI.find(w) == mMapTreeWidgetToROI.end()) return; // Search for SS (first)
+  if (mMapTreeWidgetToROI.find(w) == mMapTreeWidgetToROI.end()) {
+    mCurrentROIActor = NULL;
+    mCurrentROI = NULL;
+    mGroupBoxROI->setEnabled(false);
+    return; // Search for SS (first)
+  }
   clitk::DicomRT_ROI * roi = mMapTreeWidgetToROI[w];
-  DD(roi->GetName());
-  //setCurrentSelectedROI(roi);
+  //  DD(roi->GetName());
+
+  // Get selected roi actor
+  if (mCurrentROIActor != NULL) {
+    mCurrentROIActor->SetSelected(false);
+    mCurrentROIActor->Update();
+  }
 
-  mROInameLabel->setText(roi->GetName().c_str());
-  DD(roi->GetROINumber());
-  DD(mCurrentStructureSetIndex);
   vvROIActor * actor = mStructureSetActorsList[mCurrentStructureSetIndex]->GetROIActor(roi->GetROINumber());
   mCurrentROI = roi;
   mCurrentROIActor = actor;
 
-  DD(actor);
-  DD(actor->IsVisible());
+  // Update GUI
+  mGroupBoxROI->setEnabled(true);
+  mROInameLabel->setText(roi->GetName().c_str());
   mCheckBoxShow->setChecked(actor->IsVisible());
+  
+  // Warning -> avoir unuseful Render here by disconnect slider
+  // 
+  disconnect(mOpacitySlider, SIGNAL(valueChanged(int)), 
+            this, SLOT(opacityChanged(int)));
   mOpacitySlider->setValue((int)lrint(actor->GetOpacity()*100));
-  //actor->SetSelected(true); // remove old selection
+  mOpacitySpinBox->setValue((int)lrint(actor->GetOpacity()*100));
+  connect(mOpacitySlider, SIGNAL(valueChanged(int)), 
+         this, SLOT(opacityChanged(int)));
 
-  DD("ici");
+  actor->SetSelected(true); // remove old selection  
+  // The following must not render !!
+  DD("before update");
+  actor->Update(); // To change in UpdateSelecte
+  DD("after update");
+
+  mCurrentSlicerManager->Render();
 }
 //------------------------------------------------------------------------------
 
 
 //------------------------------------------------------------------------------
 void vvToolStructureSetManager::visibleROIToggled(bool b) {
-  DD(b);
   mCurrentROIActor->SetVisible(b);
-  //mCurrentROIActor->Update();
 }
 //------------------------------------------------------------------------------
 
 
 //------------------------------------------------------------------------------
 void vvToolStructureSetManager::opacityChanged(int v) {
-  //  if (!mCurrentROIActor) return;
-  DD(v);
   mCurrentROIActor->SetOpacity((double)v/100.0);
-  DD("ici");
-  mCurrentROIActor->Update();
-  // Render !
-  //  for(int i=0; i<mCurrentSlicerManager->NumberOfSlicers(); i++) {
-    mCurrentSlicerManager->Render(); 
-    //}
+  mCurrentROIActor->UpdateColor();
+  mCurrentSlicerManager->Render(); 
 }
 //------------------------------------------------------------------------------
 
 
+//------------------------------------------------------------------------------
+void vvToolStructureSetManager::changeColor() {
+  QColor color;
+  color.setRgbF(mCurrentROIActor->GetROI()->GetDisplayColor()[0], 
+               mCurrentROIActor->GetROI()->GetDisplayColor()[1], 
+               mCurrentROIActor->GetROI()->GetDisplayColor()[2]);
+  QColor c = QColorDialog::getColor(color, this, "Choose the ROI color");
+  mCurrentROIActor->GetROI()->SetDisplayColor(c.redF(), c.greenF(), c.blueF());
+  mCurrentROIActor->UpdateColor();
+
+  QTreeWidgetItem * w = mMapROIToTreeWidget[mCurrentROI];  
+  QBrush brush(QColor(mCurrentROI->GetDisplayColor()[0]*255, 
+                     mCurrentROI->GetDisplayColor()[1]*255, 
+                     mCurrentROI->GetDisplayColor()[2]*255));
+  brush.setStyle(Qt::SolidPattern);
+  for(int i=0; i<w->columnCount (); i++) {
+    w->setBackground(i, brush);
+  }
+}
+//------------------------------------------------------------------------------
+
 
 
 //------------------------------------------------------------------------------
index 842147325772d915edbf052582dcba7958fe60b7..008caa1518607059d818357adb2e3f34ff11f53a 100644 (file)
@@ -54,6 +54,7 @@ public slots:
   void selectedItemChangedInTree();
   void visibleROIToggled(bool b);
   void opacityChanged(int v);
+  void changeColor();
 
  protected:
   Ui::vvToolStructureSetManager ui;