From: ouv Date: Thu, 2 Nov 2006 10:13:27 +0000 (+0000) Subject: Basic realization of VisuGUI_Slider X-Git-Tag: WP1_2_3_06-10-2006~18 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=d208ef72daf5b5b5d18c1240ba6f73d754c39c08;p=modules%2Fvisu.git Basic realization of VisuGUI_Slider --- diff --git a/src/VISUGUI/Makefile.in b/src/VISUGUI/Makefile.in index b3eaeb69..bf48a9ec 100644 --- a/src/VISUGUI/Makefile.in +++ b/src/VISUGUI/Makefile.in @@ -75,7 +75,8 @@ LIB_SRC = VisuGUI.cxx \ VisuGUI_SetupPlot2dDlg.cxx \ VisuGUI_BuildProgressDlg.cxx \ VisuGUI_TransparencyDlg.cxx \ - VisuGUI_Timer.cxx + VisuGUI_Timer.cxx \ + VisuGUI_Slider.cxx LIB_MOC = VisuGUI.h \ VisuGUI_Module.h \ @@ -100,7 +101,8 @@ LIB_MOC = VisuGUI.h \ VisuGUI_ScalarMapOnDeformedShapeDlg.h \ VisuGUI_SetupPlot2dDlg.h \ VisuGUI_BuildProgressDlg.h \ - VisuGUI_TransparencyDlg.h + VisuGUI_TransparencyDlg.h \ + VisuGUI_Slider.h LIB_CLIENT_IDL = SALOME_Exception.idl \ VISU_Gen.idl \ diff --git a/src/VISUGUI/VISU_msg_en.po b/src/VISUGUI/VISU_msg_en.po index eebc49c8..63a9c4cd 100644 --- a/src/VISUGUI/VISU_msg_en.po +++ b/src/VISUGUI/VISU_msg_en.po @@ -1594,6 +1594,15 @@ msgstr "Quality" msgid "VisuGUI_Module::VISU_RECORDER_PREF_PROGRESSIVE" msgstr "Progressive" +msgid "VisuGUI_Slider::MORE" +msgstr "More..." + +msgid "VisuGUI_Slider::SPEED" +msgstr "Speed:" + +msgid "VisuGUI_Slider::AVI" +msgstr "AVI" + msgid "VisuGUI_GaussPointsDlg::DLG_PREF_TITLE" msgstr "Gauss Points Preferences" diff --git a/src/VISUGUI/VisuGUI_Module.cxx b/src/VISUGUI/VisuGUI_Module.cxx index 37d38e66..2423eb33 100644 --- a/src/VISUGUI/VisuGUI_Module.cxx +++ b/src/VISUGUI/VisuGUI_Module.cxx @@ -65,6 +65,8 @@ #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" @@ -418,7 +420,16 @@ onCreateViewManager() new LightApp_VTKSelector( aViewer, anApp->selectionMgr() ); anApp->addViewManager( aViewManager ); - aViewManager->createViewWindow(); + VVTK_ViewWindow* aViewWindow = ( VVTK_ViewWindow* )aViewManager->createViewWindow(); + if( aViewWindow ) + { + VVTK_MainWindow* aMainWindow = aViewWindow->getMainWindow1(); + if( aMainWindow ) + { + VisuGUI_Slider* aSlider = new VisuGUI_Slider( aMainWindow ); + aSlider->addToWindow( aMainWindow ); + } + } return aViewer->getViewManager(); } diff --git a/src/VISUGUI/VisuGUI_Slider.cxx b/src/VISUGUI/VisuGUI_Slider.cxx new file mode 100644 index 00000000..667ded43 --- /dev/null +++ b/src/VISUGUI/VisuGUI_Slider.cxx @@ -0,0 +1,312 @@ +// 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_Slider.h" + +#include "SUIT_Session.h" +#include "SUIT_ResourceMgr.h" + +#include "SVTK_Renderer.h" +#include "SVTK_RenderWindowInteractor.h" +#include "SVTK_Selector.h" +#include "SALOME_ListIteratorOfListIO.hxx" + +#include "VISU_Actor.h" + +#include "VVTK_MainWindow.h" +#include "VVTK_ViewWindow.h" + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +/*! + Constructor +*/ +VisuGUI_Slider::VisuGUI_Slider( VVTK_MainWindow* parent ) + : QtxDockWindow( InDock, parent ), + myMainWindow( parent ) +{ + //SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr(); + + setHorizontallyStretchable( true ); + + QWidget* aWidget = new QWidget( this ); + setWidget( aWidget ); + + QVBoxLayout* aLayout = new QVBoxLayout( aWidget, 11, 6 ); + + // Slider and time stamps + QHBox* aTopBox = new QHBox( aWidget ); + aTopBox->setSpacing( 6 ); + + myFirstTimeStamp = new QLabel( aTopBox ); + myFirstTimeStamp->setMinimumWidth( 50 ); + myFirstTimeStamp->setText( "" ); + + mySlider = new QSlider( 0, 1, 1, 0, Qt::Horizontal, aTopBox ); + //mySlider->setTickmarks( QSlider::Below ); + mySlider->setTracking( false ); + + myLastTimeStamp = new QLabel( aTopBox ); + myLastTimeStamp->setMinimumWidth( 50 ); + myLastTimeStamp->setText( "" ); + + myTimeStampsNumber = new QLabel( aTopBox ); + myTimeStampsNumber->setMinimumWidth( 50 ); + myTimeStampsNumber->setText( "" ); + + myTimeStampStrings = new QComboBox( aTopBox ); + + myTimeStampIndices = new QComboBox( aTopBox ); + + // Buttons + QHBox* aBottomBox = new QHBox( aWidget ); + aBottomBox->setSpacing( 6 ); + + myMoreButton = new QPushButton( tr( "MORE" ), aBottomBox ); + myMoreButton->setMaximumWidth( 100 ); + myMoreButton->setToggleButton( true ); + myMoreButton->setEnabled( false ); + + myFirstButton = new QPushButton( tr( "|<<" ), aBottomBox ); + myFirstButton->setMaximumWidth( 100 ); + + myPreviousButton = new QPushButton( tr( "<<" ), aBottomBox ); + myPreviousButton->setMaximumWidth( 100 ); + + myPlayButton = new QPushButton( tr( ">" ), aBottomBox ); + myPlayButton->setMaximumWidth( 100 ); + myPlayButton->setToggleButton( true ); + + myNextButton = new QPushButton( tr( ">>" ), aBottomBox ); + myNextButton->setMaximumWidth( 100 ); + + myLastButton = new QPushButton( tr( ">>|" ), aBottomBox ); + myLastButton->setMaximumWidth( 100 ); + + new QLabel( tr( "SPEED" ), aBottomBox ); + mySpeedBox = new QSpinBox( 1, 100, 1, aBottomBox ); + mySpeedBox->setValue( 10 ); + + myAVIBox = new QCheckBox( tr( "AVI" ), aBottomBox ); + myAVIBox->setEnabled( false ); + + // Common + aLayout->addWidget( aTopBox ); + aLayout->addWidget( aBottomBox ); + + connect( myTimeStampStrings, SIGNAL( activated( int ) ), SLOT( onTimeStampActivated( int ) ) ); + connect( myTimeStampIndices, SIGNAL( activated( int ) ), SLOT( onTimeStampActivated( int ) ) ); + + connect( myMoreButton, SIGNAL( toggled( bool ) ), SLOT( onMore( bool ) ) ); + connect( myFirstButton, SIGNAL( clicked() ), SLOT( onFirst() ) ); + connect( myPreviousButton, SIGNAL( clicked() ), SLOT( onPrevious() ) ); + connect( myPlayButton, SIGNAL( toggled( bool ) ), SLOT( onPlay( bool ) ) ); + connect( myNextButton, SIGNAL( clicked() ), SLOT( onNext() ) ); + connect( myLastButton, SIGNAL( clicked() ), SLOT( onLast() ) ); + + connect( mySlider, SIGNAL( sliderMoved( int ) ), SLOT( onSliderMoved( int ) ) ); + connect( mySlider, SIGNAL( valueChanged( int ) ), SLOT( onValueChanged( int ) ) ); + + enableControls( false ); +} + +/*! + Destructor +*/ +VisuGUI_Slider::~VisuGUI_Slider() +{ +} + +void VisuGUI_Slider::addToWindow( VVTK_MainWindow* theMainWindow ) +{ + theMainWindow->addDockWindow( this, Qt::DockBottom ); + + connect( theMainWindow->GetInteractor(), SIGNAL( selectionChanged() ), + SLOT( onSelectionChanged() ) ); +} + +void VisuGUI_Slider::enableControls( bool on ) +{ + myTimeStampStrings->clear(); + myTimeStampIndices->clear(); + mySlider->setMinValue( 0 ); + mySlider->setMaxValue( 0 ); + mySlider->setValue( 0 ); + + if( on ) + { + VISU::ColoredPrs3d_i* aPrs = myPrsList[0]; + + CORBA::Long aTimeStampNumber = aPrs->GetTimeStampNumber(); + VISU::ColoredPrs3d::TimeStampsRange aTimeStampsRange = *(aPrs->GetTimeStampsRange()); + CORBA::Long aLength = aTimeStampsRange.length(); + + mySlider->setMinValue( 0 ); + mySlider->setMaxValue( aLength-1 ); + + myFirstTimeStamp->setText( aTimeStampsRange[0].myTime.in() ); + myLastTimeStamp->setText( aTimeStampsRange[aLength-1].myTime.in() ); + myTimeStampsNumber->setText( QString("(") + QString::number( aLength ) + ")" ); + + int current = 0; + for( int index = 0; index < aLength; index++ ) + { + VISU::ColoredPrs3d::TimeStampInfo anInfo = aTimeStampsRange[ index ]; + long aNumber = anInfo.myNumber; + const char* aTime = anInfo.myTime.in(); + + myTimeStampStrings->insertItem( aTime ); + myTimeStampIndices->insertItem( QString::number( aNumber ) ); + + if( aNumber == aTimeStampNumber ) + current = index; + } + + mySlider->setValue( current ); + } + else + { + myPlayButton->setOn( false ); + } + + widget()->setEnabled( on ); +} + +void VisuGUI_Slider::onSelectionChanged() +{ + //cout << "VisuGUI_Slider::onSelectionChanged" << endl; + + myPrsList.resize(0); + + SVTK_Selector* aSelector = myMainWindow->GetSelector(); + const SALOME_ListIO& aListIO = aSelector->StoredIObjects(); + SALOME_ListIteratorOfListIO anIter( aListIO ); + for( int k = 0; anIter.More(); anIter.Next() ) + { + if( VISU_Actor* anActor = dynamic_cast( aSelector->GetActor( anIter.Value() ) ) ) + { + if( !anActor->GetVisibility() ) + continue; + + if( VISU::ColoredPrs3d_i* aPrs = dynamic_cast( anActor->GetPrs3d() ) ) + { + CORBA::Long aTimeStampNumber = aPrs->GetTimeStampNumber(); + VISU::ColoredPrs3d::TimeStampsRange aTimeStampsRange = *(aPrs->GetTimeStampsRange()); + CORBA::Long aLength = aTimeStampsRange.length(); + if( aLength > 1 ) + { + //cout << "ColoredPrs3d" << endl; + myPrsList.resize(k+1); + myPrsList[k] = aPrs; + k++; + } + } + } + } + + enableControls( myPrsList.size() != 0 ); +} + +void VisuGUI_Slider::onTimeStampActivated( int value ) +{ + mySlider->setValue( value ); + onValueChanged( value ); +} + +void VisuGUI_Slider::onMore( bool ) +{ +} + +void VisuGUI_Slider::onFirst() +{ + int value = mySlider->minValue(); + mySlider->setValue( value ); +} + +void VisuGUI_Slider::onPrevious() +{ + int value = mySlider->value() - 1; + if( value >= mySlider->minValue() ) + mySlider->setValue( value ); +} + +void VisuGUI_Slider::onPlay( bool on ) +{ + QString aText = on ? "||" : ">"; + myPlayButton->setText( aText ); +} + +void VisuGUI_Slider::onNext() +{ + int value = mySlider->value() + 1; + if( value <= mySlider->maxValue() ) + mySlider->setValue( value ); +} + +void VisuGUI_Slider::onLast() +{ + int value = mySlider->maxValue(); + mySlider->setValue( value ); +} + +void VisuGUI_Slider::onSliderMoved( int value ) +{ +} + +void VisuGUI_Slider::onValueChanged( int value ) +{ + //cout << "VisuGUI_Slider::onValueChanged " << value << endl; + + if( myPrsList.size() == 0 ) + return; + + myTimeStampStrings->setCurrentItem( value ); + myTimeStampIndices->setCurrentItem( value ); + + VISU::ColoredPrs3d_i* aPrs = myPrsList[0]; + VISU::ColoredPrs3d::TimeStampsRange aTimeStampsRange = *(aPrs->GetTimeStampsRange()); + CORBA::Long aNumber = aTimeStampsRange[ value ].myNumber; + + for( int i = 0, n = myPrsList.size(); i < n; i++ ) + { + aPrs = myPrsList[i]; + aPrs->SetTimeStampNumber( aNumber ); + aPrs->Apply(); + } + + myMainWindow->Repaint(); +} diff --git a/src/VISUGUI/VisuGUI_Slider.h b/src/VISUGUI/VisuGUI_Slider.h new file mode 100644 index 00000000..57c2db5f --- /dev/null +++ b/src/VISUGUI/VisuGUI_Slider.h @@ -0,0 +1,103 @@ +// 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.h +// Author : Oleg UVAROV +// Module : VISU + +#ifndef VisuGUI_Slider_HeaderFile +#define VisuGUI_Slider_HeaderFile + +#include "VisuGUI.h" + +#include "QtxDockWindow.h" + +#include "VISU_ColoredPrs3d_i.hh" + +typedef std::vector PrsList; + +class QCheckBox; +class QComboBox; +class QLabel; +class QPushButton; +class QSlider; +class QSpinBox; + +class VVTK_MainWindow; + +class VisuGUI_Slider : public QtxDockWindow +{ + Q_OBJECT + +public: + enum { First = 0, Previous, Next, Last }; + +public: + VisuGUI_Slider( VVTK_MainWindow* ); + virtual ~VisuGUI_Slider(); + +public: + virtual void addToWindow( VVTK_MainWindow* ); + + virtual void enableControls( bool ); + +public slots: + virtual void onSelectionChanged(); + + virtual void onTimeStampActivated( int ); + + virtual void onMore( bool ); + virtual void onFirst(); + virtual void onPrevious(); + virtual void onPlay( bool ); + virtual void onNext(); + virtual void onLast(); + + virtual void onSliderMoved( int ); + virtual void onValueChanged( int ); + +private: + VVTK_MainWindow* myMainWindow; + + QSlider* mySlider; + QLabel* myFirstTimeStamp; + QLabel* myLastTimeStamp; + QLabel* myTimeStampsNumber; + + QComboBox* myTimeStampStrings; + QComboBox* myTimeStampIndices; + + QPushButton* myMoreButton; + QPushButton* myFirstButton; + QPushButton* myPreviousButton; + QPushButton* myPlayButton; + QPushButton* myNextButton; + QPushButton* myLastButton; + + QSpinBox* mySpeedBox; + QCheckBox* myAVIBox; + + PrsList myPrsList; +}; + +#endif