#include <QGraphicsScene>
-#include "mapcommon.h"
+#include "maptile.h"
-class MapTile;
+class SceneCoordinate;
/**
* @brief Map scene for storing MapTile items
/**
* @brief Create and add new MapTile to MapScene
*
- * If there is a tile with same parameter already in the scene, it will be removed
+ * If there is a tile with same parameters already in the scene, it will be removed
* before adding the new tile.
*
- * @param mapTile Map tile item to be added
- * @param hashKey Hash key for the tile
+ * @param zoomLevel Zoom level of the new tile
+ * @param tileNumber X & Y indexes of the tile
+ * @param image Map tile picture
+ * @param viewZoomLevel Current view zoom level (for setting the zValue)
*/
void addTile(int zoomLevel, QPoint tileNumber, const QPixmap &image, int viewZoomLevel);
void enqueueRemoveStackedTiles(MapTile *newTile);
/**
+ * @brief Calculates scene horizontal resolution in given latitude
+ *
+ * @param latitude Resolution is calculated in this latitude
+ * @returns Scene horizontal resolution (meters/pixel)
+ */
+ static qreal horizontalResolutionAtLatitude(double latitude);
+
+ /**
* @brief Returns tile mathcing given hash key
*
* @param hashKey
/**
* @brief Remove tiles which are out of view bounds.
*
+ * Does not remove tiles which are duplicated from current view to opposite side of
+ * the scene.
+ *
+ * @param tilesGrid Current tiles grid
+ * @param zoomLevel Current zoom level
*/
void removeOutOfViewTiles(QRect tilesGrid, int zoomLevel);
*/
void removeTile(MapTile *tile);
+ /**
+ * @brief 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.
+ *
+ * @param viewHeight Height of the view
+ * @param zoomLevel Current zoom level
+ */
void setSceneVerticalOverlap(int viewHeight, int zoomLevel);
/**
*/
void setTilesDrawingLevels(int zoomLevel);
- void spanItems(ScrollDirection direction, int zoomLevel, QPoint sceneCoordinate, QSize viewSize);
+ /**
+ * @brief Setter for m_viewTilesGrid
+ *
+ * @param grid Tile grid
+ */
+ void setTilesGrid(QRect grid);
+
+ /**
+ * @brief Setter for m_zoomLevel
+ *
+ * @param zoomLevel Zoom level
+ */
+ void setZoomLevel(int zoomLevel);
+
+ /**
+ * @brief Span items (others than MapTile) to opposite side of the scene
+ *
+ * @param viewSceneRect Scene area which is currently drawn on the view
+ */
+ void spanItems(QRectF viewSceneRect);
/**
* @brief Save new tiles scene rect
void tilesSceneRectUpdated(QRect tilesSceneRect);
private:
+ /**
+ * @brief Move map items horizontally in the scene (not MapTile items)
+ *
+ * MapTile items are not moved!
+ *
+ * Move items which intersect the given rect.
+ *
+ * @param from Items colliding given rect are moved
+ * @param distance How much to move each item
+ */
void moveIntersectingItemsHorizontally(QRect from, int distance);
private slots:
/**
+ * @brief Remove tiles from other than current zoom levels
+ *
+ * Does remove tiles only if all tiles in current m_viewTilesGrid are in the scene.
+ */
+ void removeOtherLevelTiles();
+
+ /**
* @brief Slot for running next queued removal of stacked tiles
*
*/
* DATA MEMBERS
******************************************************************************/
private:
- bool m_isRemoveStackedTilesRunning; ///< Is singleshot timer already running
+ 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
+ QList<MapTile *> m_removeStackedTilesList; ///< "Queue" for stacked tiles removal requests
+ QRect m_tilesSceneRect; ///< Current viewable area
+ QRect m_viewTilesGrid; ///< Current grid of tiles
};
#endif // MAPSCENE_H