38 lines
723 B
C++
38 lines
723 B
C++
#ifndef RENDERABLE2D_H
|
|
#define RENDERABLE2D_H
|
|
|
|
#include <QPainter>
|
|
#include "Scaler2D.h"
|
|
#include "RenderParams2D.h"
|
|
|
|
class Renderable2D {
|
|
|
|
private:
|
|
|
|
bool visible = true;
|
|
|
|
public:
|
|
|
|
virtual ~Renderable2D() {;}
|
|
|
|
/** show/hide this element */
|
|
void setVisible(const bool visible) {this->visible = visible;}
|
|
|
|
/** is this element currently visible? */
|
|
bool isVisible() const {return this->visible;}
|
|
|
|
/** render this element */
|
|
void render(QPainter& qp, const Scaler2D& s, const RenderParams2D& p) {
|
|
if (!visible) {return;}
|
|
doRender(qp, s, p);
|
|
}
|
|
|
|
protected:
|
|
|
|
/** subclasses render themselves here */
|
|
virtual void doRender(QPainter& qp, const Scaler2D& s, const RenderParams2D& p) = 0;
|
|
|
|
};
|
|
|
|
#endif // RENDERABLE2D_H
|