]> Creatis software - clitk.git/commitdiff
preserve crosshair position when changing orientation
authorRomulo Pinho <romulo.pinho@lyon.unicancer.fr>
Tue, 16 Oct 2012 21:18:37 +0000 (23:18 +0200)
committerRomulo Pinho <romulo.pinho@lyon.unicancer.fr>
Tue, 16 Oct 2012 21:18:37 +0000 (23:18 +0200)
- it used to jump to the slice in the middle of the volume

vv/vvMainWindow.cxx
vv/vvSlicer.cxx

index 948c8e12da32159972d82a6eecef34924cf3df39..ba7e3ad88ad81fa43d351b85055708218eea4693 100644 (file)
@@ -2705,23 +2705,24 @@ void vvMainWindow::UpdateTSlice(int slicer, int slice)
 //------------------------------------------------------------------------------
 void vvMainWindow::UpdateSliceRange(int slicer, int min, int max, int tmin, int tmax)
 {
-  int position = int((min+max)/2);
+  //int position = int((min+max)/2);
+  int position = mSlicerManagers[mCurrentPickedImageIndex]->GetSlicer(slicer)->GetSlice();
   if (slicer == 0) {
-    NOVerticalSlider->setValue(position);
     NOVerticalSlider->setRange(min,max);
     NOHorizontalSlider->setRange(tmin,tmax);
+    NOVerticalSlider->setValue(position);
   } else if (slicer == 1) {
-    NEVerticalSlider->setValue(position);
     NEVerticalSlider->setRange(min,max);
     NEHorizontalSlider->setRange(tmin,tmax);
+    NEVerticalSlider->setValue(position);
   } else if (slicer == 2) {
-    SOVerticalSlider->setValue(position);
     SOVerticalSlider->setRange(min,max);
     SOHorizontalSlider->setRange(tmin,tmax);
+    SOVerticalSlider->setValue(position);
   } else if (slicer == 3) {
-    SEVerticalSlider->setValue(position);
     SEVerticalSlider->setRange(min,max);
     SEHorizontalSlider->setRange(tmin,tmax);
+    SEVerticalSlider->setValue(position);
   }
 }
 //------------------------------------------------------------------------------
index 17aa41b81a9619b928a3268fea886d6d4c858fad..92463226aa392cb2bbd719dea9558e00eac8bc73 100644 (file)
@@ -90,10 +90,10 @@ vvSlicer::vvSlicer()
   mCurrent[1] = -VTK_DOUBLE_MAX;
   mCurrent[2] = -VTK_DOUBLE_MAX;
 
-  mCursor[0] = -VTK_DOUBLE_MAX;
-  mCursor[1] = -VTK_DOUBLE_MAX;
-  mCursor[2] = -VTK_DOUBLE_MAX;
-  mCursor[3] = -VTK_DOUBLE_MAX;
+  mCursor[0] = 0;//-VTK_DOUBLE_MAX;
+  mCursor[1] = 0;//-VTK_DOUBLE_MAX;
+  mCursor[2] = 0;//-VTK_DOUBLE_MAX;
+  mCursor[3] = 0;//-VTK_DOUBLE_MAX;
 
   mSubSampling = 5;
   mScale = 1;
@@ -813,15 +813,22 @@ void vvSlicer::SetSliceOrientation(int orientation)
     AdjustResliceToSliceOrientation(mOverlayReslice);
 
   // Update the viewer
-  int *range = this->GetSliceRange();
-  if (range)
-    this->Slice = static_cast<int>((range[0] + range[1]) * 0.5);
-
+  
   // Go to current cursor position
   // double* cursorPos = GetCursorPosition();
   // DDV(cursorPos, 3);
   // SetCurrentPosition(cursorPos[0],cursorPos[1],cursorPos[2],cursorPos[3]);
 
+  if (this->Renderer && this->GetInput()) {
+    double s = mCursor[orientation];
+    double sCursor = (s - this->GetInput()->GetOrigin()[orientation])/this->GetInput()->GetSpacing()[orientation];
+    this->Slice = static_cast<int>(sCursor);
+  }
+  
+//   int *range = this->GetSliceRange();
+//   if (range)
+//     this->Slice = static_cast<int>((range[0] + range[1]) * 0.5);
+
   this->UpdateOrientation();
   this->UpdateDisplayExtent();