Commit 15b2bde0 authored by Gus Grubba's avatar Gus Grubba

WIP: Create polygon instead of lineString for flight plan

Remove delete flights and add "End" active flight instead
Work on flight geometry (flight list)
parent 845e8068
This diff is collapsed.
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include <QGeoCoordinate> #include <QGeoCoordinate>
#include "airmap/flight.h" #include "airmap/flight.h"
#include "airmap/flight_plan.h"
class PlanMasterController; class PlanMasterController;
...@@ -49,11 +50,14 @@ public: ...@@ -49,11 +50,14 @@ public:
QString createdTime () override; QString createdTime () override;
QString startTime () override; QString startTime () override;
QString endTime () override; QString endTime () override;
QDateTime qStartTime () override;
QGeoCoordinate takeOff () override { return QGeoCoordinate(_flight.latitude, _flight.longitude);} QGeoCoordinate takeOff () override { return QGeoCoordinate(_flight.latitude, _flight.longitude);}
QmlObjectListModel* boundingBox () override { return &_boundingBox; } QVariantList boundingBox () override { return _boundingBox; }
bool active () override;
void setEndFlight (airmap::DateTime end);
private: private:
airmap::Flight _flight; airmap::Flight _flight;
QmlObjectListModel _boundingBox; QVariantList _boundingBox;
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
...@@ -66,8 +70,8 @@ public: ...@@ -66,8 +70,8 @@ public:
~AirMapFlightPlanManager (); ~AirMapFlightPlanManager ();
PermitStatus flightPermitStatus () const override { return _flightPermitStatus; } PermitStatus flightPermitStatus () const override { return _flightPermitStatus; }
QDateTime flightStartTime () const override { return _flightStartTime; } QDateTime flightStartTime () const override;
QDateTime flightEndTime () const override { return _flightEndTime; } QDateTime flightEndTime () const override;
bool valid () override { return _valid; } bool valid () override { return _valid; }
QmlObjectListModel* advisories () override { return &_advisories; } QmlObjectListModel* advisories () override { return &_advisories; }
QmlObjectListModel* ruleSets () override { return &_rulesets; } QmlObjectListModel* ruleSets () override { return &_rulesets; }
...@@ -84,6 +88,7 @@ public: ...@@ -84,6 +88,7 @@ public:
QmlObjectListModel* authorizations () override { return &_authorizations; } QmlObjectListModel* authorizations () override { return &_authorizations; }
AirspaceFlightModel*flightList () override { return &_flightList; } AirspaceFlightModel*flightList () override { return &_flightList; }
bool loadingFlightList () override { return _loadingFlightList; } bool loadingFlightList () override { return _loadingFlightList; }
QString flightPlanID () {return QString::fromStdString(_flightPlan.id); }
void updateFlightPlan () override; void updateFlightPlan () override;
void submitFlightPlan () override; void submitFlightPlan () override;
...@@ -91,9 +96,7 @@ public: ...@@ -91,9 +96,7 @@ public:
void setFlightStartTime (QDateTime start) override; void setFlightStartTime (QDateTime start) override;
void setFlightEndTime (QDateTime end) override; void setFlightEndTime (QDateTime end) override;
void loadFlightList (QDateTime startTime, QDateTime endTime) override; void loadFlightList (QDateTime startTime, QDateTime endTime) override;
void deleteFlight (QString flightID) override; void endFlight (QString flightID) override;
void deleteSelectedFlights() override;
signals: signals:
void error (const QString& what, const QString& airmapdMessage, const QString& airmapdDetails); void error (const QString& what, const QString& airmapdMessage, const QString& airmapdDetails);
...@@ -101,7 +104,7 @@ signals: ...@@ -101,7 +104,7 @@ signals:
private slots: private slots:
void _pollBriefing (); void _pollBriefing ();
void _missionChanged (); void _missionChanged ();
void _deleteFlight (); void _endFlight ();
void _uploadFlightPlan (); void _uploadFlightPlan ();
void _updateFlightPlan (); void _updateFlightPlan ();
void _loadFlightList (); void _loadFlightList ();
...@@ -116,7 +119,7 @@ private: ...@@ -116,7 +119,7 @@ private:
GetPilotID, GetPilotID,
FlightUpload, FlightUpload,
FlightUpdate, FlightUpdate,
FlightDelete, FlightEnd,
FlightSubmit, FlightSubmit,
FlightPolling, FlightPolling,
LoadFlightList, LoadFlightList,
...@@ -138,15 +141,12 @@ private: ...@@ -138,15 +141,12 @@ private:
State _state = State::Idle; State _state = State::Idle;
AirMapSharedState& _shared; AirMapSharedState& _shared;
QTimer _pollTimer; ///< timer to poll for approval check QTimer _pollTimer; ///< timer to poll for approval check
QString _flightPlan; ///< Current flight plan
QString _flightId; ///< Current flight ID, not necessarily accepted yet QString _flightId; ///< Current flight ID, not necessarily accepted yet
QString _pilotID; ///< Pilot ID in the form "auth0|abc123" QString _pilotID; ///< Pilot ID in the form "auth0|abc123"
QStringList _flightsToDelete; QString _flightToEnd;
PlanMasterController* _planController = nullptr; PlanMasterController* _planController = nullptr;
bool _valid = false; bool _valid = false;
bool _loadingFlightList = false; bool _loadingFlightList = false;
QDateTime _flightStartTime;
QDateTime _flightEndTime;
QmlObjectListModel _advisories; QmlObjectListModel _advisories;
QmlObjectListModel _rulesets; QmlObjectListModel _rulesets;
QmlObjectListModel _rulesViolation; QmlObjectListModel _rulesViolation;
...@@ -158,6 +158,7 @@ private: ...@@ -158,6 +158,7 @@ private:
AirspaceFlightModel _flightList; AirspaceFlightModel _flightList;
QDateTime _rangeStart; QDateTime _rangeStart;
QDateTime _rangeEnd; QDateTime _rangeEnd;
airmap::FlightPlan _flightPlan;
AirspaceAdvisoryProvider::AdvisoryColor _airspaceColor; AirspaceAdvisoryProvider::AdvisoryColor _airspaceColor;
AirspaceFlightPlanProvider::PermitStatus _flightPermitStatus = AirspaceFlightPlanProvider::PermitNone; AirspaceFlightPlanProvider::PermitStatus _flightPermitStatus = AirspaceFlightPlanProvider::PermitNone;
......
...@@ -294,18 +294,6 @@ QGCView { ...@@ -294,18 +294,6 @@ QGCView {
onPressed: { mouse.accepted = true; } onPressed: { mouse.accepted = true; }
onReleased: { mouse.accepted = true; } onReleased: { mouse.accepted = true; }
} }
function updateSelection() {
//-- Clear selection
for(var i = 0; i < _flightList.count; i++) {
var o = _flightList.get(i)
if (o) o.selected = false
}
//-- Flag selected flights
tableView.selection.forEach(function(rowIndex){
var o = _flightList.get(rowIndex)
if (o) o.selected = true
})
}
//--------------------------------------------------------- //---------------------------------------------------------
//-- Flight List //-- Flight List
RowLayout { RowLayout {
...@@ -315,8 +303,19 @@ QGCView { ...@@ -315,8 +303,19 @@ QGCView {
anchors.top: parent.top anchors.top: parent.top
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
model: _flightList model: _flightList
selectionMode: SelectionMode.MultiSelection selectionMode: SelectionMode.SingleSelection
Layout.fillWidth: true Layout.fillWidth: true
onCurrentRowChanged: {
map.fitViewportToMapItems()
var o = _flightList.get(tableView.currentRow)
if(o) {
console.log(o.boundingBox.count)
console.log(o.boundingBox)
console.log(o.flightID)
} else {
console.log('No bounding box')
}
}
TableViewColumn { TableViewColumn {
title: qsTr("No") title: qsTr("No")
width: ScreenTools.defaultFontPixelWidth * 3 width: ScreenTools.defaultFontPixelWidth * 3
...@@ -331,7 +330,7 @@ QGCView { ...@@ -331,7 +330,7 @@ QGCView {
} }
TableViewColumn { TableViewColumn {
title: qsTr("Created") title: qsTr("Created")
width: ScreenTools.defaultFontPixelWidth * 20 width: ScreenTools.defaultFontPixelWidth * 18
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
delegate : Text { delegate : Text {
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
...@@ -346,7 +345,7 @@ QGCView { ...@@ -346,7 +345,7 @@ QGCView {
} }
TableViewColumn { TableViewColumn {
title: qsTr("Flight Start") title: qsTr("Flight Start")
width: ScreenTools.defaultFontPixelWidth * 20 width: ScreenTools.defaultFontPixelWidth * 18
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
delegate : Text { delegate : Text {
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
...@@ -359,15 +358,30 @@ QGCView { ...@@ -359,15 +358,30 @@ QGCView {
font.pixelSize: ScreenTools.smallFontPointSize font.pixelSize: ScreenTools.smallFontPointSize
} }
} }
TableViewColumn {
title: qsTr("Flight End")
width: ScreenTools.defaultFontPixelWidth * 18
horizontalAlignment: Text.AlignHCenter
delegate : Text {
horizontalAlignment: Text.AlignHCenter
text: {
var o = _flightList.get(styleData.row)
return o ? o.endTime : ""
}
color: tableView.currentRow === styleData.row ? qgcPal.colorBlue : "black"
font.family: ScreenTools.fixedFontFamily
font.pixelSize: ScreenTools.smallFontPointSize
}
}
TableViewColumn { TableViewColumn {
title: qsTr("State") title: qsTr("State")
width: ScreenTools.defaultFontPixelWidth * 22 width: ScreenTools.defaultFontPixelWidth * 8
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
delegate : Text { delegate : Text {
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
text: { text: {
var o = _flightList.get(styleData.row) var o = _flightList.get(styleData.row)
return o ? (o.beingDeleted ? qsTr("Deleting") : qsTr("Valid")) : qsTr("Unknown") return o ? (o.active ? qsTr("Active") : qsTr("Completed")) : qsTr("Unknown")
} }
color: tableView.currentRow === styleData.row ? qgcPal.colorBlue : "black" color: tableView.currentRow === styleData.row ? qgcPal.colorBlue : "black"
font.family: ScreenTools.fixedFontFamily font.family: ScreenTools.fixedFontFamily
...@@ -491,40 +505,21 @@ QGCView { ...@@ -491,40 +505,21 @@ QGCView {
} }
} }
QGCButton { QGCButton {
text: qsTr("Select All") text: qsTr("End Selected")
backRadius: 4
heightFactor: 0.3333
showBorder: true
width: _buttonWidth
enabled: _flightList.count > 0
anchors.horizontalCenter: parent.horizontalCenter
onClicked: {
tableView.selection.selectAll()
}
}
QGCButton {
text: qsTr("Select None")
backRadius: 4 backRadius: 4
heightFactor: 0.3333 heightFactor: 0.3333
showBorder: true showBorder: true
width: _buttonWidth width: _buttonWidth
enabled: _flightList.count > 0 enabled: {
anchors.horizontalCenter: parent.horizontalCenter var o = _flightList.get(tableView.currentRow)
onClicked: { return o && o.active
tableView.selection.clear()
} }
}
QGCButton {
text: qsTr("Delete Selected")
backRadius: 4
heightFactor: 0.3333
showBorder: true
width: _buttonWidth
enabled: tableView.selection.count > 0
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
onClicked: { onClicked: {
flightListRoot.updateSelection(); var o = _flightList.get(tableView.currentRow)
QGroundControl.airspaceManager.flightPlan.deleteSelectedFlights() if(o) {
QGroundControl.airspaceManager.flightPlan.endFlight(o.flightID)
}
} }
} }
QGCButton { QGCButton {
...@@ -539,7 +534,7 @@ QGCView { ...@@ -539,7 +534,7 @@ QGCView {
} }
} }
QGCLabel { QGCLabel {
text: _flightList.count > 0 ? tableView.selection.count + '/' + _flightList.count + qsTr(" Flights Selected") : qsTr("No Flights Loaded") text: _flightList.count > 0 ? _flightList.count + qsTr(" Flights Loaded") : qsTr("No Flights Loaded")
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
} }
QGCLabel { QGCLabel {
...@@ -578,6 +573,20 @@ QGCView { ...@@ -578,6 +573,20 @@ QGCView {
} }
} }
} }
MapItemView {
model: {
var o = _flightList.get(tableView.currentRow)
if(o) {
return o.boundingBox
}
return []
}
delegate: MapPolygon {
path: object
color: Qt.rgba(1,0,0,0.2)
border.color: Qt.rgba(1,1,1,0.65)
}
}
Component.onCompleted: { Component.onCompleted: {
updateActiveMapType() updateActiveMapType()
} }
......
...@@ -20,8 +20,6 @@ AirspaceFlightAuthorization::AirspaceFlightAuthorization(QObject *parent) ...@@ -20,8 +20,6 @@ AirspaceFlightAuthorization::AirspaceFlightAuthorization(QObject *parent)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
AirspaceFlightInfo::AirspaceFlightInfo(QObject *parent) AirspaceFlightInfo::AirspaceFlightInfo(QObject *parent)
: QObject(parent) : QObject(parent)
, _beingDeleted(false)
, _selected(false)
{ {
} }
...@@ -50,10 +48,10 @@ AirspaceFlightModel::get(int index) ...@@ -50,10 +48,10 @@ AirspaceFlightModel::get(int index)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
int int
AirspaceFlightModel::findFlightPlanID(QString flightPlanID) AirspaceFlightModel::findFlightID(QString flightID)
{ {
for(int i = 0; i < _flightEntries.count(); i++) { for(int i = 0; i < _flightEntries.count(); i++) {
if(_flightEntries[i]->flightPlanID() == flightPlanID) { if(_flightEntries[i]->flightID() == flightID) {
return i; return i;
} }
} }
...@@ -80,9 +78,9 @@ AirspaceFlightModel::append(AirspaceFlightInfo* object) ...@@ -80,9 +78,9 @@ AirspaceFlightModel::append(AirspaceFlightInfo* object)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void void
AirspaceFlightModel::remove(const QString& flightPlanID) AirspaceFlightModel::remove(const QString& flightID)
{ {
remove(findFlightPlanID(flightPlanID)); remove(findFlightID(flightID));
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
...@@ -118,6 +116,26 @@ AirspaceFlightModel::clear(void) ...@@ -118,6 +116,26 @@ AirspaceFlightModel::clear(void)
} }
} }
//-----------------------------------------------------------------------------
static bool
flight_sort(QObject* a, QObject* b)
{
AirspaceFlightInfo* aa = qobject_cast<AirspaceFlightInfo*>(a);
AirspaceFlightInfo* bb = qobject_cast<AirspaceFlightInfo*>(b);
if(!aa || !bb) return false;
return aa->qStartTime() > bb->qStartTime();
}
//-----------------------------------------------------------------------------
void
AirspaceFlightModel::sortStartFlight()
{
beginResetModel();
std::sort(_flightEntries.begin(), _flightEntries.end(), flight_sort);
endResetModel();
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
AirspaceFlightInfo* AirspaceFlightInfo*
AirspaceFlightModel::operator[](int index) AirspaceFlightModel::operator[](int index)
......
...@@ -68,30 +68,21 @@ public: ...@@ -68,30 +68,21 @@ public:
Q_PROPERTY(QString startTime READ startTime CONSTANT) Q_PROPERTY(QString startTime READ startTime CONSTANT)
Q_PROPERTY(QString endTime READ endTime CONSTANT) Q_PROPERTY(QString endTime READ endTime CONSTANT)
Q_PROPERTY(QGeoCoordinate takeOff READ takeOff CONSTANT) Q_PROPERTY(QGeoCoordinate takeOff READ takeOff CONSTANT)
Q_PROPERTY(QmlObjectListModel* boundingBox READ boundingBox CONSTANT) Q_PROPERTY(QVariantList boundingBox READ boundingBox CONSTANT)
Q_PROPERTY(bool beingDeleted READ beingDeleted WRITE setBeingDeleted NOTIFY beingDeletedChanged) Q_PROPERTY(bool active READ active NOTIFY activeChanged)
Q_PROPERTY(bool selected READ selected WRITE setSelected NOTIFY selectedChanged)
virtual QString flightID () = 0; virtual QString flightID () = 0;
virtual QString flightPlanID () = 0; virtual QString flightPlanID () = 0;
virtual QString createdTime () = 0; virtual QString createdTime () = 0;
virtual QString startTime () = 0; virtual QString startTime () = 0;
virtual QDateTime qStartTime () = 0;
virtual QString endTime () = 0; virtual QString endTime () = 0;
virtual QGeoCoordinate takeOff () = 0; virtual QGeoCoordinate takeOff () = 0;
virtual QmlObjectListModel* boundingBox () = 0; virtual QVariantList boundingBox () = 0;
virtual bool active () = 0;
virtual bool beingDeleted () { return _beingDeleted; }
virtual void setBeingDeleted (bool val) { _beingDeleted = val; emit beingDeletedChanged(); }
virtual bool selected () { return _selected; }
virtual void setSelected (bool sel) { _selected = sel; emit selectedChanged(); }
signals: signals:
void selectedChanged (); void activeChanged ();
void beingDeletedChanged ();
protected:
bool _beingDeleted;
bool _selected;
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
...@@ -109,13 +100,14 @@ public: ...@@ -109,13 +100,14 @@ public:
Q_PROPERTY(int count READ count NOTIFY countChanged) Q_PROPERTY(int count READ count NOTIFY countChanged)
Q_INVOKABLE AirspaceFlightInfo* get (int index); Q_INVOKABLE AirspaceFlightInfo* get (int index);
Q_INVOKABLE int findFlightPlanID (QString flightPlanID); Q_INVOKABLE int findFlightID (QString flightID);
int count (void) const; int count () const;
void append (AirspaceFlightInfo *entry); void append (AirspaceFlightInfo *entry);
void remove (const QString& flightPlanID); void remove (const QString& flightID);
void remove (int index); void remove (int index);
void clear (void); void clear ();
void sortStartFlight ();
AirspaceFlightInfo* AirspaceFlightInfo*
operator[] (int i); operator[] (int i);
...@@ -175,8 +167,7 @@ public: ...@@ -175,8 +167,7 @@ public:
Q_INVOKABLE virtual void submitFlightPlan () = 0; Q_INVOKABLE virtual void submitFlightPlan () = 0;
Q_INVOKABLE virtual void updateFlightPlan () = 0; Q_INVOKABLE virtual void updateFlightPlan () = 0;
Q_INVOKABLE virtual void loadFlightList (QDateTime startTime, QDateTime endTime) = 0; Q_INVOKABLE virtual void loadFlightList (QDateTime startTime, QDateTime endTime) = 0;
Q_INVOKABLE virtual void deleteFlight (QString flighPlanID) = 0; Q_INVOKABLE virtual void endFlight (QString flighID) = 0;
Q_INVOKABLE virtual void deleteSelectedFlights () = 0;
virtual PermitStatus flightPermitStatus () const { return PermitNone; } virtual PermitStatus flightPermitStatus () const { return PermitNone; }
virtual QDateTime flightStartTime () const = 0; virtual QDateTime flightStartTime () const = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment