From cd0855ee735b788059c5059e5a3a533975d3cc89 Mon Sep 17 00:00:00 2001 From: Romulo Pinho Date: Tue, 16 Oct 2012 23:18:37 +0200 Subject: [PATCH] preserve crosshair position when changing orientation - it used to jump to the slice in the middle of the volume --- vv/vvMainWindow.cxx | 11 ++++++----- vv/vvSlicer.cxx | 23 +++++++++++++++-------- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/vv/vvMainWindow.cxx b/vv/vvMainWindow.cxx index 948c8e1..ba7e3ad 100644 --- a/vv/vvMainWindow.cxx +++ b/vv/vvMainWindow.cxx @@ -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); } } //------------------------------------------------------------------------------ diff --git a/vv/vvSlicer.cxx b/vv/vvSlicer.cxx index 17aa41b..9246322 100644 --- a/vv/vvSlicer.cxx +++ b/vv/vvSlicer.cxx @@ -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((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(sCursor); + } + +// int *range = this->GetSliceRange(); +// if (range) +// this->Slice = static_cast((range[0] + range[1]) * 0.5); + this->UpdateOrientation(); this->UpdateDisplayExtent(); -- 2.47.1