From 9ad61d350326b41cf1ed2c45b6a87184e366095d Mon Sep 17 00:00:00 2001 From: eap Date: Thu, 20 Jun 2013 14:29:16 +0000 Subject: [PATCH] Show free RAM while computing the mesh --- src/SMESHGUI/SMESHGUI_ComputeDlg.cxx | 45 +++++++++++++++++++++------- src/SMESHGUI/SMESHGUI_ComputeDlg.h | 1 + src/SMESHGUI/SMESH_msg_en.ts | 8 +++++ 3 files changed, 43 insertions(+), 11 deletions(-) diff --git a/src/SMESHGUI/SMESHGUI_ComputeDlg.cxx b/src/SMESHGUI/SMESHGUI_ComputeDlg.cxx index be3fc2f18..1bd4d86f1 100644 --- a/src/SMESHGUI/SMESHGUI_ComputeDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_ComputeDlg.cxx @@ -99,6 +99,10 @@ #include #include +#ifndef WIN32 +#include +#endif + #define SPACING 6 #define MARGIN 11 @@ -748,17 +752,24 @@ SMESHGUI_ComputeDlg_QThreadQDialog::SMESHGUI_ComputeDlg_QThreadQDialog(QWidget QLabel * nbNodesName = new QLabel(tr("SMESH_MESHINFO_NODES"), this ); QLabel * nbElemsName = new QLabel(tr("SMESH_MESHINFO_ELEMENTS"), this ); + QLabel * freeRAMName = new QLabel(tr("SMESH_FREERAM"), this ); nbNodesLabel = new QLabel("0", this ); nbElemsLabel = new QLabel("0", this ); + freeRAMLabel = new QLabel("", this ); QGridLayout* layout = new QGridLayout(this); layout->setMargin( MARGIN ); layout->setSpacing( SPACING ); - layout->addWidget(nbNodesName, 0, 0); - layout->addWidget(nbNodesLabel, 0, 1); - layout->addWidget(nbElemsName, 1, 0); - layout->addWidget(nbElemsLabel, 1, 1); - layout->addWidget(cancelButton, 2, 0, 1, 2); + int row = 0; + layout->addWidget(nbNodesName, row, 0); + layout->addWidget(nbNodesLabel, row++, 1); + layout->addWidget(nbElemsName, row, 0); + layout->addWidget(nbElemsLabel, row++, 1); +#ifndef WNT + layout->addWidget(freeRAMName, row, 0); + layout->addWidget(freeRAMLabel, row++, 1); +#endif + layout->addWidget(cancelButton, row, 0, 1, 2); adjustSize(); update(); @@ -781,18 +792,30 @@ void SMESHGUI_ComputeDlg_QThreadQDialog::onCancel() void SMESHGUI_ComputeDlg_QThreadQDialog::timerEvent(QTimerEvent *event) { if(qthread.isFinished()) - { - close(); - } - nbNodesLabel->setText( QString("%1").arg( qthread.getMesh()->NbNodes() )); - nbElemsLabel->setText( QString("%1").arg( qthread.getMesh()->NbElements() )); + { + close(); + } + else + { + nbNodesLabel->setText( QString("%1").arg( qthread.getMesh()->NbNodes() )); + nbElemsLabel->setText( QString("%1").arg( qthread.getMesh()->NbElements() )); +#ifndef WNT + struct sysinfo si; + const int err = sysinfo( &si ); + if ( err ) + freeRAMLabel->setText(""); + else + freeRAMLabel->setText( tr("SMESH_GIGABYTE").arg + ( si.freeram * si.mem_unit /1024./1024./1024., 0, 'f', 2 )); +#endif + } event->accept(); } void SMESHGUI_ComputeDlg_QThreadQDialog::closeEvent(QCloseEvent *event) { if(qthread.isRunning()) - { + { event->ignore(); return; } diff --git a/src/SMESHGUI/SMESHGUI_ComputeDlg.h b/src/SMESHGUI/SMESHGUI_ComputeDlg.h index 81a09f857..e8101a311 100644 --- a/src/SMESHGUI/SMESHGUI_ComputeDlg.h +++ b/src/SMESHGUI/SMESHGUI_ComputeDlg.h @@ -317,6 +317,7 @@ private: QPushButton * cancelButton; QLabel * nbNodesLabel; QLabel * nbElemsLabel; + QLabel * freeRAMLabel; }; #endif // SMESHGUI_COMPUTEDLG_H diff --git a/src/SMESHGUI/SMESH_msg_en.ts b/src/SMESHGUI/SMESH_msg_en.ts index 3f4d8e5d1..536914858 100644 --- a/src/SMESHGUI/SMESH_msg_en.ts +++ b/src/SMESHGUI/SMESH_msg_en.ts @@ -4100,6 +4100,14 @@ Input value precision can be adjusted using Selected object has been used to create another one. It can't be deleted + + SMESH_FREERAM + Free RAM + + + SMESH_GIGABYTE + %1 G + SMESHGUI_Dialog -- 2.39.2