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);
59 * @brief Enqueue stacked tiles removal request
61 * Removal is triggered after events have been processed so the UI
62 * stays more responsive
63 * @param newTile New tile, which area under it is inspected
65 void enqueueRemoveStackedTiles(MapTile *newTile);
68 * @brief Returns if tile mathcing hash key is already in the scene
71 * @return True if tile was in the scene, otherwise false
73 bool isTileInScene(QString hashKey);
76 * @brief Remove tiles which are out of view bounds.
79 void removeOutOfViewTiles();
82 * @brief Remove tiles which are stacked.
84 * Iterate through tiles which are under this map tile and remove tiles which
85 * are fully obscured by this new tile. Tiles which are only partially
86 * obscured by this new tile are not checked, and thus deleted, because of
87 * the required complexity of the algorithm and processing power. Those tiles
88 * will be removed when they go out of the view area caused by scrolling or
91 * @param newTile new tile covering old tiles
93 void removeStackedTiles(MapTile *newTile);
98 * Removes tile from scene and list of current tiles in scene.
99 * @param tile MapTile to remove
101 void removeTile(MapTile *tile);
104 * @brief Set drawing order of all tiles in the scene
106 * Check MapTile::setSceneLevel for more information.
107 * @param zoomLevel Current zoom level
109 void setTilesDrawingLevels(int zoomLevel);
112 * @brief Save new view rect
114 * View rect must be saved to local scope whenever it changes because
115 * it is used by removal algorithms and some of the algorithms are run
116 * delayed so the actual view rect may change before the cleanup
119 * @param viewRect New view rect
121 void viewRectUpdated(QRect viewRect);
125 * @brief Slot for running next queued removal of stacked tiles
128 void runNextStackedTilesRemoval();
130 /*******************************************************************************
132 ******************************************************************************/
134 bool m_isRemoveStackedTilesRunning; ///< Is singleshot timer already running
135 QHash<QString, MapTile *> m_mapTilesInScene; ///< List of map tiles in map scene
136 QList<MapTile *> m_removeStackedTilesList; ///< "Queue" for stacked tiles removal requests
137 QRect m_viewRect; ///< Current viewable area