summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/examples.pro3
-rw-r--r--examples/qmlmaps/doc/src/qmlmaps.qdoc38
-rw-r--r--examples/qmlmaps/image.jpgbin0 -> 287172 bytes
-rw-r--r--examples/qmlmaps/main.cpp43
-rw-r--r--examples/qmlmaps/qml/qmlmaps/main.qml125
-rw-r--r--examples/qmlmaps/qmlmaps.desktop11
-rw-r--r--examples/qmlmaps/qmlmaps.pro29
-rw-r--r--examples/qmlmaps/qmlmaps.qrc5
-rw-r--r--examples/qmlmaps/qmlmaps64.pngbin0 -> 3400 bytes
-rw-r--r--examples/qmlmaps/qtquick2applicationviewer/qtquick2applicationviewer.cpp81
-rw-r--r--examples/qmlmaps/qtquick2applicationviewer/qtquick2applicationviewer.h33
-rw-r--r--examples/qmlmaps/qtquick2applicationviewer/qtquick2applicationviewer.pri180
-rw-r--r--src/datavis3d/doc/src/qtdatavis3d-index.qdoc1
-rw-r--r--src/datavis3d/engine/maps3dcontroller.cpp9
-rw-r--r--src/datavis3d/engine/maps3dcontroller_p.h6
-rw-r--r--src/datavis3d/engine/q3dmaps.h2
-rw-r--r--src/datavis3d/engine/qdatarow.h1
-rw-r--r--src/datavis3d/engine/qdatarow_p.h2
-rw-r--r--src/datavis3dqml2/declarativemaps.cpp96
-rw-r--r--src/datavis3dqml2/declarativemaps.h11
-rw-r--r--src/datavis3dqml2/declarativemaps_p.h10
21 files changed, 653 insertions, 33 deletions
diff --git a/examples/examples.pro b/examples/examples.pro
index dd772368..d66a101e 100644
--- a/examples/examples.pro
+++ b/examples/examples.pro
@@ -3,6 +3,7 @@ SUBDIRS += barchart \
rainfall \
widget \
mapdata \
- qmlbarchart
+ qmlbarchart \
+ qmlmaps
qtHaveModule(multimedia): SUBDIRS += spectrum
diff --git a/examples/qmlmaps/doc/src/qmlmaps.qdoc b/examples/qmlmaps/doc/src/qmlmaps.qdoc
new file mode 100644
index 00000000..99fbbd82
--- /dev/null
+++ b/examples/qmlmaps/doc/src/qmlmaps.qdoc
@@ -0,0 +1,38 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the QtDataVis3D module.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: http://www.gnu.org/copyleft/fdl.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \example qmlmaps
+ \title Qt Quick 2 Maps Example
+
+ The Qt Quick 2 maps example shows how to make a simple maps visualization using Q3DMaps using Qt
+ Quick 2.
+
+ \image qmlmaps-example.png
+
+ TODO
+*/
diff --git a/examples/qmlmaps/image.jpg b/examples/qmlmaps/image.jpg
new file mode 100644
index 00000000..b6c48e76
--- /dev/null
+++ b/examples/qmlmaps/image.jpg
Binary files differ
diff --git a/examples/qmlmaps/main.cpp b/examples/qmlmaps/main.cpp
new file mode 100644
index 00000000..a04991ff
--- /dev/null
+++ b/examples/qmlmaps/main.cpp
@@ -0,0 +1,43 @@
+/****************************************************************************
+**
+** 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 QtDataVis3D module.
+**
+** $QT_BEGIN_LICENSE$
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial 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
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui/QGuiApplication>
+#include "qtquick2applicationviewer.h"
+#include <QDebug>
+
+int main(int argc, char *argv[])
+{
+ QGuiApplication app(argc, argv);
+
+ QtQuick2ApplicationViewer viewer;
+#ifdef Q_OS_ANDROID
+ viewer.addImportPath(QString::fromLatin1("assets:/qml"));
+ viewer.engine()->addPluginPath(QString::fromLatin1("%1/../%2").arg(QDir::homePath(),
+ QString::fromLatin1("lib")));
+#else
+ viewer.addImportPath(QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(),
+ QString::fromLatin1("qml")));
+#endif
+ viewer.setMainQmlFile(QStringLiteral("qml/qmlmaps/main.qml"));
+ viewer.setResizeMode(QQuickView::SizeRootObjectToView);
+ viewer.show();
+
+ return app.exec();
+}
diff --git a/examples/qmlmaps/qml/qmlmaps/main.qml b/examples/qmlmaps/qml/qmlmaps/main.qml
new file mode 100644
index 00000000..0f8d618c
--- /dev/null
+++ b/examples/qmlmaps/qml/qmlmaps/main.qml
@@ -0,0 +1,125 @@
+/****************************************************************************
+**
+** 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 QtDataVis3D module.
+**
+** $QT_BEGIN_LICENSE$
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial 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
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.1
+import QtQuick.Controls 1.0
+import com.digia.QtDataVis3D 1.0
+
+Item {
+ id: mainview
+ width: 800
+ height: 500
+ visible: true
+
+ Item {
+ id: dataView
+ width: parent.width - shadowToggle.width
+ height: parent.height
+ anchors.right: parent.right;
+
+ Image {
+ id: testimage
+ source: "qrc:/images/image.jpg"
+ }
+
+ DataItem {
+ id: testitem1
+ label: "Test"
+ value: 200
+ position: "100.0, 200.0"
+ }
+ DataItem {
+ id: testitem2
+ label: "Test2"
+ value: 300
+ position: "200.0, 200.0"
+ }
+ DataItem {
+ id: testitem3
+ label: "Test3"
+ value: 400
+ position: "100.0, 100.0"
+ }
+ DataItem {
+ id: testitem4
+ label: "Test4"
+ value: 600
+ position: "200.0, 100.0"
+ }
+
+ Maps3D {
+ id: testmap
+ width: dataView.width
+ height: dataView.height
+
+ Component.onCompleted: {
+ console.log("testmap complete");
+ console.log(testimage);
+ console.log(testimage.sourceSize);
+ setAreaSpecs(Qt.rect(0, 0, testimage.sourceSize.width, testimage.sourceSize.height),
+ testimage);
+ //setImage(testimage);
+ setImage(":/images/image.jpg");
+ shadowQuality = Maps3D.ShadowNone
+ selectionMode = Maps3D.ModeBar
+ labelTransparency = Maps3D.TransparencyFromTheme
+ addDataItem(testitem1);
+ addDataItem(testitem2);
+ addDataItem(testitem3);
+ addDataItem(testitem4);
+ }
+ }
+ }
+
+ Component.onCompleted: {
+ console.log("mainview complete");
+ }
+
+ Rectangle {
+ id: shadowToggle
+ color: "#FFFFFF"
+ x: 0
+ y: 0
+ width: 160
+ height: 80
+
+ TextArea {
+ id: buttonText
+ text: "Toggle Shadows"
+ anchors.fill: parent
+ textColor: "#000000"
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ if (testmap.shadowQuality === Maps3D.ShadowNone) {
+ testmap.shadowQuality = Maps3D.ShadowLow;
+ buttonText.textColor = "#FFFFFF";
+ shadowToggle.color = "#000000";
+ } else {
+ testmap.shadowQuality = Maps3D.ShadowNone;
+ buttonText.textColor = "#000000";
+ shadowToggle.color = "#FFFFFF";
+ }
+ }
+ }
+ }
+}
diff --git a/examples/qmlmaps/qmlmaps.desktop b/examples/qmlmaps/qmlmaps.desktop
new file mode 100644
index 00000000..25959510
--- /dev/null
+++ b/examples/qmlmaps/qmlmaps.desktop
@@ -0,0 +1,11 @@
+[Desktop Entry]
+Encoding=UTF-8
+Version=1.0
+Type=Application
+Terminal=false
+Name=qmlmaps
+Exec=/opt/qmlmaps/bin/qmlmaps
+Icon=qmlmaps64
+X-Window-Icon=
+X-HildonDesk-ShowInToolbar=true
+X-Osso-Type=application/x-executable
diff --git a/examples/qmlmaps/qmlmaps.pro b/examples/qmlmaps/qmlmaps.pro
new file mode 100644
index 00000000..44963d48
--- /dev/null
+++ b/examples/qmlmaps/qmlmaps.pro
@@ -0,0 +1,29 @@
+!include( ../examples.pri ) {
+ error( "Couldn't find the examples.pri file!" )
+}
+
+# Add more folders to ship with the application, here
+folder_01.source = qml/qmlmaps
+folder_01.target = qml
+DEPLOYMENTFOLDERS = folder_01
+
+# Additional import path used to resolve QML modules in Creator's code model
+QML_IMPORT_PATH =
+
+# If your application uses the Qt Mobility libraries, uncomment the following
+# lines and add the respective components to the MOBILITY variable.
+# CONFIG += mobility
+# MOBILITY +=
+
+# The .cpp file which was generated for your project. Feel free to hack it.
+SOURCES += main.cpp
+
+# Installation path
+# target.path =
+
+# Please do not modify the following two lines. Required for deployment.
+include(qtquick2applicationviewer/qtquick2applicationviewer.pri)
+qtcAddDeployment()
+
+RESOURCES += \
+ qmlmaps.qrc
diff --git a/examples/qmlmaps/qmlmaps.qrc b/examples/qmlmaps/qmlmaps.qrc
new file mode 100644
index 00000000..fe17bae3
--- /dev/null
+++ b/examples/qmlmaps/qmlmaps.qrc
@@ -0,0 +1,5 @@
+<RCC>
+ <qresource prefix="/images">
+ <file>image.jpg</file>
+ </qresource>
+</RCC>
diff --git a/examples/qmlmaps/qmlmaps64.png b/examples/qmlmaps/qmlmaps64.png
new file mode 100644
index 00000000..707d5c4e
--- /dev/null
+++ b/examples/qmlmaps/qmlmaps64.png
Binary files differ
diff --git a/examples/qmlmaps/qtquick2applicationviewer/qtquick2applicationviewer.cpp b/examples/qmlmaps/qtquick2applicationviewer/qtquick2applicationviewer.cpp
new file mode 100644
index 00000000..10709d7a
--- /dev/null
+++ b/examples/qmlmaps/qtquick2applicationviewer/qtquick2applicationviewer.cpp
@@ -0,0 +1,81 @@
+// checksum 0x4f6f version 0x90005
+/*
+ This file was generated by the Qt Quick 2 Application wizard of Qt Creator.
+ QtQuick2ApplicationViewer is a convenience class containing mobile device specific
+ code such as screen orientation handling. Also QML paths and debugging are
+ handled here.
+ It is recommended not to modify this file, since newer versions of Qt Creator
+ may offer an updated version of it.
+*/
+
+#include "qtquick2applicationviewer.h"
+
+#include <QtCore/QCoreApplication>
+#include <QtCore/QDir>
+#include <QtQml/QQmlEngine>
+
+class QtQuick2ApplicationViewerPrivate
+{
+ QString mainQmlFile;
+ friend class QtQuick2ApplicationViewer;
+ static QString adjustPath(const QString &path);
+};
+
+QString QtQuick2ApplicationViewerPrivate::adjustPath(const QString &path)
+{
+#if defined(Q_OS_MAC)
+ if (!QDir::isAbsolutePath(path))
+ return QString::fromLatin1("%1/../Resources/%2")
+ .arg(QCoreApplication::applicationDirPath(), path);
+#elif defined(Q_OS_BLACKBERRY)
+ if (!QDir::isAbsolutePath(path))
+ return QString::fromLatin1("app/native/%1").arg(path);
+#elif !defined(Q_OS_ANDROID)
+ QString pathInInstallDir =
+ QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path);
+ if (QFileInfo(pathInInstallDir).exists())
+ return pathInInstallDir;
+ pathInInstallDir =
+ QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path);
+ if (QFileInfo(pathInInstallDir).exists())
+ return pathInInstallDir;
+#endif
+ return path;
+}
+
+QtQuick2ApplicationViewer::QtQuick2ApplicationViewer(QWindow *parent)
+ : QQuickView(parent)
+ , d(new QtQuick2ApplicationViewerPrivate())
+{
+ connect(engine(), SIGNAL(quit()), SLOT(close()));
+ setResizeMode(QQuickView::SizeRootObjectToView);
+}
+
+QtQuick2ApplicationViewer::~QtQuick2ApplicationViewer()
+{
+ delete d;
+}
+
+void QtQuick2ApplicationViewer::setMainQmlFile(const QString &file)
+{
+ d->mainQmlFile = QtQuick2ApplicationViewerPrivate::adjustPath(file);
+#ifdef Q_OS_ANDROID
+ setSource(QUrl(QLatin1String("assets:/")+d->mainQmlFile));
+#else
+ setSource(QUrl::fromLocalFile(d->mainQmlFile));
+#endif
+}
+
+void QtQuick2ApplicationViewer::addImportPath(const QString &path)
+{
+ engine()->addImportPath(QtQuick2ApplicationViewerPrivate::adjustPath(path));
+}
+
+void QtQuick2ApplicationViewer::showExpanded()
+{
+#if defined(Q_WS_SIMULATOR) || defined(Q_OS_QNX)
+ showFullScreen();
+#else
+ show();
+#endif
+}
diff --git a/examples/qmlmaps/qtquick2applicationviewer/qtquick2applicationviewer.h b/examples/qmlmaps/qtquick2applicationviewer/qtquick2applicationviewer.h
new file mode 100644
index 00000000..cf66f140
--- /dev/null
+++ b/examples/qmlmaps/qtquick2applicationviewer/qtquick2applicationviewer.h
@@ -0,0 +1,33 @@
+// checksum 0xfde6 version 0x90005
+/*
+ This file was generated by the Qt Quick 2 Application wizard of Qt Creator.
+ QtQuick2ApplicationViewer is a convenience class containing mobile device specific
+ code such as screen orientation handling. Also QML paths and debugging are
+ handled here.
+ It is recommended not to modify this file, since newer versions of Qt Creator
+ may offer an updated version of it.
+*/
+
+#ifndef QTQUICK2APPLICATIONVIEWER_H
+#define QTQUICK2APPLICATIONVIEWER_H
+
+#include <QtQuick/QQuickView>
+
+class QtQuick2ApplicationViewer : public QQuickView
+{
+ Q_OBJECT
+
+public:
+ explicit QtQuick2ApplicationViewer(QWindow *parent = 0);
+ virtual ~QtQuick2ApplicationViewer();
+
+ void setMainQmlFile(const QString &file);
+ void addImportPath(const QString &path);
+
+ void showExpanded();
+
+private:
+ class QtQuick2ApplicationViewerPrivate *d;
+};
+
+#endif // QTQUICK2APPLICATIONVIEWER_H
diff --git a/examples/qmlmaps/qtquick2applicationviewer/qtquick2applicationviewer.pri b/examples/qmlmaps/qtquick2applicationviewer/qtquick2applicationviewer.pri
new file mode 100644
index 00000000..e5f7990f
--- /dev/null
+++ b/examples/qmlmaps/qtquick2applicationviewer/qtquick2applicationviewer.pri
@@ -0,0 +1,180 @@
+# checksum 0x7b0d version 0x90005
+# This file was generated by the Qt Quick 2 Application wizard of Qt Creator.
+# The code below adds the QtQuick2ApplicationViewer to the project and handles
+# the activation of QML debugging.
+# It is recommended not to modify this file, since newer versions of Qt Creator
+# may offer an updated version of it.
+
+QT += qml quick
+
+SOURCES += $$PWD/qtquick2applicationviewer.cpp
+HEADERS += $$PWD/qtquick2applicationviewer.h
+INCLUDEPATH += $$PWD
+# This file was generated by an application wizard of Qt Creator.
+# The code below handles deployment to Android and Maemo, aswell as copying
+# of the application data to shadow build directories on desktop.
+# It is recommended not to modify this file, since newer versions of Qt Creator
+# may offer an updated version of it.
+
+defineTest(qtcAddDeployment) {
+for(deploymentfolder, DEPLOYMENTFOLDERS) {
+ item = item$${deploymentfolder}
+ greaterThan(QT_MAJOR_VERSION, 4) {
+ itemsources = $${item}.files
+ } else {
+ itemsources = $${item}.sources
+ }
+ $$itemsources = $$eval($${deploymentfolder}.source)
+ itempath = $${item}.path
+ $$itempath= $$eval($${deploymentfolder}.target)
+ export($$itemsources)
+ export($$itempath)
+ DEPLOYMENT += $$item
+}
+
+MAINPROFILEPWD = $$PWD
+
+android-no-sdk {
+ for(deploymentfolder, DEPLOYMENTFOLDERS) {
+ item = item$${deploymentfolder}
+ itemfiles = $${item}.files
+ $$itemfiles = $$eval($${deploymentfolder}.source)
+ itempath = $${item}.path
+ $$itempath = /data/user/qt/$$eval($${deploymentfolder}.target)
+ export($$itemfiles)
+ export($$itempath)
+ INSTALLS += $$item
+ }
+
+ target.path = /data/user/qt
+
+ export(target.path)
+ INSTALLS += target
+} else:android {
+ for(deploymentfolder, DEPLOYMENTFOLDERS) {
+ item = item$${deploymentfolder}
+ itemfiles = $${item}.files
+ $$itemfiles = $$eval($${deploymentfolder}.source)
+ itempath = $${item}.path
+ $$itempath = /assets/$$eval($${deploymentfolder}.target)
+ export($$itemfiles)
+ export($$itempath)
+ INSTALLS += $$item
+ }
+
+ x86 {
+ target.path = /libs/x86
+ } else: armeabi-v7a {
+ target.path = /libs/armeabi-v7a
+ } else {
+ target.path = /libs/armeabi
+ }
+
+ export(target.path)
+ INSTALLS += target
+} else:win32 {
+ copyCommand =
+ for(deploymentfolder, DEPLOYMENTFOLDERS) {
+ source = $$MAINPROFILEPWD/$$eval($${deploymentfolder}.source)
+ source = $$replace(source, /, \\)
+ sourcePathSegments = $$split(source, \\)
+ target = $$OUT_PWD/$$eval($${deploymentfolder}.target)/$$last(sourcePathSegments)
+ target = $$replace(target, /, \\)
+ target ~= s,\\\\\\.?\\\\,\\,
+ !isEqual(source,$$target) {
+ !isEmpty(copyCommand):copyCommand += &&
+ isEqual(QMAKE_DIR_SEP, \\) {
+ copyCommand += $(COPY_DIR) \"$$source\" \"$$target\"
+ } else {
+ source = $$replace(source, \\\\, /)
+ target = $$OUT_PWD/$$eval($${deploymentfolder}.target)
+ target = $$replace(target, \\\\, /)
+ copyCommand += test -d \"$$target\" || mkdir -p \"$$target\" && cp -r \"$$source\" \"$$target\"
+ }
+ }
+ }
+ !isEmpty(copyCommand) {
+ copyCommand = @echo Copying application data... && $$copyCommand
+ copydeploymentfolders.commands = $$copyCommand
+ first.depends = $(first) copydeploymentfolders
+ export(first.depends)
+ export(copydeploymentfolders.commands)
+ QMAKE_EXTRA_TARGETS += first copydeploymentfolders
+ }
+} else:unix {
+ maemo5 {
+ desktopfile.files = $${TARGET}.desktop
+ desktopfile.path = /usr/share/applications/hildon
+ icon.files = $${TARGET}64.png
+ icon.path = /usr/share/icons/hicolor/64x64/apps
+ } else:!isEmpty(MEEGO_VERSION_MAJOR) {
+ desktopfile.files = $${TARGET}_harmattan.desktop
+ desktopfile.path = /usr/share/applications
+ icon.files = $${TARGET}80.png
+ icon.path = /usr/share/icons/hicolor/80x80/apps
+ } else { # Assumed to be a Desktop Unix
+ copyCommand =
+ for(deploymentfolder, DEPLOYMENTFOLDERS) {
+ source = $$MAINPROFILEPWD/$$eval($${deploymentfolder}.source)
+ source = $$replace(source, \\\\, /)
+ macx {
+ target = $$OUT_PWD/$${TARGET}.app/Contents/Resources/$$eval($${deploymentfolder}.target)
+ } else {
+ target = $$OUT_PWD/$$eval($${deploymentfolder}.target)
+ }
+ target = $$replace(target, \\\\, /)
+ sourcePathSegments = $$split(source, /)
+ targetFullPath = $$target/$$last(sourcePathSegments)
+ targetFullPath ~= s,/\\.?/,/,
+ !isEqual(source,$$targetFullPath) {
+ !isEmpty(copyCommand):copyCommand += &&
+ copyCommand += $(MKDIR) \"$$target\"
+ copyCommand += && $(COPY_DIR) \"$$source\" \"$$target\"
+ }
+ }
+ !isEmpty(copyCommand) {
+ copyCommand = @echo Copying application data... && $$copyCommand
+ copydeploymentfolders.commands = $$copyCommand
+ first.depends = $(first) copydeploymentfolders
+ export(first.depends)
+ export(copydeploymentfolders.commands)
+ QMAKE_EXTRA_TARGETS += first copydeploymentfolders
+ }
+ }
+ !isEmpty(target.path) {
+ installPrefix = $${target.path}
+ } else {
+ installPrefix = /opt/$${TARGET}
+ }
+ for(deploymentfolder, DEPLOYMENTFOLDERS) {
+ item = item$${deploymentfolder}
+ itemfiles = $${item}.files
+ $$itemfiles = $$eval($${deploymentfolder}.source)
+ itempath = $${item}.path
+ $$itempath = $${installPrefix}/$$eval($${deploymentfolder}.target)
+ export($$itemfiles)
+ export($$itempath)
+ INSTALLS += $$item
+ }
+
+ !isEmpty(desktopfile.path) {
+ export(icon.files)
+ export(icon.path)
+ export(desktopfile.files)
+ export(desktopfile.path)
+ INSTALLS += icon desktopfile
+ }
+
+ isEmpty(target.path) {
+ target.path = $${installPrefix}/bin
+ export(target.path)
+ }
+ INSTALLS += target
+}
+
+export (ICON)
+export (INSTALLS)
+export (DEPLOYMENT)
+export (LIBS)
+export (QMAKE_EXTRA_TARGETS)
+}
diff --git a/src/datavis3d/doc/src/qtdatavis3d-index.qdoc b/src/datavis3d/doc/src/qtdatavis3d-index.qdoc
index 0c9cf8cc..04564a5a 100644
--- a/src/datavis3d/doc/src/qtdatavis3d-index.qdoc
+++ b/src/datavis3d/doc/src/qtdatavis3d-index.qdoc
@@ -61,6 +61,7 @@
\li \l{Barchart Example}
\li \l{Mapdata Example}
\li \l{Qt Quick 2 Barchart Example}
+ \li \l{Qt Quick 2 Maps Example}
\li \l{Rainfall Example}
\li \l{Spectrum Example}
\li \l{Widget Example}
diff --git a/src/datavis3d/engine/maps3dcontroller.cpp b/src/datavis3d/engine/maps3dcontroller.cpp
index 62f01848..99b25121 100644
--- a/src/datavis3d/engine/maps3dcontroller.cpp
+++ b/src/datavis3d/engine/maps3dcontroller.cpp
@@ -82,8 +82,7 @@ GLfloat distanceMod = 0.0f;
static QVector3D skipColor = QVector3D(255, 255, 255); // Selection texture's background color
Maps3DController::Maps3DController(const QRect &rect)
- : m_paintDevice(0),
- m_barShader(0),
+ : m_barShader(0),
m_depthShader(0),
m_selectionShader(0),
m_backgroundShader(0),
@@ -1448,7 +1447,7 @@ ShadowQuality Maps3DController::shadowQuality()
return m_shadowQuality;
}
-bool Maps3DController::addDataItem(QDataItem* dataItem)
+bool Maps3DController::addDataItem(QDataItem *dataItem)
{
// Check validity
if (!isValid(*dataItem))
@@ -1464,7 +1463,7 @@ bool Maps3DController::addDataItem(QDataItem* dataItem)
return true;
}
-bool Maps3DController::addData(const QVector<QDataItem*> &data)
+bool Maps3DController::addData(const QVector<QDataItem *> &data)
{
// Convert to QDataRow
for (int i = 0; i < data.size(); i++) {
@@ -1507,7 +1506,7 @@ bool Maps3DController::addData(const QDataRow &dataRow)
return true;
}
-bool Maps3DController::setData(const QVector<QDataItem*> &dataRow)
+bool Maps3DController::setData(const QVector<QDataItem *> &dataRow)
{
// Delete previous data
delete m_data;
diff --git a/src/datavis3d/engine/maps3dcontroller_p.h b/src/datavis3d/engine/maps3dcontroller_p.h
index aa18c19d..1716b7cd 100644
--- a/src/datavis3d/engine/maps3dcontroller_p.h
+++ b/src/datavis3d/engine/maps3dcontroller_p.h
@@ -61,7 +61,6 @@
//#define DISPLAY_RENDER_SPEED
-class QOpenGLPaintDevice;
class QPoint;
class QSizeF;
@@ -109,13 +108,13 @@ public:
// Add data set. New data is appended to old data.
// ownership of data is transferred
- bool addData(const QVector<QDataItem*> &data);
+ bool addData(const QVector<QDataItem *> &data);
// ownership of data is transferred
bool addData(const QDataRow &data);
// Add data set. Old data is deleted.
// ownership of data is transferred
- bool setData(const QVector<QDataItem*> &data);
+ bool setData(const QVector<QDataItem *> &data);
// ownership of data is transferred
bool setData(QDataRow *data);
@@ -222,7 +221,6 @@ private:
Maps3DRenderer *m_renderer;
CameraHelper *m_camera;
- QOpenGLPaintDevice *m_paintDevice;
ShaderHelper *m_barShader;
ShaderHelper *m_depthShader;
ShaderHelper *m_selectionShader;
diff --git a/src/datavis3d/engine/q3dmaps.h b/src/datavis3d/engine/q3dmaps.h
index df778475..439f2667 100644
--- a/src/datavis3d/engine/q3dmaps.h
+++ b/src/datavis3d/engine/q3dmaps.h
@@ -172,7 +172,7 @@ protected:
private:
QScopedPointer<Q3DMapsPrivate> d_ptr;
- Q_DISABLE_COPY(Q3DMaps);
+ Q_DISABLE_COPY(Q3DMaps)
};
QT_DATAVIS3D_END_NAMESPACE
diff --git a/src/datavis3d/engine/qdatarow.h b/src/datavis3d/engine/qdatarow.h
index 07c57894..a78bd98b 100644
--- a/src/datavis3d/engine/qdatarow.h
+++ b/src/datavis3d/engine/qdatarow.h
@@ -70,6 +70,7 @@ private:
friend class Bars3dRenderer;
friend class Bars3dController;
friend class Maps3DController;
+ friend class DeclarativeMaps;
friend class QDataSetPrivate;
};
diff --git a/src/datavis3d/engine/qdatarow_p.h b/src/datavis3d/engine/qdatarow_p.h
index ded9bcfe..816a4643 100644
--- a/src/datavis3d/engine/qdatarow_p.h
+++ b/src/datavis3d/engine/qdatarow_p.h
@@ -62,7 +62,7 @@ QT_DATAVIS3D_BEGIN_NAMESPACE
class QDataItem;
-class QDataRowPrivate
+class QT_DATAVIS3D_EXPORT QDataRowPrivate
{
public:
explicit QDataRowPrivate(QDataRow *q, const QString &label = QString());
diff --git a/src/datavis3dqml2/declarativemaps.cpp b/src/datavis3dqml2/declarativemaps.cpp
index 6356f89c..1e93a3bd 100644
--- a/src/datavis3dqml2/declarativemaps.cpp
+++ b/src/datavis3dqml2/declarativemaps.cpp
@@ -41,7 +41,9 @@
#include "declarativemaps.h"
#include "maps3dcontroller_p.h"
+#include "qdataitem.h"
#include "qdatarow.h"
+#include "qdatarow_p.h"
#include <QQuickWindow>
#include <QOpenGLFramebufferObject>
@@ -89,10 +91,15 @@ QSGNode *DeclarativeMaps::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData
}
// Check if properites have changed that need to be applied while on the SGRenderThread
-// if (m_cachedState->m_data) {
-// m_shared->addData(m_cachedState->m_data);
-// m_cachedState->m_data = 0;
-// }
+ if (m_cachedState->m_isAreaRectSet) {
+ m_shared->setAreaSpecs(m_cachedState->m_arearect, m_cachedState->m_image);
+ m_cachedState->m_isAreaRectSet = false;
+ }
+
+ if (m_cachedState->m_isImageSet) {
+ m_shared->setImage(m_cachedState->m_image);
+ m_cachedState->m_isImageSet = false;
+ }
if (m_cachedState->m_isSelectionModeSet) {
m_shared->setSelectionMode(m_cachedState->m_selectionMode);
@@ -109,6 +116,14 @@ QSGNode *DeclarativeMaps::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData
m_cachedState->m_isShadowQualitySet = false;
}
+ if (m_cachedState->m_data) {
+ if (m_cachedState->m_replaceData)
+ m_shared->setData(m_cachedState->m_data);
+ else
+ m_shared->addData(*m_cachedState->m_data);
+ m_cachedState->m_data = 0;
+ }
+
// If old node exists and has right size, reuse it.
if (oldNode && m_initializedSize == boundingRect().size().toSize()) {
// Update bounding rectangle (that has same size as before).
@@ -168,12 +183,24 @@ void DeclarativeMaps::setBarColor(QColor baseColor, QColor heightColor, bool uni
void DeclarativeMaps::setAreaSpecs(const QRect &areaRect, const QImage &image)
{
- m_shared->setAreaSpecs(areaRect, image);
+ m_cachedState->m_arearect = areaRect;
+ m_cachedState->m_isAreaRectSet = true;
+ m_cachedState->m_image = image;
+ update();
}
void DeclarativeMaps::setImage(const QImage &image)
{
- m_shared->setImage(image);
+ m_cachedState->m_image = image;
+ m_cachedState->m_isImageSet = true;
+ update();
+}
+
+void DeclarativeMaps::setImage(const QString &imageUrl)
+{
+ m_cachedState->m_image = QImage(imageUrl);
+ m_cachedState->m_isImageSet = true;
+ update();
}
void DeclarativeMaps::setSelectionMode(DeclarativeMaps::SelectionMode mode)
@@ -232,34 +259,62 @@ DeclarativeMaps::ShadowQuality DeclarativeMaps::shadowQuality()
return DeclarativeMaps::ShadowQuality(m_shared->shadowQuality());
}
-bool DeclarativeMaps::addDataItem(QDataItem *dataItem)
+void DeclarativeMaps::addDataItem(QDataItem *dataItem)
{
qDebug() << "Enter DeclarativeMaps::addDataItem(QDataItem *dataItem)";
- return m_shared->addDataItem(dataItem);
+ QDataItem *newItem = new QDataItem(*dataItem);
+ m_cachedState->appendData(newItem);
+ update();
}
-bool DeclarativeMaps::addData(const QVector<QDataItem *> &data)
+void DeclarativeMaps::addData(const QVector<QDataItem *> &data)
{
qDebug() << "Enter DeclarativeMaps::addData(const QVector<QDataItem *> &data)";
- return m_shared->addData(data);
+ QDataItem *newItem;
+ for (int i = 0; i < data.count(); i++) {
+ newItem = new QDataItem(*data.at(i));
+ m_cachedState->appendData(newItem);
+ }
+ update();
}
-bool DeclarativeMaps::addData(const QDataRow &dataRow)
+void DeclarativeMaps::addData(const QDataRow &dataRow)
{
qDebug() << "Enter DeclarativeMaps::addData(const QDataRow &dataRow)";
- return m_shared->addData(dataRow);
+ QDataItem *newItem;
+ for (int i = 0; i < dataRow.d_ptr->row().count(); i++) {
+ newItem = new QDataItem(*dataRow.d_ptr->getItem(i));
+ m_cachedState->appendData(newItem);
+ }
+ update();
}
-bool DeclarativeMaps::setData(const QVector<QDataItem *> &data)
+void DeclarativeMaps::setData(const QVector<QDataItem *> &data)
{
qDebug() << "Enter DeclarativeMaps::setData(const QVector<QDataItem *> &data)";
- return m_shared->setData(data);
+ QDataItem *newItem;
+ delete m_cachedState->m_data;
+ m_cachedState->m_data = new QDataRow();
+ for (int i = 0; i < data.count(); i++) {
+ newItem = new QDataItem(*data.at(i));
+ m_cachedState->appendData(newItem);
+ }
+ m_cachedState->m_replaceData = true;
+ update();
}
-bool DeclarativeMaps::setData(QDataRow *data)
+void DeclarativeMaps::setData(QDataRow *data)
{
qDebug() << "Enter DeclarativeMaps::setData(const QVector<QDataItem*> &data)";
- return m_shared->setData(data);
+ QDataItem *newItem;
+ delete m_cachedState->m_data;
+ m_cachedState->m_data = new QDataRow();
+ for (int i = 0; i < data->d_ptr->row().count(); i++) {
+ newItem = new QDataItem(*data->d_ptr->getItem(i));
+ m_cachedState->appendData(newItem);
+ }
+ m_cachedState->m_replaceData = true;
+ update();
}
void DeclarativeMaps::mousePressEvent(QMouseEvent *event)
@@ -351,4 +406,13 @@ DeclarativeMapsCachedStatePrivate::~DeclarativeMapsCachedStatePrivate()
{
}
+void DeclarativeMapsCachedStatePrivate::appendData(QDataItem *item)
+{
+ if (!m_data)
+ m_data = new QDataRow();
+
+ m_data->addItem(item);
+ m_replaceData = false;
+}
+
QT_DATAVIS3D_END_NAMESPACE
diff --git a/src/datavis3dqml2/declarativemaps.h b/src/datavis3dqml2/declarativemaps.h
index 78c11641..282fe168 100644
--- a/src/datavis3dqml2/declarativemaps.h
+++ b/src/datavis3dqml2/declarativemaps.h
@@ -105,19 +105,19 @@ public:
// Add data item. New data item is appended to old data.
// ownership of data is transferred
- Q_INVOKABLE bool addDataItem(QDataItem *dataItem);
+ Q_INVOKABLE void addDataItem(QDataItem *dataItem);
// Add data set. New data is appended to old data.
// ownership of data is transferred
- Q_INVOKABLE bool addData(const QVector<QDataItem *> &data);
+ Q_INVOKABLE void addData(const QVector<QDataItem *> &data);
// ownership of data is transferred
- Q_INVOKABLE bool addData(const QDataRow &data);
+ Q_INVOKABLE void addData(const QDataRow &data);
// Add data set. Old data is deleted.
// ownership of data is transferred
- Q_INVOKABLE bool setData(const QVector<QDataItem *> &data);
+ Q_INVOKABLE void setData(const QVector<QDataItem *> &data);
// ownership of data is transferred
- Q_INVOKABLE bool setData(QDataRow *data);
+ Q_INVOKABLE void setData(QDataRow *data);
// bar specifications; base thickness in x, y and z, enum to indicate which direction is increased with value
// TODO: Start using thickness also in adjustment direction; use it as a relative value.
@@ -150,6 +150,7 @@ public:
// Set area image
Q_INVOKABLE void setImage(const QImage &image);
+ Q_INVOKABLE void setImage(const QString &imageUrl);
// TODO: light placement API
diff --git a/src/datavis3dqml2/declarativemaps_p.h b/src/datavis3dqml2/declarativemaps_p.h
index 07a83225..07e38cd9 100644
--- a/src/datavis3dqml2/declarativemaps_p.h
+++ b/src/datavis3dqml2/declarativemaps_p.h
@@ -49,6 +49,7 @@
QT_DATAVIS3D_BEGIN_NAMESPACE
class QDataRow;
+class QDataItem;
class DeclarativeMapsCachedStatePrivate
{
@@ -56,10 +57,19 @@ public:
explicit DeclarativeMapsCachedStatePrivate();
~DeclarativeMapsCachedStatePrivate();
+ void appendData(QDataItem *item);
+
int m_cachedState;
+ bool m_replaceData;
QDataRow *m_data;
+ bool m_isImageSet;
+ QImage m_image;
+
+ bool m_isAreaRectSet;
+ QRect m_arearect;
+
bool m_isSelectionModeSet;
SelectionMode m_selectionMode;