From 6215596cd2f85ea3e2f296420b37c7ff257f0366 Mon Sep 17 00:00:00 2001 From: apo Date: Tue, 24 Jun 2008 12:44:01 +0000 Subject: [PATCH] Debugging of the sweep functionality 1. To check whether current VTK view is alive or destroyed. 2. To restore initial state on sweep interraption. --- src/VISUGUI/VisuGUI_Sweep.cxx | 54 +++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 22 deletions(-) diff --git a/src/VISUGUI/VisuGUI_Sweep.cxx b/src/VISUGUI/VisuGUI_Sweep.cxx index 5a2f81c9..db1c841c 100644 --- a/src/VISUGUI/VisuGUI_Sweep.cxx +++ b/src/VISUGUI/VisuGUI_Sweep.cxx @@ -304,7 +304,6 @@ namespace ~TEnabler() { - myWidget->setEnabled( myIsValidSelection ); myWidget->onStop( !myIsValidSelection ); } }; @@ -320,30 +319,36 @@ void VisuGUI_Sweep::onSelectionChanged() bool anIsValidSelection = VISU::GetPrs3dSelectionInfo( myModule, aPrs3d, aViewWindow, anActor ); + // To instantiate special helper class which will analyze validity of selection + // and make appropritate actions TEnabler anEnabler( this, anIsValidSelection ); - if ( !anIsValidSelection ) - return; + anIsValidSelection &= bool( aViewWindow ); - if ( myActor.GetPointer() == anActor ) - return; + // To keep the pointer on the view window properly it is necessary to get known when + // it will be destroyed + if ( myViewWindow != aViewWindow ) { + if ( myViewWindow ) + disconnect( myViewWindow, SIGNAL( destroyed( QObject * ) ), this, SLOT( onSelectionChanged() ) ); + + myViewWindow = aViewWindow; + + if ( myViewWindow ) + connect( myViewWindow, SIGNAL( destroyed( QObject * ) ), this, SLOT( onSelectionChanged() ) ); + } VISU::ScalarMap_i* aScalarMap = dynamic_cast< VISU::ScalarMap_i* >( aPrs3d ); anIsValidSelection &= ( aScalarMap && aScalarMap->IsTimeStampFixed() ); - if ( !anIsValidSelection ) - return; - if ( myActor.GetPointer() ) { + if ( myScalarMap ) { myScalarMap->SetMapScale( 1.0 ); - myScalarMap->UpdateActor( myActor ); - myViewWindow->Repaint(); + myScalarMap->UpdateActors(); } - if ( anActor && !anActor->GetVisibility() ) - anActor->VisibilityOn(); - - myViewWindow = aViewWindow; myScalarMap = aScalarMap; + + anIsValidSelection &= ( anActor && anActor->GetVisibility() ); + myActor = anActor; } @@ -351,7 +356,11 @@ void VisuGUI_Sweep::onSelectionChanged() //---------------------------------------------------------------------------- void VisuGUI_Sweep::onValueChanged( int value ) { - if ( !myActor ) + bool anIsValidSelection = ( myScalarMap && myActor.GetPointer() ); + + TEnabler anEnabler( this, anIsValidSelection ); + + if ( !anIsValidSelection ) return; QApplication::setOverrideCursor(Qt::WaitCursor); @@ -484,21 +493,22 @@ void VisuGUI_Sweep::onToggleView( bool on ) //---------------------------------------------------------------------------- void VisuGUI_Sweep::onStop( bool on ) { - onPlay( false ); - - mySweepSlider->setValue( mySweepSlider->maximum() ); + if ( 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 ); - if (myViewWindow) + if ( on && myViewWindow ) myViewWindow->Repaint(); } -- 2.39.2