diff options
author | Juha Vuolle <juha.vuolle@nokia.com> | 2011-12-08 10:29:39 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-12-12 05:35:27 +0100 |
commit | 1a3066cc750ad648f94864ab390d46429c2b196f (patch) | |
tree | 2b1d3c48b301cd4a0d58b4f4664c746eb4fd00ab /examples | |
parent | 8115e5739934dcb58029bc6cd8586fc052588361 (diff) | |
download | qtlocation-1a3066cc750ad648f94864ab390d46429c2b196f.tar.gz |
Removed map3d c++ example app as it is deprecated.
Change-Id: If95a13505e67300ccb755b364233d4ed8f85a43f
Reviewed-by: David Laing <david.laing@nokia.com>
Diffstat (limited to 'examples')
-rw-r--r-- | examples/examples.pro | 2 | ||||
-rw-r--r-- | examples/map3d/camerawidget.cpp | 154 | ||||
-rw-r--r-- | examples/map3d/camerawidget.h | 88 | ||||
-rw-r--r-- | examples/map3d/main.cpp | 85 | ||||
-rw-r--r-- | examples/map3d/mainwidget.cpp | 344 | ||||
-rw-r--r-- | examples/map3d/mainwidget.h | 90 | ||||
-rw-r--r-- | examples/map3d/map3d.pro | 26 | ||||
-rw-r--r-- | examples/map3d/tileview.cpp | 282 | ||||
-rw-r--r-- | examples/map3d/tileview.h | 92 |
9 files changed, 1 insertions, 1162 deletions
diff --git a/examples/examples.pro b/examples/examples.pro index 2bc9ce71..38d2cf30 100644 --- a/examples/examples.pro +++ b/examples/examples.pro @@ -1,2 +1,2 @@ TEMPLATE = subdirs -SUBDIRS += declarative map3d logfilepositionsource +SUBDIRS += declarative logfilepositionsource diff --git a/examples/map3d/camerawidget.cpp b/examples/map3d/camerawidget.cpp deleted file mode 100644 index 22a6fd3d..00000000 --- a/examples/map3d/camerawidget.cpp +++ /dev/null @@ -1,154 +0,0 @@ -/**************************************************************************** -** -** 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 examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** $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/examples/map3d/camerawidget.h b/examples/map3d/camerawidget.h deleted file mode 100644 index 0ede222d..00000000 --- a/examples/map3d/camerawidget.h +++ /dev/null @@ -1,88 +0,0 @@ -/**************************************************************************** -** -** 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 examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef CAMERAWIDGET_H -#define CAMERAWIDGET_H - -#include <QWidget> - -#include "cameradata.h" - -QT_BEGIN_NAMESPACE -class QLineEdit; -class QPushButton; -QT_END_NAMESPACE - -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/examples/map3d/main.cpp b/examples/map3d/main.cpp deleted file mode 100644 index e324d848..00000000 --- a/examples/map3d/main.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/**************************************************************************** -** -** 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 examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** $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/examples/map3d/mainwidget.cpp b/examples/map3d/mainwidget.cpp deleted file mode 100644 index fd8edeb8..00000000 --- a/examples/map3d/mainwidget.cpp +++ /dev/null @@ -1,344 +0,0 @@ -/**************************************************************************** -** -** 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 examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** $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(QSize(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); - // TODO FIXME does not work anymore, QGLView is not a widget anymore - // show() should show the map as a separate window, but for some reason - // the paintGL won't be called - // layout->addWidget(tileView_, 1); - tileView_->show(); - - 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/examples/map3d/mainwidget.h b/examples/map3d/mainwidget.h deleted file mode 100644 index d35e8792..00000000 --- a/examples/map3d/mainwidget.h +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** -** -** 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 examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef MAINWIDGET_H -#define MAINWIDGET_H - -#include <QWidget> - -class TileView; -class CameraWidget; - -QT_BEGIN_NAMESPACE -class QTextEdit; -class QPushButton; -class QLineEdit; -class QComboBox; -QT_END_NAMESPACE - -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/examples/map3d/map3d.pro b/examples/map3d/map3d.pro deleted file mode 100644 index a0e37d8f..00000000 --- a/examples/map3d/map3d.pro +++ /dev/null @@ -1,26 +0,0 @@ - -TEMPLATE = app -TARGET = map3d - -CONFIG += qt warn_on - -QT += network location qt3d widgets - -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/examples/map3d/tileview.cpp b/examples/map3d/tileview.cpp deleted file mode 100644 index 95c7c0ff..00000000 --- a/examples/map3d/tileview.cpp +++ /dev/null @@ -1,282 +0,0 @@ -/**************************************************************************** -** -** 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 examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "tileview.h" - -#include "tilecache.h" -#include "tile.h" -#include "cameradata.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 <qopenglcontext.h> - -#include <cmath> - -#include <QDebug> - - -static void ensureContext(QWindow &win, QOpenGLContext &ctx) -{ - QSurfaceFormat format; - format.setSwapBehavior(QSurfaceFormat::DoubleBuffer); - ctx.setFormat(format); - ctx.create(); - // TODO: is it possible that the platform will downgrade the actual - // format, or will it just fail if it can't deliver the actual format - format = ctx.format(); - ctx.makeCurrent(&win); -} - -TileView::TileView(TileCache *tileCache) : - tileCache_(tileCache) -{ - serviceProvider_ = new QGeoServiceProvider("nokia"); - map_ = new Map(tileCache, this); - map_->setMappingManager(serviceProvider_->mappingManager()); - - connect(map_, - SIGNAL(updateRequired()), - this, - SLOT(update())); - - setCamera(map_->glCamera()); -} - -TileView::~TileView() -{ - delete serviceProvider_; -} - -Map* TileView::map() -{ - return map_; -} - -void TileView::closeEvent(QCloseEvent *) -{ - qApp->quit(); -} - -void TileView::paintGL(QGLPainter *painter) -{ - Q_UNUSED(painter); - qDebug() << "-----------------------" << __FUNCTION__; - // TODO fixme - - QWindow glw; - glw.setSurfaceType(QWindow::OpenGLSurface); - QOpenGLContext ctx; - ensureContext(glw, ctx); - if (!ctx.isValid()) { - qWarning("Example will not render; GL implementation not valid."); - return; - } - QGLPainter glpainter(&glw); - glpainter.begin(); - map_->paintGL(&glpainter); -} - -void TileView::showEvent(QShowEvent *) -{ - updateAspectRatio(); -} - -void TileView::resizeEvent(QResizeEvent *event) -{ - QGLView::resizeEvent(event); - updateAspectRatio(); -} - -void TileView::updateAspectRatio() -{ - map_->resize(width(), height()); -} - -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; - default: - break; - } - e->accept(); -} - -void TileView::mouseReleaseEvent(QMouseEvent *) -{ -} - -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/examples/map3d/tileview.h b/examples/map3d/tileview.h deleted file mode 100644 index e38cb0c3..00000000 --- a/examples/map3d/tileview.h +++ /dev/null @@ -1,92 +0,0 @@ -/**************************************************************************** -** -** 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 examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef TILEVIEW_H -#define TILEVIEW_H - -#include <qglview.h> - -#include "cameradata.h" -#include "map.h" - -QT_BEGIN_NAMESPACE -class QGLPainter; -class QGLSceneNode; -class QGeoServiceProvider; -class TileCache; -QT_END_NAMESPACE - -class Tile; -class TileSpec; -class MapSphere; -class ScriptEngine; - -class TileView : public QGLView -{ - Q_OBJECT -public: - explicit TileView(TileCache *tileCache); - ~TileView(); - - Map *map(); - - void paintGL(QGLPainter *painter); - -protected: - void showEvent(QShowEvent *); - void resizeEvent(QResizeEvent *); - 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 |