]> Creatis software - clitk.git/commitdiff
solved bug 316
authorRomulo Pinho <pinho@lyon.fnclcc.fr>
Thu, 26 May 2011 13:16:48 +0000 (15:16 +0200)
committerRomulo Pinho <pinho@lyon.fnclcc.fr>
Thu, 26 May 2011 13:16:48 +0000 (15:16 +0200)
- also refactored the code a bit...

vv/vvMainWindow.cxx

index 995d3dee38a3cd2671a852619c5183acaa4b2c65..00e7e1afb387e01560cc594ee8a347acbc663fca 100644 (file)
@@ -1064,70 +1064,35 @@ void vvMainWindow::ImageInfoChanged()
     vvImage::Pointer imageSelected;
     if (DataTree->topLevelItem(index) == DataTree->selectedItems()[0]) {
       imageSelected = mSlicerManagers[index]->GetSlicer(0)->GetImage();
-      dimension = imageSelected->GetNumberOfDimensions();
-      origin.resize(dimension);
-      inputSpacing.resize(dimension);
-      inputSize.resize(dimension);
-      sizeMM.resize(dimension);
-      pixelType = mSlicerManagers[index]->GetImage()->GetScalarTypeAsITKString().c_str();
-      for (int i = 0; i < dimension; i++) {
-        origin[i] = imageSelected->GetOrigin()[i];
-        inputSpacing[i] = imageSelected->GetSpacing()[i];
-        inputSize[i] = imageSelected->GetSize()[i];
-        sizeMM[i] = inputSize[i]*inputSpacing[i];
-        NPixel *= inputSize[i];
-      }
-      inputSizeInBytes = GetSizeInBytes(imageSelected->GetActualMemorySize()*1000);
     } else if (DataTree->selectedItems()[0]->data(1,Qt::UserRole).toString() == "vector") {
       imageSelected = mSlicerManagers[index]->GetSlicer(0)->GetVF();
-      dimension = imageSelected->GetNumberOfDimensions();
-      origin.resize(dimension);
-      inputSpacing.resize(dimension);
-      inputSize.resize(dimension);
-      sizeMM.resize(dimension);
-      pixelType = mSlicerManagers[index]->GetVF()->GetScalarTypeAsITKString().c_str();
-      for (int i = 0; i < dimension; i++) {
-        origin[i] = imageSelected->GetOrigin()[i];
-        inputSpacing[i] = imageSelected->GetSpacing()[i];
-        inputSize[i] = imageSelected->GetSize()[i];
-        sizeMM[i] = inputSize[i]*inputSpacing[i];
-        NPixel *= inputSize[i];
-      }
-      inputSizeInBytes = GetSizeInBytes(imageSelected->GetActualMemorySize()*1000);
     } else if (DataTree->selectedItems()[0]->data(1,Qt::UserRole).toString() == "overlay") {
       imageSelected = mSlicerManagers[index]->GetSlicer(0)->GetOverlay();
-      dimension = imageSelected->GetNumberOfDimensions();
-      origin.resize(dimension);
-      inputSpacing.resize(dimension);
-      inputSize.resize(dimension);
-      sizeMM.resize(dimension);
-      pixelType = mSlicerManagers[index]->GetImage()->GetScalarTypeAsITKString().c_str();
-      for (int i = 0; i < dimension; i++) {
-        origin[i] = imageSelected->GetOrigin()[i];
-        inputSpacing[i] = imageSelected->GetSpacing()[i];
-        inputSize[i] = imageSelected->GetSize()[i];
-        sizeMM[i] = inputSize[i]*inputSpacing[i];
-        NPixel *= inputSize[i];
-      }
-      inputSizeInBytes = GetSizeInBytes(imageSelected->GetActualMemorySize()*1000);
     } else if (DataTree->selectedItems()[0]->data(1,Qt::UserRole).toString() == "fusion") {
       imageSelected = mSlicerManagers[index]->GetSlicer(0)->GetFusion();
-      dimension = imageSelected->GetNumberOfDimensions();
-      origin.resize(dimension);
-      inputSpacing.resize(dimension);
-      inputSize.resize(dimension);
-      sizeMM.resize(dimension);
-      pixelType = mSlicerManagers[index]->GetImage()->GetScalarTypeAsITKString().c_str();
-      for (int i = 0; i < dimension; i++) {
-        origin[i] = imageSelected->GetOrigin()[i];
-        inputSpacing[i] = imageSelected->GetSpacing()[i];
-        inputSize[i] = imageSelected->GetSize()[i];
-        sizeMM[i] = inputSize[i]*inputSpacing[i];
-        NPixel *= inputSize[i];
-      }
-      inputSizeInBytes = GetSizeInBytes(imageSelected->GetActualMemorySize()*1000);
+    }
+    else if (DataTree->selectedItems()[0]->data(1,Qt::UserRole).toString() == "contour") {
+      imageSelected = mSlicerManagers[index]->GetSlicer(0)->GetImage();
+    }
+    else {
+      imageSelected = mSlicerManagers[index]->GetSlicer(0)->GetImage();
     }
 
+    dimension = imageSelected->GetNumberOfDimensions();
+    origin.resize(dimension);
+    inputSpacing.resize(dimension);
+    inputSize.resize(dimension);
+    sizeMM.resize(dimension);
+    pixelType = mSlicerManagers[index]->GetImage()->GetScalarTypeAsITKString().c_str();
+    for (int i = 0; i < dimension; i++) {
+      origin[i] = imageSelected->GetOrigin()[i];
+      inputSpacing[i] = imageSelected->GetSpacing()[i];
+      inputSize[i] = imageSelected->GetSize()[i];
+      sizeMM[i] = inputSize[i]*inputSpacing[i];
+      NPixel *= inputSize[i];
+    }
+    inputSizeInBytes = GetSizeInBytes(imageSelected->GetActualMemorySize()*1000);
+    
     QString dim = QString::number(dimension) + " (";
     dim += pixelType + ")";
 
@@ -1138,7 +1103,9 @@ void vvMainWindow::ImageInfoChanged()
     infoPanel->setOrigin(GetVectorDoubleAsString(origin));
     infoPanel->setSpacing(GetVectorDoubleAsString(inputSpacing));
     infoPanel->setNPixel(QString::number(NPixel)+" ("+inputSizeInBytes+")");
+    std::cout << "Will get transform " << std::endl;
     transformation = imageSelected->GetTransform()->GetMatrix();
+    std::cout << "Got transform " << std::endl;
     infoPanel->setTransformation(Get4x4MatrixDoubleAsString(transformation));
 
     landmarksPanel->SetCurrentLandmarks(mSlicerManagers[index]->GetLandmarks(),