Updated tests cases matching the new tabs
[situare] / src / map / maptile.h
1 /*
2    Situare - A location system for Facebook
3    Copyright (C) 2010  Ixonos Plc. Authors:
4
5        Sami Rämö - sami.ramo@ixonos.com
6
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.
10
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.
15
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,
19    USA.
20 */
21
22 #ifndef MAPTILE_H
23 #define MAPTILE_H
24
25 #include <QGraphicsPixmapItem>
26
27 class SceneCoordinate;
28
29 /**
30 * @brief Map tile item
31 *
32 * @author Sami Rämö - sami.ramo (at) ixonos.com
33 */
34 class MapTile : public QGraphicsPixmapItem
35 {
36 public:
37     /**
38     * @brief Constructor
39     */
40     MapTile();
41
42 /*******************************************************************************
43  * MEMBER FUNCTIONS AND SLOTS
44  ******************************************************************************/
45 public:
46     /**
47      * @brief Convert tile x & y numbers to MapScene coordinates
48      *
49      * @param zoomLevel Zoom level
50      * @param tileNumber x & y numbers of the tile
51      * @return Scene coordinate
52      */
53     static SceneCoordinate convertTileNumberToSceneCoordinate(int zoomLevel, QPoint tileNumber);
54
55     /**
56      * @brief Calculate maximum value for tile in this zoom level.
57      *
58      * @param zoomLevel zoom level
59      * @return int tile's maximum value
60      */
61     static int lastTileIndex(int zoomLevel);
62
63     /**
64     * @brief Set drawing level of the tile based on current zoom level
65     *
66     * Drawing order of MapTiles, which has the zoom level higher than the current
67     * zoom level, is reversed and those MapTiles are mapped between lower level MapTiles.
68     * Example: If maximum zoom level is 18 and current view zoomlevel is 15, then
69     * the drawing order from top to bottom is 15, 16, 14, 17, 13, 18, 12, 11, 10, ...
70     * @param currentZoomLevel current zoom level
71     */
72     void setSceneLevel(int currentZoomLevel);
73
74     /**
75     * @brief Setter for tile number
76     *
77     * Does also set the position for the item in the MapScene coordinate system
78     * @param tileNumber Tile number
79     */
80     void setTileNumber(QPoint tileNumber);
81
82     /**
83     * @brief Setter for zoom level
84     *
85     * Does also set the zValue.
86     *
87     * @param tileZoomLevel Zoom level of the tile
88     * @param currentViewZoomLevel Current view zoom level
89     */
90     void setZoomLevel(int tileZoomLevel, int currentViewZoomLevel);
91
92     /**
93     * @brief Getter for tile number
94     *
95     * @return Tile number
96     */
97     QPoint tileNumber();
98
99     /**
100      * @brief Return tile path created from tile values.
101      *
102      * @param zoomLevel tile's zoom level
103      * @param x tile's x value
104      * @param y tile's y value
105      * @return QString tile path
106      */
107     static QString tilePath(int zoomLevel, int x, int y);
108
109     /**
110      * @brief Maximum number of individual tiles per side at given zoom level
111      *
112      * @param zoomLevel Zoom level
113      * @return amount of tiles per side at given zoom level
114      */
115     static int tilesPerSide(int zoomLevel);
116
117     /**
118     * @brief Getter for zoom level
119     *
120     * @return Zoom level
121     */
122     int zoomLevel();
123
124 private:
125     /**
126     * @brief Set position of the tile in the MapScene coordinate system
127     *
128     * Does set the position based on the m_zoomLevel and the m_TileNumber. Position is set to
129     * (UNDEFINED, UNDEFINED) if there is something wrong with zoom level or tile numbers
130     */
131     void setPosition();
132
133 /*******************************************************************************
134  * DATA MEMBERS
135  ******************************************************************************/
136 private:
137     int m_zoomLevel;        ///< Zoom level
138
139     QPoint m_tileNumber;    ///< Tile number
140 };
141
142 #endif // MAPTILE_H