MapScene Class Reference

Map scene for storing MapTile items. More...

#include <mapscene.h>

List of all members.

Public Member Functions

 MapScene (QObject *parent=0)
 Constructor.
void addTile (int zoomLevel, QPoint tileNumber, const QPixmap &image, int viewZoomLevel)
 Create and add new MapTile to MapScene.
void enqueueRemoveStackedTiles (MapTile *newTile)
 Enqueue stacked tiles removal request.
MapTiletileInScene (QString hashKey)
 Returns tile mathcing given hash key.
void removeOutOfViewTiles (QRect tilesGrid, int zoomLevel)
 Remove tiles which are out of view bounds.
void removeStackedTiles (MapTile *newTile)
 Remove tiles which are stacked.
void removeTile (MapTile *tile)
 Remove tile.
void setSceneVerticalOverlap (int viewHeight, int zoomLevel)
 Set allowed amount of exceeding the world vertical limits.
void setTilesDrawingLevels (int zoomLevel)
 Set drawing order of all tiles in the scene.
void setTilesGrid (QRect grid)
 Setter for m_viewTilesGrid.
void setZoomLevel (int zoomLevel)
 Setter for m_zoomLevel.
void spanItems (QRectF viewSceneRect)
 Span items (others than MapTile) to opposite side of the scene.
void tilesSceneRectUpdated (QRect tilesSceneRect)
 Save new tiles scene rect.

Static Public Member Functions

static qreal horizontalResolutionAtLatitude (double latitude)
 Calculates scene horizontal resolution in given latitude.

Private Slots

void removeOtherLevelTiles ()
 Remove tiles from other than current zoom levels.
void runNextStackedTilesRemoval ()
 Slot for running next queued removal of stacked tiles.

Private Member Functions

void moveIntersectingItemsHorizontally (QRect from, int distance)
 Move map items horizontally in the scene (not MapTile items).

Private Attributes

bool m_isRemoveStackedTilesRunning
 Is singleshot timer already running.
int m_zoomLevel
 Current zoom level.
QHash< QString, MapTile * > m_mapTilesInScene
 List of map tiles in map scene.
QList< MapTile * > m_removeStackedTilesList
 "Queue" for stacked tiles removal requests
QRect m_tilesSceneRect
 Current viewable area.
QRect m_viewTilesGrid
 Current grid of tiles.

Detailed Description

Map scene for storing MapTile items.

Author:
Sami Rämö - sami.ramo (at) ixonos.com

Constructor & Destructor Documentation

MapScene::MapScene ( QObject *  parent = 0  ) 

Constructor.

Scene size is set to the amount of pixels on closest zoom level

Parameters:
parent Parent

Member Function Documentation

void MapScene::addTile ( int  zoomLevel,
QPoint  tileNumber,
const QPixmap &  image,
int  viewZoomLevel 
)

Create and add new MapTile to MapScene.

If there is a tile with same parameters already in the scene, it will be removed before adding the new tile.

Parameters:
zoomLevel Zoom level of the new tile
tileNumber X & Y indexes of the tile
image Map tile picture
viewZoomLevel Current view zoom level (for setting the zValue)
void MapScene::enqueueRemoveStackedTiles ( MapTile newTile  ) 

Enqueue stacked tiles removal request.

Removal is triggered after events have been processed so the UI stays more responsive

Parameters:
newTile New tile, which area under it is inspected
qreal MapScene::horizontalResolutionAtLatitude ( double  latitude  )  [static]

Calculates scene horizontal resolution in given latitude.

Parameters:
latitude Resolution is calculated in this latitude
Returns:
Scene horizontal resolution (meters/pixel)
void MapScene::moveIntersectingItemsHorizontally ( QRect  from,
int  distance 
) [private]

Move map items horizontally in the scene (not MapTile items).

MapTile items are not moved!

Move items which intersect the given rect.

Parameters:
from Items colliding given rect are moved
distance How much to move each item
void MapScene::removeOtherLevelTiles (  )  [private, slot]

Remove tiles from other than current zoom levels.

Does remove tiles only if all tiles in current m_viewTilesGrid are in the scene.

void MapScene::removeOutOfViewTiles ( QRect  tilesGrid,
int  zoomLevel 
)

Remove tiles which are out of view bounds.

Does not remove tiles which are duplicated from current view to opposite side of the scene.

Parameters:
tilesGrid Current tiles grid
zoomLevel Current zoom level
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.

Parameters:
newTile new tile covering old tiles
void MapScene::removeTile ( MapTile tile  ) 

Remove tile.

Removes tile from scene and list of current tiles in scene.

Parameters:
tile MapTile to remove
void MapScene::setSceneVerticalOverlap ( int  viewHeight,
int  zoomLevel 
)

Set allowed amount of exceeding the world vertical limits.

Limit is set so that vertical limits of the world can be scrolled to middle of the view.

Parameters:
viewHeight Height of the view
zoomLevel Current zoom level
void MapScene::setTilesDrawingLevels ( int  zoomLevel  ) 

Set drawing order of all tiles in the scene.

Check MapTile::setSceneLevel for more information.

Parameters:
zoomLevel Current zoom level
void MapScene::setTilesGrid ( QRect  grid  ) 

Setter for m_viewTilesGrid.

Parameters:
grid Tile grid
void MapScene::setZoomLevel ( int  zoomLevel  ) 

Setter for m_zoomLevel.

Parameters:
zoomLevel Zoom level
void MapScene::spanItems ( QRectF  viewSceneRect  ) 

Span items (others than MapTile) to opposite side of the scene.

Parameters:
viewSceneRect Scene area which is currently drawn on the view
MapTile * MapScene::tileInScene ( QString  hashKey  ) 

Returns tile mathcing given hash key.

Parameters:
hashKey 
Returns:
Returns tile matching given hash key, or 0 if no match found
void MapScene::tilesSceneRectUpdated ( QRect  tilesSceneRect  ) 

Save new tiles scene rect.

Tiles scene 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 tiles scene rect may change before the cleanup algorithm is run.

Parameters:
tilesSceneRect New view rect

The documentation for this class was generated from the following files:

Generated on Fri Sep 3 12:05:41 2010 for Situare client for Maemo by  doxygen 1.6.1