diff options
author | Samuel Fadel <samuelfadel@gmail.com> | 2016-03-17 14:29:57 -0300 |
---|---|---|
committer | Samuel Fadel <samuelfadel@gmail.com> | 2016-03-17 14:29:57 -0300 |
commit | 5df4e094d9127bdcc9766c6b7da77bc5447c5d9e (patch) | |
tree | 8bfbfc45b33e2115004c897e496d30cea2fafefe | |
parent | aea8efe2e03e3348aaf4d1e076ebf7c27ddd5957 (diff) |
BarChart: brushing informs the value of the item.
-rw-r--r-- | barchart.cpp | 7 | ||||
-rw-r--r-- | barchart.h | 2 |
2 files changed, 6 insertions, 3 deletions
diff --git a/barchart.cpp b/barchart.cpp index 65db7d8..ba68843 100644 --- a/barchart.cpp +++ b/barchart.cpp @@ -62,10 +62,12 @@ void BarChart::setValues(const arma::vec &values) if (m_values.n_elem > 0) { m_scale.setDomain(m_values.min(), m_values.max()); + // m_originalIndices[i] == the original (datum) index of item i std::iota(m_originalIndices.begin(), m_originalIndices.end(), 0); std::sort(m_originalIndices.begin(), m_originalIndices.end(), [this](int i, int j) { return m_values[i] > m_values[j]; }); + // m_currentIndices[i] == the displayed position of datum i int k = 0; for (auto i: m_originalIndices) { m_currentIndices[i] = k++; @@ -115,7 +117,7 @@ void BarChart::brushItem(int item) { if (item < 0) { m_brushedItem = item; - emit itemBrushed(m_brushedItem); + emit itemBrushed(m_brushedItem, 0.0f); } else { // safe comparison: we just checked for negative values if (m_values.n_elem == 0 || item > m_values.n_elem - 1) { @@ -123,7 +125,8 @@ void BarChart::brushItem(int item) } m_brushedItem = m_currentIndices[item]; - emit itemBrushed(m_originalIndices[m_brushedItem]); + item = m_originalIndices[m_brushedItem]; + emit itemBrushed(item, m_values[item]); } update(); @@ -23,7 +23,7 @@ signals: void colorScaleChanged(const ColorScale *scale) const; void selectionChanged(const std::vector<bool> &selection) const; void selectionInteractivelyChanged(const std::vector<bool> &selection) const; - void itemBrushed(int item) const; + void itemBrushed(int item, float value) const; void itemInteractivelyBrushed(int item) const; public slots: |