From 7cb2b5a84adfb1726bb061dfe985a68199118763 Mon Sep 17 00:00:00 2001 From: Samuel Fadel Date: Tue, 15 Mar 2016 16:37:07 -0300 Subject: Initial CUBu support & LinePlot (with bundling) component. --- lineplot.h | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 lineplot.h (limited to 'lineplot.h') 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 +#include + +#include + +#include + +// 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 &values() const { return m_values; } + LinearScale scaleX() const { return m_sx; } + LinearScale 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 &sx, + const LinearScale &sy) const; + +public slots: + void setXY(const arma::mat &xy); + void setValues(const arma::vec &values); + void setScale(const LinearScale &sx, + const LinearScale &sy); + +private: + void bundle(); + + // Data + arma::mat m_xy; + std::vector m_values; + + // Visuals + const ColorScale *m_colorScale; + + void autoScale(); + bool m_autoScale; + LinearScale m_sx, m_sy; + + std::unique_ptr m_gdPtr; + + // Internal state + bool m_xyChanged, m_valuesChanged, m_colorScaleChanged; + bool m_bundleGPU; +}; + +#endif // LINEPLOT_H -- cgit v1.2.3