From fa4e836c06e5e6f88da035528e46943430c1104c Mon Sep 17 00:00:00 2001 From: apo Date: Fri, 3 Nov 2006 09:59:03 +0000 Subject: [PATCH] To improve highlight method - selection will be extended on the pointed InteractiveObject --- src/VISUGUI/VisuGUI_Module.cxx | 7 +---- src/VISUGUI/VisuGUI_Slider.cxx | 51 +++++++++++++++++----------------- src/VISUGUI/VisuGUI_Slider.h | 12 ++++---- 3 files changed, 33 insertions(+), 37 deletions(-) diff --git a/src/VISUGUI/VisuGUI_Module.cxx b/src/VISUGUI/VisuGUI_Module.cxx index 2423eb33..5866c6df 100644 --- a/src/VISUGUI/VisuGUI_Module.cxx +++ b/src/VISUGUI/VisuGUI_Module.cxx @@ -423,12 +423,7 @@ onCreateViewManager() 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 ); - } + VisuGUI_Slider* aSlider = new VisuGUI_Slider( aViewWindow, anApp->selectionMgr() ); } return aViewer->getViewManager(); diff --git a/src/VISUGUI/VisuGUI_Slider.cxx b/src/VISUGUI/VisuGUI_Slider.cxx index d0ef34fc..88d423e7 100644 --- a/src/VISUGUI/VisuGUI_Slider.cxx +++ b/src/VISUGUI/VisuGUI_Slider.cxx @@ -32,7 +32,10 @@ #include "SVTK_Renderer.h" #include "SVTK_RenderWindowInteractor.h" -#include "SVTK_Selector.h" + +#include "VTKViewer_Algorithm.h" +#include "SVTK_Functor.h" + #include "SALOME_ListIteratorOfListIO.hxx" #include "VISU_Actor.h" @@ -56,9 +59,11 @@ /*! Constructor */ -VisuGUI_Slider::VisuGUI_Slider( VVTK_MainWindow* parent ) - : QtxDockWindow( InDock, parent ), - myMainWindow( parent ) +VisuGUI_Slider::VisuGUI_Slider( VVTK_ViewWindow* theViewWondow, + LightApp_SelectionMgr* theSelectionMgr ) + : QtxDockWindow( InDock, theViewWondow->getMainWindow1() ), + myMainWindow( theViewWondow->getMainWindow1() ), + mySelectionMgr( theSelectionMgr ) { //SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr(); @@ -122,7 +127,7 @@ VisuGUI_Slider::VisuGUI_Slider( VVTK_MainWindow* parent ) new QLabel( tr( "SPEED" ), aBottomBox ); mySpeedBox = new QSpinBox( 1, 100, 1, aBottomBox ); - mySpeedBox->setValue( 10 ); + mySpeedBox->setValue( 50 ); myAVIBox = new QCheckBox( tr( "AVI" ), aBottomBox ); myAVIBox->setEnabled( false ); @@ -133,6 +138,8 @@ VisuGUI_Slider::VisuGUI_Slider( VVTK_MainWindow* parent ) aLayout->addWidget( aTopBox ); aLayout->addWidget( aBottomBox ); + connect( mySelectionMgr, SIGNAL( currentSelectionChanged() ), SLOT( onSelectionChanged() ) ); + connect( myTimeStampStrings, SIGNAL( activated( int ) ), SLOT( onTimeStampActivated( int ) ) ); connect( myTimeStampIndices, SIGNAL( activated( int ) ), SLOT( onTimeStampActivated( int ) ) ); @@ -149,6 +156,8 @@ VisuGUI_Slider::VisuGUI_Slider( VVTK_MainWindow* parent ) connect( myTimer, SIGNAL( timeout() ), SLOT( onTimeout() ) ); enableControls( false ); + + myMainWindow->addDockWindow( this, Qt::DockBottom ); } /*! @@ -158,14 +167,6 @@ 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(); @@ -179,8 +180,8 @@ void VisuGUI_Slider::enableControls( bool on ) VISU::ColoredPrs3d_i* aPrs = myPrsList[0]; CORBA::Long aTimeStampNumber = aPrs->GetTimeStampNumber(); - VISU::ColoredPrs3d::TimeStampsRange aTimeStampsRange = *(aPrs->GetTimeStampsRange()); - CORBA::Long aLength = aTimeStampsRange.length(); + VISU::ColoredPrs3d::TimeStampsRange_var aTimeStampsRange = aPrs->GetTimeStampsRange(); + CORBA::Long aLength = aTimeStampsRange->length(); mySlider->setMinValue( 0 ); mySlider->setMaxValue( aLength-1 ); @@ -215,26 +216,24 @@ void VisuGUI_Slider::enableControls( bool 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_ListIO aListIO; + mySelectionMgr->selectedObjects(aListIO); SALOME_ListIteratorOfListIO anIter( aListIO ); + vtkActorCollection* anActorCollection = myMainWindow->getRenderer()->GetActors(); for( int k = 0; anIter.More(); anIter.Next() ) { - if( VISU_Actor* anActor = dynamic_cast( aSelector->GetActor( anIter.Value() ) ) ) + VISU_Actor* anActor = + SVTK::Find(anActorCollection, SVTK::TIsSameIObject(anIter.Value())); + if( anActor ) { 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 ) + if( !aPrs->IsTimeStampFixed() ) { //cout << "ColoredPrs3d" << endl; myPrsList.resize(k+1); @@ -277,7 +276,7 @@ void VisuGUI_Slider::onPlay( bool on ) { myPlayButton->setText( "||" ); - double delay = 5000.0 / ( double )mySpeedBox->value(); + int delay = int(5000.0 / double(mySpeedBox->value())); myTimer->start( delay ); } else @@ -315,7 +314,7 @@ void VisuGUI_Slider::onValueChanged( int value ) myTimeStampIndices->setCurrentItem( value ); VISU::ColoredPrs3d_i* aPrs = myPrsList[0]; - VISU::ColoredPrs3d::TimeStampsRange aTimeStampsRange = *(aPrs->GetTimeStampsRange()); + VISU::ColoredPrs3d::TimeStampsRange_var aTimeStampsRange = aPrs->GetTimeStampsRange(); CORBA::Long aNumber = aTimeStampsRange[ value ].myNumber; for( int i = 0, n = myPrsList.size(); i < n; i++ ) diff --git a/src/VISUGUI/VisuGUI_Slider.h b/src/VISUGUI/VisuGUI_Slider.h index e7b3cbb1..872b8bdc 100644 --- a/src/VISUGUI/VisuGUI_Slider.h +++ b/src/VISUGUI/VisuGUI_Slider.h @@ -29,10 +29,10 @@ #define VisuGUI_Slider_HeaderFile #include "VisuGUI.h" - -#include "QtxDockWindow.h" - #include "VISU_ColoredPrs3d_i.hh" +#include "VVTK_ViewWindow.h" +#include "LightApp_SelectionMgr.h" +#include "QtxDockWindow.h" typedef std::vector PrsList; @@ -45,6 +45,7 @@ class QSpinBox; class QTimer; class VVTK_MainWindow; +class LightApp_SelectionMgr; class VisuGUI_Slider : public QtxDockWindow { @@ -54,11 +55,11 @@ public: enum { First = 0, Previous, Next, Last }; public: - VisuGUI_Slider( VVTK_MainWindow* ); + VisuGUI_Slider( VVTK_ViewWindow* theViewWondow, + LightApp_SelectionMgr* theSelectionMgr ); virtual ~VisuGUI_Slider(); public: - virtual void addToWindow( VVTK_MainWindow* ); virtual void enableControls( bool ); @@ -81,6 +82,7 @@ public slots: private: VVTK_MainWindow* myMainWindow; + LightApp_SelectionMgr* mySelectionMgr; QSlider* mySlider; QLabel* myFirstTimeStamp; -- 2.39.2