diff options
author | Samuel Fadel <samuelfadel@gmail.com> | 2016-03-15 16:37:07 -0300 |
---|---|---|
committer | Samuel Fadel <samuelfadel@gmail.com> | 2016-03-15 16:37:07 -0300 |
commit | 7cb2b5a84adfb1726bb061dfe985a68199118763 (patch) | |
tree | d50c73265ed4bf37f45e4b2cd00d32a5c8a01cb1 /lineplot.h | |
parent | 85af9a3daf3a9197a21dbf7d7bd4285755d3d037 (diff) |
Initial CUBu support & LinePlot (with bundling) component.
Diffstat (limited to 'lineplot.h')
-rw-r--r-- | lineplot.h | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/lineplot.h b/lineplot.h new file mode 100644 index 0000000..060171d --- /dev/null +++ b/lineplot.h @@ -0,0 +1,83 @@ +#ifndef LINEPLOT_H +#define LINEPLOT_H + +#include <memory> +#include <vector> + +#include <QQuickFramebufferObject> + +#include <armadillo> + +// From CUBu +#include "gdrawing.h" + +#include "colorscale.h" +#include "scale.h" + +class LinePlot + : public QQuickFramebufferObject +{ + Q_OBJECT +public: + static const int PADDING = 20; + + LinePlot(QQuickItem *parent = 0); + + void setColorScale(const ColorScale *colorScale); + void setAutoScale(bool autoScale); + + const GraphDrawing *graphDrawing() const { return m_gdPtr.get(); } + const std::vector<float> &values() const { return m_values; } + LinearScale<float> scaleX() const { return m_sx; } + LinearScale<float> scaleY() const { return m_sy; } + + Renderer *createRenderer() const; + + bool xyChanged() const { return m_xyChanged; } + bool valuesChanged() const { return m_valuesChanged; } + bool colorScaleChanged() const { return m_colorScaleChanged; } + + void setXYChanged(bool xyChanged) { + m_xyChanged = xyChanged; + } + void setValuesChanged(bool valuesChanged) { + m_valuesChanged = valuesChanged; + } + void setColorScaleChanged(bool colorScaleChanged) { + m_colorScaleChanged = colorScaleChanged; + } + +signals: + void xyChanged(const arma::mat &xy); + void valuesChanged(const arma::vec &values) const; + void scaleChanged(const LinearScale<float> &sx, + const LinearScale<float> &sy) const; + +public slots: + void setXY(const arma::mat &xy); + void setValues(const arma::vec &values); + void setScale(const LinearScale<float> &sx, + const LinearScale<float> &sy); + +private: + void bundle(); + + // Data + arma::mat m_xy; + std::vector<float> m_values; + + // Visuals + const ColorScale *m_colorScale; + + void autoScale(); + bool m_autoScale; + LinearScale<float> m_sx, m_sy; + + std::unique_ptr<GraphDrawing> m_gdPtr; + + // Internal state + bool m_xyChanged, m_valuesChanged, m_colorScaleChanged; + bool m_bundleGPU; +}; + +#endif // LINEPLOT_H |