MapWidget.h 3.72 KB
Newer Older
pixhawk's avatar
pixhawk committed
1 2
/*=====================================================================

3
QGroundControl Open Source Ground Control Station
pixhawk's avatar
pixhawk committed
4

5
(c) 2009, 2010 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
pixhawk's avatar
pixhawk committed
6

7
This file is part of the QGROUNDCONTROL project
pixhawk's avatar
pixhawk committed
8

9
    QGROUNDCONTROL is free software: you can redistribute it and/or modify
pixhawk's avatar
pixhawk committed
10 11 12 13
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

14
    QGROUNDCONTROL is distributed in the hope that it will be useful,
pixhawk's avatar
pixhawk committed
15 16 17 18 19
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
20
    along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
pixhawk's avatar
pixhawk committed
21 22 23 24 25

======================================================================*/

/**
 * @file
pixhawk's avatar
pixhawk committed
26
 *   @brief Definition of MapWidget
pixhawk's avatar
pixhawk committed
27 28
 *
 *   @author Lorenz Meier <mavteam@student.ethz.ch>
lm's avatar
lm committed
29
 *   @author Mariano Lizarraga
pixhawk's avatar
pixhawk committed
30 31 32 33 34 35 36
 *
 */

#ifndef MAPWIDGET_H
#define MAPWIDGET_H

#include <QtGui/QWidget>
pixhawk's avatar
pixhawk committed
37
#include <QMap>
pixhawk's avatar
pixhawk committed
38
#include "qmapcontrol.h"
lm's avatar
lm committed
39
#include "UASInterface.h"
pixhawk's avatar
pixhawk committed
40

lm's avatar
lm committed
41 42
class QMenu;

pixhawk's avatar
pixhawk committed
43 44 45 46 47 48
namespace Ui {
    class MapWidget;
}

using namespace qmapcontrol;

lm's avatar
lm committed
49 50 51 52 53 54
/**
 * @brief 2D Moving map
 *
 * This map displays street maps, aerial images and the MAV position,
 * waypoints and trails on top.
 */
pixhawk's avatar
pixhawk committed
55 56 57 58 59 60 61
class MapWidget : public QWidget {
    Q_OBJECT
public:
    MapWidget(QWidget *parent = 0);
    ~MapWidget();

public slots:
lm's avatar
lm committed
62 63 64
    void addUAS(UASInterface* uas);
    void updateGlobalPosition(UASInterface* uas, double lat, double lon, double alt, quint64 usec);
    void updatePosition(float time, double lat, double lon);
pixhawk's avatar
pixhawk committed
65

66 67 68
    //ROCA
    void clearPath();

pixhawk's avatar
pixhawk committed
69 70 71 72 73 74
protected:
    void changeEvent(QEvent* e);
    void wheelEvent(QWheelEvent *event);
    void keyPressEvent(QKeyEvent *event);
    void resizeEvent(QResizeEvent* event);

lm's avatar
lm committed
75 76 77 78 79 80 81
    QAction* osmAction;
    QAction* yahooActionMap;
    QAction* yahooActionSatellite;
    QAction* yahooActionOverlay;
    QAction* googleActionMap;
    QAction* googleSatAction;

82

pixhawk's avatar
pixhawk committed
83
    QPushButton* followgps;
84
    QPushButton* createPath;
pixhawk's avatar
pixhawk committed
85
    QLabel* gpsposition;
lm's avatar
lm committed
86 87 88 89 90 91 92 93
    QMenu* mapMenu;
    QPushButton* mapButton;

    MapControl* mc;                   ///< QMapControl widget
    MapAdapter* mapadapter;           ///< Adapter to load the map data
    qmapcontrol::Layer* l;            ///< Current map layer (background)
    qmapcontrol::Layer* overlay;      ///< Street overlay (foreground)
    qmapcontrol::GeometryLayer* geomLayer; ///< Layer for waypoints
pixhawk's avatar
pixhawk committed
94 95 96
    int zoomLevel;
    int detailZoom; ///< Steps zoomed in further than qMapControl allows
    static const int scrollStep = 40; ///< Scroll n pixels per keypress
lm's avatar
lm committed
97
    static const int maxZoom = 50;    ///< Maximum zoom level
98

99
    //Layer* gSatLayer;
pixhawk's avatar
pixhawk committed
100

pixhawk's avatar
pixhawk committed
101
    QMap<int, CirclePoint*> uasIcons;
102
    QMap<int, LineString*> uasTrails;
lm's avatar
lm committed
103
    UASInterface* mav;
pixhawk's avatar
pixhawk committed
104
    quint64 lastUpdate;
lm's avatar
lm committed
105

106 107
  protected slots:
    void captureMapClick (const QMouseEvent* event, const QPointF coordinate);
108
    void createPathButtonClicked(bool checked);
109
    void captureGeometryClick(Geometry*, QPoint);
lm's avatar
lm committed
110
    void mapproviderSelected(QAction* action);
111
    void captureGeometryDrag(Geometry* geom, QPointF coordinate);
112 113
    void captureGeometryEndDrag(Geometry* geom, QPointF coordinate);

114 115


116
  signals:
117
    //void movePoint(QPointF newCoord);
118
    void captureMapCoordinateClick(const QPointF coordinate); //ROCA
119
    void createGlobalWP(bool value);
120
    void sendGeometryEndDrag(const QPointF coordinate, const int index);
121

122

pixhawk's avatar
pixhawk committed
123 124
private:
    Ui::MapWidget *m_ui;
125
    QList<Point*> wps;
126
    QHash <QString, Point*> wpIndex;
127 128
    LineString* path;
    QPen* pointPen;
pixhawk's avatar
pixhawk committed
129 130 131
};

#endif // MAPWIDGET_H