Adding comments
[situare] / src / ui / mapscale.h
1  /*
2     Situare - A location system for Facebook
3     Copyright (C) 2010  Ixonos Plc. Authors:
4
5         Kaj Wallin - kaj.wallin@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
23 #ifndef MAPSCALE_H
24 #define MAPSCALE_H
25
26 #include <QWidget>
27
28 class QLineF;
29
30 /**
31  * @brief Map distance scale
32  *
33  * @author Kaj Wallin - kaj.wallin (at) ixonos.com
34  */
35 class MapScale : public QWidget
36 {
37     Q_OBJECT
38
39 public:
40     /**
41      * @brief Constructor
42      *
43      * @param parent Parent
44      */
45     MapScale(QWidget *parent = 0);
46
47 /*******************************************************************************
48  * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
49  ******************************************************************************/
50     /**
51      * @brief Event handler for paint events
52      *
53      * Paints the scale
54      * @param event Paint event
55      */
56     void paintEvent(QPaintEvent *event);
57
58 /******************************************************************************
59  * MEMBER FUNCTIONS AND SLOTS
60  ******************************************************************************/
61 private:
62     /**
63      * @brief Rounding function for distances
64      *
65      * Rounds the given value to closest 1,2,5 or 10 in the original scale
66      * @param value Value to be rounded
67      * @return qreal Rounded value
68      */
69     qreal roundToBaseScale(qreal value);
70
71 public slots:
72     /**
73      * @brief Slot to update the scale with latest resolution
74      *
75      * @param resolution Resolution of the map in meters/pixel
76      */
77     void updateMapResolution(const qreal &resolution);
78
79 /*******************************************************************************
80  * DATA MEMBERS
81  ******************************************************************************/
82 private:
83     qreal m_centerLineImperial;     ///< Length of the imperial scale
84     qreal m_centerLineMetric;       ///< Length of the metric scale
85     QString m_imperialText;         ///< Text description of the imperial scale
86     QString m_metricText;           ///< Text description of the metric scale
87 };
88
89 #endif // MAPSCALE_H