Map scene for storing MapTile items. More...
#include <mapscene.h>
Public Member Functions | |
MapScene (QObject *parent=0) | |
Constructor. | |
void | addTile (MapTile *mapTile, QString hashKey) |
Add MapTile item to scene. | |
void | enqueueRemoveStackedTiles (MapTile *newTile) |
Enqueue stacked tiles removal request. | |
bool | isTileInScene (QString hashKey) |
Returns if tile mathcing hash key is already in the scene. | |
void | removeOutOfViewTiles () |
Remove tiles which are out of view bounds. | |
void | removeStackedTiles (MapTile *newTile) |
Remove tiles which are stacked. | |
void | removeTile (MapTile *tile) |
Remove tile. | |
void | setTilesDrawingLevels (int zoomLevel) |
Set drawing order of all tiles in the scene. | |
void | viewRectUpdated (QRect viewRect) |
Save new view rect. | |
Private Slots | |
void | runNextStackedTilesRemoval () |
Slot for running next queued removal of stacked tiles. | |
Private Attributes | |
bool | m_isRemoveStackedTilesRunning |
Is singleshot timer already running. | |
QHash< QString, MapTile * > | m_mapTilesInScene |
List of map tiles in map scene. | |
QList< MapTile * > | m_removeStackedTilesList |
"Queue" for stacked tiles removal requests | |
QRect | m_viewRect |
Current viewable area. |
Map scene for storing MapTile items.
MapScene::MapScene | ( | QObject * | parent = 0 |
) |
Constructor.
Scene size is set to the amount of pixels on closest zoom level
parent | Parent |
void MapScene::addTile | ( | MapTile * | mapTile, | |
QString | hashKey | |||
) |
Add MapTile item to scene.
mapTile | Map tile item to be added | |
hashKey | Hash key for the tile |
void MapScene::enqueueRemoveStackedTiles | ( | MapTile * | newTile | ) |
Enqueue stacked tiles removal request.
Removal is triggered after events have been processed so the UI stays more responsive
newTile | New tile, which area under it is inspected |
bool MapScene::isTileInScene | ( | QString | hashKey | ) |
Returns if tile mathcing hash key is already in the scene.
hashKey |
void MapScene::removeStackedTiles | ( | MapTile * | newTile | ) |
Remove tiles which are stacked.
Iterate through tiles which are under this map tile and remove tiles which are fully obscured by this new tile. Tiles which are only partially obscured by this new tile are not checked, and thus deleted, because of the required complexity of the algorithm and processing power. Those tiles will be removed when they go out of the view area caused by scrolling or zooming in enough.
newTile | new tile covering old tiles |
void MapScene::removeTile | ( | MapTile * | tile | ) |
Remove tile.
Removes tile from scene and list of current tiles in scene.
tile | MapTile to remove |
void MapScene::setTilesDrawingLevels | ( | int | zoomLevel | ) |
Set drawing order of all tiles in the scene.
Check MapTile::setSceneLevel for more information.
zoomLevel | Current zoom level |
void MapScene::viewRectUpdated | ( | QRect | viewRect | ) |
Save new view rect.
View rect must be saved to local scope whenever it changes because it is used by removal algorithms and some of the algorithms are run delayed so the actual view rect may change before the cleanup algorithm is run.
viewRect | New view rect |