#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 <vtkActorCollection.h>
#include <vtkRenderer.h>
+#include <QMainWindow>
#include <QComboBox>
#include <QFont>
#include <QLabel>
#include <QToolTip>
#include <QSlider>
#include <QSpinBox>
+#include <QGroupBox>
+#include <QCheckBox>
+#include <QRadioButton>
#include <QTimer>
/*!
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() ) );
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();
}
/*!
{
}
+void VisuGUI_Slider::onModuleDeactivated()
+{
+ setHidden( true );
+}
+
+void VisuGUI_Slider::onModuleActivated()
+{
+ setHidden( false );
+}
+
bool VisuGUI_Slider::checkHolderList()
{
THolderList aHolderList;
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();
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;
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() )
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()
{
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
}
myTimeStampStrings->setCurrentIndex( value );
- myTimeStampIndices->setCurrentIndex( value );
+ myTimeStampIndexes->setCurrentIndex( value );
VISU::ColoredPrs3dHolder_var aHolder = myHolderList.front();
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++ )
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 );
}
}