]> Creatis software - clitk.git/commitdiff
add memory usage info in panel (need libstatgrab)
authordsarrut <dsarrut>
Thu, 3 Mar 2011 10:16:29 +0000 (10:16 +0000)
committerdsarrut <dsarrut>
Thu, 3 Mar 2011 10:16:29 +0000 (10:16 +0000)
vv/qt_ui/vvInfoPanel.ui
vv/vvInfoPanel.cxx
vv/vvInfoPanel.h
vv/vvMainWindow.cxx
vv/vvMainWindow.h

index 9768d2f0e34cc8dd61f40a1ba9829f0906300f1d..756f444eb8203843f8db42e611a0b4d4e3637961 100644 (file)
@@ -30,8 +30,8 @@
        <rect>
         <x>0</x>
         <y>0</y>
-        <width>273</width>
-        <height>417</height>
+        <width>281</width>
+        <height>425</height>
        </rect>
       </property>
       <layout class="QGridLayout" name="gridLayout">
@@ -486,6 +486,23 @@ p, li { white-space: pre-wrap; }
          </property>
         </widget>
        </item>
+       <item row="16" column="0">
+        <widget class="QLabel" name="memoryUsageLabel">
+         <property name="sizePolicy">
+          <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+           <horstretch>0</horstretch>
+           <verstretch>0</verstretch>
+          </sizepolicy>
+         </property>
+         <property name="text">
+          <string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
+&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
+p, li { white-space: pre-wrap; }
+&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;&quot;&gt;
+&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-weight:600; color:#0000ff;&quot;&gt;Memory usage: &lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+         </property>
+        </widget>
+       </item>
       </layout>
      </widget>
     </widget>
index 33564b323d8a0fd47025f6fa4cb813f55f801682..e20a9c1a4e071fa13e3bffca9f7af43cc81ae0fa 100644 (file)
 
   - BSD        See included LICENSE.txt file
   - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
-======================================================================-====*/
+  ======================================================================-====*/
 #include <QtGui>
 #include <Qt>
 
 #include "vvInfoPanel.h"
+#include "clitkMemoryUsage.h"
 
+//------------------------------------------------------------------------------
 void vvInfoPanel::setFileName(QString text)
 {
   if (text.size() > 30)
@@ -27,37 +29,58 @@ void vvInfoPanel::setFileName(QString text)
   else
     imageLabel->setText(text);
 }
+//------------------------------------------------------------------------------
 
+
+//------------------------------------------------------------------------------
 void vvInfoPanel::setDimension(QString text)
 {
   dimensionLabel->setText(text);
 }
+//------------------------------------------------------------------------------
+
 
+//------------------------------------------------------------------------------
 void vvInfoPanel::setSizeMM(QString text)
 {
   sizeMMLabel->setText(text);
 }
+//------------------------------------------------------------------------------
+
 
+//------------------------------------------------------------------------------
 void vvInfoPanel::setNPixel(QString text)
 {
   nPixelLabel->setText(text);
 }
+//------------------------------------------------------------------------------
 
+
+//------------------------------------------------------------------------------
 void vvInfoPanel::setSizePixel(QString text)
 {
   sizePixelLabel->setText(text);
 }
+//------------------------------------------------------------------------------
+
 
+//------------------------------------------------------------------------------
 void vvInfoPanel::setOrigin(QString text)
 {
   originLabel->setText(text);
 }
+//------------------------------------------------------------------------------
+
 
+//------------------------------------------------------------------------------
 void vvInfoPanel::setSpacing(QString text)
 {
   spacingLabel->setText(text);
 }
+//------------------------------------------------------------------------------
 
+
+//------------------------------------------------------------------------------
 void vvInfoPanel::setCurrentInfo(int visibility, double x, double y, double z, double X, double Y, double Z, double value)
 {
   QString world = "";
@@ -78,8 +101,10 @@ void vvInfoPanel::setCurrentInfo(int visibility, double x, double y, double z, d
   pixelPosLabel->setText(mouse);
   valueLabel->setText(val);
 }
+//------------------------------------------------------------------------------
 
 
+//------------------------------------------------------------------------------
 void vvInfoPanel::setViews(int window, int view, int slice)
 {
   QString viewString;
@@ -125,3 +150,13 @@ void vvInfoPanel::setViews(int window, int view, int slice)
   }
   }
 }
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvInfoPanel::setMemoryInMb(QString text)
+{
+  memoryUsageLabel->setText("Memory usage: "+text);
+}
+//------------------------------------------------------------------------------
+
index 8927018f323cc9b15a41066557197d504c45ef39..63bc052af787bcab42ef58bce56d5ebf0c7fc95b 100644 (file)
@@ -14,7 +14,7 @@
 
   - BSD        See included LICENSE.txt file
   - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
-======================================================================-====*/
+  ======================================================================-====*/
 #ifndef vvInfoPanel_h
 #define vvInfoPanel_h
 #include <iostream>
 
 class vvInfoPanel : public QWidget, private Ui::vvInfoPanel
 {
-    Q_OBJECT
-
-public:
-    vvInfoPanel(QWidget * parent=0):QWidget(parent) {
-        setupUi(this);
-    }
-    ~vvInfoPanel() {}
-
-    void setFileName(QString text);
-    void setSizeMM(QString text);
-    void setOrigin(QString text);
-    void setSpacing(QString text);
-    void setNPixel(QString text);
-    void setDimension(QString text);
-    void setSizePixel(QString text);
-    void setCurrentInfo(int visibility, double x, double y, double z, double X, double Y, double Z, double value);
-    void setViews(int window, int view, int slice);
+  Q_OBJECT
+
+  public:
+  vvInfoPanel(QWidget * parent=0):QWidget(parent) {
+    setupUi(this);
+  }
+  ~vvInfoPanel() {}
+
+  void setFileName(QString text);
+  void setSizeMM(QString text);
+  void setOrigin(QString text);
+  void setSpacing(QString text);
+  void setNPixel(QString text);
+  void setDimension(QString text);
+  void setSizePixel(QString text);
+  void setCurrentInfo(int visibility, double x, double y, double z, double X, double Y, double Z, double value);
+  void setViews(int window, int view, int slice);
+  void setMemoryInMb(QString text);
 
 public slots:
 
index 456e9bda79a93f4687ad29f0958d5e7a61466c4e..1c109f02aa475eaaba2913d4dccc8d5b0384bf0c 100644 (file)
@@ -317,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();
 }
 //------------------------------------------------------------------------------
 
@@ -1076,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());
@@ -1496,6 +1514,7 @@ void vvMainWindow::CloseImage(QTreeWidgetItem* item, int column)
       InitDisplay();
     }
   }
+  ImageInfoChanged();
 }
 //------------------------------------------------------------------------------
 
@@ -2739,6 +2758,7 @@ vvSlicerManager* vvMainWindow::AddImage(vvImage::Pointer image,std::string filen
   qApp->processEvents();
   
   // End
+  ImageInfoChanged();
   return slicer_manager;
 }
 //------------------------------------------------------------------------------
index 87765a96a659fb665adcd1d7eaf396438db5fc5e..300d758463ac0ae38628092273e05ddeaa4038ab 100644 (file)
@@ -26,6 +26,7 @@
 #include "vvToolManager.h"
 #include "vvConstants.h"
 #include "vvMesh.h"
+#include "clitkMemoryUsage.h"
 
 class vvSlicerManager;
 class vvHelpDialog;
@@ -146,6 +147,7 @@ public slots:
     mFrameRate = rate;
   }
   void UpdateRenderWindows();
+  void UpdateMemoryUsage();
 
 private: