WaypointList.h 4.92 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 26 27 28 29

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

/**
 * @file
 *   @brief Definition of list of waypoints widget
 *
 *   @author Lorenz Meier <mavteam@student.ethz.ch>
 *   @author Benjamin Knecht <mavteam@student.ethz.ch>
30
 *   @author Petri Tanskanen <mavteam@student.ethz.ch>
pixhawk's avatar
pixhawk committed
31 32 33 34 35 36
 *
 */

#ifndef WAYPOINTLIST_H
#define WAYPOINTLIST_H

37
#include <QWidget>
pixhawk's avatar
pixhawk committed
38 39 40
#include <QMap>
#include <QVBoxLayout>
#include <QTimer>
41
#include "MissionItem.h"
pixhawk's avatar
pixhawk committed
42
#include "UASInterface.h"
43 44
#include "WaypointEditableView.h"
#include "WaypointViewOnlyView.h"
45

46 47 48
namespace Ui
{
class WaypointList;
pixhawk's avatar
pixhawk committed
49 50
}

51 52
class WaypointList : public QWidget
{
pixhawk's avatar
pixhawk committed
53 54
    Q_OBJECT
    Q_DISABLE_COPY(WaypointList)
55
public:
56
    WaypointList(QWidget* parent = NULL, UASWaypointManager* wpm = NULL);
pixhawk's avatar
pixhawk committed
57 58 59
    virtual ~WaypointList();

public slots:
60
    void updatePosition(UASInterface*, double x, double y, double z, quint64 usec);
pixhawk's avatar
pixhawk committed
61 62
    void updateAttitude(UASInterface*, double roll, double pitch, double yaw, quint64 usec);

pixhawk's avatar
pixhawk committed
63
    void setUAS(UASInterface* uas);
pixhawk's avatar
pixhawk committed
64

65
    //MissionItem list operations
pixhawk's avatar
pixhawk committed
66
    /** @brief Save the local waypoint list to a file */
pixhawk's avatar
pixhawk committed
67
    void saveWaypoints();
pixhawk's avatar
pixhawk committed
68
    /** @brief Load a waypoint list from a file */
69
    void loadWaypoints();
pixhawk's avatar
pixhawk committed
70
    /** @brief Transmit the local waypoint list to the UAS */
pixhawk's avatar
pixhawk committed
71
    void transmit();
pixhawk's avatar
pixhawk committed
72
    /** @brief Read the remote waypoint list to both tabs */
73
    void read();
pixhawk's avatar
pixhawk committed
74 75 76
    /** @brief Read the remote waypoint list to "view"-tab only*/
    void refresh();
    /** @brief Add a waypoint to "edit"-tab */
77 78 79
    void addEditable();
    /** @brief Add a waypoint to "edit"-tab on current MAV position or on generic position (home) */
    void addEditable(bool onCurrentPosition);
80
    /** @brief Add a waypoint at the current MAV position */
81
    void addCurrentPositionWaypoint();
82
    /** @brief Add a waypoint by mouse click over the map */
83

pixhawk's avatar
pixhawk committed
84
    //Update events
85 86
    /** @brief sets statusLabel string */
    void updateStatusLabel(const QString &string);
pixhawk's avatar
pixhawk committed
87 88
    /** @brief The user wants to change the current waypoint */
    void changeCurrentWaypoint(quint16 seq);
89 90 91 92 93
    /** @brief Current waypoint in edit-tab was changed, so the list must be updated (to contain only one waypoint checked as "current")  */
    void currentWaypointEditableChanged(quint16 seq);
    /** @brief Current waypoint on UAV was changed, update view-tab  */
    void currentWaypointViewOnlyChanged(quint16 seq);
    /** @brief The waypoint manager informs that one editable waypoint was changed */
94
    void updateWaypointEditable(int uas, MissionItem* wp);
95
    /** @brief The waypoint manager informs that one viewonly waypoint was changed */
96
    void updateWaypointViewOnly(int uas, MissionItem* wp);
pixhawk's avatar
pixhawk committed
97
    /** @brief The waypoint manager informs that the editable waypoint list was changed */
98
    void waypointEditableListChanged(void);
pixhawk's avatar
pixhawk committed
99 100
    /** @brief The waypoint manager informs that the waypoint list on the MAV was changed */
    void waypointViewOnlyListChanged(void);
pixhawk's avatar
pixhawk committed
101

pixhawk's avatar
pixhawk committed
102 103
//    /** @brief The MapWidget informs that a waypoint global was changed on the map */
//    void waypointGlobalChanged(const QPointF coordinate, const int indexWP);
104

105
    void clearWPWidget();
106

107
    //void changeWPPositionBySpinBox(MissionItem* wp);
108

109 110 111 112
    // MissionItem operations
    void moveUp(MissionItem* wp);
    void moveDown(MissionItem* wp);
    void removeWaypoint(MissionItem* wp);
pixhawk's avatar
pixhawk committed
113

pixhawk's avatar
pixhawk committed
114 115
//    void setIsLoadFileWP();
//    void setIsReadGlobalWP(bool value);
116

117

118 119


120
signals:
121 122
    void clearPathclicked();
    void createWaypointAtMap(const QPointF coordinate);
lm's avatar
lm committed
123

pixhawk's avatar
pixhawk committed
124 125
protected:
    virtual void changeEvent(QEvent *e);
pixhawk's avatar
pixhawk committed
126

127
protected:
128 129
    QMap<MissionItem*, WaypointEditableView*> wpEditableViews;
    QMap<MissionItem*, WaypointViewOnlyView*> wpViewOnlyViews;
pixhawk's avatar
pixhawk committed
130 131
    QVBoxLayout* viewOnlyListLayout;
    QVBoxLayout* editableListLayout;
pixhawk's avatar
pixhawk committed
132
    UASInterface* uas;
133
    UASWaypointManager* WPM;
134 135 136 137
    double mavX;
    double mavY;
    double mavZ;
    double mavYaw;
138
    QPointF centerMapCoordinate;
139
    bool loadFileGlobalWP;
140
    bool readGlobalWP;
141
    bool showOfflineWarning;
pixhawk's avatar
pixhawk committed
142 143 144

private:
    Ui::WaypointList *m_ui;
145 146 147 148 149 150 151





private slots:
    void on_clearWPListButton_clicked();
152

pixhawk's avatar
pixhawk committed
153 154 155
};

#endif // WAYPOINTLIST_H