diff options
-rw-r--r-- | lineplot.cpp | 16 | ||||
-rw-r--r-- | lineplot.h | 5 |
2 files changed, 15 insertions, 6 deletions
diff --git a/lineplot.cpp b/lineplot.cpp index 83f6e12..0e9e001 100644 --- a/lineplot.cpp +++ b/lineplot.cpp @@ -58,6 +58,15 @@ void LinePlot::setColorScale(const ColorScale *scale) update(); } +void LinePlot::relax() +{ + m_gdFinalPtr.reset(new GraphDrawing); + *m_gdFinalPtr.get() = *m_gdBundlePtr.get(); + m_gdFinalPtr.get()->interpolate(*m_gdPtr.get(), m_relaxation); + + setLinesChanged(true); +} + void LinePlot::bundle() { m_gdBundlePtr.reset(new GraphDrawing); @@ -78,7 +87,6 @@ void LinePlot::bundle() bundling.spl = m_edgeSampling; bundling.eps = m_advectionSpeed; - // TODO: use m_relaxation as lerp param towards original (without bundling) if (m_bundleGPU) { bundling.bundleGPU(); @@ -86,7 +94,7 @@ void LinePlot::bundle() bundling.bundleCPU(); } - setLinesChanged(true); + relax(); } void LinePlot::setLines(const arma::uvec &indices, const arma::mat &Y) @@ -288,7 +296,7 @@ void LinePlot::setRelaxation(float relaxation) m_relaxation = relaxation; emit relaxationChanged(m_relaxation); - bundle(); + relax(); update(); } @@ -545,7 +553,7 @@ void LinePlotRenderer::synchronize(QQuickFramebufferObject *item) m_colormapChanged = plot->colorScaleChanged(); if (m_pointsChanged) { - copyPolylines(plot->bundleGraphDrawing()); + copyPolylines(plot->graphDrawing()); } m_values = &(plot->values()); m_cmap = &(plot->colorScale()); @@ -44,7 +44,7 @@ public: void setColorScale(const ColorScale *scale); - const GraphDrawing *bundleGraphDrawing() const { return m_gdBundlePtr.get(); } + const GraphDrawing *graphDrawing() const { return m_gdFinalPtr.get(); } const std::vector<float> &values() const { return m_values; } const std::vector<float> &colorScale() const { return m_cmap; } LinearScale<float> scaleX() const { return m_sx; } @@ -131,6 +131,7 @@ public slots: private: void bundle(); + void relax(); // Data arma::mat m_lines; @@ -139,7 +140,7 @@ private: // Visuals std::vector<float> m_cmap; LinearScale<float> m_sx, m_sy; - std::unique_ptr<GraphDrawing> m_gdPtr, m_gdBundlePtr; + std::unique_ptr<GraphDrawing> m_gdPtr, m_gdBundlePtr, m_gdFinalPtr; // Internal state bool m_linesChanged, m_valuesChanged, m_colorScaleChanged; |