]> Creatis software - clitk.git/blobdiff - vv/vvMainWindow.cxx
Display 'NA' if memory usage is not available
[clitk.git] / vv / vvMainWindow.cxx
index 5266fc15f236f1490d2d0bc40b00cd6510e4f3c8..a2336e789062e7f36356fa150d7f83bae61dde54 100644 (file)
 #include "vtkPNMWriter.h"
 #include "vtkPNGWriter.h"
 #include "vtkJPEGWriter.h"
+#include "vtkMatrix4x4.h"
+#include "vtkTransform.h"
 
 // Standard includes
 #include <iostream>
+#include <sstream>
+#include <iomanip>
 
 #define COLUMN_TREE 0
 #define COLUMN_UL_VIEW 1
@@ -331,7 +335,8 @@ vvMainWindow::vvMainWindow():vvMainWindowBase()
 void vvMainWindow::UpdateMemoryUsage()
 {
   //  clitk::PrintMemory(true);
-  infoPanel->setMemoryInMb(QString::number(clitk::GetMemoryUsageInMb())+" MiB");
+  if (clitk::GetMemoryUsageInMb() == 0) infoPanel->setMemoryInMb("NA");
+  else infoPanel->setMemoryInMb(QString::number(clitk::GetMemoryUsageInMb())+" MiB");
 }
 //------------------------------------------------------------------------------
 
@@ -996,6 +1001,7 @@ void vvMainWindow::ImageInfoChanged()
     std::vector<double> inputSpacing;
     std::vector<int> inputSize;
     std::vector<double> sizeMM;
+    vtkSmartPointer<vtkMatrix4x4> transformation;
     int dimension=0;
     QString pixelType;
     QString inputSizeInBytes;
@@ -1029,6 +1035,7 @@ void vvMainWindow::ImageInfoChanged()
         sizeMM[i] = inputSize[i]*inputSpacing[i];
         NPixel *= inputSize[i];
       }
+      transformation = imageSelected->GetTransform()->GetMatrix();
       inputSizeInBytes = GetSizeInBytes(imageSelected->GetActualMemorySize()*1000);
     } else if (DataTree->selectedItems()[0]->data(1,Qt::UserRole).toString() == "vector") {
       vvImage::Pointer imageSelected = mSlicerManagers[index]->GetSlicer(0)->GetVF();
@@ -1090,6 +1097,7 @@ void vvMainWindow::ImageInfoChanged()
     infoPanel->setOrigin(GetVectorDoubleAsString(origin));
     infoPanel->setSpacing(GetVectorDoubleAsString(inputSpacing));
     infoPanel->setNPixel(QString::number(NPixel)+" ("+inputSizeInBytes+")");
+    infoPanel->setTransformation(Get4x4MatrixDoubleAsString(transformation));
 
     landmarksPanel->SetCurrentLandmarks(mSlicerManagers[index]->GetLandmarks(),
                                         mSlicerManagers[index]->GetSlicer(0)->GetImage()->GetVTKImages().size());
@@ -1240,6 +1248,29 @@ QString vvMainWindow::GetSizeInBytes(unsigned long size)
 }
 //------------------------------------------------------------------------------
 
+//------------------------------------------------------------------------------
+QString vvMainWindow::Get4x4MatrixDoubleAsString(vtkSmartPointer<vtkMatrix4x4> matrix)
+{
+  std::ostringstream strmatrix;
+  
+  for (unsigned int i = 0; i < 4; i++) {
+    for (unsigned int j = 0; j < 4; j++) {
+      strmatrix.flags(ios::showpos);
+      strmatrix.width(10);
+      strmatrix.precision(3);
+      strmatrix.setf(ios::fixed,ios::floatfield);
+      strmatrix.fill(' ');
+      strmatrix << std::left << matrix->GetElement(i, j);
+      //strmatrix.width(10);
+      strmatrix << " ";
+    }
+    strmatrix << std::endl;
+  }
+  QString result = strmatrix.str().c_str();
+  return result;
+}
+//------------------------------------------------------------------------------
+
 //------------------------------------------------------------------------------
 QString vvMainWindow::GetVectorDoubleAsString(std::vector<double> vectorDouble)
 {