refactor of VtkCallbackCommand to be its' own class
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
#include "TimerCallbackCommand.h"
|
||||
#include "../helperClasses/Program.h"
|
||||
|
||||
|
||||
// TimerCallbackCommand::TimerCallbackCommand() : dt(3600), maxTime(3600*24*365), time(0) {}
|
||||
|
||||
TimerCallbackCommand *New() {
|
||||
TimerCallbackCommand *cb = new TimerCallbackCommand();
|
||||
cb->setDefaults();
|
||||
return cb;
|
||||
}
|
||||
|
||||
void TimerCallbackCommand::Execute(vtkObject *caller, long unsigned int eventId, void* clientData, void* callData) {
|
||||
this->time += this->dt;
|
||||
|
||||
if (this->time >= this->maxTime) {
|
||||
return;
|
||||
// TODO: how do we deal with reaching the end of the simulated dataset? Do we just stop simulating, loop back around? What about the location of the particles in this case? Just some ideas to consider, but we should iron this out pretty soon.
|
||||
}
|
||||
|
||||
((Program *)clientData)->updateData(this->time);
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
#ifndef TIMERCALLBACKCOMMAND_H
|
||||
#define TIMERCALLBACKCOMMAND_H
|
||||
|
||||
#include <vtkCallbackCommand.h>
|
||||
#include "../helperClasses/Program.h"
|
||||
|
||||
class TimerCallbackCommand : public vtkCallbackCommand {
|
||||
public:
|
||||
TimerCallbackCommand();
|
||||
static TimerCallbackCommand* New(Program *program);
|
||||
void Execute(vtkObject* caller, unsigned long eventId, void* vtkNotUsed(callData)) override;
|
||||
|
||||
void setDefaults();
|
||||
|
||||
|
||||
private:
|
||||
int time;
|
||||
int dt;
|
||||
int maxTime;
|
||||
};
|
||||
|
||||
#endif
|
||||
30
vtk/src/commands/TimerCallbackCommand.cpp
Normal file
30
vtk/src/commands/TimerCallbackCommand.cpp
Normal file
@@ -0,0 +1,30 @@
|
||||
#include "TimerCallbackCommand.h"
|
||||
#include "../helperClasses/Program.h"
|
||||
|
||||
|
||||
TimerCallbackCommand::TimerCallbackCommand() : dt(3600), maxTime(3600*24*365), time(0) {}
|
||||
|
||||
TimerCallbackCommand* TimerCallbackCommand::New(Program *program) {
|
||||
TimerCallbackCommand *cb = new TimerCallbackCommand();
|
||||
cb->setProgram(program);
|
||||
return cb;
|
||||
}
|
||||
|
||||
void TimerCallbackCommand::Execute(vtkObject* caller, unsigned long eventId, void* vtkNotUsed(callData)) {
|
||||
cout << this->time << " " << this->maxTime << endl;
|
||||
|
||||
this->time += this->dt;
|
||||
|
||||
if (this->time >= this->maxTime) {
|
||||
return;
|
||||
// TODO: how do we deal with reaching the end of the simulated dataset? Do we just stop simulating, loop back around? What about the location of the particles in this case? Just some ideas to consider, but we should iron this out pretty soon.
|
||||
}
|
||||
|
||||
this->program->updateData(this->time);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void TimerCallbackCommand::setProgram(Program *program) {
|
||||
this->program = program;
|
||||
}
|
||||
22
vtk/src/commands/TimerCallbackCommand.h
Normal file
22
vtk/src/commands/TimerCallbackCommand.h
Normal file
@@ -0,0 +1,22 @@
|
||||
#ifndef TIMERCALLBACKCOMMAND_H
|
||||
#define TIMERCALLBACKCOMMAND_H
|
||||
|
||||
#include <vtkCallbackCommand.h>
|
||||
#include "../helperClasses/Program.h"
|
||||
|
||||
class TimerCallbackCommand : public vtkCallbackCommand {
|
||||
public:
|
||||
TimerCallbackCommand();
|
||||
static TimerCallbackCommand* New(Program *program);
|
||||
void Execute(vtkObject* caller, unsigned long eventId, void* vtkNotUsed(callData)) override;
|
||||
|
||||
void setProgram(Program *program);
|
||||
|
||||
private:
|
||||
int time;
|
||||
int dt;
|
||||
int maxTime;
|
||||
Program *program;
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user