]> Creatis software - clitk.git/commitdiff
Undo the current transformation before cropping and Redo after it
authortbaudier <thomas.baudier@creatis.insa-lyon.fr>
Mon, 29 Feb 2016 08:41:14 +0000 (09:41 +0100)
committertbaudier <thomas.baudier@creatis.insa-lyon.fr>
Mon, 29 Feb 2016 08:41:14 +0000 (09:41 +0100)
vv/vvToolCropImage.cxx
vv/vvToolCropImage.h

index 2de985882c6eec8dc002d26913ba26a51cb151ef..1530341ce83456fa770bebe4e3b595cb9ed72927 100644 (file)
@@ -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; i<mCurrentSlicerManager->GetNumberOfSlicers(); 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<vtkMatrix4x4>::New();
+  mConcatenedTransform->DeepCopy(slicer->GetSlicer(0)->GetConcatenatedTransform()->GetMatrix());
+  vtkSmartPointer<vtkMatrix4x4> matrix = vtkSmartPointer<vtkMatrix4x4>::New();
+  matrix->Identity();
+  mCurrentSlicerManager->GetImage()->GetTransform()[0]->SetMatrix(matrix);
+  for (int i=0; i<mCurrentSlicerManager->GetNumberOfSlicers(); 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
index 11ee8def9e7f5bfd8b26bacf6b64d0fd7ca058a8..4024435664d41fc8d136d85af22eb7934ffb70db 100644 (file)
@@ -32,6 +32,8 @@
 #include "vvToolWidgetBase.h"
 #include "vvMainWindowBase.h"
 #include "ui_vvToolCropImage.h"
+//vtk
+#include <vtkTransform.h>
 
 //------------------------------------------------------------------------------
 class vvToolCropImage:
@@ -71,6 +73,7 @@ public slots:
   virtual void closeEvent(QCloseEvent *event);
 
   std::vector<QSlider*> mSliders;
+  vtkSmartPointer<vtkMatrix4x4> mConcatenedTransform;
 }; // end class vvToolCropImage
 //------------------------------------------------------------------------------