string GetTitle();
/*!
- * Gets an expended memory size for the presentation.
+ * Gets an expended memory size for the presentation (Mb).
*/
- long GetMemorySize();
+ float GetMemorySize();
};
/*! 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,
<parameter name="recorder_fps" value="17.3" />
<parameter name="recorder_quality" value="100" />
<parameter name="recorder_progressive" value="true" />
- <parameter name="cache_is_limited_memory" value="false" />
- <parameter name="cache_limited_memory" value="1000" />
+ <parameter name="cache_memory_mode" value="0" />
+ <parameter name="cache_memory_limit" value="1024" />
</section>
<section name="resources">
<!-- Module resources -->
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"
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)
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();
}
#include "LightApp_Application.h"
+#include "QtxDblSpinBox.h"
+
#include <qbuttongroup.h>
#include <qgroupbox.h>
#include <qlayout.h>
#include <qlineedit.h>
#include <qpushbutton.h>
#include <qradiobutton.h>
-#include <qspinbox.h>
-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" ) );
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 ) ) );
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();
}
#ifndef VISUGUI_CACHEDLG_H
#define VISUGUI_CACHEDLG_H
+#include "SALOMEconfig.h"
+#include CORBA_SERVER_HEADER(VISU_Gen)
+
#include <qdialog.h>
class QRadioButton;
-class QSpinBox;
+class QtxDblSpinBox;
class SalomeApp_Module;
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();
void onHelp();
private:
+ VISU::ColoredPrs3dCache_var myCache;
+
QRadioButton* myMimimalMemoryButton;
QRadioButton* myLimitedMemoryButton;
- QSpinBox* myLimitedMemory;
+ QtxDblSpinBox* myLimitedMemory;
};
#endif
static int MYDEBUG = 0;
#endif
-static int MEMORY_UNIT = 1000;
-
//----------------------------------------------------------------------------
VISU::ColoredPrs3dCache_i
::ColoredPrs3dCache_i(SALOMEDS::Study_ptr theStudy):
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 );
}
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<TSCALARMAP>(theInput, true);
+ aMemory = CheckIsPossible<TSCALARMAP>(theInput, true);
break;
case TGAUSSPOINTS:
- aMemoryNeeded = CheckIsPossible<TGAUSSPOINTS>(theInput, true);
+ aMemory = CheckIsPossible<TGAUSSPOINTS>(theInput, true);
break;
case TDEFORMEDSHAPE:
- aMemoryNeeded = CheckIsPossible<TDEFORMEDSHAPE>(theInput, true);
+ aMemory = CheckIsPossible<TDEFORMEDSHAPE>(theInput, true);
break;
case TSCALARMAPONDEFORMEDSHAPE:
- aMemoryNeeded = CheckIsPossible<TSCALARMAPONDEFORMEDSHAPE>(theInput, true);
+ aMemory = CheckIsPossible<TSCALARMAPONDEFORMEDSHAPE>(theInput, true);
break;
case TISOSURFACE:
- aMemoryNeeded = CheckIsPossible<TISOSURFACE>(theInput, true);
+ aMemory = CheckIsPossible<TISOSURFACE>(theInput, true);
break;
case TSTREAMLINES:
- aMemoryNeeded = CheckIsPossible<TSTREAMLINES>(theInput, true);
+ aMemory = CheckIsPossible<TSTREAMLINES>(theInput, true);
break;
case TPLOT3D:
- aMemoryNeeded = CheckIsPossible<TPLOT3D>(theInput, true);
+ aMemory = CheckIsPossible<TPLOT3D>(theInput, true);
break;
case TCUTPLANES:
- aMemoryNeeded = CheckIsPossible<TCUTPLANES>(theInput, true);
+ aMemory = CheckIsPossible<TCUTPLANES>(theInput, true);
break;
case TCUTLINES:
- aMemoryNeeded = CheckIsPossible<TCUTLINES>(theInput, true);
+ aMemory = CheckIsPossible<TCUTLINES>(theInput, true);
break;
case TVECTORS:
- aMemoryNeeded = CheckIsPossible<TVECTORS>(theInput, true);
+ aMemory = CheckIsPossible<TVECTORS>(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++){
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: "<<aMemoryNeeded<<"; used: "<<aMemoryUsed<<"; limit: "<<aMemoryLimit<<endl;
return aMemoryUsed + aMemoryNeeded < aMemoryLimit;
}
}
- return aMemoryNeeded > 0;
+ return aMemory > 0;
}
//----------------------------------------------------------------------------
void
VISU::ColoredPrs3dCache_i
-::SetLimitedMemory(CORBA::Long theMemorySize)
+::SetLimitedMemory(CORBA::Float theMemorySize)
{
myLimitedMemory = theMemorySize;
}
-CORBA::Long
+CORBA::Float
VISU::ColoredPrs3dCache_i
::GetLimitedMemory()
{
//! Sets a memory size for limited mode.
virtual
void
- SetLimitedMemory(CORBA::Long theMemorySize);
+ SetLimitedMemory(CORBA::Float theMemorySize);
virtual
- CORBA::Long
+ CORBA::Float
GetLimitedMemory();
//----------------------------------------------------------------------------
const VISU::ColoredPrs3dHolder::BasicInput& theInput);
private:
- CORBA::Long myLimitedMemory;
+ CORBA::Float myLimitedMemory;
VISU::ColoredPrs3dCache::MemoryMode myMemoryMode;
TColoredPrs3dHolderMap myHolderMap;
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*
GetCTitle();
virtual
- CORBA::Long
+ CORBA::Float
GetMemorySize();
//! Returns presentation input