<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="1" />
+ <parameter name="cache_limited_memory" value="1000" />
</section>
<section name="resources">
<!-- Module resources -->
#include "VisuGUI_Tools.h"
+#include "VISU_PipeLine.hxx"
#include "VISU_ColoredPrs3dCache_i.hh"
#include "SUIT_Desktop.h"
myMimimalMemoryButton = new QRadioButton( tr( "MINIMAL_MEMORY" ), aMemoryGroup );
myMimimalMemoryButton->setChecked( !theIsLimitedMemory );
- myLimitedMemory = new QSpinBox( 1, 5000, 1, aMemoryGroup );
- myLimitedMemory->setSuffix( " Mb" );
+ // start from 1Gb
+ long aLimitedMemoryMax = ( long )( VISU_PipeLine::GetAvailableMemory( 1024 * 1024 * 1024.0 ) / 1024.0 );
+
+ myLimitedMemory = new QSpinBox( 1, aLimitedMemoryMax, 10, aMemoryGroup );
+ myLimitedMemory->setSuffix( " kb" );
myLimitedMemory->setValue( theLimitedMemory );
myLimitedMemory->setEnabled( theIsLimitedMemory );
VVTK_ViewWindow* aViewWindow = ( VVTK_ViewWindow* )aViewManager->createViewWindow();
if( aViewWindow )
{
- new VisuGUI_Slider( aViewWindow, anApp->selectionMgr() );
+ new VisuGUI_Slider( this, aViewWindow, anApp->selectionMgr() );
}
return aViewer->getViewManager();
#include "VVTK_MainWindow.h"
#include "VVTK_ViewWindow.h"
+#include "VISU_Gen_i.hh"
#include "VISU_ColoredPrs3d_i.hh"
#include "VISU_ColoredPrs3dHolder_i.hh"
+#include "VisuGUI_Module.h"
+#include "VisuGUI_Tools.h"
+
#include <vtkActorCollection.h>
#include <vtkRenderer.h>
/*!
Constructor
*/
-VisuGUI_Slider::VisuGUI_Slider( VVTK_ViewWindow* theViewWindow,
+VisuGUI_Slider::VisuGUI_Slider( VisuGUI_Module* theModule,
+ VVTK_ViewWindow* theViewWindow,
LightApp_SelectionMgr* theSelectionMgr )
: QtxDockWindow( InDock, theViewWindow->getMainWindow1() ),
+ myModule( theModule ),
myMainWindow( theViewWindow->getMainWindow1() ),
mySelectionMgr( theSelectionMgr )
{
myTimeStampStrings->clear();
myTimeStampIndices->clear();
- if( myPrsList.size() == 0 )
+ if( myHolderList.size() == 0 )
return;
- VISU::ColoredPrs3d_i* aPrs = myPrsList[0];
+ VISU::ColoredPrs3dHolder_var aHolder = myHolderList[0];
+ VISU::ColoredPrs3d_var aPrs = aHolder->GetDevice();
CORBA::Long aTimeStampNumber = aPrs->GetTimeStampNumber();
VISU::ColoredPrs3d::TimeStampsRange_var aTimeStampsRange = aPrs->GetTimeStampsRange();
+
CORBA::Long aLength = aTimeStampsRange->length();
mySlider->setMinValue( 0 );
void VisuGUI_Slider::onSelectionChanged()
{
- myPrsList.resize(0);
+ //cout << "VisuGUI_Slider::onSelectionChanged()" << endl;
+ myHolderList.resize(0);
_PTR(SObject) aSObject;
if (aSObject) {
CORBA::Object_var anObject = VISU::ClientSObjectToObject(aSObject);
if (!CORBA::is_nil(anObject)) {
- VISU::ColoredPrs3dHolder_i* aHolder =
- dynamic_cast<VISU::ColoredPrs3dHolder_i*>(VISU::GetServant(anObject).in());
+ VISU::ColoredPrs3dHolder_var aHolder = VISU::ColoredPrs3dHolder::_narrow(anObject);
- if( aHolder )
+ if(!CORBA::is_nil(aHolder))
{
- VISU::ColoredPrs3d_i* aPrs =
- dynamic_cast<VISU::ColoredPrs3d_i*>( VISU::GetServant(aHolder->GetDevice()).in() );
-
- if( aPrs && !aPrs->IsTimeStampFixed() ) {
- //cout << "ColoredPrs3d" << endl;
- myPrsList.resize(k+1);
- myPrsList[k] = aPrs;
- k++;
- }
+ //cout << "ColoredPrs3dHolder" << endl;
+ myHolderList.resize(k+1);
+ myHolderList[k] = aHolder;
+ k++;
}
}
}
}
}
- enableControls( myPrsList.size() != 0 );
+ enableControls( myHolderList.size() != 0 );
}
void VisuGUI_Slider::onTimeStampActivated( int value )
void VisuGUI_Slider::onValueChanged( int value )
{
- if( myPrsList.size() == 0 )
+ if( myHolderList.size() == 0 )
return;
- VISU::ColoredPrs3d_i* aPrs = myPrsList[0];
+ VISU::ColoredPrs3dHolder_var aHolder = myHolderList[0];
+ VISU::ColoredPrs3d_var aPrs = aHolder->GetDevice();
+
VISU::ColoredPrs3d::TimeStampsRange_var aTimeStampsRange = aPrs->GetTimeStampsRange();
+
CORBA::Long aLength = aTimeStampsRange->length();
if(value < 0 || aLength <= value)
return;
CORBA::Long aNumber = aTimeStampsRange[ value ].myNumber;
- for( int i = 0, n = myPrsList.size(); i < n; i++ )
+ HolderList::iterator it = myHolderList.begin();
+ HolderList::iterator itEnd = myHolderList.end();
+ for( ; it != itEnd; ++it )
{
- aPrs = myPrsList[i];
- aPrs->SetTimeStampNumber( aNumber );
- aPrs->Apply();
+ VISU::ColoredPrs3dHolder_var aHolder = *it;
+ if( CORBA::is_nil( aHolder.in() ) )
+ continue;
+
+ VISU::ColoredPrs3dHolder::BasicInput* anInput = aHolder->GetBasicInput();
+ anInput->myTimeStampNumber = aNumber;
+
+ VISU::View_var aView = VISU::GetVisuGen( myModule )->GetViewManager()->GetCurrentView();
+ if( CORBA::is_nil( aView.in() ) )
+ continue;
+
+ VISU::View3D_var aView3D = VISU::View3D::_narrow( aView );
+ if( CORBA::is_nil( aView3D.in() ) )
+ continue;
+
+ aHolder->Apply( aHolder->GetDevice(), *anInput, aView3D );
}
myTimeStampStrings->setCurrentItem( value );
#include "QtxDockWindow.h"
#include <vector>
+#include "SALOMEconfig.h"
+#include CORBA_SERVER_HEADER(VISU_Gen)
+
namespace VISU
{
- class ColoredPrs3d_i;
+ class ColoredPrs3dHolder_i;
}
-typedef std::vector<VISU::ColoredPrs3d_i*> PrsList;
+typedef std::vector<VISU::ColoredPrs3dHolder_var> HolderList;
class QCheckBox;
class QComboBox;
class VVTK_MainWindow;
class LightApp_SelectionMgr;
+class VisuGUI_Module;
+
class VisuGUI_Slider : public QtxDockWindow
{
Q_OBJECT
public:
- VisuGUI_Slider( VVTK_ViewWindow* theViewWindow,
+ VisuGUI_Slider( VisuGUI_Module* theModule,
+ VVTK_ViewWindow* theViewWindow,
LightApp_SelectionMgr* theSelectionMgr );
virtual ~VisuGUI_Slider();
virtual void onTimeout();
private:
+ VisuGUI_Module* myModule;
VVTK_MainWindow* myMainWindow;
LightApp_SelectionMgr* mySelectionMgr;
QTimer* myTimer;
- PrsList myPrsList;
+ //PrsList myPrsList;
+ HolderList myHolderList;
};
#endif
#include "VISU_View_i.hh"
#include "VISU_ViewManager_i.hh"
+#include "VISU_Convertor.hxx"
+#include "VISU_PipeLine.hxx"
+
#include "VVTK_ViewWindow.h"
#include "SUIT_ResourceMgr.h"
static int MYDEBUG = 0;
#endif
+static int INCMEMORY = 4;
+
+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", true );
+ bool anIsLimitedMemory = aResourceMgr->booleanValue( "VISU", "cache_is_limited_memory", false );
SetMemoryMode( anIsLimitedMemory ? VISU::ColoredPrs3dCache::LIMITED : VISU::ColoredPrs3dCache::MINIMAL );
- int aLimitedMemory = aResourceMgr->integerValue( "VISU", "cache_limited_memory", 10 );
+ int aLimitedMemory = aResourceMgr->integerValue( "VISU", "cache_limited_memory", 1000 );
SetLimitedMemory( aLimitedMemory );
-
}
return TColoredPrs3d::IsPossible(aResult,aMeshName,anEntity,aFieldName,aTimeStampNumber);
}
+
//----------------------------------------------------------------------------
int
VISU::ColoredPrs3dCache_i
::IsPossible(VISU::VISUType theType,
- const VISU::ColoredPrs3dHolder::BasicInput& theInput)
+ const VISU::ColoredPrs3dHolder::BasicInput& theInput,
+ bool theMemoryCheck)
{
//cout << "VISU::ColoredPrs3dCache_i::IsPossible " << endl;
+ bool anIsPossible = false;
switch(theType){
case TSCALARMAP:
- return CheckIsPossible<TSCALARMAP>(theInput);
+ anIsPossible = CheckIsPossible<TSCALARMAP>(theInput);
case TGAUSSPOINTS:
- return CheckIsPossible<TGAUSSPOINTS>(theInput);
+ anIsPossible = CheckIsPossible<TGAUSSPOINTS>(theInput);
case TDEFORMEDSHAPE:
- return CheckIsPossible<TDEFORMEDSHAPE>(theInput);
+ anIsPossible = CheckIsPossible<TDEFORMEDSHAPE>(theInput);
case TSCALARMAPONDEFORMEDSHAPE:
- return CheckIsPossible<TSCALARMAPONDEFORMEDSHAPE>(theInput);
+ anIsPossible = CheckIsPossible<TSCALARMAPONDEFORMEDSHAPE>(theInput);
case TISOSURFACE:
- return CheckIsPossible<TISOSURFACE>(theInput);
+ anIsPossible = CheckIsPossible<TISOSURFACE>(theInput);
case TSTREAMLINES:
- return CheckIsPossible<TSTREAMLINES>(theInput);
+ anIsPossible = CheckIsPossible<TSTREAMLINES>(theInput);
case TPLOT3D:
- return CheckIsPossible<TPLOT3D>(theInput);
+ anIsPossible = CheckIsPossible<TPLOT3D>(theInput);
case TCUTPLANES:
- return CheckIsPossible<TCUTPLANES>(theInput);
+ anIsPossible = CheckIsPossible<TCUTPLANES>(theInput);
case TCUTLINES:
- return CheckIsPossible<TCUTLINES>(theInput);
+ anIsPossible = CheckIsPossible<TCUTLINES>(theInput);
case TVECTORS:
- return CheckIsPossible<TVECTORS>(theInput);
+ anIsPossible = CheckIsPossible<TVECTORS>(theInput);
}
- return 0;
+ if( anIsPossible && theMemoryCheck )
+ {
+ //cout << "Memory checking..." << endl;
+ if( GetMemoryMode() == VISU::ColoredPrs3dCache::LIMITED )
+ {
+ long aMemoryUsed = 0;
+
+ VISU::ColoredPrs3d_i* aPrs3d;
+ TColoredPrs3dHolderMap::iterator aMapIterator = myHolderMap.begin();
+ TColoredPrs3dHolderMap::iterator aMapIteratorEnd = myHolderMap.end();
+ for(; aMapIterator != aMapIteratorEnd; ++aMapIterator)
+ {
+ TLastVisitedPrsList aList = aMapIterator->second;
+
+ TLastVisitedPrsList::iterator it = aList.begin();
+ TLastVisitedPrsList::iterator itEnd = aList.end();
+ for(; it != itEnd; ++it)
+ {
+ aPrs3d = *it;
+ if( aPrs3d )
+ aMemoryUsed += aPrs3d->GetMemorySize();
+ }
+ }
+
+ long aMemoryLimit = GetLimitedMemory() * MEMORY_UNIT;
+
+ //cout << "Cache memory : " << aMemoryLimit << endl;
+ //cout << "Memory used : " << aMemoryUsed << endl;
+
+ VISU::Result_i* aResult = dynamic_cast<VISU::Result_i*>( VISU::GetServant(theInput.myResult).in() );
+ std::string aMeshName = theInput.myMeshName.in();
+ VISU::Entity anEntity = theInput.myEntity;
+ std::string aFieldName = theInput.myFieldName.in();
+ long aTimeStampNumber = theInput.myTimeStampNumber;
+
+ VISU::Result_i::TInput* anInput = aResult->GetInput();
+ float aMemoryNeeded = anInput->GetTimeStampSize(aMeshName,
+ (VISU::TEntity)anEntity,
+ aFieldName,
+ aTimeStampNumber);
+ aMemoryNeeded *= INCMEMORY;
+ //cout << "Memory needed : " << aMemoryNeeded << endl;
+
+ if( aMemoryUsed + aMemoryNeeded > aMemoryLimit )
+ anIsPossible = false;
+ }
+ else
+ anIsPossible = false;
+ }
+
+ return anIsPossible;
}
VISU::ColoredPrs3dCache_var aCache = ColoredPrs3dCache_i::GetInstance(aStudy);
VISU::ColoredPrs3dHolder_var aHolder = aCache->CreateHolder(theType, anInput);
+ if( CORBA::is_nil(aHolder) )
+ return NULL;
+
VISU::ColoredPrs3d_var aPrs3d = aHolder->GetDevice();
aColoredPrs3d = dynamic_cast<VISU::ColoredPrs3d_i*>(GetServant(aPrs3d).in());
}
{
TLastVisitedPrsList aList = GetLastVisitedPrsList(theHolder);
if( !aList.empty() )
- return aList.front();
+ return aList.back();
return NULL;
}
{
aLastVisitedPrsList.pop_front();
}
- else if(IsPossible(theHolder->GetPrsType(), theInput))
+ else if(IsPossible(theHolder->GetPrsType(), theInput, true))
{
aPrs3d = CreatePrs(theHolder->GetPrsType(), theInput, theHolder);
//cout << "Created " << aPrs3d->GetName() << endl;
}
aLastVisitedPrsList.push_back(aPrs3d);
- //aPrs3d->SameAs(thePrs);
+ aPrs3d->SameAs(thePrs);
if(aPrs3d && !CORBA::is_nil(theView3D))
{
//----------------------------------------------------------------------------
virtual int
IsPossible(VISU::VISUType theType,
- const VISU::ColoredPrs3dHolder::BasicInput& theInput);
+ const VISU::ColoredPrs3dHolder::BasicInput& theInput,
+ bool theMemoryCheck = false);
VISU::ColoredPrs3d_i*
FindPrsByInput(TLastVisitedPrsList& theLastVisitedPrsList,
static int MYDEBUG = 0;
#endif
+static int INCMEMORY = 4;
+
//============================================================================
VISU::ColoredPrs3d_i::
return aTimeStampsRange._retn();
}
+CORBA::Long
+VISU::ColoredPrs3d_i
+::GetMemorySize()
+{
+ VISU::Result_i* aResult = dynamic_cast<VISU::Result_i*>( VISU::GetServant(GetResultObject()).in() );
+ std::string aMeshName = GetCMeshName();
+ VISU::Entity anEntity = GetEntity();
+ std::string aFieldName = GetCFieldName();
+ long aTimeStampNumber = GetTimeStampNumber();
+
+ VISU::Result_i::TInput* anInput = aResult->GetInput();
+ float aSize = anInput->GetTimeStampSize(aMeshName,
+ (VISU::TEntity)anEntity,
+ aFieldName,
+ aTimeStampNumber);
+ aSize *= INCMEMORY;
+
+ return (CORBA::Long)aSize;
+}
+
VISU::ColoredPrs3dHolder::BasicInput*
VISU::ColoredPrs3d_i
::GetBasicInput()
virtual
CORBA::Long
- GetMemorySize() { return 0; }
+ GetMemorySize();
//! Returns presentation input
VISU::ColoredPrs3dHolder::BasicInput*