From 2b85f1a9fdc413d26a2b417659812fea96c990b8 Mon Sep 17 00:00:00 2001 From: PT_Dreamer Date: Sun, 24 Jun 2012 20:02:45 +0100 Subject: [PATCH] GCS/OPMap- Bugfixes to the model/map proxy. Dynamic overlay creation based on the path plan actions. --- .../src/plugins/opmap/modelmapproxy.cpp | 35 +++++++++++++++++-- .../src/plugins/opmap/modelmapproxy.h | 1 + 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/opmap/modelmapproxy.cpp b/ground/openpilotgcs/src/plugins/opmap/modelmapproxy.cpp index 35cbda7a0..48d78a34c 100644 --- a/ground/openpilotgcs/src/plugins/opmap/modelmapproxy.cpp +++ b/ground/openpilotgcs/src/plugins/opmap/modelmapproxy.cpp @@ -126,10 +126,31 @@ void modelMapProxy::createOverlay(WayPointItem *from, WayPointItem *to, modelMap } } +void modelMapProxy::createOverlay(WayPointItem *from, HomeItem *to, modelMapProxy::overlayType type,QColor color) +{ + if(from==NULL || to==NULL) + return; + switch(type) + { + case OVERLAY_LINE: + myMap->WPLineCreate(to,from,color); + break; + case OVERLAY_CIRCLE_RIGHT: + myMap->WPCircleCreate(to,from,true,color); + break; + case OVERLAY_CIRCLE_LEFT: + myMap->WPCircleCreate(to,from,false,color); + break; + default: + break; + } +} void modelMapProxy::refreshOverlays() { myMap->deleteAllOverlays(); + if(model->rowCount()<1) + return; WayPointItem * wp_current=NULL; WayPointItem * wp_next=NULL; int wp_jump; @@ -137,15 +158,18 @@ void modelMapProxy::refreshOverlays() overlayType wp_next_overlay; overlayType wp_jump_overlay; overlayType wp_error_overlay; + wp_current=findWayPointNumber(0); + overlayType wp_current_overlay=overlayTranslate(model->data(model->index(0,flightDataModel::MODE)).toInt()); + createOverlay(wp_current,myMap->Home,wp_current_overlay,Qt::green); for(int x=0;xrowCount();++x) { wp_current=findWayPointNumber(x); wp_jump=model->data(model->index(x,flightDataModel::JUMPDESTINATION)).toInt(); wp_error=model->data(model->index(x,flightDataModel::ERRORDESTINATION)).toInt(); wp_next_overlay=overlayTranslate(model->data(model->index(x+1,flightDataModel::MODE)).toInt()); - wp_jump_overlay=overlayTranslate(model->data(model->index(wp_jump,flightDataModel::MODE)).toInt()); - wp_error_overlay=overlayTranslate(model->data(model->index(wp_error,flightDataModel::MODE)).toInt()); - createOverlay(wp_current,findWayPointNumber(wp_error),wp_error_overlay,Qt::red); + wp_jump_overlay=overlayTranslate(model->data(model->index(wp_jump,flightDataModel::MODE)).toInt()); + wp_error_overlay=overlayTranslate(model->data(model->index(wp_error,flightDataModel::MODE)).toInt()); + createOverlay(wp_current,findWayPointNumber(wp_error),wp_error_overlay,Qt::red); switch(model->data(model->index(x,flightDataModel::COMMAND)).toInt()) { case ComboBoxDelegate::COMMAND_ONCONDITIONNEXTWAYPOINT: @@ -234,22 +258,27 @@ void modelMapProxy::on_dataChanged(const QModelIndex &topLeft, const QModelIndex distBearing=item->getRelativeCoord(); index=model->index(x,flightDataModel::BEARELATIVE); distBearing.setBearingFromDegrees(index.data(Qt::DisplayRole).toDouble()); + item->setRelativeCoord(distBearing); break; case flightDataModel::DISRELATIVE: distBearing=item->getRelativeCoord(); index=model->index(x,flightDataModel::DISRELATIVE); distBearing.distance=index.data(Qt::DisplayRole).toDouble(); + item->setRelativeCoord(distBearing); break; case flightDataModel::ALTITUDERELATIVE: distBearing=item->getRelativeCoord(); index=model->index(x,flightDataModel::ALTITUDERELATIVE); distBearing.altitudeRelative=index.data(Qt::DisplayRole).toFloat(); + item->setRelativeCoord(distBearing); break; case flightDataModel::ISRELATIVE: index=model->index(x,flightDataModel::ISRELATIVE); relative=index.data(Qt::DisplayRole).toBool(); if(relative) item->setWPType(mapcontrol::WayPointItem::relative); + else + item->setWPType(mapcontrol::WayPointItem::absolute); break; case flightDataModel::ALTITUDE: index=model->index(x,flightDataModel::ALTITUDE); diff --git a/ground/openpilotgcs/src/plugins/opmap/modelmapproxy.h b/ground/openpilotgcs/src/plugins/opmap/modelmapproxy.h index ad49e414a..c6bcaf076 100644 --- a/ground/openpilotgcs/src/plugins/opmap/modelmapproxy.h +++ b/ground/openpilotgcs/src/plugins/opmap/modelmapproxy.h @@ -35,6 +35,7 @@ private slots: private: overlayType overlayTranslate(int type); void createOverlay(WayPointItem * from,WayPointItem * to,overlayType type,QColor color); + void createOverlay(WayPointItem *from, HomeItem *to, modelMapProxy::overlayType type, QColor color); OPMapWidget * myMap; flightDataModel * model; void refreshOverlays();