// ESAF : Euso Simulation and Analysis Framework
// $Id: EAnimator.cc,v 1.1 2004/08/06 00:44:48 thea Exp $
// Author: A.Thea Aug, 5 2004
#include "EAnimator.hh"
#include "TTimer.h"
#include "TPad.h"
ClassImp(EAnimator)
//_____________________________________________________________________________
EAnimator::EAnimator() {
//
// Constructor
//
fTimer = new TTimer(100);
fFrame = 0;
fNumFrames = 0;
}
//_____________________________________________________________________________
EAnimator::~EAnimator() {
//
// Destructor
//
if ( fTimer ) delete fTimer;
}
//_____________________________________________________________________________
void EAnimator::Play( Option_t *opt ) {
//
// Start the movie
//
if ( gPad ) gPad->Clear();
TString option(opt);
Draw( option.Data() );
fTimer->Connect("Timeout()",IsA()->GetName(), this, "Animate()" );
Rewind();
Info("Play","Animation started");
fTimer->TurnOn();
}
//_____________________________________________________________________________
void EAnimator::Stop() {
//
// Stop the movie
//
fTimer->TurnOff();
Info("Stop","Animation completed");
}
//_____________________________________________________________________________
void EAnimator::Animate() {
//
// Move to next animation step and increase the counter
//
if ( IsEnded() ) {
// leave the last frame to be painted
fFrame = fNumFrames-1;
Stop();
return;
}
NextFrame();
if ( gPad ) {
gPad->Modified();
gPad->Update();
}
}