mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-05 21:52:10 +01:00
GCS - Changes to the map lib. Preparatory steps
to allow WPs to be defined relative to home. GPS fed UAV map item is only visible when diagnostics are enabled. Should make users not be confused by 2 UAVs on screen.
This commit is contained in:
parent
9f1afacdaf
commit
bb7e85cf2c
@ -215,6 +215,13 @@ Point PureProjection::FromLatLngToPixel(const PointLatLng &p,const int &zoom)
|
|||||||
Lat /= (PI / 180);
|
Lat /= (PI / 180);
|
||||||
Lng /= (PI / 180);
|
Lng /= (PI / 180);
|
||||||
}
|
}
|
||||||
|
double PureProjection::courseBetweenLatLng(PointLatLng const& p1,PointLatLng const& p2)
|
||||||
|
{
|
||||||
|
return fmod(atan2(sin(p1.Lng()-p2.Lng())*cos(p2.Lat()),
|
||||||
|
cos(p1.Lat())*sin(p2.Lat())-sin(p1.Lat())*cos(p2.Lat())*cos(p1.Lng()-p2.Lng())), 2*PI);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
double PureProjection::DistanceBetweenLatLng(PointLatLng const& p1,PointLatLng const& p2)
|
double PureProjection::DistanceBetweenLatLng(PointLatLng const& p1,PointLatLng const& p2)
|
||||||
{
|
{
|
||||||
double R = 6371; // km
|
double R = 6371; // km
|
||||||
@ -229,4 +236,23 @@ Point PureProjection::FromLatLngToPixel(const PointLatLng &p,const int &zoom)
|
|||||||
double d = R * c;
|
double d = R * c;
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PureProjection::offSetFromLatLngs(PointLatLng p1,PointLatLng p2,double &dX,double &dY)
|
||||||
|
{
|
||||||
|
dX=DistanceBetweenLatLng(p1,p2)*sin(courseBetweenLatLng(p1,p2));
|
||||||
|
dY=DistanceBetweenLatLng(p1,p2)*sin(courseBetweenLatLng(p1,p2));
|
||||||
|
}
|
||||||
|
|
||||||
|
PointLatLng PureProjection::translate(PointLatLng p1,double dX,double dY)
|
||||||
|
{
|
||||||
|
PointLatLng origin=p1;
|
||||||
|
PointLatLng ret;
|
||||||
|
double d=sqrt(pow(dX,2)+pow(dY,2));
|
||||||
|
double tc=atan2(dY,dX);
|
||||||
|
ret.SetLat(asin(sin(origin.Lat())*cos(d)+cos(origin.Lat())*sin(d)*cos(tc)));
|
||||||
|
double dlon=atan2(sin(tc)*sin(d)*cos(origin.Lat()),cos(d)-sin(origin.Lat())*sin(p1.Lat()));
|
||||||
|
ret.SetLng(fmod(origin.Lng()-dlon +PI,2*PI )-PI);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -81,6 +81,9 @@ public:
|
|||||||
void FromCartesianTGeodetic(const double &X,const double &Y,const double &Z, double &Lat, double &Lng);
|
void FromCartesianTGeodetic(const double &X,const double &Y,const double &Z, double &Lat, double &Lng);
|
||||||
static double DistanceBetweenLatLng(PointLatLng const& p1,PointLatLng const& p2);
|
static double DistanceBetweenLatLng(PointLatLng const& p1,PointLatLng const& p2);
|
||||||
|
|
||||||
|
PointLatLng translate(PointLatLng p1, double dX, double dY);
|
||||||
|
double courseBetweenLatLng(const PointLatLng &p1, const PointLatLng &p2);
|
||||||
|
void offSetFromLatLngs(PointLatLng p1, PointLatLng p2, double &dX, double &dY);
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
static const double PI;
|
static const double PI;
|
||||||
|
@ -27,15 +27,20 @@
|
|||||||
#include "homeitem.h"
|
#include "homeitem.h"
|
||||||
namespace mapcontrol
|
namespace mapcontrol
|
||||||
{
|
{
|
||||||
HomeItem::HomeItem(MapGraphicItem* map,OPMapWidget* parent):safe(true),map(map),mapwidget(parent),showsafearea(true),safearea(1000),altitude(0)
|
HomeItem::HomeItem(MapGraphicItem* map,OPMapWidget* parent):safe(true),map(map),mapwidget(parent),showsafearea(true),safearea(1000),altitude(0),isDragging(false)
|
||||||
{
|
{
|
||||||
pic.load(QString::fromUtf8(":/markers/images/home2.svg"));
|
pic.load(QString::fromUtf8(":/markers/images/home2.svg"));
|
||||||
pic=pic.scaled(30,30,Qt::IgnoreAspectRatio);
|
pic=pic.scaled(30,30,Qt::IgnoreAspectRatio);
|
||||||
this->setFlag(QGraphicsItem::ItemIgnoresTransformations,true);
|
this->setFlag(QGraphicsItem::ItemIgnoresTransformations,true);
|
||||||
|
this->setFlag(QGraphicsItem::ItemIsMovable,true);
|
||||||
|
this->setFlag(QGraphicsItem::ItemIsSelectable,true);
|
||||||
localposition=map->FromLatLngToLocal(mapwidget->CurrentPosition());
|
localposition=map->FromLatLngToLocal(mapwidget->CurrentPosition());
|
||||||
this->setPos(localposition.X(),localposition.Y());
|
this->setPos(localposition.X(),localposition.Y());
|
||||||
this->setZValue(4);
|
this->setZValue(4);
|
||||||
coord=internals::PointLatLng(50,50);
|
coord=internals::PointLatLng(50,50);
|
||||||
|
setToolTip("AAAA");
|
||||||
|
qDebug()<<"HomeItem created type:"<<type();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void HomeItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
void HomeItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||||
@ -56,7 +61,7 @@ namespace mapcontrol
|
|||||||
}
|
}
|
||||||
QRectF HomeItem::boundingRect()const
|
QRectF HomeItem::boundingRect()const
|
||||||
{
|
{
|
||||||
if(!showsafearea)
|
if(pic.width()>localsafearea*2)
|
||||||
return QRectF(-pic.width()/2,-pic.height()/2,pic.width(),pic.height());
|
return QRectF(-pic.width()/2,-pic.height()/2,pic.width(),pic.height());
|
||||||
else
|
else
|
||||||
return QRectF(-localsafearea,-localsafearea,localsafearea*2,localsafearea*2);
|
return QRectF(-localsafearea,-localsafearea,localsafearea*2,localsafearea*2);
|
||||||
@ -76,5 +81,34 @@ namespace mapcontrol
|
|||||||
localsafearea=safearea/map->Projection()->GetGroundResolution(map->ZoomTotal(),coord.Lat());
|
localsafearea=safearea/map->Projection()->GetGroundResolution(map->ZoomTotal(),coord.Lat());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
void HomeItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||||
|
{
|
||||||
|
if(event->button()==Qt::LeftButton)
|
||||||
|
{
|
||||||
|
isDragging=true;
|
||||||
|
}
|
||||||
|
QGraphicsItem::mousePressEvent(event);
|
||||||
|
}
|
||||||
|
void HomeItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||||
|
{
|
||||||
|
if(event->button()==Qt::LeftButton)
|
||||||
|
{
|
||||||
|
coord=map->FromLocalToLatLng(this->pos().x(),this->pos().y());
|
||||||
|
isDragging=false;
|
||||||
|
|
||||||
|
emit homePositionChanged(coord);
|
||||||
|
}
|
||||||
|
QGraphicsItem::mouseReleaseEvent(event);
|
||||||
|
}
|
||||||
|
void HomeItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
||||||
|
{
|
||||||
|
|
||||||
|
if(isDragging)
|
||||||
|
{
|
||||||
|
coord=map->FromLocalToLatLng(this->pos().x(),this->pos().y());
|
||||||
|
emit homePositionChanged(coord);
|
||||||
|
}
|
||||||
|
QGraphicsItem::mouseMoveEvent(event);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,11 +67,15 @@ namespace mapcontrol
|
|||||||
int safearea;
|
int safearea;
|
||||||
int localsafearea;
|
int localsafearea;
|
||||||
int altitude;
|
int altitude;
|
||||||
|
bool isDragging;
|
||||||
|
protected:
|
||||||
|
void mouseMoveEvent ( QGraphicsSceneMouseEvent * event );
|
||||||
|
void mousePressEvent ( QGraphicsSceneMouseEvent * event );
|
||||||
|
void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
void homePositionChanged(internals::PointLatLng coord);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
#endif // HOMEITEM_H
|
#endif // HOMEITEM_H
|
||||||
|
@ -40,6 +40,9 @@ namespace mapcontrol
|
|||||||
map=new MapGraphicItem(core,config);
|
map=new MapGraphicItem(core,config);
|
||||||
mscene.addItem(map);
|
mscene.addItem(map);
|
||||||
this->setScene(&mscene);
|
this->setScene(&mscene);
|
||||||
|
Home=new HomeItem(map,this);
|
||||||
|
Home->setParentItem(map);
|
||||||
|
setStyleSheet("QToolTip {font-size:8pt; color:yellow;background-color : transparent; padding:2px; border-width:2px; border-style:solid; border-radius:4px }");
|
||||||
this->adjustSize();
|
this->adjustSize();
|
||||||
connect(map,SIGNAL(zoomChanged(double,double,double)),this,SIGNAL(zoomChanged(double,double,double)));
|
connect(map,SIGNAL(zoomChanged(double,double,double)),this,SIGNAL(zoomChanged(double,double,double)));
|
||||||
connect(map->core,SIGNAL(OnCurrentPositionChanged(internals::PointLatLng)),this,SIGNAL(OnCurrentPositionChanged(internals::PointLatLng)));
|
connect(map->core,SIGNAL(OnCurrentPositionChanged(internals::PointLatLng)),this,SIGNAL(OnCurrentPositionChanged(internals::PointLatLng)));
|
||||||
@ -70,12 +73,23 @@ namespace mapcontrol
|
|||||||
delete diagTimer;
|
delete diagTimer;
|
||||||
diagTimer=0;
|
diagTimer=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(GPS!=0)
|
||||||
|
{
|
||||||
|
delete GPS;
|
||||||
|
GPS=0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
diagTimer=new QTimer();
|
diagTimer=new QTimer();
|
||||||
connect(diagTimer,SIGNAL(timeout()),this,SLOT(diagRefresh()));
|
connect(diagTimer,SIGNAL(timeout()),this,SLOT(diagRefresh()));
|
||||||
diagTimer->start(500);
|
diagTimer->start(500);
|
||||||
|
if(GPS==0)
|
||||||
|
{
|
||||||
|
GPS=new GPSItem(map,this);
|
||||||
|
GPS->setParentItem(map);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -106,37 +120,10 @@ namespace mapcontrol
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if(value && GPS==0)
|
|
||||||
{
|
|
||||||
GPS=new GPSItem(map,this);
|
|
||||||
GPS->setParentItem(map);
|
|
||||||
}
|
|
||||||
else if(!value)
|
|
||||||
{
|
|
||||||
if(GPS!=0)
|
|
||||||
{
|
|
||||||
delete GPS;
|
|
||||||
GPS=0;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
void OPMapWidget::SetShowHome(const bool &value)
|
void OPMapWidget::SetShowHome(const bool &value)
|
||||||
{
|
{
|
||||||
if(value && Home==0)
|
Home->setVisible(value);
|
||||||
{
|
|
||||||
Home=new HomeItem(map,this);
|
|
||||||
Home->setParentItem(map);
|
|
||||||
}
|
|
||||||
else if(!value)
|
|
||||||
{
|
|
||||||
if(Home!=0)
|
|
||||||
{
|
|
||||||
delete Home;
|
|
||||||
Home=0;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OPMapWidget::resizeEvent(QResizeEvent *event)
|
void OPMapWidget::resizeEvent(QResizeEvent *event)
|
||||||
@ -329,12 +316,12 @@ namespace mapcontrol
|
|||||||
compass->setScale(0.1+0.05*(qreal)(this->size().width())/1000*(qreal)(this->size().height())/600);
|
compass->setScale(0.1+0.05*(qreal)(this->size().width())/1000*(qreal)(this->size().height())/600);
|
||||||
// compass->setTransformOriginPoint(compass->boundingRect().width(),compass->boundingRect().height());
|
// compass->setTransformOriginPoint(compass->boundingRect().width(),compass->boundingRect().height());
|
||||||
compass->setFlag(QGraphicsItem::ItemIsMovable,true);
|
compass->setFlag(QGraphicsItem::ItemIsMovable,true);
|
||||||
|
compass->setFlag(QGraphicsItem::ItemIsSelectable,true);
|
||||||
mscene.addItem(compass);
|
mscene.addItem(compass);
|
||||||
compass->setTransformOriginPoint(compass->boundingRect().width()/2,compass->boundingRect().height()/2);
|
compass->setTransformOriginPoint(compass->boundingRect().width()/2,compass->boundingRect().height()/2);
|
||||||
compass->setPos(55-compass->boundingRect().width()/2,55-compass->boundingRect().height()/2);
|
compass->setPos(55-compass->boundingRect().width()/2,55-compass->boundingRect().height()/2);
|
||||||
compass->setZValue(3);
|
compass->setZValue(3);
|
||||||
compass->setOpacity(0.7);
|
compass->setOpacity(0.7);
|
||||||
|
|
||||||
}
|
}
|
||||||
if(!value && compass)
|
if(!value && compass)
|
||||||
{
|
{
|
||||||
|
@ -36,6 +36,8 @@ namespace mapcontrol
|
|||||||
pic.load(uavPic);
|
pic.load(uavPic);
|
||||||
// Don't scale but trust the image we are given
|
// Don't scale but trust the image we are given
|
||||||
// pic=pic.scaled(50,33,Qt::IgnoreAspectRatio);
|
// pic=pic.scaled(50,33,Qt::IgnoreAspectRatio);
|
||||||
|
this->setFlag(QGraphicsItem::ItemIsMovable,true);
|
||||||
|
this->setFlag(QGraphicsItem::ItemIsSelectable,true);
|
||||||
localposition=map->FromLatLngToLocal(mapwidget->CurrentPosition());
|
localposition=map->FromLatLngToLocal(mapwidget->CurrentPosition());
|
||||||
this->setPos(localposition.X(),localposition.Y());
|
this->setPos(localposition.X(),localposition.Y());
|
||||||
this->setZValue(4);
|
this->setZValue(4);
|
||||||
@ -57,14 +59,14 @@ namespace mapcontrol
|
|||||||
{
|
{
|
||||||
Q_UNUSED(option);
|
Q_UNUSED(option);
|
||||||
Q_UNUSED(widget);
|
Q_UNUSED(widget);
|
||||||
// painter->rotate(-90);
|
|
||||||
painter->drawPixmap(-pic.width()/2,-pic.height()/2,pic);
|
painter->drawPixmap(-pic.width()/2,-pic.height()/2,pic);
|
||||||
// painter->drawRect(QRectF(-pic.width()/2,-pic.height()/2,pic.width()-1,pic.height()-1));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QRectF UAVItem::boundingRect()const
|
QRectF UAVItem::boundingRect()const
|
||||||
{
|
{
|
||||||
return QRectF(-pic.width()/2,-pic.height()/2,pic.width(),pic.height());
|
return QRectF(-pic.width()/2,-pic.height()/2,pic.width(),pic.height());
|
||||||
}
|
}
|
||||||
|
|
||||||
void UAVItem::SetUAVPos(const internals::PointLatLng &position, const int &altitude)
|
void UAVItem::SetUAVPos(const internals::PointLatLng &position, const int &altitude)
|
||||||
{
|
{
|
||||||
if(coord.IsEmpty())
|
if(coord.IsEmpty())
|
||||||
|
@ -25,9 +25,11 @@
|
|||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*/
|
*/
|
||||||
#include "waypointitem.h"
|
#include "waypointitem.h"
|
||||||
|
#include "homeitem.h"
|
||||||
|
|
||||||
namespace mapcontrol
|
namespace mapcontrol
|
||||||
{
|
{
|
||||||
WayPointItem::WayPointItem(const internals::PointLatLng &coord,int const& altitude, MapGraphicItem *map):coord(coord),reached(false),description(""),shownumber(true),isDragging(false),altitude(altitude),map(map)
|
WayPointItem::WayPointItem(const internals::PointLatLng &coord,int const& altitude, MapGraphicItem *map,wptype type):coord(coord),reached(false),description(""),shownumber(true),isDragging(false),altitude(altitude),map(map),myType(type)
|
||||||
{
|
{
|
||||||
text=0;
|
text=0;
|
||||||
numberI=0;
|
numberI=0;
|
||||||
@ -37,13 +39,31 @@ namespace mapcontrol
|
|||||||
this->setFlag(QGraphicsItem::ItemIsMovable,true);
|
this->setFlag(QGraphicsItem::ItemIsMovable,true);
|
||||||
this->setFlag(QGraphicsItem::ItemIgnoresTransformations,true);
|
this->setFlag(QGraphicsItem::ItemIgnoresTransformations,true);
|
||||||
this->setFlag(QGraphicsItem::ItemIsSelectable,true);
|
this->setFlag(QGraphicsItem::ItemIsSelectable,true);
|
||||||
// transf.translate(picture.width()/2,picture.height());
|
|
||||||
// this->setTransform(transf);
|
|
||||||
SetShowNumber(shownumber);
|
SetShowNumber(shownumber);
|
||||||
RefreshToolTip();
|
RefreshToolTip();
|
||||||
RefreshPos();
|
RefreshPos();
|
||||||
|
if(relativeCoord.isNull())
|
||||||
|
{
|
||||||
|
HomeItem* home=NULL;
|
||||||
|
QList<QGraphicsItem *> list=map->childItems();
|
||||||
|
foreach(QGraphicsItem * obj,list)
|
||||||
|
{
|
||||||
|
HomeItem* h=qgraphicsitem_cast <HomeItem*>(obj);
|
||||||
|
if(h)
|
||||||
|
home=h;
|
||||||
}
|
}
|
||||||
WayPointItem::WayPointItem(const internals::PointLatLng &coord,int const& altitude, const QString &description, MapGraphicItem *map):coord(coord),reached(false),description(description),shownumber(true),isDragging(false),altitude(altitude),map(map)
|
|
||||||
|
double X;
|
||||||
|
double Y;
|
||||||
|
map->Projection()->offSetFromLatLngs(home->Coord(),coord,X,Y);
|
||||||
|
relativeCoord.setX(X);
|
||||||
|
relativeCoord.setY(Y);
|
||||||
|
|
||||||
|
}
|
||||||
|
HomeItem * home=this->parent()->findChild<HomeItem *>();
|
||||||
|
connect(home,SIGNAL(homePositionChanged(internals::PointLatLng)),this,SLOT(onHomePositionChanged(internals::PointLatLng)));
|
||||||
|
}
|
||||||
|
WayPointItem::WayPointItem(const internals::PointLatLng &coord,int const& altitude, const QString &description, MapGraphicItem *map,wptype type):coord(coord),reached(false),description(description),shownumber(true),isDragging(false),altitude(altitude),map(map),myType(type)
|
||||||
{
|
{
|
||||||
text=0;
|
text=0;
|
||||||
numberI=0;
|
numberI=0;
|
||||||
@ -53,8 +73,58 @@ namespace mapcontrol
|
|||||||
this->setFlag(QGraphicsItem::ItemIsMovable,true);
|
this->setFlag(QGraphicsItem::ItemIsMovable,true);
|
||||||
this->setFlag(QGraphicsItem::ItemIgnoresTransformations,true);
|
this->setFlag(QGraphicsItem::ItemIgnoresTransformations,true);
|
||||||
this->setFlag(QGraphicsItem::ItemIsSelectable,true);
|
this->setFlag(QGraphicsItem::ItemIsSelectable,true);
|
||||||
//transf.translate(picture.width()/2,picture.height());
|
SetShowNumber(shownumber);
|
||||||
// this->setTransform(transf);
|
RefreshToolTip();
|
||||||
|
RefreshPos();
|
||||||
|
if(relativeCoord.isNull())
|
||||||
|
{
|
||||||
|
HomeItem* home=NULL;
|
||||||
|
QList<QGraphicsItem *> list=map->childItems();
|
||||||
|
foreach(QGraphicsItem * obj,list)
|
||||||
|
{
|
||||||
|
HomeItem* h=qgraphicsitem_cast <HomeItem*>(obj);
|
||||||
|
if(h)
|
||||||
|
home=h;
|
||||||
|
}
|
||||||
|
double X;
|
||||||
|
double Y;
|
||||||
|
map->Projection()->offSetFromLatLngs(home->Coord(),coord,X,Y);
|
||||||
|
relativeCoord.setX(X);
|
||||||
|
relativeCoord.setY(Y);
|
||||||
|
|
||||||
|
}
|
||||||
|
HomeItem* home=NULL;
|
||||||
|
QList<QGraphicsItem *> list=map->childItems();
|
||||||
|
foreach(QGraphicsItem * obj,list)
|
||||||
|
{
|
||||||
|
HomeItem* h=qgraphicsitem_cast <HomeItem*>(obj);
|
||||||
|
if(h)
|
||||||
|
home=h;
|
||||||
|
}
|
||||||
|
connect(home,SIGNAL(homePositionChanged(internals::PointLatLng)),this,SLOT(onHomePositionChanged(internals::PointLatLng)));
|
||||||
|
}
|
||||||
|
|
||||||
|
WayPointItem::WayPointItem(const QPoint &relativeCoord, const int &altitude, const QString &description, MapGraphicItem *map):relativeCoord(relativeCoord),reached(false),description(description),shownumber(true),isDragging(false),altitude(altitude),map(map)
|
||||||
|
{
|
||||||
|
HomeItem* home=NULL;
|
||||||
|
QList<QGraphicsItem *> list=map->childItems();
|
||||||
|
foreach(QGraphicsItem * obj,list)
|
||||||
|
{
|
||||||
|
HomeItem* h=qgraphicsitem_cast <HomeItem*>(obj);
|
||||||
|
if(h)
|
||||||
|
home=h;
|
||||||
|
}
|
||||||
|
connect(home,SIGNAL(homePositionChanged(internals::PointLatLng)),this,SLOT(onHomePositionChanged(internals::PointLatLng)));
|
||||||
|
coord=map->Projection()->translate(home->Coord(),relativeCoord.x(),relativeCoord.y());
|
||||||
|
myType=relative;
|
||||||
|
text=0;
|
||||||
|
numberI=0;
|
||||||
|
picture.load(QString::fromUtf8(":/markers/images/marker.png"));
|
||||||
|
number=WayPointItem::snumber;
|
||||||
|
++WayPointItem::snumber;
|
||||||
|
this->setFlag(QGraphicsItem::ItemIsMovable,true);
|
||||||
|
this->setFlag(QGraphicsItem::ItemIgnoresTransformations,true);
|
||||||
|
this->setFlag(QGraphicsItem::ItemIsSelectable,true);
|
||||||
SetShowNumber(shownumber);
|
SetShowNumber(shownumber);
|
||||||
RefreshToolTip();
|
RefreshToolTip();
|
||||||
RefreshPos();
|
RefreshPos();
|
||||||
@ -79,10 +149,7 @@ namespace mapcontrol
|
|||||||
text=new QGraphicsSimpleTextItem(this);
|
text=new QGraphicsSimpleTextItem(this);
|
||||||
textBG=new QGraphicsRectItem(this);
|
textBG=new QGraphicsRectItem(this);
|
||||||
|
|
||||||
// textBG->setBrush(Qt::white);
|
textBG->setBrush(Qt::yellow);
|
||||||
// textBG->setOpacity(0.5);
|
|
||||||
|
|
||||||
textBG->setBrush(QColor(255, 255, 255, 128));
|
|
||||||
|
|
||||||
text->setPen(QPen(Qt::red));
|
text->setPen(QPen(Qt::red));
|
||||||
text->setPos(10,-picture.height());
|
text->setPos(10,-picture.height());
|
||||||
@ -205,6 +272,14 @@ namespace mapcontrol
|
|||||||
this->update();
|
this->update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WayPointItem::onHomePositionChanged(internals::PointLatLng homepos)
|
||||||
|
{
|
||||||
|
if(myType==relative)
|
||||||
|
{
|
||||||
|
coord=map->Projection()->translate(homepos,relativeCoord.x(),relativeCoord.y());
|
||||||
|
}
|
||||||
|
}
|
||||||
void WayPointItem::WPRenumbered(const int &oldnumber, const int &newnumber, WayPointItem *waypoint)
|
void WayPointItem::WPRenumbered(const int &oldnumber, const int &newnumber, WayPointItem *waypoint)
|
||||||
{
|
{
|
||||||
if (waypoint!=this)
|
if (waypoint!=this)
|
||||||
|
@ -33,6 +33,8 @@
|
|||||||
#include "../internals/pointlatlng.h"
|
#include "../internals/pointlatlng.h"
|
||||||
#include "mapgraphicitem.h"
|
#include "mapgraphicitem.h"
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
#include <QPoint>
|
||||||
|
|
||||||
namespace mapcontrol
|
namespace mapcontrol
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@ -46,6 +48,7 @@ class WayPointItem:public QObject,public QGraphicsItem
|
|||||||
Q_INTERFACES(QGraphicsItem)
|
Q_INTERFACES(QGraphicsItem)
|
||||||
public:
|
public:
|
||||||
enum { Type = UserType + 1 };
|
enum { Type = UserType + 1 };
|
||||||
|
enum wptype {absolute,relative};
|
||||||
/**
|
/**
|
||||||
* @brief Constructer
|
* @brief Constructer
|
||||||
*
|
*
|
||||||
@ -54,7 +57,7 @@ public:
|
|||||||
* @param map pointer to map to use
|
* @param map pointer to map to use
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
WayPointItem(internals::PointLatLng const& coord,int const& altitude,MapGraphicItem* map);
|
WayPointItem(internals::PointLatLng const& coord,int const& altitude,MapGraphicItem* map,wptype type=absolute);
|
||||||
/**
|
/**
|
||||||
* @brief Constructer
|
* @brief Constructer
|
||||||
*
|
*
|
||||||
@ -64,7 +67,9 @@ public:
|
|||||||
* @param map pointer to map to use
|
* @param map pointer to map to use
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
WayPointItem(internals::PointLatLng const& coord,int const& altitude,QString const& description,MapGraphicItem* map);
|
WayPointItem(internals::PointLatLng const& coord,int const& altitude,QString const& description,MapGraphicItem* map,wptype type=absolute);
|
||||||
|
WayPointItem(QPoint const& relativeCoord,int const& altitude,QString const& description,MapGraphicItem* map);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Returns the WayPoint description
|
* @brief Returns the WayPoint description
|
||||||
*
|
*
|
||||||
@ -149,9 +154,9 @@ protected:
|
|||||||
void mousePressEvent ( QGraphicsSceneMouseEvent * event );
|
void mousePressEvent ( QGraphicsSceneMouseEvent * event );
|
||||||
void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
|
void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
internals::PointLatLng coord;//coordinates of this WayPoint
|
internals::PointLatLng coord;//coordinates of this WayPoint
|
||||||
|
QPoint relativeCoord;
|
||||||
bool reached;
|
bool reached;
|
||||||
QString description;
|
QString description;
|
||||||
bool shownumber;
|
bool shownumber;
|
||||||
@ -167,6 +172,8 @@ private:
|
|||||||
QGraphicsRectItem* numberIBG;
|
QGraphicsRectItem* numberIBG;
|
||||||
QTransform transf;
|
QTransform transf;
|
||||||
|
|
||||||
|
wptype myType;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
/**
|
/**
|
||||||
* @brief Called when a WayPoint is deleted
|
* @brief Called when a WayPoint is deleted
|
||||||
@ -189,6 +196,8 @@ public slots:
|
|||||||
* @param waypoint a pointer to the WayPoint inserted
|
* @param waypoint a pointer to the WayPoint inserted
|
||||||
*/
|
*/
|
||||||
void WPInserted(int const& number,WayPointItem* waypoint);
|
void WPInserted(int const& number,WayPointItem* waypoint);
|
||||||
|
|
||||||
|
void onHomePositionChanged(internals::PointLatLng);
|
||||||
signals:
|
signals:
|
||||||
/**
|
/**
|
||||||
* @brief fires when this WayPoint number changes (not fired if due to a auto-renumbering)
|
* @brief fires when this WayPoint number changes (not fired if due to a auto-renumbering)
|
||||||
|
@ -178,13 +178,13 @@ OPMapGadgetWidget::OPMapGadgetWidget(QWidget *parent) : QWidget(parent)
|
|||||||
|
|
||||||
m_map->UAV->SetTrailType(UAVTrailType::ByTimeElapsed);
|
m_map->UAV->SetTrailType(UAVTrailType::ByTimeElapsed);
|
||||||
// m_map->UAV->SetTrailType(UAVTrailType::ByDistance);
|
// m_map->UAV->SetTrailType(UAVTrailType::ByDistance);
|
||||||
|
if(m_map->GPS)
|
||||||
|
{
|
||||||
m_map->GPS->SetTrailTime(uav_trail_time_list[0]); // seconds
|
m_map->GPS->SetTrailTime(uav_trail_time_list[0]); // seconds
|
||||||
m_map->GPS->SetTrailDistance(uav_trail_distance_list[1]); // meters
|
m_map->GPS->SetTrailDistance(uav_trail_distance_list[1]); // meters
|
||||||
|
|
||||||
m_map->GPS->SetTrailType(UAVTrailType::ByTimeElapsed);
|
m_map->GPS->SetTrailType(UAVTrailType::ByTimeElapsed);
|
||||||
// m_map->GPS->SetTrailType(UAVTrailType::ByDistance);
|
}
|
||||||
|
|
||||||
// **************
|
// **************
|
||||||
|
|
||||||
setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
|
setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
|
||||||
@ -269,8 +269,9 @@ OPMapGadgetWidget::OPMapGadgetWidget(QWidget *parent) : QWidget(parent)
|
|||||||
m_map->SetCurrentPosition(m_home_position.coord); // set the map position
|
m_map->SetCurrentPosition(m_home_position.coord); // set the map position
|
||||||
m_map->Home->SetCoord(m_home_position.coord); // set the HOME position
|
m_map->Home->SetCoord(m_home_position.coord); // set the HOME position
|
||||||
m_map->UAV->SetUAVPos(m_home_position.coord, 0.0); // set the UAV position
|
m_map->UAV->SetUAVPos(m_home_position.coord, 0.0); // set the UAV position
|
||||||
|
if(m_map->GPS)
|
||||||
m_map->GPS->SetUAVPos(m_home_position.coord, 0.0); // set the UAV position
|
m_map->GPS->SetUAVPos(m_home_position.coord, 0.0); // set the UAV position
|
||||||
|
m_map->WPCreate();
|
||||||
// **************
|
// **************
|
||||||
// create various context menu (mouse right click menu) actions
|
// create various context menu (mouse right click menu) actions
|
||||||
|
|
||||||
@ -700,9 +701,11 @@ void OPMapGadgetWidget::updatePosition()
|
|||||||
|
|
||||||
// *************
|
// *************
|
||||||
// set the GPS icon position on the map
|
// set the GPS icon position on the map
|
||||||
|
if(m_map->GPS)
|
||||||
|
{
|
||||||
m_map->GPS->SetUAVPos(gps_pos, gps_altitude); // set the maps GPS position
|
m_map->GPS->SetUAVPos(gps_pos, gps_altitude); // set the maps GPS position
|
||||||
m_map->GPS->SetUAVHeading(gps_heading); // set the maps GPS heading
|
m_map->GPS->SetUAVHeading(gps_heading); // set the maps GPS heading
|
||||||
|
}
|
||||||
|
|
||||||
// *************
|
// *************
|
||||||
}
|
}
|
||||||
@ -1886,6 +1889,7 @@ void OPMapGadgetWidget::onClearUAVtrailAct_triggered()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
m_map->UAV->DeleteTrail();
|
m_map->UAV->DeleteTrail();
|
||||||
|
if(m_map->GPS)
|
||||||
m_map->GPS->DeleteTrail();
|
m_map->GPS->DeleteTrail();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user