34 GPSItem::GPSItem(MapGraphicItem *map, TLMapWidget *parent, QString uavPic) :
48 localposition=map->FromLatLngToLocal(mapwidget->CurrentPosition());
49 this->setPos(localposition.X(),localposition.Y());
51 trail=
new QGraphicsItemGroup(
this);
52 trail->setParentItem(map);
53 trailLine=
new QGraphicsItemGroup(
this);
54 trailLine->setParentItem(map);
55 this->setFlag(QGraphicsItem::ItemIgnoresTransformations,
true);
56 mapfollowtype=UAVMapFollowType::None;
57 trailtype=UAVTrailType::ByDistance;
59 connect(map,SIGNAL(childRefreshPosition()),
this,SLOT(RefreshPos()));
60 connect(map,SIGNAL(childSetOpacity(qreal)),
this,SLOT(setOpacitySlot(qreal)));
67 void GPSItem::paint(QPainter *painter,
const QStyleOptionGraphicsItem *option, QWidget *widget)
71 painter->drawPixmap(-pic.width()/2,-pic.height()/2,pic);
73 QRectF GPSItem::boundingRect()
const
75 return QRectF(-pic.width()/2,-pic.height()/2,pic.width(),pic.height());
84 if(trailtype==UAVTrailType::ByTimeElapsed)
86 if(timer.elapsed()>trailtime*1000)
88 TrailItem * ob=
new TrailItem(position,altitude,Qt::green,map);
89 trail->addToGroup(ob);
93 TrailLineItem * obj=
new TrailLineItem(lasttrailline,position,Qt::red,map);
94 trailLine->addToGroup(obj);
95 connect(
this,SIGNAL(
setChildLine()),obj,SLOT(setLineSlot()));
97 lasttrailline=position;
102 else if(trailtype==UAVTrailType::ByDistance)
106 TrailItem * ob=
new TrailItem(position,altitude,Qt::green,map);
107 trail->addToGroup(ob);
111 TrailLineItem * obj=
new TrailLineItem(lasttrailline,position,Qt::red,map);
112 trailLine->addToGroup(obj);
113 connect(
this,SIGNAL(
setChildLine()),obj,SLOT(setLineSlot()));
115 lasttrailline=position;
129 void GPSItem::SetUAVHeading(
const qreal &value)
131 if(mapfollowtype==UAVMapFollowType::CenterAndRotateMap)
136 if (this->rotation() != value)
137 this->setRotation(value);
142 int GPSItem::type()
const
150 localposition=map->FromLatLngToLocal(
coord);
151 this->setPos(localposition.
X(),localposition.
Y());
161 void GPSItem::SetTrailType(
const UAVTrailType::Types &value)
164 if(trailtype==UAVTrailType::ByTimeElapsed)
167 void GPSItem::SetShowTrail(
const bool &value)
170 trail->setVisible(value);
173 void GPSItem::SetShowTrailLine(
const bool &value)
176 trailLine->setVisible(value);
178 void GPSItem::DeleteTrail()
const
180 foreach(QGraphicsItem*
i,trail->childItems())
182 foreach(QGraphicsItem* i,trailLine->childItems())
188 pow(this->altitude - altitude, 2));
191 void GPSItem::SetUavPic(QString UAVPic)
193 pic.load(
":/uavs/images/"+UAVPic);
A graphicsItem representing a WayPoint.
A graphicsItem representing a WayPoint.