From 68e0a771f4993b87a51c33ffc743b225b9925974 Mon Sep 17 00:00:00 2001 From: ouv Date: Mon, 27 Nov 2006 16:36:33 +0000 Subject: [PATCH] Additional control - Memory State --- src/VISUGUI/VISU_msg_en.po | 9 ++++++++ src/VISUGUI/VisuGUI_CacheDlg.cxx | 35 ++++++++++++++++++++++++++++++-- src/VISUGUI/VisuGUI_CacheDlg.h | 4 ++++ 3 files changed, 46 insertions(+), 2 deletions(-) diff --git a/src/VISUGUI/VISU_msg_en.po b/src/VISUGUI/VISU_msg_en.po index 0fc4a39f..539cb4b9 100644 --- a/src/VISUGUI/VISU_msg_en.po +++ b/src/VISUGUI/VISU_msg_en.po @@ -1759,6 +1759,15 @@ msgstr "Minimal memory" msgid "VisuGUI_CacheDlg::LIMITED_MEMORY" msgstr "Limited memory" +msgid "VisuGUI_CacheDlg::MEMORY STATE" +msgstr "Memory state" + +msgid "VisuGUI_CacheDlg::USED_BY_CACHE" +msgstr "Used by cache" + +msgid "VisuGUI_CacheDlg::FREE" +msgstr "Free" + msgid "VVTK_ViewManager::VTK_VIEW_TITLE" msgstr "Gauss scene:%1 - viewer:%2" diff --git a/src/VISUGUI/VisuGUI_CacheDlg.cxx b/src/VISUGUI/VisuGUI_CacheDlg.cxx index c27a7f15..a17535f2 100644 --- a/src/VISUGUI/VisuGUI_CacheDlg.cxx +++ b/src/VISUGUI/VisuGUI_CacheDlg.cxx @@ -43,6 +43,7 @@ #include #include +#include #include #include #include @@ -61,9 +62,10 @@ VisuGUI_CacheDlg::VisuGUI_CacheDlg( VISU::ColoredPrs3dCache_var theCache, aTopLayout->setMargin( 6 ); aTopLayout->setAutoAdd( true ); + long aMb = 1024 * 1024; bool isLimitedMemory = myCache->GetMemoryMode() == VISU::ColoredPrs3dCache::LIMITED; double aLimitedMemory = myCache->GetLimitedMemory(); - double aLimitedMemoryMax = ( double )( VISU_PipeLine::GetAvailableMemory( 2048 * 1024 * 1024.0 ) / ( 1024 * 1024.0 ) ); + double aLimitedMemoryMax = (double)VISU_PipeLine::GetAvailableMemory( 2048 * aMb ) / (double)aMb; // Settings QButtonGroup* aMemoryGroup = new QButtonGroup( 2, Qt::Vertical, tr( "MEMORY_MODE" ), this ); @@ -75,13 +77,42 @@ VisuGUI_CacheDlg::VisuGUI_CacheDlg( VISU::ColoredPrs3dCache_var theCache, myMimimalMemoryButton = new QRadioButton( tr( "MINIMAL_MEMORY" ), aMemoryGroup ); myMimimalMemoryButton->setChecked( !isLimitedMemory ); - myLimitedMemory = new QtxDblSpinBox( 1.0, aLimitedMemoryMax, 10.0, aMemoryGroup ); + myLimitedMemory = new QtxDblSpinBox( 1.0, std::max( aLimitedMemory, aLimitedMemoryMax ), 10.0, aMemoryGroup ); myLimitedMemory->setSuffix( " Mb" ); myLimitedMemory->setValue( aLimitedMemory ); myLimitedMemory->setEnabled( isLimitedMemory ); connect( myLimitedMemoryButton, SIGNAL( toggled( bool ) ), myLimitedMemory, SLOT( setEnabled( bool ) ) ); + // Current state + QGroupBox* aStateGroup = new QGroupBox( tr( "MEMORY STATE" ), this ); + aStateGroup->setColumnLayout( 0, Qt::Vertical ); + aStateGroup->layout()->setSpacing( 0 ); + aStateGroup->layout()->setMargin( 0 ); + + QGridLayout* aStateLayout = new QGridLayout( aStateGroup->layout(), 2, 2 ); + aStateLayout->setSpacing(6); + aStateLayout->setMargin(6); + + QLabel* aUsedMemoryLabel = new QLabel( tr( "USED_BY_CACHE" ), aStateGroup ); + myUsedMemory = new QLineEdit( aStateGroup ); + myUsedMemory->setText( QString::number( (double)myCache->GetMemorySize() ) + " Mb" ); + myUsedMemory->setReadOnly( true ); + myUsedMemory->setEnabled( false ); + myUsedMemory->setPaletteForegroundColor( Qt::black ); + + QLabel* aFreeMemoryLabel = new QLabel( tr( "FREE" ), aStateGroup ); + myFreeMemory = new QLineEdit( aStateGroup ); + myFreeMemory->setText( QString::number( aLimitedMemoryMax ) + " Mb" ); + myFreeMemory->setReadOnly( true ); + myFreeMemory->setEnabled( false ); + myFreeMemory->setPaletteForegroundColor( Qt::black ); + + aStateLayout->addWidget( aUsedMemoryLabel, 0, 0 ); + aStateLayout->addWidget( myUsedMemory, 0, 1 ); + aStateLayout->addWidget( aFreeMemoryLabel, 1, 0 ); + aStateLayout->addWidget( myFreeMemory, 1, 1 ); + // Ok / Cancel QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" ); GroupButtons->setColumnLayout(0, Qt::Vertical ); diff --git a/src/VISUGUI/VisuGUI_CacheDlg.h b/src/VISUGUI/VisuGUI_CacheDlg.h index 60e3e7f3..71693e76 100644 --- a/src/VISUGUI/VisuGUI_CacheDlg.h +++ b/src/VISUGUI/VisuGUI_CacheDlg.h @@ -33,6 +33,7 @@ #include +class QLineEdit; class QRadioButton; class QtxDblSpinBox; @@ -62,6 +63,9 @@ private: QRadioButton* myMimimalMemoryButton; QRadioButton* myLimitedMemoryButton; QtxDblSpinBox* myLimitedMemory; + + QLineEdit* myUsedMemory; + QLineEdit* myFreeMemory; }; #endif -- 2.39.2