diff options
author | Keränen Pasi <pasi.keranen@digia.com> | 2013-11-28 08:42:27 +0200 |
---|---|---|
committer | Pasi Keränen <pasi.keranen@digia.com> | 2013-11-28 13:02:50 +0200 |
commit | a7e8a3279547dbea4b5343f44f3b7563c0212f1e (patch) | |
tree | 7e82c0645dc34397c2593f86f440c22606b672df | |
parent | 5fde532408da5b6b3ddef13aff5e07f32015e7d9 (diff) |
InputHandler C++ Example Code.
QDocs to follow in separate task.
Change-Id: I9f1352c190818ba43637345881e151e566188160
Task-id: QTRD-2562
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@digia.com>
-rw-r--r-- | examples/custominput/custominput.pro | 17 | ||||
-rw-r--r-- | examples/custominput/custominput.qrc | 5 | ||||
-rw-r--r-- | examples/custominput/custominputhandler.cpp | 49 | ||||
-rw-r--r-- | examples/custominput/custominputhandler.h | 36 | ||||
-rw-r--r-- | examples/custominput/data/data.txt | 1060 | ||||
-rw-r--r-- | examples/custominput/doc/images/custominput-example.png | bin | 0 -> 108178 bytes | |||
-rw-r--r-- | examples/custominput/doc/src/custominput.qdoc | 30 | ||||
-rw-r--r-- | examples/custominput/main.cpp | 84 | ||||
-rw-r--r-- | examples/custominput/scatterdatamodifier.cpp | 160 | ||||
-rw-r--r-- | examples/custominput/scatterdatamodifier.h | 60 | ||||
-rw-r--r-- | examples/examples.pro | 1 |
11 files changed, 1502 insertions, 0 deletions
diff --git a/examples/custominput/custominput.pro b/examples/custominput/custominput.pro new file mode 100644 index 00000000..9a94cfcd --- /dev/null +++ b/examples/custominput/custominput.pro @@ -0,0 +1,17 @@ +!include( ../examples.pri ) { + error( "Couldn't find the examples.pri file!" ) +} + +SOURCES += main.cpp scatterdatamodifier.cpp \ + custominputhandler.cpp +HEADERS += scatterdatamodifier.h \ + custominputhandler.h + +QT += widgets + +INSTALLS += target + +RESOURCES += custominput.qrc + +OTHER_FILES += doc/src/* \ + doc/images/* diff --git a/examples/custominput/custominput.qrc b/examples/custominput/custominput.qrc new file mode 100644 index 00000000..8ced2b91 --- /dev/null +++ b/examples/custominput/custominput.qrc @@ -0,0 +1,5 @@ +<RCC> + <qresource prefix="/"> + <file>data/data.txt</file> + </qresource> +</RCC> diff --git a/examples/custominput/custominputhandler.cpp b/examples/custominput/custominputhandler.cpp new file mode 100644 index 00000000..dad7c851 --- /dev/null +++ b/examples/custominput/custominputhandler.cpp @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the QtDataVisualization module. +** +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** +****************************************************************************/ + +#include "custominputhandler.h" + +#include <QtDataVisualization/Q3DCamera> + +CustomInputHandler::CustomInputHandler(QObject *parent) : + QAbstract3DInputHandler(parent) +{ +} + +void CustomInputHandler::mouseMoveEvent(QMouseEvent *event, const QPoint &mousePos) +{ + setInputPosition(mousePos); +} + +void CustomInputHandler::wheelEvent(QWheelEvent *event) +{ + // Adjust zoom level based on what zoom range we're in. + int zoomLevel = scene()->activeCamera()->zoomLevel(); + if (zoomLevel > 100) + zoomLevel += event->angleDelta().y() / 12; + else if (zoomLevel > 50) + zoomLevel += event->angleDelta().y() / 60; + else + zoomLevel += event->angleDelta().y() / 120; + if (zoomLevel > 500) + zoomLevel = 500; + else if (zoomLevel < 10) + zoomLevel = 10; + + scene()->activeCamera()->setZoomLevel(zoomLevel); +} diff --git a/examples/custominput/custominputhandler.h b/examples/custominput/custominputhandler.h new file mode 100644 index 00000000..1fecb8d8 --- /dev/null +++ b/examples/custominput/custominputhandler.h @@ -0,0 +1,36 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the QtDataVisualization module. +** +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** +****************************************************************************/ + +#ifndef CUSTOMINPUTHANDLER_H +#define CUSTOMINPUTHANDLER_H + +#include <QtDataVisualization/QAbstract3DInputHandler> + +using namespace QtDataVisualization; + +class CustomInputHandler : public QAbstract3DInputHandler +{ + Q_OBJECT +public: + explicit CustomInputHandler(QObject *parent = 0); + + virtual void mouseMoveEvent(QMouseEvent *event, const QPoint &mousePos); + virtual void wheelEvent(QWheelEvent *event); +}; + +#endif diff --git a/examples/custominput/data/data.txt b/examples/custominput/data/data.txt new file mode 100644 index 00000000..c1623c87 --- /dev/null +++ b/examples/custominput/data/data.txt @@ -0,0 +1,1060 @@ +# Each line contains 3 floating point values +# for x, y and z values in the scatter chart + -10.0,5.0,-5.0, + -9.0,3.0,-4.5, + -8.5,4.1,-4.0, + -8.0,4.75,-3.9, + -9.5,4.9,-4.2, + -9.9,3.42,-3.5, + -7.8,3.1,-4.9, + -7.3,2.91,-4.1, + -7.1,3.68,-4.52, + -8.8,2.96,-3.6, + -6.94,2.4,-2.92, + -9.02,4.74,-4.18, + -9.54,3.1,-3.8, + -6.86,3.66,-3.58, + -8.16,1.82,-4.64, + -7.4,3.18,-4.22, + -7.9,3.06,-4.3, + -8.98,2.64,-4.44, + -6.36,3.96,-4.38, + -7.18,3.32,-4.04, + -7.9,3.4,-2.78, + -7.4,3.12,-3.1, + -7.54,2.8,-3.68, + 2.25,1.36,-1.3, + -2,-0.08,1, + 2.65,-1.2,2.7, + -2.55,3.48,-0.45, + -3.85,0.2,0.5, + 2.85,1.32,1.05, + -0.4,-2.36,-1.6, + 1.5,0.36,-0.55, + 0.25,0.12,-0.75, + -2.45,-0.72,-1.1, + 4.1,1.92,-0.95, + 2.05,0.64,-0.1, + 0.25,0.8,3.05, + 1.5,0.24,2.25, + 1.15,-0.4,0.8, + -0.05,0.12,0.25, + 0.9,-0.48,-3.2, + 3.55,-1.04,-0.95, + -2.4,-0.96,-0.65, + 4.25,0.16,2.05, + -0.6,1,-0.2, + 0,-0.84,-0.95, + -4.2,1.44,0.85, + -1.5,-1.2,-1.5, + -3.35,-1.96,1.8, + -2.75,-0.96,-1.2, + -2.45,0.28,-4.55, + 2.7,-1.4,-0.65, + 2.7,2.2,-2.4, + -0.8,-2.04,3.75, + -1,-1.84,2.35, + -3.25,-1.6,-4.4, + -0.35,-0.56,-1.75, + -0.8,-0.28,-0.05, + 4.75,-1.48,-2.45, + 4.35,1.4,0.8, + -3.2,2,0.5, + 2,1.92,0.55, + -0.45,0.68,-0.8, + -2.7,2,-2.4, + -1.65,1.32,-2.05, + -1.6,1.8,-3.65, + -1.2,-0.72,0.85, + 1.4,1.08,2.1, + -3.9,-1.16,-0.85, + 3.15,0.12,-0.95, + -1.35,-2.64,-0.5, + -4.15,1.28,-4.4, + -2,2.48,-0.15, + -3.4,0.6,0, + -1.5,-0.96,2.35, + -0.75,1.16,-0.75, + -0.85,0.64,-1.75, + 0.85,0.48,2.9, + 4.05,3.24,-0.1, + 0.65,0.84,0.3, + -2.1,0.92,-2.75, + -0.65,0.16,1.6, + -1.8,-1.48,-2.15, + -1.6,2.96,1.85, + -0.75,0.28,-0.75, + 2.2,1.16,2.65, + 2.6,2.92,-0.2, + -1.65,3.28,2.5, + -0.5,2.52,-1.15, + -1.85,0.52,-2, + 0.15,-2.36,-0.5, + -3.9,0.28,-0.25, + 0.1,-3.88,-0.7, + -1,-1.96,0.95, + -0.3,-3.52,-1.45, + 3.2,-2.56,2.5, + 0,-2.44,1.35, + 1.45,-1.96,0.1, + 3.55,-2.16,1.75, + 2.8,-0.72,-0.3, + -1.65,-0.6,0.25, + -4.35,-1.32,-2.3, + 2.75,-1.88,1.7, + 2.75,-0.6,2.45, + 0.15,-0.88,-0.2, + 0.15,0.04,-0.1, + -1.2,-2.92,-3, + -0.7,0.16,3.5, + -1.8,-2.4,0.2, + 1.25,2.64,1.65, + -0.65,1.32,-0.55, + 3.85,2.32,-1, + 1.65,-2.28,0.95, + -2.45,-2.96,3.45, + -1.75,0.36,1.6, + 1.1,-0.84,0.35, + -1.55,1.6,-3.1, + 0.4,-1.36,-1.55, + -3.95,0.2,3.7, + -1.8,-0.24,2.2, + -0.45,1.64,1.35, + -0.6,-0.72,2.5, + -1.2,-3.04,-1.55, + -0.95,1.48,0.95, + 1.7,-1.36,2.15, + -3.9,-0.32,-2.45, + 2.95,3.12,-2.4, + 3.55,-1.48,0.15, + -1.4,3.24,0.7, + -3.3,-0.8,0, + 1.15,0.36,-2.7, + 0.4,0.12,1.35, + 1.9,-3.32,-0.75, + 0.4,-0.2,-2.4, + 0.55,1.56,2.25, + 4.35,-0.96,-0.7, + 3.35,-1.04,-0.85, + 1.7,-0.28,-0.25, + -3.05,-0.44,1.3, + -3.95,-2.72,-3.8, + 2.1,1.32,1.15, + 1.4,-0.44,-2.85, + -2.1,0.04,2, + 2.45,-2.44,-2.85, + 4.35,0.24,1.1, + 1.8,1.8,-0.7, + 1.8,2.04,-0.95, + 1.65,-2.48,0.35, + -3.3,0.28,-1.6, + 1.85,1,2.25, + -2,-0.88,-2.6, + -0.1,0.28,-1.75, + -2.5,-2.76,-0.2, + 0.3,-1.64,-0.75, + 2.3,-1.28,-2.7, + -1.7,-1.48,-2.6, + 0.5,0.24,-2.2, + 0.45,-1.88,-0.95, + -1.2,0.96,2.35, + -0.55,-0.36,-1.8, + 2.7,-0.56,-0.4, + 1.1,2.76,-2.35, + -1.2,-2.16,3.1, + -0.05,1.76,1, + 1.45,-0.72,0.7, + 0.2,-3.2,-0.25, + -0.8,1.08,-0.1, + -2.45,0.56,-0.55, + 2,1.12,2, + -1.05,-2.16,-1.8, + 1.2,-2.12,-1.55, + -4,-0.76,0.2, + -0.15,-0.2,-2, + -2.95,1.36,-3.65, + 2.7,1.16,2.05, + 0.95,-1.52,-1.05, + -1.8,2.72,-0.55, + 0.45,2.88,-4.4, + 1.35,1.08,-0.8, + -2.7,-1.36,-2.65, + 0.35,2.32,-1.6, + -0.45,1.6,0.1, + 3.75,1.12,-3.8, + 0.5,2.6,0.5, + -0.75,-3.52,-3.2, + 0.25,-1.32,2.25, + -2.8,-1.6,-2.45, + 0.15,-0.56,3.9, + 2.15,-1.68,-1.7, + -4.2,-1.92,2.35, + 1.95,-1.32,0.3, + 0.5,0.64,0.75, + 0.85,-0.84,-0.5, + -2.15,-1.64,-2.3, + -0.85,-2.84,-0.3, + -3.1,-0.32,-0.85, + 3.45,0,0.8, + 1.4,0.2,0.3, + 0.45,1.76,-0.15, + 0.85,3.16,-2, + 2.15,0.72,-0.95, + -2.4,0.6,-0.5, + 1.45,-0.4,-1.95, + 0.6,-1.84,1.8, + 3.4,-0.2,-0.55, + 0.2,-0.84,4.6, + -0.25,-2.4,2.1, + -1.15,-3.16,-3.05, + 1.45,0.96,-0.7, + 0.35,0.52,-1, + 2.6,0.28,-0.85, + -1.25,0.76,-1.6, + -0.65,-2.16,3, + -0.25,-2.36,-1.8, + 0.35,-0.8,1.85, + 0.05,0.6,0.85, + -2.5,2.28,-2.05, + 1.65,1.2,2.1, + -3,-0.24,0.7, + -2.1,-0.84,-0.2, + 0.45,0.96,2.5, + -2.4,1.28,2.75, + -1.7,-3.2,-2.3, + 0.95,-0.08,0.3, + 1.4,0.88,0.45, + 2.1,1.08,0.2, + -2.1,-0.2,-0.6, + 0.5,1.24,-0.45, + 2.55,-0.56,-2.65, + -4.5,-0.48,-1.25, + 3.45,-0.44,2.2, + -0.25,0.64,1.65, + 1.25,-0.6,-0.35, + 1.95,-1.56,-4.1, + 2.75,-1,3.3, + 3.05,1.04,-0.9, + -2.95,1.4,-2.25, + 1.3,0.36,-2.9, + 0.4,-2.48,3.25, + -1.15,0.36,0.45, + -2.25,0.04,0.65, + -1.85,-0.96,4.25, + 1.5,0.04,-3.85, + 0.05,0.68,-2.45, + -0.1,-0.48,1.9, + 2.1,-1.52,-4, + 3.4,0,-2.05, + 0.7,2.68,-0.85, + 1.6,1.68,-0.8, + 2.1,-2.44,1.2, + -0.15,-1.88,-0.35, + -0.35,1.76,1.6, + -2.15,0.08,0.75, + -0.15,-3.36,0.35, + 2.7,-2.84,0.35, + -1.35,0,-0.5, + -0.35,-2.56,-0.9, + -2.75,-3.56,1.55, + -2.5,-0.68,2.7, + 1.35,0.6,-2.2, + -1.3,-0.24,-1.65, + -1.4,-1.44,4.45, + -1.8,3.64,2.05, + -0.65,0.08,3.9, + 2.25,2.96,-2.35, + 1.3,1.64,-0.05, + 1.75,2.24,-2.85, + -0.05,-1.56,-0.05, + -3.85,-0.8,-0.3, + 0.95,0.32,-2.5, + -2.4,0.4,-3.55, + 3.7,2.36,3.6, + 0.55,0.88,3.15, + -1,-1.36,-2.1, + 2.05,0.44,-0.8, + -4.75,1.8,-1.7, + 0.15,2.64,-2.2, + -2.05,-2.56,1.15, + -3.7,2.12,1.3, + 1.05,0,4, + -0.7,-0.88,1.35, + 0.95,-1.84,0.1, + 0.75,1.16,4.25, + -1.3,0.72,0.65, + 3,-0.08,-1.75, + 2.85,-0.68,0.65, + -0.4,3.04,-2.35, + 3.05,-0.6,-0.6, + -0.85,-0.44,0.35, + 0,-1.92,0, + -1.25,-1.44,1.9, + -1.6,0.04,-0.7, + 1.45,-1,-3.4, + -2.8,-1.24,-3, + 0.2,-0.68,-3.7, + 3.35,0.68,-1.9, + -2.3,1.08,-1, + 1.5,1.8,-1.2, + 1.55,3.64,1.35, + 1.15,-1.36,0.75, + -1.95,0.08,-0.85, + -2.25,-0.52,1.05, + -2.6,-1.32,1.05, + -0.4,-1.52,2.45, + -0.05,0.64,-2.85, + 4.45,-0.24,-0.15, + 3.45,1.72,-1.1, + 3.3,-1.72,-0.25, + 1.7,2.76,2, + 2.1,-2.88,-1.75, + -3.7,-0.04,0.25, + -0.45,-3,-2.95, + 3.1,-2.32,0.1, + 0.7,-2.88,-3.45, + 2.9,0.4,-0.65, + -1.8,-2.48,-3.5, + 1.65,3.16,2.15, + -1.25,-0.76,2.15, + 3.55,0.28,2.4, + 0.25,0.52,2.3, + -1.7,-1.36,-2.5, + 3.8,1.04,0.45, + 2.45,-0.72,-4.05, + -0.85,0.16,-0.55, + 0.65,0.52,3.3, + 0.85,-0.08,0.6, + -0.1,1.12,-3.15, + -2.95,0.24,0.8, + 0.2,-0.6,-0.45, + 0.15,2.52,1.5, + 0.65,-1.4,-1.5, + 4.75,1.76,1.15, + -1.75,-1.44,-3.6, + 0.85,0.04,-0.3, + -0.55,-0.28,-1.85, + -4.05,0.52,-2.35, + -0.35,-0.96,0.8, + -1.8,-0.04,0.05, + -2,0.12,-2.5, + -1.85,-1.04,-1.2, + -1,-3.44,-1, + 2.25,0.16,-0.05, + -1.3,0.24,-1.5, + -0.05,-0.48,1.7, + -2.5,0.28,-2.1, + 3.9,-0.44,-0.85, + -0.3,-1.96,1.3, + 1.35,2.92,-1.15, + -2.2,-2.2,-0.45, + -0.2,-0.12,0.15, + 0.7,1.4,-3, + -0.3,3.16,2.65, + -1.1,-1.44,0.45, + 0.25,-1.04,4.3, + -2.2,-2.48,0.4, + 0.95,-3.4,-1.2, + 2.75,-1.6,-1.95, + 0.75,-1.84,-0.15, + -0.75,-1.84,0.35, + -2.85,-2.12,-0.95, + -0.8,-2.84,-0.15, + -1.95,-0.44,2.1, + -1.05,-2.48,-1.25, + -2.6,-1.48,0.8, + 2.5,-1.08,1.9, + 0.45,2.52,0.45, + 1.55,-0.16,0.25, + -2.9,0.36,0.35, + 2.95,-1.56,-2.7, + 3.4,-1.76,3.05, + 1.75,-2.84,0.5, + -0.95,0.64,1.1, + 2,2.04,0.1, + -0.15,-0.08,-0.9, + 2.2,-1.2,2.8, + -0.8,2.68,-0.3, + 3.4,0.84,-2.65, + -0.25,-0.24,0.45, + 2.7,1.64,-1.95, + 1.35,-2.96,0.65, + -1.45,-0.2,0.8, + 1.45,1.64,-3.45, + -1.1,3.08,1.1, + 0.8,1.88,-2.1, + 1.15,3.04,-0.75, + -0.45,1.36,-0.15, + -2.8,-1.24,2.55, + 4.4,2.04,1.25, + -0.95,1.24,3.65, + 3.45,1.32,2.5, + -3,1.12,-1.2, + -2.45,0.68,4.35, + 0.55,-0.12,-3.95, + -0.35,3.08,-0.3, + 1.35,-2.92,-3.3, + 0.5,-0.2,0.95, + 1.2,-0.24,-0.75, + -1.2,2.16,3.35, + -3.35,2.36,3.45, + 0.95,-0.88,1.25, + 0.1,1.24,0, + 1.8,1.56,-1.05, + -1.35,3.8,-1.45, + 1.45,-2.64,0.5, + 2.05,1.16,1.4, + 2.9,-2.4,0.15, + -1.1,0.76,-1.65, + -2.5,-2.4,1.05, + 3.55,-1.8,-2.55, + -0.8,1.24,-3.75, + -1.35,-2.48,2.85, + -2.1,1.48,-0.15, + -0.45,2.68,2.85, + 0.8,1.4,-3.35, + -2.2,-2.24,0.35, + 1.4,-2.32,0.55, + 3.65,1.12,-4.5, + 0.1,-0.68,1.85, + -1.95,-0.56,-2.05, + 1.85,1.32,-4.4, + -0.6,0.64,-0.3, + -1.55,1.52,-3.75, + 1.85,0.48,0.65, + 3.35,2.52,1.9, + 0.4,1.4,-1.3, + -2.7,0.84,1.6, + -0.5,1,0.4, + 2.25,-1,1.25, + 1.7,2.4,-0.95, + -3.55,1.04,3.95, + 0.9,1.28,2.05, + -3.15,1.96,-0.3, + 1.35,-0.92,-1, + -3.1,-3.08,0.9, + 1.25,-2.44,2.25, + -3.8,0.76,-1.05, + -1.05,-3.8,-0.8, + -4,1.24,-2.6, + 2.45,-1.84,0.35, + -1.5,2.16,4.3, + 2.1,-1.8,-0.95, + -1.8,-0.2,0.2, + 0.75,1.04,-1.3, + 2.85,1.6,-2.05, + -2,-0.2,-2.15, + 1.75,2.28,0.75, + 1.95,-0.68,-2.3, + -0.8,1.08,1.65, + -1.85,1.8,-0.75, + -3.05,2.44,0.35, + -0.4,-3,-2.85, + -0.95,0.64,2.15, + -1.35,-0.2,-0.8, + 2.1,-0.04,0.65, + 2.6,0.2,2.75, + 1.65,-0.16,1.65, + -1.85,0.68,1.95, + -3.05,-2.28,0.1, + 3.4,-1.88,3, + -0.75,0.36,1.5, + 2.9,-1,-1.85, + 0.4,1.08,0.8, + -1.05,1.04,2.15, + 2.6,-2.08,-0.1, + 0,-2.84,-0.95, + 0.4,1.88,2.05, + -3.1,-2.76,-2.75, + -2.65,3.52,-1.2, + -4.3,-0.28,3, + -2.8,-2.56,-2.85, + -0.15,2.72,-2.8, + -0.95,-0.6,1.05, + 1.9,2.56,1.25, + -0.85,0.24,0.05, + 2.4,2.56,-1.2, + 2.35,-1.08,2.7, + -2.1,-0.76,2.8, + 1.4,1,2.35, + -0.9,1.72,4.1, + 3.7,-1.4,2.05, + -0.25,0.76,-1.4, + -1.6,0.32,0.05, + 2.5,-3.08,0.85, + 0.05,-1.96,1.55, + -3.7,0.84,-0.25, + 2.35,0.6,-1.5, + 1.1,2.64,-1.45, + 2.55,-1.56,2.05, + -2.15,3.56,3.25, + -0.55,-1.24,2.65, + -0.3,1.32,0.85, + -1.9,1.24,1.15, + 0.35,-2.44,-1.35, + 2.9,-1.08,-4.3, + 1.8,-0.44,1.25, + -0.6,-1.08,-0.6, + -0.3,-0.88,-1.45, + -1,2.12,2.3, + 3.15,0.52,-2.8, + 0.45,2.48,-1.3, + 0.5,-0.84,0.7, + -0.6,-0.44,-1.35, + -1.7,-0.12,-2.55, + -0.5,0.52,1.4, + 4,-1.68,-0.1, + 1.4,-1.64,1.35, + 0.05,0.28,-2.2, + 1.55,-1.2,0.45, + 3.1,3.64,1.45, + -1.55,2.16,0.15, + 3.9,-2.56,-1.25, + 4.15,0.64,2.65, + -2.8,0.56,-1.35, + 1.3,1.28,0.8, + -2.3,-3.08,1.2, + 0.5,-0.36,-2.4, + 0.6,0.52,2.75, + 3.9,-0.52,-4.25, + -0.5,1.28,-0.05, + -0.25,-3.84,3.15, + -0.9,-1.72,-3.15, + 0.85,0.84,-1.7, + -3.35,0.72,2.15, + -1.6,0.6,1.65, + -3.6,0.8,2.6, + -0.7,1.96,-0.9, + -2.4,1.32,-2.75, + -1.75,0.72,-0.85, + -2.7,0.6,-2.5, + -2.2,-3.4,-1.85, + 0.85,2.2,-3.75, + -3.85,2.44,4.3, + -3.65,0.52,0.2, + -4.35,-0.52,1.5, + 1.45,-0.08,-0.4, + 1.85,-0.76,-4.6, + 0.95,0.52,-1, + -2.5,-0.88,-0.3, + -2.9,1.68,-1.15, + -3.2,0.2,1.1, + 0.9,-0.2,0.7, + 3.6,1.08,-2.15, + -0.8,1.72,2.85, + 0.3,1.76,0.9, + -1.3,-0.56,-2.3, + -2.8,0.4,4.2, + 1,-0.32,0.35, + -0.6,-0.24,4.05, + -2,-1.84,-2.2, + -1.95,-0.8,1.85, + -0.05,-0.16,3.85, + 0.15,-2.64,1.7, + -3.85,1.4,0.1, + 0.25,1,-2.45, + -4.1,0,-0.1, + -1.4,-0.32,-0.8, + -1.9,-1.84,-3, + 0.35,1.32,-3.95, + -2.6,-1.04,4.25, + -3.1,-0.96,-1.65, + -0.55,-1.16,4.05, + -3.1,-1,-0.5, + 2.25,1.24,3.4, + -1.2,-1.24,-4.05, + 3.05,1.92,1, + 0.55,-2.76,-3.25, + -2.05,1.6,0.6, + -0.45,0.12,-0.15, + 2.1,2.96,1.1, + 0.05,-2.08,-0.7, + -3.15,1.08,-0.1, + -1.95,0.44,0.6, + 0.15,-0.32,2.85, + 0.55,1,0.55, + -2.05,1.84,-1, + -0.25,0.36,1.2, + 4.6,-0.2,0.6, + -1.95,-0.8,0.05, + -0.35,-1.04,0.8, + 0.7,3.04,-3.55, + -0.15,1.12,-2.5, + -0.5,-1.68,1.5, + 1,-0.44,-1.5, + 4.05,-1.32,2.85, + 1.6,-1.56,2.15, + 0.3,-1.16,1.25, + -2.65,-1.28,0.45, + 0,1.52,-1.35, + 1.3,1.68,-2.75, + 1.25,0.4,0.3, + -0.95,3.68,1.75, + -3.55,0.48,1.15, + -1.7,-2.64,-3.3, + -2.2,-2.4,1.05, + 0.1,0.44,-1.05, + 2.05,0.4,0.8, + 0.4,0.04,4.2, + -1.25,0.76,0.45, + 1.6,2.04,-2.95, + -2.05,-0.44,1.35, + -3.25,0.44,2.15, + -1.75,0.04,2.35, + -4.15,0.68,0.8, + -1.6,1.12,0.55, + -0.15,3.4,3.05, + -0.2,0.04,-1.45, + 2.9,-0.36,1.45, + -1.4,1.56,1, + 3.4,-1.2,-4.2, + -1.1,0.6,1.55, + -0.35,1.52,-0.35, + 0.3,0.96,1.8, + 2.5,-1.84,1.65, + -0.6,2.24,-2.9, + -0.25,-2.32,-0.7, + 3.35,-2.24,1.5, + 1.6,1.96,3.9, + 1.8,0.68,-1.55, + 2.7,1.76,-2.9, + -2.35,-0.6,-3.9, + -1.85,1.96,-1.2, + -4.05,1.12,-2.75, + -2.85,-1.36,0.65, + -1.75,2.12,-1.35, + -2.95,-0.08,3.65, + -2.4,2,4.5, + -0.05,0.04,0.35, + -3.2,0.16,1.1, + 3,2.32,1.3, + 4.9,-1.88,0.45, + -2.35,-1.44,-0.7, + 2.4,-0.6,0.1, + 1,1.6,1, + 1.3,-0.4,-0.4, + -0.9,-2.72,-3.6, + 1.2,-0.44,2.1, + 0.65,3,-1.55, + -1.55,-2.64,0.55, + 1.9,-0.32,-2.1, + 1.35,-2.84,-0.4, + 0.25,-2.68,-0.2, + -2.05,-1.6,-3.05, + 1.65,-0.44,-0.75, + -1.25,0.96,-4.15, + -4.2,-0.56,1.45, + 0.95,-2.4,-1.6, + -0.05,0.88,3.15, + -1.65,-0.88,-3.85, + 0.35,0.2,4.25, + 0.8,0.84,3.1, + 1.85,-2.16,-2.2, + -2.05,0.16,-0.4, + 0.85,1.84,-1.45, + 1.6,1.56,-1.45, + 1.25,-0.84,-2.95, + -1.9,2.32,-1.8, + -0.6,2.4,-3.65, + 4.45,0.52,3, + 2.7,0.28,-1.8, + 0.35,-2.56,3.9, + -0.95,-1.28,1.6, + 0.4,-0.2,-2.15, + -0.05,-1.08,-4.1, + 3.1,-1.2,-3.85, + 0.75,0.12,-3.1, + -1.65,-1.16,-1.65, + -1.65,3.84,4.65, + 2.8,-2.6,-1.65, + 1.2,-2.76,-2.2, + 0.4,3.04,3.45, + -3.6,1.04,-0.6, + 2.25,1.64,2.9, + -3.05,-0.76,-2.3, + -2.85,2.12,-0.65, + -0.1,0.08,-1.6, + -1.55,-1.36,2.2, + -0.4,1.56,-0.3, + 0.3,-2.36,1.35, + 0.2,-0.6,1.6, + -0.65,1.96,-3.1, + 0.6,-1.04,2.5, + -2,-1.08,-0.85, + 1.45,-2.56,-2.6, + -2.45,0.04,-2.85, + -0.05,-1.24,-1.25, + -2.95,-1.8,-2.05, + 4.3,-0.96,3.5, + 2.15,-1.6,-0.8, + -1.2,-1,1.75, + -1.5,-1.28,-0.25, + 2.5,-2.6,-0.3, + -1.6,-0.36,3.15, + -0.1,-0.64,-3.6, + -1.9,1.88,2.1, + -2.85,-2.28,-1.55, + -1.3,-0.48,-2.2, + 0.5,0.28,0.65, + -1.1,0.24,-2.25, + 1.75,-1.4,0.3, + 1.5,-1.32,-2.8, + -0.95,2.08,-0.3, + 2.75,0.24,0.75, + 0.75,0.56,-1.5, + 1.1,-3.76,0, + 0.3,-1.2,2.6, + -0.25,2.68,-3, + 1.8,-0.76,4.4, + 0,0,-1.9, + -1.6,-0.12,-2.4, + -1.25,2.36,-2.9, + 2.65,0.04,0.1, + -3.35,0.08,-1.3, + 3.35,0.04,2.8, + 4.45,1.24,-0.95, + -0.1,-1.52,-4.6, + 1.1,1.72,-3.2, + -0.45,1.92,1.2, + -0.7,-0.16,0.8, + 2.3,0.2,2.75, + 1.7,2.08,-0.95, + 2.1,1.56,1.2, + 3.05,-1.56,-0.45, + 0.1,-3.08,-1.3, + 1.65,-0.32,-0.8, + 2.05,-1.8,1.8, + -0.55,1.52,-0.8, + -2.05,1.52,2.3, + -2.35,-3.28,3.5, + -2.25,2.56,-1.9, + 0.3,-3.28,3.4, + 0.95,-1.68,-1.8, + 2,2.2,-0.05, + 3,2.92,-2.1, + 2.55,3.12,2.95, + -0.5,-2.8,-0.3, + 0.35,0.64,0.35, + -1.15,-0.16,-0.45, + -2.4,-0.88,-0.3, + 1.55,-1.48,-0.5, + -0.85,-2.08,-1.1, + 0.5,-0.8,1.35, + -2.15,1.04,-3.25, + -0.65,-1.32,-3.1, + 0.35,-0.84,-1.7, + -2.1,0.96,2.5, + 1,-0.6,-3.15, + -1.35,0.76,3.45, + -3.05,-1.2,1.45, + -1.6,0.8,-1.9, + 0.7,1.68,2.3, + 0,-0.76,-0.95, + -2.3,-0.16,-1.25, + -0.55,-2.28,1.5, + 0,-0.24,0.55, + -0.4,-0.92,-0.7, + -2.6,-1.64,-0.9, + 0.25,-1.24,0.9, + 0.7,2.88,0.4, + -0.6,-1.84,-2.4, + 0.5,2.8,1.6, + -3.2,3.28,-3.45, + -1.45,2.52,2.7, + 1,-2.68,3, + -0.6,-2.56,1.35, + 1.95,-1.48,-3.85, + 3.85,0.08,-1.65, + -1.1,-1.6,-1.05, + 1.25,-0.04,1.35, + 2.9,2.08,0.2, + 0.7,2.52,0.65, + -1.85,-1.8,1.05, + 1.6,1.12,-3.05, + -2.8,0.12,0.5, + -1.4,1.64,-1.95, + 2.35,0.4,-0.95, + 0.95,-0.28,-0.8, + -1.5,-1.76,2.5, + -3.05,2.44,-0.2, + -0.6,1.12,-0.5, + -1.7,-0.72,-1.05, + 0.45,0.84,-0.1, + -3.5,0.36,1.1, + 0.2,-2.08,0.25, + -2.1,0.72,0.85, + -2.45,-0.72,-0.8, + 4.25,1.84,-0.55, + 0.1,-1.32,-1.45, + -3.65,0.36,0.3, + 0.9,0.32,-3.6, + -0.25,1.84,0, + 3.5,0.92,-2.1, + 0.65,2.36,4, + 0.55,-1.08,0.2, + 1,0.04,-3.75, + 0.05,0.52,-3.8, + 3.45,0.56,4.2, + -0.25,2.36,-3.55, + 1.95,1.28,4.25, + 1.8,3.12,0.65, + -3.35,0.8,-1, + 2.4,-0.16,1.25, + 2.5,0.96,1.45, + 0.8,-0.16,-0.55, + -3.45,-0.08,0.85, + -3.4,0.8,1.35, + -0.8,0.24,-1.2, + 3.6,1.16,-0.1, + -1.45,-3.08,-0.3, + -3.65,-1.04,0.15, + 1.35,-0.76,0.55, + -2.75,-1,-1.55, + 1.6,2.04,0.9, + 3,-3.24,0.1, + -4.25,0.56,-4.35, + -2.6,-0.44,0.5, + 0.2,-0.64,-0.35, + -3.2,-3.52,1, + -0.7,-1.84,-2.45, + -4.1,0.12,3.85, + -4.05,0.04,-0.3, + 2,2.32,1.2, + -0.35,1,-0.7, + -0.9,0.36,1.55, + -0.05,2.4,-4.35, + 1.5,-0.96,-3.4, + -2.8,2.08,-1.75, + -0.2,0.72,0.9, + -1.1,-1.68,0.1, + -1.2,-0.32,-0.85, + 0.75,0.56,3.95, + 1.15,2.8,0.65, + -2.55,-2.56,0.75, + 0.95,0.84,-0.85, + -2.15,0.24,-3.1, + 0.35,-1.68,0.45, + -0.75,-2.4,-0.35, + 0.2,2.04,0.1, + -2.4,0.68,1.8, + 1.9,0.88,1.45, + 0.25,1.92,-1.7, + -0.95,-0.6,-2, + 0.2,-2.44,1.05, + 0.3,-0.6,-3.35, + 0.05,0.52,-3.3, + -0.05,-0.88,-0.8, + 0.45,2.84,-1.9, + 2.85,-0.68,-2.45, + -1.05,-1.92,0.9, + -2.75,-0.16,-1.55, + 1.9,1,3.15, + -2.25,0.8,-4.35, + 1.8,-0.72,-3.8, + -3.25,-1.16,-1.85, + -1.6,-2.32,-0.8, + 3.1,0.32,2.15, + -1.05,-0.56,-3.45, + 0.75,-1.08,-0.25, + -0.45,-2.24,2.5, + 0.2,0.12,0, + -1,1.56,-1.6, + 1.3,-2.84,-0.25, + 0.55,1.36,2.95, + -1.9,-0.88,0.05, + -1.9,0.56,-0.7, + -1.25,-0.52,2.35, + 2.1,-0.72,-1.4, + -0.9,-0.72,-2.05, + 0.9,-0.96,-3, + 2.7,-2.36,1.25, + 3.3,-1,-3.55, + -0.75,-1.96,2, + -0.45,0.52,-0.1, + 0.8,0,-3.3, + -0.45,-0.44,-2.8, + -3.2,3.12,0.5, + -3.1,2.84,-0.45, + 0.2,-1.2,0.9, + -0.65,-1.4,-1.35, + -0.45,1.84,-0.95, + -1.3,0.8,-1, + 2.35,-0.28,1.55, + 2,-2.4,1.2, + 1.2,-1.72,-0.4, + -2,3.04,1.9, + -1.85,-0.16,-2.9, + -0.95,-2.76,2.5, + 2.55,-0.64,3.25, + -0.6,-0.72,-1.45, + 0.8,0.16,2.2, + 0.6,0.04,3.2, + -3.75,-0.24,0.2, + 0.4,-0.32,0.6, + -2.1,-3.68,0.2, + 0.45,-2.44,3, + 0.5,-1.8,-1.9, + 0,1.8,-1.25, + 2.6,2.2,-4.25, + 0.25,2.28,-0.4, + -0.3,-1.24,0.7, + 0.1,-3,0.05, + -1.2,-0.76,2.65, + 2.8,0.44,0.55, + 2.6,-0.68,0.2, + 1.75,-0.16,-3.6, + -0.55,-0.16,2.3, + 0.1,-1.72,-0.4, + 3.6,-0.84,-0.2, + -1.4,-1.48,-2.7, +1.1,-0.2,-2.75, + -1.85,1.76,-0.85, + 0.05,-0.4,1.05, + -1.25,0.52,-0.3, + -0.85,-0.24,1.9, + -1.95,-0.08,-1.95, + -2.7,-0.52,-0.35, + 0.1,0.16,4.1, + -0.6,-0.52,-1.2, + -2.3,-0.4,-2.85, + -0.35,-1.2,-1.85, + 1.7,-0.2,3.35, + 2.75,-2.32,3.15, + 2.85,0.44,0.9, + -2.1,0.4,1, + 4.45,-0.4,-3.75, + 0.7,-1.44,0.85, + -0.85,1.76,1.05, + -0.4,-0.92,-2.4, + -1,-0.28,-1.6, + -0.75,0.56,-0.75, + 0.55,1.72,-0.2, + 2.75,-0.24,-0.5, + -2.2,-1.04,-4.05, + 3.35,-0.56,-2.9, + 2.4,-0.32,-1.55, + 0.85,-0.88,-2.1, + 0.4,0.24,-0.45, + -4.1,-0.72,0.35, + -0.5,0.04,-0.95, + -2.8,2.92,0.95, + -1.65,0.96,1.25, + 1.45,0.84,0.25, + 2.2,-1.76,0, + -0.75,1.08,-2.1, + -3.15,-0.16,-1.1, + 2.55,-1.6,1.1, + 0.15,1.84,0.4, + -1.5,2.04,3.2, + -1.05,-0.84,-1.9, + 0.1,-2.96,-0.2, + 2.6,0.68,-2.6, + -0.4,-0.36,-1.05, + 1.1,0.04,-2.4, + -2.3,1.4,-0.1, + 0.85,-1.2,1.5, + 0.1,0.24,-2.75, + 1.15,1.32,-1.7, + 0.35,-1.6,-2.75, + 0.35,-1.36,2.55, + -1.65,-0.28,2.75, + -3.8,-3.28,2.55, + -2.6,1.08,-0.45, + 1.6,-2.2,2.45, + -0.75,1.16,-1.9, + -2.05,3.04,1.9, + -0.6,2.88,1, + 3.25,-2,-0.35, + -0.7,1.36,1.85, + 0.85,1.08,0.95, + 1.15,1.32,3.4, + 3.6,0.44,-0.4, + 0.9,2.12,1.95, + -0.6,-0.24,1.05, + -1.6,0.64,-1.3, + -1.3,-0.6,-1.95, + -0.1,0.36,-1.25, + 1,-1.48,0.95, + 1.2,-1.92,-0.9, + 0.1,2.2,-0.4, + -2.85,0.64,0.55, + -1.6,2.56,-2.2, + -3.2,-0.08,-0.65, + 3.15,-0.76,1.15, + 1.2,0.6,-2.6, + 2.65,-3.52,1.5, + -1.85,-1.76,-1.7, + -1.55,1.2,2.15, + -0.55,2.88,-2.85, + -3.1,-0.28,-3.35, + 2.45,0.08,-2.2, + -2.05,0.88,-0.65, + 1.1,-0.56,-3.65, + -0.5,-0.68,0.3, + 0.4,0.88,-1.65, + 1.65,0.16,0.75, + -0.2,1.72,0.6, + 1.15,-0.48,0.1, + 0.05,1.04,2.15, + 0.15,-0.64,-1.3, + 1.7,-1.88,-2.85, + 3.35,1.28,-1.05, + -3.7,-2.88,-1.05, + -1.7,3.08,0.15, + 3,-2.52,-2.45, + -0.15,0.16,-0.3, + -2.15,-0.8,1.25, + -1.95,-0.84,-3.1, + -0.2,-0.8,-3.55, + 0.4,0.32,-1.55, + 1.9,-2.84,-0.55, + 1.05,1.32,0.6, + 2.4,1,2.35, + -0.7,0.28,-1.3, + 0.85,0.96,-2.7, + -0.85,-0.88,1.1, + 1.5,0.28,-3.1, + 1.9,0.28,-1.75, + 0.2,-2.04,-0.85, + -1.5,2.04,-1.35, + -0.7,1.24,1.95, + 1.65,-1.04,-0.95, + -2.35,-1.76,-0.2, + 0.85,-2.92,3.4, + -0.7,2.52,1, + -3.4,0.6,0.9, + 8.0,-2.0,4.0, + 7.8,-2.2,5.0, + 7.6,-2.4,4.5, + 7.4,-2.6,3.8, + 7.2,-2.8,4.8, + 7.0,-2.3,4.1, + 6.9,-3.3,4.9, + 6.7,-3.5,3.5, + 6.5,-3.7,3.3, + 6.3,-3.4,3.7, + 7.9,-3.32,2.48, + 6.2,-4.04,3.4, + 8.06,-4.6,4.08, + 5.98,-2.26,2.82, + 5.46,-3.9,3.2, + 8.14,-3.34,3.42, + 6.84,-5.0,2.36, + 7.6,-3.82,2.78, + 7.1,-3.94,2.7, + 6.02,-4.36,2.56, + 8.64,-3.04,2.62, + 7.82,-3.68,2.96, + 7.1,-3.6,4.22, + 7.6,-3.88,3.9, + 7.46,-4.2,3.32, + 6.98,-3.94,3.1, + 7.36,-4.24,1.72, + 8.42,-4.52,2.62, + 6.04,-4.48,2.74, + 8.7,-3.92,3.82, + 6.76,-3.5,2.92, + 7,-4.42,2.62, + 5.32,-3.28,3.34, + 6.4,-4.6,2.4, + 5.66,-4.98,3.72 diff --git a/examples/custominput/doc/images/custominput-example.png b/examples/custominput/doc/images/custominput-example.png Binary files differnew file mode 100644 index 00000000..083bac58 --- /dev/null +++ b/examples/custominput/doc/images/custominput-example.png diff --git a/examples/custominput/doc/src/custominput.qdoc b/examples/custominput/doc/src/custominput.qdoc new file mode 100644 index 00000000..69333d96 --- /dev/null +++ b/examples/custominput/doc/src/custominput.qdoc @@ -0,0 +1,30 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the QtDataVisualization module. +** +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** +****************************************************************************/ + +/*! + \example custominput + \title Custom Input Example + \ingroup qtdatavisualization_examples + \brief Implementing custom input handler in a widget application. + + TBD... + + \image custominput-example.png + + TBD... +*/ diff --git a/examples/custominput/main.cpp b/examples/custominput/main.cpp new file mode 100644 index 00000000..9cf3ec60 --- /dev/null +++ b/examples/custominput/main.cpp @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the QtDataVisualization module. +** +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** +****************************************************************************/ + +#include "scatterdatamodifier.h" + +#include <QApplication> +#include <QWidget> +#include <QHBoxLayout> +#include <QVBoxLayout> +#include <QPushButton> +#include <QCheckBox> +#include <QComboBox> +#include <QFontComboBox> +#include <QLabel> +#include <QScreen> +#include <QFontDatabase> + +int main(int argc, char **argv) +{ + QApplication app(argc, argv); + Q3DScatter *graph = new Q3DScatter(); + QWidget *container = QWidget::createWindowContainer(graph); + + QSize screenSize = graph->screen()->size(); + container->setMinimumSize(QSize(screenSize.width() / 2, screenSize.height() / 1.5)); + container->setMaximumSize(screenSize); + container->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + container->setFocusPolicy(Qt::StrongFocus); + + QWidget *widget = new QWidget; + QHBoxLayout *hLayout = new QHBoxLayout(widget); + QVBoxLayout *vLayout = new QVBoxLayout(); + hLayout->addWidget(container, 1); + hLayout->addLayout(vLayout); + + widget->setWindowTitle(QStringLiteral("Custom Input Handling")); + + QPushButton *cameraButton = new QPushButton(widget); + cameraButton->setText(QStringLiteral("Toggle Camera Animation")); + + QComboBox *shadowQuality = new QComboBox(widget); + shadowQuality->addItem(QStringLiteral("None")); + shadowQuality->addItem(QStringLiteral("Low")); + shadowQuality->addItem(QStringLiteral("Medium")); + shadowQuality->addItem(QStringLiteral("High")); + shadowQuality->addItem(QStringLiteral("Low Soft")); + shadowQuality->addItem(QStringLiteral("Medium Soft")); + shadowQuality->addItem(QStringLiteral("High Soft")); + shadowQuality->setCurrentIndex(4); + + vLayout->addWidget(cameraButton, 0, Qt::AlignTop); + vLayout->addWidget(new QLabel(QStringLiteral("Adjust shadow quality")), 0, Qt::AlignTop); + vLayout->addWidget(shadowQuality, 1, Qt::AlignTop); + + ScatterDataModifier *modifier = new ScatterDataModifier(graph); + + QObject::connect(cameraButton, &QPushButton::clicked, modifier, + &ScatterDataModifier::toggleCameraAnimation); + + QObject::connect(shadowQuality, SIGNAL(currentIndexChanged(int)), modifier, + SLOT(changeShadowQuality(int))); + + QObject::connect(modifier, &ScatterDataModifier::shadowQualityChanged, shadowQuality, + &QComboBox::setCurrentIndex); + + widget->show(); + modifier->start(); + return app.exec(); +} diff --git a/examples/custominput/scatterdatamodifier.cpp b/examples/custominput/scatterdatamodifier.cpp new file mode 100644 index 00000000..a1e7e55f --- /dev/null +++ b/examples/custominput/scatterdatamodifier.cpp @@ -0,0 +1,160 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the QtDataVisualization module. +** +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** +****************************************************************************/ + +#include "scatterdatamodifier.h" + +#include <QtDataVisualization/QScatterDataProxy> +#include <QtDataVisualization/Q3DValueAxis> +#include <QtDataVisualization/Q3DScene> +#include <QtDataVisualization/Q3DCamera> +#include <QtDataVisualization/QScatter3DSeries> +#include <QtDataVisualization/Q3DTheme> +#include <qmath.h> + +using namespace QtDataVisualization; + +ScatterDataModifier::ScatterDataModifier(Q3DScatter *scatter) + : m_graph(scatter), + m_inputHandler(new CustomInputHandler()) +{ + m_graph->setObjectType(QDataVis::MeshStyleCubes, false); + m_graph->setTheme(new Q3DTheme(QDataVis::ThemeDigia)); + m_graph->setShadowQuality(QDataVis::ShadowQualitySoftLow); + m_graph->scene()->activeCamera()->setCameraPreset(QDataVis::CameraPresetFront); + + m_graph->setAxisX(new Q3DValueAxis); + m_graph->setAxisY(new Q3DValueAxis); + m_graph->setAxisZ(new Q3DValueAxis); + + QScatter3DSeries *series = new QScatter3DSeries; + series->setItemLabelFormat("@xTitle: @xLabel @yTitle: @yLabel @zTitle: @zLabel"); + m_graph->addSeries(series); + + m_animationCameraX = new QPropertyAnimation(m_graph->scene()->activeCamera(), "xRotation"); + m_animationCameraX->setDuration(20000); + m_animationCameraX->setStartValue(QVariant::fromValue(0.0f)); + m_animationCameraX->setEndValue(QVariant::fromValue(360.0f)); + m_animationCameraX->setLoopCount(-1); + + QPropertyAnimation *upAnimation = new QPropertyAnimation(m_graph->scene()->activeCamera(), "yRotation"); + upAnimation->setDuration(9000); + upAnimation->setStartValue(QVariant::fromValue(5.0f)); + upAnimation->setEndValue(QVariant::fromValue(45.0f)); + + QPropertyAnimation *downAnimation = new QPropertyAnimation(m_graph->scene()->activeCamera(), "yRotation"); + downAnimation->setDuration(9000); + downAnimation->setStartValue(QVariant::fromValue(45.0f)); + downAnimation->setEndValue(QVariant::fromValue(5.0f)); + + m_animationCameraY = new QSequentialAnimationGroup(); + m_animationCameraY->setLoopCount(-1); + m_animationCameraY->addAnimation(upAnimation); + m_animationCameraY->addAnimation(downAnimation); + + m_animationCameraX->start(); + m_animationCameraY->start(); + + // Give ownership of the handler to the graph and make it the active handler + m_graph->setActiveInputHandler(m_inputHandler); + + m_selectionTimer = new QTimer(this); + m_selectionTimer->setInterval(10); + m_selectionTimer->setSingleShot(false); + QObject::connect(m_selectionTimer, &QTimer::timeout, this, + &ScatterDataModifier::triggerSelection); + + m_selectionTimer->start(); +} + +ScatterDataModifier::~ScatterDataModifier() +{ + delete m_graph; +} + +void ScatterDataModifier::start() +{ + addData(); +} + +void ScatterDataModifier::addData() +{ + QVector<QVector3D> *itemList = new QVector<QVector3D>(); + + // Read data items from the file to QVector + QTextStream stream; + QFile dataFile(":/data/data.txt"); + if (dataFile.open(QIODevice::ReadOnly | QIODevice::Text)) { + stream.setDevice(&dataFile); + while (!stream.atEnd()) { + QString line = stream.readLine(); + if (line.startsWith("#")) // Ignore comments + continue; + QStringList strList = line.split(",", QString::SkipEmptyParts); + // Each line has three data items: xPos, yPos and zPos value + if (strList.size() < 3) { + qWarning() << "Invalid row read from data:" << line; + continue; + } + itemList->append(QVector3D( + strList.at(0).trimmed().toFloat(), + strList.at(1).trimmed().toFloat(), + strList.at(2).trimmed().toFloat())); + } + } else { + qWarning() << "Unable to open data file:" << dataFile.fileName(); + } + + // Add data from the QVector to datamodel + QScatterDataArray *dataArray = new QScatterDataArray; + dataArray->resize(itemList->count()); + QScatterDataItem *ptrToDataArray = &dataArray->first(); + for (int i = 0; i < itemList->count(); i++) { + ptrToDataArray->setPosition(itemList->at(i)); + ptrToDataArray++; + } + + m_graph->seriesList().at(0)->dataProxy()->resetArray(dataArray); +} + +void ScatterDataModifier::toggleCameraAnimation() +{ + if (m_animationCameraX->state() != QAbstractAnimation::Paused) { + m_animationCameraX->pause(); + m_animationCameraY->pause(); + } else { + m_animationCameraX->resume(); + m_animationCameraY->resume(); + } +} + +void ScatterDataModifier::triggerSelection() +{ + m_graph->scene()->setSelectionQueryPosition(m_inputHandler->inputPosition()); +} + +void ScatterDataModifier::shadowQualityUpdatedByVisual(QDataVis::ShadowQuality sq) +{ + int quality = int(sq); + emit shadowQualityChanged(quality); // connected to a checkbox in main.cpp +} + +void ScatterDataModifier::changeShadowQuality(int quality) +{ + QDataVis::ShadowQuality sq = QDataVis::ShadowQuality(quality); + m_graph->setShadowQuality(sq); +} diff --git a/examples/custominput/scatterdatamodifier.h b/examples/custominput/scatterdatamodifier.h new file mode 100644 index 00000000..fc0bc789 --- /dev/null +++ b/examples/custominput/scatterdatamodifier.h @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the QtDataVisualization module. +** +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** +****************************************************************************/ + +#ifndef SCATTERDATAMODIFIER_H +#define SCATTERDATAMODIFIER_H + +#include "custominputhandler.h" + +#include <QtDataVisualization/q3dscatter.h> +#include <QtGui/QFont> +#include <QtCore/QTimer> +#include <QPropertyAnimation> +#include <QSequentialAnimationGroup> +#include <QVector3D> + +using namespace QtDataVisualization; + +class ScatterDataModifier : public QObject +{ + Q_OBJECT +public: + explicit ScatterDataModifier(Q3DScatter *scatter); + ~ScatterDataModifier(); + + void addData(); + void toggleCameraAnimation(); + void start(); + +public slots: + void changeShadowQuality(int quality); + void shadowQualityUpdatedByVisual(QDataVis::ShadowQuality shadowQuality); + void triggerSelection(); + +signals: + void shadowQualityChanged(int quality); + +private: + Q3DScatter *m_graph; + QPropertyAnimation *m_animationCameraX; + QSequentialAnimationGroup *m_animationCameraY; + CustomInputHandler *m_inputHandler; + QTimer *m_selectionTimer; +}; + +#endif diff --git a/examples/examples.pro b/examples/examples.pro index 5ecc27aa..d126b26d 100644 --- a/examples/examples.pro +++ b/examples/examples.pro @@ -5,6 +5,7 @@ SUBDIRS += qmlbars \ qmlcustominput !android: { SUBDIRS += bars \ + custominput \ customproxy \ itemmodel \ scatter \ |