]> Creatis software - clitk.git/commitdiff
- add mechanism to stop callback if nothing change (far from perfect)
authordsarrut <dsarrut>
Mon, 19 Apr 2010 07:20:35 +0000 (07:20 +0000)
committerdsarrut <dsarrut>
Mon, 19 Apr 2010 07:20:35 +0000 (07:20 +0000)
vv/vvImageContour.cxx
vv/vvImageContour.h
vv/vvSlicerManager.cxx
vv/vvSlicerManager.h

index fa22d45e98d60c234aa825f10e36979967dfa837..35215794be42afaf0358bd22288d9a5f4ca4ad94 100644 (file)
@@ -52,25 +52,12 @@ vvImageContour::~vvImageContour() {
 //------------------------------------------------------------------------------
 void vvImageContour::setSlicer(vvSlicer * slicer) {
   mSlicer = slicer;  
-
+  // Create an actor for each time slice
   for (unsigned int numImage = 0; numImage < mSlicer->GetImage()->GetVTKImages().size(); numImage++) {
     vtkImageClip * mClipper = vtkImageClip::New();
     vtkMarchingSquares * mSquares = vtkMarchingSquares::New();
-    //    vtkPolyDataMapper * mSquaresMapper = vtkPolyDataMapper::New();
     vtkActor * mSquaresActor = vtkActor::New();
-
-    createNewActor(&mSquaresActor, &mSquares, &mClipper);
-    /*
-    mClipper->SetInput(mSlicer->GetImage()->GetVTKImages()[numImage]);
-    mSquares->SetInput(mClipper->GetOutput());
-    mSquaresMapper->SetInput(mSquares->GetOutput());
-    mSquaresMapper->ScalarVisibilityOff();
-    mSquaresActor->SetMapper(mSquaresMapper);
-    mSquaresActor->GetProperty()->SetColor(1.0,0,0);
-    mSquaresActor->SetPickable(0);
-    mSquaresActor->VisibilityOff();
-    mSlicer->GetRenderer()->AddActor(mSquaresActor);
-    */
+    createNewActor(&mSquaresActor, &mSquares, &mClipper, numImage);
     mSquaresActorList.push_back(mSquaresActor);
     mSquaresList.push_back(mSquares);
     mClipperList.push_back(mClipper);
@@ -81,7 +68,6 @@ void vvImageContour::setSlicer(vvSlicer * slicer) {
 
 //------------------------------------------------------------------------------
 void vvImageContour::setImage(vvImage::Pointer image) {
-  DD("vvImageContour::setImage");
   for (unsigned int numImage = 0; numImage < image->GetVTKImages().size(); numImage++) {
     mClipperList[numImage]->SetInput(image->GetVTKImages()[numImage]);
   }
@@ -92,19 +78,19 @@ void vvImageContour::setImage(vvImage::Pointer image) {
 
 
 //------------------------------------------------------------------------------
-void vvImageContour::setPreserveModeEnabled(bool b) {
-  DD("setPreserveModeEnabled");
-  DD(b);
-  DD(mDisplayModeIsPreserveMemory);
+void vvImageContour::setPreserveMemoryModeEnabled(bool b) {
+  // FastCache mode work only if threshold is always the same
   if (mDisplayModeIsPreserveMemory == b) return;
   mDisplayModeIsPreserveMemory = b;
   if (!b) {
+    hideActors();
     initializeCacheMode();
   }
   else {
     for(unsigned int d=0; d<mListOfCachedContourActors.size(); d++)
       mListOfCachedContourActors[d].clear();
     mListOfCachedContourActors.clear();
+    showActors();
   }
 }
 //------------------------------------------------------------------------------
@@ -146,8 +132,17 @@ void vvImageContour::showActors() {
 //------------------------------------------------------------------------------
 void vvImageContour::update(double value) {
   if (!mSlicer) return;
+  if (mPreviousValue == value) {
+    if (mPreviousSlice == mSlicer->GetSlice()) {
+      if (mPreviousTSlice == mSlicer->GetTSlice()) {
+        return; // Nothing to do
+      }
+    }
+  }
+
   // Get current threshold value
-  mValue= value;
+  mValue = value;
+
   // Get current slice
   mSlice = mSlicer->GetSlice();
 
@@ -157,163 +152,53 @@ void vvImageContour::update(double value) {
   else {
     updateWithFastCacheMode();
   }
+  mSlicer->Render();
+  mPreviousTSlice = mSlicer->GetTSlice();
+  mPreviousSlice  = mSlicer->GetSlice();
+  mPreviousValue  = value;
 }
 //------------------------------------------------------------------------------
 
 
 //------------------------------------------------------------------------------
 void vvImageContour::updateWithPreserveMemoryMode() {
-
   // Only change actor visibility if tslice change
-  if (mTSlice != mSlicer->GetTSlice()) {
-    if (mTSlice != -1) 
-      mSquaresActorList[mTSlice]->VisibilityOff();
-    mTSlice = mSlicer->GetTSlice();
-    mSquaresActorList[mTSlice]->VisibilityOn();
-  }
-  
+  //DD(mTSlice);
+  //DD(mSlice);
+  int mPreviousTslice = mTSlice;
+  //    ;
+  //   if (mTSlice != mSlicer->GetTSlice()) {
+  //     if (mTSlice != -1) mTsliceToSetOff = mTSlice;
+  //       mSquaresActorList[mTSlice]->VisibilityOff();
+  mTSlice = mSlicer->GetTSlice();
+  //   }
+  //  else return;
+  //  DD(mTSlice);
   vtkMarchingSquares * mSquares = mSquaresList[mTSlice];
   vtkImageClip * mClipper = mClipperList[mTSlice];
   vtkActor * mSquaresActor = mSquaresActorList[mTSlice];
   int orientation = computeCurrentOrientation();
-  // DD(orientation);
-
   updateActor(mSquaresActor, mSquares, mClipper, mValue, orientation, mSlice);
-
-  return;
-  
-  // Do it
-  mSquares->SetValue(0, mValue );
-
-  int* extent = mSlicer->GetImageActor()->GetDisplayExtent();
-  // DD(extent[0]);
-  // DD(extent[1]);
-  // DD(extent[2]);
-  // DD(extent[3]);
-  // DD(extent[4]);
-  // DD(extent[5]);
-
-  // int* extent2 = mClipper->GetInput()->GetDisplayExtent();
-  // DD(extent2[0]);
-  // DD(extent2[1]);
-  int* extent2 = new int[6];
-  if (mHiddenImageIsUsed) {
-    int * extent3;
-    extent3 = mHiddenImage->GetFirstVTKImageData()->GetExtent();
-    for(int i=0; i<6; i++) extent2[i] = extent3[i];
-    // DD(extent2[0]);
-    // DD(extent2[1]);
-    // DD(extent2[2]);
-    // DD(extent2[3]);
-    // DD(extent2[4]);
-    // DD(extent2[5]);
-    for(int i=0; i<6; i+=2) {
-      if (extent[i] != extent[i+1]) { 
-        // extent[i] = extent2[i]; 
-        // extent[i+1] = extent2[i+1]; 
-      }
-      else {
-        // DD(extent[i]);
-        // DD(mSlicer->GetImage()->GetSpacing()[i/2]);
-        // DD(mHiddenImage->GetFirstVTKImageData()->GetSpacing()[i/2]);
-
-        double s = (double)extent[i]*(double)mSlicer->GetImage()->GetSpacing()[i/2]; // in mm
-        // DD(s);
-        s = s+mSlicer->GetImage()->GetOrigin()[i/2]; // from origin
-        // DD(s);
-        s = s-mHiddenImage->GetFirstVTKImageData()->GetOrigin()[i/2]; // from corner second image
-        s = s/mHiddenImage->GetFirstVTKImageData()->GetSpacing()[i/2]; // in voxel
-        // DD(s);
-
-        if (s == floor(s)) { 
-          extent2[i] = extent2[i+1] = (int)floor(s);
-        }
-        else {
-          extent2[i] = (int)floor(s);
-          extent2[i+1] = extent2[i];
-        }
-        // DD(extent2[i]);
-      }
-    }
-  }
-  else extent2 = extent;
-  // DD(extent2[0]);
-  // DD(extent2[1]);
-  // DD(extent2[2]);
-  // DD(extent2[3]);
-  // DD(extent2[4]);
-  // DD(extent2[5]);
-  
-
-  mClipper->SetOutputWholeExtent(extent2[0],extent2[1],extent2[2],
-                                extent2[3],extent2[4],extent2[5]);
-  int i;
-  for (i = 0; i < 6;i = i+2) {
-    if (extent[i] == extent[i+1]) {
-      break;
-    }
+  mSquaresActorList[mTSlice]->VisibilityOn();
+  if (mPreviousTslice != mTSlice) {
+    if (mPreviousTslice != -1) mSquaresActorList[mPreviousTslice]->VisibilityOff();
   }
-  
-  switch (i)
-    {
-    case 0:
-      if (mSlicer->GetRenderer()->GetActiveCamera()->GetPosition()[0] > mSlice)
-        {
-         mSquaresActor->SetPosition(1,0,0);
-        }
-      else
-        {
-         mSquaresActor->SetPosition(-1,0,0);
-        }
-      break;
-    case 2:
-      if (mSlicer->GetRenderer()->GetActiveCamera()->GetPosition()[1] > mSlice)
-        {
-         mSquaresActor->SetPosition(0,1,0);
-        }
-      else
-        {
-         mSquaresActor->SetPosition(0,-1,0);
-        }
-      break;
-    case 4:
-      if (mSlicer->GetRenderer()->GetActiveCamera()->GetPosition()[2] > mSlice)
-        {
-         mSquaresActor->SetPosition(0,0,1);
-        }
-      else
-        {
-         mSquaresActor->SetPosition(0,0,-1);
-        }
-      break;
-    }
-  mSquares->Update();
 }
 //------------------------------------------------------------------------------
 
 
 //------------------------------------------------------------------------------
 void vvImageContour::initializeCacheMode() {
-  DD("vvImageContour::initializeCacheMode");
-    
   mPreviousSlice = mPreviousOrientation = 0;
-  int dim;
-  if (mHiddenImageIsUsed) dim = mHiddenImage->GetNumberOfDimensions();
-  else dim = mSlicer->GetImage()->GetNumberOfDimensions();
-  DD(dim);
+  int dim = mSlicer->GetImage()->GetNumberOfDimensions();
 
   mListOfCachedContourActors.resize(dim);
   for(int d=0; d<dim; d++) {
-    DD(d);
-    int size;
-    if (mHiddenImageIsUsed) size = mHiddenImage->GetSize()[d];
-    else size = mSlicer->GetImage()->GetSize()[d];
-    DD(size);
+    int size = mSlicer->GetImage()->GetSize()[d];
+    //DD(size);
     mListOfCachedContourActors[d].resize(size);
     for(int j=0; j<size; j++) {
       mListOfCachedContourActors[d][j] = NULL;
-      DD(mListOfCachedContourActors.size());
-      DD(mListOfCachedContourActors[d].size());
     }
   }
 }
@@ -333,7 +218,6 @@ int vvImageContour::computeCurrentOrientation() {
     }
   }
   orientation = orientation/2;
-  // DD(orientation);
   return orientation;
 }
 //------------------------------------------------------------------------------
@@ -341,34 +225,29 @@ int vvImageContour::computeCurrentOrientation() {
 
 //------------------------------------------------------------------------------
 void vvImageContour::updateWithFastCacheMode() {
-  DD("vvImageContour::updateWithFastCacheMode");
-
   // Compute orientation
   int orientation = computeCurrentOrientation();
 
-  // Turn off previous actor
-  DD(mPreviousOrientation);
-  DD(mPreviousSlice);
-  if (mListOfCachedContourActors[mPreviousOrientation][mPreviousSlice] != NULL)
-    mListOfCachedContourActors[mPreviousOrientation][mPreviousSlice]->VisibilityOff();
-  mPreviousSlice = mSlice;
-  mPreviousOrientation = orientation;
+  if ((mPreviousSlice == mSlice) && (mPreviousOrientation == orientation)) return;
 
-  // Display actor if it exist
   vtkActor * actor = mListOfCachedContourActors[orientation][mSlice];
   if (actor != NULL) {
-    DD("Actor exist");
     mListOfCachedContourActors[orientation][mSlice]->VisibilityOn();
   }
   else {
     vtkImageClip * mClipper;
     vtkMarchingSquares * mSquares;
     vtkActor * mSquaresActor;
-    createNewActor(&mSquaresActor, &mSquares, &mClipper);
+    createNewActor(&mSquaresActor, &mSquares, &mClipper, 0);
     updateActor(mSquaresActor, mSquares, mClipper, mValue, orientation, mSlice);
     mListOfCachedContourActors[orientation][mSlice] = mSquaresActor;
     mSquaresActor->VisibilityOn();
   }
+
+  if (mListOfCachedContourActors[mPreviousOrientation][mPreviousSlice] != NULL)
+    mListOfCachedContourActors[mPreviousOrientation][mPreviousSlice]->VisibilityOff();
+  mPreviousSlice = mSlice;
+  mPreviousOrientation = orientation;
 }
 //------------------------------------------------------------------------------
 
@@ -376,8 +255,8 @@ void vvImageContour::updateWithFastCacheMode() {
 //------------------------------------------------------------------------------
 void vvImageContour::createNewActor(vtkActor ** actor, 
                                    vtkMarchingSquares ** squares, 
-                                   vtkImageClip ** clipper) {
-  // DD("vvImageContour::CreateNewActor");
+                                   vtkImageClip ** clipper
+                                    int numImage) {
   vtkActor * mSquaresActor = (*actor = vtkActor::New());
   vtkImageClip * mClipper = (*clipper = vtkImageClip::New());
   vtkMarchingSquares * mSquares = (*squares = vtkMarchingSquares::New());
@@ -386,7 +265,7 @@ void vvImageContour::createNewActor(vtkActor ** actor,
   if (mHiddenImageIsUsed) 
     mClipper->SetInput(mHiddenImage->GetVTKImages()[0]);
   else 
-    mClipper->SetInput(mSlicer->GetImage()->GetVTKImages()[0]);
+    mClipper->SetInput(mSlicer->GetImage()->GetVTKImages()[numImage]);
   mSquares->SetInput(mClipper->GetOutput());
   mSquaresMapper->SetInput(mSquares->GetOutput());
   mSquaresMapper->ScalarVisibilityOff();
@@ -404,36 +283,81 @@ void vvImageContour::updateActor(vtkActor * actor,
                                 vtkMarchingSquares * squares, 
                                 vtkImageClip * clipper, 
                                 int threshold, int orientation, int slice) {
-  // DD("Update Actor according to extend/threshold");
-  
-  int* extent = mSlicer->GetImageActor()->GetDisplayExtent();
-  clipper->SetOutputWholeExtent(extent[0],extent[1],extent[2],
-                                extent[3],extent[4],extent[5]);
+  // Set parameter for the MarchigSquare
   squares->SetValue(0, threshold);
 
+  // Get image extent
+  int* extent = mSlicer->GetImageActor()->GetDisplayExtent();
+
+  // Change extent if needed
+  int* extent2;
+  if (mHiddenImageIsUsed) {
+    extent2 = new int[6];
+    int * extent3;
+    extent3 = mHiddenImage->GetFirstVTKImageData()->GetExtent();
+    for(int i=0; i<6; i++) extent2[i] = extent3[i];
+    
+    double s = (double)extent[orientation*2]*(double)mSlicer->GetImage()->GetSpacing()[orientation]; // in mm
+    s = s+mSlicer->GetImage()->GetOrigin()[orientation]; // from origin
+    s = s-mHiddenImage->GetFirstVTKImageData()->GetOrigin()[orientation]; // from corner second image
+    s = s/mHiddenImage->GetFirstVTKImageData()->GetSpacing()[orientation]; // in voxel
+    
+    if (s == floor(s)) { 
+      extent2[orientation*2] = extent2[orientation*2+1] = (int)floor(s);
+    }
+    else {
+      extent2[orientation*2] = (int)floor(s);
+      extent2[orientation*2+1] = extent2[orientation*2];
+    }
+  }
+  else {
+    extent2 = extent;
+  }
+  clipper->SetOutputWholeExtent(extent2[0],extent2[1],extent2[2],
+                                extent2[3],extent2[4],extent2[5]);
+
+  if (mHiddenImage) delete extent2;
+
+  // Move the actor to be visible
+  DD(orientation);
+  DD(slice);
+
+  //TO SIMPLiFY :!!!!!!!!! == ???????
+  // actor->SetPosition(-1,-1,-1);
   switch (orientation)  {
-  case 0: if (mSlicer->GetRenderer()->GetActiveCamera()->GetPosition()[0] > slice) {
+  case 0: 
+    DD(mSlicer->GetRenderer()->GetActiveCamera()->GetPosition()[0]);
+    if (mSlicer->GetRenderer()->GetActiveCamera()->GetPosition()[0] > slice) {
       actor->SetPosition(1,0,0);
     }
     else {
       actor->SetPosition(-1,0,0);
     }
     break;
-  case 1: if (mSlicer->GetRenderer()->GetActiveCamera()->GetPosition()[1] > slice) {
+  case 1: 
+    DD(mSlicer->GetRenderer()->GetActiveCamera()->GetPosition()[1]);
+    if (mSlicer->GetRenderer()->GetActiveCamera()->GetPosition()[1] > slice) {
       actor->SetPosition(0,1,0);
     }
     else {
       actor->SetPosition(0,-1,0);
     }
     break;
-  case 2: if (mSlicer->GetRenderer()->GetActiveCamera()->GetPosition()[2] > slice) {
+  case 2: 
+    DD(mSlicer->GetRenderer()->GetActiveCamera()->GetPosition()[2]);
+    if (mSlicer->GetRenderer()->GetActiveCamera()->GetPosition()[2] > slice) {
+      DD("1");
       actor->SetPosition(0,0,1);
     }
     else {
+      DD("-1");
       actor->SetPosition(0,0,-1);
     }
     break;
   }
+
   squares->Update();
 }
 //------------------------------------------------------------------------------
index ad1143dd963399ca01319dbc382e78da529fe1e2..12bb2dcca7c065a77577377fad238bdafc97159e 100644 (file)
@@ -40,13 +40,15 @@ class vvImageContour
   void showActors();
   void setColor(double r, double g, double b);
   void setImage(vvImage::Pointer image);
-  void setPreserveModeEnabled(bool b);
+  void setPreserveMemoryModeEnabled(bool b);
 
  protected:
   vvSlicer * mSlicer;
   int mSlice;
   int mTSlice;
   double mValue;
+  int mPreviousTSlice;
+  double mPreviousValue;
   bool mHiddenImageIsUsed;
   vvImage::Pointer mHiddenImage;
   bool mDisplayModeIsPreserveMemory;
@@ -67,7 +69,7 @@ class vvImageContour
   void updateWithFastCacheMode();
   void createNewActor(vtkActor ** actor, 
                      vtkMarchingSquares ** squares, 
-                     vtkImageClip ** clipper);
+                     vtkImageClip ** clipper, int numImage);
   void updateActor(vtkActor * actor, 
                   vtkMarchingSquares * squares,
                   vtkImageClip * clipper, 
index b0156adee468c769722994599cc6d494f24212e0..9c64dedd5a6d2210d60053afcd9f1d3de27d68a0 100644 (file)
@@ -69,11 +69,12 @@ vvSlicerManager::vvSlicerManager(int numberOfSlicers)
   mLandmarks = NULL;
   mLinkedId.resize(0);
 
-  for ( int i = 0; i < numberOfSlicers; i++)
-    {
-      vvSlicer *slicer = vvSlicer::New();
-      mSlicers.push_back(slicer);
-    }
+  for ( int i = 0; i < numberOfSlicers; i++) {
+    vvSlicer *slicer = vvSlicer::New();
+    mSlicers.push_back(slicer);
+  }
+  mPreviousSlice.resize(numberOfSlicers);
+  mPreviousTSlice.resize(numberOfSlicers);
 }
 //----------------------------------------------------------------------------
 
@@ -233,7 +234,7 @@ bool vvSlicerManager::SetImages(std::vector<std::string> filenames,LoadedImageTy
     mFileName.append("_"+clitk::toString(n));
     //    DD(mFileName);
   }
- return true;
 return true;
 }
 //----------------------------------------------------------------------------
 
@@ -328,17 +329,29 @@ bool vvSlicerManager::SetVF(std::string filename)
 //----------------------------------------------------------------------------
 bool vvSlicerManager::SetVF(vvImage::Pointer vf,std::string filename)
 {
-  if (vf->GetNumberOfDimensions() > mImage->GetNumberOfDimensions())
-    {
-      mLastError = " Vector field dimension cannot be greater then reference image!";
+  if (vf->GetNumberOfDimensions() > mImage->GetNumberOfDimensions()) {
+    mLastError = "Sorry, vector field dimension cannot be greater then reference image.";
+    return false;
+  }
+  if (vf->GetNumberOfDimensions() == 4) {
+    // DD(vf->GetSpacing()[3]);
+    //     DD(mImage->GetSpacing()[3]);
+    //     DD(vf->GetOrigin()[3]);
+    //     DD(mImage->GetOrigin()[3]);    
+    if (vf->GetSpacing()[3] != mImage->GetSpacing()[3]) {
+      mLastError = "Sorry, vector field time spacing cannot be different from time spacing of the reference image.";
+      return false;
+    }
+    if (vf->GetOrigin()[3] != mImage->GetOrigin()[3]) {
+      mLastError = "Sorry, vector field time origin cannot be different from time origin of the reference image.";
       return false;
     }
+  }
   mVF=vf;
   mVFName = filename;
-  for ( unsigned int i = 0; i < mSlicers.size(); i++)
-    {
-      mSlicers[i]->SetVF(vf);
-    }
+  for ( unsigned int i = 0; i < mSlicers.size(); i++) {
+    mSlicers[i]->SetVF(vf);
+  }
   return true;
 }
 //----------------------------------------------------------------------------
@@ -431,11 +444,22 @@ void vvSlicerManager::SetInteractorStyleNavigator(int i, vtkInteractorStyle* sty
     GetInteractorStyle()->AddObserver(vtkCommand::MouseWheelForwardEvent, smc);
   mSlicers[i]->GetRenderWindow()->GetInteractor()->
     GetInteractorStyle()->AddObserver(vtkCommand::MouseWheelBackwardEvent, smc);
+  // mSlicers[i]->GetRenderWindow()->GetInteractor()->
+  //   GetInteractorStyle()->AddObserver(vtkCommand::LeftButtonReleaseEvent, smc);
+  mSlicers[i]->GetRenderWindow()->GetInteractor()->
+     GetInteractorStyle()->AddObserver(vtkCommand::EndPickEvent, smc);
   smc->Delete();
 }
 //----------------------------------------------------------------------------
 
 
+//----------------------------------------------------------------------------
+void vvSlicerManager::LeftButtonReleaseEvent(int slicer) {
+  emit LeftButtonReleaseSignal(slicer);
+}
+//----------------------------------------------------------------------------
+
+
 //----------------------------------------------------------------------------
 void vvSlicerManager::SetTSlice(int slice)
 {
@@ -447,9 +471,11 @@ void vvSlicerManager::SetTSlice(int slice)
     mLandmarks->SetTime(slice);
   for ( unsigned int i = 0; i < mSlicers.size(); i++)
     {
-      mSlicers[i]->SetTSlice(slice);
-      if (mSlicers[i]->GetImageActor()->GetVisibility())
-       UpdateTSlice(i);
+      if (slice != mSlicers[i]->GetTSlice()) {
+        mSlicers[i]->SetTSlice(slice);
+        if (mSlicers[i]->GetImageActor()->GetVisibility())
+          UpdateTSlice(i);
+      }
     }
 }
 //----------------------------------------------------------------------------
@@ -462,6 +488,9 @@ void vvSlicerManager::SetNextTSlice(int originating_slicer)
   t++;
   if (t > mSlicers[0]->GetTMax())
     t = 0;
+  // DD("SetNextTSlice");
+//   DD(originating_slicer);
+//   DD(t);
   emit UpdateTSlice(originating_slicer,t);
 }
 //----------------------------------------------------------------------------
@@ -500,6 +529,9 @@ void vvSlicerManager::SetTSliceInSlicer(int tslice, int slicer)
     tslice = mSlicers[slicer]->GetTMax();
   if (mLandmarks)
     mLandmarks->SetTime(tslice);
+
+  if (mSlicers[slicer]->GetTSlice() == tslice) return;
+
   mSlicers[slicer]->SetTSlice(tslice);
   if (mSlicers[slicer]->GetImageActor()->GetVisibility())
     UpdateTSlice(slicer);
@@ -935,9 +967,14 @@ void vvSlicerManager::UpdateWindowLevel()
 void vvSlicerManager::UpdateSlice(int slicer)
 {
   // DD("vvSlicerManager::UpdateSlice emit UpdateSlice");
-  // DD(slicer);
-  // DD(mSlicers[slicer]->GetSlice());
+//   DD(slicer);
+//   DD(mSlicers[slicer]->GetSlice());
+  if (mPreviousSlice[slicer] == mSlicers[slicer]->GetSlice()) {
+    //DD("============= NOTHING");
+    return;
+  }
   emit UpdateSlice(slicer, mSlicers[slicer]->GetSlice());
+  mPreviousSlice[slicer] = mSlicers[slicer]->GetSlice();
 }
 //----------------------------------------------------------------------------
 
@@ -945,7 +982,19 @@ void vvSlicerManager::UpdateSlice(int slicer)
 //----------------------------------------------------------------------------
 void vvSlicerManager::UpdateTSlice(int slicer)
 {
-  emit UpdateTSlice(slicer,mSlicers[0]->GetTSlice());
+  // DD("vvSlicerManager::UpdateTSlice emit UpdateTSlice");
+//   DD(slicer);
+//   DD(mSlicers[slicer]->GetTSlice());
+//   DD(mSlicers[slicer]->GetSlice());
+  if (mPreviousSlice[slicer] == mSlicers[slicer]->GetSlice()) {
+    if (mPreviousTSlice[slicer] == mSlicers[slicer]->GetTSlice()) {
+      //      DD("************** NOTHING ***********");
+      return;
+    }
+  }
+  mPreviousSlice[slicer] = mSlicers[slicer]->GetSlice();
+  mPreviousTSlice[slicer] = mSlicers[slicer]->GetTSlice();
+  emit UpdateTSlice(slicer,mSlicers[slicer]->GetTSlice());  
 }
 //----------------------------------------------------------------------------
 
@@ -1202,9 +1251,17 @@ void vvSlicerManager::PrevImage(int slicer)
 }
 //----------------------------------------------------------------------------
 
+
 //----------------------------------------------------------------------------
 void vvSlicerManager::NextImage(int slicer)
 {
   emit ChangeImageWithIndexOffset(this, slicer,  1);
 }
 //----------------------------------------------------------------------------
+
+
+//----------------------------------------------------------------------------
+void vvSlicerManager::VerticalSliderHasChanged(int slicer, int slice) {
+  emit AVerticalSliderHasChanged(slicer, slice);
+}
+//----------------------------------------------------------------------------
index 1608fbcec492dff52fae769cc3f957b6c3e5bb51..a5eccce4e0610bc86da2f1c1e5ffdbc7e90891b2 100644 (file)
@@ -1,3 +1,4 @@
+
 /*=========================================================================
   Program:   vv                     http://www.creatis.insa-lyon.fr/rio/vv
 
@@ -186,6 +187,8 @@ class vvSlicerManager : public QObject {
   
   void NextImage(int slicer);
   void PrevImage(int slicer);
+  void LeftButtonReleaseEvent(int slicer);
+  void VerticalSliderHasChanged(int slicer, int slice);
 
 signals :
   void currentImageChanged(std::string id);
@@ -201,6 +204,8 @@ signals :
   void UpdateLinkManager(std::string, int slicer, double x, double y, double z, int temps);
   void LandmarkAdded();
   void ChangeImageWithIndexOffset(vvSlicerManager *sm, int slicer, int offset);
+  void LeftButtonReleaseSignal(int slicer);
+  void AVerticalSliderHasChanged(int slicer, int slice);
 
 protected:
   std::vector<vvSlicer*> mSlicers;
@@ -235,6 +240,9 @@ protected:
   std::list<std::string> mLinkedId;
 
   vvLandmarks* mLandmarks;
+  
+  std::vector<int> mPreviousSlice;
+  std::vector<int> mPreviousTSlice;
 };
 
 #endif