--- /dev/null
+// 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 <vtkActorCollection.h>
+#include <vtkRenderer.h>
+
+#include <qcheckbox.h>
+#include <qcombobox.h>
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qhbox.h>
+#include <qpushbutton.h>
+#include <qslider.h>
+#include <qspinbox.h>
+
+/*!
+ 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<VISU_Actor*>( aSelector->GetActor( anIter.Value() ) ) )
+ {
+ if( !anActor->GetVisibility() )
+ continue;
+
+ if( VISU::ColoredPrs3d_i* aPrs = dynamic_cast<VISU::ColoredPrs3d_i*>( 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();
+}
--- /dev/null
+// 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<VISU::ColoredPrs3d_i*> 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