]> Creatis software - clitk.git/blobdiff - vv/vvMainWindow.cxx
add memory usage info in panel (need libstatgrab)
[clitk.git] / vv / vvMainWindow.cxx
index f62198883969d56e456f1d22e0a0a54d85b69d11..1c109f02aa475eaaba2913d4dccc8d5b0384bf0c 100644 (file)
@@ -268,6 +268,7 @@ vvMainWindow::vvMainWindow():vvMainWindowBase()
   connect(colorMapComboBox,SIGNAL(currentIndexChanged(int)),this,SLOT(UpdateColorMap()));
   connect(presetComboBox,SIGNAL(currentIndexChanged(int)),this,SLOT(UpdateWindowLevel()));
   connect(inverseButton,SIGNAL(clicked()),this,SLOT(SwitchWindowLevel()));
+  connect(applyWindowLevelToAllButton,SIGNAL(clicked()),this,SLOT(ApplyWindowLevelToAllImages()));
 
 
   connect(this,SIGNAL(customContextMenuRequested(QPoint)),this,SLOT(ShowContextMenu(QPoint)));
@@ -316,6 +317,21 @@ vvMainWindow::vvMainWindow():vvMainWindowBase()
 
   if (!CLITK_EXPERIMENTAL)
     menuExperimental->menuAction()->setVisible(false);
+
+
+  QTimer * timerMemory = new QTimer(this);
+  //timerMemory->setInterval(5);
+  connect(timerMemory, SIGNAL(timeout()), this, SLOT(UpdateMemoryUsage()));
+  timerMemory->start(5000);
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvMainWindow::UpdateMemoryUsage()
+{
+  clitk::PrintMemory(true);
+  ImageInfoChanged();
 }
 //------------------------------------------------------------------------------
 
@@ -1075,6 +1091,9 @@ void vvMainWindow::ImageInfoChanged()
     infoPanel->setSpacing(GetVectorDoubleAsString(inputSpacing));
     infoPanel->setNPixel(QString::number(NPixel)+" ("+inputSizeInBytes+")");
 
+    infoPanel->setMemoryInMb(QString::number(clitk::GetMemoryUsageInMb())+" Mb");
+
+
     landmarksPanel->SetCurrentLandmarks(mSlicerManagers[index]->GetLandmarks(),
                                         mSlicerManagers[index]->GetSlicer(0)->GetImage()->GetVTKImages().size());
     landmarksPanel->SetCurrentPath(mInputPathName.toStdString());
@@ -1495,6 +1514,7 @@ void vvMainWindow::CloseImage(QTreeWidgetItem* item, int column)
       InitDisplay();
     }
   }
+  ImageInfoChanged();
 }
 //------------------------------------------------------------------------------
 
@@ -1616,6 +1636,20 @@ void vvMainWindow::SwitchWindowLevel()
 }
 //------------------------------------------------------------------------------
 
+//------------------------------------------------------------------------------
+void vvMainWindow::ApplyWindowLevelToAllImages()
+{
+  for (unsigned int i = 0; i < mSlicerManagers.size(); i++) {
+    if (mSlicerManagers[i] == NULL)
+      continue;
+    mSlicerManagers[i]->SetColorWindow(windowSpinBox->value());
+    mSlicerManagers[i]->SetColorLevel(levelSpinBox->value());
+    mSlicerManagers[i]->SetPreset(6);
+    mSlicerManagers[i]->Render();
+  }
+}
+//------------------------------------------------------------------------------
+
 //------------------------------------------------------------------------------
 void vvMainWindow::UpdateLinkManager(std::string id, int slicer, double x, double y, double z, int temps)
 {
@@ -2724,6 +2758,7 @@ vvSlicerManager* vvMainWindow::AddImage(vvImage::Pointer image,std::string filen
   qApp->processEvents();
   
   // End
+  ImageInfoChanged();
   return slicer_manager;
 }
 //------------------------------------------------------------------------------