diff options
author | Samuel Fadel <samuelfadel@gmail.com> | 2016-01-18 15:46:05 +0100 |
---|---|---|
committer | Samuel Fadel <samuelfadel@gmail.com> | 2016-01-18 15:46:05 +0100 |
commit | 8cc4c24249600392871cc802f3ac4dd27368d335 (patch) | |
tree | 9bfde6414953828b379ee3728f5d92bbb772558d /scatterplot.cpp | |
parent | d0ba4bbd9eb7b550cf71bb421e2a6f8b83018b48 (diff) |
Added observer to update values displayed based on some metric.
* Modified main() function to connect signals/slots to display
calculated values
* Color scales are no longer shared; they are also normalized to
each component's own data
* Stub mouse handling in BarChart (changes cursor shape)
Diffstat (limited to 'scatterplot.cpp')
-rw-r--r-- | scatterplot.cpp | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/scatterplot.cpp b/scatterplot.cpp index 0433af4..366583b 100644 --- a/scatterplot.cpp +++ b/scatterplot.cpp @@ -1,8 +1,13 @@ #include "scatterplot.h" -#include "geometry.h" #include <cmath> +#include <QSGGeometryNode> +#include <QSGSimpleRectNode> + +#include "continuouscolorscale.h" +#include "geometry.h" + static const qreal GLYPH_OPACITY = 1.0; static const qreal GLYPH_OPACITY_SELECTED = 1.0; @@ -16,6 +21,7 @@ static const float GLYPH_OUTLINE_WIDTH = 2.0f; Scatterplot::Scatterplot(QQuickItem *parent) : QQuickItem(parent) , m_glyphSize(DEFAULT_GLYPH_SIZE) + , m_colorScale(ContinuousColorScale::builtin(ContinuousColorScale::HEATED_OBJECTS)) , m_autoScale(true) , m_sx(0, 1, 0, 1) , m_sy(0, 1, 0, 1) @@ -27,14 +33,11 @@ Scatterplot::Scatterplot(QQuickItem *parent) setFlag(QQuickItem::ItemHasContents); } -void Scatterplot::setColorScale(const ColorScale *colorScale) +void Scatterplot::setColorScale(const ColorScale &colorScale) { - if (!colorScale) { - return; - } - m_colorScale = colorScale; if (m_colorData.n_elem > 0) { + m_colorScale.setExtents(m_colorData.min(), m_colorData.max()); m_shouldUpdateMaterials = true; } } @@ -96,6 +99,7 @@ void Scatterplot::setColorData(const arma::vec &colorData, bool updateView) m_colorData = colorData; emit colorDataChanged(m_colorData); + m_colorScale.setExtents(m_colorData.min(), m_colorData.max()); m_shouldUpdateMaterials = true; if (updateView) { update(); @@ -320,7 +324,7 @@ void Scatterplot::updateGlyphs(QSGNode *glyphsNode) glyphOutlineNode->markDirty(QSGNode::DirtyMaterial); material = static_cast<QSGFlatColorMaterial *>(glyphNode->material()); - material->setColor(m_colorScale->color(m_colorData[i])); + material->setColor(m_colorScale.color(m_colorData[i])); glyphNode->markDirty(QSGNode::DirtyMaterial); } |