From 0c6510de4b5d2a1c0853e8a7351277e0ba3ba440 Mon Sep 17 00:00:00 2001 From: ouv Date: Thu, 2 Nov 2006 12:42:15 +0000 Subject: [PATCH] "Play" functionality --- src/VISUGUI/VisuGUI_Slider.cxx | 30 ++++++++++++++++++++++++++++-- src/VISUGUI/VisuGUI_Slider.h | 5 +++++ 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src/VISUGUI/VisuGUI_Slider.cxx b/src/VISUGUI/VisuGUI_Slider.cxx index 667ded43..d0ef34fc 100644 --- a/src/VISUGUI/VisuGUI_Slider.cxx +++ b/src/VISUGUI/VisuGUI_Slider.cxx @@ -51,6 +51,7 @@ #include #include #include +#include /*! Constructor @@ -89,8 +90,10 @@ VisuGUI_Slider::VisuGUI_Slider( VVTK_MainWindow* parent ) myTimeStampsNumber->setText( "" ); myTimeStampStrings = new QComboBox( aTopBox ); + myTimeStampStrings->setFixedWidth( 120 ); myTimeStampIndices = new QComboBox( aTopBox ); + myTimeStampIndices->setFixedWidth( 50 ); // Buttons QHBox* aBottomBox = new QHBox( aWidget ); @@ -124,6 +127,8 @@ VisuGUI_Slider::VisuGUI_Slider( VVTK_MainWindow* parent ) myAVIBox = new QCheckBox( tr( "AVI" ), aBottomBox ); myAVIBox->setEnabled( false ); + myTimer = new QTimer( this ); + // Common aLayout->addWidget( aTopBox ); aLayout->addWidget( aBottomBox ); @@ -141,6 +146,8 @@ VisuGUI_Slider::VisuGUI_Slider( VVTK_MainWindow* parent ) connect( mySlider, SIGNAL( sliderMoved( int ) ), SLOT( onSliderMoved( int ) ) ); connect( mySlider, SIGNAL( valueChanged( int ) ), SLOT( onValueChanged( int ) ) ); + connect( myTimer, SIGNAL( timeout() ), SLOT( onTimeout() ) ); + enableControls( false ); } @@ -266,8 +273,18 @@ void VisuGUI_Slider::onPrevious() void VisuGUI_Slider::onPlay( bool on ) { - QString aText = on ? "||" : ">"; - myPlayButton->setText( aText ); + if( on ) + { + myPlayButton->setText( "||" ); + + double delay = 5000.0 / ( double )mySpeedBox->value(); + myTimer->start( delay ); + } + else + { + myTimer->stop(); + myPlayButton->setText( ">" ); + } } void VisuGUI_Slider::onNext() @@ -310,3 +327,12 @@ void VisuGUI_Slider::onValueChanged( int value ) myMainWindow->Repaint(); } + +void VisuGUI_Slider::onTimeout() +{ + int value = mySlider->value(); + if( value < mySlider->maxValue() ) + onNext(); + else + myPlayButton->setOn( false ); +} diff --git a/src/VISUGUI/VisuGUI_Slider.h b/src/VISUGUI/VisuGUI_Slider.h index 57c2db5f..e7b3cbb1 100644 --- a/src/VISUGUI/VisuGUI_Slider.h +++ b/src/VISUGUI/VisuGUI_Slider.h @@ -42,6 +42,7 @@ class QLabel; class QPushButton; class QSlider; class QSpinBox; +class QTimer; class VVTK_MainWindow; @@ -76,6 +77,8 @@ public slots: virtual void onSliderMoved( int ); virtual void onValueChanged( int ); + virtual void onTimeout(); + private: VVTK_MainWindow* myMainWindow; @@ -97,6 +100,8 @@ private: QSpinBox* mySpeedBox; QCheckBox* myAVIBox; + QTimer* myTimer; + PrsList myPrsList; }; -- 2.39.2