summaryrefslogtreecommitdiff
path: root/tests/applications
diff options
context:
space:
mode:
authorshubinba <natalia.shubina@nokia.com>2011-10-03 13:34:11 +1000
committerQt by Nokia <qt-info@nokia.com>2011-10-04 07:38:29 +0200
commit14c8f32fb17a1361c068b92bef311259c57d382c (patch)
treee9adf3c29cdcbdd4cf5ca074ef72591432fb1c99 /tests/applications
parent1707481d2f541c3895c8e881b7653c0072d43082 (diff)
downloadqtlocation-14c8f32fb17a1361c068b92bef311259c57d382c.tar.gz
restructure of tests directory
Change-Id: I9665c1a48976720597779be164d93da5087c3133 Reviewed-on: http://codereview.qt-project.org/5907 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Natalia Shubina <natalia.shubina@nokia.com> Reviewed-by: Juha Vuolle <juha.vuolle@nokia.com>
Diffstat (limited to 'tests/applications')
-rw-r--r--tests/applications/map3d/camerawidget.cpp155
-rw-r--r--tests/applications/map3d/camerawidget.h87
-rw-r--r--tests/applications/map3d/main.cpp86
-rw-r--r--tests/applications/map3d/mainwidget.cpp341
-rw-r--r--tests/applications/map3d/mainwidget.h89
-rw-r--r--tests/applications/map3d/map3d.pro26
-rw-r--r--tests/applications/map3d/tileview.cpp293
-rw-r--r--tests/applications/map3d/tileview.h92
8 files changed, 1169 insertions, 0 deletions
diff --git a/tests/applications/map3d/camerawidget.cpp b/tests/applications/map3d/camerawidget.cpp
new file mode 100644
index 00000000..79b86647
--- /dev/null
+++ b/tests/applications/map3d/camerawidget.cpp
@@ -0,0 +1,155 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "camerawidget.h"
+
+#include <QLabel>
+#include <QLineEdit>
+#include <QPushButton>
+#include <QVBoxLayout>
+#include <QGridLayout>
+
+CameraWidget::CameraWidget(QWidget *parent)
+ : QWidget(parent)
+{
+ setupUi();
+}
+
+void CameraWidget::setupUi()
+{
+ QLabel *latLabel = new QLabel("Latitude");
+ lat_ = new QLineEdit();
+
+ QLabel *lonLabel = new QLabel("Longitude");
+ lon_ = new QLineEdit();
+
+ QLabel *distanceLabel = new QLabel("Distance");
+ distance_ = new QLineEdit();
+
+ QLabel *zoomLevelLabel = new QLabel("Zoom Level");
+ zoomLevel_ = new QLineEdit();
+
+ QLabel *zoomFactorLabel = new QLabel("Zoom Factor");
+ zoomFactor_ = new QLineEdit();
+
+ QLabel *bearingLabel = new QLabel("Bearing");
+ bearing_ = new QLineEdit();
+
+ QLabel *tiltLabel = new QLabel("Tilt");
+ tilt_ = new QLineEdit();
+
+ QLabel *rollLabel = new QLabel("Roll");
+ roll_ = new QLineEdit();
+
+ QGridLayout *grid = new QGridLayout();
+ grid->addWidget(latLabel, 0, 0);
+ grid->addWidget(lat_, 0, 1);
+ grid->addWidget(lonLabel, 1, 0);
+ grid->addWidget(lon_, 1, 1);
+ grid->addWidget(distanceLabel, 2, 0);
+ grid->addWidget(distance_, 2, 1);
+ grid->addWidget(zoomLevelLabel, 3, 0);
+ grid->addWidget(zoomLevel_, 3, 1);
+ grid->addWidget(zoomFactorLabel, 4, 0);
+ grid->addWidget(zoomFactor_, 4, 1);
+ grid->addWidget(bearingLabel, 5, 0);
+ grid->addWidget(bearing_, 5, 1);
+ grid->addWidget(tiltLabel, 6, 0);
+ grid->addWidget(tilt_, 6, 1);
+ grid->addWidget(rollLabel, 7, 0);
+ grid->addWidget(roll_, 7, 1);
+
+ update_ = new QPushButton("Update");
+ connect(update_,
+ SIGNAL(clicked()),
+ this,
+ SLOT(updateCamera()));
+
+ capture_ = new QPushButton("Capture");
+ connect(capture_,
+ SIGNAL(clicked()),
+ this,
+ SIGNAL(capture()));
+
+ QVBoxLayout *layout = new QVBoxLayout();
+ layout->addLayout(grid);
+ layout->addWidget(update_);
+ layout->addWidget(capture_);
+
+ setLayout(layout);
+}
+
+CameraData CameraWidget::camera() const
+{
+ return cam_;
+}
+
+void CameraWidget::setCamera(const CameraData& camera)
+{
+ cam_ = camera;
+
+ lat_->setText(QString::number(cam_.center().latitude(), 'g', 10));
+ lon_->setText(QString::number(cam_.center().longitude(), 'g', 10));
+ distance_->setText(QString::number(cam_.distance(), 'g', 4));
+ zoomLevel_->setText(QString::number(cam_.zoomLevel()));
+ zoomFactor_->setText(QString::number(cam_.zoomFactor()));
+ bearing_->setText(QString::number(cam_.bearing(), 'g', 10));
+ tilt_->setText(QString::number(cam_.tilt(), 'g', 10));
+ roll_->setText(QString::number(cam_.roll(), 'g', 10));
+}
+
+void CameraWidget::updateCamera()
+{
+ double lat = lat_->text().toDouble();
+ double lon = lon_->text().toDouble();
+ cam_.setCenter(QGeoCoordinate(lat, lon));
+ if (!zoomFactor_->text().isEmpty()) {
+ cam_.setZoomFactor(zoomFactor_->text().toDouble());
+ } else {
+ cam_.setZoomLevel(zoomLevel_->text().toInt());
+ cam_.setDistance(distance_->text().toDouble());
+ }
+ cam_.setBearing(bearing_->text().toDouble());
+ cam_.setTilt(tilt_->text().toDouble());
+ cam_.setRoll(roll_->text().toDouble());
+
+ emit updated();
+}
diff --git a/tests/applications/map3d/camerawidget.h b/tests/applications/map3d/camerawidget.h
new file mode 100644
index 00000000..a2120089
--- /dev/null
+++ b/tests/applications/map3d/camerawidget.h
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef CAMERAWIDGET_H
+#define CAMERAWIDGET_H
+
+#include <QWidget>
+
+#include "cameradata.h"
+
+class QLineEdit;
+class QPushButton;
+
+class CameraWidget : public QWidget
+{
+ Q_OBJECT
+public:
+ CameraWidget(QWidget *parent = 0);
+
+ CameraData camera() const;
+
+public slots:
+ void setCamera(const CameraData& camera);
+
+private slots:
+ void updateCamera();
+
+signals:
+ void updated();
+ void capture();
+
+private:
+ void setupUi();
+
+ CameraData cam_;
+
+ QLineEdit *lat_;
+ QLineEdit *lon_;
+ QLineEdit *distance_;
+ QLineEdit *zoomLevel_;
+ QLineEdit *zoomFactor_;
+ QLineEdit *bearing_;
+ QLineEdit *tilt_;
+ QLineEdit *roll_;
+ QPushButton *update_;
+ QPushButton *capture_;
+};
+
+#endif // CAMERAWIDGET_H
diff --git a/tests/applications/map3d/main.cpp b/tests/applications/map3d/main.cpp
new file mode 100644
index 00000000..89d8dcc7
--- /dev/null
+++ b/tests/applications/map3d/main.cpp
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QApplication>
+
+#include <QUrl>
+#include <QSettings>
+#include <QProcessEnvironment>
+#include <QNetworkProxyFactory>
+
+#include "mainwidget.h"
+
+int main(int argc, char** argv)
+{
+ QApplication app(argc, argv);
+
+ // not in the tutorial text: set up a proxy server from
+ // a QSettings file if necessary (useful on Linux)
+
+ QApplication::setOrganizationName("Nokia");
+ QApplication::setApplicationName("Maps3D");
+
+ QSettings settings;
+
+ QVariant value = settings.value("http.proxy");
+ if (value.isValid()) {
+ QUrl url(value.toString(), QUrl::TolerantMode);
+ QNetworkProxy proxy;
+ proxy.setType(QNetworkProxy::HttpProxy);
+ proxy.setHostName(url.host());
+ proxy.setPort(url.port(8080));
+ QNetworkProxy::setApplicationProxy(proxy);
+ }
+
+ int bm = 0;
+
+ if (argc == 2) {
+ bool ok = false;
+ bm = QString(QLatin1String(argv[1])).toInt(&ok);
+ if (!ok)
+ bm = 0;
+ }
+
+ MainWidget *w = new MainWidget(0, bm);
+ w->show();
+
+ return app.exec();
+}
diff --git a/tests/applications/map3d/mainwidget.cpp b/tests/applications/map3d/mainwidget.cpp
new file mode 100644
index 00000000..a43f10c7
--- /dev/null
+++ b/tests/applications/map3d/mainwidget.cpp
@@ -0,0 +1,341 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "mainwidget.h"
+
+#include "tilecache.h"
+#include "tileview.h"
+#include "camerawidget.h"
+
+#include <QHBoxLayout>
+#include <QVBoxLayout>
+#include <QGridLayout>
+#include <QTextEdit>
+#include <QPushButton>
+#include <QLabel>
+#include <QLineEdit>
+#include <QTimer>
+#include <QComboBox>
+
+#include <QApplication>
+
+#include <QPropertyAnimation>
+#include <QSequentialAnimationGroup>
+
+MainWidget::MainWidget(QWidget *parent, int bm)
+ : QWidget(parent),
+ exitWhenDone_(false)
+{
+ TileCache *cache = new TileCache();
+
+ tileView_ = new TileView(cache);
+ tileView_->setMinimumSize(450, 450);
+
+ camera1_ = new CameraWidget();
+
+ connect(camera1_,
+ SIGNAL(updated()),
+ this,
+ SLOT(camera1Update()));
+ connect(camera1_,
+ SIGNAL(capture()),
+ this,
+ SLOT(camera1Capture()));
+
+ camera2_ = new CameraWidget();
+
+ animate1_ = new QPushButton("Go");
+ connect(animate1_,
+ SIGNAL(clicked()),
+ this,
+ SLOT(animate1Clicked()));
+
+ animate2_ = new QPushButton("Go");
+ connect(animate2_,
+ SIGNAL(clicked()),
+ this,
+ SLOT(animate2Clicked()));
+
+ QLabel *durationLabel = new QLabel("Duration");
+ duration_ = new QLineEdit();
+ duration_->setText("2000");
+
+ QLabel *easingLabel = new QLabel("Easing Curve");
+ easing_ = new QComboBox();
+ easing_->setEditable(false);
+
+ easing_->addItem("Linear", 0);
+
+ easing_->addItem("InQuad", 1);
+ easing_->addItem("OutQuad", 2);
+ easing_->addItem("InOutQuad", 3);
+ easing_->addItem("OutInQuad", 4);
+
+ easing_->addItem("InCubic", 5);
+ easing_->addItem("OutCubic", 6);
+ easing_->addItem("InOutCubic", 7);
+ easing_->addItem("OutInCubic", 8);
+
+ easing_->addItem("InQuart", 9);
+ easing_->addItem("OutQuart", 10);
+ easing_->addItem("InOutQuart", 11);
+ easing_->addItem("OutInQuart", 12);
+
+ easing_->addItem("InQunit", 13);
+ easing_->addItem("OutQunit", 14);
+ easing_->addItem("InOutQunit", 15);
+ easing_->addItem("OutInQunit", 16);
+
+ easing_->addItem("InSine", 17);
+ easing_->addItem("OutSine", 18);
+ easing_->addItem("InOutSine", 19);
+ easing_->addItem("OutInSine", 20);
+
+ easing_->addItem("InExpo", 21);
+ easing_->addItem("OutExpo", 22);
+ easing_->addItem("InOutExpo", 23);
+ easing_->addItem("OutInExpo", 24);
+
+ easing_->addItem("InCirc", 25);
+ easing_->addItem("OutCirc", 26);
+ easing_->addItem("InOutCirc", 27);
+ easing_->addItem("OutInCirc", 28);
+
+ easing_->addItem("InElastic", 29);
+ easing_->addItem("OutElastic", 30);
+ easing_->addItem("InOutElastic", 31);
+ easing_->addItem("OutInElastic", 32);
+
+ easing_->addItem("InBounce", 33);
+ easing_->addItem("OutBounce", 34);
+ easing_->addItem("InOutBounce", 35);
+ easing_->addItem("OutInBounce", 36);
+
+ easing_->addItem("InBack", 37);
+ easing_->addItem("OutBack", 38);
+ easing_->addItem("InOutBack", 39);
+ easing_->addItem("OutInBack", 40);
+
+ connect(camera2_,
+ SIGNAL(updated()),
+ this,
+ SLOT(camera2Update()));
+ connect(camera2_,
+ SIGNAL(capture()),
+ this,
+ SLOT(camera2Capture()));
+
+ bm1Button_ = new QPushButton("Benchmark 1");
+ connect(bm1Button_,
+ SIGNAL(clicked()),
+ this,
+ SLOT(runBenchmark1()));
+
+ QGridLayout *animateLayout = new QGridLayout;
+ animateLayout->addWidget(durationLabel, 0, 0);
+ animateLayout->addWidget(duration_, 0, 1);
+ animateLayout->addWidget(easingLabel, 1, 0);
+ animateLayout->addWidget(easing_, 1, 1);
+
+ QGridLayout *cameraLayout = new QGridLayout;
+ cameraLayout->addWidget(camera1_, 0, 0);
+ cameraLayout->addWidget(camera2_, 0, 1);
+ cameraLayout->addLayout(animateLayout, 1, 0, 1, 2);
+ cameraLayout->addWidget(animate1_, 2, 0);
+ cameraLayout->addWidget(animate2_, 2, 1);
+ cameraLayout->addWidget(bm1Button_, 3, 0);
+ cameraLayout->setRowStretch(4, 1);
+
+ QHBoxLayout *layout = new QHBoxLayout;
+ layout->addLayout(cameraLayout, 0);
+ layout->addWidget(tileView_, 1);
+
+ CameraData c1;
+ camera1_->setCamera(c1);
+ CameraData c2;
+ c2.setCenter(QGeoCoordinate(-19.2, 146.75));
+ c2.setZoomFactor(8.0);
+ camera2_->setCamera(c2);
+
+ setLayout(layout);
+
+ if (bm == 1) {
+ exitWhenDone_ = true;
+ QTimer::singleShot(0, this, SLOT(runBenchmark1()));
+ }
+}
+
+void MainWidget::runBenchmark1()
+{
+ oldAutoUpdate_ = tileView_->map()->autoUpdate();
+ tileView_->map()->setAutoUpdate(true);
+
+ CameraData newCameraData;
+ newCameraData.setCenter(QGeoCoordinate(-19.2, 146.75));
+ newCameraData.setZoomFactor(8.0);
+ // hack to get the internal projection set in the cameradata object
+ tileView_->map()->setCameraData(newCameraData);
+ CameraData newCamera = tileView_->map()->cameraData();
+
+ CameraData oldCameraData;
+ oldCameraData.setCenter(QGeoCoordinate(-27.5, 153));
+ oldCameraData.setZoomFactor(4.0);
+ // hack to get the internal projection set in the cameradata object
+ tileView_->map()->setCameraData(oldCameraData);
+ CameraData oldCamera = tileView_->map()->cameraData();
+
+ QPropertyAnimation *a20f = new QPropertyAnimation(tileView_->map(), "camera", this);
+ a20f->setStartValue(QVariant::fromValue(oldCamera));
+ a20f->setEndValue(QVariant::fromValue(newCamera));
+ a20f->setDuration(20000);
+
+ QPropertyAnimation *a20b = new QPropertyAnimation(tileView_->map(), "camera", this);
+ a20b->setStartValue(QVariant::fromValue(newCamera));
+ a20b->setEndValue(QVariant::fromValue(oldCamera));
+ a20b->setDuration(20000);
+
+ QPropertyAnimation *a2f = new QPropertyAnimation(tileView_->map(), "camera", this);
+ a2f->setStartValue(QVariant::fromValue(oldCamera));
+ a2f->setEndValue(QVariant::fromValue(newCamera));
+ a2f->setDuration(2000);
+
+ QPropertyAnimation *a2b = new QPropertyAnimation(tileView_->map(), "camera", this);
+ a2b->setStartValue(QVariant::fromValue(newCamera));
+ a2b->setEndValue(QVariant::fromValue(oldCamera));
+ a2b->setDuration(2000);
+
+ QSequentialAnimationGroup *s2 = new QSequentialAnimationGroup(this);
+ s2->addAnimation(a2f);
+ s2->addAnimation(a2b);
+ s2->setLoopCount(10);
+
+ QSequentialAnimationGroup *s = new QSequentialAnimationGroup(this);
+ s->addAnimation(a20f);
+ s->addAnimation(a20b);
+ s->addAnimation(s2);
+
+ if (exitWhenDone_) {
+ connect(s,
+ SIGNAL(finished()),
+ qApp,
+ SLOT(quit()));
+ }
+
+ QTimer::singleShot(0, s, SLOT(start()));
+
+}
+
+void MainWidget::camera1Update()
+{
+ tileView_->map()->setCameraData(camera1_->camera());
+ if (!tileView_->map()->autoUpdate())
+ tileView_->map()->update();
+}
+
+void MainWidget::camera2Update()
+{
+ tileView_->map()->setCameraData(camera2_->camera());
+ if (!tileView_->map()->autoUpdate())
+ tileView_->map()->update();
+}
+
+void MainWidget::camera1Capture()
+{
+ camera1_->setCamera(tileView_->map()->cameraData());
+}
+
+void MainWidget::camera2Capture()
+{
+ camera2_->setCamera(tileView_->map()->cameraData());
+}
+
+void MainWidget::animate1Clicked()
+{
+ oldAutoUpdate_ = tileView_->map()->autoUpdate();
+ tileView_->map()->setAutoUpdate(true);
+ CameraData oldCamera = tileView_->map()->cameraData();
+ CameraData newCamera = camera1_->camera();
+
+ QPropertyAnimation *a = new QPropertyAnimation(tileView_->map(), "camera", this);
+
+ connect(a,
+ SIGNAL(finished()),
+ this,
+ SLOT(animationFinished()));
+
+ a->setStartValue(QVariant::fromValue(oldCamera));
+ a->setEndValue(QVariant::fromValue(newCamera));
+ a->setDuration(duration_->text().toInt());
+ a->setEasingCurve(QEasingCurve::Type(easing_->itemData(easing_->currentIndex()).toInt()));
+
+ QTimer::singleShot(0, a, SLOT(start()));
+}
+
+void MainWidget::animate2Clicked()
+{
+ oldAutoUpdate_ = tileView_->map()->autoUpdate();
+ tileView_->map()->setAutoUpdate(true);
+ CameraData oldCamera = tileView_->map()->cameraData();
+ CameraData newCamera = camera2_->camera();
+
+ QPropertyAnimation *a = new QPropertyAnimation(tileView_->map(), "camera", this);
+
+ connect(a,
+ SIGNAL(finished()),
+ this,
+ SLOT(animationFinished()));
+
+ a->setStartValue(QVariant::fromValue(oldCamera));
+ a->setEndValue(QVariant::fromValue(newCamera));
+ a->setDuration(duration_->text().toInt());
+ a->setEasingCurve(QEasingCurve::Type(easing_->itemData(easing_->currentIndex()).toInt()));
+
+// TilePlan *tp = new TilePlan(a);
+// tileView_->map()->mapCamera()->prepareAnimation(tp);
+// delete tp;
+
+ QTimer::singleShot(0, a, SLOT(start()));
+}
+
+void MainWidget::animationFinished()
+{
+ tileView_->map()->setAutoUpdate(oldAutoUpdate_);
+}
diff --git a/tests/applications/map3d/mainwidget.h b/tests/applications/map3d/mainwidget.h
new file mode 100644
index 00000000..f0cd1955
--- /dev/null
+++ b/tests/applications/map3d/mainwidget.h
@@ -0,0 +1,89 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef MAINWIDGET_H
+#define MAINWIDGET_H
+
+#include <QWidget>
+
+class TileView;
+class CameraWidget;
+
+class QTextEdit;
+class QPushButton;
+class QLineEdit;
+class QComboBox;
+
+class MainWidget : public QWidget
+{
+ Q_OBJECT
+public:
+ MainWidget(QWidget *parent = 0, int bm = 0);
+
+public slots:
+ void camera1Update();
+ void camera1Capture();
+ void camera2Update();
+ void camera2Capture();
+ void animate1Clicked();
+ void animate2Clicked();
+ void animationFinished();
+
+ void runBenchmark1();
+
+private:
+ TileView *tileView_;
+
+ CameraWidget *camera1_;
+ CameraWidget *camera2_;
+ QLineEdit *duration_;
+ QComboBox *easing_;
+ QPushButton *animate1_;
+ QPushButton *animate2_;
+
+ QPushButton *bm1Button_;
+
+ bool exitWhenDone_;
+
+ bool oldAutoUpdate_;
+};
+
+#endif // MAINWIDGET_H
diff --git a/tests/applications/map3d/map3d.pro b/tests/applications/map3d/map3d.pro
new file mode 100644
index 00000000..1430fb92
--- /dev/null
+++ b/tests/applications/map3d/map3d.pro
@@ -0,0 +1,26 @@
+
+TEMPLATE = app
+TARGET = map3d
+
+CONFIG += qt warn_on qt3d
+
+QT += network location
+
+INCLUDEPATH += ../../../src/location/mapsgl/map3d
+
+HEADERS += \
+ camerawidget.h \
+ mainwidget.h \
+ tileview.h
+
+SOURCES += \
+ main.cpp \
+ camerawidget.cpp \
+ mainwidget.cpp \
+ tileview.cpp
+
+#install
+target.path = $$[QT_INSTALL_DEMOS]/qtlocation/map3d
+sources.files = $$SOURCES $HEADERS $$RESOURCES $$FORMS *.pro
+sources.path = $$[QT_INSTALL_DEMOS]/qtlocation/map3d
+INSTALLS += target sources
diff --git a/tests/applications/map3d/tileview.cpp b/tests/applications/map3d/tileview.cpp
new file mode 100644
index 00000000..f3b92b3b
--- /dev/null
+++ b/tests/applications/map3d/tileview.cpp
@@ -0,0 +1,293 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "tileview.h"
+
+#include "tilecache.h"
+#include "tile.h"
+#include "cameradata.h"
+#include "mapitem.h"
+
+#include "qgeocoordinate.h"
+
+#include "qgeoserviceprovider.h"
+#include "qgeomappingmanager.h"
+
+#include <qglscenenode.h>
+#include <qglbuilder.h>
+#include <qgeometrydata.h>
+
+#include <QApplication>
+#include <QKeyEvent>
+#include <QTimer>
+
+#include <QColor>
+
+#include <QPropertyAnimation>
+
+#include <cmath>
+
+#include <QDebug>
+
+TileView::TileView(TileCache *tileCache, QWidget *parent) :
+ QGLView(parent),
+ tileCache_(tileCache)
+{
+ serviceProvider_ = new QGeoServiceProvider("nokia");
+ map_ = new Map(tileCache, this);
+ map_->setMappingManager(serviceProvider_->mappingManager());
+ map_->setAutoUpdate(false);
+
+ connect(map_,
+ SIGNAL(updateRequired()),
+ this,
+ SLOT(update()));
+
+ setCamera(map_->glCamera());
+
+
+ MapItem *item1 = new MapItem;
+ item1->setCoordinate(QGeoCoordinate(-27, 153));
+ item1->setSize(QSizeF(128, 128));
+ item1->setZoom(5);
+ map_->addMapItem(item1);
+
+ MapItem *item2 = new MapItem;
+ item2->setCoordinate(QGeoCoordinate(-27, 153));
+ item2->setSize(QSizeF(128, 128));
+ item2->setAnchor(QPointF(128, 128));
+ item2->setZoom(5);
+ map_->addMapItem(item2);
+
+ MapItem *item3 = new MapItem;
+ item3->setCoordinate(QGeoCoordinate(-27, 153));
+ item3->setSize(QSizeF(256.0, 256.0));
+ item3->setAnchor(QPointF(-256.0, -256.0));
+ item3->setZoom(6);
+ map_->addMapItem(item3);
+}
+
+TileView::~TileView()
+{
+ delete serviceProvider_;
+}
+
+Map* TileView::map()
+{
+ return map_;
+}
+
+void TileView::closeEvent(QCloseEvent *)
+{
+ qApp->quit();
+}
+
+void TileView::paintGL(QGLPainter *painter)
+{
+ map_->paintGL(painter);
+// QGLSceneNode *node = map_->sceneNodeForRendering();
+// if (node) {
+// node->draw(painter);
+// map_->sceneNodeRenderingDone();
+// }
+}
+
+void TileView::showEvent(QShowEvent *)
+{
+ updateAspectRatio();
+}
+
+void TileView::resizeEvent(QResizeEvent *event)
+{
+ QGLView::resizeEvent(event);
+ updateAspectRatio();
+}
+
+void TileView::updateAspectRatio()
+{
+ map_->resize(width(), height());
+}
+
+void TileView::enterEvent(QEvent *)
+{
+ setFocus();
+ grabKeyboard();
+}
+
+void TileView::leaveEvent(QEvent *)
+{
+ releaseKeyboard();
+}
+
+void TileView::keyPressEvent(QKeyEvent *e)
+{
+ CameraData cameraData = map_->cameraData();
+ if (e->key() == Qt::Key_Left) {
+ if (e->modifiers() & Qt::ShiftModifier) {
+ QGeoCoordinate coord = cameraData.center();
+ coord.setLongitude(coord.longitude() - 1);
+ cameraData.setCenter(coord);
+ } else {
+ cameraData.setBearing(cameraData.bearing() - 5.0);
+ }
+ } else if (e->key() == Qt::Key_Right) {
+ if (e->modifiers() & Qt::ShiftModifier) {
+ QGeoCoordinate coord = cameraData.center();
+ coord.setLongitude(coord.longitude() + 1);
+ cameraData.setCenter(coord);
+ } else {
+ cameraData.setBearing(cameraData.bearing() + 5.0);
+ }
+ } else if (e->key() == Qt::Key_Up) {
+ if (e->modifiers() & Qt::ShiftModifier) {
+ QGeoCoordinate coord = cameraData.center();
+ coord.setLatitude(coord.latitude() + 1);
+ cameraData.setCenter(coord);
+ } else {
+ cameraData.setTilt(cameraData.tilt() - 5.0);
+ }
+ } else if (e->key() == Qt::Key_Down) {
+ if (e->modifiers() & Qt::ShiftModifier) {
+ QGeoCoordinate coord = cameraData.center();
+ coord.setLatitude(coord.latitude() - 1);
+ cameraData.setCenter(coord);
+ } else {
+ cameraData.setTilt(cameraData.tilt() + 5.0);
+ }
+ } else if (e->key() == Qt::Key_Plus) {
+ if (e->modifiers() & Qt::ShiftModifier) {
+ cameraData.setDistance(cameraData.distance() / 2.0);
+ cameraData.setZoomLevel(cameraData.zoomLevel() + 1);
+ map_->setCameraData(cameraData);
+ if (!map_->autoUpdate())
+ map_->update();
+ } else {
+ cameraData.setDistance(cameraData.distance() / 1.1);
+ }
+ } else if (e->key() == Qt::Key_Minus) {
+ if (e->modifiers() & Qt::ShiftModifier) {
+ if (cameraData.zoomLevel() != 1)
+ cameraData.setZoomLevel(cameraData.zoomLevel() - 1);
+ cameraData.setDistance(cameraData.distance() * 2.0);
+ map_->setCameraData(cameraData);
+ if (!map_->autoUpdate())
+ map_->update();
+ } else {
+ cameraData.setDistance(cameraData.distance() * 1.1);
+ }
+ } else if (e->key() == Qt::Key_U) {
+ map_->setCameraData(cameraData);
+ if (!map_->autoUpdate())
+ map_->update();
+ }
+ map_->setCameraData(cameraData);
+ update();
+}
+
+//void TileView::wheelEvent(QWheelEvent *e)
+//{
+// CameraData cameraData = map_->cameraData();
+// if (e->delta() > 0) {
+// if (e->modifiers() & Qt::ShiftModifier) {
+// cameraData.setDistance(cameraData.distance() / 2.0);
+// cameraData.setZoomLevel(cameraData.zoomLevel() + 1);
+// map_->setCameraData(cameraData);
+// if (!map_->autoUpdate())
+// map_->update();
+// } else {
+// cameraData.setDistance(cameraData.distance() / 1.1);
+// }
+// } else {
+// if (e->modifiers() & Qt::ShiftModifier) {
+// if (cameraData.zoomLevel() != 1)
+// cameraData.setZoomLevel(cameraData.zoomLevel() - 1);
+// cameraData.setDistance(cameraData.distance() * 2.0);
+// map_->setCameraData(cameraData);
+// if (!map_->autoUpdate())
+// map_->update();
+// } else {
+// cameraData.setDistance(cameraData.distance() * 1.1);
+// }
+// }
+// map_->setCameraData(cameraData);
+// update();
+
+// e->accept();
+//}
+//
+//void TileView::mousePressEvent(QMouseEvent *e)
+//{
+// switch (e->button()) {
+// case Qt::LeftButton:
+// mousePos_ = e->pos();
+//// QGeoCoordinate coord = map_->screenPositionToCoordinate(mousePos_);
+//// qDebug() << __FUNCTION__
+//// << "mousePos " << mousePos_
+//// << " -> coord " << coord
+//// << " -> screen " << map_->coordinateToScreenPosition(coord);
+// break;
+// }
+// e->accept();
+//}
+
+//void TileView::mouseReleaseEvent(QMouseEvent *e)
+//{
+//}
+
+//void TileView::mouseMoveEvent(QMouseEvent *e)
+//{
+// CameraData cameraData = map_->cameraData();
+
+// if ((e->buttons() & Qt::LeftButton) == Qt::LeftButton)
+// {
+// // Pixel pan support?!
+// QPoint delta = (mousePos_ - e->pos()) / 50;
+
+// QGeoCoordinate coord = cameraData.center();
+// coord.setLatitude(coord.latitude() + delta.y());
+// coord.setLongitude(coord.longitude() - delta.x());
+// cameraData.setCenter(coord);
+
+// map_->setCameraData(cameraData);
+// update();
+// }
+// e->accept();
+//}
diff --git a/tests/applications/map3d/tileview.h b/tests/applications/map3d/tileview.h
new file mode 100644
index 00000000..562214b7
--- /dev/null
+++ b/tests/applications/map3d/tileview.h
@@ -0,0 +1,92 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TILEVIEW_H
+#define TILEVIEW_H
+
+#include <qglview.h>
+
+#include "cameradata.h"
+#include "map.h"
+
+class QGLPainter;
+class QGLSceneNode;
+class TileCache;
+class Tile;
+class TileSpec;
+class MapSphere;
+class QGeoServiceProvider;
+class ScriptEngine;
+
+class TileView : public QGLView
+{
+ Q_OBJECT
+public:
+ explicit TileView(TileCache *tileCache, QWidget *parent = 0);
+ ~TileView();
+
+ Map *map();
+
+ void paintGL(QGLPainter *painter);
+
+protected:
+ void showEvent(QShowEvent *);
+ void resizeEvent(QResizeEvent *);
+ void enterEvent(QEvent *);
+ void leaveEvent(QEvent *e);
+ void keyPressEvent(QKeyEvent *e);
+ void closeEvent(QCloseEvent *);
+
+// void wheelEvent(QWheelEvent *e);
+// void mousePressEvent(QMouseEvent *e);
+// void mouseReleaseEvent(QMouseEvent *e);
+// void mouseMoveEvent(QMouseEvent *e);
+
+private:
+ void updateAspectRatio();
+
+ QGeoServiceProvider *serviceProvider_;
+ TileCache *tileCache_;
+ Map *map_;
+ QPoint mousePos_;
+};
+
+#endif // TILEVIEW_H