From 3ce49858c6859fccc2e4d35839c34685348790d1 Mon Sep 17 00:00:00 2001 From: Samuel Fadel Date: Wed, 2 Mar 2016 15:47:24 -0300 Subject: Improvements related to ColorScale and screenshots. * ColorScale: now a pointer whenever needed. main() takes care of updating extents * New class DivergentColorScale: works specifically for divergent scales, always has 3 colors as input: negative values, 0, positive values * ManipulationHandler: ProjectionHistory no longer needed --- barchart.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'barchart.cpp') diff --git a/barchart.cpp b/barchart.cpp index cfa82aa..e651ccd 100644 --- a/barchart.cpp +++ b/barchart.cpp @@ -35,7 +35,7 @@ BarChart::BarChart(QQuickItem *parent) , m_dragLastPos(-1.0f) , m_shouldUpdateSelection(false) , m_brushedItem(-1) - , m_colorScale(ContinuousColorScale::builtin(ContinuousColorScale::HeatedObjects)) + , m_colorScale(0) , m_scale(0.0f, 1.0f, 0.0f, 1.0f) { setClip(true); @@ -61,7 +61,6 @@ void BarChart::setValues(const arma::vec &values) setAcceptHoverEvents(m_values.n_elem > 0); if (m_values.n_elem > 0) { m_scale.setDomain(m_values.min(), m_values.max()); - m_colorScale.setExtents(m_values.min(), m_values.max()); std::iota(m_originalIndices.begin(), m_originalIndices.end(), 0); std::sort(m_originalIndices.begin(), m_originalIndices.end(), @@ -79,12 +78,9 @@ void BarChart::setValues(const arma::vec &values) update(); } -void BarChart::setColorScale(const ColorScale &scale) +void BarChart::setColorScale(const ColorScale *scale) { m_colorScale = scale; - if (m_values.n_elem > 0) { - m_colorScale.setExtents(m_values.min(), m_values.max()); - } emit colorScaleChanged(m_colorScale); m_shouldUpdateBars = true; @@ -265,7 +261,7 @@ void BarChart::updateBars(QSGNode *node) const float x = 0; for (auto it = m_originalIndices.cbegin(); it != m_originalIndices.cend(); it++) { updateBarNodeGeom(node, x, barWidth, m_scale(m_values[*it])); - updateBarNodeColor(node, m_colorScale.color(m_values[*it])); + updateBarNodeColor(node, m_colorScale->color(m_values[*it])); x += barWidth; node = node->nextSibling(); } -- cgit v1.2.3