Commit 83ae3a5a authored by Utkarsh Ayachit's avatar Utkarsh Ayachit

Fixed issues with Animation playback.

* The "AnimationTime" property wasn't getting updated since pqAnimationScene was
  listening to events on the proxy instead of the vtk-object. Fixed that.
* vtkPVAnimationScene was not forwarding start/end events from the player. This
  was resulting in the VCR control getting never swithcing to pause button when
  play was hit. Fixed that.
parent 17b4620e
......@@ -82,17 +82,19 @@ pqAnimationScene::pqAnimationScene(const QString& group, const QString& name,
vtkSMProxy* proxy, pqServer* server, QObject* _parent/*=NULL*/)
: pqProxy(group, name, proxy, server, _parent)
{
vtkObject* animationScene =
vtkObject::SafeDownCast(proxy->GetClientSideObject());
this->Internals = new pqAnimationScene::pqInternals();
vtkEventQtSlotConnect* connector = this->getConnector();
connector->Connect(proxy->GetProperty("Cues"),
vtkCommand::ModifiedEvent, this, SLOT(onCuesChanged()));
connector->Connect(proxy,
vtkCommand::AnimationCueTickEvent,
connector->Connect(animationScene, vtkCommand::AnimationCueTickEvent,
this, SLOT(onTick(vtkObject*, unsigned long, void*, void*)));
connector->Connect(proxy, vtkCommand::StartEvent,
connector->Connect(animationScene, vtkCommand::StartEvent,
this, SIGNAL(beginPlay()));
connector->Connect(proxy, vtkCommand::EndEvent,
connector->Connect(animationScene, vtkCommand::EndEvent,
this, SIGNAL(endPlay()));
connector->Connect(
......
......@@ -28,6 +28,7 @@ vtkPVAnimationScene::vtkPVAnimationScene()
this->AnimationCues = vtkCollection::New();
this->AnimationCuesIterator = this->AnimationCues->NewIterator();
this->SceneTime = 0;
this->InTick = false;
}
//----------------------------------------------------------------------------
......@@ -108,6 +109,8 @@ void vtkPVAnimationScene::StartCueInternal()
void vtkPVAnimationScene::TickInternal(
double currenttime, double deltatime, double clocktime)
{
bool previous = this->InTick;
this->InTick = true;
this->SceneTime = currenttime;
vtkCollectionIterator* iter = this->AnimationCuesIterator;
......@@ -135,6 +138,7 @@ void vtkPVAnimationScene::TickInternal(
}
this->Superclass::TickInternal(currenttime, deltatime, clocktime);
this->InTick = previous;
}
//----------------------------------------------------------------------------
......
......@@ -53,7 +53,12 @@ public:
// Description:
// Sets the current animation time.
void SetSceneTime(double time)
{
{
if (this->InTick)
{
// Since this method can be called during a Tick() event handler.
return;
}
this->Initialize();
this->Tick(time, 0, time);
}
......@@ -80,7 +85,8 @@ protected:
vtkCollection* AnimationCues;
vtkCollectionIterator* AnimationCuesIterator;
bool InTick;
double SceneTime;
private:
vtkPVAnimationScene(const vtkPVAnimationScene&); // Not implemented.
......
......@@ -14,13 +14,13 @@
=========================================================================*/
#include "vtkSMAnimationScene.h"
#include "vtkCommand.h"
#include "vtkCompositeAnimationPlayer.h"
#include "vtkEventForwarderCommand.h"
#include "vtkObjectFactory.h"
#include "vtkSmartPointer.h"
#include "vtkSMProperty.h"
#include "vtkSMPropertyHelper.h"
#include "vtkSMViewProxy.h"
#include "vtkSMProperty.h"
#include <vtkstd/vector>
......@@ -75,6 +75,13 @@ vtkSMAnimationScene::vtkSMAnimationScene()
// vtkAnimationPlayer::SetAnimationScene() is not reference counted.
this->AnimationPlayer->SetAnimationScene(this);
this->Internals = new vtkInternals();
this->Forwarder = vtkEventForwarderCommand::New();
this->Forwarder->SetTarget(this);
this->AnimationPlayer->AddObserver(
vtkCommand::StartEvent, this->Forwarder);
this->AnimationPlayer->AddObserver(
vtkCommand::EndEvent, this->Forwarder);
}
//----------------------------------------------------------------------------
......@@ -82,9 +89,13 @@ vtkSMAnimationScene::~vtkSMAnimationScene()
{
this->SetTimeKeeper(NULL);
this->AnimationPlayer->RemoveObserver(this->Forwarder);
this->AnimationPlayer->Delete();
this->AnimationPlayer = NULL;
this->Forwarder->SetTarget(NULL);
this->Forwarder->Delete();
delete this->Internals;
this->Internals = NULL;
}
......
......@@ -17,15 +17,18 @@
// .SECTION Description
// vtkSMAnimationScene subclasses vtkPVAnimationScene to add awareness about
// view proxies so that the scene can update view proxies using properties.
// vtkSMAnimationScene forwards the vtkCommand::StartEvent and
// vtkCommand::EndEvent from vtkCompositeAnimationPlayer to mark the start and
// end of animation playback.
#ifndef __vtkSMAnimationScene_h
#define __vtkSMAnimationScene_h
#include "vtkPVAnimationScene.h"
class vtkCompositeAnimationPlayer;
class vtkEventForwarderCommand;
class vtkSMProxy;
class vtkSMViewProxy;
class vtkCompositeAnimationPlayer;
class VTK_EXPORT vtkSMAnimationScene : public vtkPVAnimationScene
{
......@@ -111,6 +114,7 @@ protected:
bool LockEndTime;
vtkSMProxy* TimeKeeper;
vtkCompositeAnimationPlayer* AnimationPlayer;
vtkEventForwarderCommand* Forwarder;
friend class vtkSMAnimationSceneImageWriter;
bool OverrideStillRender;
......
......@@ -172,6 +172,8 @@ vtkObjectBase* vtkSMProxy::GetClientSideObject()
{
if (this->Session)
{
this->CreateVTKObjects();
vtkTypeUInt32 gid = this->GetGlobalID();
vtkPMProxy* pmproxy =
vtkPMProxy::SafeDownCast(this->Session->GetPMObject(gid));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment