WayPointItem::WayPointItem(const internals::PointLatLng &coord,double const& altitude, const QString &description, MapGraphicItem *map) : map(map), autoreachedEnabled(true), text(NULL), textBG(NULL), numberI(NULL), numberIBG(NULL), coord(coord), reached(false), description(description), shownumber(true), isDragging(false), altitude(altitude), // sets a 10m default just in case heading(0), number(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); //transf.translate(picture.width()/2,picture.height()); // this->setTransform(transf); SetShowNumber(shownumber); RefreshToolTip(); RefreshPos(); }
WayPointItem::WayPointItem(const internals::PointLatLng &coord,double const& altitude, MapGraphicItem *map) : AbstractBaseItem(map), map(map), autoreachedEnabled(true), coord(coord), reached(false), description(""), shownumber(true), isDragging(false), altitude(altitude), heading(0) { 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); this->setZValue(4); // transf.translate(picture.width()/2,picture.height()); // this->setTransform(transf); SetShowNumber(shownumber); RefreshToolTip(); RefreshPos(); }
WayPointItem::WayPointItem(MapGraphicItem *map, bool magicwaypoint):reached(false),description(""),shownumber(true),isDragging(false),altitude(0),map(map) { relativeCoord.bearing=0; relativeCoord.distance=0; relativeCoord.altitudeRelative=0; myType=relative; if(magicwaypoint) { isMagic=true; picture.load(QString::fromUtf8(":/opmap/images/waypoint_marker3.png")); number=-1; } else { isMagic=false; number=WayPointItem::snumber; ++WayPointItem::snumber; } text=0; numberI=0; this->setFlag(QGraphicsItem::ItemIsMovable,true); this->setFlag(QGraphicsItem::ItemIgnoresTransformations,true); this->setFlag(QGraphicsItem::ItemIsSelectable,true); SetShowNumber(shownumber); RefreshToolTip(); RefreshPos(); myHome=NULL; QList<QGraphicsItem *> list=map->childItems(); foreach(QGraphicsItem * obj,list) { HomeItem* h=qgraphicsitem_cast <HomeItem*>(obj); if(h) myHome=h; }
GPSItem::GPSItem(MapGraphicItem *map, TLMapWidget *parent, QString uavPic) : mapwidget(parent), showtrail(true), showtrailline(true), trailtime(5), traildistance(50), autosetreached(true), autosetdistance(100) { this->map = map; altitude = 0; pic.load(uavPic); // Don't scale but trust the image we are given // pic=pic.scaled(50,33,Qt::IgnoreAspectRatio); localposition=map->FromLatLngToLocal(mapwidget->CurrentPosition()); this->setPos(localposition.X(),localposition.Y()); this->setZValue(4); trail=new QGraphicsItemGroup(this); trail->setParentItem(map); trailLine=new QGraphicsItemGroup(this); trailLine->setParentItem(map); this->setFlag(QGraphicsItem::ItemIgnoresTransformations,true); mapfollowtype=UAVMapFollowType::None; trailtype=UAVTrailType::ByDistance; timer.start(); connect(map,SIGNAL(childRefreshPosition()),this,SLOT(RefreshPos())); connect(map,SIGNAL(childSetOpacity(qreal)),this,SLOT(setOpacitySlot(qreal))); }
void WayPointItem::SetCoord(const internals::PointLatLng &value) { coord=value; emit WPValuesChanged(this); RefreshPos(); RefreshToolTip(); this->update(); }
inline void Messager_cls::RefreshEnvInfo() { uint8_t i; EnvRobotInfoRec_stru *pRobotInfo = NULL; RefreshPos( InfoManager.ObstacleInfo ); pRobotInfo = InfoManager.RobotInfo; for ( i = 0; i < ENVROBOT_INFOTBL_NUM; ++i ) { if ( 0 < pRobotInfo->TTLCnt ) { RefreshPos( pRobotInfo->Position ); } pRobotInfo++; } }
void GPSItem::SetUAVPos(const internals::PointLatLng &position, const int &altitude) { if(coord.IsEmpty()) lastcoord=coord; if(coord!=position) { if(trailtype==UAVTrailType::ByTimeElapsed) { if(timer.elapsed()>trailtime*1000) { TrailItem * ob=new TrailItem(position,altitude,Qt::green,map); trail->addToGroup(ob); connect(this,SIGNAL(setChildPosition()),ob,SLOT(setPosSLOT())); if(!lasttrailline.IsEmpty()) { TrailLineItem * obj=new TrailLineItem(lasttrailline,position,Qt::red,map); trailLine->addToGroup(obj); connect(this,SIGNAL(setChildLine()),obj,SLOT(setLineSlot())); } lasttrailline=position; timer.restart(); } } else if(trailtype==UAVTrailType::ByDistance) { if(qAbs(internals::PureProjection::DistanceBetweenLatLng(lastcoord,position)*1000)>traildistance) { TrailItem * ob=new TrailItem(position,altitude,Qt::green,map); trail->addToGroup(ob); connect(this,SIGNAL(setChildPosition()),ob,SLOT(setPosSLOT())); if(!lasttrailline.IsEmpty()) { TrailLineItem * obj=new TrailLineItem(lasttrailline,position,Qt::red,map); trailLine->addToGroup(obj); connect(this,SIGNAL(setChildLine()),obj,SLOT(setLineSlot())); } lasttrailline=position; lastcoord=position; } } coord=position; this->altitude=altitude; RefreshPos(); } }