From 2888090345c718aceff0174d5048b6806487046d Mon Sep 17 00:00:00 2001 From: apo Date: Thu, 8 May 2008 08:32:21 +0000 Subject: [PATCH] The first implementation of the "Removing 3D Cache System from Gauss Viewer" --- idl/VISU_Gen.idl | 4 +- src/VISUGUI/VISU_msg_en.ts | 82 ++++---- src/VISUGUI/VisuGUI.cxx | 27 ++- src/VISUGUI/VisuGUI.h | 9 +- src/VISUGUI/VisuGUI_Module.cxx | 10 +- src/VISUGUI/VisuGUI_Slider.cxx | 343 +++++++++++++++++++++------------ src/VISUGUI/VisuGUI_Slider.h | 53 ++--- src/VISU_I/VISU_View_i.hh | 8 +- 8 files changed, 323 insertions(+), 213 deletions(-) diff --git a/idl/VISU_Gen.idl b/idl/VISU_Gen.idl index 9e1958f8..2497187f 100644 --- a/idl/VISU_Gen.idl +++ b/idl/VISU_Gen.idl @@ -2093,8 +2093,8 @@ module VISU { * the following types: 3d, Table, XY plot. * %View interface is a base for all types of %view interfaces. */ - interface View: Base { - + interface View: Base, SALOME::GenericObj + { /*! \brief %ViewRepresentation enumeration * * displaying part ("ALL" isn't setable) diff --git a/src/VISUGUI/VISU_msg_en.ts b/src/VISUGUI/VISU_msg_en.ts index 9218e1f6..dcb15c65 100644 --- a/src/VISUGUI/VISU_msg_en.ts +++ b/src/VISUGUI/VISU_msg_en.ts @@ -1327,37 +1327,6 @@ Please, refer to the documentation. Elapsed time : - - VisuGUI_CacheDlg - - CACHE_TITLE - Cache properties - - - FREE - Free - - - LIMITED_MEMORY - Limited memory - - - MEMORY STATE - Memory state - - - MEMORY_MODE - Memory mode - - - MINIMAL_MEMORY - Minimal memory - - - USED_BY_CACHE - Used by cache - - VisuGUI_ClippingDlg @@ -2768,30 +2737,57 @@ Please, provide non-empty resulting presentation. VisuGUI_Slider + + + TITLE + Slider + + - AVI - AVI + NAVIGATION + Navigation - CACHE_MEMORY - Cache: + IS_CYCLED + Is Cycled + - FREE_MEMORY - Free: + SPEED + Speed + - MORE - More... + MEMORY_MODE + Mode - SPEED - Speed: + MINIMAL_MEMORY + Minimal - TOOLBAR_TITLE - Slider + LIMITED_MEMORY + Limited + + + MEMORY_UNITS + Mb + + + + + MEMORY_STATE + State + + + USED_BY_CACHE + Used: + + + AVAILABLE_MEMORY + Free: + VisuGUI_StreamLinesDlg diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index a802ab00..131ccec8 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -150,6 +150,8 @@ #include "VVTK_ViewModel.h" +#include "VisuGUI_Slider.h" + using namespace VISU; #ifdef _DEBUG_ @@ -169,9 +171,9 @@ static int MYDEBUG = 0; VisuGUI ::VisuGUI(): SalomeApp_Module( "VISU" ), + mySlider( NULL ), myDisplayer( 0 ) -{ -} +{} VisuGUI @@ -184,6 +186,7 @@ VisuGUI ::OnImportFromFile() { if(MYDEBUG) MESSAGE("VisuGUI::OnImportFromFile()"); + if ( CheckLock(GetCStudy(GetAppStudy(this)),GetDesktop(this)) ) return; @@ -2936,7 +2939,14 @@ bool VisuGUI ::activateModule( SUIT_Study* theStudy ) { - SalomeApp_Module::activateModule( theStudy ); + bool aResult = SalomeApp_Module::activateModule( theStudy ); + + if ( !mySlider ) { + SALOMEDS::Study_var aStudy = GetDSStudy( GetCStudy( GetAppStudy( this ) ) ); + VISU::ColoredPrs3dCache_var aCache = GetVisuGen( this )->GetColoredPrs3dCache( aStudy ); + mySlider = new VisuGUI_Slider( this, getApp()->desktop(), getApp()->selectionMgr() ); + } + studyActivated(); setMenuShown( true ); setToolShown( true ); @@ -2946,7 +2956,9 @@ VisuGUI shortcuts.append( QKeySequence(Qt::CTRL + Qt::Key_I) ); action(VISU_IMPORT_FROM_FILE)->setShortcuts(shortcuts); - return true; + emit moduleActivated(); + + return aResult; } @@ -2960,8 +2972,11 @@ VisuGUI // Unset actions accelerator keys action(VISU_IMPORT_FROM_FILE)->setShortcuts(QKeySequence::UnknownKey); - SalomeApp_Module::deactivateModule( theStudy ); - return true; + bool aResult = SalomeApp_Module::deactivateModule( theStudy ); + + emit moduleDeactivated(); + + return aResult; } LightApp_Selection* diff --git a/src/VISUGUI/VisuGUI.h b/src/VISUGUI/VisuGUI.h index 536a45a3..2f612517 100644 --- a/src/VISUGUI/VisuGUI.h +++ b/src/VISUGUI/VisuGUI.h @@ -39,13 +39,13 @@ #include "SVTK_ViewWindow.h" - class SUIT_ViewManager; class SVTK_ViewWindow; -class Prs3d_i; +class VisuGUI_Slider; namespace VISU { + class Prs3d_i; typedef std::pair TPrs3dToInd; // prs pointer and default index of scalar bar placement typedef std::set TSetPrs3d; typedef std::map TViewToPrs3d; @@ -82,6 +82,10 @@ public: VISU::TViewToPrs3d& getScalarBarsMap(); +signals: + void moduleDeactivated(); + void moduleActivated(); + public slots: virtual bool deactivateModule( SUIT_Study* ); virtual bool activateModule( SUIT_Study* ); @@ -188,6 +192,7 @@ private: void createPopupMenus(); private: + VisuGUI_Slider* mySlider; LightApp_Displayer* myDisplayer; VISU::TViewToPrs3d myScalarBarsMap; }; diff --git a/src/VISUGUI/VisuGUI_Module.cxx b/src/VISUGUI/VisuGUI_Module.cxx index d2a59a73..21ffa19d 100644 --- a/src/VISUGUI/VisuGUI_Module.cxx +++ b/src/VISUGUI/VisuGUI_Module.cxx @@ -65,8 +65,6 @@ #include "VISU_GaussPtsAct.h" #include "VisuGUI_GaussPointsDlg.h" -#include "VisuGUI_Slider.h" - #include "VISU_Gen_i.hh" #include "VISU_Result_i.hh" #include "VISU_CutLines_i.hh" @@ -414,14 +412,10 @@ onCreateViewManager() aViewer->setBackgroundColor( aResourceMgr->colorValue( "VTKViewer", "background", aViewer->backgroundColor() ) ); aViewer->setTrihedronSize( aResourceMgr->integerValue( "VTKViewer", "trihedron_size", aViewer->trihedronSize() ), aResourceMgr->booleanValue( "VTKViewer", "relative_size", aViewer->trihedronRelative() ) ); + new LightApp_VTKSelector( aViewer, anApp->selectionMgr() ); + anApp->addViewManager( aViewManager ); - - VVTK_ViewWindow* aViewWindow = ( VVTK_ViewWindow* )aViewManager->createViewWindow(); - if( aViewWindow ) - { - new VisuGUI_Slider( this, aViewWindow, anApp->selectionMgr() ); - } return aViewer->getViewManager(); } diff --git a/src/VISUGUI/VisuGUI_Slider.cxx b/src/VISUGUI/VisuGUI_Slider.cxx index 64379d60..23b38039 100644 --- a/src/VISUGUI/VisuGUI_Slider.cxx +++ b/src/VISUGUI/VisuGUI_Slider.cxx @@ -41,20 +41,21 @@ #include "VISU_Actor.h" -#include "VVTK_MainWindow.h" -#include "VVTK_ViewWindow.h" - #include "VISU_Gen_i.hh" -#include "VisuGUI_Module.h" +#include "VisuGUI.h" #include "VisuGUI_Tools.h" #include "VisuGUI_Prs3dTools.h" #include "VTKViewer_Algorithm.h" #include "SVTK_Functor.h" +#include "QtxDockWidget.h" +#include "QtxDoubleSpinBox.h" + #include #include +#include #include #include #include @@ -64,146 +65,205 @@ #include #include #include +#include +#include +#include #include /*! Constructor */ -VisuGUI_Slider::VisuGUI_Slider( VisuGUI_Module* theModule, - VVTK_ViewWindow* theViewWindow, +VisuGUI_Slider::VisuGUI_Slider( VisuGUI* theModule, + QMainWindow* theParent, LightApp_SelectionMgr* theSelectionMgr ) - : QtxToolBar( tr("TOOLBAR_TITLE"), theViewWindow->getMainWindow1() ), - myModule( theModule ), - myMainWindow( theViewWindow->getMainWindow1() ), + : QWidget( theParent ), + myViewManager( VISU::GetVisuGen( theModule )->GetViewManager() ), mySelectionMgr( theSelectionMgr ) { - //setLabel(); - //setCloseMode(QDockWindow::Undocked); - setMovable( true ); - - VISU::ViewManager_var aViewManager = VISU::GetVisuGen( myModule )->GetViewManager(); - VISU::View_var aView = aViewManager->GetCurrentView(); - if(!CORBA::is_nil(aView.in())) - myView3D = VISU::View3D::_narrow(aView); + setWindowTitle( tr("TITLE") ); SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr(); - //setHorizontallyStretchable( true ); + QGridLayout *aWidgetGridLayout = new QGridLayout( this ); - QWidget* aWidget = new QWidget( this ); - aWidget->setFocusPolicy(Qt::StrongFocus); - myWidgetAction = addWidget( aWidget ); + //---------------------------------------------------------------------------- + // Definition of the navigation group box + QGroupBox *aNavigationGroupBox = new QGroupBox( tr( "NAVIGATION" ), this ); - QGridLayout* aLayout = new QGridLayout( aWidget ); - aLayout->setMargin( 11 ); - aLayout->setSpacing( 6 ); + QGridLayout *aNavigationGridLayout = new QGridLayout( aNavigationGroupBox ); + aNavigationGridLayout->setHorizontalSpacing( 6 ); + aNavigationGridLayout->setVerticalSpacing( 6 ); + aNavigationGridLayout->setContentsMargins( 9, 9, 9, 9 ); - // Slider and time stamps - myFirstTimeStamp = new QLabel( aWidget ); - myFirstTimeStamp->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); - aLayout->addWidget( myFirstTimeStamp, 0, 0, Qt::AlignHCenter ); + myFirstTimeStamp = new QLabel( aNavigationGroupBox ); + myFirstTimeStamp->setAlignment( Qt::AlignRight | Qt::AlignTrailing | Qt::AlignVCenter ); + myFirstTimeStamp->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ); + aNavigationGridLayout->addWidget( myFirstTimeStamp, 0, 0, 1, 1 ); - mySlider = new QSlider( aWidget ); - mySlider->setMinimum( 0 ); - mySlider->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); + mySlider = new QSlider( aNavigationGroupBox ); + mySlider->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); + mySlider->setFocusPolicy( Qt::StrongFocus ); mySlider->setOrientation( Qt::Horizontal ); mySlider->setTracking( false ); - mySlider->setFocusPolicy(Qt::StrongFocus); - aLayout->addWidget( mySlider, 0, 1, 1, 8 ); - - myLastTimeStamp = new QLabel( aWidget ); - myLastTimeStamp->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); - aLayout->addWidget( myLastTimeStamp, 0, 9, Qt::AlignHCenter ); - - myTimeStampsNumber = new QLabel( aWidget ); - myTimeStampsNumber->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); - aLayout->addWidget( myTimeStampsNumber, 0, 10, Qt::AlignHCenter ); - - QLabel* aCacheMemoryLabel = new QLabel( tr( "CACHE_MEMORY" ), aWidget ); - aCacheMemoryLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); - aLayout->addWidget( aCacheMemoryLabel, 0, 11 ); - - myCacheMemory = new QLabel( aWidget ); - myCacheMemory->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); - QFontMetrics fm( myCacheMemory->font() ); - myCacheMemory->setFixedWidth( fm.width( "9.99E+99 Mb" ) ); - - aLayout->addWidget( myCacheMemory, 0, 12 ); - - // Buttons -#ifdef ENABLE_AVI_AND_MORE_BUTTONS - myMoreButton = new QToolButton( aWidget ); - myMoreButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); - myMoreButton->setEnabled( false ); - myMoreButton->setCheckble( true ); - myMoreButton->setIcon( aResourceMgr->loadPixmap( "VISU", tr( "ICON_SLIDER_MORE" ) ) ); - QToolTip::add( myMoreButton, tr( "MORE" ) ); - aLayout->addWidget( myMoreButton, 1, 0 ); - - myAVIButton = new QToolButton( aWidget ); - myAVIButton->setEnabled( false ); - myAVIButton->setCheckble( true ); - myAVIButton->setIcon( aResourceMgr->loadPixmap( "VISU", tr( "ICON_SLIDER_AVI" ) ) ); - QToolTip::add( myAVIButton, tr( "AVI" ) ); - aLayout->addWidget( myAVIButton, 1, 1 ); -#endif - - aLayout->addItem( new QSpacerItem( 24, 24, QSizePolicy::Expanding, QSizePolicy::Minimum ), 1, 2 ); - - myFirstButton = new QToolButton( aWidget ); + mySlider->setMinimum( 0 ); + + aNavigationGridLayout->addWidget( mySlider, 0, 1, 1, 5 ); + + myLastTimeStamp = new QLabel( aNavigationGroupBox ); + aNavigationGridLayout->addWidget( myLastTimeStamp, 0, 6, 1, 1 ); + + myTimeStampsNumber = new QLabel( aNavigationGroupBox ); + aNavigationGridLayout->addWidget( myTimeStampsNumber, 0, 7, 1, 1 ); + + myIsCycled = new QCheckBox( tr( "IS_CYCLED" ), aNavigationGroupBox ); + myIsCycled->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ); + myIsCycled->setLayoutDirection( Qt::LeftToRight ); + myIsCycled->setEnabled( false ); + + aNavigationGridLayout->addWidget( myIsCycled, 1, 0, 1, 1 ); + + myFirstButton = new QToolButton( aNavigationGroupBox ); myFirstButton->setIcon( aResourceMgr->loadPixmap( "VISU", tr( "ICON_SLIDER_FIRST" ) ) ); - aLayout->addWidget( myFirstButton, 1, 3 ); + myFirstButton->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); + aNavigationGridLayout->addWidget( myFirstButton, 1, 1, 1, 1 ); - myPreviousButton = new QToolButton( aWidget ); + myPreviousButton = new QToolButton( aNavigationGroupBox ); myPreviousButton->setIcon( aResourceMgr->loadPixmap( "VISU", tr( "ICON_SLIDER_PREVIOUS" ) ) ); - aLayout->addWidget( myPreviousButton, 1, 4 ); + myPreviousButton->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); + aNavigationGridLayout->addWidget( myPreviousButton, 1, 2, 1, 1 ); - myPlayButton = new QToolButton( aWidget ); + myPlayButton = new QToolButton( aNavigationGroupBox ); myPlayButton->setIcon( aResourceMgr->loadPixmap( "VISU", tr( "ICON_SLIDER_PLAY" ) ) ); + myPlayButton->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); myPlayButton->setCheckable( true ); - aLayout->addWidget( myPlayButton, 1, 5 ); + aNavigationGridLayout->addWidget( myPlayButton, 1, 3, 1, 1 ); - myNextButton = new QToolButton( aWidget ); + myNextButton = new QToolButton( aNavigationGroupBox ); myNextButton->setIcon( aResourceMgr->loadPixmap( "VISU", tr( "ICON_SLIDER_NEXT" ) ) ); - aLayout->addWidget( myNextButton, 1, 6 ); + myNextButton->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); + aNavigationGridLayout->addWidget( myNextButton, 1, 4, 1, 1 ); - myLastButton = new QToolButton( aWidget ); + myLastButton = new QToolButton(aNavigationGroupBox); myLastButton->setIcon( aResourceMgr->loadPixmap( "VISU", tr( "ICON_SLIDER_LAST" ) ) ); - aLayout->addWidget( myLastButton, 1, 7 ); - - aLayout->addItem( new QSpacerItem( 24, 24, QSizePolicy::Expanding, QSizePolicy::Minimum ), 1, 8 ); - - myTimeStampStrings = new QComboBox( aWidget ); - myTimeStampStrings->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); - myTimeStampStrings->setFocusPolicy(Qt::StrongFocus); - aLayout->addWidget( myTimeStampStrings, 1, 9 ); - - myTimeStampIndices = new QComboBox( aWidget ); - myTimeStampIndices->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); - myTimeStampIndices->setFocusPolicy(Qt::StrongFocus); - aLayout->addWidget( myTimeStampIndices, 1, 10 ); - - // Speed - QLabel* aSpeedLabel = new QLabel( tr( "SPEED" ), aWidget ); - aSpeedLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); - aLayout->addWidget( aSpeedLabel, 1, 11 ); - - mySpeedBox = new QSpinBox( aWidget ); - mySpeedBox->setMinimum( 1 ); - mySpeedBox->setMaximum( 100 ); - mySpeedBox->setSingleStep( 1 ); - mySpeedBox->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); - mySpeedBox->setFocusPolicy(Qt::StrongFocus); - mySpeedBox->setValue( 50 ); - aLayout->addWidget( mySpeedBox, 1, 12 ); + myLastButton->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); + aNavigationGridLayout->addWidget( myLastButton, 1, 5, 1, 1 ); + + myTimeStampStrings = new QComboBox( aNavigationGroupBox ); + myTimeStampStrings->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ); + myTimeStampStrings->setFocusPolicy( Qt::StrongFocus ); + aNavigationGridLayout->addWidget( myTimeStampStrings, 1, 6, 1, 1 ); + + myTimeStampIndexes = new QComboBox( aNavigationGroupBox ); + myTimeStampIndexes->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ); + myTimeStampIndexes->setFocusPolicy( Qt::StrongFocus ); + aNavigationGridLayout->addWidget( myTimeStampIndexes, 1, 7, 1, 1 ); + + aWidgetGridLayout->addWidget( aNavigationGroupBox, 0, 0, 1, 1 ); + + //---------------------------------------------------------------------------- + // Definition of the speed group box + QGroupBox* aSpeedGroupBox = new QGroupBox( tr( "SPEED" ), this ); + { + QHBoxLayout* aSpeedBoxLayout = new QHBoxLayout( aSpeedGroupBox ); + aSpeedBoxLayout->setSpacing( 6 ); + aSpeedBoxLayout->setContentsMargins( 9, 9, 9, 9 ); + + mySpeedSlider = new QSlider( aSpeedGroupBox ); + mySpeedSlider->setLayoutDirection( Qt::RightToLeft ); + mySpeedSlider->setMaximum( 100 ); + mySpeedSlider->setValue( 55 ); + mySpeedSlider->setOrientation( Qt::Vertical ); + mySpeedSlider->setTickPosition( QSlider::TicksBothSides ); + mySpeedSlider->setTickInterval( 20 ); + + aSpeedBoxLayout->addWidget( mySpeedSlider ); + } + aWidgetGridLayout->addWidget( aSpeedGroupBox, 0, 1, 2, 1 ); + + + //---------------------------------------------------------------------------- + QHBoxLayout* aMemoryBoxLayout = new QHBoxLayout(); + aMemoryBoxLayout->setSpacing( 6 ); + aMemoryBoxLayout->setContentsMargins( 0, 0, 0, 0 ); + + //---------------------------------------------------------------------------- + // Definition of the memory mode group box + QGroupBox* aModeGroupBox = new QGroupBox( tr( "MEMORY_MODE" ), this ); + { + QHBoxLayout* aMemoryModeBoxLayout = new QHBoxLayout( aModeGroupBox ); + aMemoryModeBoxLayout->setSpacing( 6 ); + aMemoryModeBoxLayout->setContentsMargins( 9, 9, 9, 9 ); + + myMinimalMemoryButton = new QRadioButton( tr( "MINIMAL_MEMORY" ), aModeGroupBox ); + aMemoryModeBoxLayout->addWidget( myMinimalMemoryButton ); + + QSpacerItem* aSpacer = new QSpacerItem( 40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + aMemoryModeBoxLayout->addItem( aSpacer ); + + myLimitedMemoryButton = new QRadioButton( tr( "LIMITED_MEMORY" ), aModeGroupBox ); + myLimitedMemoryButton->setChecked( true ); + aMemoryModeBoxLayout->addWidget( myLimitedMemoryButton ); + + myLimitedMemory = new QtxDoubleSpinBox( aModeGroupBox ); + myLimitedMemory->setMaximum( 10000 ); + myLimitedMemory->setValue( 512 ); + aMemoryModeBoxLayout->addWidget( myLimitedMemory ); + + QLabel* aMemoryDimensionLabel = new QLabel( aModeGroupBox ); + aMemoryDimensionLabel->setText( tr( "MEMORY_UNITS" ) ); + aMemoryModeBoxLayout->addWidget( aMemoryDimensionLabel ); + } + + aMemoryBoxLayout->addWidget( aModeGroupBox ); + //---------------------------------------------------------------------------- + // Definition of the memory state group box + QGroupBox* aStateGroupBox = new QGroupBox( tr( "MEMORY_STATE" ), this ); + { + QHBoxLayout* aMemoryStateBoxLayout = new QHBoxLayout( aStateGroupBox ); + aMemoryStateBoxLayout->setSpacing( 6 ); + aMemoryStateBoxLayout->setContentsMargins( 9, 9, 9, 9 ); + + QLabel* aUsedMemoryLabel = new QLabel( tr( "USED_BY_CACHE" ), aStateGroupBox ); + aMemoryStateBoxLayout->addWidget( aUsedMemoryLabel ); + + myUsedMemory = new QLineEdit( aStateGroupBox ); + myUsedMemory->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ); + myUsedMemory->setEnabled( false ); + aMemoryStateBoxLayout->addWidget( myUsedMemory ); + + QSpacerItem* aSpacer = new QSpacerItem( 40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + aMemoryStateBoxLayout->addItem( aSpacer ); + + QLabel* aFreeMemoryLabel = new QLabel( tr( "AVAILABLE_MEMORY" ), aStateGroupBox ); + aMemoryStateBoxLayout->addWidget( aFreeMemoryLabel ); + + myFreeMemory = new QLineEdit( aStateGroupBox ); + myFreeMemory->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ); + myFreeMemory->setEnabled( false ); + aMemoryStateBoxLayout->addWidget( myFreeMemory ); + } + + aMemoryBoxLayout->addWidget( aStateGroupBox ); + + aWidgetGridLayout->addLayout( aMemoryBoxLayout, 1, 0, 1, 1 ); + + //---------------------------------------------------------------------------- + QSpacerItem* spacerItem1 = new QSpacerItem( 20, 0, QSizePolicy::Minimum, QSizePolicy::Expanding ); + aWidgetGridLayout->addItem( spacerItem1, 2, 0, 1, 1 ); + + //---------------------------------------------------------------------------- myTimer = new QTimer( this ); // Common + connect( theModule, SIGNAL( moduleDeactivated() ), SLOT( onModuleDeactivated() ) ); + + connect( theModule, SIGNAL( moduleActivated() ), SLOT( onModuleActivated() ) ); + connect( mySelectionMgr, SIGNAL( currentSelectionChanged() ), SLOT( onSelectionChanged() ) ); connect( myTimeStampStrings, SIGNAL( activated( int ) ), SLOT( onTimeStampActivated( int ) ) ); - connect( myTimeStampIndices, SIGNAL( activated( int ) ), SLOT( onTimeStampActivated( int ) ) ); + connect( myTimeStampIndexes, SIGNAL( activated( int ) ), SLOT( onTimeStampActivated( int ) ) ); connect( myFirstButton, SIGNAL( clicked() ), SLOT( onFirst() ) ); connect( myPreviousButton, SIGNAL( clicked() ), SLOT( onPrevious() ) ); @@ -213,13 +273,20 @@ VisuGUI_Slider::VisuGUI_Slider( VisuGUI_Module* theModule, connect( mySlider, SIGNAL( valueChanged( int ) ), SLOT( onValueChanged( int ) ) ); - connect( mySpeedBox, SIGNAL( valueChanged( int ) ), SLOT( onSpeedChanged( int ) ) ); + connect( mySpeedSlider, SIGNAL( valueChanged( int ) ), SLOT( onSpeedChanged( int ) ) ); connect( myTimer, SIGNAL( timeout() ), SLOT( onTimeout() ) ); + //---------------------------------------------------------------------------- + connect( myLimitedMemoryButton, SIGNAL( toggled( bool ) ), myLimitedMemory, SLOT( setEnabled( bool ) ) ); + + //---------------------------------------------------------------------------- enableControls( false ); - myMainWindow->addToolBar( Qt::BottomToolBarArea, this ); + QtxDockWidget* aQtxDockWidget = new QtxDockWidget( true, theParent ); + theParent->addDockWidget( Qt::BottomDockWidgetArea , aQtxDockWidget ); + aQtxDockWidget->setWidget( this ); + aQtxDockWidget->show(); } /*! @@ -229,6 +296,16 @@ VisuGUI_Slider::~VisuGUI_Slider() { } +void VisuGUI_Slider::onModuleDeactivated() +{ + setHidden( true ); +} + +void VisuGUI_Slider::onModuleActivated() +{ + setHidden( false ); +} + bool VisuGUI_Slider::checkHolderList() { THolderList aHolderList; @@ -245,14 +322,15 @@ bool VisuGUI_Slider::checkHolderList() void VisuGUI_Slider::enableControls( bool on ) { - widgetForAction( myWidgetAction )->setEnabled( on ); + setEnabled( on ); + if( on ) { if( checkHolderList() ) return; myTimeStampStrings->clear(); - myTimeStampIndices->clear(); + myTimeStampIndexes->clear(); VISU::ColoredPrs3dHolder_var aHolder = myHolderList.front(); @@ -278,7 +356,7 @@ void VisuGUI_Slider::enableControls( bool on ) QString aTime = anInfo.myTime.in(); myTimeStampStrings->addItem( aTime ); - myTimeStampIndices->addItem( QString::number( aNumber ) ); + myTimeStampIndexes->addItem( QString::number( aNumber ) ); if( aNumber == aTimeStampNumber ) a_current_index = an_index; @@ -287,14 +365,14 @@ void VisuGUI_Slider::enableControls( bool on ) myTimeStampStrings->setFont(myTimeStampStrings->font()); myTimeStampStrings->updateGeometry(); - myTimeStampIndices->setFont(myTimeStampStrings->font()); - myTimeStampIndices->updateGeometry(); + myTimeStampIndexes->setFont(myTimeStampStrings->font()); + myTimeStampIndexes->updateGeometry(); if( a_current_index > mySlider->maximum() ) mySlider->setMaximum( aLength-1 ); myTimeStampStrings->setCurrentIndex( a_current_index ); - myTimeStampIndices->setCurrentIndex( a_current_index ); + myTimeStampIndexes->setCurrentIndex( a_current_index ); mySlider->setValue( a_current_index ); if( a_current_index <= mySlider->maximum() ) @@ -313,10 +391,19 @@ void VisuGUI_Slider::updateMemoryState() return; VISU::ColoredPrs3dHolder_var aHolder = myHolderList.front(); - VISU::ColoredPrs3dCache_var aCache = aHolder->GetCache(); + CORBA::Float aCacheMemory = aCache->GetMemorySize(); - myCacheMemory->setText( QString::number( double( aCacheMemory ), 'E', 2 ) + " Mb" ); + myUsedMemory->setText( QString::number( double( aCacheMemory ), 'E', 2 ) + " Mb" ); + myUsedMemory->setFont( myUsedMemory->font() ); + myUsedMemory->updateGeometry(); + + + long aMb = 1024 * 1024; + double aFreeMemory = (double)VISU_PipeLine::GetAvailableMemory( 2048 * aMb ) / (double)aMb; + myFreeMemory->setText( QString::number( double( aFreeMemory ), 'E', 2 ) + " Mb" ); + myFreeMemory->setFont( myFreeMemory->font() ); + myFreeMemory->updateGeometry(); } void VisuGUI_Slider::onSelectionChanged() @@ -384,7 +471,7 @@ void VisuGUI_Slider::onPlay( bool on ) { myPlayButton->setIcon( aResourceMgr->loadPixmap( "VISU", tr( "ICON_SLIDER_PAUSE" ) ) ); - int delay = int(5000.0 / double(mySpeedBox->value())); + int delay = int(5000.0 / double(mySpeedSlider->value())); myTimer->start( delay ); } else @@ -415,7 +502,7 @@ void VisuGUI_Slider::onValueChanged( int value ) } myTimeStampStrings->setCurrentIndex( value ); - myTimeStampIndices->setCurrentIndex( value ); + myTimeStampIndexes->setCurrentIndex( value ); VISU::ColoredPrs3dHolder_var aHolder = myHolderList.front(); @@ -430,6 +517,12 @@ void VisuGUI_Slider::onValueChanged( int value ) if(aNumber == aTimeStampNumber) return; + VISU::View_var aView = myViewManager->GetCurrentView(); + if ( CORBA::is_nil( aView.in() ) ) + return; + + VISU::View3D_var aView3D = VISU::View3D::_narrow( aView ); + THolderList::const_iterator anIter = myHolderList.begin(); THolderList::const_iterator anIterEnd = myHolderList.end(); for( ; anIter != anIterEnd; anIter++ ) @@ -444,18 +537,20 @@ void VisuGUI_Slider::onValueChanged( int value ) QApplication::setOverrideCursor(Qt::WaitCursor); - aHolder->Apply( aPrs3d, anInput, myView3D ); + aHolder->Apply( aPrs3d, anInput, aView3D ); QApplication::restoreOverrideCursor(); } + aView3D->Destroy(); + updateMemoryState(); } void VisuGUI_Slider::onSpeedChanged( int value ) { if(myPlayButton->isChecked()){ - int delay = int(5000.0 / double(mySpeedBox->value())); + int delay = int(5000.0 / double(mySpeedSlider->value())); myTimer->start( delay ); } } diff --git a/src/VISUGUI/VisuGUI_Slider.h b/src/VISUGUI/VisuGUI_Slider.h index 1347b650..ab8b5f5b 100644 --- a/src/VISUGUI/VisuGUI_Slider.h +++ b/src/VISUGUI/VisuGUI_Slider.h @@ -28,7 +28,8 @@ #ifndef VisuGUI_Slider_HeaderFile #define VisuGUI_Slider_HeaderFile -#include "QtxToolBar.h" +#include + #include #include "SALOMEconfig.h" @@ -45,23 +46,24 @@ class QLineEdit; class QToolButton; class QSlider; class QSpinBox; +class QCheckBox; +class QRadioButton; +class QMainWindow; class QTimer; -class QAction; -class VVTK_ViewWindow; -class VVTK_MainWindow; +class QtxDoubleSpinBox; class LightApp_SelectionMgr; +class VisuGUI; -class VisuGUI_Module; - -class VisuGUI_Slider : public QtxToolBar +class VisuGUI_Slider : public QWidget { - Q_OBJECT + Q_OBJECT; public: - VisuGUI_Slider( VisuGUI_Module* theModule, - VVTK_ViewWindow* theViewWindow, + VisuGUI_Slider( VisuGUI* theModule, + QMainWindow* theParent, LightApp_SelectionMgr* theSelectionMgr ); + virtual ~VisuGUI_Slider(); public slots: @@ -81,29 +83,25 @@ public slots: virtual void onTimeout(); +protected slots: + void onModuleDeactivated(); + void onModuleActivated(); + protected: virtual void enableControls( bool ); virtual void updateMemoryState(); virtual bool checkHolderList(); private: - VisuGUI_Module* myModule; - VVTK_MainWindow* myMainWindow; LightApp_SelectionMgr* mySelectionMgr; - VISU::View3D_var myView3D; + VISU::ViewManager_var myViewManager; QSlider* mySlider; QLabel* myFirstTimeStamp; QLabel* myLastTimeStamp; QLabel* myTimeStampsNumber; - QLabel* myCacheMemory; - -#ifdef ENABLE_AVI_AND_MORE_BUTTONS - QToolButton* myMoreButton; - QToolButton* myAVIButton; -#endif - + QCheckBox* myIsCycled; QToolButton* myFirstButton; QToolButton* myPreviousButton; QToolButton* myPlayButton; @@ -111,16 +109,21 @@ private: QToolButton* myLastButton; QComboBox* myTimeStampStrings; - QComboBox* myTimeStampIndices; + QComboBox* myTimeStampIndexes; + + QSlider* mySpeedSlider; - QSpinBox* mySpeedBox; + QRadioButton* myMinimalMemoryButton; + QRadioButton* myLimitedMemoryButton; + QtxDoubleSpinBox* myLimitedMemory; - QTimer* myTimer; + QLineEdit* myUsedMemory; + QLineEdit* myFreeMemory; typedef std::vector THolderList; - THolderList myHolderList; + THolderList myHolderList; - QAction* myWidgetAction; + QTimer* myTimer; }; #endif diff --git a/src/VISU_I/VISU_View_i.hh b/src/VISU_I/VISU_View_i.hh index c388740b..8ebf690f 100644 --- a/src/VISU_I/VISU_View_i.hh +++ b/src/VISU_I/VISU_View_i.hh @@ -28,6 +28,7 @@ #define VISU_View_i_HeaderFile #include "VISUConfig.hh" +#include "SALOME_GenericObj_i.hh" class QWidget; @@ -46,7 +47,8 @@ namespace VISU class Curve_i; class VISU_I_EXPORT View_i : public virtual POA_VISU::View, - public virtual Storable + public virtual SALOME::GenericObj_i, + public virtual Storable { public: View_i (SalomeApp_Application *theApplication, @@ -125,7 +127,7 @@ namespace VISU //=========================================================================== class VISU_I_EXPORT XYPlot_i : public virtual POA_VISU::XYPlot, - public virtual View_i + public virtual View_i { public: typedef VISU::XYPlot TInterface; @@ -216,7 +218,7 @@ namespace VISU //=========================================================================== class VISU_I_EXPORT View3D_i : public virtual POA_VISU::View3D, - public virtual View_i + public virtual View_i { public: typedef VISU::View3D TInterface; -- 2.39.2