summaryrefslogtreecommitdiffstats
path: root/examples/datavisualization/texturesurface/main.cpp
diff options
context:
space:
mode:
authorMika Salmela <mika.salmela@digia.com>2014-08-21 09:55:23 +0300
committerMika Salmela <mika.salmela@digia.com>2014-08-21 10:09:04 +0300
commit8fab0a9cfcbed9deb47f4a9bd101434985c1c611 (patch)
tree4c884d30f6bed5ce7471a16884b734ab8a347763 /examples/datavisualization/texturesurface/main.cpp
parent7ef676c7cbe5e3a960a66150794be3a862642073 (diff)
Gradient to highlight series
Added a gradient to highlight series on textured surface example. Change-Id: I2fc17dfa79f986cf5b651d964eb3bcf5d65f1c80 Reviewed-by: Tomi Korpipää <tomi.korpipaa@digia.com>
Diffstat (limited to 'examples/datavisualization/texturesurface/main.cpp')
-rw-r--r--examples/datavisualization/texturesurface/main.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/examples/datavisualization/texturesurface/main.cpp b/examples/datavisualization/texturesurface/main.cpp
index e73dc864..ed1a9be4 100644
--- a/examples/datavisualization/texturesurface/main.cpp
+++ b/examples/datavisualization/texturesurface/main.cpp
@@ -22,8 +22,11 @@
#include <QtWidgets/QWidget>
#include <QtWidgets/QHBoxLayout>
#include <QtWidgets/QVBoxLayout>
+#include <QtWidgets/QGroupBox>
#include <QtWidgets/QCheckBox>
+#include <QtWidgets/QLabel>
#include <QtGui/QScreen>
+#include <QtGui/QPainter>
int main(int argc, char **argv)
{
@@ -49,7 +52,41 @@ int main(int argc, char **argv)
QCheckBox *enableTexture = new QCheckBox(widget);
enableTexture->setText(QStringLiteral("Surface texture"));
+ int height = 400;
+ int width = 100;
+ int border = 10;
+ QLinearGradient gr(0, 0, 1, height - 2 * border);
+ gr.setColorAt(1.0f, Qt::black);
+ gr.setColorAt(0.8f, Qt::darkGreen);
+ gr.setColorAt(0.6f, Qt::green);
+ gr.setColorAt(0.4f, Qt::yellow);
+ gr.setColorAt(0.2f, Qt::red);
+ gr.setColorAt(0.0f, Qt::darkRed);
+
+ QPixmap pm(width, height);
+ pm.fill(Qt::transparent);
+ QPainter pmp(&pm);
+ pmp.setBrush(QBrush(gr));
+ pmp.setPen(Qt::NoPen);
+ pmp.drawRect(border, border, 35, height - 2 * border);
+ pmp.setPen(Qt::black);
+ int step = (height - 2 * border) / 5;
+ for (int i = 0; i < 6; i++) {
+ int yPos = i * step + border;
+ pmp.drawLine(border, yPos, 55, yPos);
+ pmp.drawText(60, yPos + 2, QString("%1 m").arg(550 - (i * 110)));
+ }
+
+ QLabel *label = new QLabel(widget);
+ label->setPixmap(pm);
+
+ QGroupBox *heightMapGroupBox = new QGroupBox(QStringLiteral("Height color map"));
+ QVBoxLayout *colorMapVBox = new QVBoxLayout;
+ colorMapVBox->addWidget(label);
+ heightMapGroupBox->setLayout(colorMapVBox);
+
vLayout->addWidget(enableTexture);
+ vLayout->addWidget(heightMapGroupBox);
widget->show();