From 8fab0a9cfcbed9deb47f4a9bd101434985c1c611 Mon Sep 17 00:00:00 2001 From: Mika Salmela Date: Thu, 21 Aug 2014 09:55:23 +0300 Subject: Gradient to highlight series MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added a gradient to highlight series on textured surface example. Change-Id: I2fc17dfa79f986cf5b651d964eb3bcf5d65f1c80 Reviewed-by: Tomi Korpipää --- .../texturesurface/highlightseries.cpp | 28 ++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) (limited to 'examples/datavisualization/texturesurface/highlightseries.cpp') diff --git a/examples/datavisualization/texturesurface/highlightseries.cpp b/examples/datavisualization/texturesurface/highlightseries.cpp index 7e5f7efb..13d1fba3 100644 --- a/examples/datavisualization/texturesurface/highlightseries.cpp +++ b/examples/datavisualization/texturesurface/highlightseries.cpp @@ -18,10 +18,16 @@ #include "highlightseries.h" -#include - using namespace QtDataVisualization; +//! [2] +const float darkRedPos = 1.0f; +const float redPos = 0.8f; +const float yellowPos = 0.6f; +const float greenPos = 0.4f; +const float darkGreenPos = 0.2f; +//! [2] + HighlightSeries::HighlightSeries() : m_width(100), m_height(100) @@ -93,3 +99,21 @@ void HighlightSeries::handlePositionChange(const QPoint &position) setVisible(true); } //! [1] + +//! [3] +void HighlightSeries::handleGradientChange(float value) +{ + float ratio = m_minHeight / value; + + QLinearGradient gr; + gr.setColorAt(0.0f, Qt::black); + gr.setColorAt(darkGreenPos * ratio, Qt::darkGreen); + gr.setColorAt(greenPos * ratio, Qt::green); + gr.setColorAt(yellowPos * ratio, Qt::yellow); + gr.setColorAt(redPos * ratio, Qt::red); + gr.setColorAt(darkRedPos * ratio, Qt::darkRed); + + setBaseGradient(gr); + setColorStyle(Q3DTheme::ColorStyleRangeGradient); +} +//! [3] -- cgit v1.2.3