~TEnabler()
{
- myWidget->setEnabled( myIsValidSelection );
myWidget->onStop( !myIsValidSelection );
}
};
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;
}
//----------------------------------------------------------------------------
void VisuGUI_Sweep::onValueChanged( int value )
{
- if ( !myActor )
+ bool anIsValidSelection = ( myScalarMap && myActor.GetPointer() );
+
+ TEnabler anEnabler( this, anIsValidSelection );
+
+ if ( !anIsValidSelection )
return;
QApplication::setOverrideCursor(Qt::WaitCursor);
//----------------------------------------------------------------------------
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();
}