added addObserver function to layer

This commit is contained in:
Djairo Hougee 2024-05-05 08:29:55 +02:00
parent 7d4fde3485
commit feec302053
2 changed files with 14 additions and 0 deletions

View File

@ -1,4 +1,6 @@
#include "Layer.h" #include "Layer.h"
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
using std::string; using std::string;
@ -8,3 +10,8 @@ vtkSmartPointer<vtkRenderer> Layer::getLayer() {
void Layer::updateData(int t) { void Layer::updateData(int t) {
} }
void Layer::addObserver(const char *event, vtkCommand *observer) {
this->getLayer()->GetRenderWindow()->GetInteractor()->AddObserver(event, observer);
}

View File

@ -1,6 +1,7 @@
#ifndef LAYER_H #ifndef LAYER_H
#define LAYER_H #define LAYER_H
#include <vtkInteractorStyle.h>
#include <vtkRenderer.h> #include <vtkRenderer.h>
/** This class represents one abstract layer to be rendered to VTK. /** This class represents one abstract layer to be rendered to VTK.
@ -21,6 +22,12 @@ public:
* @param t : the timestamp which the data should reflect. * @param t : the timestamp which the data should reflect.
*/ */
virtual void updateData(int t); virtual void updateData(int t);
/** Adds an observer to the renderWindowinteractor within which this layer is active.
* @param event : the specific event type to subscribe to (see the vtkCommand::EventIds enum)
* @param observer : the observer to add.
*/
virtual void addObserver(const char *event, vtkCommand *observer);
}; };
#endif #endif