From: apo Date: Thu, 15 May 2008 12:47:36 +0000 (+0000) Subject: Implementation of the sweep functionality X-Git-Tag: TG_VISU_2008_2008-06-26~44 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=87aaba3ab4aa39c38d1a5b9bf6027cfe237857d6;p=modules%2Fvisu.git Implementation of the sweep functionality --- diff --git a/src/VISUGUI/Makefile.am b/src/VISUGUI/Makefile.am index aed0f567..e0544ae6 100644 --- a/src/VISUGUI/Makefile.am +++ b/src/VISUGUI/Makefile.am @@ -72,6 +72,7 @@ dist_libVISU_la_SOURCES= \ VisuGUI_TransparencyDlg.cxx \ VisuGUI_Timer.cxx \ VisuGUI_Slider.cxx \ + VisuGUI_Sweep.cxx \ VisuGUI_InputPane.cxx \ VisuGUI_CacheDlg.cxx \ VisuGUI_FieldFilter.cxx \ @@ -109,6 +110,7 @@ MOC_FILES= \ VisuGUI_BuildProgressDlg_moc.cxx \ VisuGUI_TransparencyDlg_moc.cxx \ VisuGUI_Slider_moc.cxx \ + VisuGUI_Sweep_moc.cxx \ VisuGUI_InputPane_moc.cxx \ VisuGUI_CacheDlg_moc.cxx \ VisuGUI_ViewExtender_moc.cxx \ diff --git a/src/VISUGUI/VISU_images.ts b/src/VISUGUI/VISU_images.ts index dd7a9d46..46aac25d 100644 --- a/src/VISUGUI/VISU_images.ts +++ b/src/VISUGUI/VISU_images.ts @@ -278,6 +278,10 @@ ICON_VVTK_RECORDING_STOP Visu_recording_stop.png + + ICON_SWEEP_STOP + Visu_recording_stop.png + ICON_VVTK_SELECTION_MODE_SWITCH Visu_points.png diff --git a/src/VISUGUI/VISU_msg_en.ts b/src/VISUGUI/VISU_msg_en.ts index 96593c8c..57f26ebc 100644 --- a/src/VISUGUI/VISU_msg_en.ts +++ b/src/VISUGUI/VISU_msg_en.ts @@ -2825,6 +2825,31 @@ Please, provide non-empty resulting presentation. Do you want to choose all items with the same units for vertical axis? + + VisuGUI_Sweep + + TITLESweep + + NAVIGATION_TABNavigation + START_SWEEP_POSITION0 % + END_SWEEP_POSITION100 % + IS_CYCLEDCycled + + PROPERTIES_TABProperties + + MODEMode: + LINEARLinear + COSINUSOIDAL1 - cos( t ) / 2 + SINUSOIDALsin( t - Pi / 2 ) + + NUMBER_OF_STEPSNumber Steps: + + INTERVALInterval + [ 0, +PI ][ 0, +PI ] + [ -PI, +PI ][ -PI, +PI ] + + DELAY_BETWEEN_STEPSStep Dealy [ sec ]: + VisuGUI_Slider diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index 4c299b75..6cb20abf 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -1008,36 +1008,6 @@ VisuGUI } -namespace -{ - //---------------------------------------------------------------------------- - bool - GetPrs3dSelectionInfo(const SalomeApp_Module* theModule, - VISU::Prs3d_i*& thePrs3d, - SVTK_ViewWindow*& theViewWindow, - VISU_Actor*& thenActor) - { - VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(theModule); - if(aSelectionInfo.empty()) - return false; - - VISU::TSelectionItem aSelectionItem = aSelectionInfo.front(); - thePrs3d = GetPrs3dFromBase(aSelectionItem.myObjectInfo.myBase); - if(!thePrs3d) - return false; - - theViewWindow = GetActiveViewWindow(theModule); - if(!theViewWindow) - return false; - - thenActor = FindActor(theViewWindow, thePrs3d); - if(!thenActor) - return false; - - return true; - } -} - //---------------------------------------------------------------------------- void VisuGUI @@ -1670,64 +1640,7 @@ void VisuGUI ::OnSweep() { - VISU_Actor* anActor = NULL; - VISU::Prs3d_i* aPrs3d = NULL; - SVTK_ViewWindow* aViewWindow = NULL; - if(!GetPrs3dSelectionInfo(this, aPrs3d, aViewWindow, anActor)) - return; - - VISU::ScalarMap_i* aScalarMap = dynamic_cast(aPrs3d); - if(!aScalarMap) - return; - - if(!anActor->GetVisibility()) - anActor->VisibilityOn(); - - // Get sweep parameters - SUIT_ResourceMgr* aResourceMgr = GetResourceMgr(); - - double aTempoDbl = aResourceMgr->doubleValue("VISU", "sweeping_time_step", 0.1); - int aTemp = int(1.E6 * aTempoDbl); - - int aCycles = aResourceMgr->integerValue("VISU", "sweeping_number_cycles", 1); - int aSteps = aResourceMgr->integerValue("VISU", "sweeping_number_steps", 40); - - int aMode = aResourceMgr->integerValue("VISU", "sweeping_modes", 0); - - int is2Pi = aResourceMgr->integerValue("VISU", "sweeping_is2PI", 0); - - // Sweep - QApplication::setOverrideCursor(Qt::WaitCursor); - - for (int j = 0; j < aCycles; j++) { - for (int i = 0; i <= aSteps; i++) { - try { - float aPercents; - float aT; - if( aMode >= 1 ) - aT = ( is2Pi == 1 ? -PI + 2. * PI * float(i)/aSteps : PI * float(i)/aSteps ); - if( aMode == 1 ){ //if selected Periodic cosinusoidal mode of sweeping - //This is necessary in order for animation to return to the initial picture - aPercents = (1.-cos( aT ))/2.; - } - else if( aMode == 2 ){ //if selected Periodic sinusoidal mode of sweeping - //This is necessary in order for animation to return to the initial picture - aPercents = sin( aT - PI/2 ); - } - else //if selected Linear mode of sweeping - aPercents = float(i)/aSteps; - aScalarMap->SetMapScale(aPercents); - aScalarMap->UpdateActor(anActor); - aViewWindow->getRenderWindow()->Render(); - usleep(aTemp); - } catch (std::exception& exc) { - INFOS("Follow exception was occured :\n" << exc.what()); - } catch (...) { - INFOS("Unknown exception was occured!"); - } - } - } - QApplication::restoreOverrideCursor(); + new VisuGUI_Sweep( this, getApp()->desktop(), getApp()->selectionMgr() ); } //---------------------------------------------------------------------------- diff --git a/src/VISUGUI/VisuGUI_Sweep.cxx b/src/VISUGUI/VisuGUI_Sweep.cxx new file mode 100644 index 00000000..54b8d2e8 --- /dev/null +++ b/src/VISUGUI/VisuGUI_Sweep.cxx @@ -0,0 +1,499 @@ +// VISU VISUGUI : GUI of VISU component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// +// File : VisuGUI_Slider.cxx +// Author : Oleg UVAROV +// Module : VISU + +#include "VisuGUI_Sweep.h" + +#include "SUIT_ResourceMgr.h" + +#include "LightApp_SelectionMgr.h" + +#include "VISU_Actor.h" + +#include "VisuGUI.h" +#include "VisuGUI_Tools.h" +#include "VISU_ScalarMap_i.hh" +#include "VISU_Actor.h" + +#include "QtxDockWidget.h" +#include "QtxIntSpinBox.h" +#include "QtxDoubleSpinBox.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +/*! + Constructor +*/ +VisuGUI_Sweep::VisuGUI_Sweep( VisuGUI* theModule, + QMainWindow* theParent, + LightApp_SelectionMgr* theSelectionMgr ) + : QWidget( theParent ) + , myModule( theModule ) + , myViewWindow( NULL ) + , myScalarMap( NULL ) + , myActor( NULL ) +{ + setWindowTitle( tr("TITLE") ); + + SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr(); + + //---------------------------------------------------------------------------- + QVBoxLayout* aVBoxLayout = new QVBoxLayout( this ); + + QTabWidget* aTabWidget = new QTabWidget( this ); + aVBoxLayout->addWidget( aTabWidget ); + + { + QWidget* aNavigationTab = new QWidget(); + { + QVBoxLayout* aVBoxLayout = new QVBoxLayout( aNavigationTab ); + { + QHBoxLayout* aHBoxLayout = new QHBoxLayout(); + + QLabel* aStartSweepPosition = new QLabel( aNavigationTab ); + aStartSweepPosition->setText( tr( "START_SWEEP_POSITION" ) ); + aHBoxLayout->addWidget( aStartSweepPosition ); + + mySweepSlider = new QSlider( aNavigationTab ); + mySweepSlider->setOrientation( Qt::Horizontal ); + mySweepSlider->setMinimum( 0 ); + aHBoxLayout->addWidget( mySweepSlider ); + + QLabel* anEndSweepPosition = new QLabel( aNavigationTab ); + anEndSweepPosition->setText( tr( "END_SWEEP_POSITION" ) ); + aHBoxLayout->addWidget( anEndSweepPosition ); + + aVBoxLayout->addLayout( aHBoxLayout ); + } + { + QHBoxLayout* aHBoxLayout = new QHBoxLayout(); + + myFirstButton = new QToolButton( aNavigationTab ); + myFirstButton->setIcon( aResourceMgr->loadPixmap( "VISU", tr( "ICON_SLIDER_FIRST" ) ) ); + myFirstButton->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); + connect( myFirstButton, SIGNAL( clicked() ), SLOT( onFirst() ) ); + aHBoxLayout->addWidget( myFirstButton ); + + myPreviousButton = new QToolButton( aNavigationTab ); + myPreviousButton->setIcon( aResourceMgr->loadPixmap( "VISU", tr( "ICON_SLIDER_PREVIOUS" ) ) ); + myPreviousButton->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); + connect( myPreviousButton, SIGNAL( clicked() ), SLOT( onPrevious() ) ); + aHBoxLayout->addWidget( myPreviousButton ); + + myPlayButton = new QToolButton( aNavigationTab ); + myPlayButton->setIcon( aResourceMgr->loadPixmap( "VISU", tr( "ICON_SLIDER_PLAY" ) ) ); + myPlayButton->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); + myPlayButton->setCheckable( true ); + aHBoxLayout->addWidget( myPlayButton ); + + myNextButton = new QToolButton( aNavigationTab ); + myNextButton->setIcon( aResourceMgr->loadPixmap( "VISU", tr( "ICON_SLIDER_NEXT" ) ) ); + myNextButton->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); + connect( myNextButton, SIGNAL( clicked() ), SLOT( onNext() ) ); + aHBoxLayout->addWidget( myNextButton ); + + myLastButton = new QToolButton( aNavigationTab ); + myLastButton->setIcon( aResourceMgr->loadPixmap( "VISU", tr( "ICON_SLIDER_LAST" ) ) ); + myLastButton->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); + connect( myLastButton, SIGNAL( clicked() ), SLOT( onLast() ) ); + aHBoxLayout->addWidget( myLastButton ); + + aVBoxLayout->addLayout( aHBoxLayout ); + } + { + QHBoxLayout* aHBoxLayout = new QHBoxLayout(); + + QToolButton* aStopButton = new QToolButton( aNavigationTab ); + aStopButton->setIcon( aResourceMgr->loadPixmap( "VISU", tr( "ICON_SWEEP_STOP" ) ) ); + aStopButton->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); + aStopButton->setCheckable( true ); + connect( aStopButton, SIGNAL( toggled( bool ) ), SLOT( onStop( bool ) ) ); + aHBoxLayout->addWidget( aStopButton ); + + myIsCycled = new QCheckBox( aNavigationTab ); + myIsCycled->setText( tr( "IS_CYCLED" ) ); + myIsCycled->setChecked( true ); + aHBoxLayout->addWidget( myIsCycled ); + + aVBoxLayout->addLayout( aHBoxLayout ); + } + { + QSpacerItem* aSpacerItem = new QSpacerItem( 16, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); + aVBoxLayout->addItem( aSpacerItem ); + } + + aTabWidget->addTab( aNavigationTab, tr( "NAVIGATION_TAB" ) ); + } + } + { + QWidget* aPropertiesTab = new QWidget(); + + QVBoxLayout* aVBoxLayout = new QVBoxLayout( aPropertiesTab ); + { + QGridLayout* aGridLayout = new QGridLayout( aPropertiesTab ); + + QLabel* aModeAnnotation = new QLabel( aPropertiesTab ); + aModeAnnotation->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Preferred ); + aModeAnnotation->setText( tr( "MODE" ) ); + aGridLayout->addWidget( aModeAnnotation, 0, 0 ); + + mySweepMode = new QComboBox( aPropertiesTab ); + mySweepMode->insertItems( 0, QStringList() + << tr( "LINEAR" ) + << tr( "COSINUSOIDAL" ) + << tr( "SINUSOIDAL" ) ); + mySweepMode->setCurrentIndex( aResourceMgr->integerValue( "VISU", "sweeping_modes", 0 ) ); + aGridLayout->addWidget( mySweepMode, 0, 1 ); + + myIntervals = new QComboBox( aPropertiesTab ); + myIntervals->insertItems( 0, QStringList() + << tr( "[ 0, +PI ]" ) + << tr( "[ -PI, +PI ]" ) ); + myIntervals->setCurrentIndex( aResourceMgr->integerValue( "VISU", "sweeping_is2PI", 0 ) ); + aGridLayout->addWidget( myIntervals, 0, 2 ); + + QLabel* aNumberOfStepsAnnotation = new QLabel( aPropertiesTab ); + aNumberOfStepsAnnotation->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Preferred ); + aNumberOfStepsAnnotation->setText( tr( "NUMBER_OF_STEPS" ) ); + aGridLayout->addWidget( aNumberOfStepsAnnotation, 1, 0 ); + + myNumberOfSteps = new QtxIntSpinBox( aPropertiesTab ); + connect( myNumberOfSteps, SIGNAL( valueChanged( int ) ), SLOT( onNumberOfStepsChanged( int ) ) ); + myNumberOfSteps->setValue( aResourceMgr->integerValue( "VISU", "sweeping_number_steps", 40 ) ); + aGridLayout->addWidget( myNumberOfSteps, 1, 1, 1, 2 ); + + QLabel* aStepDelayAnnotation = new QLabel( aPropertiesTab ); + aStepDelayAnnotation->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Preferred ); + aStepDelayAnnotation->setText( tr( "DELAY_BETWEEN_STEPS" ) ); + aGridLayout->addWidget( aStepDelayAnnotation, 2, 0 ); + + myStepDelay = new QtxDoubleSpinBox( aPropertiesTab ); + myStepDelay->setValue( aResourceMgr->doubleValue("VISU", "sweeping_time_step", 0.1) ); + aGridLayout->addWidget( myStepDelay, 2, 1, 1, 2 ); + + QSpacerItem* aSpacerItem = new QSpacerItem( 16, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); + aGridLayout->addItem( aSpacerItem, 3, 0 ); + + aVBoxLayout->addLayout( aGridLayout ); + } + + aTabWidget->addTab( aPropertiesTab, tr( "PROPERTIES_TAB" ) ); + } + + { + QSpacerItem* aSpacerItem = new QSpacerItem( 16, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); + aVBoxLayout->addItem( aSpacerItem ); + } + + + //---------------------------------------------------------------------------- + QtxDockWidget* aQtxDockWidget = new QtxDockWidget( true, theParent ); + theParent->addDockWidget( Qt::BottomDockWidgetArea , aQtxDockWidget ); + aQtxDockWidget->setWidget( this ); + aQtxDockWidget->show(); + + + //---------------------------------------------------------------------------- + myTimer = new QTimer( this ); + + connect( myTimer, SIGNAL( timeout() ), SLOT( onTimeout() ) ); + + connect( myPlayButton, SIGNAL( toggled( bool ) ), SLOT( onPlay( bool ) ) ); + + connect( mySweepSlider, SIGNAL( valueChanged( int ) ), SLOT( onValueChanged( int ) ) ); + + connect( myStepDelay, SIGNAL( valueChanged( double ) ), SLOT( onDelayChanged( double ) ) ); + + connect( mySweepMode, SIGNAL( currentIndexChanged( int ) ), SLOT( onModeChanged( int ) ) ); + + connect( theModule, SIGNAL( moduleDeactivated() ), SLOT( onModuleDeactivated() ) ); + + connect( theModule, SIGNAL( moduleActivated() ), SLOT( onModuleActivated() ) ); + + connect( theSelectionMgr, SIGNAL( currentSelectionChanged() ), SLOT( onSelectionChanged() ) ); + + onSelectionChanged(); + + onModeChanged( mySweepMode->currentIndex() ); + + onPlay( true ); +} + + +//---------------------------------------------------------------------------- +VisuGUI_Sweep::~VisuGUI_Sweep() +{} + + +//---------------------------------------------------------------------------- +void VisuGUI_Sweep::onModuleDeactivated() +{ + setHidden( true ); + + onStop( true ); +} + + +//---------------------------------------------------------------------------- +void VisuGUI_Sweep::onModuleActivated() +{ + setHidden( false ); +} + + +//---------------------------------------------------------------------------- +namespace +{ + struct TEnabler + { + VisuGUI_Sweep* myWidget; + VISU_Actor*& myActor; + + TEnabler( VisuGUI_Sweep* theWidget, VISU_Actor*& theActor ) + : myWidget( theWidget ) + , myActor( theActor ) + {} + + ~TEnabler() + { + myWidget->setEnabled( myActor ); + myWidget->onStop( !myActor ); + } + }; +} + + +//---------------------------------------------------------------------------- +void VisuGUI_Sweep::onSelectionChanged() +{ + VISU_Actor* anActor = NULL; + VISU::Prs3d_i* aPrs3d = NULL; + SVTK_ViewWindow* aViewWindow = NULL; + + TEnabler anEnabler( this, anActor ); + + if( !VISU::GetPrs3dSelectionInfo( myModule, aPrs3d, aViewWindow, anActor ) ) + return; + + if ( anActor == myActor ) + return; + + VISU::ScalarMap_i* aScalarMap = dynamic_cast< VISU::ScalarMap_i* >( aPrs3d ); + if ( !aScalarMap ) + return; + + if ( myActor ) { + myScalarMap->SetMapScale( 1.0 ); + myScalarMap->UpdateActor( myActor ); + myViewWindow->Repaint(); + } + + if ( anActor && !anActor->GetVisibility() ) + anActor->VisibilityOn(); + + myViewWindow = aViewWindow; + myScalarMap = aScalarMap; + myActor = anActor; +} + + +//---------------------------------------------------------------------------- +void VisuGUI_Sweep::onValueChanged( int value ) +{ + if ( !myActor ) + return; + + QApplication::setOverrideCursor(Qt::WaitCursor); + + int aSweepMode = mySweepMode->currentIndex(); + int aNbSteps = myNumberOfSteps->value(); + + double anArgument = double( value ) / aNbSteps; + + int anIntervalMode = myIntervals->currentIndex(); + // To correct the input value according to the given interval mode + if ( aSweepMode != 0 ) { + switch ( anIntervalMode ) { + case 0 : + anArgument = vtkMath::Pi() * anArgument; + break; + case 1 : + anArgument = -vtkMath::Pi() + 2.0 * vtkMath::Pi() * anArgument; + break; + default : + break; + } + } + + // To correct the input value according to the given sweep mode + double aValue = anArgument; + switch ( aSweepMode ) { + case 1 : + aValue = ( 1.0 - cos( anArgument ) ) / 2.0; + break; + case 2 : + aValue = sin( anArgument - vtkMath::Pi() / 2.0 ); + break; + default : + break; + } + +// cout << "VisuGUI_Sweep::onValueChanged - ( " << value +// << "; " << anArgument +// << "; " << aValue +// << ")" << endl; + + try { + myScalarMap->SetMapScale( aValue ); + myScalarMap->UpdateActor( myActor ); + myViewWindow->Repaint(); + } catch (std::exception& exc) { + INFOS( "Follow exception was occured :\n" << exc.what() ); + } catch (...) { + INFOS( "Unknown exception was occured!" ); + } + + QApplication::restoreOverrideCursor(); +} + + +//---------------------------------------------------------------------------- +void VisuGUI_Sweep::onDelayChanged( double value ) +{ + myTimer->start( int( value * 1000 ) ); +} + + +//---------------------------------------------------------------------------- +void VisuGUI_Sweep::onNumberOfStepsChanged( int value ) +{ + int anOldNumberOfSteps = mySweepSlider->maximum(); + mySweepSlider->setMaximum( value ); + + double aNewSweepValue = value / anOldNumberOfSteps * mySweepSlider->value(); + mySweepSlider->setValue( int( aNewSweepValue ) ); + + double aNewPageStep = value / anOldNumberOfSteps * mySweepSlider->pageStep(); + mySweepSlider->setPageStep( int( aNewPageStep ) ); +} + + +//---------------------------------------------------------------------------- +void VisuGUI_Sweep::onModeChanged( int ) +{ + myIntervals->setEnabled( mySweepMode->currentIndex() != 0 ); +} + + +//---------------------------------------------------------------------------- +void VisuGUI_Sweep::onFirst() +{ + mySweepSlider->setValue( mySweepSlider->minimum() ); +} + + +//---------------------------------------------------------------------------- +void VisuGUI_Sweep::onPrevious() +{ + mySweepSlider->setValue( mySweepSlider->value() - 1 ); +} + +void VisuGUI_Sweep::onNext() +{ + mySweepSlider->setValue( mySweepSlider->value() + 1 ); +} + +void VisuGUI_Sweep::onLast() +{ + mySweepSlider->setValue( mySweepSlider->maximum() ); +} + +//---------------------------------------------------------------------------- +void VisuGUI_Sweep::onPlay( bool on ) +{ + SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr(); + if ( on ) { + myPlayButton->setIcon( aResourceMgr->loadPixmap( "VISU", tr( "ICON_SLIDER_PAUSE" ) ) ); + myTimer->start( int( myStepDelay->value() * 1000 ) ); + myPlayButton->setChecked( true ); + } else { + myTimer->stop(); + myPlayButton->setChecked( false ); + myPlayButton->setIcon( aResourceMgr->loadPixmap( "VISU", tr( "ICON_SLIDER_PLAY" ) ) ); + } +} + + +//---------------------------------------------------------------------------- +void VisuGUI_Sweep::onStop( bool on ) +{ + onPlay( false ); + + mySweepSlider->setValue( mySweepSlider->maximum() ); + + mySweepSlider->setEnabled( !on ); + + myFirstButton->setEnabled( !on ); + myPreviousButton->setEnabled( !on ); + + myPlayButton->setEnabled( !on ); + + myNextButton->setEnabled( !on ); + myLastButton->setEnabled( !on ); +} + + +//---------------------------------------------------------------------------- +void VisuGUI_Sweep::onTimeout() +{ + int value = mySweepSlider->value(); + if ( value < mySweepSlider->maximum() ) { + mySweepSlider->setValue( value + 1 ); + } else { + if ( myIsCycled->isChecked() ) + mySweepSlider->setValue( 0 ); + else + myPlayButton->setChecked( false ); + //myStopButton->setEnabled( false ); + } +} + + +//---------------------------------------------------------------------------- diff --git a/src/VISUGUI/VisuGUI_Sweep.h b/src/VISUGUI/VisuGUI_Sweep.h new file mode 100644 index 00000000..6d03d71a --- /dev/null +++ b/src/VISUGUI/VisuGUI_Sweep.h @@ -0,0 +1,127 @@ +// VISU VISUGUI : GUI of VISU component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// +// File : VisuGUI_Sweep.h +// Author : Oleg UVAROV +// Module : VISU + +#ifndef VisuGUI_Sweep_HeaderFile +#define VisuGUI_Sweep_HeaderFile + +#include + +class QComboBox; +class QToolButton; +class QSlider; +class QSpinBox; +class QCheckBox; +class QMainWindow; +class QTimer; + +class QtxIntSpinBox; +class QtxDoubleSpinBox; + +class LightApp_SelectionMgr; +class SVTK_ViewWindow; +class VISU_Actor; +class VisuGUI; + + +namespace VISU +{ + class ScalarMap_i; +} + + +//---------------------------------------------------------------------------- +class VisuGUI_Sweep : public QWidget +{ + Q_OBJECT; + +public: + VisuGUI_Sweep( VisuGUI* theModule, + QMainWindow* theParent, + LightApp_SelectionMgr* theSelectionMgr ); + + virtual ~VisuGUI_Sweep(); + +public slots: + virtual void onSelectionChanged(); + + virtual void onFirst(); + + virtual void onPrevious(); + + virtual void onPlay( bool ); + + virtual void onNext(); + + virtual void onLast(); + + virtual void onStop( bool ); + + virtual void onValueChanged( int ); + + virtual void onDelayChanged( double ); + + virtual void onNumberOfStepsChanged( int ); + + virtual void onModeChanged( int ); + + virtual void onTimeout(); + + void onModuleDeactivated(); + + void onModuleActivated(); + +private: + QSlider* mySweepSlider; + + QToolButton* myFirstButton; + QToolButton* myPreviousButton; + QToolButton* myPlayButton; + QToolButton* myNextButton; + QToolButton* myLastButton; + + QCheckBox* myIsCycled; + + QComboBox* mySweepMode; + QtxIntSpinBox* myNumberOfSteps; + + QComboBox* myIntervals; + QtxDoubleSpinBox* myStepDelay; + + QTimer* myTimer; + + VisuGUI* myModule; + + VISU_Actor* myActor; + VISU::ScalarMap_i* myScalarMap; + SVTK_ViewWindow* myViewWindow; +}; + + +//---------------------------------------------------------------------------- + + +#endif diff --git a/src/VISUGUI/VisuGUI_Tools.h b/src/VISUGUI/VisuGUI_Tools.h index 8e69af3d..2d68def7 100644 --- a/src/VISUGUI/VisuGUI_Tools.h +++ b/src/VISUGUI/VisuGUI_Tools.h @@ -121,6 +121,11 @@ namespace VISU VISU::Prs3d_i* GetPrs3dFromBase(Base_i* theBase); + bool GetPrs3dSelectionInfo( const SalomeApp_Module* theModule, + VISU::Prs3d_i*& thePrs3d, + SVTK_ViewWindow*& theViewWindow, + VISU_Actor*& thenActor ); + //---------------------------------------------------------------------------- void Add(LightApp_SelectionMgr* theSelectionMgr, const Handle(SALOME_InteractiveObject)& theIO);