From 8cc4c24249600392871cc802f3ac4dd27368d335 Mon Sep 17 00:00:00 2001 From: Samuel Fadel Date: Mon, 18 Jan 2016 15:46:05 +0100 Subject: 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) --- scatterplot.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'scatterplot.cpp') 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 +#include +#include + +#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(glyphNode->material()); - material->setColor(m_colorScale->color(m_colorData[i])); + material->setColor(m_colorScale.color(m_colorData[i])); glyphNode->markDirty(QSGNode::DirtyMaterial); } -- cgit v1.2.3