From 37a82fbeb7aa59260fe5f31b62228914ee4a44a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomi=20Korpip=C3=A4=C3=A4?= Date: Wed, 21 May 2014 12:27:16 +0300 Subject: Added an example about QML axis dragging Task-number: QTRD-3128 To be documented Change-Id: I044a890c8ef4814274b97be68cf7582c07a77247 Reviewed-by: Miikka Heikkinen --- examples/datavisualization/datavisualization.pro | 3 +- examples/datavisualization/qmlaxisdrag/main.cpp | 48 +++ .../qmlaxisdrag/qml/qmlaxisdrag/NewButton.qml | 44 +++ .../qmlaxisdrag/qml/qmlaxisdrag/cube.obj | 415 +++++++++++++++++++++ .../qmlaxisdrag/qml/qmlaxisdrag/cubetexture.png | Bin 0 -> 10429 bytes .../qmlaxisdrag/qml/qmlaxisdrag/main.qml | 266 +++++++++++++ .../datavisualization/qmlaxisdrag/qmlaxisdrag.pro | 11 + .../datavisualization/qmlaxisdrag/qmlaxisdrag.qrc | 12 + 8 files changed, 798 insertions(+), 1 deletion(-) create mode 100644 examples/datavisualization/qmlaxisdrag/main.cpp create mode 100644 examples/datavisualization/qmlaxisdrag/qml/qmlaxisdrag/NewButton.qml create mode 100644 examples/datavisualization/qmlaxisdrag/qml/qmlaxisdrag/cube.obj create mode 100644 examples/datavisualization/qmlaxisdrag/qml/qmlaxisdrag/cubetexture.png create mode 100644 examples/datavisualization/qmlaxisdrag/qml/qmlaxisdrag/main.qml create mode 100644 examples/datavisualization/qmlaxisdrag/qmlaxisdrag.pro create mode 100644 examples/datavisualization/qmlaxisdrag/qmlaxisdrag.qrc diff --git a/examples/datavisualization/datavisualization.pro b/examples/datavisualization/datavisualization.pro index bd736360..1f72820c 100644 --- a/examples/datavisualization/datavisualization.pro +++ b/examples/datavisualization/datavisualization.pro @@ -7,7 +7,8 @@ SUBDIRS += qmlbars \ qmlmultigraph \ qmloscilloscope \ qmlsurfacelayers \ - qmlaxisformatter + qmlaxisformatter \ + qmlaxisdrag !android:!ios { SUBDIRS += bars \ diff --git a/examples/datavisualization/qmlaxisdrag/main.cpp b/examples/datavisualization/qmlaxisdrag/main.cpp new file mode 100644 index 00000000..523d8d16 --- /dev/null +++ b/examples/datavisualization/qmlaxisdrag/main.cpp @@ -0,0 +1,48 @@ +/**************************************************************************** +** +** Copyright (C) 2014 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 +#include +#include +#include + +int main(int argc, char *argv[]) +{ + QGuiApplication app(argc, argv); + + QQuickView viewer; + + // The following are needed to make examples run without having to install the module + // in desktop environments. +#ifdef Q_OS_WIN + QString extraImportPath(QStringLiteral("%1/../../../../%2")); +#else + QString extraImportPath(QStringLiteral("%1/../../../%2")); +#endif + viewer.engine()->addImportPath(extraImportPath.arg(QGuiApplication::applicationDirPath(), + QString::fromLatin1("qml"))); + QObject::connect(viewer.engine(), &QQmlEngine::quit, &viewer, &QWindow::close); + + viewer.setTitle(QStringLiteral("QML Draggable Axes")); + + viewer.setSource(QUrl("qrc:/qml/qmlaxisdrag/main.qml")); + viewer.setResizeMode(QQuickView::SizeRootObjectToView); + viewer.show(); + + return app.exec(); +} diff --git a/examples/datavisualization/qmlaxisdrag/qml/qmlaxisdrag/NewButton.qml b/examples/datavisualization/qmlaxisdrag/qml/qmlaxisdrag/NewButton.qml new file mode 100644 index 00000000..ce946ed8 --- /dev/null +++ b/examples/datavisualization/qmlaxisdrag/qml/qmlaxisdrag/NewButton.qml @@ -0,0 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2014 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 +** +****************************************************************************/ + +import QtQuick 2.1 +import QtQuick.Controls 1.0 + +Item { + id: newbutton + + property alias text: buttonText.text + + signal clicked + + height: 80 + + Button { + opacity: 0.5 + width: parent.width + height: parent.height + Text { + id: buttonText + wrapMode: Text.WordWrap + verticalAlignment: Text.AlignVCenter + horizontalAlignment: Text.AlignHCenter + anchors.fill: parent + } + onClicked: newbutton.clicked() + } +} diff --git a/examples/datavisualization/qmlaxisdrag/qml/qmlaxisdrag/cube.obj b/examples/datavisualization/qmlaxisdrag/qml/qmlaxisdrag/cube.obj new file mode 100644 index 00000000..0197618f --- /dev/null +++ b/examples/datavisualization/qmlaxisdrag/qml/qmlaxisdrag/cube.obj @@ -0,0 +1,415 @@ +# Blender v2.66 (sub 0) OBJ File: 'beveled_cube.blend' +# www.blender.org +v -1.000000 -0.878027 0.878027 +v -0.978771 -0.929277 0.878027 +v -0.950975 -0.932562 0.932562 +v -0.978771 -0.878027 0.929277 +v -0.932562 -0.950975 0.932562 +v -0.929277 -0.978771 0.878027 +v -0.878027 -1.000000 0.878027 +v -0.878027 -0.978771 0.929277 +v -0.932562 -0.932562 0.950975 +v -0.878027 -0.929277 0.978771 +v -0.878027 -0.878027 1.000000 +v -0.929277 -0.878027 0.978771 +v -1.000000 -0.878027 -0.878027 +v -0.978771 -0.878027 -0.929277 +v -0.950975 -0.932562 -0.932562 +v -0.978771 -0.929277 -0.878027 +v -0.932562 -0.932562 -0.950975 +v -0.929277 -0.878027 -0.978771 +v -0.878027 -0.878027 -1.000000 +v -0.878027 -0.929277 -0.978771 +v -0.932562 -0.950975 -0.932562 +v -0.878027 -0.978771 -0.929277 +v -0.878027 -1.000000 -0.878027 +v -0.929277 -0.978771 -0.878027 +v 0.878027 -0.878027 -1.000000 +v 0.929277 -0.878027 -0.978771 +v 0.932562 -0.932562 -0.950975 +v 0.878027 -0.929277 -0.978771 +v 0.950975 -0.932562 -0.932562 +v 0.978771 -0.878027 -0.929277 +v 1.000000 -0.878027 -0.878027 +v 0.978771 -0.929277 -0.878027 +v 0.932562 -0.950975 -0.932562 +v 0.929277 -0.978771 -0.878027 +v 0.878027 -1.000000 -0.878027 +v 0.878027 -0.978771 -0.929277 +v 1.000000 -0.878027 0.878027 +v 0.978771 -0.878027 0.929277 +v 0.950975 -0.932562 0.932562 +v 0.978771 -0.929277 0.878027 +v 0.932562 -0.932562 0.950975 +v 0.929277 -0.878027 0.978771 +v 0.878027 -0.878027 1.000000 +v 0.878027 -0.929277 0.978771 +v 0.932562 -0.950975 0.932562 +v 0.878027 -0.978771 0.929277 +v 0.878027 -1.000000 0.878027 +v 0.929277 -0.978771 0.878027 +v -0.878027 0.878027 1.000000 +v -0.878027 0.929277 0.978771 +v -0.932562 0.932562 0.950975 +v -0.929277 0.878027 0.978771 +v -0.932562 0.950975 0.932562 +v -0.878027 0.978771 0.929277 +v -0.878027 1.000000 0.878027 +v -0.929277 0.978771 0.878027 +v -0.950975 0.932562 0.932562 +v -0.978771 0.929277 0.878027 +v -1.000000 0.878027 0.878027 +v -0.978771 0.878027 0.929277 +v -1.000000 0.878027 -0.878027 +v -0.978771 0.929277 -0.878027 +v -0.950975 0.932562 -0.932562 +v -0.978771 0.878027 -0.929277 +v -0.932562 0.950975 -0.932562 +v -0.929277 0.978771 -0.878027 +v -0.878027 1.000000 -0.878027 +v -0.878027 0.978771 -0.929277 +v -0.932562 0.932562 -0.950975 +v -0.878027 0.929277 -0.978771 +v -0.878027 0.878027 -1.000000 +v -0.929277 0.878027 -0.978771 +v 0.878027 0.878027 -1.000000 +v 0.878027 0.929277 -0.978771 +v 0.932562 0.932562 -0.950975 +v 0.929277 0.878027 -0.978771 +v 0.932562 0.950975 -0.932562 +v 0.878027 0.978771 -0.929277 +v 0.878027 1.000000 -0.878027 +v 0.929277 0.978771 -0.878027 +v 0.950975 0.932562 -0.932562 +v 0.978771 0.929277 -0.878027 +v 1.000000 0.878027 -0.878027 +v 0.978771 0.878027 -0.929277 +v 1.000000 0.878027 0.878027 +v 0.978771 0.929277 0.878027 +v 0.950975 0.932562 0.932562 +v 0.978771 0.878027 0.929277 +v 0.932562 0.950975 0.932562 +v 0.929277 0.978771 0.878027 +v 0.878027 1.000000 0.878027 +v 0.878027 0.978771 0.929277 +v 0.932562 0.932562 0.950975 +v 0.878027 0.929277 0.978771 +v 0.878027 0.878027 1.000000 +v 0.929277 0.878027 0.978771 +vt 0.024513 0.966281 +vt 0.033719 0.975487 +vt 0.033719 0.966281 +vt 0.964639 0.060986 +vt 0.964639 0.939014 +vt 0.989386 0.939014 +vt 0.939014 0.964639 +vt 0.060986 0.964639 +vt 0.939014 0.989386 +vt 0.060986 0.060986 +vt 0.060986 0.939014 +vt 0.939014 0.939014 +vt 0.035361 0.060986 +vt 0.035361 0.939014 +vt 0.010614 0.060986 +vt 0.010614 0.939014 +vt 0.989386 0.060986 +vt 0.939014 0.035361 +vt 0.060986 0.035361 +vt 0.060986 0.010614 +vt 0.060986 0.989386 +vt 0.939014 0.060986 +vt 0.966281 0.975487 +vt 0.966281 0.966281 +vt 0.975487 0.966281 +vt 0.975487 0.033719 +vt 0.966281 0.033719 +vt 0.966281 0.024513 +vt 0.033719 0.024513 +vt 0.033719 0.033719 +vt 0.024513 0.033719 +vt 0.939014 0.010614 +vn -0.713187 -0.495651 -0.495651 +vn -0.495651 -0.495651 -0.713187 +vn -0.495651 -0.713187 -0.495651 +vn 0.539384 -0.823450 0.175909 +vn 0.539384 -0.823450 -0.175909 +vn 0.823450 -0.539384 -0.175909 +vn -0.713187 0.495651 -0.495651 +vn -0.495651 0.713187 -0.495651 +vn -0.495651 0.495651 -0.713187 +vn 0.175909 -0.823450 -0.539384 +vn -0.185644 -0.825892 -0.532365 +vn 0.175909 -0.539384 -0.823450 +vn -0.193426 -0.961852 0.193426 +vn -0.193426 -0.961852 -0.193426 +vn 0.187689 -0.964110 -0.187689 +vn -0.532365 -0.185644 0.825892 +vn -0.532365 0.185644 0.825892 +vn -0.825892 -0.185644 0.532365 +vn -0.532365 0.185644 -0.825892 +vn -0.532365 -0.185644 -0.825892 +vn -0.825892 0.185644 -0.532365 +vn 0.823450 0.175909 -0.539384 +vn 0.823450 -0.175909 -0.539384 +vn 0.539384 -0.175909 -0.823450 +vn 0.539384 0.175909 0.823450 +vn 0.539384 -0.175909 0.823450 +vn 0.823450 -0.175909 0.539384 +vn 0.175909 0.823450 0.539384 +vn -0.185644 0.825892 0.532365 +vn -0.185644 0.532365 0.825892 +vn -0.185644 0.825892 -0.532365 +vn 0.175909 0.823450 -0.539384 +vn -0.185644 0.532365 -0.825892 +vn 0.539384 0.823450 -0.175909 +vn 0.539384 0.823450 0.175909 +vn 0.823450 0.539384 0.175909 +vn 0.187689 0.964110 0.187689 +vn 0.187689 0.964110 -0.187689 +vn -0.193426 0.961852 -0.193426 +vn -0.193426 0.193426 -0.961852 +vn 0.187689 0.187689 -0.964110 +vn -0.193426 -0.193426 -0.961852 +vn -0.961852 0.193426 0.193426 +vn -0.961852 0.193426 -0.193426 +vn -0.961852 -0.193426 0.193426 +vn -0.532365 -0.825892 -0.185644 +vn -0.532365 -0.825892 0.185644 +vn -0.825892 -0.532365 -0.185644 +vn 0.498856 0.498856 -0.708701 +vn 0.498856 0.708701 -0.498856 +vn 0.708701 0.498856 -0.498856 +vn 0.964110 0.187689 -0.187689 +vn 0.964110 0.187689 0.187689 +vn 0.964110 -0.187689 0.187689 +vn 0.498856 -0.498856 -0.708701 +vn 0.708701 -0.498856 -0.498856 +vn 0.498856 -0.708701 -0.498856 +vn 0.708701 0.498856 0.498856 +vn 0.498856 0.708701 0.498856 +vn 0.498856 0.498856 0.708701 +vn -0.495651 0.495651 0.713187 +vn -0.495651 0.713187 0.495651 +vn -0.713187 0.495651 0.495651 +vn 0.708701 -0.498856 0.498856 +vn 0.498856 -0.498856 0.708701 +vn 0.498856 -0.708701 0.498856 +vn -0.532365 0.825892 0.185644 +vn -0.532365 0.825892 -0.185644 +vn -0.825892 0.532365 0.185644 +vn 0.187689 0.187689 0.964110 +vn -0.193426 0.193426 0.961852 +vn -0.193426 -0.193426 0.961852 +vn -0.185644 -0.825892 0.532365 +vn 0.175909 -0.823450 0.539384 +vn 0.175909 -0.539384 0.823450 +vn -0.825892 -0.532365 0.185644 +vn -0.713187 -0.495651 0.495651 +vn -0.495651 -0.713187 0.495651 +vn -0.495651 -0.495651 0.713187 +vn -0.185644 -0.532365 0.825892 +vn -0.961852 -0.193426 -0.193426 +vn -0.825892 -0.185644 -0.532365 +vn 0.187689 -0.187689 -0.964110 +vn 0.823450 -0.539384 0.175909 +vn -0.193426 0.961852 0.193426 +vn -0.825892 0.532365 -0.185644 +vn 0.175909 0.539384 -0.823450 +vn 0.539384 0.175909 -0.823450 +vn 0.823450 0.539384 -0.175909 +vn 0.823450 0.175909 0.539384 +vn 0.175909 0.539384 0.823450 +vn -0.185644 -0.532365 -0.825892 +vn -0.825892 0.185644 0.532365 +vn 0.964110 -0.187689 -0.187689 +vn 0.187689 -0.187689 0.964110 +vn 0.187689 -0.964110 0.187689 +s 1 +f 15/1/1 17/2/2 21/3/3 +f 48/4/4 34/5/5 32/6/6 +f 63/1/7 65/3/8 69/2/9 +f 36/7/10 22/8/11 28/9/12 +f 7/10/13 23/11/14 35/12/15 +f 12/13/16 52/14/17 4/15/18 +f 72/14/19 18/13/20 64/16/21 +f 84/6/22 30/17/23 26/4/24 +f 96/5/25 42/4/26 38/17/27 +f 92/18/28 54/19/29 50/20/30 +f 68/8/31 78/7/32 70/21/33 +f 80/5/34 90/4/35 86/17/36 +f 91/22/37 79/12/38 67/11/39 +f 71/11/40 73/12/41 19/10/42 +f 59/11/43 61/12/44 1/10/45 +f 24/14/46 6/13/47 16/16/48 +f 75/23/49 77/24/50 81/25/51 +f 83/12/52 85/11/53 37/10/54 +f 27/23/55 29/25/56 33/24/57 +f 87/26/58 89/27/59 93/28/60 +f 51/29/61 53/30/62 57/31/63 +f 39/26/64 41/28/65 45/27/66 +f 56/13/67 66/14/68 58/15/69 +f 95/12/70 49/11/71 11/10/72 +f 8/19/73 46/18/74 44/32/75 +f 1/10/45 2/19/76 3/30/77 +f 5/30/78 6/13/47 7/10/13 +f 9/30/79 10/19/80 11/10/72 +f 13/22/81 14/4/82 15/27/1 +f 17/30/2 18/13/20 19/10/42 +f 21/3/3 22/8/11 23/11/14 +f 25/22/83 26/4/24 28/18/12 +f 29/27/56 30/4/23 32/18/6 +f 33/24/57 34/5/5 36/7/10 +f 37/10/54 38/13/27 40/19/84 +f 41/27/65 42/4/26 44/18/75 +f 45/27/66 46/18/74 48/4/4 +f 49/11/71 50/8/30 51/3/61 +f 53/30/62 54/19/29 55/10/85 +f 57/3/63 58/8/69 59/11/43 +f 61/12/44 62/7/86 63/24/7 +f 65/3/8 66/14/68 67/11/39 +f 69/3/9 70/8/33 71/11/40 +f 73/12/41 74/7/87 76/5/88 +f 77/24/50 78/7/32 80/5/34 +f 81/24/51 82/7/89 84/5/22 +f 85/11/53 86/8/36 88/14/90 +f 89/27/59 90/4/35 92/18/28 +f 93/24/60 94/7/91 96/5/25 +f 2/15/76 6/13/47 3/31/77 +f 8/19/73 10/20/80 5/30/78 +f 12/13/16 4/15/18 9/30/79 +f 14/15/82 18/13/20 15/31/1 +f 20/21/92 22/8/11 17/2/2 +f 24/14/46 16/16/48 21/3/3 +f 26/4/24 30/17/23 29/26/56 +f 32/6/6 34/5/5 33/24/57 +f 36/7/10 28/9/12 27/23/55 +f 38/17/27 42/4/26 41/27/65 +f 44/32/75 46/18/74 45/27/66 +f 48/4/4 40/17/84 39/26/64 +f 50/20/30 54/19/29 51/29/61 +f 56/13/67 58/15/69 53/30/62 +f 60/16/93 52/14/17 57/1/63 +f 62/16/86 66/14/68 63/1/7 +f 68/8/31 70/21/33 65/3/8 +f 72/14/19 64/16/21 69/3/9 +f 74/9/87 78/7/32 77/24/50 +f 80/5/34 82/6/89 81/25/51 +f 84/6/22 76/5/88 75/24/49 +f 86/17/36 90/4/35 89/27/59 +f 92/18/28 94/32/91 93/28/60 +f 96/5/25 88/6/90 87/25/58 +f 55/10/85 67/11/39 56/13/67 +f 61/12/44 59/11/43 62/7/86 +f 71/11/40 19/10/42 72/14/19 +f 13/22/81 61/12/44 14/4/82 +f 23/11/14 7/10/13 24/14/46 +f 1/10/45 13/22/81 2/19/76 +f 11/10/72 49/11/71 12/13/16 +f 59/11/43 1/10/45 60/14/93 +f 67/11/39 79/12/38 68/8/31 +f 73/12/41 71/11/40 74/7/87 +f 83/12/52 31/22/94 30/4/23 +f 25/22/83 73/12/41 76/5/88 +f 35/12/15 23/11/14 36/7/10 +f 19/10/42 25/22/83 20/19/92 +f 79/12/38 91/22/37 90/4/35 +f 85/11/53 83/12/52 82/7/89 +f 95/12/70 43/22/95 42/4/26 +f 37/10/54 85/11/53 88/14/90 +f 47/22/96 35/12/15 34/5/5 +f 31/22/94 37/10/54 40/19/84 +f 91/22/37 55/10/85 54/19/29 +f 49/11/71 95/12/70 94/7/91 +f 7/10/13 47/22/96 46/18/74 +f 43/22/95 11/10/72 10/19/80 +f 3/31/77 5/30/78 9/29/79 +f 40/17/84 48/4/4 32/6/6 +f 22/8/11 20/21/92 28/9/12 +f 47/22/96 7/10/13 35/12/15 +f 52/14/17 60/16/93 4/15/18 +f 18/13/20 14/15/82 64/16/21 +f 76/5/88 84/6/22 26/4/24 +f 88/6/90 96/5/25 38/17/27 +f 94/32/91 92/18/28 50/20/30 +f 78/7/32 74/9/87 70/21/33 +f 82/6/89 80/5/34 86/17/36 +f 55/10/85 91/22/37 67/11/39 +f 73/12/41 25/22/83 19/10/42 +f 61/12/44 13/22/81 1/10/45 +f 6/13/47 2/15/76 16/16/48 +f 31/22/94 83/12/52 37/10/54 +f 66/14/68 62/16/86 58/15/69 +f 43/22/95 95/12/70 11/10/72 +f 10/20/80 8/19/73 44/32/75 +f 4/13/18 1/10/45 3/30/77 +f 8/19/73 5/30/78 7/10/13 +f 12/13/16 9/30/79 11/10/72 +f 16/18/48 13/22/81 15/27/1 +f 20/19/92 17/30/2 19/10/42 +f 24/14/46 21/3/3 23/11/14 +f 26/4/24 27/27/55 28/18/12 +f 30/4/23 31/22/94 32/18/6 +f 34/5/5 35/12/15 36/7/10 +f 38/13/27 39/30/64 40/19/84 +f 42/4/26 43/22/95 44/18/75 +f 46/18/74 47/22/96 48/4/4 +f 52/14/17 49/11/71 51/3/61 +f 56/13/67 53/30/62 55/10/85 +f 60/14/93 57/3/63 59/11/43 +f 64/5/21 61/12/44 63/24/7 +f 68/8/31 65/3/8 67/11/39 +f 72/14/19 69/3/9 71/11/40 +f 74/7/87 75/24/49 76/5/88 +f 78/7/32 79/12/38 80/5/34 +f 82/7/89 83/12/52 84/5/22 +f 86/8/36 87/3/58 88/14/90 +f 90/4/35 91/22/37 92/18/28 +f 94/7/91 95/12/70 96/5/25 +f 6/13/47 5/30/78 3/31/77 +f 10/20/80 9/29/79 5/30/78 +f 4/15/18 3/31/77 9/30/79 +f 18/13/20 17/30/2 15/31/1 +f 22/8/11 21/3/3 17/2/2 +f 16/16/48 15/1/1 21/3/3 +f 27/27/55 26/4/24 29/26/56 +f 29/25/56 32/6/6 33/24/57 +f 33/24/57 36/7/10 27/23/55 +f 39/26/64 38/17/27 41/27/65 +f 41/28/65 44/32/75 45/27/66 +f 45/27/66 48/4/4 39/26/64 +f 54/19/29 53/30/62 51/29/61 +f 58/15/69 57/31/63 53/30/62 +f 52/14/17 51/3/61 57/1/63 +f 66/14/68 65/3/8 63/1/7 +f 70/21/33 69/2/9 65/3/8 +f 64/16/21 63/1/7 69/3/9 +f 75/23/49 74/9/87 77/24/50 +f 77/24/50 80/5/34 81/25/51 +f 81/25/51 84/6/22 75/24/49 +f 87/26/58 86/17/36 89/27/59 +f 89/27/59 92/18/28 93/28/60 +f 93/24/60 96/5/25 87/25/58 +f 67/11/39 66/14/68 56/13/67 +f 59/11/43 58/8/69 62/7/86 +f 19/10/42 18/13/20 72/14/19 +f 61/12/44 64/5/21 14/4/82 +f 7/10/13 6/13/47 24/14/46 +f 13/22/81 16/18/48 2/19/76 +f 49/11/71 52/14/17 12/13/16 +f 1/10/45 4/13/18 60/14/93 +f 79/12/38 78/7/32 68/8/31 +f 71/11/40 70/8/33 74/7/87 +f 84/5/22 83/12/52 30/4/23 +f 26/4/24 25/22/83 76/5/88 +f 23/11/14 22/8/11 36/7/10 +f 25/22/83 28/18/12 20/19/92 +f 80/5/34 79/12/38 90/4/35 +f 86/8/36 85/11/53 82/7/89 +f 96/5/25 95/12/70 42/4/26 +f 38/13/27 37/10/54 88/14/90 +f 48/4/4 47/22/96 34/5/5 +f 32/18/6 31/22/94 40/19/84 +f 92/18/28 91/22/37 54/19/29 +f 50/8/30 49/11/71 94/7/91 +f 8/19/73 7/10/13 46/18/74 +f 44/18/75 43/22/95 10/19/80 diff --git a/examples/datavisualization/qmlaxisdrag/qml/qmlaxisdrag/cubetexture.png b/examples/datavisualization/qmlaxisdrag/qml/qmlaxisdrag/cubetexture.png new file mode 100644 index 00000000..3cea6863 Binary files /dev/null and b/examples/datavisualization/qmlaxisdrag/qml/qmlaxisdrag/cubetexture.png differ diff --git a/examples/datavisualization/qmlaxisdrag/qml/qmlaxisdrag/main.qml b/examples/datavisualization/qmlaxisdrag/qml/qmlaxisdrag/main.qml new file mode 100644 index 00000000..64472a57 --- /dev/null +++ b/examples/datavisualization/qmlaxisdrag/qml/qmlaxisdrag/main.qml @@ -0,0 +1,266 @@ +/**************************************************************************** +** +** Copyright (C) 2014 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 +** +****************************************************************************/ + +import QtQuick 2.1 +import QtDataVisualization 1.1 +import "." + +Item { + id: mainView + width: 800 + height: 600 + visible: true + + property int selectedAxisLabel: -1 + property real dragSpeedModifier: 100.0 + + ListModel { + id: graphModel + ListElement{ xPos: 0.0; yPos: 0.0; zPos: 0.0; rotation: "@0,0,0,0" } + ListElement{ xPos: 1.0; yPos: 1.0; zPos: 1.0; rotation: "@45,1,1,1" } + } + + Timer { + id: dataTimer + interval: 1 + running: true + repeat: true + property bool isIncreasing: true + property real rotationAngle: 0 + + function generateQuaternion() { + return "@" + Math.random() * 360 + "," + Math.random() + "," + + Math.random() + "," + Math.random() + } + + function appendRow() { + graphModel.append({"xPos": Math.random(), + "yPos": Math.random(), + "zPos": Math.random(), + "rotation": generateQuaternion() + }); + } + + onTriggered: { + rotationAngle = rotationAngle + 1 + scatterSeries.setMeshAxisAndAngle(Qt.vector3d(1,1,1), rotationAngle) + qtCube.setRotationAxisAndAngle(Qt.vector3d(1,0,1), rotationAngle) + if (isIncreasing) { + for (var i = 0; i < 10; i++) + appendRow() + if (graphModel.count > 2002) { + scatterGraph.theme = isabelleTheme + isIncreasing = false + } + } else { + graphModel.remove(2, 10); + if (graphModel.count == 2) { + scatterGraph.theme = dynamicColorTheme + isIncreasing = true + } + } + } + } + + ThemeColor { + id: dynamicColor + ColorAnimation on color { + from: "red" + to: "yellow" + duration: 2000 + loops: Animation.Infinite + } + } + + Theme3D { + id: dynamicColorTheme + type: Theme3D.ThemeEbony + baseColors: [dynamicColor] + font.pointSize: 50 + labelBorderEnabled: true + labelBackgroundColor: "gold" + labelTextColor: "black" + } + + Theme3D { + id: isabelleTheme + type: Theme3D.ThemeIsabelle + font.pointSize: 50 + labelBorderEnabled: true + labelBackgroundColor: "gold" + labelTextColor: "black" + } + + Item { + id: dataView + anchors.bottom: parent.bottom + width: parent.width + height: parent.height + + Scatter3D { + id: scatterGraph + width: dataView.width + height: dataView.height + theme: dynamicColorTheme + shadowQuality: AbstractGraph3D.ShadowQualityNone + scene.activeCamera.yRotation: 45.0 + scene.activeCamera.xRotation: 45.0 + scene.activeCamera.zoomLevel: 75.0 + inputHandler: null + + Scatter3DSeries { + id: scatterSeries + itemLabelFormat: "X:@xLabel Y:@yLabel Z:@zLabel" + mesh: Abstract3DSeries.MeshCube + + ItemModelScatterDataProxy { + itemModel: graphModel + xPosRole: "xPos" + yPosRole: "yPos" + zPosRole: "zPos" + rotationRole: "rotation" + } + } + customItemList: [ + Custom3DItem { + id: qtCube + meshFile: ":/mesh/cube" + textureFile: ":/texture/texture" + position: Qt.vector3d(0.5,0.5,0.5) + scaling: Qt.vector3d(0.3,0.3,0.3) + } + ] + onSelectedElementChanged: { + if (selectedElement >= AbstractGraph3D.ElementAxisXLabel + && selectedElement <= AbstractGraph3D.ElementAxisYLabel) + selectedAxisLabel = selectedElement + else + selectedAxisLabel = -1 + } + } + + MouseArea { + id: inputArea + anchors.fill: parent + hoverEnabled: true + acceptedButtons: Qt.LeftButton + property int mouseX: -1 + property int mouseY: -1 + property int previousMouseX: -1 + property int previousMouseY: -1 + + onPositionChanged: { + mouseX = mouse.x; + mouseY = mouse.y; + if (pressed && selectedAxisLabel != -1) + dragAxis(mouseX, mouseY, previousMouseX, previousMouseY); + previousMouseX = mouseX; + previousMouseY = mouseY; + } + + onPressed: { + scatterGraph.scene.selectionQueryPosition = Qt.point(inputArea.mouseX, + inputArea.mouseY); + } + } + } + + function dragAxis(mouseX, mouseY, previousMouseX, previousMouseY) { + // Directional drag multipliers based on rotation + // In this example camera is locked to 45 degrees, so we can use precalculated values + var xMulX = 0.70710678146 + var xMulY = 0.7071067809 + var zMulX = 0.7071067809 + var zMulY = 0.70710678146 + + // Get the drag amount + var moveX = mouseX - previousMouseX + var moveY = mouseY - previousMouseY + + // Adjust axes + switch (selectedAxisLabel) { + case AbstractGraph3D.ElementAxisXLabel: + var distance = (moveX * xMulX - moveY * xMulY) / dragSpeedModifier + scatterGraph.axisX.min -= distance + scatterGraph.axisX.max -= distance + break + case AbstractGraph3D.ElementAxisZLabel: + distance = (moveX * zMulX + moveY * zMulY) / dragSpeedModifier + scatterGraph.axisZ.min += distance + scatterGraph.axisZ.max += distance + break + case AbstractGraph3D.ElementAxisYLabel: + distance = moveY / dragSpeedModifier + scatterGraph.axisY.min += distance + scatterGraph.axisY.max += distance + break + } + } + + NewButton { + id: rangeToggle + width: parent.width / 3 // We're adding 3 buttons and want to divide them equally + text: "Use Preset Range" + anchors.left: parent.left + property bool autoRange: true + onClicked: { + if (autoRange) { + text = "Use Automatic Range" + scatterGraph.axisX.min = 0.3 + scatterGraph.axisX.max = 0.7 + scatterGraph.axisY.min = 0.3 + scatterGraph.axisY.max = 0.7 + scatterGraph.axisZ.min = 0.3 + scatterGraph.axisZ.max = 0.7 + autoRange = false + dragSpeedModifier = 200.0 + } else { + text = "Use Preset Range" + autoRange = true + dragSpeedModifier = 100.0 + } + scatterGraph.axisX.autoAdjustRange = autoRange + scatterGraph.axisY.autoAdjustRange = autoRange + scatterGraph.axisZ.autoAdjustRange = autoRange + } + } + + NewButton { + id: orthoToggle + width: parent.width / 3 + text: "Display Orthographic" + anchors.left: rangeToggle.right + onClicked: { + if (scatterGraph.orthoProjection) { + text = "Display Orthographic"; + scatterGraph.orthoProjection = false + } else { + text = "Display Perspective"; + scatterGraph.orthoProjection = true + } + } + } + + NewButton { + id: exitButton + width: parent.width / 3 + text: "Quit" + anchors.left: orthoToggle.right + onClicked: Qt.quit(0); + } +} diff --git a/examples/datavisualization/qmlaxisdrag/qmlaxisdrag.pro b/examples/datavisualization/qmlaxisdrag/qmlaxisdrag.pro new file mode 100644 index 00000000..d45525ad --- /dev/null +++ b/examples/datavisualization/qmlaxisdrag/qmlaxisdrag.pro @@ -0,0 +1,11 @@ +!include( ../examples.pri ) { + error( "Couldn't find the examples.pri file!" ) +} + +SOURCES += main.cpp + +RESOURCES += qmlaxisdrag.qrc + +OTHER_FILES += doc/src/* \ + doc/images/* \ + qml/qmlaxisdrag/* diff --git a/examples/datavisualization/qmlaxisdrag/qmlaxisdrag.qrc b/examples/datavisualization/qmlaxisdrag/qmlaxisdrag.qrc new file mode 100644 index 00000000..c6c45e26 --- /dev/null +++ b/examples/datavisualization/qmlaxisdrag/qmlaxisdrag.qrc @@ -0,0 +1,12 @@ + + + qml/qmlaxisdrag/main.qml + qml/qmlaxisdrag/NewButton.qml + + + qml/qmlaxisdrag/cube.obj + + + qml/qmlaxisdrag/cubetexture.png + + -- cgit v1.2.3