Root/mapwidget.h

1/*
2 * Copyright 2010 Niels Kummerfeldt <niels.kummerfeldt@tu-harburg.de>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301 USA
18 */
19
20#ifndef MAPWIDGET_H
21#define MAPWIDGET_H
22
23#include "abstractlayer.h"
24
25#include <QtCore/QMap>
26#include <QtCore/QPoint>
27#include <QtGui/QMenu>
28#include <QtGui/QWidget>
29#include <QtNetwork/QNetworkAccessManager>
30
31class MapWidget : public QWidget
32{
33    Q_OBJECT
34public:
35    MapWidget(QWidget *parent = 0);
36    ~MapWidget();
37
38    void addLayer(AbstractLayer *layer, int z, const QString &name);
39
40    QRectF geoRect() const;
41    QPointF geoPos() const;
42    QPoint geo2screen(qreal lon, qreal lat) const;
43    QPoint raw2screen(qreal x, qreal y, int scale) const;
44
45public slots:
46    void centerOnGeoPos(qreal lon, qreal lat);
47
48signals:
49    void close();
50    void showMarkerList();
51    void downloadArea(int level, const QRectF &rect);
52    void loadFile();
53    void search();
54
55protected:
56    virtual void resizeEvent(QResizeEvent *event);
57    virtual void mouseMoveEvent(QMouseEvent *event);
58    virtual void mousePressEvent(QMouseEvent *event);
59    virtual void mouseReleaseEvent(QMouseEvent *event);
60    virtual void wheelEvent(QWheelEvent *event);
61    virtual void keyPressEvent(QKeyEvent *event);
62    virtual void paintEvent(QPaintEvent *event);
63
64private slots:
65    void replyFinished(QNetworkReply *reply);
66    void loadConfig();
67
68private:
69    void updatePos();
70    void reloadPixmaps();
71    QString filename(int x, int y);
72    QPixmap *loadPixmap(int x, int y);
73    void loadMapFile(const QString &filename);
74    void saveConfig();
75    void downloadTile(int x, int y, int level);
76    void changeZoomLevel(int diff);
77
78    bool m_usage, m_ui, m_zoomable;
79    bool m_takeScreenshot;
80    int m_screenshotNumber;
81    QString m_baseName;
82    int m_xPadding, m_yPadding;
83    QPoint m_pos, m_startPos;
84    bool m_isMoving;
85    int m_pixWidth, m_pixHeight;
86    QPixmap *m_pix[100][100];
87    int m_cols, m_rows;
88    int m_indexX, m_indexY;
89    int m_minIndexX, m_minIndexY;
90    int m_maxIndexX, m_maxIndexY;
91    QList<int> m_minIndexXList, m_minIndexYList;
92    QList<int> m_maxIndexXList, m_maxIndexYList;
93    int m_level;
94    QStringList m_zoomLevel;
95    QNetworkAccessManager *m_manager;
96    bool m_networkMode;
97    QString m_copyright;
98    QMap<int, AbstractLayer *> m_layer;
99    QMenu *m_layerMenu;
100
101};
102
103#endif // MAPWIDGET_H
104

Archive Download this file

Branches:
master



interactive