From 3c92c6256fd796f24db177caf813ba52e2389ff8 Mon Sep 17 00:00:00 2001 From: Samuel Fadel Date: Wed, 13 Apr 2016 12:20:01 -0300 Subject: Bundling now supports selection. Selection is implemented via main() updating the line plot using the current active selection. Beware of bug (issue #23). Also adds support for setting the line width, while changing the default line width to 2 pixels wide. ProjectionHistory: now reports changes to selections relative to the whole dataset, not only CPs/RPs. --- lineplot.h | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) (limited to 'lineplot.h') diff --git a/lineplot.h b/lineplot.h index 422bd2e..61e5988 100644 --- a/lineplot.h +++ b/lineplot.h @@ -2,6 +2,7 @@ #define LINEPLOT_H #include +#include #include #include @@ -14,6 +15,9 @@ #include "colorscale.h" #include "scale.h" +// (private) Implementation of QQuickFramebufferObject::Renderer +class LinePlotRenderer; + class LinePlot : public QQuickFramebufferObject { @@ -36,6 +40,7 @@ class LinePlot Q_PROPERTY(float advectionSpeed READ advectionSpeed WRITE setAdvectionSpeed NOTIFY advectionSpeedChanged) Q_PROPERTY(float relaxation READ relaxation WRITE setRelaxation NOTIFY relaxationChanged) Q_PROPERTY(bool bundleGPU READ bundleGPU WRITE setBundleGPU NOTIFY bundleGPUChanged) + Q_PROPERTY(float lineWidth READ lineWidth WRITE setLineWidth NOTIFY lineWidthChanged) public: static const int PADDING = 20; @@ -45,6 +50,8 @@ public: void setColorScale(const ColorScale *scale); const GraphDrawing *graphDrawing() const { return &m_gdFinal; } + const arma::uvec &indices() const { return m_indices; } + const arma::mat &points() const { return m_Y; } const std::vector &values() const { return m_values; } const std::vector &colorScale() const { return m_cmap; } LinearScale scaleX() const { return m_sx; } @@ -91,17 +98,22 @@ public: float advectionSpeed() const { return m_advectionSpeed; } float relaxation() const { return m_relaxation; } bool bundleGPU() const { return m_bundleGPU; } + float lineWidth() const { return m_lineWidth; } void setEdgeSampling(float edgeSampling); void setAdvectionSpeed(float advectionSpeed); void setRelaxation(float relaxation); void setBundleGPU(bool bundleGPU); + void setLineWidth(float lineWidth); signals: - void linesChanged(const arma::mat &xy); + void indicesChanged(const arma::uvec &indices); + void pointsChanged(const arma::mat &Y); void valuesChanged(const arma::vec &values) const; void scaleChanged(const LinearScale &sx, const LinearScale &sy) const; + void itemBrushed(int item) const; + void selectionChanged(const std::vector &selection) const; // Q_PROPERTY's void iterationsChanged(int iterations) const; @@ -118,6 +130,7 @@ signals: void advectionSpeedChanged(float advectionSpeed) const; void relaxationChanged(float relaxation) const; void bundleGPUChanged(bool bundleGPU) const; + void lineWidthChanged(float lineWidth) const; public slots: // Lines are two consecutive elements in 'indices' (ref. points in 'Y') @@ -129,12 +142,17 @@ public slots: void setScale(const LinearScale &sx, const LinearScale &sy); + void brushItem(int item); + void setSelection(const std::vector &selection); + private: + void buildGraph(); void bundle(); void relax(); // Data - arma::mat m_lines; + arma::uvec m_indices; + arma::mat m_Y; std::vector m_values; // Visuals @@ -144,7 +162,10 @@ private: GraphDrawing m_gdBundle, m_gdFinal; // Internal state - bool m_linesChanged, m_valuesChanged, m_colorScaleChanged; + int m_brushedItem; + std::vector m_selection; + bool m_anySelected; + bool m_linesChanged, m_valuesChanged, m_colorScaleChanged, m_updateOffsets; // Q_PROPERTY's int m_iterations; @@ -161,6 +182,9 @@ private: float m_advectionSpeed; float m_relaxation; bool m_bundleGPU; + float m_lineWidth; + + friend class LinePlotRenderer; }; #endif // LINEPLOT_H -- cgit v1.2.3