Updated tests cases matching the new tabs
[situare] / src / map / mapscene.h
index 73431c8..7f221da 100644 (file)
@@ -24,9 +24,9 @@
 
 #include <QGraphicsScene>
 
-#include "mapcommon.h"
+#include "maptile.h"
 
-class MapTile;
+class SceneCoordinate;
 
 /**
 * @brief Map scene for storing MapTile items
@@ -52,11 +52,13 @@ public:
     /**
     * @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);
 
@@ -70,6 +72,14 @@ public:
     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
@@ -80,6 +90,11 @@ public:
     /**
     * @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);
 
@@ -105,6 +120,15 @@ public:
     */
     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);
 
     /**
@@ -115,7 +139,26 @@ public:
     */
     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
@@ -130,10 +173,27 @@ public:
     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
     *
     */
@@ -143,10 +203,12 @@ private slots:
  * 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