summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--examples/map3d/tileview.cpp22
-rw-r--r--src/imports/location/location.cpp2
-rw-r--r--src/imports/location/location.pro2
-rw-r--r--src/imports/location/qdeclarativegeomap.cpp88
-rw-r--r--src/imports/location/qdeclarativegeomap_p.h10
-rw-r--r--src/imports/location/qdeclarativegeomapitem.cpp266
-rw-r--r--src/imports/location/qdeclarativegeomapitem_p.h119
-rw-r--r--src/imports/location/qdeclarativegeomapitemview.cpp20
-rw-r--r--src/imports/location/qdeclarativegeomapitemview_p.h6
-rw-r--r--src/location/mapsgl/intervaltree_p.h859
-rw-r--r--src/location/mapsgl/map.cpp72
-rw-r--r--src/location/mapsgl/map.h8
-rw-r--r--src/location/mapsgl/map2d/map2d_p.cpp58
-rw-r--r--src/location/mapsgl/map2d/map2d_p.h1
-rw-r--r--src/location/mapsgl/map3d/map3d_p.cpp4
-rw-r--r--src/location/mapsgl/map3d/map3d_p.h1
-rw-r--r--src/location/mapsgl/map_p.h11
-rw-r--r--src/location/mapsgl/mapitem.cpp189
-rw-r--r--src/location/mapsgl/mapitem.h120
-rw-r--r--src/location/mapsgl/mapitemtree.cpp258
-rw-r--r--src/location/mapsgl/mapitemtree_p.h83
-rw-r--r--src/location/mapsgl/mapsgl.pri5
-rw-r--r--src/location/mapsgl/mapsphere.cpp430
-rw-r--r--src/location/mapsgl/mapsphere_p.h37
-rw-r--r--tests/applications/declarative_map/map3d.qml74
-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
-rw-r--r--tests/auto/auto.pro2
-rw-r--r--tests/auto/intervaltree/intervaltree.pro8
-rw-r--r--tests/auto/intervaltree/tst_intervaltree.cpp772
-rw-r--r--tests/auto/mapitemtree/mapitemtree.pro8
-rw-r--r--tests/auto/mapitemtree/tst_mapitemtree.cpp629
38 files changed, 28 insertions, 5305 deletions
diff --git a/examples/map3d/tileview.cpp b/examples/map3d/tileview.cpp
index 8c27da9e..95c7c0ff 100644
--- a/examples/map3d/tileview.cpp
+++ b/examples/map3d/tileview.cpp
@@ -43,7 +43,6 @@
#include "tilecache.h"
#include "tile.h"
#include "cameradata.h"
-#include "mapitem.h"
#include "qgeocoordinate.h"
@@ -93,27 +92,6 @@ TileView::TileView(TileCache *tileCache) :
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()
diff --git a/src/imports/location/location.cpp b/src/imports/location/location.cpp
index 2686045a..1c6f985c 100644
--- a/src/imports/location/location.cpp
+++ b/src/imports/location/location.cpp
@@ -60,7 +60,6 @@
#include "qdeclarativegeomaneuver_p.h"
#include "qdeclarativegeomapflickable_p.h"
#include "qdeclarativegeomappincharea_p.h"
-#include "qdeclarativegeomapitem_p.h"
#include "qdeclarativegeomapscreenitem_p.h"
#include "qdeclarativegeomapitemview_p.h"
#include "qdeclarativegeomaptype_p.h"
@@ -113,7 +112,6 @@ public:
qmlRegisterType<QDeclarativeGeoServiceProvider>(uri, 5, 0, "Plugin");
qmlRegisterType<QDeclarativeGeoServiceProviderParameter>(uri, 5, 0, "PluginParameter");
qmlRegisterType<QDeclarativeGeoMap>(uri, 5, 0, "Map");
- qmlRegisterType<QDeclarativeGeoMapItem>(uri, 5, 0, "MapItem");
qmlRegisterType<QDeclarativeGeoMapScreenItem>(uri, 5, 0, "MapScreenItem");
qmlRegisterType<QDeclarativeGeoMapItemView>(uri, 5, 0, "MapItemView");
qmlRegisterType<QDeclarativeGeoMapMouseArea>(uri, 5, 0, "MapMouseArea");
diff --git a/src/imports/location/location.pro b/src/imports/location/location.pro
index e5abf489..8c82a3a6 100644
--- a/src/imports/location/location.pro
+++ b/src/imports/location/location.pro
@@ -35,7 +35,6 @@ HEADERS += qdeclarativeposition_p.h \
qdeclarativegeomap_p.h \
qdeclarativegeomapflickable_p.h \
qdeclarativegeomappincharea_p.h \
- qdeclarativegeomapitem_p.h \
qdeclarativegeomaptype_p.h \
qdeclarativegeomapscreenitem_p.h \
mapnode_p.h
@@ -61,7 +60,6 @@ SOURCES += qdeclarativeposition.cpp \
qdeclarativegeomap.cpp \
qdeclarativegeomapflickable.cpp \
qdeclarativegeomappincharea.cpp \
- qdeclarativegeomapitem.cpp \
qdeclarativegeomaptype.cpp \
qdeclarativegeomapscreenitem.cpp \
mapnode.cpp
diff --git a/src/imports/location/qdeclarativegeomap.cpp b/src/imports/location/qdeclarativegeomap.cpp
index 4c6ed71f..08e7d5ae 100644
--- a/src/imports/location/qdeclarativegeomap.cpp
+++ b/src/imports/location/qdeclarativegeomap.cpp
@@ -59,7 +59,6 @@
#include <Qt3D/qglscenenode.h>
#include <Qt3D/qglbuilder.h>
#include <Qt3D/qgeometrydata.h>
-#include "qdeclarativegeomapitem_p.h"
#include <cmath>
#include <qgeoserviceprovider.h>
@@ -140,7 +139,6 @@ QDeclarativeGeoMap::QDeclarativeGeoMap(QQuickItem *parent)
pinchArea_ = new QDeclarativeGeoMapPinchArea(this, this);
}
-
QDeclarativeGeoMap::~QDeclarativeGeoMap()
{
// TODO we do not clear the map items atm
@@ -189,11 +187,6 @@ void QDeclarativeGeoMap::populateMap()
setupMapView(mapView);
continue;
}
- QDeclarativeGeoMapItem* mapItem = qobject_cast<QDeclarativeGeoMapItem*>(kids.at(i));
- if (mapItem) {
- addMapItem(mapItem);
- }
-
QDeclarativeGeoMapItemBase* mapScreenItem = qobject_cast<QDeclarativeGeoMapItemBase*>(kids.at(i));
if (mapScreenItem) {
addMapScreenItem(mapScreenItem);
@@ -295,26 +288,6 @@ QSGNode* QDeclarativeGeoMap::updatePaintNode(QSGNode* oldNode, UpdatePaintNodeDa
node->setSize(QSize(width(), height()));
node->update();
- //TODO: refactor below
- if (updateMutex_.tryLock()) {
- if (canvas_) {
- for (int i = 0; i < mapItemsPending_.count(); i++) {
- mapItemsPending_.at(i)->setMap(this);
- mapItems_.append(mapItemsPending_.at(i));
- map_->addMapItem(mapItemsPending_.at(i)->mapItem());
- }
- mapItemsPending_.clear();
- }
-
- // perform any updates needed by items
- // can be optimized if lot of map items: usually the operation is no-op (static map items)
- for (int i = 0; i < mapItems_.count(); ++i)
- mapItems_.at(i)->updateItem();
- updateMutex_.unlock();
- } else {
- QLOC_TRACE1("===== Map item update will be missed, mutex not acquired =====");
- }
-
return node;
}
@@ -947,69 +920,13 @@ void QDeclarativeGeoMap::mouseMoveEvent(QMouseEvent *event)
Note: MapItemViews can not be added with this method.
*/
-// all map item additions and removals, whether internal or app originated,
-// must go through these functions
-void QDeclarativeGeoMap::addMapItem(QDeclarativeGeoMapItem *item)
-{
- QLOC_TRACE0;
- if (!item || mapItems_.contains(item) || mapItemsPending_.contains(item))
- return;
- updateMutex_.lock();
- // set pending, we'll add them once we have GL context
- mapItemsPending_.append(item);
- connect(item, SIGNAL(destroyed(QObject*)), this, SLOT(mapItemDestroyed(QObject*)));
- updateMutex_.unlock();
-}
-
-void QDeclarativeGeoMap::removeMapItem(QDeclarativeGeoMapItem *item)
-{
- QLOC_TRACE0;
- if (!item || !map_)
- return;
- if (mapItemsPending_.contains(item)) {
- mapItemsPending_.removeAll(item);
- return;
- }
- if (!mapItems_.contains(item))
- return;
- updateMutex_.lock();
- item->setMap(0);
- // stop listening to destroyed()
- item->disconnect(this);
- // these can be optmized for perf, as we already check the 'contains' above
- mapItems_.removeOne(item);
- mapItemsPending_.removeOne(item);
- map_->removeMapItem(item->mapItem());
- updateMutex_.unlock();
-}
-
-// TODO clears all items including ones from models/MapItemview which is not intended
-void QDeclarativeGeoMap::clearMapItems()
-{
- if (mapItems_.isEmpty() || !map_)
- return;
- updateMutex_.lock();
- mapItems_.clear();
- mapItemsPending_.clear();
- map_->clearMapItems();
- updateMutex_.unlock();
-}
-
-// when a map item is getting destroyed, we need make sure resources are released gracefully
-// with QML we must prepare for arbitrary deletion times
-void QDeclarativeGeoMap::mapItemDestroyed(QObject* item)
-{
- QDeclarativeGeoMapItem* mapItem = qobject_cast<QDeclarativeGeoMapItem*>(item);
- if (mapItem)
- removeMapItem(mapItem);
-}
-
void QDeclarativeGeoMap::addMapScreenItem(QDeclarativeGeoMapItemBase *item)
{
QLOC_TRACE0;
if (!item || mapScreenItems_.contains(item))
return;
updateMutex_.lock();
+ item->setParentItem(this);
item->setMap(this, map_);
mapScreenItems_.append(item);
connect(item, SIGNAL(destroyed(QObject*)), this, SLOT(mapScreenItemDestroyed(QObject*)));
@@ -1024,6 +941,7 @@ void QDeclarativeGeoMap::removeMapScreenItem(QDeclarativeGeoMapItemBase *item)
if (!mapScreenItems_.contains(item))
return;
updateMutex_.lock();
+ item->setParentItem(0);
item->setMap(0, 0);
// stop listening to destroyed()
item->disconnect(this);
@@ -1084,7 +1002,7 @@ QDeclarativeGeoMapType * QDeclarativeGeoMap::activeMapType() const
// This function is strictly for testing purposes
int QDeclarativeGeoMap::testGetDeclarativeMapItemCount()
{
- return mapItems_.count();
+ return 0;
}
#include "moc_qdeclarativegeomap_p.cpp"
diff --git a/src/imports/location/qdeclarativegeomap_p.h b/src/imports/location/qdeclarativegeomap_p.h
index 1b5cb6cf..cedae348 100644
--- a/src/imports/location/qdeclarativegeomap_p.h
+++ b/src/imports/location/qdeclarativegeomap_p.h
@@ -148,11 +148,8 @@ public:
QDeclarativeListProperty<QDeclarativeGeoMapType> supportedMapTypes();
- QDeclarativeListProperty<QDeclarativeGeoMapItem> items();
-
- Q_INVOKABLE void removeMapItem(QDeclarativeGeoMapItem *item);
- Q_INVOKABLE void addMapItem(QDeclarativeGeoMapItem *item);
- Q_INVOKABLE void clearMapItems();
+ // do we need this?
+ //QDeclarativeListProperty<QDeclarativeGeoMapItemBase> items();
Q_INVOKABLE void removeMapScreenItem(QDeclarativeGeoMapItemBase *item);
Q_INVOKABLE void addMapScreenItem(QDeclarativeGeoMapItemBase *item);
@@ -201,7 +198,6 @@ private Q_SLOTS:
void centerLatitudeChanged(double latitude);
void centerLongitudeChanged(double longitude);
void centerAltitudeChanged(double altitude);
- void mapItemDestroyed(QObject* item);
void mapScreenItemDestroyed(QObject* item);
void mappingManagerInitialized();
void mapZoomLevelChanged(qreal zoom);
@@ -249,8 +245,6 @@ private:
TileCache *tileCache_;
Map *map_;
- QList<QDeclarativeGeoMapItem*> mapItems_;
- QList<QDeclarativeGeoMapItem*> mapItemsPending_;
QList<QDeclarativeGeoMapItemBase*> mapScreenItems_;
diff --git a/src/imports/location/qdeclarativegeomapitem.cpp b/src/imports/location/qdeclarativegeomapitem.cpp
deleted file mode 100644
index 4a962624..00000000
--- a/src/imports/location/qdeclarativegeomapitem.cpp
+++ /dev/null
@@ -1,266 +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 QtLocation module 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 "qdeclarativegeomapitem_p.h"
-#include "qdeclarativecoordinate_p.h"
-#include <QtDeclarative/qdeclarativeinfo.h>
-
-#include <QDebug>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \qmlclass MapItem QDeclarativeGeoMapItem
- \inqmlmodule QtLocation 5
-
- The MapItem element is part of the \bold{QtLocation 5.0} module.
-
- \ingroup qml-QtLocation5-maps
-
- \since QtLocation 5.0
-*/
-
-class QDeclarativeGeoMapItemNode : public QSGNode
-{
-public:
- QDeclarativeGeoMapItemNode(QDeclarativeGeoMapItem* item) :
- item_(item)
- {
- Q_ASSERT(item);
- setFlag(UsePreprocess, true);
- }
- ~QDeclarativeGeoMapItemNode() {}
- virtual void preprocess() {
- // TODO mutex protect changing of shaderSource_
- if (!item_->shaderSource_)
- return;
- QSGTextureProvider *provider = item_->shaderSource_->textureProvider();
- if (QQuickShaderEffectTexture *texture = qobject_cast<QQuickShaderEffectTexture *>(provider->texture())) {
- texture->updateTexture();
- }
- }
-private:
- QDeclarativeGeoMapItem* item_;
-};
-
-QDeclarativeGeoMapItem::QDeclarativeGeoMapItem(QQuickItem *parent)
- : QQuickItem(parent),
- shaderSource_(0),
- sourceItem_(0),
- coordinate_(0),
- map_(0),
- componentCompleted_(false)
-{
- setFlag(ItemHasContents);
-}
-
-QDeclarativeGeoMapItem::~QDeclarativeGeoMapItem()
-{
- // Remove this item from map if it still exists (qpointer protection todo).
- if (map_)
- map_->removeMapItem(this);
- delete shaderSource_;
-}
-
-QSGNode* QDeclarativeGeoMapItem::updatePaintNode(QSGNode* node, UpdatePaintNodeData* data)
-{
- Q_UNUSED(data);
- if (!node)
- node = new QDeclarativeGeoMapItemNode(this);
- return node;
-}
-
-MapItem* QDeclarativeGeoMapItem::mapItem()
-{
- return &mapItem_;
-}
-
-void QDeclarativeGeoMapItem::setZoomLevel(double zoom)
-{
- if (zoom == mapItem_.zoom())
- return;
- mapItem_.setZoom(zoom);
- emit zoomLevelChanged();
-}
-
-double QDeclarativeGeoMapItem::zoomLevel()
-{
- return mapItem_.zoom();
-}
-
-bool QDeclarativeGeoMapItem::hasValidTexture()
-{
- if (mapItem_.textureId())
- return true;
- return false;
-}
-
-void QDeclarativeGeoMapItem::setCoordinate(QDeclarativeCoordinate *coordinate)
-{
- if (coordinate_ == coordinate)
- return;
- if (coordinate_)
- coordinate_->disconnect(this);
- coordinate_ = coordinate;
- if (coordinate_) {
- connect(coordinate_,
- SIGNAL(latitudeChanged(double)),
- this,
- SLOT(coordinateCoordinateChanged(double)));
- connect(coordinate_,
- SIGNAL(longitudeChanged(double)),
- this,
- SLOT(coordinateCoordinateChanged(double)));
- connect(coordinate_,
- SIGNAL(altitudeChanged(double)),
- this,
- SLOT(coordinateCoordinateChanged(double)));
- mapItem_.setCoordinate(coordinate->coordinate());
- } else {
- mapItem_.setCoordinate(QGeoCoordinate());
- }
- emit coordinateChanged();
-}
-
-// note: call this only from render thread (e.g. paint() call). todo check this wrt removal
-// this function notably associates and disassociates the item to map
-// and reserves / releases resources accordingly
-void QDeclarativeGeoMapItem::setMap(QDeclarativeGeoMap* map)
-{
- QLOC_TRACE2(map, map_);
- if (map == map_)
- return;
- if (map && map_)
- return; // don't allow association to more than one map
- map_ = map;
-
- if (!map_)
- down();
- else
- up();
-}
-
-void QDeclarativeGeoMapItem::up()
-{
- if (!map_ || !map_->canvas_ || !sourceItem_ || shaderSource_)
- return;
- // QSG -parent ourselves - it glues us to QSG tree and essentially enables rendering
- setParentItem(map_);
- shaderSource_ = new QQuickShaderEffectSource(this);
- shaderSource_->setSourceItem(sourceItem_);
- shaderSource_->setHideSource(true);
- shaderSource_->setParentItem(this);
- mapItem_.setSize(QSize(sourceItem_->width(), sourceItem_->height()));
- connect(shaderSource_, SIGNAL(sourceItemChanged()), this, SIGNAL(sourceItemChanged()));
- connect(shaderSource_->textureProvider(), SIGNAL(textureChanged()), this, SLOT(textureChangedSlot()), Qt::DirectConnection);
-}
-
-void QDeclarativeGeoMapItem::down()
-{
- if (!shaderSource_)
- return;
- setParentItem(0);
- shaderSource_->disconnect(this);
- delete shaderSource_;
- shaderSource_ = 0;
-}
-
-void QDeclarativeGeoMapItem::textureChangedSlot()
-{
- if (!shaderSource_ || !shaderSource_->textureProvider()->texture()) {
- mapItem_.setTextureId(0); // invalidate
- return;
- }
- QLOC_TRACE2("new texture ID: ", shaderSource_->textureProvider()->texture()->textureId());
- mapItem_.setTextureId(shaderSource_->textureProvider()->texture()->textureId());
- mapItem_.setSize(shaderSource_->textureProvider()->texture()->textureSize());
-}
-
-void QDeclarativeGeoMapItem::coordinateCoordinateChanged(double)
-{
- mapItem_.setCoordinate(coordinate_->coordinate());
- emit coordinateChanged();
-}
-
-void QDeclarativeGeoMapItem::updateItem()
-{
- // we seem to not always get texture changed -signals when
- // adding static map items with add
- if (!shaderSource_)
- return;
- if (shaderSource_->textureProvider()->texture() &&
- (GLuint)shaderSource_->textureProvider()->texture()->textureId() != mapItem_.textureId()) {
- QLOC_TRACE2("changing/setting map item texture ID to: ", shaderSource_->textureProvider()->texture()->textureId());
- mapItem_.setTextureId(shaderSource_->textureProvider()->texture()->textureId());
- }
- mapItem_.update();
-}
-
-QDeclarativeCoordinate* QDeclarativeGeoMapItem::coordinate()
-{
- return coordinate_;
-}
-
-void QDeclarativeGeoMapItem::componentComplete()
-{
- componentCompleted_ = true;
- QQuickItem::componentComplete();
-}
-
-void QDeclarativeGeoMapItem::setSourceItem(QQuickItem* sourceItem)
-{
- if (sourceItem == sourceItem_)
- return;
- sourceItem_ = sourceItem;
- down();
- up();
-}
-
-QQuickItem* QDeclarativeGeoMapItem::sourceItem()
-{
- if (!map_ || !shaderSource_)
- return sourceItem_;
- return shaderSource_->sourceItem();
-}
-
-#include "moc_qdeclarativegeomapitem_p.cpp"
-
-QT_END_NAMESPACE
diff --git a/src/imports/location/qdeclarativegeomapitem_p.h b/src/imports/location/qdeclarativegeomapitem_p.h
deleted file mode 100644
index 4aa6d5f1..00000000
--- a/src/imports/location/qdeclarativegeomapitem_p.h
+++ /dev/null
@@ -1,119 +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 QtLocation module 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 QDECLARATIVEGEOMAPITEM_H
-#define QDECLARATIVEGEOMAPITEM_H
-
-#include <QtDeclarative/qquickitem.h>
-#include <QtCore/QCoreApplication>
-#include <QtCore/QPointer>
-
-#include "qsgtexture.h"
-#include "mapitem.h"
-#include "qdeclarativecoordinate_p.h"
-#include "qdeclarativegeomap_p.h"
-
-QT_BEGIN_NAMESPACE
-
-#include <private/qquickshadereffectsource_p.h>
-
-class QDeclarativeGeoMapItem : public QQuickItem
-{
- Q_OBJECT
- Q_PROPERTY(QDeclarativeCoordinate* coordinate READ coordinate WRITE setCoordinate NOTIFY coordinateChanged)
- Q_PROPERTY(QQuickItem* sourceItem READ sourceItem WRITE setSourceItem NOTIFY sourceItemChanged)
- Q_PROPERTY(double zoomLevel READ zoomLevel WRITE setZoomLevel NOTIFY zoomLevelChanged)
- //Q_PROPERTY(bool live READ live WRITE setLive NOTIFY liveChanged)
-
-public:
- QDeclarativeGeoMapItem(QQuickItem *parent = 0);
- ~QDeclarativeGeoMapItem();
-
- // From QDeclarativeParserStatus
- virtual void componentComplete();
-
- void setCoordinate(QDeclarativeCoordinate *coordinate);
- QDeclarativeCoordinate* coordinate();
-
- void setSourceItem(QQuickItem* sourceItem);
- QQuickItem* sourceItem();
-
- void setZoomLevel(double zoomLevel);
- double zoomLevel();
-
- void updateItem();
- void setMap(QDeclarativeGeoMap* map);
-
- MapItem* mapItem();
- bool hasValidTexture();
-
- // from QQuickItem
- QSGNode* updatePaintNode(QSGNode* node, UpdatePaintNodeData* data);
-
-Q_SIGNALS:
- void coordinateChanged();
- void sourceItemChanged();
- void zoomLevelChanged();
-
-private Q_SLOTS:
- void coordinateCoordinateChanged(double);
- void textureChangedSlot();
-
-private:
- void up();
- void down();
- QQuickShaderEffectSource* shaderSource_;
- QQuickItem* sourceItem_;
- QDeclarativeCoordinate* coordinate_;
- QDeclarativeGeoMap* map_;
- // TODO enable didnt compile
- //QPointer<QDeclarativeGeoMap*> map_;
- bool componentCompleted_;
- MapItem mapItem_;
- friend class QDeclarativeGeoMapItemNode;
- Q_DISABLE_COPY(QDeclarativeGeoMapItem);
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QT_PREPEND_NAMESPACE(QDeclarativeGeoMapItem));
-
-#endif
diff --git a/src/imports/location/qdeclarativegeomapitemview.cpp b/src/imports/location/qdeclarativegeomapitemview.cpp
index c4d3441f..0e146520 100644
--- a/src/imports/location/qdeclarativegeomapitemview.cpp
+++ b/src/imports/location/qdeclarativegeomapitemview.cpp
@@ -42,7 +42,7 @@
#include "qdeclarativegeomapitemview_p.h"
#include "qdeclarativegeomapmousearea_p.h"
#include "qdeclarativegeomap_p.h"
-#include "qdeclarativegeomapitem_p.h"
+#include "qdeclarativegeomapscreenitem_p.h"
#include <QDebug>
#include <QDeclarativeParserStatus>
@@ -126,7 +126,7 @@ void QDeclarativeGeoMapItemView::modelReset()
void QDeclarativeGeoMapItemView::modelRowsInserted(QModelIndex, int start, int end)
{
if (!componentCompleted_ || !map_ || !delegate_ || !model_) {
- QDeclarativeGeoMapItem* mapItem;
+ QDeclarativeGeoMapScreenItem* mapItem;
for (int i = start; i <= end; ++i) {
mapItem = createItem(i);
if (!mapItem) {
@@ -135,7 +135,7 @@ void QDeclarativeGeoMapItemView::modelRowsInserted(QModelIndex, int start, int e
mapItemList_.append(mapItem);
// TODO visibility factors need to be solved
//mapItem->setVisible(visible_);
- map_->addMapItem(mapItem);
+ map_->addMapScreenItem(mapItem);
// TODO mouse areas are omitted atm
}
}
@@ -146,11 +146,11 @@ void QDeclarativeGeoMapItemView::modelRowsRemoved(QModelIndex, int start, int en
if (!componentCompleted_ || !map_ || !delegate_ || !model_)
return;
for (int i = end; i >= start; --i) {
- QDeclarativeGeoMapItem *mapItem = mapItemList_.takeAt(i);
+ QDeclarativeGeoMapScreenItem *mapItem = mapItemList_.takeAt(i);
Q_ASSERT(mapItem);
if (!mapItem) // bad
break;
- map_->removeMapItem(mapItem);
+ map_->removeMapScreenItem(mapItem);
delete mapItem;
}
}
@@ -192,7 +192,7 @@ void QDeclarativeGeoMapItemView::removeInstantiatedItems()
if (!map_)
return;
for (int i = 0; i < mapItemList_.count(); ++ i) {
- map_->removeMapItem(mapItemList_.at(i));
+ map_->removeMapScreenItem(mapItemList_.at(i));
}
qDeleteAll(mapItemList_);
mapItemList_.clear();
@@ -210,7 +210,7 @@ void QDeclarativeGeoMapItemView::repopulate()
// We could use more specialized landmark model calls here too,
// but hopefully the support will be leveraged to a general model
// level.
- QDeclarativeGeoMapItem* mapItem;
+ QDeclarativeGeoMapScreenItem* mapItem;
for (int i = 0; i < model_->rowCount(); ++i) {
mapItem = createItem(i);
Q_ASSERT(mapItem);
@@ -218,7 +218,7 @@ void QDeclarativeGeoMapItemView::repopulate()
break;
mapItemList_.append(mapItem);
// TODO what to do with visibility
- map_->addMapItem(mapItem);
+ map_->addMapScreenItem(mapItem);
}
}
@@ -226,7 +226,7 @@ void QDeclarativeGeoMapItemView::repopulate()
// QObject* as data. Some day this may be leveraged to any user defined
// model or e.g. XML model.
//QDeclarativeGeoMapItem* QDeclarativeGeoMapItemView::createItem(int modelRow)
-QDeclarativeGeoMapItem* QDeclarativeGeoMapItemView::createItem(int modelRow)
+QDeclarativeGeoMapScreenItem* QDeclarativeGeoMapItemView::createItem(int modelRow)
{
if (!delegate_ || !model_)
return NULL;
@@ -263,7 +263,7 @@ QDeclarativeGeoMapItem* QDeclarativeGeoMapItemView::createItem(int modelRow)
delete itemContext;
return 0;
}
- QDeclarativeGeoMapItem *declMapObj = qobject_cast<QDeclarativeGeoMapItem*>(obj);
+ QDeclarativeGeoMapScreenItem *declMapObj = qobject_cast<QDeclarativeGeoMapScreenItem*>(obj);
if (!declMapObj) {
qWarning() << "QDeclarativeGeoMapItem map item delegate is of unsupported type.";
delete itemContext;
diff --git a/src/imports/location/qdeclarativegeomapitemview_p.h b/src/imports/location/qdeclarativegeomapitemview_p.h
index 03696bc6..a7d084a2 100644
--- a/src/imports/location/qdeclarativegeomapitemview_p.h
+++ b/src/imports/location/qdeclarativegeomapitemview_p.h
@@ -53,7 +53,7 @@ QT_BEGIN_NAMESPACE
class QAbstractItemModel;
class QDeclarativeGraphicsGeoMap;
class QDeclarativeGeoMap;
-class QDeclarativeGeoMapItem;
+class QDeclarativeGeoMapScreenItem;
class QDeclarativeGeoMapMouseArea;
class QDeclarativeGeoMapItemView : public QObject, public QDeclarativeParserStatus
@@ -87,7 +87,7 @@ public:
void setVisible(bool visible);
bool isVisible() const;
- QDeclarativeGeoMapItem* createItem(int modelRow);
+ QDeclarativeGeoMapScreenItem* createItem(int modelRow);
// From QDeclarativeParserStatus
virtual void componentComplete();
void classBegin() {}
@@ -110,7 +110,7 @@ private:
QVariant modelVariant_;
QAbstractItemModel* model_;
QDeclarativeGeoMap *map_;
- QList<QDeclarativeGeoMapItem*> mapItemList_;
+ QList<QDeclarativeGeoMapScreenItem*> mapItemList_;
};
QT_END_NAMESPACE
diff --git a/src/location/mapsgl/intervaltree_p.h b/src/location/mapsgl/intervaltree_p.h
deleted file mode 100644
index 68ec3ba2..00000000
--- a/src/location/mapsgl/intervaltree_p.h
+++ /dev/null
@@ -1,859 +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 QtLocation module 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 INTERVALTREE_P_H
-#define INTERVALTREE_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QString>
-#include <QRect>
-#include <QPoint>
-
-QT_BEGIN_NAMESPACE
-
-template <class D>
-class AAIntervalTreeNodeOperation;
-
-template <class D>
-class AAIntervalTreeNode
-{
-public:
- AAIntervalTreeNode();
- ~AAIntervalTreeNode();
-
- bool operator == (const AAIntervalTreeNode<D> &other) const;
- bool operator != (const AAIntervalTreeNode<D> &other) const;
-
- AAIntervalTreeNode<D> * find(int min, int max);
-
- AAIntervalTreeNode<D> * insert(int min, int max, D data);
- AAIntervalTreeNode<D> * remove(int min, int max, D data);
-
- void visitRange(int x1, int x2, AAIntervalTreeNodeOperation<D> *op);
-
- D& data();
-
- QList<D> items() const;
- QList<D> itemsAt(int x) const;
- QList<D> itemsWithin(int x1, int x2) const;
-
- QList<AAIntervalTreeNode<D>*> nodes();
- QList<AAIntervalTreeNode<D>*> nodesAt(int x);
- QList<AAIntervalTreeNode<D>*> nodesWithin(int x1, int x2);
-
- QString print(const QString &indent);
-
-private:
- AAIntervalTreeNode<D> * skew();
- AAIntervalTreeNode<D> * split();
-
- bool nodeLess(int min, int max) const;
- bool nodeGreater(int min, int max) const;
-
- int min_;
- int max_;
- int maxTree_;
- D data_;
-
- int level_;
- AAIntervalTreeNode<D> * left_;
- AAIntervalTreeNode<D> * right_;
-};
-
-template <class D>
-class AAIntervalTreeNodeOperation
-{
-public:
- virtual ~AAIntervalTreeNodeOperation() {}
- virtual void apply(D data) = 0;
-};
-
-template <class D>
-AAIntervalTreeNode<D>::AAIntervalTreeNode()
- : min_(-1),
- max_(-1),
- maxTree_(-1),
- level_(0),
- left_(0),
- right_(0)
-{
-}
-
-template <class D>
-AAIntervalTreeNode<D>::~AAIntervalTreeNode()
-{
- if (left_)
- delete left_;
- if (right_)
- delete right_;
-}
-
-template <class D>
-bool AAIntervalTreeNode<D>::operator == (const AAIntervalTreeNode<D> &other) const
-{
- if (min_ != other.min_)
- return false;
-
- if (max_ != other.max_)
- return false;
-
- if (data_ != other.data_)
- return false;
-
- if ((left_ == 0) != (other.left_ == 0))
- return false;
-
- if ((right_ == 0) != (other.right_ == 0))
- return false;
-
- if (left_ && !(*left_ == *(other.left_)))
- return false;
-
- if (right_ && !(*right_ == *(other.right_)))
- return false;
-
- return true;
-}
-
-template <class D>
-bool AAIntervalTreeNode<D>::operator != (const AAIntervalTreeNode<D> &other) const
-{
- return !(*this == other);
-}
-
-template <class D>
-bool AAIntervalTreeNode<D>::nodeLess(int min, int max) const
-{
- if (this->min_ < min)
- return true;
- if (min < this->min_)
- return false;
- return (this->max_ < max);
-}
-
-template <class D>
-bool AAIntervalTreeNode<D>::nodeGreater(int min, int max) const
-{
- if (min < this->min_)
- return true;
- if (this->min_ < min)
- return false;
- return (max < this->max_);
-}
-
-template <class D>
-AAIntervalTreeNode<D> * AAIntervalTreeNode<D>::find(int min, int max)
-{
- if (nodeGreater(min, max)) {
- if (left_)
- return left_->find(min, max);
- return 0;
- } else if (nodeLess(min, max)) {
- if (right_)
- return right_->find(min, max);
- return 0;
- } else {
- return this;
- }
-}
-
-template <class D>
-void AAIntervalTreeNode<D>::visitRange(int x1, int x2, AAIntervalTreeNodeOperation<D> *op)
-{
- if (left_ && (x1 <= left_->maxTree_))
- left_->visitRange(x1, x2, op);
-
- if ((min_ <= x2) && (x1 <= max_))
- op->apply(data_);
-
- if (right_ && (min_ <= x2))
- right_->visitRange(x1, x2, op);
-}
-
-template <class D>
-AAIntervalTreeNode<D> * AAIntervalTreeNode<D>::insert(int min, int max, D data)
-{
- if (level_ == 0) {
- level_ = 1;
- this->min_ = min;
- this->max_ = max;
- this->maxTree_ = max;
- this->data_ = data;
- return this;
- }
-
- if (nodeGreater(min, max)) {
- if (!left_)
- left_ = new AAIntervalTreeNode<D>();
- left_ = left_->insert(min, max, data);
- } else if (nodeLess(min, max)) {
- if (!right_)
- right_ = new AAIntervalTreeNode<D>();
- right_ = right_->insert(min, max, data);
- } else {
- // TODO handle equal case ie don't silently ignore it
- }
-
- AAIntervalTreeNode<D> * result = this->skew()->split();
-
- int m = result->max_;
- if (result->left_)
- m = qMax(m, result->left_->maxTree_);
- if (result->right_)
- m = qMax(m, result->right_->maxTree_);
- result->maxTree_ = m;
-
- return result;
-}
-
-template <class D>
-AAIntervalTreeNode<D> * AAIntervalTreeNode<D>::remove(int min, int max, D data)
-{
- if (nodeGreater(min, max)) {
- if (left_) {
- AAIntervalTreeNode<D> *newLeft = left_->remove(min, max, data);
- if (newLeft) {
- left_ = newLeft;
- } else {
- delete left_;
- left_ = 0;
- }
- }
- } else if (nodeLess(min, max)) {
- if (right_) {
- AAIntervalTreeNode<D> *newRight = right_->remove(min, max, data);
- if (newRight) {
- right_ = newRight;
- } else {
- delete right_;
- right_ = 0;
- }
- }
- } else {
- // TODO handle multiple equal cases
- // - remove particular case
- // - return unless the list of cases is now empty
- if (left_) {
- if (right_) {
- AAIntervalTreeNode<D> *prev = left_;
-
- while (prev->right_)
- prev = prev->right_;
-
- this->min_ = prev->min_;
- this->max_ = prev->max_;
- this->data_ = prev->data_;
-
- left_ = left_->remove(this->min_, this->max_, this->data_);
- } else {
- return left_;
- }
- } else {
- if (right_) {
- return right_;
- } else {
- return 0;
- }
- }
- }
-
- AAIntervalTreeNode<D> *newRoot = this;
-
- if ((left_ && (left_->level_ < level_ - 1))
- || (right_ && (right_->level_ < level_ - 1))) {
-
- if (right_ && (right_->level_ > --level_))
- right_->level_ = level_;
-
- newRoot = newRoot->skew()->split();
- }
-
- int m = newRoot->max_;
- if (newRoot->left_)
- m = qMax(m, newRoot->left_->maxTree_);
- if (newRoot->right_)
- m = qMax(m, newRoot->right_->maxTree_);
- newRoot->maxTree_ = m;
-
- return newRoot;
-}
-
-template <class D>
-D& AAIntervalTreeNode<D>::data()
-{
- return data_;
-}
-
-template <class D>
-QList<D> AAIntervalTreeNode<D>::items() const
-{
- QList<D> result;
-
- if (left_)
- result.append(left_->items());
- result.append(data_);
- if (right_)
- result.append(right_->items());
-
- return result;
-}
-
-template <class D>
-QList<D> AAIntervalTreeNode<D>::itemsAt(int x) const
-{
- QList<D> result;
-
- if (left_ && (x <= left_->maxTree_))
- result.append(left_->itemsAt(x));
- if ((min_ <= x) && (x <= max_))
- result.append(data_);
- if (right_ && (min_ <= x))
- result.append(right_->itemsAt(x));
-
- return result;
-}
-
-template <class D>
-QList<D> AAIntervalTreeNode<D>::itemsWithin(int x1, int x2) const
-{
- QList<D> result;
-
- if (left_ && (x1 <= left_->maxTree_))
- result.append(left_->itemsWithin(x1, x2));
- if ((min_ <= x2) && (x1 <= max_))
- result.append(data_);
- if (right_ && (min_ <= x2))
- result.append(right_->itemsWithin(x1, x2));
-
- return result;
-}
-
-template <class D>
-QList<AAIntervalTreeNode<D>*> AAIntervalTreeNode<D>::nodes()
-{
- QList<AAIntervalTreeNode<D>*> result;
-
- if (left_)
- result.append(left_->nodes());
- result.append(this);
- if (right_)
- result.append(right_->nodes());
-
- return result;
-}
-
-template <class D>
-QList<AAIntervalTreeNode<D>*> AAIntervalTreeNode<D>::nodesAt(int x)
-{
- QList<AAIntervalTreeNode<D>*> result;
-
- if (left_ && (x <= left_->maxTree_))
- result.append(left_->nodesAt(x));
- if ((min_ <= x) && (x <= max_))
- result.append(this);
- if (right_ && (min_ <= x))
- result.append(right_->nodesAt(x));
-
- return result;
-}
-
-template <class D>
-QList<AAIntervalTreeNode<D>*> AAIntervalTreeNode<D>::nodesWithin(int x1, int x2)
-{
- QList<AAIntervalTreeNode<D>*> result;
-
- if (left_ && (x1 <= left_->maxTree_))
- result.append(left_->nodesWithin(x1, x2));
- if ((min_ <= x2) && (x1 <= max_))
- result.append(this);
- if (right_ && (min_ <= x2))
- result.append(right_->nodesWithin(x1, x2));
-
- return result;
-}
-
-template <class D>
-AAIntervalTreeNode<D> * AAIntervalTreeNode<D>::skew()
-{
- if (level_ == 0)
- return this;
-
- AAIntervalTreeNode<D> *newRoot = this;
-
- if (left_ && (level_ == left_->level_)) {
- AAIntervalTreeNode<D> *newRight = this;
-
- newRoot = left_;
- newRight->left_ = newRoot->right_;
- newRoot->right_ = newRight;
- }
-
- if (newRoot->right_)
- newRoot->right_ = newRoot->right_->skew();
-
- return newRoot;
-}
-
-template <class D>
-AAIntervalTreeNode<D> * AAIntervalTreeNode<D>::split()
-{
- if (level_ == 0)
- return this;
-
- AAIntervalTreeNode<D> *newRoot = this;
-
- if (right_ && right_->right_ && (level_ == right_->right_->level_)) {
- AAIntervalTreeNode<D> *newLeft = this;
-
- newRoot = right_;
- newLeft->right_ = newRoot->left_;
- newRoot->left_ = newLeft;
-
- ++(newRoot->level_);
-
- if (newRoot->right_)
- newRoot->right_ = newRoot->right_->split();
- }
-
- return newRoot;
-}
-
-template <class D>
-QString AAIntervalTreeNode<D>::print(const QString &indent)
-{
- QString s;
- s += indent + "level " + QString::number(level_) + "\n";
- s += indent + "min " + QString::number(min_) + "\n";
- s += indent + "max " + QString::number(max_) + "\n";
- s += indent + "maxTree " + QString::number(maxTree_) + "\n";
- s += indent + "left\n";
- if (left_)
- s += left_->print(indent + " ");
- s += indent + "right\n";
- if (right_)
- s += right_->print(indent + " ");
- return s;
-}
-
-template <class D>
-class AAIntervalTree
-{
-public:
- AAIntervalTree();
- ~AAIntervalTree();
-
- bool operator == (const AAIntervalTree<D> &other) const;
- bool operator != (const AAIntervalTree<D> &other) const;
-
- bool isEmpty() const;
-
- void insert(int min, int max, D data);
- void remove(int min, int max, D data);
-
- QList<D> items() const;
- QList<D> itemsAt(int x) const;
- QList<D> itemsWithin(int x1, int x2) const;
-
- QString print();
-
-private:
- AAIntervalTreeNode<D> * root_;
-};
-
-template <class D>
-AAIntervalTree<D>::AAIntervalTree()
- : root_(0) {}
-
-template <class D>
-AAIntervalTree<D>::~AAIntervalTree()
-{
- if (root_)
- delete root_;
-}
-
-template <class D>
-bool AAIntervalTree<D>::operator == (const AAIntervalTree<D> &other) const
-{
- if ((root_ == 0) != (other.root_ == 0))
- return false;
-
- return (*root_ == *(other.root_));
-}
-
-template <class D>
-bool AAIntervalTree<D>::operator != (const AAIntervalTree<D> &other) const
-{
- return !(*this == other);
-}
-
-template <class D>
-bool AAIntervalTree<D>::isEmpty() const
-{
- return (root_ == 0);
-}
-
-template <class D>
-void AAIntervalTree<D>::insert(int min, int max, D data)
-{
- if (!root_)
- root_ = new AAIntervalTreeNode<D>();
- root_ = root_->insert(min, max, data);
-}
-
-template <class D>
-void AAIntervalTree<D>::remove(int min, int max, D data)
-{
- if (!root_)
- return;
-
- AAIntervalTreeNode<D> *newRoot = root_->remove(min, max, data);
- if (newRoot) {
- root_ = newRoot;
- } else {
- delete root_;
- root_ = 0;
- }
-}
-
-template <class D>
-QList<D> AAIntervalTree<D>::items() const
-{
- QList<D> result;
-
- if (root_)
- result = root_->items();
-
- return result;
-}
-
-template <class D>
-QList<D> AAIntervalTree<D>::itemsAt(int x) const
-{
- QList<D> result;
-
- if (root_)
- result = root_->itemsAt(x);
-
- return result;
-}
-
-template <class D>
-QList<D> AAIntervalTree<D>::itemsWithin(int x1, int x2) const
-{
- QList<D> result;
-
- if (root_)
- result = root_->itemsWithin(x1, x2);
-
- return result;
-}
-
-template <class D>
-QString AAIntervalTree<D>::print()
-{
- QString s;
-
- if (root_)
- s = root_->print("");
-
- return s;
-}
-
-template <class D>
-class AAInterval2DTree
-{
-public:
- AAInterval2DTree();
- ~AAInterval2DTree();
-
- bool operator == (const AAInterval2DTree<D> &other) const;
- bool operator != (const AAInterval2DTree<D> &other) const;
-
- bool isEmpty() const;
-
- void insert(const QRect &rect, D data);
- void remove(const QRect &rect, D data);
-
- void visitRect(const QRect &rect, AAIntervalTreeNodeOperation<D> *op);
-
- QList<D> items() const;
- QList<D> itemsAt(const QPoint &point) const;
- QList<D> itemsWithin(const QRect &viewport) const;
-
- QString print();
-
-private:
- AAIntervalTreeNode<AAIntervalTreeNode<QList<D> >*> * root_;
-};
-
-template <class D>
-class InnerOp : public AAIntervalTreeNodeOperation<AAIntervalTreeNode<QList<D> >*>
-{
-public:
- InnerOp(const QRect &rect, AAIntervalTreeNodeOperation<D> *op)
- : rect_(rect), op_(op) {}
-
- void apply(AAIntervalTreeNode<QList<D> >* data) {
- if (!data)
- return;
- data->visitRange(rect_.y(), rect_.y() + rect_.height(), op_);
- }
-
-private:
- QRect rect_;
- AAIntervalTreeNodeOperation<D> *op_;
-};
-
-template <class D>
-AAInterval2DTree<D>::AAInterval2DTree()
- : root_(0) {}
-
-template <class D>
-AAInterval2DTree<D>::~AAInterval2DTree()
-{
- if (root_)
- delete root_;
-}
-
-template <class D>
-bool AAInterval2DTree<D>::operator == (const AAInterval2DTree<D> &other) const
-{
- if ((root_ == 0) != (other.root_ == 0))
- return false;
-
- return (*root_ == *(other.root_));
-}
-
-template <class D>
-bool AAInterval2DTree<D>::operator != (const AAInterval2DTree<D> &other) const
-{
- return !(*this == other);
-}
-
-template <class D>
-bool AAInterval2DTree<D>::isEmpty() const
-{
- return (root_ == 0);
-}
-
-template <class D>
-void AAInterval2DTree<D>::visitRect(const QRect &rect, AAIntervalTreeNodeOperation<D> *op)
-{
- if (!root_)
- return;
-
- AAIntervalTreeNodeOperation<D> *innerOp = new InnerOp<D>(rect, op);
-
- root_->visitRange(rect.x(), rect.x() + rect.width(), innerOp);
-
- delete innerOp;
-}
-
-template <class D>
-void AAInterval2DTree<D>::insert(const QRect &rect, D data)
-{
- if (!root_)
- root_ = new AAIntervalTreeNode<AAIntervalTreeNode<QList<D> >*>();
-
- AAIntervalTreeNode<AAIntervalTreeNode<QList<D> >*> *childNode
- = root_->find(rect.x(), rect.x() + rect.width());
-
- AAIntervalTreeNode<QList<D> > *child = 0;
- if (childNode)
- child = childNode->data();
-
- if (!child)
- child = new AAIntervalTreeNode<QList<D> >();
-
- AAIntervalTreeNode<QList<D> > *grandchildNode
- = child->find(rect.y(), rect.y() + rect.height());
-
- QList<D> list;
-
- if (grandchildNode)
- list = grandchildNode->data();
-
- if (!list.contains(data))
- list.append(data);
-
- if (grandchildNode)
- grandchildNode->data() = list;
- else
- child = child->insert(rect.y(), rect.y() + rect.height(), list);
-
- if (childNode)
- childNode->data() = child;
- else
- root_ = root_->insert(rect.x(), rect.x() + rect.width(), child);
-}
-
-template <class D>
-void AAInterval2DTree<D>::remove(const QRect &rect, D data)
-{
- if (!root_)
- return;
-
- AAIntervalTreeNode<AAIntervalTreeNode<QList<D> >*> *childNode
- = root_->find(rect.x(), rect.x() + rect.width());
-
- if (!childNode)
- return;
-
- AAIntervalTreeNode<QList<D> > *child = childNode->data();
-
- if (!child)
- return;
-
- AAIntervalTreeNode<QList<D> > *grandchildNode
- = child->find(rect.y(), rect.y() + rect.height());
-
- if (!grandchildNode)
- return;
-
- QList<D> list = grandchildNode->data();
-
- if (!list.contains(data))
- return;
-
- list.removeAll(data);
-
- grandchildNode->data() = list;
-
- if (!list.isEmpty())
- return;
-
- AAIntervalTreeNode<QList<D> > * newChild = child->remove(rect.y(), rect.y() + rect.height(), list);
-
- if (newChild) {
- childNode->data() = newChild;
- return;
- }
-
- AAIntervalTreeNode<AAIntervalTreeNode<QList<D> >*> *newRoot
- = root_->remove(rect.x(), rect.x() + rect.width(), child);
-
- delete child;
-
- if (newRoot) {
- root_ = newRoot;
- } else {
- delete root_;
- root_ = 0;
- }
-}
-
-template <class D>
-QList<D> AAInterval2DTree<D>::items() const
-{
- QList<D> result;
-
- if (root_) {
- QList<AAIntervalTreeNode<AAIntervalTreeNode<QList<D> >*>*> tmp1 = root_->nodes();
- for (int i = 0; i < tmp1.size(); ++i) {
- QList<AAIntervalTreeNode<QList<D> >*> tmp2 = tmp1.at(i)->data()->nodes();
- for (int j = 0; j < tmp2.size(); ++j)
- result.append(tmp2.at(j)->data());
- }
- }
-
- return result;
-}
-
-template <class D>
-QList<D> AAInterval2DTree<D>::itemsAt(const QPoint &point) const
-{
- QList<D> result;
-
- if (root_) {
- QList<AAIntervalTreeNode<AAIntervalTreeNode<QList<D> >*>*> tmp1 = root_->nodesAt(point.x());
- for (int i = 0; i < tmp1.size(); ++i) {
- QList<AAIntervalTreeNode<QList<D> >*> tmp2 = tmp1.at(i)->data()->nodesAt(point.y());
- for (int j = 0; j < tmp2.size(); ++j)
- result.append(tmp2.at(j)->data());
- }
- }
-
- return result;
-}
-
-template <class D>
-QList<D> AAInterval2DTree<D>::itemsWithin(const QRect &viewport) const
-{
- QList<D> result;
-
- if (root_) {
- QList<AAIntervalTreeNode<AAIntervalTreeNode<QList<D> >*>*> tmp1
- = root_->nodesWithin(viewport.x(), viewport.x() + viewport.width());
- for (int i = 0; i < tmp1.size(); ++i) {
- QList<AAIntervalTreeNode<QList<D> >*> tmp2
- = tmp1.at(i)->data()->nodesWithin(viewport.y(), viewport.y() + viewport.height());
- for (int j = 0; j < tmp2.size(); ++j)
- result.append(tmp2.at(j)->data());
- }
- }
-
- return result;
-}
-
-template <class D>
-QString AAInterval2DTree<D>::print()
-{
- QString s;
-
- if (root_)
- s = root_->print("");
-
- return s;
-}
-
-QT_END_NAMESPACE
-
-#endif // INTERVALTREE_P_H
-
diff --git a/src/location/mapsgl/map.cpp b/src/location/mapsgl/map.cpp
index c07417e4..9915ddf6 100644
--- a/src/location/mapsgl/map.cpp
+++ b/src/location/mapsgl/map.cpp
@@ -47,7 +47,6 @@
#include "mapsphere_p.h"
#include "projection_p.h"
#include "tile.h"
-#include "mapitem.h"
#include "mapcontroller.h"
#include <QMutex>
@@ -149,41 +148,6 @@ void Map::update()
emit updateRequired();
}
-int Map::numMapItems() const
-{
- return d_ptr->numMapItems();
-}
-
-QList<MapItem*> Map::mapItems() const
-{
- return d_ptr->mapItems();
-}
-
-QList<MapItem*> Map::mapItemsAt(const QPoint &point) const
-{
- return d_ptr->mapItemsAt(point);
-}
-
-QList<MapItem*> Map::mapItemsWithin(const QRect &rect) const
-{
- return d_ptr->mapItemsWithin(rect);
-}
-
-void Map::addMapItem(MapItem *item)
-{
- d_ptr->addMapItem(item);
-}
-
-void Map::removeMapItem(MapItem *item)
-{
- d_ptr->removeMapItem(item);
-}
-
-void Map::clearMapItems()
-{
- d_ptr->clearMapItems();
-}
-
QGeoCoordinate Map::screenPositionToCoordinate(const QPointF &pos, bool clipToViewport) const
{
if (clipToViewport) {
@@ -339,42 +303,6 @@ void MapPrivate::paintGL(QGLPainter *painter)
sphere_->paintGL(painter);
}
-int MapPrivate::numMapItems() const
-{
- return sphere_->numMapItems();
-}
-
-QList<MapItem*> MapPrivate::mapItems() const
-{
- return sphere_->mapItems();
-}
-
-QList<MapItem*> MapPrivate::mapItemsAt(const QPoint &point) const
-{
- return sphere_->mapItemsAt(point);
-}
-
-QList<MapItem*> MapPrivate::mapItemsWithin(const QRect &rect) const
-{
- return sphere_->mapItemsWithin(rect);
-}
-
-void MapPrivate::addMapItem(MapItem *item)
-{
- sphere_->addMapItem(item);
-}
-
-// Must not be called from rendering thread
-void MapPrivate::removeMapItem(MapItem *item)
-{
- sphere_->removeMapItem(item);
-}
-
-void MapPrivate::clearMapItems()
-{
- sphere_->clearMapItems();
-}
-
QVector2D MapPrivate::pointToTile(const QVector3D &point, int zoom, bool roundUp) const
{
QVector2D p = projection_->pointToMercator(point);
diff --git a/src/location/mapsgl/map.h b/src/location/mapsgl/map.h
index 26d3e4c0..5f52bfff 100644
--- a/src/location/mapsgl/map.h
+++ b/src/location/mapsgl/map.h
@@ -94,14 +94,6 @@ public:
void setCameraData(const CameraData &cameraData);
CameraData cameraData() const;
- int numMapItems() const;
- QList<MapItem*> mapItems() const;
- QList<MapItem*> mapItemsAt(const QPoint &point) const;
- QList<MapItem*> mapItemsWithin(const QRect &rect) const;
- void addMapItem(MapItem *item);
- void removeMapItem(MapItem *item);
- void clearMapItems();
-
QGeoCoordinate screenPositionToCoordinate(const QPointF &pos, bool clipToViewport = true) const;
QPointF coordinateToScreenPosition(const QGeoCoordinate &coordinate, bool clipToViewport = true) const;
diff --git a/src/location/mapsgl/map2d/map2d_p.cpp b/src/location/mapsgl/map2d/map2d_p.cpp
index 8a8df5c5..d5c01ab2 100644
--- a/src/location/mapsgl/map2d/map2d_p.cpp
+++ b/src/location/mapsgl/map2d/map2d_p.cpp
@@ -42,7 +42,6 @@
#include "projection2d_p.h"
#include "tile.h"
-#include "mapitem.h"
#include <Qt3D/qgeometrydata.h>
#include <Qt3D/qglbuilder.h>
@@ -859,63 +858,6 @@ QList<TileSpec> Map2DPrivate::tilesFromPoints(const QVector<QVector3D> &points,
return results;
}
-void Map2DPrivate::updateMapItemSceneNode(MapItem *item)
-{
- double z = item->zoom();
-
- if (z < 0) {
- // TODO draw item on camera
- return;
- }
-
- double scale = sideLength_ / (tileSize_ * pow(2, z));
- QPointF anchor = item->anchor() * scale;
- QSizeF size = item->size() * scale;
- double alt = 100.0;
- QVector3D point = projection()->coordToPoint(item->coordinate());
- QVector3D tl = QVector3D(point.x() + anchor.x(), point.y() - anchor.y(), alt);
- QVector3D tr = QVector3D(tl.x() + size.width(), tl.y(), alt);
- QVector3D bl = QVector3D(tl.x(), tl.y() - size.height(), alt);
- QVector3D br = QVector3D(tl.x() + size.width(), tl.y() - size.height(), alt);
-
- QVector3D up(0.0, 0.0, 1.0);
-
- QGeometryData g;
-
- g.appendVertex(tl);
- g.appendNormal(up);
- g.appendTexCoord(QVector2D(0.0, 0.0));
-
- g.appendVertex(bl);
- g.appendNormal(up);
- g.appendTexCoord(QVector2D(0.0, 1.0));
-
- g.appendVertex(br);
- g.appendNormal(up);
- g.appendTexCoord(QVector2D(1.0, 1.0));
-
- g.appendVertex(tr);
- g.appendNormal(up);
- g.appendTexCoord(QVector2D(1.0, 0.0));
-
- QGLBuilder builder;
- builder.addQuads(g);
- QGLSceneNode *node = builder.finalizedSceneNode();
-
- QGLMaterial *mat = new QGLMaterial(node);
- QColor defaultItemColor(128, 128, 128, 256);
- mat->setColor(defaultItemColor);
- mat->setSpecularColor(defaultItemColor);
- mat->setDiffuseColor(defaultItemColor);
- mat->setShininess(1.0);
- node->setEffect(QGL::LitMaterial);
-
- node->setMaterial(mat);
- item->setSceneNode(node);
-
- item->setBounds(QRect(bl.x(), bl.y(), size.width(), size.height()));
-}
-
QGeoCoordinate Map2DPrivate::screenPositionToCoordinate(const QPointF &pos) const
{
double w = width() * 1.0 / viewSize_.width();
diff --git a/src/location/mapsgl/map2d/map2d_p.h b/src/location/mapsgl/map2d/map2d_p.h
index 14201383..27a55bb4 100644
--- a/src/location/mapsgl/map2d/map2d_p.h
+++ b/src/location/mapsgl/map2d/map2d_p.h
@@ -128,7 +128,6 @@ public:
virtual void updateGlCamera(QGLCamera* glCamera);
virtual void updateFrustum(Frustum &frustum);
virtual QList<TileSpec> updateVisibleTiles();
- virtual void updateMapItemSceneNode(MapItem *item);
virtual QGeoCoordinate screenPositionToCoordinate(const QPointF &pos) const;
virtual QPointF coordinateToScreenPosition(const QGeoCoordinate &coordinate) const;
diff --git a/src/location/mapsgl/map3d/map3d_p.cpp b/src/location/mapsgl/map3d/map3d_p.cpp
index c306fd4a..398a0313 100644
--- a/src/location/mapsgl/map3d/map3d_p.cpp
+++ b/src/location/mapsgl/map3d/map3d_p.cpp
@@ -202,10 +202,6 @@ QList<TileSpec> Map3DPrivate::updateVisibleTiles()
return viewport_.visibleTiles();
}
-void Map3DPrivate::updateMapItemSceneNode(MapItem */*item*/)
-{
-}
-
QGeoCoordinate Map3DPrivate::screenPositionToCoordinate(const QPointF &/*pos*/) const
{
return QGeoCoordinate();
diff --git a/src/location/mapsgl/map3d/map3d_p.h b/src/location/mapsgl/map3d/map3d_p.h
index 09995748..8d5ce1dc 100644
--- a/src/location/mapsgl/map3d/map3d_p.h
+++ b/src/location/mapsgl/map3d/map3d_p.h
@@ -71,7 +71,6 @@ public:
virtual void updateGlCamera(QGLCamera* glCamera);
virtual void updateFrustum(Frustum &frustum);
virtual QList<TileSpec> updateVisibleTiles();
- virtual void updateMapItemSceneNode(MapItem *item);
virtual QGeoCoordinate screenPositionToCoordinate(const QPointF &pos) const;
virtual QPointF coordinateToScreenPosition(const QGeoCoordinate &coordinate) const;
diff --git a/src/location/mapsgl/map_p.h b/src/location/mapsgl/map_p.h
index 78dec9e5..b5482ab9 100644
--- a/src/location/mapsgl/map_p.h
+++ b/src/location/mapsgl/map_p.h
@@ -58,7 +58,6 @@
#include "cameradata.h"
#include "frustum_p.h"
-#include "mapitem.h"
#include "maptype.h"
#include <QSharedPointer>
@@ -72,7 +71,6 @@ class Map;
class MapController;
class MapSphere;
class Projection;
-struct MapItemGLResources;
class QGLCamera;
class QGLSceneNode;
@@ -111,13 +109,6 @@ public:
void update();
- int numMapItems() const;
- QList<MapItem*> mapItems() const;
- QList<MapItem*> mapItemsAt(const QPoint &point) const;
- QList<MapItem*> mapItemsWithin(const QRect &rect) const;
- void addMapItem(MapItem *item);
- void removeMapItem(MapItem *item);
- void clearMapItems();
const MapType activeMapType() const;
void setActiveMapType(const MapType mapType);
@@ -128,8 +119,6 @@ public:
QVector3D tileXIntersectToPoint(int zoomLevel, int x) const;
QVector3D tileYIntersectToPoint(int zoomLevel, int y) const;
- virtual void updateMapItemSceneNode(MapItem *item) = 0;
-
protected:
Frustum frustum() const;
diff --git a/src/location/mapsgl/mapitem.cpp b/src/location/mapsgl/mapitem.cpp
deleted file mode 100644
index c2b7cdd0..00000000
--- a/src/location/mapsgl/mapitem.cpp
+++ /dev/null
@@ -1,189 +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 QtLocation module 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 "mapitem.h"
-
-#include <Qt3D/qglscenenode.h>
-#include <Qt3D/qgltexture2d.h>
-#include <Qt3D/qglmaterial.h>
-
-MapItem::MapItem()
- : zoom_(8.0),
- visible_(true),
- textureId_(0), // invalid value according to specs
- textureDirty_(false),
- glResources_(0),
- needsUpdate_(false)
-{
-}
-
-MapItem::~MapItem()
-{
- // map item will not release the GL resources, but it is Map's responsibility
- // to do that (needs to be done in correct thread)
-}
-
-void MapItem::setCoordinate(const QGeoCoordinate &coordinate)
-{
- coordinate_ = coordinate;
-}
-
-QGeoCoordinate MapItem::coordinate() const
-{
- return coordinate_;
-}
-
-void MapItem::setAnchor(const QPointF &anchor)
-{
- anchor_ = anchor;
-}
-
-MapItemGLResources* MapItem::glResources()
-{
- return glResources_;
-}
-
-void MapItem::setGLResources(MapItemGLResources* resources)
-{
- glResources_ = resources;
-}
-
-void MapItem::setTextureId(GLuint textureId)
-{
- needsUpdate_ = true;
- if (textureId_ == textureId)
- return;
- textureId_ = textureId;
- textureDirty_ = true;
-}
-
-GLuint MapItem::textureId()
-{
- return textureId_;
-}
-
-// Note: this function 'must be only' / 'is guaranteed only to be called'
-// when running in the thread that has valid GL context (rendering thread).
-void MapItem::update()
-{
- if (!textureDirty_ || !glResources_->sceneNode)
- return;
- textureDirty_ = false;
- // TODO do we want to provide some default texture if we don't have a texture ID?
- // Also: prepare for case when texture ID is invalidated (after first being valid).
- if (textureId_ != 0) {
- glResources_->texture = QGLTexture2D::fromTextureId(textureId_, size_.toSize()); // todo optimize out the .toSize() call
- glResources_->sceneNode->material()->setTexture(glResources_->texture);
- glResources_->sceneNode->setEffect(QGL::LitDecalTexture2D);
- }
-}
-
-void MapItem::setNeedsUpdate(bool needsUpdate)
-{
- needsUpdate_ = needsUpdate;
-}
-
-bool MapItem::needsUpdate() const
-{
- return needsUpdate_;
-}
-
-QGLTexture2D* MapItem::texture()
-{
- return glResources_->texture;
-}
-
-QPointF MapItem::anchor() const
-{
- return anchor_;
-}
-
-void MapItem::setSize(const QSizeF &size)
-{
- size_ = size;
-}
-
-QSizeF MapItem::size() const
-{
- return size_;
-}
-
-void MapItem::setZoom(double zoom)
-{
- zoom_ = zoom;
-}
-
-double MapItem::zoom() const
-{
- return zoom_;
-}
-
-void MapItem::setSceneNode(QGLSceneNode *sceneNode)
-{
- glResources_->sceneNode = sceneNode;
-}
-
-QGLSceneNode* MapItem::sceneNode() const
-{
- if (!glResources_)
- return 0;
- return glResources_->sceneNode;
-}
-
-// TODO make this into a property and update the item tree when it changes?
-void MapItem::setBounds(const QRect &bounds)
-{
- bounds_ = bounds;
-}
-
-QRect MapItem::bounds() const
-{
- return bounds_;
-}
-
-void MapItem::setVisibleFromViewport(bool visible)
-{
- visible_ = visible;
-}
-
-bool MapItem::visibleFromViewport() const
-{
- return visible_;
-}
diff --git a/src/location/mapsgl/mapitem.h b/src/location/mapsgl/mapitem.h
deleted file mode 100644
index f696141b..00000000
--- a/src/location/mapsgl/mapitem.h
+++ /dev/null
@@ -1,120 +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 QtLocation module 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 MAPITEM_H
-#define MAPITEM_H
-
-#include "qgeocoordinate.h"
-#include <QPointF>
-#include <QSizeF>
-#include <QtOpenGL/qgl.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QGLTexture2D;
-class QGLMaterial;
-class QGLSceneNode;
-
-struct MapItemGLResources {
- QGLSceneNode* sceneNode;
- QGLTexture2D* texture;
- QGLMaterial* defaultMaterial;
- MapItemGLResources() : sceneNode(0), texture(0), defaultMaterial(0) {}
-};
-
-class Q_LOCATION_EXPORT MapItem
-{
-public:
- MapItem();
- ~MapItem();
-
- void setCoordinate(const QGeoCoordinate &coordinate);
- QGeoCoordinate coordinate() const;
-
- void setTextureId(GLuint textureId);
- GLuint textureId();
- QGLTexture2D* texture();
- void update();
-
- void setNeedsUpdate(bool needsUpdate);
- bool needsUpdate() const;
-
- void setAnchor(const QPointF &anchor);
- QPointF anchor() const;
-
- void setSize(const QSizeF &size);
- QSizeF size() const;
-
- void setZoom(double zoom);
- double zoom() const;
-
- void setSceneNode(QGLSceneNode *sceneNode);
- QGLSceneNode* sceneNode() const;
-
- void setBounds(const QRect &bounds);
- QRect bounds() const;
-
- void setVisibleFromViewport(bool visible);
- bool visibleFromViewport() const;
-
- // put to private
- MapItemGLResources* glResources();
- void setGLResources(MapItemGLResources* resources);
-
-private:
- QGeoCoordinate coordinate_;
- QPointF anchor_;
- QSizeF size_;
- double zoom_;
- QRect bounds_;
- bool visible_;
- GLuint textureId_;
- bool textureDirty_;
- MapItemGLResources* glResources_;
- bool needsUpdate_;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // MAPITEM_H
diff --git a/src/location/mapsgl/mapitemtree.cpp b/src/location/mapsgl/mapitemtree.cpp
deleted file mode 100644
index 79e4ce72..00000000
--- a/src/location/mapsgl/mapitemtree.cpp
+++ /dev/null
@@ -1,258 +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 QtLocation module 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 "mapitemtree_p.h"
-#include "mapitem.h"
-
-#include <QHash>
-
-MapItemTree::MapItemTree()
- : root_(new AAInterval2DTree<MapItem*>()) {}
-
-MapItemTree::~MapItemTree()
-{
- delete root_;
-}
-
-void MapItemTree::insert(MapItem *item)
-{
- if (item && item->bounds().isValid())
- root_->insert(item->bounds(), item);
-}
-
-void MapItemTree::remove(MapItem *item)
-{
- if (item && item->bounds().isValid())
- root_->remove(item->bounds(), item);
-}
-
-bool MapItemTree::isEmpty() const
-{
- return root_->isEmpty();
-}
-
-int MapItemTree::size() const
-{
- return root_->items().size();
-}
-
-QList<MapItem*> MapItemTree::items() const
-{
- return root_->items();
-}
-
-QList<MapItem*> MapItemTree::itemsAt(const QPoint &point) const
-{
- return root_->itemsAt(point);
-}
-
-QList<MapItem*> MapItemTree::itemsWithin(const QRect &viewport) const
-{
- return root_->itemsWithin(viewport);
-}
-
-// TODO make static private
-bool checkPoint(const QPoint &p, const QRect &r)
-{
- return ((r.x() <= p.x())
- && (p.x() <= r.x() + r.width())
- && (r.y() <= p.y())
- && (p.y() <= r.y() + r.height()));
-}
-
-bool checkOverlap(const QRect& r1, const QRect &r2)
-{
- return (((r1.x() <= r2.x() + r2.width()) && (r2.x() <= r1.x() + r1.width()))
- &&
- ((r1.y() <= r2.y() + r2.height()) && (r2.y() <= r1.y() + r1.height())));
-}
-
-int getIndex(const QPoint &p, const QRect &oldRec, const QRect &newRect)
-{
- int result = 0;
-
- if (oldRec.isValid() && checkPoint(p, oldRec))
- result += 1;
-
- if (checkPoint(p, newRect))
- result += 2;
-
- return result;
-}
-
-void MapItemTree::makeVisible(const QRect& viewport, QList<MapItem*> &added, QList<MapItem*> &removed)
-{
- added.clear();
- removed.clear();
-
- QList<int> x;
-
- if (viewport_.isValid()) {
- x << viewport_.x();
- if (viewport_.width() != 0)
- x << viewport_.x() + viewport_.width();
- }
-
- x << viewport.x();
- if (viewport.width() != 0)
- x << viewport.x() + viewport.width();
-
- qSort(x.begin(), x.end());
-
- for (int i = x.size() - 1; i > 0; --i) {
- int x1 = x.at(i);
- int x2 = x.at(i - 1);
- if (x1 == x2) {
- x.removeAt(i);
- }
- }
-
- QList<int> y;
-
- if (viewport_.isValid()) {
- y << viewport_.y();
- if (viewport_.height() != 0)
- y << viewport_.y() + viewport_.height();
- }
-
- y << viewport.y();
- if (viewport.height() != 0)
- y << viewport.y() + viewport.height();
-
- qSort(y.begin(), y.end());
-
- for (int i = y.size() - 1; i > 0; --i) {
- int y1 = y.at(i);
- int y2 = y.at(i - 1);
- if (y1 == y2) {
- y.removeAt(i);
- }
- }
-
- QList<QRect> wasVisible;
- QList<QRect> isVisible;
- QRect overlap;
-
- int xsize = x.size();
- int ysize = y.size();
-
- for (int j = 0; j < ysize - 1; ++j) {
- int y1 = y.at(j);
- int y2 = y.at(j + 1);
- for (int i = 0; i < xsize - 1; ++i) {
- int x1 = x.at(i);
- int x2 = x.at(i + 1);
-
- QRect r = QRect(x1, y1, x2 - x1, y2 - y1);
-
- QHash<int, int> counts;
- counts[0] = 0;
- counts[1] = 0;
- counts[2] = 0;
- counts[3] = 0;
-
- counts[getIndex(QPoint(x1, y1), viewport_, viewport)] += 1;
- counts[getIndex(QPoint(x1, y2), viewport_, viewport)] += 1;
- counts[getIndex(QPoint(x2, y1), viewport_, viewport)] += 1;
- counts[getIndex(QPoint(x2, y2), viewport_, viewport)] += 1;
-
- if (counts[0] != 0) {
- continue;
- }
- if (counts[3] == 4) {
- overlap = r;
- continue;
- }
-
- if (counts[1] != 0) {
- if (counts[2] != 0) {
- continue;
- } else {
- wasVisible << r;
- }
- } else {
- if (counts[2] != 0) {
- isVisible << r;
- } else {
- continue;
- }
- }
- }
- }
-
- for (int i = 0; i < wasVisible.size(); ++i) {
-
- QList<MapItem*> items = itemsWithin(wasVisible.at(i));
-
- for (int j = 0; j < items.size(); ++j) {
-
- MapItem *item = items.at(j);
-
- bool inMiddleGround = false;
- if (overlap.isValid())
- inMiddleGround = checkOverlap(item->bounds(), overlap);
-
- if (item->visibleFromViewport() && !inMiddleGround) {
- item->setVisibleFromViewport(false);
- removed << item;
- }
- }
- }
-
- if (overlap.isValid())
- isVisible << overlap;
-
- for (int i = 0; i < isVisible.size(); ++i) {
-
- QList<MapItem*> items = itemsWithin(isVisible.at(i));
-
- for (int j = 0; j < items.size(); ++j) {
-
- MapItem *item = items.at(j);
-
- if (!item->visibleFromViewport()) {
- item->setVisibleFromViewport(true);
- added << item;
- }
- }
- }
-
- viewport_ = viewport;
-}
diff --git a/src/location/mapsgl/mapitemtree_p.h b/src/location/mapsgl/mapitemtree_p.h
deleted file mode 100644
index a7a57f7b..00000000
--- a/src/location/mapsgl/mapitemtree_p.h
+++ /dev/null
@@ -1,83 +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 QtLocation module 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 MAPITEMTREE_P_H
-#define MAPITEMTREE_P_H
-
-#include <QPoint>
-#include <QRect>
-#include <QList>
-#include <QtLocation/qlocationglobal.h>
-
-#include "intervaltree_p.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class MapItem;
-
-class Q_LOCATION_EXPORT MapItemTree
-{
-public:
- MapItemTree();
- ~MapItemTree();
-
- void insert(MapItem *item);
- void remove(MapItem *item);
-
- bool isEmpty() const;
- int size() const;
-
- QList<MapItem*> items() const;
- QList<MapItem*> itemsAt(const QPoint &point) const;
- QList<MapItem*> itemsWithin(const QRect &viewport) const;
- void makeVisible(const QRect& viewport, QList<MapItem*> &added, QList<MapItem*> &removed);
-
-private:
- QRect viewport_;
- AAInterval2DTree<MapItem*> *root_;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // MAPITEMTREE_P__H
diff --git a/src/location/mapsgl/mapsgl.pri b/src/location/mapsgl/mapsgl.pri
index 960479ce..240d7ede 100644
--- a/src/location/mapsgl/mapsgl.pri
+++ b/src/location/mapsgl/mapsgl.pri
@@ -11,8 +11,6 @@ SOURCES += \
mapsgl/frustum.cpp \
mapsgl/map.cpp \
mapsgl/mapcontroller.cpp \
- mapsgl/mapitem.cpp \
- mapsgl/mapitemtree.cpp \
mapsgl/mapsphere.cpp \
mapsgl/projection.cpp \
mapsgl/tilecache.cpp \
@@ -24,7 +22,6 @@ PUBLIC_HEADERS += \
mapsgl/cameradata.h \
mapsgl/map.h \
mapsgl/mapcontroller.h \
- mapsgl/mapitem.h \
mapsgl/tilecache.h \
mapsgl/tile.h \
mapsgl/tilespec.h \
@@ -32,8 +29,6 @@ PUBLIC_HEADERS += \
PRIVATE_HEADERS += \
mapsgl/frustum_p.h \
- mapsgl/intervaltree_p.h \
mapsgl/map_p.h \
- mapsgl/mapitemtree_p.h \
mapsgl/mapsphere_p.h \
mapsgl/projection_p.h
diff --git a/src/location/mapsgl/mapsphere.cpp b/src/location/mapsgl/mapsphere.cpp
index 703c1a27..359ccbbb 100644
--- a/src/location/mapsgl/mapsphere.cpp
+++ b/src/location/mapsgl/mapsphere.cpp
@@ -56,38 +56,6 @@
#include <QVector>
#include <QTimer>
-struct ItemTileResources {
-
- ItemTileResources() :
- node(0),
- fbo(0) {}
-
- bool operator == (const ItemTileResources &other) const {
- return ((fbo == other.fbo) && (node == other.node));
- }
-
- QGLSceneNode *node;
- QOpenGLFramebufferObject *fbo;
-};
-
-struct ItemTileCacheEntry {
-
- ItemTileCacheEntry(MapSphere *mapSphere) :
- mapSphere(mapSphere) {}
-
- ~ItemTileCacheEntry() {
- if (!mapSphere->itemTileEvictions_.contains(resources))
- mapSphere->itemTileEvictions_.append(resources);
- }
-
- MapSphere *mapSphere;
-
- QRect viewport;
- QList<MapItem*> items;
-
- ItemTileResources resources;
-};
-
MapSphere::MapSphere(Map* map, MapPrivate *mapPrivate, TileCache *tileCache)
: QObject(0),
tileCache_(tileCache),
@@ -97,8 +65,6 @@ MapSphere::MapSphere(Map* map, MapPrivate *mapPrivate, TileCache *tileCache)
sphereNode_ = new QGLSceneNode(this);
- itemNode_ = new QGLSceneNode(this);
-
connect(tileCache_,
SIGNAL(prefetchingFinished()),
this,
@@ -161,20 +127,6 @@ void MapSphere::GLContextAvailable()
tileCache_->GLContextAvailable(sphereNode_);
// qDeleteAll(obsoleteNodes_);
// obsoleteNodes_.clear();
-
-
- // remove obsolete scene nodes
- QSet<MapItemGLResources *>::const_iterator i = obsoleteGLResources_.constBegin();
- while (i != obsoleteGLResources_.constEnd()) {
- if (*i) {
- // todo do we have to delete all pointers or will scene node take down everything
- delete (*i)->sceneNode;
- //obsoleteGLResources_.removeAll(*i);
- }
- ++i;
- }
- if (!obsoleteGLResources_.isEmpty())
- obsoleteGLResources_.clear();
}
void MapSphere::update(const QList<TileSpec> &tiles)
@@ -238,94 +190,6 @@ void MapSphere::update(const QList<TileSpec> &tiles)
} else {
tileCache_->prefetch(req.toList());
}
-
- QSet<TileSpec> wereVisible = visibleTiles_.toSet() - tiles.toSet();
- QSet<TileSpec> stillVisible = visibleTiles_.toSet().intersect(tiles.toSet());
- QSet<TileSpec> nowVisible = tiles.toSet() - visibleTiles_.toSet();
-
- visibleTiles_ = tiles;
-
- QSet<TileSpec>::const_iterator a = wereVisible.constBegin();
- QSet<TileSpec>::const_iterator removeEnd = wereVisible.constEnd();
-
- while (a != removeEnd) {
- TileSpec spec = *a;
- removeSpec(spec);
- ++a;
- }
-
- QSet<TileSpec>::const_iterator c = nowVisible.constBegin();
- QSet<TileSpec>::const_iterator addEnd = nowVisible.constEnd();
-
- while (c != addEnd) {
- TileSpec spec = *c;
- addSpec(spec);
- ++c;
- }
-}
-
-void MapSphere::removeSpec(const TileSpec &spec)
-{
- ItemTileCacheEntry *entry = itemTileCache_.object(spec);
-
- if (!entry) {
- return;
- }
-
- // update reverse map
- QList<MapItem*>::const_iterator i = entry->items.constBegin();
- QList<MapItem*>::const_iterator end = entry->items.constEnd();
- while (i != end) {
- MapItem *item = *i;
- QSet<TileSpec> v = itemTileReverseMap_.value(item, QSet<TileSpec>());
- v.remove(spec);
- itemTileReverseMap_.insert(item, v);
- ++i;
- }
-
- // update scene node
- QGLSceneNode *node = entry->resources.node;
- if (node && itemNode_->children().contains(node))
- itemNode_->removeNode(node);
-
- // update cache
- itemTileCache_.remove(spec);
-}
-
-void MapSphere::addSpec(const TileSpec &spec)
-{
- QList<MapItem*> items = itemTree_.itemsWithin(mapPrivate_->specToRect(spec));
-
- if (items.isEmpty())
- return;
-
- // update reverse map
- QList<MapItem*>::const_iterator i = items.constBegin();
- QList<MapItem*>::const_iterator end = items.constEnd();
- while (i != end) {
- MapItem *item = *i;
- QSet<TileSpec> v = itemTileReverseMap_.value(item, QSet<TileSpec>());
- v.insert(spec);
- itemTileReverseMap_.insert(item, v);
- ++i;
- }
-
- bool created = false;
- ItemTileCacheEntry *entry = itemTileCache_.object(spec);
-
- if (entry == 0) {
- entry = new ItemTileCacheEntry(this);
- entry->viewport = mapPrivate_->specToRect(spec);
- created = true;
- }
-
- if (entry->items.toSet() != items.toSet()) {
- entry->items = items;
- itemTileUpdates_.insert(spec);
- }
-
- if (created)
- itemTileCache_.insert(spec, entry);
}
void MapSphere::prefetchingFinished()
@@ -338,12 +202,6 @@ void MapSphere::tileFetched(const TileSpec &spec)
if (!requested_.contains(spec))
return;
- if (itemTileCache_.contains(spec)) {
- ItemTileCacheEntry *entry = itemTileCache_.object(spec);
- if (entry && !entry->items.isEmpty())
- itemTileUpdates_.insert(spec);
- }
-
displayTile(spec);
requested_.remove(spec);
@@ -372,147 +230,6 @@ void MapSphere::displayTile(const TileSpec &spec)
updateMutex.unlock();
}
-
-// depth test should be disabled before this is called
-void MapSphere::updateItems(QGLPainter *painter)
-{
- // clear the eviction list
- QList<ItemTileResources>::iterator j = itemTileEvictions_.begin();
- QList<ItemTileResources>::iterator evictEnd = itemTileEvictions_.end();
-
- while (j != evictEnd) {
- ItemTileResources itr = *j;
-
- if (itr.node)
- delete itr.node;
- if (itr.fbo)
- delete itr.fbo;
- itr.node = 0;
- itr.fbo = 0;
- *j = itr;
- ++j;
- }
-
- itemTileEvictions_.clear();
-
- QGLCamera *camera = new QGLCamera(this);
-
- // loop through visible tiles
- // grab all the items within those tiles
- // if any are marked as needs update, add the spec to the update list
-
- for (int i = 0; i < visibleTiles_.size(); ++i) {
- ItemTileCacheEntry *entry = itemTileCache_.object(visibleTiles_.at(i));
- bool needsUpdate = false;
- if (entry) {
- for (int j = 0; j < entry->items.size(); ++j) {
- if (entry->items.at(j)->needsUpdate()) {
- entry->items[j]->update();
- needsUpdate = true;
- }
- }
- }
- if (needsUpdate) {
- itemTileUpdates_.insert(visibleTiles_.at(i));
- }
- }
-
- for (int i = 0; i < visibleTiles_.size(); ++i) {
- ItemTileCacheEntry *entry = itemTileCache_.object(visibleTiles_.at(i));
- if (entry) {
- for (int j = 0; j < entry->items.size(); ++j) {
- if (entry->items.at(j)->needsUpdate()) {
- entry->items[j]->setNeedsUpdate(false);
- }
- }
- }
- }
-
- QSet<TileSpec>::const_iterator i = itemTileUpdates_.constBegin();
- QSet<TileSpec>::const_iterator updateEnd = itemTileUpdates_.constEnd();
-
- QSet<TileSpec> nextUpdates;
-
- // loop through updated entries
- while (i != updateEnd) {
- TileSpec spec = *i;
- ItemTileCacheEntry *entry = itemTileCache_.object(spec);
-
- if (!entry || entry->items.isEmpty()) {
- ++i;
- continue;
- }
-
- QOpenGLFramebufferObject *fbo = entry->resources.fbo;
-
- if (!fbo) {
- fbo = new QOpenGLFramebufferObject(512, 512);
- entry->resources.fbo = fbo;
- }
-
- QGLFramebufferObjectSurface *fboSurface = new QGLFramebufferObjectSurface(fbo, painter->context());
-
- double x = entry->viewport.x() + entry->viewport.width() / 2.0;
- double y = entry->viewport.y() + entry->viewport.height() / 2.0;
-
- camera->setCenter(QVector3D(x, y, 100));
- camera->setEye(QVector3D(x, y, 512));
- camera->setProjectionType(QGLCamera::Orthographic);
- camera->setViewSize(entry->viewport.size());
-
- painter->pushSurface(fboSurface);
-
- painter->setCamera(camera);
-
- if (built_.contains(spec))
- built_[spec]->draw(painter);
-
- for (int j = 0; j < entry->items.size(); ++j) {
- MapItem *item = entry->items.at(j);
- if (item->glResources() == 0)
- continue;
-
- if (item->textureId() == 0) {
- nextUpdates.insert(spec);
- } else if (item->sceneNode()) {
- item->sceneNode()->draw(painter);
- }
- }
-
- painter->popSurface();
-
- delete fboSurface;
-
- QGLSceneNode *node = entry->resources.node;
-
- bool hasNode = (node != 0);
-
- if (!hasNode) {
- node = mapPrivate_->createTileSpecNode(spec);
- node->setEffect(QGL::LitDecalTexture2D);
- QGLMaterial *mat = new QGLMaterial(node);
- node->setMaterial(mat);
- entry->resources.node = node;
- }
-
- QGLTexture2D *tex = QGLTexture2D::fromTextureId(fbo->texture(), fbo->size());
- // null check? free old texture?
- QGLMaterial *m = node->material();
- m->setTexture(tex);
- node->setMaterial(m);
-
- if (!hasNode)
- itemNode_->addNode(node);
-
- ++i;
- }
-
- delete camera;
-
- itemTileUpdates_.clear();
- itemTileUpdates_ = nextUpdates;
-}
-
void MapSphere::paintGL(QGLPainter *painter)
{
if (!updateMutex.tryLock()) {
@@ -524,152 +241,5 @@ void MapSphere::paintGL(QGLPainter *painter)
sphereNode_->draw(painter);
- glDisable(GL_DEPTH_TEST);
- itemNode_->draw(painter);
- updateItems(painter);
- glEnable(GL_DEPTH_TEST);
-
updateMutex.unlock();
}
-
-int MapSphere::numMapItems() const
-{
- return itemTree_.size();
-}
-
-QList<MapItem*> MapSphere::mapItems() const
-{
- return itemTree_.items();
-}
-
-QList<MapItem*> MapSphere::mapItemsAt(const QPoint &point) const
-{
- return itemTree_.itemsAt(point);
-}
-
-QList<MapItem*> MapSphere::mapItemsWithin(const QRect &rect) const
-{
- return itemTree_.itemsWithin(rect);
-}
-
-void MapSphere::addMapItem(MapItem *item)
-{
- // TODO bit hard block - on declarative side the coordinate may well be invalid time to time
- if (!item->coordinate().isValid())
- return;
-
- updateMutex.lock();
- if (!item->glResources())
- item->setGLResources(new MapItemGLResources);
- mapPrivate_->updateMapItemSceneNode(item);
- item->update();
-
- itemTree_.insert(item);
-
- QList<TileSpec>::const_iterator i = visibleTiles_.constBegin();
- QList<TileSpec>::const_iterator end = visibleTiles_.constEnd();
-
- QSet<TileSpec> specs = itemTileReverseMap_.value(item, QSet<TileSpec>());
-
- while (i != end) {
- TileSpec spec = *i;
-
- bool created = false;
- ItemTileCacheEntry *entry = itemTileCache_.object(spec);
- if (entry == 0) {
- entry = new ItemTileCacheEntry(this);
- entry->viewport = mapPrivate_->specToRect(spec);
- created = true;
- }
-
- if (itemTree_.itemsWithin(entry->viewport).contains(item)) {
-
- if (!entry->items.contains(item)) {
- entry->items.append(item);
- itemTileUpdates_.insert(spec);
- }
-
- specs.insert(spec);
- if (created)
- itemTileCache_.insert(spec, entry);
- }
-
- ++i;
- }
-
- itemTileReverseMap_.insert(item, specs);
-
- updateMutex.unlock();
-}
-
-// Must not be called from rendering thread
-void MapSphere::removeMapItem(MapItem *item)
-{
- if (!item)
- return;
- updateMutex.lock();
- // nodes need to be removed from the scene node tree in GUI thread
- // because the tree has been created in it,
- // but the actual scene node deletion needs to occur in rendering thread
- // because it has the gl context
- if (item->glResources() && !obsoleteGLResources_.contains(item->glResources())) {
- obsoleteGLResources_.insert(item->glResources());
- }
- item->setGLResources(0);
- itemTree_.remove(item);
-
- QSet<TileSpec> tiles = itemTileReverseMap_.value(item);
- itemTileReverseMap_.remove(item);
-
- QSet<TileSpec>::const_iterator i = tiles.constBegin();
- QSet<TileSpec>::const_iterator end = tiles.constEnd();
-
- while (i != end) {
- TileSpec spec = *i;
- if (itemTileCache_.contains(spec)) {
- ItemTileCacheEntry *entry = itemTileCache_.object(spec);
- entry->items.removeAll(item);
- if (entry->items.isEmpty()) {
- QGLSceneNode *node = entry->resources.node;
- if (node && itemNode_->children().contains(node))
- itemNode_->removeNode(node);
- itemTileCache_.remove(spec);
- } else {
- itemTileUpdates_.insert(spec);
- }
- }
-
- ++i;
- }
-
- updateMutex.unlock();
-}
-
-void MapSphere::clearMapItems()
-{
- updateMutex.lock();
- QList<MapItem*> items = itemTree_.items();
- for (int i = 0; i < items.size(); ++i) {
- MapItem *item = items.at(i);
- if (item->glResources() && !obsoleteGLResources_.contains(item->glResources())) {
- obsoleteGLResources_.insert(item->glResources());
- }
- itemTree_.remove(item);
- }
-
- itemTileReverseMap_.clear();
-
- QList<TileSpec> keys = itemTileCache_.keys();
- QList<TileSpec>::const_iterator i = keys.constBegin();
- QList<TileSpec>::const_iterator end = keys.constEnd();
-
- itemNode_->removeNodes(itemNode_->children());
-
- while (i != end) {
- itemTileCache_.remove(*i);
- ++i;
- }
-
- updateMutex.unlock();
-}
-
diff --git a/src/location/mapsgl/mapsphere_p.h b/src/location/mapsgl/mapsphere_p.h
index 0d5d7820..d98e03ce 100644
--- a/src/location/mapsgl/mapsphere_p.h
+++ b/src/location/mapsgl/mapsphere_p.h
@@ -53,8 +53,6 @@
//
#include <QtLocation/qlocationglobal.h>
-#include "mapitem.h"
-#include "mapitemtree_p.h"
#include "tilespec.h"
#include <QObject>
@@ -81,11 +79,6 @@ class MapPrivate;
class QGeoMappingManager;
-struct MapItemGLResources;
-
-struct ItemTileResources;
-struct ItemTileCacheEntry;
-
class Q_LOCATION_EXPORT MapSphere : public QObject
{
Q_OBJECT
@@ -104,14 +97,6 @@ public:
void paintGL(QGLPainter *painter);
- int numMapItems() const;
- QList<MapItem*> mapItems() const;
- QList<MapItem*> mapItemsAt(const QPoint &point) const;
- QList<MapItem*> mapItemsWithin(const QRect &rect) const;
- void addMapItem(MapItem *item);
- void removeMapItem(MapItem *item);
- void clearMapItems();
-
public slots:
void clearCache();
void update(const QList<TileSpec> &tiles);
@@ -127,24 +112,8 @@ signals:
private:
void displayTile(const TileSpec &spec);
- //void updateItemTiles();
- //void renderItemTiles(QGLPainter *painter);
-
QList<TileSpec> visibleTiles_;
- void updateItems(QGLPainter *painter);
-
- void addSpec(const TileSpec &spec);
- void removeSpec(const TileSpec &spec);
-
- QCache<TileSpec, ItemTileCacheEntry> itemTileCache_;
- QList<ItemTileResources> itemTileEvictions_;
- QHash<MapItem*, QSet<TileSpec> > itemTileReverseMap_;
- QSet<TileSpec> itemTileUpdates_;
-
- QGLSceneNode *itemNode_;
- QList<QOpenGLFramebufferObject*> fboList_;
-
TileCache *tileCache_;
int minZoom_;
@@ -155,12 +124,6 @@ private:
Map *map_;
MapPrivate* mapPrivate_;
- QList<QGLSceneNode*> obsoleteNodes_;
-
- MapItemTree itemTree_;
- QSet<MapItemGLResources*> obsoleteGLResources_;
-
- friend struct ItemTileCacheEntry;
};
QT_END_NAMESPACE
diff --git a/tests/applications/declarative_map/map3d.qml b/tests/applications/declarative_map/map3d.qml
index 9a01de55..b43ab06a 100644
--- a/tests/applications/declarative_map/map3d.qml
+++ b/tests/applications/declarative_map/map3d.qml
@@ -71,7 +71,7 @@ Item {
Text {text: "Crazy mode:\n" + testModel.crazyMode + "\nclick to\ntoggle."}
MouseArea{ anchors.fill: parent;
onClicked: testModel.crazyMode = !testModel.crazyMode
- onDoubleClicked: map.removeMapItem(mapItem1)
+ onDoubleClicked: map.removeMapScreenItem(mapItem1)
}
}
AnimatedImage {
@@ -84,14 +84,14 @@ Item {
Rectangle {color: "lightblue"; width: 80; height: 80;
Text {text: "Click:\nadd item1\nDouble-click:\nrm item1"}
MouseArea{ anchors.fill: parent;
- onClicked: {console.log('----------------adding item 1'); map.addMapItem(externalStaticMapItem1);}
- onDoubleClicked: {console.log('+++++++++++++++ removing item 1'); map.removeMapItem(externalStaticMapItem1);}
+ onClicked: {console.log('----------------adding item 1'); map.addMapScreenItem(externalStaticMapItem1);}
+ onDoubleClicked: {console.log('+++++++++++++++ removing item 1'); map.removeMapScreenItem(externalStaticMapItem1);}
}
}
Rectangle {color: "lightblue"; width: 80; height: 80;
Text {text: "Click:\nadd item2\nDouble-click:\nrm item2"}
MouseArea{ anchors.fill: parent;
- onClicked: {console.log('adding item 2'); map.addMapItem(externalStaticMapItem2);}
+ onClicked: {console.log('adding item 2'); map.addMapScreenItem(externalStaticMapItem2);}
onDoubleClicked: {console.log('removing item 2'); map.removeMapItem(externalStaticMapItem2);}
}
}
@@ -199,50 +199,6 @@ Item {
altitude: 0
}
- /*
- MapItem {
- id: externalStaticMapItem1
- objectName: "externalStaticMapItem1"
- coordinate: brisbaneCoordinate
- zoomLevel: 5.0
- source: Rectangle {
- color: "gray"
- width: 140
- height: 20
- Text {font.pixelSize: 15;text: "ext map item 1"; font.bold: true; color: 'red'}
- }
- }
-
- MapItem {
- id: externalStaticMapItem2
- objectName: "externalStaticMapItem2"
- coordinate: brisbaneCoordinate2
- zoomLevel: 5.0
- source: Rectangle {
- color: "gray"
- width: 140
- height: 20
- Text {font.pixelSize: 15;text: "ext map item 2"; font.bold: true; color: 'red'}
- }
- }
- */
-
- /*
- MapItem {
- id: mapItem1
- source: AnimatedImage {width: 80; height: 80; playing: true; source: "walk.gif"}
- }
- */
-
- //AnimatedImage {width: 80; height: 80; playing: true; source: "walk.gif"}
- //MapItem {id: mapItem2 }
- //MapItem {id: mapItem3 }
- //MapItem {id: mapItem4 }
- //MapItem {id: mapItem5 }
- //MapItem {id: mapItem6 }
- //MapItem {id: mapItem7 }
- //MapItem {id: mapItem8 }
-
Coordinate {
id: brisbaneCoordinate
latitude: -27.5
@@ -264,6 +220,7 @@ Item {
anchors.fill: parent
onClicked: console.log('coordinate: ' + mouse.coordinate.latitude + ' to screen pos: ' + map.toScreenPosition(mouse.coordinate).x + ' ' + map.toScreenPosition(mouse.coordinate).y)
}
+/*
MapItem {
id: externalStaticMapItem1
visible: true
@@ -281,6 +238,7 @@ Item {
}
}
}
+*/
MapScreenItem {
objectName: "blinky screen item 1"
@@ -293,7 +251,6 @@ Item {
}
}
-
MapScreenItem {
objectName: "blinky screen item 2"
coordinate: brisbaneCoordinate
@@ -313,25 +270,14 @@ Item {
}
}
- MapItem {
- objectName: 'blinky static item'
- zoomLevel: 7 // at which map's zoom level the width and height are '1-to-1'
- coordinate: brisbaneCoordinate
- sourceItem: AnimatedImage {
- width: 80
- height: 80
- playing: true
- source: "blinky.gif"
- }
- }
-
MapItemView {
id: theObjectView
model: testModel
delegate: Component {
- MapItem {
- objectName: 'one of many items from model'
- visible: true
+ MapScreenItem {
+// objectName: 'one of many items from model'
+// visible: true
+ zoomLevel: 7
sourceItem: Rectangle {
width: 300; height: 300; color: 'green'
Component.onCompleted: {
diff --git a/tests/applications/map3d/camerawidget.cpp b/tests/applications/map3d/camerawidget.cpp
deleted file mode 100644
index 79b86647..00000000
--- a/tests/applications/map3d/camerawidget.cpp
+++ /dev/null
@@ -1,155 +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 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
deleted file mode 100644
index a2120089..00000000
--- a/tests/applications/map3d/camerawidget.h
+++ /dev/null
@@ -1,87 +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 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
deleted file mode 100644
index 89d8dcc7..00000000
--- a/tests/applications/map3d/main.cpp
+++ /dev/null
@@ -1,86 +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 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
deleted file mode 100644
index a43f10c7..00000000
--- a/tests/applications/map3d/mainwidget.cpp
+++ /dev/null
@@ -1,341 +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 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
deleted file mode 100644
index f0cd1955..00000000
--- a/tests/applications/map3d/mainwidget.h
+++ /dev/null
@@ -1,89 +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 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
deleted file mode 100644
index 0c69e5bc..00000000
--- a/tests/applications/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/tests/applications/map3d/tileview.cpp b/tests/applications/map3d/tileview.cpp
deleted file mode 100644
index f3b92b3b..00000000
--- a/tests/applications/map3d/tileview.cpp
+++ /dev/null
@@ -1,293 +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 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
deleted file mode 100644
index 562214b7..00000000
--- a/tests/applications/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 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
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro
index 6f1a9190..6f265098 100644
--- a/tests/auto/auto.pro
+++ b/tests/auto/auto.pro
@@ -31,8 +31,6 @@ SUBDIRS += geotestplugin \
qplacesupplier \
qplacesearchresult \
declarative \
- intervaltree \
- mapitemtree \
sphere \
qmlinterface \
maptype
diff --git a/tests/auto/intervaltree/intervaltree.pro b/tests/auto/intervaltree/intervaltree.pro
deleted file mode 100644
index 6b919c5f..00000000
--- a/tests/auto/intervaltree/intervaltree.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-TEMPLATE = app
-CONFIG += testcase
-TARGET = tst_intervaltree
-
-INCLUDEPATH = ../../../src/location/mapsgl
-SOURCES += tst_intervaltree.cpp
-
-QT += location testlib
diff --git a/tests/auto/intervaltree/tst_intervaltree.cpp b/tests/auto/intervaltree/tst_intervaltree.cpp
deleted file mode 100644
index 9c28e427..00000000
--- a/tests/auto/intervaltree/tst_intervaltree.cpp
+++ /dev/null
@@ -1,772 +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 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 <QObject>
-#include <QtTest/QtTest>
-
-#include "intervaltree_p.h"
-
-#include <QHash>
-
-QT_USE_NAMESPACE
-
-uint qHash(const QRect &rect)
-{
- uint result = qHash(rect.x());
- result = 17 * result + qHash(rect.y());
- result = 17 * result + qHash(rect.width());
- result = 17 * result + qHash(rect.height());
- return result;
-}
-
-class tst_IntervalTree : public QObject
-{
- Q_OBJECT
-
-public:
- tst_IntervalTree() {
-
- }
-
-private slots:
- void insert_min();
- void remove_min();
-
- void insert_max();
- void remove_max();
-
- void insert_minmax();
- void remove_minmax();
-
- void itemsAt();
- void itemsWithin();
-
- void insert2D();
- void insert2D_sameRect_sameData();
- void insert2D_sameRect_uniqueData();
-
- void remove2D();
- void remove2D_duplicates();
-
- void itemsAt2D();
- void itemsWithin2D();
-};
-
-void tst_IntervalTree::insert_min()
-{
- // effectively tests all the sizes lower than this as it goes
- int size = 8;
-
- // tree contains [1..size], inserted in order
- AAIntervalTree<int> tree;
- QList<int> data;
- int limit = 1;
-
- for (int j = 1; j <= size; ++j) {
- tree.insert(j, 0, j);
- data.append(j);
- limit *= j;
- }
-
- QCOMPARE(tree.items(), data);
-
- // we insert [1..size] into testTree in every possible order
- // and compare the inorder traversal
- for (int i = 0; i < limit; ++i) {
- QList<int> tmp = data;
- QList<int> input;
- int div = 1;
- for (int j = size; j > 0; --j) {
- input.append(tmp.takeAt((i / div) % j));
- div *= j;
- }
-
- AAIntervalTree<int> testTree;
- for (int j = 0; j < input.size(); ++j) {
- int k = input.at(j);
- testTree.insert(k, 0, k);
- }
-
- QCOMPARE(testTree.items(), data);
- }
-}
-
-void tst_IntervalTree::remove_min()
-{
- // effectively tests all the sizes lower than this as it goes
- int size = 8;
-
- QList<int> data;
- int limit = 1;
-
- for (int j = 1; j <= size; ++j) {
- data.append(j);
- limit *= j;
- }
-
- for (int i = 0; i < limit; ++i) {
- QList<int> tmp = data;
- QList<int> input;
- int div = 1;
- for (int j = size; j > 0; --j) {
- input.append(tmp.takeAt((i / div) % j));
- div *= j;
- }
-
- // tree contains [1..size], inserted in order
- AAIntervalTree<int> tree;
- for (int j = 1; j <= size; ++j) {
- tree.insert(j, 0, j);
- }
-
- // we remove [1..size] into tree in every possible order
- // and compare the inorder traversal to a sorted list from
- // which we remove the same values
- QList<int> tmp2 = data;
- for (int j = 0; j < input.size(); ++j) {
- int k = input.at(j);
- tmp2.removeAll(k);
- tree.remove(k, 0, k);
-
- QCOMPARE(tree.items(), tmp2);
- }
- }
-}
-
-void tst_IntervalTree::insert_max()
-{
- // effectively tests all the sizes lower than this as it goes
- int size = 8;
-
- // tree contains [1..size], inserted in order
- AAIntervalTree<int> tree;
- QList<int> data;
- int limit = 1;
-
- for (int j = 1; j <= size; ++j) {
- tree.insert(0, j, j);
- data.append(j);
- limit *= j;
- }
-
- QCOMPARE(tree.items(), data);
-
- // we insert [1..size] into testTree in every possible order
- // and compare the inorder traversal
- for (int i = 0; i < limit; ++i) {
- QList<int> tmp = data;
- QList<int> input;
- int div = 1;
- for (int j = size; j > 0; --j) {
- input.append(tmp.takeAt((i / div) % j));
- div *= j;
- }
-
- AAIntervalTree<int> testTree;
- for (int j = 0; j < input.size(); ++j) {
- int k = input.at(j);
- testTree.insert(0, k, k);
- }
-
- QCOMPARE(testTree.items(), data);
- }
-}
-
-void tst_IntervalTree::remove_max()
-{
- // effectively tests all the sizes lower than this as it goes
- int size = 8;
-
- QList<int> data;
- int limit = 1;
-
- for (int j = 1; j <= size; ++j) {
- data.append(j);
- limit *= j;
- }
-
- for (int i = 0; i < limit; ++i) {
- QList<int> tmp = data;
- QList<int> input;
- int div = 1;
- for (int j = size; j > 0; --j) {
- input.append(tmp.takeAt((i / div) % j));
- div *= j;
- }
-
- // tree contains [1..size], inserted in order
- AAIntervalTree<int> tree;
- for (int j = 1; j <= size; ++j) {
- tree.insert(0, j, j);
- }
-
- // we remove [1..size] into tree in every possible order
- // and compare the inorder traversal to a sorted list from
- // which we remove the same values
- QList<int> tmp2 = data;
- for (int j = 0; j < input.size(); ++j) {
- int k = input.at(j);
- tmp2.removeAll(k);
- tree.remove(0, k, k);
-
- QCOMPARE(tree.items(), tmp2);
- }
- }
-}
-
-
-void tst_IntervalTree::insert_minmax()
-{
- // effectively tests all the sizes lower than this as it goes
- int size = 6;
-
- // tree contains [(1,1),(1,2)..(size, size+1),(size,size+2)], inserted in order
- AAIntervalTree<int> tree;
- QList<int> data;
- int limit = 1;
-
- for (int j = 1; j <= size; ++j) {
- tree.insert(j, j + 1, j * 2);
- data.append(j * 2);
- tree.insert(j, j + 2, j * 2 + 1);
- data.append(j * 2 + 1);
- limit *= 2 * j;
- }
-
- QCOMPARE(tree.items(), data);
-
- // we insert the same data into testTree in every possible order
- // and compare the inorder traversal
- for (int i = 0; i < limit; ++i) {
- QList<int> tmp = data;
- QList<int> input;
- int div = 1;
- for (int j = size * 2; j > 0; --j) {
- input.append(tmp.takeAt((i / div) % j));
- div *= j;
- }
-
- AAIntervalTree<int> testTree;
- for (int j = 0; j < input.size(); ++j) {
- int k = input.at(j);
- testTree.insert(k / 2, k / 2 + 1 + k % 2, k);
- }
-
- QCOMPARE(testTree.items(), data);
- }
-}
-
-void tst_IntervalTree::remove_minmax()
-{
- // effectively tests all the sizes lower than this as it goes
- int size = 6;
-
- QList<int> data;
- int limit = 1;
-
- for (int j = 1; j <= size; ++j) {
- data.append(j * 2);
- data.append(j * 2 + 1);
- limit *= 2 * j;
- }
-
- for (int i = 0; i < limit; ++i) {
- QList<int> tmp = data;
- QList<int> input;
- int div = 1;
- for (int j = 2 * size; j > 0; --j) {
- input.append(tmp.takeAt((i / div) % j));
- div *= j;
- }
-
- // tree contains [1..size], inserted in order
- AAIntervalTree<int> tree;
- for (int j = 1; j <= size; ++j) {
- tree.insert(j, j + 1, 2 * j);
- tree.insert(j, j + 2, 2 * j + 1);
- }
-
- // we remove [1..size] into tree in every possible order
- // and compare the inorder traversal to a sorted list from
- // which we remove the same values
- QList<int> tmp2 = data;
- for (int j = 0; j < input.size(); ++j) {
- int k = input.at(j);
- tmp2.removeAll(k);
- tree.remove(k / 2, k / 2 + 1 + k % 2, k);
-
- QCOMPARE(tree.items(), tmp2);
- }
- }
-}
-
-struct ItemTriple {
- ItemTriple(int min, int max, int value)
- : min(min),
- max(max),
- value(value) {}
-
- int min;
- int max;
- int value;
-};
-
-void tst_IntervalTree::itemsAt()
-{
- QList<ItemTriple> triples;
-
- triples << ItemTriple(1, 4, 1);
- triples << ItemTriple(6, 9, 2);
- triples << ItemTriple(7, 11, 3);
- triples << ItemTriple(9, 10, 4);
- triples << ItemTriple(16, 24, 5);
- triples << ItemTriple(17, 22, 6);
- triples << ItemTriple(18, 20, 7);
- triples << ItemTriple(20, 21, 8);
- triples << ItemTriple(26, 31, 9);
- triples << ItemTriple(27, 27, 10);
-
- QHash<int, QSet<int> > data;
-
- AAIntervalTree<int> tree;
-
- for (int i = 0; i < triples.size(); ++i) {
- ItemTriple t1 = triples.at(i);
- tree.insert(t1.min, t1.max, t1.value);
- for (int j = t1.min; j <= t1.max; ++j) {
- data[j].insert(t1.value);
- }
- }
-
- for (int i = 1; i <= 31; ++i) {
- QCOMPARE(tree.itemsAt(i).toSet(), data.value(i));
- }
-}
-
-void tst_IntervalTree::itemsWithin()
-{
- QList<ItemTriple> triples;
-
- triples << ItemTriple(1, 4, 1);
- triples << ItemTriple(6, 9, 2);
- triples << ItemTriple(7, 11, 3);
- triples << ItemTriple(9, 10, 4);
- triples << ItemTriple(16, 24, 5);
- triples << ItemTriple(17, 22, 6);
- triples << ItemTriple(18, 20, 7);
- triples << ItemTriple(20, 21, 8);
- triples << ItemTriple(26, 31, 9);
- triples << ItemTriple(27, 27, 10);
-
- QHash<int, QSet<int> > data;
-
- AAIntervalTree<int> tree;
-
- for (int i = 0; i < triples.size(); ++i) {
- ItemTriple t1 = triples.at(i);
- tree.insert(t1.min, t1.max, t1.value);
- for (int j = t1.min; j <= t1.max; ++j) {
- data[j].insert(t1.value);
- }
- }
-
- for (int i = 1; i <= 31; ++i) {
- for (int j = i; j <= 31; ++j) {
- QSet<int> d;
- for (int k = i; k <= j; ++k)
- d += data.value(k);
- QCOMPARE(tree.itemsWithin(i, j).toSet(), d);
- }
- }
-}
-
-void tst_IntervalTree::insert2D()
-{
- AAInterval2DTree<int> *tree = new AAInterval2DTree<int>();
-
- int size = 6;
- int index = 0;
-
- QList<int> data;
-
- for (int x1 = 0; x1 < size; ++x1) {
- for (int x2 = x1; x2 < size; ++x2) {
- for (int y1 = 0; y1 < size; ++y1) {
- for (int y2 = y1; y2 < size; ++y2) {
- tree->insert(QRect(x1, y1, x2 - x1, y2 - y1), index);
- data.append(index);
- ++index;
- }
- }
- }
- }
-
- QCOMPARE(tree->items(), data);
-
- delete tree;
-}
-
-void tst_IntervalTree::insert2D_sameRect_sameData()
-{
- AAInterval2DTree<int> *tree = new AAInterval2DTree<int>();
-
- int size = 6;
- int index = 0;
-
- QList<int> data;
-
- for (int x1 = 0; x1 < size; ++x1) {
- for (int x2 = x1; x2 < size; ++x2) {
- for (int y1 = 0; y1 < size; ++y1) {
- for (int y2 = y1; y2 < size; ++y2) {
- tree->insert(QRect(x1, y1, x2 - x1, y2 - y1), index);
- tree->insert(QRect(x1, y1, x2 - x1, y2 - y1), index);
- data.append(index);
- ++index;
- }
- }
- }
- }
-
- QCOMPARE(tree->items(), data);
-
- delete tree;
-}
-
-
-void tst_IntervalTree::insert2D_sameRect_uniqueData()
-{
- AAInterval2DTree<int> *tree = new AAInterval2DTree<int>();
-
- int size = 6;
- int index = 0;
-
- QList<int> data;
-
- for (int x1 = 0; x1 < size; ++x1) {
- for (int x2 = x1; x2 < size; ++x2) {
- for (int y1 = 0; y1 < size; ++y1) {
- for (int y2 = y1; y2 < size; ++y2) {
- tree->insert(QRect(x1, y1, x2 - x1, y2 - y1), index);
- data.append(index);
- ++index;
- tree->insert(QRect(x1, y1, x2 - x1, y2 - y1), index);
- data.append(index);
- ++index;
- }
- }
- }
- }
-
- QCOMPARE(tree->items(), data);
-
- delete tree;
-}
-
-void tst_IntervalTree::remove2D()
-{
- int size = 6;
- int index = 0;
-
- QHash<QRect, int> indexHash;
-
- QList<QList<QPair<QRect, int> > > removals;
-
- QList<QPair<QRect, int> > removal1;
-
- for (int x1 = 0; x1 < size; ++x1) {
- for (int x2 = x1; x2 < size; ++x2) {
- for (int y1 = 0; y1 < size; ++y1) {
- for (int y2 = y1; y2 < size; ++y2) {
- QRect r = QRect(x1, y1, x2 - x1, y2 - y1);
- indexHash[r] = index;
- removal1 << QPair<QRect, int>(QRect(x1, y1, x2 - x1, y2 - y1), index);
- ++index;
- }
- }
- }
- }
-
- removals << removal1;
-
- QList<QPair<QRect, int> > removal2;
-
- for (int x1 = 0; x1 < size; ++x1) {
- for (int y1 = 0; y1 < size; ++y1) {
- for (int x2 = x1; x2 < size; ++x2) {
- for (int y2 = y1; y2 < size; ++y2) {
- QRect r = QRect(x1, y1, x2 - x1, y2 - y1);
- removal2 << QPair<QRect, int>(r, indexHash.value(r, -1));
- }
- }
- }
- }
-
- removals << removal2;
-
- QList<QPair<QRect, int> > removal3;
-
- for (int x1 = 0; x1 < size; ++x1) {
- for (int y1 = 0; y1 < size; ++y1) {
- for (int y2 = y1; y2 < size; ++y2) {
- for (int x2 = x1; x2 < size; ++x2) {
- QRect r = QRect(x1, y1, x2 - x1, y2 - y1);
- removal3 << QPair<QRect, int>(r, indexHash.value(r, -1));
- }
- }
- }
- }
-
- removals << removal3;
-
- QList<QPair<QRect, int> > removal4;
-
- for (int y1 = 0; y1 < size; ++y1) {
- for (int x1 = 0; x1 < size; ++x1) {
- for (int x2 = x1; x2 < size; ++x2) {
- for (int y2 = y1; y2 < size; ++y2) {
- QRect r = QRect(x1, y1, x2 - x1, y2 - y1);
- removal4 << QPair<QRect, int>(r, indexHash.value(r, -1));
- }
- }
- }
- }
-
- removals << removal4;
-
- QList<QPair<QRect, int> > removal5;
-
- for (int y1 = 0; y1 < size; ++y1) {
- for (int x1 = 0; x1 < size; ++x1) {
- for (int y2 = y1; y2 < size; ++y2) {
- for (int x2 = x1; x2 < size; ++x2) {
- QRect r = QRect(x1, y1, x2 - x1, y2 - y1);
- removal5 << QPair<QRect, int>(r, indexHash.value(r, -1));
- }
- }
- }
- }
-
- removals << removal5;
-
- QList<QPair<QRect, int> > removal6;
-
- for (int y1 = 0; y1 < size; ++y1) {
- for (int y2 = y1; y2 < size; ++y2) {
- for (int x1 = 0; x1 < size; ++x1) {
- for (int x2 = x1; x2 < size; ++x2) {
- QRect r = QRect(x1, y1, x2 - x1, y2 - y1);
- removal6 << QPair<QRect, int>(r, indexHash.value(r, -1));
- }
- }
- }
- }
-
- removals << removal6;
-
- index = 0;
-
- for (int i = 0; i < removals.size(); ++i) {
- AAInterval2DTree<int> *tree = new AAInterval2DTree<int>();
-
- QList<int> data;
-
- for (int x1 = 0; x1 < size; ++x1) {
- for (int x2 = x1; x2 < size; ++x2) {
- for (int y1 = 0; y1 < size; ++y1) {
- for (int y2 = y1; y2 < size; ++y2) {
- tree->insert(QRect(x1, y1, x2 - x1, y2 - y1), index);
- data.append(index);
- ++index;
- }
- }
- }
- }
-
- QCOMPARE(tree->items(), data);
-
- QList<QPair<QRect, int> > removal = removals.at(i);
-
- for (int j = 0; j < removal.size(); ++j) {
- QPair<QRect, int> p = removal.at(j);
- tree->remove(p.first, p.second);
- data.removeAll(p.second);
-
- QCOMPARE(tree->items(), data);
- }
-
- delete tree;
- }
-}
-
-void tst_IntervalTree::remove2D_duplicates()
-{
- AAInterval2DTree<int> *tree = new AAInterval2DTree<int>();
-
- QList<int> data;
-
- QList<QPair<QRect, int> > items;
-
- int size = 6;
- int index = 0;
-
- for (int x1 = 0; x1 < size; ++x1) {
- for (int x2 = x1; x2 < size; ++x2) {
- for (int y1 = 0; y1 < size; ++y1) {
- for (int y2 = y1; y2 < size; ++y2) {
- QRect r = QRect(x1, y1, x2 - x1, y2 - y1);
- tree->insert(r, index);
- data.append(index);
- items << QPair<QRect, int>(r, index);
- ++index;
- tree->insert(r, index);
- data.append(index);
- items << QPair<QRect, int>(r, index);
- ++index;
- }
- }
- }
- }
-
- QCOMPARE(tree->items(), data);
-
- for (int i = 0; i < items.size(); ++i) {
- QPair<QRect, int> p = items.at(i);
- tree->remove(p.first, p.second);
- data.removeAll(p.second);
- QCOMPARE(tree->items(), data);
- }
-
- delete tree;
-}
-
-void tst_IntervalTree::itemsAt2D()
-{
- QList<ItemTriple> triples;
-
- triples << ItemTriple(1, 4, 1);
- triples << ItemTriple(6, 9, 2);
- triples << ItemTriple(7, 11, 3);
- triples << ItemTriple(9, 10, 4);
- triples << ItemTriple(16, 24, 5);
- triples << ItemTriple(17, 22, 6);
- triples << ItemTriple(18, 20, 7);
- triples << ItemTriple(20, 21, 8);
- triples << ItemTriple(26, 31, 9);
- triples << ItemTriple(27, 27, 10);
-
- QHash<int, QSet<int> > data;
-
- AAInterval2DTree<int> tree;
-
- for (int i = 0; i < triples.size(); ++i) {
- ItemTriple t1 = triples.at(i);
- for (int j = 0; j < triples.size(); ++j) {
- ItemTriple t2 = triples.at(i);
- tree.insert(QRect(t1.min, t2.min, t1.max - t1.min, t2.max - t2.min), t1.value * 32 + t2.value);
- for (int k = t1.min; k <= t1.max; ++k) {
- for (int l = t2.min; l <= t2.max; ++l) {
- data[k * 32 + l].insert(t1.value * 32 + t2.value);
- }
- }
- }
- }
-
- for (int i = 1; i <= 31; ++i) {
- for (int j = 1; j <= 31; ++j) {
- QCOMPARE(tree.itemsAt(QPoint(i, j)).toSet(), data.value(i * 32 + j));
- }
- }
-}
-
-void tst_IntervalTree::itemsWithin2D()
-{
- QList<ItemTriple> triples;
-
- triples << ItemTriple(1, 4, 1);
- triples << ItemTriple(6, 9, 2);
- triples << ItemTriple(7, 11, 3);
- triples << ItemTriple(9, 10, 4);
- triples << ItemTriple(16, 24, 5);
- triples << ItemTriple(17, 22, 6);
- triples << ItemTriple(18, 20, 7);
- triples << ItemTriple(20, 21, 8);
- triples << ItemTriple(26, 31, 9);
- triples << ItemTriple(27, 27, 10);
-
- QHash<int, QSet<int> > data;
-
- AAInterval2DTree<int> tree;
-
- for (int i = 0; i < triples.size(); ++i) {
- ItemTriple t1 = triples.at(i);
- for (int j = 0; j < triples.size(); ++j) {
- ItemTriple t2 = triples.at(i);
- tree.insert(QRect(t1.min, t2.min, t1.max - t1.min, t2.max - t2.min), t1.value * 32 + t2.value);
- for (int k = t1.min; k <= t1.max; ++k) {
- for (int l = t2.min; l <= t2.max; ++l) {
- data[k * 32 + l].insert(t1.value * 32 + t2.value);
- }
- }
- }
- }
-
- for (int i1 = 1; i1 <= 31; ++i1) {
- for (int i2 = i1; i2 <= 31; ++i2) {
- for (int j1 = 1; j1 <= 31; ++j1) {
- for (int j2 = j1; j2 <= 31; ++j2) {
- QSet<int> d;
- for (int x = i1; x <= i2; ++x) {
- for (int y = j1; y <= j2; ++y) {
- d += data.value(32 * x + y);
- }
- }
- QCOMPARE(tree.itemsWithin(QRect(i1, j1, i2 - i1, j2 - j1)).toSet(), d);
- }
- }
- }
- }
-}
-
-
-QTEST_APPLESS_MAIN(tst_IntervalTree)
-#include "tst_intervaltree.moc"
-
-
diff --git a/tests/auto/mapitemtree/mapitemtree.pro b/tests/auto/mapitemtree/mapitemtree.pro
deleted file mode 100644
index ca86f981..00000000
--- a/tests/auto/mapitemtree/mapitemtree.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-TEMPLATE = app
-CONFIG += testcase
-TARGET = tst_mapitemtree
-
-INCLUDEPATH = ../../../src/location/mapsgl
-SOURCES += tst_mapitemtree.cpp
-
-QT += location testlib
diff --git a/tests/auto/mapitemtree/tst_mapitemtree.cpp b/tests/auto/mapitemtree/tst_mapitemtree.cpp
deleted file mode 100644
index a0708d2f..00000000
--- a/tests/auto/mapitemtree/tst_mapitemtree.cpp
+++ /dev/null
@@ -1,629 +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 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 <QObject>
-#include <QtTest/QtTest>
-
-#include <mapitem.h>
-#include "mapitemtree_p.h"
-
-#include <QSet>
-#include <QHash>
-
-#include <QMetaType>
-
-#include <cmath>
-
-QT_USE_NAMESPACE
-
-uint qHash(const QRect &rect)
-{
- uint result = qHash(rect.x());
- result = 17 * result + qHash(rect.y());
- result = 17 * result + qHash(rect.width());
- result = 17 * result + qHash(rect.height());
- return result;
-}
-
-class tst_MapItemTree : public QObject
-{
- Q_OBJECT
-
-public:
- tst_MapItemTree() {
-
- }
-
-private slots:
- void insertRemove();
- void itemsAt_allQuads();
- void itemsAt_singleQuad();
- void itemsWithin_allQuads();
- void itemsWithin_singleQuad();
- void makeVisible();
-
-private:
- MapItemTree* setupTree();
- MapItem* dummyItemFromRect(const QRect &rect);
-};
-
-MapItem* tst_MapItemTree::dummyItemFromRect(const QRect &rect)
-{
- MapItem *item = new MapItem();
- item->setBounds(rect);
- return item;
-}
-
-void tst_MapItemTree::insertRemove()
-{
-// MapItemTree *root = new MapItemTree(QRect(0, 0, 512, 512));
- MapItemTree *root = new MapItemTree();
-
- MapItem* item1 = dummyItemFromRect(QRect(16, 16, 16, 16));
- MapItem* item2 = dummyItemFromRect(QRect(272, 16, 16, 16));
- MapItem* item3 = dummyItemFromRect(QRect(16, 272, 16, 16));
- MapItem* item4 = dummyItemFromRect(QRect(272, 272, 16, 16));
- MapItem* item5 = dummyItemFromRect(QRect(248, 248, 16, 16));
-
- MapItem* badItem1 = dummyItemFromRect(QRect(17, 17, 16, 16));
- MapItem* badItem2 = dummyItemFromRect(QRect(273, 17, 16, 16));
- MapItem* badItem3 = dummyItemFromRect(QRect(17, 273, 16, 16));
- MapItem* badItem4 = dummyItemFromRect(QRect(273, 273, 16, 16));
- MapItem* badItem5 = dummyItemFromRect(QRect(249, 249, 16, 16));
-
- QCOMPARE(root->isEmpty(), true);
- QCOMPARE(root->size(), 0);
- QCOMPARE(root->items().size(), 0);
-
- root->insert(item1);
-
- QCOMPARE(root->isEmpty(), false);
- QCOMPARE(root->size(), 1);
- QCOMPARE(root->items().size(), 1);
-
- root->insert(item2);
-
- QCOMPARE(root->isEmpty(), false);
- QCOMPARE(root->size(), 2);
- QCOMPARE(root->items().size(), 2);
-
- root->insert(item3);
-
- QCOMPARE(root->isEmpty(), false);
- QCOMPARE(root->size(), 3);
- QCOMPARE(root->items().size(), 3);
-
- root->insert(item4);
-
- QCOMPARE(root->isEmpty(), false);
- QCOMPARE(root->size(), 4);
- QCOMPARE(root->items().size(), 4);
-
- root->insert(item5);
-
- QCOMPARE(root->isEmpty(), false);
- QCOMPARE(root->size(), 5);
- QCOMPARE(root->items().size(), 5);
-
- root->remove(badItem1);
-
- QCOMPARE(root->isEmpty(), false);
- QCOMPARE(root->size(), 5);
- QCOMPARE(root->items().size(), 5);
-
- root->remove(badItem2);
-
- QCOMPARE(root->isEmpty(), false);
- QCOMPARE(root->size(), 5);
- QCOMPARE(root->items().size(), 5);
-
- root->remove(badItem3);
-
- QCOMPARE(root->isEmpty(), false);
- QCOMPARE(root->size(), 5);
- QCOMPARE(root->items().size(), 5);
-
- root->remove(badItem4);
-
- QCOMPARE(root->isEmpty(), false);
- QCOMPARE(root->size(), 5);
- QCOMPARE(root->items().size(), 5);
-
- root->remove(badItem5);
-
- QCOMPARE(root->isEmpty(), false);
- QCOMPARE(root->size(), 5);
- QCOMPARE(root->items().size(), 5);
-
- root->remove(item1);
-
- QCOMPARE(root->isEmpty(), false);
- QCOMPARE(root->size(), 4);
- QCOMPARE(root->items().size(), 4);
-
- root->remove(item2);
-
- QCOMPARE(root->isEmpty(), false);
- QCOMPARE(root->size(), 3);
- QCOMPARE(root->items().size(), 3);
-
- root->remove(item3);
-
- QCOMPARE(root->isEmpty(), false);
- QCOMPARE(root->size(), 2);
- QCOMPARE(root->items().size(), 2);
-
- root->remove(item4);
-
- QCOMPARE(root->isEmpty(), false);
- QCOMPARE(root->size(), 1);
- QCOMPARE(root->items().size(), 1);
-
- root->remove(item5);
-
- QCOMPARE(root->isEmpty(), true);
- QCOMPARE(root->size(), 0);
- QCOMPARE(root->items().size(), 0);
-
- root->remove(badItem1);
-
- QCOMPARE(root->isEmpty(), true);
- QCOMPARE(root->size(), 0);
- QCOMPARE(root->items().size(), 0);
-
- root->remove(badItem2);
-
- QCOMPARE(root->isEmpty(), true);
- QCOMPARE(root->size(), 0);
- QCOMPARE(root->items().size(), 0);
-
- root->remove(badItem3);
-
- QCOMPARE(root->isEmpty(), true);
- QCOMPARE(root->size(), 0);
- QCOMPARE(root->items().size(), 0);
-
- root->remove(badItem4);
-
- QCOMPARE(root->isEmpty(), true);
- QCOMPARE(root->size(), 0);
- QCOMPARE(root->items().size(), 0);
-
- root->remove(badItem5);
-
- QCOMPARE(root->isEmpty(), true);
- QCOMPARE(root->size(), 0);
- QCOMPARE(root->items().size(), 0);
-
- delete root;
-
- delete item1;
- delete item2;
- delete item3;
- delete item4;
- delete item5;
-
- delete badItem1;
- delete badItem2;
- delete badItem3;
- delete badItem4;
- delete badItem5;
-}
-
-void tst_MapItemTree::itemsAt_allQuads()
-{
- MapItemTree *tree = setupTree();
-
- QList<int> empty;
- empty.append(0);
- empty.append(2);
- empty.append(3);
- empty.append(5);
- empty.append(6);
- empty.append(9);
- empty.append(10);
- empty.append(12);
- empty.append(13);
- empty.append(15);
-
- QList<int> full;
- full.append(1);
- full.append(4);
- full.append(7);
- full.append(8);
- full.append(11);
- full.append(14);
-
- // Test mid points of the "cells"
-
- for (int x = 0; x < 16; ++x) {
- for (int i = 0; i < empty.size(); ++i) {
- int y = empty.at(i);
- QCOMPARE(tree->itemsAt(QPoint(x * 16 + 8, y * 16 + 8)).size(), 0);
- }
- }
-
- for (int i = 0; i < empty.size(); ++i) {
- int x = empty.at(i);
- for (int y = 0; y < 16; ++y) {
- QCOMPARE(tree->itemsAt(QPoint(x * 16 + 8, y * 16 + 8)).size(), 0);
- }
- }
-
- for (int i = 0; i < full.size(); ++i) {
- int x = full.at(i);
- for (int j = 0; j < full.size(); ++j) {
- int y = full.at(j);
- QList<MapItem*> items = tree->itemsAt(QPoint(x * 16 + 8, y * 16 + 8));
-
- QCOMPARE(items.size(), 1);
-
- QRect r = items.at(0)->bounds();
-
- if (x != 8) {
- QCOMPARE(r.x(), x * 16);
- if (x != 7) {
- QCOMPARE(r.width(), 15);
- } else {
- QCOMPARE(r.width(), 31);
- }
- } else {
- QCOMPARE(r.x(), (x - 1) * 16);
- QCOMPARE(r.width(), 31);
- }
-
- if (y != 8) {
- QCOMPARE(r.y(), y * 16);
- if (y != 7) {
- QCOMPARE(r.height(), 15);
- } else {
- QCOMPARE(r.height(), 31);
- }
- } else {
- QCOMPARE(r.y(), (y - 1) * 16);
- QCOMPARE(r.height(), 31);
- }
- }
- }
-
- QList<MapItem*> items = tree->items();
- delete tree;
- qDeleteAll(items);
-}
-
-void tst_MapItemTree::itemsAt_singleQuad()
-{
- MapItemTree *tree = setupTree();
-
- // Test that we include x and x+width but don't go
- // beyond that range on either side
-
- QList<QPair<int, bool> > vals;
- vals.append(QPair<int, bool>(15, false));
- vals.append(QPair<int, bool>(16, true));
- vals.append(QPair<int, bool>(24, true));
- vals.append(QPair<int, bool>(31, true));
- vals.append(QPair<int, bool>(32, false));
-
- for (int i = 0; i < vals.size(); ++i) {
-
- QPair<int, bool> px = vals.at(i);
-
- for (int j = 0; j < vals.size(); ++j) {
-
- QPair<int, bool> py = vals.at(j);
-
- QList<MapItem*> items = tree->itemsAt(QPoint(px.first, py.first));
-
- if (px.second && py.second) {
- QCOMPARE(items.size(), 1);
- QCOMPARE(items.at(0)->bounds(), QRect(16, 16, 15, 15));
- } else {
- QCOMPARE(items.size(), 0);
- }
- }
- }
-
- QList<MapItem*> items = tree->items();
- delete tree;
- qDeleteAll(items);
-}
-
-struct intervalAll {
- intervalAll(int start, int end, int count)
- : start(start),
- end(end),
- count(count) {}
-
- int start;
- int end;
- int count;
-};
-
-void tst_MapItemTree::itemsWithin_allQuads()
-{
- MapItemTree *tree = setupTree();
-
- QList<int> start;
- start.append(16);
- start.append(64);
- start.append(112);
- start.append(176);
- start.append(224);
-
- QList<int> end;
- end.append(31);
- end.append(79);
- end.append(143);
- end.append(191);
- end.append(239);
-
- QList<intervalAll> vals;
-
- for (int i = 0; i < start.size(); ++i) {
-
- int s = start.at(i);
-
- vals.append(intervalAll(s - 1, s, 1));
- vals.append(intervalAll(s, s + 1, 1));
- vals.append(intervalAll(s - 1, s + 1, 1));
-
- for (int j = i; j < end.size(); ++j) {
-
- int e = end.at(j);
- int c = j - i + 1;
-
- vals.append(intervalAll(s - 1, e + 1, c));
- vals.append(intervalAll(s, e, c));
- vals.append(intervalAll(s + 1, e - 1, c));
- }
- }
-
- for (int i = 0; i < end.size() - 1; ++i) {
- int e = end.at(i);
- for (int j = i + 1; j < start.size(); ++j) {
- int s = start.at(j);
- vals.append(intervalAll(e + 1, s - 1, j - i - 1));
- }
- }
-
- for (int i = 0; i < vals.size(); ++i) {
-
- intervalAll ix = vals.at(i);
-
- for (int j = 0; j < vals.size(); ++j) {
-
- intervalAll iy = vals.at(j);
-
- QRect r(ix.start, iy.start, ix.end - ix.start, iy.end - iy.start);
-
- QList<MapItem*> items = tree->itemsWithin(r);
-
- QCOMPARE(items.size(), ix.count * iy.count);
- }
- }
-
- QList<MapItem*> items = tree->items();
- delete tree;
- qDeleteAll(items);
-}
-
-struct intervalSingle {
- intervalSingle(int start, int end, bool contains)
- : start(start),
- end(end),
- contains(contains) {}
-
- int start;
- int end;
- bool contains;
-};
-
-void tst_MapItemTree::itemsWithin_singleQuad()
-{
- MapItemTree *tree = setupTree();
-
- QList<intervalSingle> vals;
- vals.append(intervalSingle(14, 15, false));
- vals.append(intervalSingle(15, 16, true));
- vals.append(intervalSingle(15, 17, true));
- vals.append(intervalSingle(16, 17, true));
-
- vals.append(intervalSingle(15, 32, true));
- vals.append(intervalSingle(16, 31, true));
- vals.append(intervalSingle(17, 30, true));
-
- vals.append(intervalSingle(30, 31, true));
- vals.append(intervalSingle(30, 32, true));
- vals.append(intervalSingle(31, 32, true));
- vals.append(intervalSingle(32, 33, false));
-
- for (int i = 0; i < vals.size(); ++i) {
-
- intervalSingle ix = vals.at(i);
-
- for (int j = 0; j < vals.size(); ++j) {
-
- intervalSingle iy = vals.at(j);
-
- QRect r(ix.start, iy.start, ix.end - ix.start, iy.end - iy.start);
-
- QList<MapItem*> items = tree->itemsWithin(r);
-
- if (ix.contains && iy.contains) {
- QCOMPARE(items.size(), 1);
- QCOMPARE(items.at(0)->bounds(), QRect(16, 16, 15, 15));
- } else {
- QCOMPARE(items.size(), 0);
- }
- }
- }
-
- QList<MapItem*> items = tree->items();
- delete tree;
- qDeleteAll(items);
-}
-
-void tst_MapItemTree::makeVisible()
-{
- MapItemTree *tree = setupTree();
-
- QList<MapItem*> added;
- QList<MapItem*> removed;
-
- tree->makeVisible(QRect(0, 0, 1, 1), added, removed);
- QCOMPARE(added.size(), 0);
- QCOMPARE(removed.size(), 25);
-
- QList<int> start;
- start.append(16);
- start.append(64);
- start.append(112);
- start.append(176);
- start.append(224);
-
- QList<int> end;
- end.append(31);
- end.append(79);
- end.append(143);
- end.append(191);
- end.append(239);
-
- QList<intervalAll> vals;
-
- for (int i = 0; i < start.size(); ++i) {
-
- int s = start.at(i);
-
- vals.append(intervalAll(s - 1, s, 1));
- vals.append(intervalAll(s, s + 1, 1));
- vals.append(intervalAll(s - 1, s + 1, 1));
-
- for (int j = i; j < end.size(); ++j) {
-
- int e = end.at(j);
- int c = j - i + 1;
-
- vals.append(intervalAll(s - 1, e + 1, c));
- vals.append(intervalAll(s, e, c));
- vals.append(intervalAll(s + 1, e - 1, c));
- }
- }
-
- for (int i = 0; i < end.size() - 1; ++i) {
- int e = end.at(i);
- for (int j = i + 1; j < start.size(); ++j) {
- int s = start.at(j);
- vals.append(intervalAll(e + 1, s - 1, j - i - 1));
- }
- }
-
- for (int i = 0; i < vals.size(); ++i) {
-
- intervalAll ix = vals.at(i);
-
- for (int j = 0; j < vals.size(); ++j) {
-
- intervalAll iy = vals.at(j);
-
- QRect r(ix.start, iy.start, ix.end - ix.start, iy.end - iy.start);
-
- tree->makeVisible(r, added, removed);
-
- QCOMPARE(added.size(), ix.count * iy.count);
- QCOMPARE(removed.size(), 0);
-
- tree->makeVisible(QRect(0, 0, 1, 1), added, removed);
-
- QCOMPARE(added.size(), 0);
- QCOMPARE(removed.size(), ix.count * iy.count);
- }
- }
-
- QList<MapItem*> items = tree->items();
- delete tree;
- qDeleteAll(items);
-}
-
-MapItemTree* tst_MapItemTree::setupTree()
-{
- MapItemTree *root = new MapItemTree();
-
- root->insert(dummyItemFromRect(QRect(16, 16, 15, 15)));
- root->insert(dummyItemFromRect(QRect(64, 16, 15, 15)));
- root->insert(dummyItemFromRect(QRect(112, 16, 31, 15)));
- root->insert(dummyItemFromRect(QRect(176, 16, 15, 15)));
- root->insert(dummyItemFromRect(QRect(224, 16, 15, 15)));
-
- root->insert(dummyItemFromRect(QRect(16, 64, 15, 15)));
- root->insert(dummyItemFromRect(QRect(64, 64, 15, 15)));
- root->insert(dummyItemFromRect(QRect(112, 64, 31, 15)));
- root->insert(dummyItemFromRect(QRect(176, 64, 15, 15)));
- root->insert(dummyItemFromRect(QRect(224, 64, 15, 15)));
-
- root->insert(dummyItemFromRect(QRect(16, 112, 15, 31)));
- root->insert(dummyItemFromRect(QRect(64, 112, 15, 31)));
- root->insert(dummyItemFromRect(QRect(112, 112, 31, 31)));
- root->insert(dummyItemFromRect(QRect(176, 112, 15, 31)));
- root->insert(dummyItemFromRect(QRect(224, 112, 15, 31)));
-
- root->insert(dummyItemFromRect(QRect(16, 176, 15, 15)));
- root->insert(dummyItemFromRect(QRect(64, 176, 15, 15)));
- root->insert(dummyItemFromRect(QRect(112, 176, 31, 15)));
- root->insert(dummyItemFromRect(QRect(176, 176, 15, 15)));
- root->insert(dummyItemFromRect(QRect(224, 176, 15, 15)));
-
- root->insert(dummyItemFromRect(QRect(16, 224, 15, 15)));
- root->insert(dummyItemFromRect(QRect(64, 224, 15, 15)));
- root->insert(dummyItemFromRect(QRect(112, 224, 31, 15)));
- root->insert(dummyItemFromRect(QRect(176, 224, 15, 15)));
- root->insert(dummyItemFromRect(QRect(224, 224, 15, 15)));
-
- QList<MapItem*> added;
- QList<MapItem*> removed;
- root->makeVisible(QRect(0, 0, 256, 256), added, removed);
-
- return root;
-}
-
-QTEST_APPLESS_MAIN(tst_MapItemTree)
-
-#include "tst_mapitemtree.moc"
-