35 #include <QMetaObject>
42 configuration(config),UAV(nullptr),GPS(nullptr),Home(nullptr),followmouse(true),
43 compassRose(nullptr),windCompass(nullptr),showuav(false),showhome(false),
44 diagTimer(nullptr),diagGraphItem(nullptr),showDiag(false),overlayOpacity(1),
47 setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
48 this->setScene(
new QGraphicsScene(
this));
53 scene()->addItem(map);
55 Home->setParentItem(map);
58 setStyleSheet(
"QToolTip {font-size:8pt; color:blue;opacity: 223; padding:2px; border-width:2px; border-style:solid; border-color: rgb(170, 170, 127);border-radius:4px }");
72 this->setMouseTracking(followmouse);
75 QPixmapCache::setCacheLimit(64*1024);
85 if(diagGraphItem!=
nullptr)
88 diagGraphItem=
nullptr;
90 if(diagTimer!=
nullptr)
104 diagTimer=
new QTimer();
105 connect(diagTimer,SIGNAL(timeout()),
this,SLOT(diagRefresh()));
106 diagTimer->start(500);
110 GPS->setParentItem(map);
120 UAV->SetUavPic(UAVPic);
122 GPS->SetUavPic(UAVPic);
130 ret->setOpacity(overlayOpacity);
139 ret->setOpacity(overlayOpacity);
157 ret->setOpacity(overlayOpacity);
166 ret->setOpacity(overlayOpacity);
175 ret->setOpacity(overlayOpacity);
181 if(value &&
UAV==
nullptr)
184 UAV->setParentItem(map);
187 UAV->setOpacity(overlayOpacity);
202 Home->setVisible(value);
208 scene()->setSceneRect(
209 QRect(QPoint(0, 0), event->size()));
210 QGraphicsView::resizeEvent(event);
213 compassRose->setScale(0.1+0.05*(qreal)(event->size().width())/1000*(qreal)(
event->size().height())/600);
215 windCompass->setPos(70 - windCompass->boundingRect().width()/2, this->size().height() - 70 - windCompass->boundingRect().height()/2);
216 windspeedTxt->setPos(73 - windCompass->boundingRect().width()/2 * windCompass->scale(), this->size().height() - windCompass->boundingRect().height()/2 * windCompass->scale() - 30);
221 QSize TLMapWidget::sizeHint()
const
223 return map->sizeHint();
228 connect(scene(),SIGNAL(sceneRectChanged(QRectF)),map,SLOT(resize(QRectF)));
230 QGraphicsView::showEvent(event);
245 foreach(QGraphicsItem*
i,this->items())
260 return currentmouseposition;
265 QGraphicsView::mouseMoveEvent(event);
266 QPointF p=
event->pos();
267 p=map->mapFromParent(p);
268 currentmouseposition=map->FromLocalToLatLng(p.x(),p.y());
276 item->setParentItem(map);
277 int position=item->Number();
285 item->SetShowNumber(
false);
286 item->setParentItem(map);
293 item->setParentItem(map);
294 int position=item->Number();
303 item->setParentItem(map);
304 int position=item->Number();
314 item->setParentItem(map);
315 int position=item->Number();
325 item->setParentItem(map);
326 int position=item->Number();
335 item->SetNumber(position);
337 item->setParentItem(map);
345 item->SetNumber(position);
347 item->setParentItem(map);
355 item->SetNumber(position);
357 item->setParentItem(map);
375 item->SetNumber(position);
377 item->setParentItem(map);
388 item->SetNumber(position);
390 item->setParentItem(map);
404 foreach(QGraphicsItem*
i,map->childItems())
409 if(w->Number()==number)
421 foreach(QGraphicsItem*
i,map->childItems())
426 if(w->Number()==number)
437 foreach(QGraphicsItem*
i,map->childItems())
443 w->setVisible(value);
450 foreach(QGraphicsItem*
i,map->childItems())
466 foreach(QGraphicsItem*
i,map->childItems())
482 foreach(QGraphicsItem*
i,map->childItems())
499 foreach(QGraphicsItem*
i,scene()->selectedItems())
510 item->SetNumber(newnumber);
523 void TLMapWidget::diagRefresh()
527 if(diagGraphItem==
nullptr)
529 diagGraphItem=
new QGraphicsTextItem();
530 scene()->addItem(diagGraphItem);
531 diagGraphItem->setPos(10,100);
532 diagGraphItem->setZValue(3);
533 diagGraphItem->setFlag(QGraphicsItem::ItemIsMovable,
true);
534 diagGraphItem->setDefaultTextColor(Qt::yellow);
539 if(diagGraphItem!=
nullptr)
541 delete diagGraphItem;
542 diagGraphItem=
nullptr;
553 if(value && !compassRose)
555 compassRose=
new QGraphicsSvgItem(QString::fromUtf8(
":/markers/images/compass.svg"));
556 compassRose->setScale(0.1+0.05*(qreal)(this->size().width())/1000*(qreal)(this->size().height())/600);
557 compassRose->setFlag(QGraphicsItem::ItemIsMovable,
false);
558 compassRose->setFlag(QGraphicsItem::ItemIsSelectable,
false);
559 scene()->addItem(compassRose);
560 compassRose->setTransformOriginPoint(compassRose->boundingRect().width()/2,compassRose->boundingRect().height()/2);
561 compassRose->setPos(55-compassRose->boundingRect().width()/2,55-compassRose->boundingRect().height()/2);
562 compassRose->setZValue(3);
563 compassRose->setOpacity(0.7);
565 if(!value && compassRose)
578 if (value && !windCompass) {
579 windCompass=
new QGraphicsSvgItem(QString::fromUtf8(
":/markers/images/wind_compass.svg"));
580 windCompass->setScale(120/windCompass->boundingRect().width());
581 windCompass->setFlag(QGraphicsItem::ItemIsMovable,
false);
582 windCompass->setFlag(QGraphicsItem::ItemIsSelectable,
false);
583 windCompass->setTransformOriginPoint(windCompass->boundingRect().width()/2, windCompass->boundingRect().height()/2);
584 windCompass->setZValue(compassRose->zValue() + 1);
585 windCompass->setOpacity(0.70);
586 scene()->addItem(windCompass);
589 windspeedTxt =
new QGraphicsTextItem();
590 windspeedTxt->setDefaultTextColor(QColor(
"Black"));
591 windspeedTxt->setZValue(compassRose->zValue() + 2);
593 scene()->addItem(windspeedTxt);
596 double dummyWind[3] = {0,0,0};
598 windCompass->setPos(70 - windCompass->boundingRect().width()/2, this->size().height() - 70 - windCompass->boundingRect().height()/2);
599 windspeedTxt->setPos(73 - windCompass->boundingRect().width()/2 * windCompass->scale(), this->size().height() - windCompass->boundingRect().height()/2 * windCompass->scale() - 30);
602 if (!value && windCompass) {
611 double windAngle_D = atan2(windVelocity_NED[1], windVelocity_NED[0]) *
RAD2DEG;
613 windAngle_D = windAngle_D + 360;
615 if (windspeedTxt != NULL)
616 windspeedTxt->setPlainText(QString(
"%1%2 @ %3m/s\nsink: %4m/s").arg(windAngle_D, 3,
'f', 0, QChar(0x30)).arg(QChar(0x00B0)).arg(sqrt(pow(windVelocity_NED[0], 2) + pow(windVelocity_NED[1], 2)), 3,
'f', 1).arg(windVelocity_NED[2], 0,
'f', 1));
618 if (windCompass != NULL)
619 windCompass->setRotation(windAngle_D);
625 map->setOverlayOpacity(value);
626 overlayOpacity=value;
631 map->mapRotate(value);
632 if(compassRose && (compassRose->rotation() != value)) {
633 compassRose->setRotation(value);
635 if(windCompass && (windCompass->rotation() != value)) {
636 windCompass->setRotation(value);
647 this->scene()->clearSelection();
650 wp->setSelected(
true);
658 list=this->scene()->selectedItems();
659 foreach(QGraphicsItem* item,list)
665 if(wplist.length()>0)
A graphicsItem representing a WayPoint.
A class that centralizes most of the mapcontrol configurations.
The WayPointCurve class draws an arc between two graphics items of a given radius and direction of cu...
The main graphicsItem used on the widget, contains the map and map logic.
A QGraphicsItem representing a WayPoint.
A QGraphicsItem representing the UAV.