mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-30 15:52:12 +01:00
GCS -OPMapLib - add relative altitude to waypoints
This commit is contained in:
parent
3cf4676aef
commit
1299bbda93
@ -253,9 +253,9 @@ namespace mapcontrol
|
||||
emit WPCreated(position,item);
|
||||
return item;
|
||||
}
|
||||
WayPointItem* OPMapWidget::WPCreate(const distBearing &relativeCoord, const int &altitude, const QString &description)
|
||||
WayPointItem* OPMapWidget::WPCreate(const distBearingAltitude &relativeCoord, const QString &description)
|
||||
{
|
||||
WayPointItem* item=new WayPointItem(relativeCoord,altitude,description,map);
|
||||
WayPointItem* item=new WayPointItem(relativeCoord,description,map);
|
||||
ConnectWP(item);
|
||||
item->setParentItem(map);
|
||||
int position=item->Number();
|
||||
@ -308,6 +308,15 @@ namespace mapcontrol
|
||||
emit WPValuesChanged(item);
|
||||
return item;
|
||||
}
|
||||
WayPointItem* OPMapWidget::WPInsert(distBearingAltitude const& relative, QString const& description,const int &position)
|
||||
{
|
||||
WayPointItem* item=new WayPointItem(relative,description,map);
|
||||
item->SetNumber(position);
|
||||
ConnectWP(item);
|
||||
item->setParentItem(map);
|
||||
emit WPInserted(position,item);
|
||||
return item;
|
||||
}
|
||||
void OPMapWidget::WPDelete(WayPointItem *item)
|
||||
{
|
||||
emit WPDeleted(item->Number(),item);
|
||||
|
@ -289,7 +289,7 @@ namespace mapcontrol
|
||||
* @param description the description of the WayPoint
|
||||
* @return WayPointItem a pointer to the WayPoint created
|
||||
*/
|
||||
WayPointItem *WPCreate(const distBearing &relativeCoord, const int &altitude, const QString &description);
|
||||
WayPointItem *WPCreate(const distBearingAltitude &relativeCoord, const QString &description);
|
||||
/**
|
||||
* @brief Inserts a new WayPoint on the specified position
|
||||
*
|
||||
@ -323,6 +323,7 @@ namespace mapcontrol
|
||||
* @return WayPointItem a pointer to the WayPoint Inserted
|
||||
*/
|
||||
WayPointItem* WPInsert(internals::PointLatLng const& coord,int const& altitude, QString const& description,int const& position);
|
||||
WayPointItem *WPInsert(const distBearingAltitude &relative, const QString &description, const int &position);
|
||||
|
||||
/**
|
||||
* @brief Deletes the WayPoint
|
||||
@ -372,7 +373,7 @@ namespace mapcontrol
|
||||
void WPDelete(int number);
|
||||
WayPointItem *WPFind(int number);
|
||||
void setSelectedWP(QList<WayPointItem *> list);
|
||||
private:
|
||||
private:
|
||||
internals::Core *core;
|
||||
MapGraphicItem *map;
|
||||
QGraphicsScene mscene;
|
||||
|
@ -47,7 +47,7 @@ WayPointCircle::WayPointCircle(HomeItem *radius, WayPointItem *center, bool cloc
|
||||
my_radius(radius),my_map(map),QGraphicsEllipseItem(map),myColor(color),myClockWise(clockwise)
|
||||
{
|
||||
qDebug()<<"circle clock:"<<clockwise;
|
||||
connect(radius,SIGNAL(homePositionChanged(internals::PointLatLng)),this,SLOT(refreshLocations()));
|
||||
connect(radius,SIGNAL(homePositionChanged(internals::PointLatLng,float)),this,SLOT(refreshLocations()));
|
||||
connect(center,SIGNAL(localPositionChanged(QPointF)),this,SLOT(refreshLocations()));
|
||||
connect(center,SIGNAL(aboutToBeDeleted(WayPointItem*)),this,SLOT(waypointdeleted()));
|
||||
refreshLocations();
|
||||
|
@ -52,8 +52,11 @@ WayPointItem::WayPointItem(const internals::PointLatLng &coord,int const& altitu
|
||||
}
|
||||
|
||||
if(myHome)
|
||||
{
|
||||
map->Projection()->offSetFromLatLngs(myHome->Coord(),coord,relativeCoord.distance,relativeCoord.bearing);
|
||||
connect(myHome,SIGNAL(homePositionChanged(internals::PointLatLng)),this,SLOT(onHomePositionChanged(internals::PointLatLng)));
|
||||
relativeCoord.altitudeRelative=Altitude()-myHome->Altitude();
|
||||
connect(myHome,SIGNAL(homePositionChanged(internals::PointLatLng,float)),this,SLOT(onHomePositionChanged(internals::PointLatLng,float)));
|
||||
}
|
||||
connect(this,SIGNAL(waypointdoubleclick(WayPointItem*)),map,SIGNAL(wpdoubleclicked(WayPointItem*)));
|
||||
emit manualCoordChange(this);
|
||||
}
|
||||
@ -62,6 +65,7 @@ WayPointItem::WayPointItem(MapGraphicItem *map, bool magicwaypoint):reached(fals
|
||||
{
|
||||
relativeCoord.bearing=0;
|
||||
relativeCoord.distance=0;
|
||||
relativeCoord.altitudeRelative=0;
|
||||
myType=relative;
|
||||
if(magicwaypoint)
|
||||
{
|
||||
@ -93,7 +97,8 @@ WayPointItem::WayPointItem(MapGraphicItem *map, bool magicwaypoint):reached(fals
|
||||
if(myHome)
|
||||
{
|
||||
coord=map->Projection()->translate(myHome->Coord(),relativeCoord.distance,relativeCoord.bearing);
|
||||
connect(myHome,SIGNAL(homePositionChanged(internals::PointLatLng)),this,SLOT(onHomePositionChanged(internals::PointLatLng)));
|
||||
SetAltitude(myHome->Altitude()+relativeCoord.altitudeRelative);
|
||||
connect(myHome,SIGNAL(homePositionChanged(internals::PointLatLng,float)),this,SLOT(onHomePositionChanged(internals::PointLatLng,float)));
|
||||
}
|
||||
connect(this,SIGNAL(waypointdoubleclick(WayPointItem*)),map,SIGNAL(wpdoubleclicked(WayPointItem*)));
|
||||
emit manualCoordChange(this);
|
||||
@ -122,14 +127,14 @@ WayPointItem::WayPointItem(MapGraphicItem *map, bool magicwaypoint):reached(fals
|
||||
if(myHome)
|
||||
{
|
||||
map->Projection()->offSetFromLatLngs(myHome->Coord(),coord,relativeCoord.distance,relativeCoord.bearing);
|
||||
connect(myHome,SIGNAL(homePositionChanged(internals::PointLatLng)),this,SLOT(onHomePositionChanged(internals::PointLatLng)));
|
||||
relativeCoord.altitudeRelative=Altitude()-myHome->Altitude();
|
||||
connect(myHome,SIGNAL(homePositionChanged(internals::PointLatLng,float)),this,SLOT(onHomePositionChanged(internals::PointLatLng,float)));
|
||||
}
|
||||
connect(this,SIGNAL(waypointdoubleclick(WayPointItem*)),map,SIGNAL(wpdoubleclicked(WayPointItem*)));
|
||||
qDebug()<<"Waypoint CTOR distance"<<relativeCoord.distance;
|
||||
emit manualCoordChange(this);
|
||||
}
|
||||
|
||||
WayPointItem::WayPointItem(const distBearing &relativeCoordenate, const int &altitude, const QString &description, MapGraphicItem *map):relativeCoord(relativeCoordenate),reached(false),description(description),shownumber(true),isDragging(false),altitude(altitude),map(map)
|
||||
WayPointItem::WayPointItem(const distBearingAltitude &relativeCoordenate, const QString &description, MapGraphicItem *map):relativeCoord(relativeCoordenate),reached(false),description(description),shownumber(true),isDragging(false),map(map)
|
||||
{
|
||||
myHome=NULL;
|
||||
QList<QGraphicsItem *> list=map->childItems();
|
||||
@ -141,8 +146,9 @@ WayPointItem::WayPointItem(MapGraphicItem *map, bool magicwaypoint):reached(fals
|
||||
}
|
||||
if(myHome)
|
||||
{
|
||||
connect(myHome,SIGNAL(homePositionChanged(internals::PointLatLng)),this,SLOT(onHomePositionChanged(internals::PointLatLng)));
|
||||
connect(myHome,SIGNAL(homePositionChanged(internals::PointLatLng,float)),this,SLOT(onHomePositionChanged(internals::PointLatLng,float)));
|
||||
coord=map->Projection()->translate(myHome->Coord(),relativeCoord.distance,relativeCoord.bearing);
|
||||
SetAltitude(myHome->Altitude()+relativeCoord.altitudeRelative);
|
||||
}
|
||||
myType=relative;
|
||||
text=0;
|
||||
@ -250,16 +256,15 @@ WayPointItem::WayPointItem(MapGraphicItem *map, bool magicwaypoint):reached(fals
|
||||
}
|
||||
QGraphicsItem::mouseMoveEvent(event);
|
||||
}
|
||||
void WayPointItem::SetAltitude(const int &value)
|
||||
void WayPointItem::SetAltitude(const float &value)
|
||||
{
|
||||
altitude=value;
|
||||
RefreshToolTip();
|
||||
|
||||
emit WPValuesChanged(this);
|
||||
this->update();
|
||||
}
|
||||
|
||||
void WayPointItem::setRelativeCoord(distBearing value)
|
||||
void WayPointItem::setRelativeCoord(distBearingAltitude value)
|
||||
{
|
||||
relativeCoord=value;
|
||||
if(myHome)
|
||||
@ -279,7 +284,7 @@ WayPointItem::WayPointItem(MapGraphicItem *map, bool magicwaypoint):reached(fals
|
||||
if(coord!=value)
|
||||
abs_coord=true;
|
||||
coord=value;
|
||||
distBearing back=relativeCoord;
|
||||
distBearingAltitude back=relativeCoord;
|
||||
qDebug()<<"SET COORD"<<value.Lat()<<value.Lng();
|
||||
if(myHome)
|
||||
map->Projection()->offSetFromLatLngs(myHome->Coord(),coord,relativeCoord.distance,relativeCoord.bearing);
|
||||
@ -361,11 +366,12 @@ WayPointItem::WayPointItem(MapGraphicItem *map, bool magicwaypoint):reached(fals
|
||||
}
|
||||
}
|
||||
|
||||
void WayPointItem::onHomePositionChanged(internals::PointLatLng homepos)
|
||||
void WayPointItem::onHomePositionChanged(internals::PointLatLng homepos, float homeAltitude)
|
||||
{
|
||||
if(myType==relative)
|
||||
{
|
||||
coord=map->Projection()->translate(homepos,relativeCoord.distance,relativeCoord.bearing);
|
||||
SetAltitude(relativeCoord.altitudeRelative+homeAltitude);
|
||||
emit WPValuesChanged(this);
|
||||
RefreshPos();
|
||||
RefreshToolTip();
|
||||
@ -374,7 +380,10 @@ WayPointItem::WayPointItem(MapGraphicItem *map, bool magicwaypoint):reached(fals
|
||||
else
|
||||
{
|
||||
if(myHome)
|
||||
{
|
||||
map->Projection()->offSetFromLatLngs(myHome->Coord(),coord,relativeCoord.distance,relativeCoord.bearing);
|
||||
relativeCoord.altitudeRelative=Altitude()-homeAltitude;
|
||||
}
|
||||
emit WPValuesChanged(this);
|
||||
}
|
||||
}
|
||||
|
@ -37,10 +37,11 @@
|
||||
|
||||
namespace mapcontrol
|
||||
{
|
||||
struct distBearing
|
||||
struct distBearingAltitude
|
||||
{
|
||||
double distance;
|
||||
double bearing;
|
||||
float altitudeRelative;
|
||||
double bearingToDegrees(){return bearing*180/M_PI;}
|
||||
void setBearingFromDegrees(double degrees){bearing=degrees*M_PI/180;}
|
||||
};
|
||||
@ -77,7 +78,7 @@ public:
|
||||
* @return
|
||||
*/
|
||||
WayPointItem(internals::PointLatLng const& coord,int const& altitude,QString const& description,MapGraphicItem* map,wptype type=absolute);
|
||||
WayPointItem(distBearing const& relativeCoord,int const& altitude,QString const& description,MapGraphicItem* map);
|
||||
WayPointItem(distBearingAltitude const& relativeCoord,QString const& description,MapGraphicItem* map);
|
||||
|
||||
/**
|
||||
* @brief Returns the WayPoint description
|
||||
@ -141,15 +142,15 @@ public:
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
int Altitude(){return altitude;}
|
||||
float Altitude(){return altitude;}
|
||||
/**
|
||||
* @brief Sets the WayPoint Altitude
|
||||
*
|
||||
* @param value
|
||||
*/
|
||||
void SetAltitude(int const& value);
|
||||
void setRelativeCoord(distBearing value);
|
||||
distBearing getRelativeCoord(){return relativeCoord;}
|
||||
void SetAltitude(const float &value);
|
||||
void setRelativeCoord(distBearingAltitude value);
|
||||
distBearingAltitude getRelativeCoord(){return relativeCoord;}
|
||||
int type() const;
|
||||
QRectF boundingRect() const;
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
@ -172,12 +173,12 @@ protected:
|
||||
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
|
||||
private:
|
||||
internals::PointLatLng coord;//coordinates of this WayPoint
|
||||
distBearing relativeCoord;
|
||||
distBearingAltitude relativeCoord;
|
||||
bool reached;
|
||||
QString description;
|
||||
bool shownumber;
|
||||
bool isDragging;
|
||||
int altitude;
|
||||
float altitude;
|
||||
MapGraphicItem* map;
|
||||
int number;
|
||||
|
||||
@ -214,7 +215,7 @@ public slots:
|
||||
*/
|
||||
void WPInserted(int const& number,WayPointItem* waypoint);
|
||||
|
||||
void onHomePositionChanged(internals::PointLatLng);
|
||||
void onHomePositionChanged(internals::PointLatLng,float altitude);
|
||||
signals:
|
||||
/**
|
||||
* @brief fires when this WayPoint number changes (not fired if due to a auto-renumbering)
|
||||
|
@ -45,7 +45,7 @@ WayPointLine::WayPointLine(HomeItem *from, WayPointItem *to, MapGraphicItem *map
|
||||
destination(to),my_map(map),QGraphicsLineItem(map),myColor(color)
|
||||
{
|
||||
this->setLine(to->pos().x(),to->pos().y(),from->pos().x(),from->pos().y());
|
||||
connect(from,SIGNAL(homePositionChanged(internals::PointLatLng)),this,SLOT(refreshLocations()));
|
||||
connect(from,SIGNAL(homePositionChanged(internals::PointLatLng,float)),this,SLOT(refreshLocations()));
|
||||
connect(to,SIGNAL(localPositionChanged(QPointF,WayPointItem*)),this,SLOT(refreshLocations()));
|
||||
connect(to,SIGNAL(aboutToBeDeleted(WayPointItem*)),this,SLOT(waypointdeleted()));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user