From 0ce5d781d5a90574c2175860de10b5540b5079a6 Mon Sep 17 00:00:00 2001 From: tbaudier Date: Mon, 29 Feb 2016 09:41:14 +0100 Subject: [PATCH] Undo the current transformation before cropping and Redo after it --- vv/vvToolCropImage.cxx | 20 ++++++++++++++++++++ vv/vvToolCropImage.h | 3 +++ 2 files changed, 23 insertions(+) diff --git a/vv/vvToolCropImage.cxx b/vv/vvToolCropImage.cxx index 2de9858..1530341 100644 --- a/vv/vvToolCropImage.cxx +++ b/vv/vvToolCropImage.cxx @@ -106,6 +106,12 @@ void vvToolCropImage::closeEvent(QCloseEvent *event) mCurrentSlicerManager->GetSlicer(i)->EnableReducedExtent(false); UpdateExtent(); } + mCurrentSlicerManager->GetImage()->GetTransform()[0]->SetMatrix(mConcatenedTransform); + for (int i=0; iGetNumberOfSlicers(); i++) { + mCurrentSlicerManager->GetSlicer(i)->ResetCamera(); + mCurrentSlicerManager->GetSlicer(i)->Render(); + mCurrentSlicerManager->UpdateLinkedNavigation( mCurrentSlicerManager->GetSlicer(i) ); + } vvToolWidgetBase::closeEvent(event); } //------------------------------------------------------------------------------ @@ -162,6 +168,18 @@ void vvToolCropImage::UpdateExtent() //------------------------------------------------------------------------------ void vvToolCropImage::InputIsSelected(vvSlicerManager * slicer) { + //Save the current transformation + mConcatenedTransform = vtkSmartPointer::New(); + mConcatenedTransform->DeepCopy(slicer->GetSlicer(0)->GetConcatenatedTransform()->GetMatrix()); + vtkSmartPointer matrix = vtkSmartPointer::New(); + matrix->Identity(); + mCurrentSlicerManager->GetImage()->GetTransform()[0]->SetMatrix(matrix); + for (int i=0; iGetNumberOfSlicers(); i++) { + mCurrentSlicerManager->GetSlicer(i)->ResetCamera(); + mCurrentSlicerManager->GetSlicer(i)->Render(); + mCurrentSlicerManager->UpdateLinkedNavigation( mCurrentSlicerManager->GetSlicer(i) ); + } + // Change interface according to number of dimension mExtentSize = 2*slicer->GetDimension(); if (slicer->GetDimension()<4) { @@ -295,6 +313,8 @@ void vvToolCropImage::apply() // Retrieve result and display it vvImage::Pointer output = filter->GetOutputVVImage(); + output->GetTransform()[0]->SetMatrix(mConcatenedTransform); + AddImage(output,croppedImageName.str()); // End diff --git a/vv/vvToolCropImage.h b/vv/vvToolCropImage.h index 11ee8de..4024435 100644 --- a/vv/vvToolCropImage.h +++ b/vv/vvToolCropImage.h @@ -32,6 +32,8 @@ #include "vvToolWidgetBase.h" #include "vvMainWindowBase.h" #include "ui_vvToolCropImage.h" +//vtk +#include //------------------------------------------------------------------------------ class vvToolCropImage: @@ -71,6 +73,7 @@ public slots: virtual void closeEvent(QCloseEvent *event); std::vector mSliders; + vtkSmartPointer mConcatenedTransform; }; // end class vvToolCropImage //------------------------------------------------------------------------------ -- 2.47.1