00001 /* 00002 Situare - A location system for Facebook 00003 Copyright (C) 2010 Ixonos Plc. Authors: 00004 00005 Sami Rämö - sami.ramo@ixonos.com 00006 00007 Situare is free software; you can redistribute it and/or 00008 modify it under the terms of the GNU General Public License 00009 version 2 as published by the Free Software Foundation. 00010 00011 Situare is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with Situare; if not, write to the Free Software 00018 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 00019 USA. 00020 */ 00021 00022 #ifndef MAPSCENE_H 00023 #define MAPSCENE_H 00024 00025 #include <QGraphicsScene> 00026 00027 #include "maptile.h" 00028 00029 class SceneCoordinate; 00030 00036 class MapScene : public QGraphicsScene 00037 { 00038 Q_OBJECT 00039 public: 00046 MapScene(QObject *parent = 0); 00047 00048 /******************************************************************************* 00049 * MEMBER FUNCTIONS AND SLOTS 00050 ******************************************************************************/ 00051 public: 00063 void addTile(int zoomLevel, QPoint tileNumber, const QPixmap &image, int viewZoomLevel); 00064 00072 void enqueueRemoveStackedTiles(MapTile *newTile); 00073 00080 static qreal horizontalResolutionAtLatitude(double latitude); 00081 00088 MapTile* tileInScene(QString hashKey); 00089 00099 void removeOutOfViewTiles(QRect tilesGrid, int zoomLevel); 00100 00113 void removeStackedTiles(MapTile *newTile); 00114 00121 void removeTile(MapTile *tile); 00122 00132 void setSceneVerticalOverlap(int viewHeight, int zoomLevel); 00133 00140 void setTilesDrawingLevels(int zoomLevel); 00141 00147 void setTilesGrid(QRect grid); 00148 00154 void setZoomLevel(int zoomLevel); 00155 00161 void spanItems(QRectF viewSceneRect); 00162 00173 void tilesSceneRectUpdated(QRect tilesSceneRect); 00174 00175 private: 00186 void moveIntersectingItemsHorizontally(QRect from, int distance); 00187 00188 private slots: 00194 void removeOtherLevelTiles(); 00195 00200 void runNextStackedTilesRemoval(); 00201 00202 /******************************************************************************* 00203 * DATA MEMBERS 00204 ******************************************************************************/ 00205 private: 00206 bool m_isRemoveStackedTilesRunning; 00207 int m_zoomLevel; 00208 QHash<QString, MapTile *> m_mapTilesInScene; 00209 QList<MapTile *> m_removeStackedTilesList; 00210 QRect m_tilesSceneRect; 00211 QRect m_viewTilesGrid; 00212 }; 00213 00214 #endif // MAPSCENE_H