mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-18 03:52:11 +01:00
GCS/OPMap- Bugfixes to the model/map proxy.
Dynamic overlay creation based on the path plan actions.
This commit is contained in:
parent
ff48babb46
commit
2b85f1a9fd
@ -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()
|
void modelMapProxy::refreshOverlays()
|
||||||
{
|
{
|
||||||
myMap->deleteAllOverlays();
|
myMap->deleteAllOverlays();
|
||||||
|
if(model->rowCount()<1)
|
||||||
|
return;
|
||||||
WayPointItem * wp_current=NULL;
|
WayPointItem * wp_current=NULL;
|
||||||
WayPointItem * wp_next=NULL;
|
WayPointItem * wp_next=NULL;
|
||||||
int wp_jump;
|
int wp_jump;
|
||||||
@ -137,15 +158,18 @@ void modelMapProxy::refreshOverlays()
|
|||||||
overlayType wp_next_overlay;
|
overlayType wp_next_overlay;
|
||||||
overlayType wp_jump_overlay;
|
overlayType wp_jump_overlay;
|
||||||
overlayType wp_error_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;x<model->rowCount();++x)
|
for(int x=0;x<model->rowCount();++x)
|
||||||
{
|
{
|
||||||
wp_current=findWayPointNumber(x);
|
wp_current=findWayPointNumber(x);
|
||||||
wp_jump=model->data(model->index(x,flightDataModel::JUMPDESTINATION)).toInt();
|
wp_jump=model->data(model->index(x,flightDataModel::JUMPDESTINATION)).toInt();
|
||||||
wp_error=model->data(model->index(x,flightDataModel::ERRORDESTINATION)).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_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_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());
|
wp_error_overlay=overlayTranslate(model->data(model->index(wp_error,flightDataModel::MODE)).toInt());
|
||||||
createOverlay(wp_current,findWayPointNumber(wp_error),wp_error_overlay,Qt::red);
|
createOverlay(wp_current,findWayPointNumber(wp_error),wp_error_overlay,Qt::red);
|
||||||
switch(model->data(model->index(x,flightDataModel::COMMAND)).toInt())
|
switch(model->data(model->index(x,flightDataModel::COMMAND)).toInt())
|
||||||
{
|
{
|
||||||
case ComboBoxDelegate::COMMAND_ONCONDITIONNEXTWAYPOINT:
|
case ComboBoxDelegate::COMMAND_ONCONDITIONNEXTWAYPOINT:
|
||||||
@ -234,22 +258,27 @@ void modelMapProxy::on_dataChanged(const QModelIndex &topLeft, const QModelIndex
|
|||||||
distBearing=item->getRelativeCoord();
|
distBearing=item->getRelativeCoord();
|
||||||
index=model->index(x,flightDataModel::BEARELATIVE);
|
index=model->index(x,flightDataModel::BEARELATIVE);
|
||||||
distBearing.setBearingFromDegrees(index.data(Qt::DisplayRole).toDouble());
|
distBearing.setBearingFromDegrees(index.data(Qt::DisplayRole).toDouble());
|
||||||
|
item->setRelativeCoord(distBearing);
|
||||||
break;
|
break;
|
||||||
case flightDataModel::DISRELATIVE:
|
case flightDataModel::DISRELATIVE:
|
||||||
distBearing=item->getRelativeCoord();
|
distBearing=item->getRelativeCoord();
|
||||||
index=model->index(x,flightDataModel::DISRELATIVE);
|
index=model->index(x,flightDataModel::DISRELATIVE);
|
||||||
distBearing.distance=index.data(Qt::DisplayRole).toDouble();
|
distBearing.distance=index.data(Qt::DisplayRole).toDouble();
|
||||||
|
item->setRelativeCoord(distBearing);
|
||||||
break;
|
break;
|
||||||
case flightDataModel::ALTITUDERELATIVE:
|
case flightDataModel::ALTITUDERELATIVE:
|
||||||
distBearing=item->getRelativeCoord();
|
distBearing=item->getRelativeCoord();
|
||||||
index=model->index(x,flightDataModel::ALTITUDERELATIVE);
|
index=model->index(x,flightDataModel::ALTITUDERELATIVE);
|
||||||
distBearing.altitudeRelative=index.data(Qt::DisplayRole).toFloat();
|
distBearing.altitudeRelative=index.data(Qt::DisplayRole).toFloat();
|
||||||
|
item->setRelativeCoord(distBearing);
|
||||||
break;
|
break;
|
||||||
case flightDataModel::ISRELATIVE:
|
case flightDataModel::ISRELATIVE:
|
||||||
index=model->index(x,flightDataModel::ISRELATIVE);
|
index=model->index(x,flightDataModel::ISRELATIVE);
|
||||||
relative=index.data(Qt::DisplayRole).toBool();
|
relative=index.data(Qt::DisplayRole).toBool();
|
||||||
if(relative)
|
if(relative)
|
||||||
item->setWPType(mapcontrol::WayPointItem::relative);
|
item->setWPType(mapcontrol::WayPointItem::relative);
|
||||||
|
else
|
||||||
|
item->setWPType(mapcontrol::WayPointItem::absolute);
|
||||||
break;
|
break;
|
||||||
case flightDataModel::ALTITUDE:
|
case flightDataModel::ALTITUDE:
|
||||||
index=model->index(x,flightDataModel::ALTITUDE);
|
index=model->index(x,flightDataModel::ALTITUDE);
|
||||||
|
@ -35,6 +35,7 @@ private slots:
|
|||||||
private:
|
private:
|
||||||
overlayType overlayTranslate(int type);
|
overlayType overlayTranslate(int type);
|
||||||
void createOverlay(WayPointItem * from,WayPointItem * to,overlayType type,QColor color);
|
void createOverlay(WayPointItem * from,WayPointItem * to,overlayType type,QColor color);
|
||||||
|
void createOverlay(WayPointItem *from, HomeItem *to, modelMapProxy::overlayType type, QColor color);
|
||||||
OPMapWidget * myMap;
|
OPMapWidget * myMap;
|
||||||
flightDataModel * model;
|
flightDataModel * model;
|
||||||
void refreshOverlays();
|
void refreshOverlays();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user