QGCMapWidget.h 3.5 KB
Newer Older
lm's avatar
lm committed
1 2 3
#ifndef QGCMAPWIDGET_H
#define QGCMAPWIDGET_H

4
#include <QMap>
5
#include <QTimer>
lm's avatar
lm committed
6 7
#include "opmapcontrol.h"

lm's avatar
lm committed
8
class UASInterface;
9 10
class UASWaypointManager;
class Waypoint;
11
typedef mapcontrol::WayPointItem WayPointItem;
lm's avatar
lm committed
12

13 14 15
/**
 * @brief Class representing a 2D map using aerial imagery
 */
lm's avatar
lm committed
16
class QGCMapWidget : public mapcontrol::OPMapWidget
lm's avatar
lm committed
17 18 19 20
{
    Q_OBJECT
public:
    explicit QGCMapWidget(QWidget *parent = 0);
lm's avatar
lm committed
21
    ~QGCMapWidget();
22 23 24 25
//    /** @brief Convert meters to pixels */
//    float metersToPixels(double meters);
//    double headingP1P2(internals::PointLatLng p1, internals::PointLatLng p2);
//    internals::PointLatLng targetLatLon(internals::PointLatLng source, double heading, double dist);
lm's avatar
lm committed
26

27 28 29
    /** @brief Map centered on current active system */
    bool getFollowUAVEnabled() { return followUAVEnabled; }

lm's avatar
lm committed
30
signals:
31
    void homePositionChanged(double latitude, double longitude, double altitude);
32 33 34
    /** @brief Signal for newly created map waypoints */
    void waypointCreated(Waypoint* wp);
    void waypointChanged(Waypoint* wp);
lm's avatar
lm committed
35 36

public slots:
37
    /** @brief Add system to map view */
lm's avatar
lm committed
38
    void addUAS(UASInterface* uas);
39
    /** @brief Update the global position of a system */
lm's avatar
lm committed
40
    void updateGlobalPosition(UASInterface* uas, double lat, double lon, double alt, quint64 usec);
41 42
    /** @brief Update the global position of all systems */
    void updateGlobalPosition();
43 44
    /** @brief Update the type, size, etc. of this system */
    void updateSystemSpecs(int uas);
45 46 47 48
    /** @brief Change current system in focus / editing */
    void activeUASSet(UASInterface* uas);
    /** @brief Show a dialog to jump to given GPS coordinates */
    void showGoToDialog();
49 50
    /** @brief Jump to the home position on the map */
    void goHome();
51 52 53 54 55 56
    /** @brief Update this waypoint for this UAS */
    void updateWaypoint(int uas, Waypoint* wp);
    /** @brief Update the whole waypoint */
    void updateWaypointList(int uas);
    /** @brief Update the home position on the map */
    void updateHomePosition(double latitude, double longitude, double altitude);
57 58
    /** @brief Set update rate limit */
    void setUpdateRateLimit(float seconds);
59 60 61 62
    /** @brief Cache visible region to harddisk */
    void cacheVisibleRegion();
    /** @brief Set follow mode */
    void setFollowUAVEnabled(bool enabled) { followUAVEnabled = enabled; }
63

64 65 66
    void loadSettings();
    void storeSettings();

67 68 69 70
protected slots:
    /** @brief Convert a map edit into a QGC waypoint event */
    void handleMapWaypointEdit(WayPointItem* waypoint);

71
protected:
72 73
    /** @brief Update the highlighting of the currently controlled system */
    void updateSelectedSystem(int uas);
74 75 76 77
    /** @brief Initialize */
    void showEvent(QShowEvent* event);
    void hideEvent(QHideEvent* event);
    void mouseDoubleClickEvent(QMouseEvent* event);
78 79 80 81

    UASWaypointManager* currWPManager; ///< The current waypoint manager
    QMap<Waypoint* , mapcontrol::WayPointItem*> waypointsToIcons;
    QMap<mapcontrol::WayPointItem*, Waypoint*> iconsToWaypoints;
82
    Waypoint* firingWaypointChange;
83 84
    QTimer updateTimer;
    float maxUpdateInterval;
85 86 87 88 89 90 91 92 93 94
    enum editMode {
        EDIT_MODE_NONE,
        EDIT_MODE_WAYPOINTS,
        EDIT_MODE_SWEEP,
        EDIT_MODE_UAVS,
        EDIT_MODE_HOME,
        EDIT_MODE_SAFE_AREA,
        EDIT_MODE_CACHING
    };
    editMode currEditMode;            ///< The current edit mode on the map
95 96
    bool followUAVEnabled;              ///< Does the map follow the UAV?
    int followUAVID;                    ///< Which UAV should be tracked?
97

lm's avatar
lm committed
98 99 100 101

};

#endif // QGCMAPWIDGET_H