Skip to content
Snippets Groups Projects
Commit 8551e89f authored by Nicolas Cadart's avatar Nicolas Cadart
Browse files

[fix][ui] Avoid speed factor change when going previous/next frame

Going previous/next frame changes animation mode to 'Snap To Timesteps'.
This will set the speed factor text to 'All frames'.
Currently, user has to set back themselves the desired speed factor using the combo box.

This commit restores previous animation play mode after having snaped to previous/next frame,
so that user does not have to set it themselves again using the speed factor combo box.

Also, if we are in 'Real Time' play mode with for example a speed factor 'x5',
and if we click Next frame, the speed factor will blink to 'All frames' before going back to 'x5'.
As this blink is noisy, we block all animations signals to keep it unchanged during operation.
parent 46e2e999
No related branches found
No related tags found
1 merge request!148Using custom animation play mode in LidarView
Pipeline #202347 failed
Pipeline: LidarView

#202348

    ...@@ -61,6 +61,11 @@ void SetProperty(QPointer<pqAnimationScene> scene, const char* property, int val ...@@ -61,6 +61,11 @@ void SetProperty(QPointer<pqAnimationScene> scene, const char* property, int val
    (scene->getProxy()->GetProperty(property))->SetElements1(value); (scene->getProxy()->GetProperty(property))->SetElements1(value);
    scene->getProxy()->UpdateProperty(property); scene->getProxy()->UpdateProperty(property);
    } }
    int GetProperty(QPointer<pqAnimationScene> scene, const char* property)
    {
    return pqSMAdaptor::getElementProperty(scene->getProxy()->GetProperty(property)).toInt();
    }
    } }
    //----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
    ...@@ -242,6 +247,11 @@ void lqPlayerControlsController::onFirstFrame() ...@@ -242,6 +247,11 @@ void lqPlayerControlsController::onFirstFrame()
    //----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
    void lqPlayerControlsController::onPreviousFrame() void lqPlayerControlsController::onPreviousFrame()
    { {
    // Get current animation PlayMode, and disable its signals so that toolbar
    // will not be updated to avoid blinking
    int playMode = GetProperty(this->Scene, "PlayMode");
    bool signalsWereBlocked = this->Scene->blockSignals(true);
    emit this->beginNonUndoableChanges(); emit this->beginNonUndoableChanges();
    SetProperty(this->Scene, "PlayMode", 2); SetProperty(this->Scene, "PlayMode", 2);
    this->Scene->getProxy()->InvokeCommand("GoToPrevious"); this->Scene->getProxy()->InvokeCommand("GoToPrevious");
    ...@@ -249,11 +259,20 @@ void lqPlayerControlsController::onPreviousFrame() ...@@ -249,11 +259,20 @@ void lqPlayerControlsController::onPreviousFrame()
    .arg(this->Scene->getProxy()) .arg(this->Scene->getProxy())
    .arg("GoToPrevious"); .arg("GoToPrevious");
    emit this->endNonUndoableChanges(); emit this->endNonUndoableChanges();
    // Restore animation PlayMode and signals
    SetProperty(this->Scene, "PlayMode", playMode);
    this->Scene->blockSignals(signalsWereBlocked);
    } }
    //----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
    void lqPlayerControlsController::onNextFrame() void lqPlayerControlsController::onNextFrame()
    { {
    // Get current animation PlayMode, and disable its signals so that toolbar
    // will not be updated to avoid blinking
    int playMode = GetProperty(this->Scene, "PlayMode");
    bool signalsWereBlocked = this->Scene->blockSignals(true);
    emit this->beginNonUndoableChanges(); emit this->beginNonUndoableChanges();
    SetProperty(this->Scene, "PlayMode", 2); SetProperty(this->Scene, "PlayMode", 2);
    this->Scene->getProxy()->InvokeCommand("GoToNext"); this->Scene->getProxy()->InvokeCommand("GoToNext");
    ...@@ -261,6 +280,10 @@ void lqPlayerControlsController::onNextFrame() ...@@ -261,6 +280,10 @@ void lqPlayerControlsController::onNextFrame()
    .arg(this->Scene->getProxy()) .arg(this->Scene->getProxy())
    .arg("GoToNext"); .arg("GoToNext");
    emit this->endNonUndoableChanges(); emit this->endNonUndoableChanges();
    // Restore animation PlayMode and signals
    SetProperty(this->Scene, "PlayMode", playMode);
    this->Scene->blockSignals(signalsWereBlocked);
    } }
    //----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
    ......
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Finish editing this message first!
    Please register or to comment