Commit 87ae0874 authored by Valentin Platzgummer's avatar Valentin Platzgummer

befor editing WimaView.qml (allow only one masterController)

parent 8f6a4a95
...@@ -127,6 +127,8 @@ void WimaArea::join(WimaArea &poly1, WimaArea &poly2, WimaArea &joinedPoly) ...@@ -127,6 +127,8 @@ void WimaArea::join(WimaArea &poly1, WimaArea &poly2, WimaArea &joinedPoly)
if (poly1.count() >= 3 && poly2.count() >= 3) { if (poly1.count() >= 3 && poly2.count() >= 3) {
joinedPoly.clear();
poly1.verifyClockwiseWinding(); poly1.verifyClockwiseWinding();
poly2.verifyClockwiseWinding(); poly2.verifyClockwiseWinding();
......
...@@ -45,7 +45,14 @@ void WimaController::setCurrentPolygonIndex(int index) ...@@ -45,7 +45,14 @@ void WimaController::setCurrentPolygonIndex(int index)
void WimaController::removeArea(int index) void WimaController::removeArea(int index)
{ {
if(index >= 0 && index < _visualItems->count()){ if(index >= 0 && index < _visualItems->count()){
_visualItems->removeAt(index); WimaArea* area = qobject_cast<WimaArea*>(_visualItems->removeAt(index));
if ( area == nullptr) {
qWarning("WimaController::removeArea(): nullptr catched, internal error.");
return;
}
disconnect(area, &WimaArea::pathChanged, this, &WimaController::updateJoinedArea);
emit visualItemsChanged(); emit visualItemsChanged();
...@@ -67,41 +74,88 @@ void WimaController::removeArea(int index) ...@@ -67,41 +74,88 @@ void WimaController::removeArea(int index)
} }
void WimaController::addGOperationArea() bool WimaController::addGOperationArea()
{ {
WimaGOperationArea* newPoly = new WimaGOperationArea(this); // check if opArea exists already
_visualItems->append(newPoly); WimaGOperationArea* opArea = nullptr;
for (int i = 0; i < _visualItems->count(); i++) {
WimaGOperationArea* currentArea = qobject_cast<WimaGOperationArea*>(_visualItems->get(i));
if ( currentArea != nullptr ) {
opArea = currentArea;
return false;
}
}
// create one if no opArea available
opArea = new WimaGOperationArea(this);
connect(opArea, &WimaArea::pathChanged, this, &WimaController::updateJoinedArea);
_visualItems->append(opArea);
int newIndex = _visualItems->count()-1; int newIndex = _visualItems->count()-1;
setCurrentPolygonIndex(newIndex); setCurrentPolygonIndex(newIndex);
emit visualItemsChanged(); emit visualItemsChanged();
return true;
} }
void WimaController::addServiceArea() bool WimaController::addServiceArea()
{ {
WimaServiceArea* newPoly = new WimaServiceArea(this); // check if serArea exists already
_visualItems->append(newPoly); WimaServiceArea* serArea = nullptr;
for (int i = 0; i < _visualItems->count(); i++) {
WimaServiceArea* currentArea = qobject_cast<WimaServiceArea*>(_visualItems->get(i));
if ( currentArea != nullptr ) {
serArea = currentArea;
return false;
}
}
// create one if no serArea available
serArea = new WimaServiceArea(this);
connect(serArea, &WimaArea::pathChanged, this, &WimaController::updateJoinedArea);
_visualItems->append(serArea);
int newIndex = _visualItems->count()-1; int newIndex = _visualItems->count()-1;
setCurrentPolygonIndex(newIndex); setCurrentPolygonIndex(newIndex);
emit visualItemsChanged(); emit visualItemsChanged();
return true;
} }
void WimaController::addVehicleCorridor() bool WimaController::addVehicleCorridor()
{ {
WimaVCorridor* corridor = new WimaVCorridor(this); // check if corridor exists already
WimaVCorridor* corridor = nullptr;
for (int i = 0; i < _visualItems->count(); i++) {
WimaVCorridor* currentArea = qobject_cast<WimaVCorridor*>(_visualItems->get(i));
if ( currentArea != nullptr ) {
corridor = currentArea;
return false;
}
}
// create one if no corridor available
corridor = new WimaVCorridor(this);
connect(corridor, &WimaArea::pathChanged, this, &WimaController::updateJoinedArea);
_visualItems->append(corridor); _visualItems->append(corridor);
int newIndex = _visualItems->count()-1; int newIndex = _visualItems->count()-1;
setCurrentPolygonIndex(newIndex); setCurrentPolygonIndex(newIndex);
emit visualItemsChanged(); emit visualItemsChanged();
return true;
} }
void WimaController::removeAllAreas() void WimaController::removeAll()
{ {
bool changesApplied = false; bool changesApplied = false;
while (_visualItems->count() > 0) { while (_visualItems->count() > 0) {
_visualItems->removeAt(0); removeArea(0);
changesApplied = true; changesApplied = true;
} }
_missionController->removeAll();
_currentFile = ""; _currentFile = "";
emit currentFileChanged(); emit currentFileChanged();
...@@ -165,14 +219,7 @@ bool WimaController::updateMission() ...@@ -165,14 +219,7 @@ bool WimaController::updateMission()
break; break;
} }
} }
// join service area and op area
WimaArea joinedArea;
if (corridor != nullptr) {
WimaArea::join(*corridor, *serArea, joinedArea);
joinedArea.join(*opArea);
} else {
WimaArea::join(*serArea, *opArea, joinedArea);
}
#if debug #if debug
WimaArea* joinedAreaPt = new WimaArea(joinedArea, this); WimaArea* joinedAreaPt = new WimaArea(joinedArea, this);
...@@ -180,10 +227,23 @@ bool WimaController::updateMission() ...@@ -180,10 +227,23 @@ bool WimaController::updateMission()
#endif #endif
// extract survey if present
QmlObjectListModel* missionItems = _missionController->visualItems();
SurveyComplexItem* oldSurveyItem;
{
int i = 0;
while( i < missionItems->count() ) {
oldSurveyItem = qobject_cast<SurveyComplexItem*>(missionItems->get(i));
if (oldSurveyItem != nullptr){
break;
}
i++;
}
}
// reset visual items // reset visual items
_missionController->removeAll(); _missionController->removeAll();
QmlObjectListModel* missionItems = _missionController->visualItems(); missionItems = _missionController->visualItems();
// set home position to serArea center // set home position to serArea center
MissionSettingsItem* settingsItem= qobject_cast<MissionSettingsItem*>(missionItems->get(0)); MissionSettingsItem* settingsItem= qobject_cast<MissionSettingsItem*>(missionItems->get(0));
if (settingsItem == nullptr){ if (settingsItem == nullptr){
...@@ -205,13 +265,14 @@ bool WimaController::updateMission() ...@@ -205,13 +265,14 @@ bool WimaController::updateMission()
} else { } else {
survey->surveyAreaPolygon()->clear(); survey->surveyAreaPolygon()->clear();
survey->surveyAreaPolygon()->appendVertices(opArea->coordinateList()); survey->surveyAreaPolygon()->appendVertices(opArea->coordinateList());
//survey->
} }
// calculate path from take off to opArea // calculate path from take off to opArea
QGeoCoordinate start = serArea->center(); QGeoCoordinate start = serArea->center();
QGeoCoordinate end = survey->visualTransectPoints().first().value<QGeoCoordinate>(); QGeoCoordinate end = survey->visualTransectPoints().first().value<QGeoCoordinate>();
QList<QGeoCoordinate> path; QList<QGeoCoordinate> path;
WimaArea::dijkstraPath(start, end, joinedArea, path); WimaArea::dijkstraPath(start, end, _joinedArea, path);
for (int i = 1; i < path.count()-1; i++) { for (int i = 1; i < path.count()-1; i++) {
_missionController->insertSimpleMissionItem(path.value(i), i+1); _missionController->insertSimpleMissionItem(path.value(i), i+1);
index++; index++;
...@@ -221,7 +282,7 @@ bool WimaController::updateMission() ...@@ -221,7 +282,7 @@ bool WimaController::updateMission()
start = survey->visualTransectPoints().last().value<QGeoCoordinate>(); start = survey->visualTransectPoints().last().value<QGeoCoordinate>();
end = serArea->center(); end = serArea->center();
path.clear(); path.clear();
WimaArea::dijkstraPath(start, end, joinedArea, path); WimaArea::dijkstraPath(start, end, _joinedArea, path);
for (int i = 1; i < path.count()-1; i++) { for (int i = 1; i < path.count()-1; i++) {
_missionController->insertSimpleMissionItem(path.value(i), index++); _missionController->insertSimpleMissionItem(path.value(i), index++);
} }
...@@ -240,9 +301,6 @@ bool WimaController::updateMission() ...@@ -240,9 +301,6 @@ bool WimaController::updateMission()
} }
} }
//saveToFile("TestFile.wima");
//loadFromFile("TestFile.wima");
return true; return true;
} }
...@@ -376,6 +434,7 @@ bool WimaController::loadFromFile(const QString &filename) ...@@ -376,6 +434,7 @@ bool WimaController::loadFromFile(const QString &filename)
_currentFile.sprintf("%s/%s.%s", fileInfo.path().toLocal8Bit().data(), fileInfo.completeBaseName().toLocal8Bit().data(), wimaFileExtension); _currentFile.sprintf("%s/%s.%s", fileInfo.path().toLocal8Bit().data(), fileInfo.completeBaseName().toLocal8Bit().data(), wimaFileExtension);
emit currentFileChanged(); emit currentFileChanged();
updateJoinedArea();
return true; return true;
...@@ -410,6 +469,51 @@ void WimaController::recalcPolygonInteractivity(int index) ...@@ -410,6 +469,51 @@ void WimaController::recalcPolygonInteractivity(int index)
} }
} }
void WimaController::updateJoinedArea()
{
// pick first WimaGOperationArea
WimaGOperationArea* opArea = nullptr;
for (int i = 0; i < _visualItems->count(); i++) {
WimaGOperationArea* currentArea = qobject_cast<WimaGOperationArea*>(_visualItems->get(i));
if (currentArea != nullptr){
opArea = currentArea;
break;
}
}
if (opArea == nullptr)
return;
// pick first WimaServiceArea
WimaServiceArea* serArea = nullptr;
for (int i = 0; i < _visualItems->count(); i++) {
WimaServiceArea* currentArea = qobject_cast<WimaServiceArea*>(_visualItems->get(i));
if (currentArea != nullptr){
serArea = currentArea;
break;
}
}
if ( serArea == nullptr )
return;
// pick first WimaVCorridor
WimaVCorridor* corridor = nullptr;
for (int i = 0; i < _visualItems->count(); i++) {
WimaVCorridor* currentArea = qobject_cast<WimaVCorridor*>(_visualItems->get(i));
if (currentArea != nullptr){
corridor = currentArea;
break;
}
}
// join service area, op area and corridor
if (corridor != nullptr) {
WimaArea::join(*corridor, *serArea, _joinedArea);
_joinedArea.join(*opArea);
} else {
WimaArea::join(*serArea, *opArea, _joinedArea);
}
}
void WimaController::resetAllInteractive() void WimaController::resetAllInteractive()
{ {
int itemCount = _visualItems->count(); int itemCount = _visualItems->count();
......
...@@ -33,6 +33,7 @@ public: ...@@ -33,6 +33,7 @@ public:
Q_PROPERTY(QString currentFile READ currentFile NOTIFY currentFileChanged) Q_PROPERTY(QString currentFile READ currentFile NOTIFY currentFileChanged)
Q_PROPERTY(QStringList loadNameFilters READ loadNameFilters CONSTANT) Q_PROPERTY(QStringList loadNameFilters READ loadNameFilters CONSTANT)
Q_PROPERTY(QString fileExtension READ fileExtension CONSTANT) Q_PROPERTY(QString fileExtension READ fileExtension CONSTANT)
Q_PROPERTY(QGeoCoordinate joinedAreaCenter READ joinedAreaCenter CONSTANT)
// Property accessors // Property accessors
...@@ -42,7 +43,8 @@ public: ...@@ -42,7 +43,8 @@ public:
int currentPolygonIndex (void) const { return _currentPolygonIndex; } int currentPolygonIndex (void) const { return _currentPolygonIndex; }
QString currentFile (void) const { return _currentFile; } QString currentFile (void) const { return _currentFile; }
QStringList loadNameFilters (void) const; QStringList loadNameFilters (void) const;
QString fileExtension (void) const { return wimaFileExtension; } QString fileExtension (void) const { return wimaFileExtension; }
QGeoCoordinate joinedAreaCenter (void) const { return _joinedArea.center(); }
...@@ -52,14 +54,13 @@ public: ...@@ -52,14 +54,13 @@ public:
/// Sets the integer index pointing to the current polygon. Current polygon is set interactive. /// Sets the integer index pointing to the current polygon. Current polygon is set interactive.
void setCurrentPolygonIndex (int index); void setCurrentPolygonIndex (int index);
Q_INVOKABLE void addGOperationArea(); Q_INVOKABLE bool addGOperationArea();
/// Removes an area from _visualItems /// Removes an area from _visualItems
/// @param index Index of the area to be removed /// @param index Index of the area to be removed
Q_INVOKABLE void removeArea(int index); Q_INVOKABLE void removeArea(int index);
Q_INVOKABLE void addServiceArea(); Q_INVOKABLE bool addServiceArea();
/// @return true if a vehicle corridor was added sucessfully and false otherwise. Q_INVOKABLE bool addVehicleCorridor();
Q_INVOKABLE void addVehicleCorridor(); Q_INVOKABLE void removeAll();
Q_INVOKABLE void removeAllAreas();
Q_INVOKABLE void startMission(); Q_INVOKABLE void startMission();
Q_INVOKABLE void abortMission(); Q_INVOKABLE void abortMission();
...@@ -97,11 +98,13 @@ private slots: ...@@ -97,11 +98,13 @@ private slots:
void recalcVehicleMeasurementAreas(); void recalcVehicleMeasurementAreas();
void recalcAll(); void recalcAll();
void recalcPolygonInteractivity(int index); void recalcPolygonInteractivity(int index);
void updateJoinedArea();
private: private:
bool _planView; bool _planView;
QmlObjectListModel* _visualItems; QmlObjectListModel* _visualItems;
WimaArea _joinedArea;
PlanMasterController* _masterController; PlanMasterController* _masterController;
MissionController* _missionController; MissionController* _missionController;
int _currentPolygonIndex; int _currentPolygonIndex;
......
...@@ -21,7 +21,7 @@ Rectangle { ...@@ -21,7 +21,7 @@ Rectangle {
visible: false visible: false
anchors.bottomMargin: 1 anchors.bottomMargin: 1
signal showFlyView signal showWimaFlightView
property var planMasterController property var planMasterController
property var currentMissionItem ///< Mission item to display status for property var currentMissionItem ///< Mission item to display status for
...@@ -100,12 +100,12 @@ Rectangle { ...@@ -100,12 +100,12 @@ Rectangle {
id: settingsButton id: settingsButton
anchors.top: parent.top anchors.top: parent.top
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
source: "/qmlimages/PaperPlane.svg" source: "/qmlimages/TelemRSSI.svg"
logo: true logo: true
checked: false checked: false
onClicked: { onClicked: {
checked = false checked = false
showFlyView() showWimaFlightView()
} }
} }
} }
......
This diff is collapsed.
...@@ -33,7 +33,7 @@ Item { ...@@ -33,7 +33,7 @@ Item {
property var activeVehicle: QGroundControl.multiVehicleManager.activeVehicle property var activeVehicle: QGroundControl.multiVehicleManager.activeVehicle
property string formatedMessage: activeVehicle ? activeVehicle.formatedMessage : "" property string formatedMessage: activeVehicle ? activeVehicle.formatedMessage : ""
property var _viewList: [ settingsViewLoader, setupViewLoader, planViewLoader, wimaViewLoader, flightView, analyzeViewLoader ] property var _viewList: [ settingsViewLoader, setupViewLoader, planViewLoader, wimaViewLoader, wimaFlightView, flightView, analyzeViewLoader ]
readonly property string _settingsViewSource: "AppSettings.qml" readonly property string _settingsViewSource: "AppSettings.qml"
readonly property string _setupViewSource: "SetupView.qml" readonly property string _setupViewSource: "SetupView.qml"
...@@ -125,6 +125,18 @@ Item { ...@@ -125,6 +125,18 @@ Item {
wimaToolBar.visible = true wimaToolBar.visible = true
} }
function showWimaFlightView() {
mainWindow.enableToolbar()
rootLoader.sourceComponent = null
if(currentPopUp) {
currentPopUp.close()
}
ScreenTools.availableHeight = parent.height - toolBar.height
hideAllViews()
wimaFlightView.visible = true
toolBar.checkWimaFlyButton()
}
function showFlyView() { function showFlyView() {
mainWindow.enableToolbar() mainWindow.enableToolbar()
rootLoader.sourceComponent = null rootLoader.sourceComponent = null
...@@ -301,7 +313,7 @@ Item { ...@@ -301,7 +313,7 @@ Item {
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
anchors.top: parent.top anchors.top: parent.top
opacity: planToolBar.visible ? 0 : 1 opacity: planToolBar.visible || wimaToolBar.visible ? 0 : 1
z: QGroundControl.zOrderTopMost z: QGroundControl.zOrderTopMost
Component.onCompleted: ScreenTools.availableHeight = parent.height - toolBar.height Component.onCompleted: ScreenTools.availableHeight = parent.height - toolBar.height
...@@ -311,6 +323,7 @@ Item { ...@@ -311,6 +323,7 @@ Item {
onShowPlanView: mainWindow.showPlanView() onShowPlanView: mainWindow.showPlanView()
onShowWimaView: mainWindow.showWimaView() onShowWimaView: mainWindow.showWimaView()
onShowAnalyzeView: mainWindow.showAnalyzeView() onShowAnalyzeView: mainWindow.showAnalyzeView()
onShowWimaFlightView: mainWindow.showWimaFlightView()
onArmVehicle: flightView.guidedController.confirmAction(flightView.guidedController.actionArm) onArmVehicle: flightView.guidedController.confirmAction(flightView.guidedController.actionArm)
onDisarmVehicle: { onDisarmVehicle: {
if (flightView.guidedController.showEmergenyStop) { if (flightView.guidedController.showEmergenyStop) {
...@@ -330,22 +343,22 @@ Item { ...@@ -330,22 +343,22 @@ Item {
} }
} }
PlanToolBar { WimaToolBar {
id: planToolBar id: wimaToolBar
height: ScreenTools.toolbarHeight height: ScreenTools.toolbarHeight
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
anchors.top: parent.top anchors.top: parent.top
z: toolBar.z + 1 z: toolBar.z + 1
onShowFlyView: { onShowWimaFlightView: {
planToolBar.visible = false wimaToolBar.visible = false
mainWindow.showFlyView() mainWindow.showWimaFlightView()
} }
} }
WimaToolBar { PlanToolBar {
id: wimaToolBar id: planToolBar
height: ScreenTools.toolbarHeight height: ScreenTools.toolbarHeight
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
...@@ -353,7 +366,7 @@ Item { ...@@ -353,7 +366,7 @@ Item {
z: toolBar.z + 1 z: toolBar.z + 1
onShowFlyView: { onShowFlyView: {
wimaToolBar.visible = false planToolBar.visible = false
mainWindow.showFlyView() mainWindow.showFlyView()
} }
} }
...@@ -401,6 +414,7 @@ Item { ...@@ -401,6 +414,7 @@ Item {
property var toolbar: wimaToolBar property var toolbar: wimaToolBar
} }
FlightDisplayView { FlightDisplayView {
id: flightView id: flightView
anchors.fill: parent anchors.fill: parent
...@@ -414,6 +428,19 @@ Item { ...@@ -414,6 +428,19 @@ Item {
} }
} }
FlightDisplayView {
id: wimaFlightView
anchors.fill: parent
visible: true
//-------------------------------------------------------------------------
//-- Loader helper for any child, no matter how deep can display an element
// on top of the video window.
/*Loader {
id: rootVideoLoader
anchors.centerIn: parent
}*/
}
Loader { Loader {
id: analyzeViewLoader id: analyzeViewLoader
anchors.left: parent.left anchors.left: parent.left
......
...@@ -31,6 +31,7 @@ Rectangle { ...@@ -31,6 +31,7 @@ Rectangle {
signal showSetupView signal showSetupView
signal showPlanView signal showPlanView
signal showWimaView signal showWimaView
signal showWimaFlightView
signal showFlyView signal showFlyView
signal showAnalyzeView signal showAnalyzeView
signal armVehicle signal armVehicle
...@@ -54,6 +55,10 @@ Rectangle { ...@@ -54,6 +55,10 @@ Rectangle {
wimaButton.checked = true wimaButton.checked = true
} }
function checkWimaFlyButton() {
wimaFlyButton.checked = true
}
function checkFlyButton() { function checkFlyButton() {
flyButton.checked = true flyButton.checked = true
} }
...@@ -64,7 +69,7 @@ Rectangle { ...@@ -64,7 +69,7 @@ Rectangle {
Component.onCompleted: { Component.onCompleted: {
//-- TODO: Get this from the actual state //-- TODO: Get this from the actual state
flyButton.checked = true planButton.checked = true
} }
// Prevent all clicks from going through to lower layers // Prevent all clicks from going through to lower layers
...@@ -126,6 +131,15 @@ Rectangle { ...@@ -126,6 +131,15 @@ Rectangle {
onClicked: toolBar.showPlanView() onClicked: toolBar.showPlanView()
} }
QGCToolBarButton {
id: flyButton
anchors.top: parent.top
anchors.bottom: parent.bottom
exclusiveGroup: mainActionGroup
source: "/qmlimages/PaperPlane.svg"
onClicked: toolBar.showFlyView()
}
QGCToolBarButton { QGCToolBarButton {
id: wimaButton id: wimaButton
anchors.top: parent.top anchors.top: parent.top
...@@ -136,12 +150,12 @@ Rectangle { ...@@ -136,12 +150,12 @@ Rectangle {
} }
QGCToolBarButton { QGCToolBarButton {
id: flyButton id: wimaFlyButton
anchors.top: parent.top anchors.top: parent.top
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
exclusiveGroup: mainActionGroup exclusiveGroup: mainActionGroup
source: "/qmlimages/PaperPlane.svg" source: "/qmlimages/TelemRSSI.svg"
onClicked: toolBar.showFlyView() onClicked: toolBar.showWimaFlyView()
} }
QGCToolBarButton { QGCToolBarButton {
......
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