From 5768d2b6f7414288e013fde596958aba99384945 Mon Sep 17 00:00:00 2001
From: tbaudier <thomas.baudier@creatis.insa-lyon.fr>
Date: Tue, 23 Feb 2016 13:53:50 +0100
Subject: [PATCH] The profile points follow the current transform

---
 vv/vvToolProfile.cxx | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/vv/vvToolProfile.cxx b/vv/vvToolProfile.cxx
index 4909aad..83334a2 100644
--- a/vv/vvToolProfile.cxx
+++ b/vv/vvToolProfile.cxx
@@ -160,6 +160,13 @@ void vvToolProfile::selectPoint1()
       int i(0);
       while (i<mCurrentSlicerManager->GetImage()->GetNumberOfDimensions() && i<3) {
         pos[i] = mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetCursorPosition()[i];
+        ++i;
+      }
+      double posTransformed[3];
+      mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetConcatenatedTransform()->TransformPoint(pos, posTransformed);
+      i = 0;
+      while (i<mCurrentSlicerManager->GetImage()->GetNumberOfDimensions() && i<3) {
+        pos[i] = posTransformed[i];
         mPoint1[i] = round((pos[i] - mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetInput()->GetOrigin()[i])/mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetInput()->GetSpacing()[i]);
         pos[i] = mPoint1[i]*mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetInput()->GetSpacing()[i] + mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetInput()->GetOrigin()[i]; //Ensure to be at the center of the voxel
         position += QString::number(mPoint1[i],'f',0) + " ";
@@ -211,8 +218,15 @@ void vvToolProfile::selectPoint2()
       pos[0] = pos[1] = pos[2] = pos[3] = 0;;
           
       int i(0);
-      while (i<mCurrentSlicerManager->GetImage()->GetNumberOfDimensions() &&i<3) {
+      while (i<mCurrentSlicerManager->GetImage()->GetNumberOfDimensions() && i<3) {
         pos[i] = mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetCursorPosition()[i];
+        ++i;
+      }
+      double posTransformed[3];
+      mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetConcatenatedTransform()->TransformPoint(pos, posTransformed);
+      i = 0;
+      while (i<mCurrentSlicerManager->GetImage()->GetNumberOfDimensions() && i<3) {
+        pos[i] = posTransformed[i];
         mPoint2[i] = round((pos[i] - mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetInput()->GetOrigin()[i])/mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetInput()->GetSpacing()[i]);
         pos[i] = mPoint2[i]*mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetInput()->GetSpacing()[i] + mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetInput()->GetOrigin()[i]; //Ensure to be at the center of the voxel
         position += QString::number(mPoint2[i],'f',0) + " ";
-- 
2.47.1