2 Situare - A location system for Facebook
3 Copyright (C) 2010 Ixonos Plc. Authors:
5 Sami Rämö - sami.ramo@ixonos.com
7 Situare is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License
9 version 2 as published by the Free Software Foundation.
11 Situare is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with Situare; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
25 #include <QGraphicsScene>
27 #include "mapcommon.h"
32 * @brief Map scene for storing MapTile items
34 * @author Sami Rämö - sami.ramo (at) ixonos.com
36 class MapScene : public QGraphicsScene
43 * Scene size is set to the amount of pixels on closest zoom level
44 * @param parent Parent
46 MapScene(QObject *parent = 0);
48 /*******************************************************************************
49 * MEMBER FUNCTIONS AND SLOTS
50 ******************************************************************************/
53 * @brief Create and add new MapTile to MapScene
55 * If there is a tile with same parameter already in the scene, it will be removed
56 * before adding the new tile.
58 * @param mapTile Map tile item to be added
59 * @param hashKey Hash key for the tile
61 void addTile(int zoomLevel, QPoint tileNumber, const QPixmap &image, int viewZoomLevel);
64 * @brief Enqueue stacked tiles removal request
66 * Removal is triggered after events have been processed so the UI
67 * stays more responsive
68 * @param newTile New tile, which area under it is inspected
70 void enqueueRemoveStackedTiles(MapTile *newTile);
73 * @brief Returns tile mathcing given hash key
76 * @return Returns tile matching given hash key, or 0 if no match found
78 MapTile* tileInScene(QString hashKey);
81 * @brief Remove tiles which are out of view bounds.
84 void removeOutOfViewTiles(QRect tilesGrid, int zoomLevel);
87 * @brief Remove tiles which are stacked.
89 * Iterate through tiles which are under this map tile and remove tiles which
90 * are fully obscured by this new tile. Tiles which are only partially
91 * obscured by this new tile are not checked, and thus deleted, because of
92 * the required complexity of the algorithm and processing power. Those tiles
93 * will be removed when they go out of the view area caused by scrolling or
96 * @param newTile new tile covering old tiles
98 void removeStackedTiles(MapTile *newTile);
101 * @brief Remove tile.
103 * Removes tile from scene and list of current tiles in scene.
104 * @param tile MapTile to remove
106 void removeTile(MapTile *tile);
108 void setSceneVerticalOverlap(int viewHeight, int zoomLevel);
111 * @brief Set drawing order of all tiles in the scene
113 * Check MapTile::setSceneLevel for more information.
114 * @param zoomLevel Current zoom level
116 void setTilesDrawingLevels(int zoomLevel);
118 QRect spanItems(ScrollDirection direction, int zoomLevel);
121 * @brief Save new tiles scene rect
123 * Tiles scene rect must be saved to local scope whenever it changes because
124 * it is used by removal algorithms and some of the algorithms are run
125 * delayed so the actual tiles scene rect may change before the cleanup
128 * @param tilesSceneRect New view rect
130 void tilesSceneRectUpdated(QRect tilesSceneRect);
134 * @brief Slot for running next queued removal of stacked tiles
137 void runNextStackedTilesRemoval();
139 /*******************************************************************************
141 ******************************************************************************/
143 bool m_isRemoveStackedTilesRunning; ///< Is singleshot timer already running
144 QHash<QString, MapTile *> m_mapTilesInScene; ///< List of map tiles in map scene
145 QList<MapTile *> m_removeStackedTilesList; ///< "Queue" for stacked tiles removal requests
146 QRect m_tilesSceneRect; ///< Current viewable area