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