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>
30 * @brief Map scene for storing MapTile items
32 * @author Sami Rämö - sami.ramo (at) ixonos.com
34 class MapScene : public QGraphicsScene
41 * Scene size is set to the amount of pixels on closest zoom level
42 * @param parent Parent
44 MapScene(QObject *parent = 0);
46 /*******************************************************************************
47 * MEMBER FUNCTIONS AND SLOTS
48 ******************************************************************************/
51 * @brief Add MapTile item to scene
53 * @param mapTile Map tile item to be added
54 * @param hashKey Hash key for the tile
56 void addTile(MapTile *mapTile, QString hashKey);
58 void debugItemsCount();
61 * @brief Enqueue stacked tiles removal request
63 * Removal is triggered after events have been processed so the UI
64 * stays more responsive
65 * @param newTile New tile, which area under it is inspected
67 void enqueueRemoveStackedTiles(MapTile *newTile);
70 * @brief Returns if tile mathcing hash key is already in the scene
73 * @return True if tile was in the scene, otherwise false
75 bool isTileInScene(QString hashKey);
78 * @brief Remove tiles which are out of view bounds.
81 void removeOutOfViewTiles();
84 * @brief Remove tiles which are stacked.
86 * Iterate through tiles which are under this map tile and remove tiles which
87 * are fully obscured by this new tile. Tiles which are only partially
88 * obscured by this new tile are not checked, and thus deleted, because of
89 * the required complexity of the algorithm and processing power. Those tiles
90 * will be removed when they go out of the view area caused by scrolling or
93 * @param newTile new tile covering old tiles
95 void removeStackedTiles(MapTile *newTile);
100 * Removes tile from scene and list of current tiles in scene.
101 * @param tile MapTile to remove
103 void removeTile(MapTile *tile);
106 * @brief Set drawing order of all tiles in the scene
108 * Check MapTile::setSceneLevel for more information.
109 * @param zoomLevel Current zoom level
111 void setTilesDrawingLevels(int zoomLevel);
114 * @brief Save new view rect
116 * View rect must be saved to local scope whenever it changes because
117 * it is used by removal algorithms and some of the algorithms are run
118 * delayed so the actual view rect may change before the cleanup
121 * @param viewRect New view rect
123 void viewRectUpdated(QRect viewRect);
127 * @brief Slot for running next queued removal of stacked tiles
130 void runNextStackedTilesRemoval();
132 /*******************************************************************************
134 ******************************************************************************/
136 bool m_isRemoveStackedTilesRunning; ///< Is singleshot timer already running
137 QHash<QString, MapTile *> m_mapTilesInScene; ///< List of map tiles in map scene
138 QList<MapTile *> m_removeStackedTilesList; ///< "Queue" for stacked tiles removal requests
139 QRect m_viewRect; ///< Current viewable area