From: ouv Date: Mon, 27 Nov 2006 12:38:36 +0000 (+0000) Subject: 1) Cache preferences X-Git-Tag: WP1_2_3_05-12-2006_cache_system~50 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=6137a9b217efc5b77f52baa05636c78eed531865;p=modules%2Fvisu.git 1) Cache preferences 2) Memory values converted to Mb --- diff --git a/idl/VISU_Gen.idl b/idl/VISU_Gen.idl index 0d0a114f..d04202e8 100644 --- a/idl/VISU_Gen.idl +++ b/idl/VISU_Gen.idl @@ -568,9 +568,9 @@ module VISU { string GetTitle(); /*! - * Gets an expended memory size for the presentation. + * Gets an expended memory size for the presentation (Mb). */ - long GetMemorySize(); + float GetMemorySize(); }; @@ -644,11 +644,11 @@ module VISU { /*! Gets a memory mode.*/ MemoryMode GetMemoryMode(); - /*! Sets a memory size for limited mode. */ - void SetLimitedMemory(in long theMemorySize); + /*! Sets a memory size for limited mode (Mb). */ + void SetLimitedMemory(in float theMemorySize); - /*! Gets a memory size for limited mode. */ - long GetLimitedMemory(); + /*! Gets a memory size for limited mode (Mb). */ + float GetLimitedMemory(); /*! Creates %ColoredPrs3dHolder.*/ ColoredPrs3dHolder CreateHolder(in VISUType theType, diff --git a/resources/SalomeApp.xml b/resources/SalomeApp.xml index 518184ba..52b2a829 100644 --- a/resources/SalomeApp.xml +++ b/resources/SalomeApp.xml @@ -109,8 +109,8 @@ - - + +
diff --git a/src/VISUGUI/VISU_msg_en.po b/src/VISUGUI/VISU_msg_en.po index 867b914a..0fc4a39f 100644 --- a/src/VISUGUI/VISU_msg_en.po +++ b/src/VISUGUI/VISU_msg_en.po @@ -171,6 +171,21 @@ msgstr "Use Shading" msgid "VISU_SHRINK" msgstr "Shrink" +msgid "VISU_3DCACHE_PROPS" +msgstr "3D Cache properties" + +msgid "VISU_MEMORY_MODE" +msgstr "Memory mode" + +msgid "VISU_MINIMAL" +msgstr "Minimal" + +msgid "VISU_LIMITED" +msgstr "Limited" + +msgid "VISU_MEMORY_LIMIT" +msgstr "Memory limit" + #: VisuGUI.cxx msgid "VisuGUI::MEN_IMPORT" diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index 246aa020..d83027d6 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -3107,6 +3107,33 @@ void VisuGUI::createPreferences() addPreference( tr( "VISU_USE_SHADING" ), representGr, LightApp_Preferences::Bool, "VISU", "represent_shading" ); + + + // TAB: 3D Cache ; group: "Cache properties" + int cacheTab = addPreference( tr( "3D Cache" ) ); + + int cacheGr = addPreference( tr( "VISU_3DCACHE_PROPS" ), cacheTab ); + setPreferenceProperty( cacheGr, "columns", 1 ); + + modes.clear(); + modes.append( tr( "VISU_MINIMAL" ) ); + modes.append( tr( "VISU_LIMITED" ) ); + indices.clear(); + indices.append( 0 ); + indices.append( 1 ); + setPreferenceProperty( mode, "strings", modes ); + setPreferenceProperty( mode, "indexes", indices ); + + int memory_mode = addPreference( tr( "VISU_MEMORY_MODE" ), cacheGr, + LightApp_Preferences::Selector, "VISU", "cache_memory_mode" ); + setPreferenceProperty( memory_mode, "strings", modes ); + setPreferenceProperty( memory_mode, "indexes", indices ); + + int memory_limit = addPreference( tr( "VISU_MEMORY_LIMIT" ), cacheGr, + LightApp_Preferences::IntSpin, "VISU", "cache_memory_limit" ); + setPreferenceProperty( memory_limit, "min", 1 ); + setPreferenceProperty( memory_limit, "max", 5000 ); + setPreferenceProperty( memory_limit, "step", 10 ); } void VisuGUI::preferencesChanged( const QString& a, const QString& b) @@ -3313,19 +3340,6 @@ void VisuGUI::OnCacheProperties() if( CORBA::is_nil( aCache ) ) return; - VisuGUI_CacheDlg* aDlg = new VisuGUI_CacheDlg( this, - aCache->GetMemoryMode() == VISU::ColoredPrs3dCache::LIMITED, - aCache->GetLimitedMemory() ); - if( !aDlg->exec() ) - return; - - if( aDlg->isLimitedMemory() ) - { - aCache->SetMemoryMode( VISU::ColoredPrs3dCache::LIMITED ); - aCache->SetLimitedMemory( aDlg->getLimitedMemory() ); - } - else - aCache->SetMemoryMode( VISU::ColoredPrs3dCache::MINIMAL ); - - delete aDlg; + VisuGUI_CacheDlg* aDlg = new VisuGUI_CacheDlg( aCache, this ); + aDlg->exec(); } diff --git a/src/VISUGUI/VisuGUI_CacheDlg.cxx b/src/VISUGUI/VisuGUI_CacheDlg.cxx index 617b0836..c27a7f15 100644 --- a/src/VISUGUI/VisuGUI_CacheDlg.cxx +++ b/src/VISUGUI/VisuGUI_CacheDlg.cxx @@ -39,17 +39,20 @@ #include "LightApp_Application.h" +#include "QtxDblSpinBox.h" + #include #include #include #include #include #include -#include -VisuGUI_CacheDlg::VisuGUI_CacheDlg( SalomeApp_Module* theModule, bool theIsLimitedMemory, long theLimitedMemory ) +VisuGUI_CacheDlg::VisuGUI_CacheDlg( VISU::ColoredPrs3dCache_var theCache, + SalomeApp_Module* theModule ) : QDialog( VISU::GetDesktop( theModule ), "VisuGUI_CacheDlg", true, - WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) + WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose ), + myCache( theCache ) { setCaption( tr( "CACHE_TITLE" ) ); @@ -58,23 +61,24 @@ VisuGUI_CacheDlg::VisuGUI_CacheDlg( SalomeApp_Module* theModule, bool theIsLimit aTopLayout->setMargin( 6 ); aTopLayout->setAutoAdd( true ); + bool isLimitedMemory = myCache->GetMemoryMode() == VISU::ColoredPrs3dCache::LIMITED; + double aLimitedMemory = myCache->GetLimitedMemory(); + double aLimitedMemoryMax = ( double )( VISU_PipeLine::GetAvailableMemory( 2048 * 1024 * 1024.0 ) / ( 1024 * 1024.0 ) ); + // Settings QButtonGroup* aMemoryGroup = new QButtonGroup( 2, Qt::Vertical, tr( "MEMORY_MODE" ), this ); aMemoryGroup->setRadioButtonExclusive( true ); myLimitedMemoryButton = new QRadioButton( tr( "LIMITED_MEMORY" ), aMemoryGroup ); - myLimitedMemoryButton->setChecked( theIsLimitedMemory ); + myLimitedMemoryButton->setChecked( isLimitedMemory ); myMimimalMemoryButton = new QRadioButton( tr( "MINIMAL_MEMORY" ), aMemoryGroup ); - myMimimalMemoryButton->setChecked( !theIsLimitedMemory ); - - // start from 1Gb - long aLimitedMemoryMax = ( long )( VISU_PipeLine::GetAvailableMemory( 1024 * 1024 * 1024.0 ) / 1024.0 ); + myMimimalMemoryButton->setChecked( !isLimitedMemory ); - myLimitedMemory = new QSpinBox( 1, aLimitedMemoryMax, 10, aMemoryGroup ); - myLimitedMemory->setSuffix( " kb" ); - myLimitedMemory->setValue( theLimitedMemory ); - myLimitedMemory->setEnabled( theIsLimitedMemory ); + myLimitedMemory = new QtxDblSpinBox( 1.0, aLimitedMemoryMax, 10.0, aMemoryGroup ); + myLimitedMemory->setSuffix( " Mb" ); + myLimitedMemory->setValue( aLimitedMemory ); + myLimitedMemory->setEnabled( isLimitedMemory ); connect( myLimitedMemoryButton, SIGNAL( toggled( bool ) ), myLimitedMemory, SLOT( setEnabled( bool ) ) ); @@ -116,13 +120,22 @@ bool VisuGUI_CacheDlg::isLimitedMemory() return myLimitedMemoryButton->isChecked(); } -int VisuGUI_CacheDlg::getLimitedMemory() +double VisuGUI_CacheDlg::getLimitedMemory() { return myLimitedMemory->value(); } void VisuGUI_CacheDlg::accept() { + if( isLimitedMemory() ) + { + myCache->SetMemoryMode( VISU::ColoredPrs3dCache::LIMITED ); + myCache->SetLimitedMemory( (float)getLimitedMemory() ); + } + else + myCache->SetMemoryMode( VISU::ColoredPrs3dCache::MINIMAL ); + + QDialog::accept(); } diff --git a/src/VISUGUI/VisuGUI_CacheDlg.h b/src/VISUGUI/VisuGUI_CacheDlg.h index 77e51ad9..60e3e7f3 100644 --- a/src/VISUGUI/VisuGUI_CacheDlg.h +++ b/src/VISUGUI/VisuGUI_CacheDlg.h @@ -28,10 +28,13 @@ #ifndef VISUGUI_CACHEDLG_H #define VISUGUI_CACHEDLG_H +#include "SALOMEconfig.h" +#include CORBA_SERVER_HEADER(VISU_Gen) + #include class QRadioButton; -class QSpinBox; +class QtxDblSpinBox; class SalomeApp_Module; @@ -40,12 +43,13 @@ class VisuGUI_CacheDlg : public QDialog Q_OBJECT public: - VisuGUI_CacheDlg( SalomeApp_Module* theModule, bool theIsLimitedMemory, long theLimitedMemory ); + VisuGUI_CacheDlg( VISU::ColoredPrs3dCache_var aCache, + SalomeApp_Module* theModule ); virtual ~VisuGUI_CacheDlg(); public: bool isLimitedMemory(); - int getLimitedMemory(); + double getLimitedMemory(); protected slots: virtual void accept(); @@ -53,9 +57,11 @@ protected slots: void onHelp(); private: + VISU::ColoredPrs3dCache_var myCache; + QRadioButton* myMimimalMemoryButton; QRadioButton* myLimitedMemoryButton; - QSpinBox* myLimitedMemory; + QtxDblSpinBox* myLimitedMemory; }; #endif diff --git a/src/VISU_I/VISU_ColoredPrs3dCache_i.cc b/src/VISU_I/VISU_ColoredPrs3dCache_i.cc index a8f0fa3e..c93ac4b6 100644 --- a/src/VISU_I/VISU_ColoredPrs3dCache_i.cc +++ b/src/VISU_I/VISU_ColoredPrs3dCache_i.cc @@ -50,8 +50,6 @@ static int MYDEBUG = 0; static int MYDEBUG = 0; #endif -static int MEMORY_UNIT = 1000; - //---------------------------------------------------------------------------- VISU::ColoredPrs3dCache_i ::ColoredPrs3dCache_i(SALOMEDS::Study_ptr theStudy): @@ -68,10 +66,10 @@ VISU::ColoredPrs3dCache_i SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr(); - bool anIsLimitedMemory = aResourceMgr->booleanValue( "VISU", "cache_is_limited_memory", false ); - SetMemoryMode( anIsLimitedMemory ? VISU::ColoredPrs3dCache::LIMITED : VISU::ColoredPrs3dCache::MINIMAL ); + int aMemoryMode = aResourceMgr->integerValue( "VISU", "cache_memory_mode", 0 ); + SetMemoryMode( aMemoryMode == 0 ? VISU::ColoredPrs3dCache::MINIMAL : VISU::ColoredPrs3dCache::LIMITED ); - int aLimitedMemory = aResourceMgr->integerValue( "VISU", "cache_limited_memory", 1000 ); + float aLimitedMemory = aResourceMgr->doubleValue( "VISU", "cache_memory_limit", 1024.0 ); SetLimitedMemory( aLimitedMemory ); } @@ -124,42 +122,42 @@ VISU::ColoredPrs3dCache_i const VISU::ColoredPrs3dHolder::BasicInput& theInput) { //cout << "VISU::ColoredPrs3dCache_i::IsPossible " << endl; - size_t aMemoryNeeded = 0; + size_t aMemory = 0; switch(theType){ case TSCALARMAP: - aMemoryNeeded = CheckIsPossible(theInput, true); + aMemory = CheckIsPossible(theInput, true); break; case TGAUSSPOINTS: - aMemoryNeeded = CheckIsPossible(theInput, true); + aMemory = CheckIsPossible(theInput, true); break; case TDEFORMEDSHAPE: - aMemoryNeeded = CheckIsPossible(theInput, true); + aMemory = CheckIsPossible(theInput, true); break; case TSCALARMAPONDEFORMEDSHAPE: - aMemoryNeeded = CheckIsPossible(theInput, true); + aMemory = CheckIsPossible(theInput, true); break; case TISOSURFACE: - aMemoryNeeded = CheckIsPossible(theInput, true); + aMemory = CheckIsPossible(theInput, true); break; case TSTREAMLINES: - aMemoryNeeded = CheckIsPossible(theInput, true); + aMemory = CheckIsPossible(theInput, true); break; case TPLOT3D: - aMemoryNeeded = CheckIsPossible(theInput, true); + aMemory = CheckIsPossible(theInput, true); break; case TCUTPLANES: - aMemoryNeeded = CheckIsPossible(theInput, true); + aMemory = CheckIsPossible(theInput, true); break; case TCUTLINES: - aMemoryNeeded = CheckIsPossible(theInput, true); + aMemory = CheckIsPossible(theInput, true); break; case TVECTORS: - aMemoryNeeded = CheckIsPossible(theInput, true); + aMemory = CheckIsPossible(theInput, true); break; } - if(aMemoryNeeded > 0){ + if(aMemory > 0){ if(GetMemoryMode() == VISU::ColoredPrs3dCache::LIMITED){ - size_t aMemoryUsed = 0; + float aMemoryUsed = 0; TColoredPrs3dHolderMap::const_iterator aHolderIter = myHolderMap.begin(); TColoredPrs3dHolderMap::const_iterator aHolderIterEnd = myHolderMap.end(); for(; aHolderIter != aHolderIterEnd; aHolderIter++){ @@ -171,12 +169,14 @@ VISU::ColoredPrs3dCache_i aMemoryUsed += aPrs3d->GetMemorySize(); } } - size_t aMemoryLimit = GetLimitedMemory() * MEMORY_UNIT; + float aMemoryNeeded = (float)(aMemory / (1024.0 * 1024.0)); // convert to Mb + float aMemoryLimit = GetLimitedMemory(); + //cout<<"Memory needed: "< 0; + return aMemory > 0; } @@ -247,12 +247,12 @@ VISU::ColoredPrs3dCache_i //---------------------------------------------------------------------------- void VISU::ColoredPrs3dCache_i -::SetLimitedMemory(CORBA::Long theMemorySize) +::SetLimitedMemory(CORBA::Float theMemorySize) { myLimitedMemory = theMemorySize; } -CORBA::Long +CORBA::Float VISU::ColoredPrs3dCache_i ::GetLimitedMemory() { diff --git a/src/VISU_I/VISU_ColoredPrs3dCache_i.hh b/src/VISU_I/VISU_ColoredPrs3dCache_i.hh index 2c3d32d5..1ba75dc5 100644 --- a/src/VISU_I/VISU_ColoredPrs3dCache_i.hh +++ b/src/VISU_I/VISU_ColoredPrs3dCache_i.hh @@ -83,10 +83,10 @@ namespace VISU //! Sets a memory size for limited mode. virtual void - SetLimitedMemory(CORBA::Long theMemorySize); + SetLimitedMemory(CORBA::Float theMemorySize); virtual - CORBA::Long + CORBA::Float GetLimitedMemory(); //---------------------------------------------------------------------------- @@ -165,7 +165,7 @@ namespace VISU const VISU::ColoredPrs3dHolder::BasicInput& theInput); private: - CORBA::Long myLimitedMemory; + CORBA::Float myLimitedMemory; VISU::ColoredPrs3dCache::MemoryMode myMemoryMode; TColoredPrs3dHolderMap myHolderMap; diff --git a/src/VISU_I/VISU_ColoredPrs3d_i.cc b/src/VISU_I/VISU_ColoredPrs3d_i.cc index 621a968f..f5d0ded1 100644 --- a/src/VISU_I/VISU_ColoredPrs3d_i.cc +++ b/src/VISU_I/VISU_ColoredPrs3d_i.cc @@ -345,14 +345,14 @@ VISU::ColoredPrs3d_i return aTimeStampsRange._retn(); } -CORBA::Long +CORBA::Float VISU::ColoredPrs3d_i ::GetMemorySize() { vtkDataSet* aDataSet = GetPipeLine()->GetMapper()->GetInput(); - vtkFloatingPointType aSize = aDataSet->GetActualMemorySize() * 1024.0; - vtkFloatingPointType aMemorySize = aSize * INCMEMORY; - return CORBA::Long(aMemorySize); + vtkFloatingPointType aSize = aDataSet->GetActualMemorySize(); + vtkFloatingPointType aMemorySize = aSize * INCMEMORY / 1024.0; // in Mb + return CORBA::Float(aMemorySize); } VISU::ColoredPrs3dHolder::BasicInput* diff --git a/src/VISU_I/VISU_ColoredPrs3d_i.hh b/src/VISU_I/VISU_ColoredPrs3d_i.hh index f5738ea8..5897f443 100644 --- a/src/VISU_I/VISU_ColoredPrs3d_i.hh +++ b/src/VISU_I/VISU_ColoredPrs3d_i.hh @@ -217,7 +217,7 @@ namespace VISU GetCTitle(); virtual - CORBA::Long + CORBA::Float GetMemorySize(); //! Returns presentation input