From 511278ec5b5bbada13f31121cd11d34b49e6cb28 Mon Sep 17 00:00:00 2001 From: pip Date: Sat, 12 Jun 2010 19:12:47 +0000 Subject: [PATCH] Added GSC and UAV map icon, but still have an icon display bug on the google maps. git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@751 ebee16cc-31ac-478f-84a7-5cbb03baadba --- .../src/libs/qmapcontrol/src/mapcontrol.cpp | 9 +- ground/src/plugins/map/images/gsc.png | Bin 0 -> 1398 bytes ground/src/plugins/map/images/uav.png | Bin 0 -> 1201 bytes ground/src/plugins/map/images/waypoint.png | Bin 0 -> 1176 bytes ground/src/plugins/map/map.pro | 41 +-- ground/src/plugins/map/map.qrc | 7 + ground/src/plugins/map/mapgadgetwidget.cpp | 335 ++++++++++++++---- ground/src/plugins/map/mapgadgetwidget.h | 28 +- 8 files changed, 323 insertions(+), 97 deletions(-) create mode 100644 ground/src/plugins/map/images/gsc.png create mode 100644 ground/src/plugins/map/images/uav.png create mode 100644 ground/src/plugins/map/images/waypoint.png create mode 100644 ground/src/plugins/map/map.qrc diff --git a/ground/src/libs/qmapcontrol/src/mapcontrol.cpp b/ground/src/libs/qmapcontrol/src/mapcontrol.cpp index 8df71f761..d93ed7525 100644 --- a/ground/src/libs/qmapcontrol/src/mapcontrol.cpp +++ b/ground/src/libs/qmapcontrol/src/mapcontrol.cpp @@ -292,14 +292,17 @@ namespace qmapcontrol layermanager->scrollView(offset); pre_click_px = QPoint(evnt->x(), evnt->y()); } - else if (mousepressed && mymousemode == Dragging) + else + if (mousepressed && mymousemode == Dragging) { current_mouse_pos = QPoint(evnt->x(), evnt->y()); } - // emit(mouseEventCoordinate(evnt, clickToWorldCoordinate(evnt->pos()))); + + emit mouseEventCoordinate(evnt, clickToWorldCoordinate(evnt->pos())); // cathy .. uncommented to produce mouse move events update(); - // emit(mouseEventCoordinate(evnt, clickToWorldCoordinate(evnt->pos()))); + +// emit mouseEventCoordinate(evnt, clickToWorldCoordinate(evnt->pos())); } // added by cathy diff --git a/ground/src/plugins/map/images/gsc.png b/ground/src/plugins/map/images/gsc.png new file mode 100644 index 0000000000000000000000000000000000000000..8c569c441fb4773c1ad40d5d7bbc2f2d08df7947 GIT binary patch literal 1398 zcmV-+1&R8JP)$@(#6Ha!otG9z`(q`ytufyw6wIau&}PKuBxi4tgNg+KtR#a(ap`x&d$#4?Ck67 z>$G zDl6BJkI8{gWOP>ktGgXctg=0bDi zhKk30e0-U|;%=_*Xr}IAp6pwe>s5~FPKD@5eC9Y>-=M_gc(?I#ukdWB?q;CvV3_M! zkm^&1=uCd*Ms?*tY~ws+;W=L5g^b3Xot>x3<%7TSeYo*=vG8%K?`xv%Wt!|>lImEA z=uv^^OLyf&ZsR^>;WSI#gp9?0etxdc=Z(koh`{rLy7GLp@OG^4aHQ^Oo$Os^fL zR)gnIdge)Stc`UTZZUW zedbPd<+se^v&i7D!``aC+@`tOqO{kYuhp5V z(v_spke|(qn9Guyz)w$4+}zyR+1b_A)yc`p92^`uIXOE!J2y8sIj!WC00001bW%=J z06^y0W&i*I>`6pHRCwBBU|?YQ^Yl9T@}EXpe`At|G;rfRGU zmU=4s?D>nAuU@}-`|kaRkDoq&`TEU9>pNKLsMytO*Kgdsb^FfUd-oqaeDwHA;u9MK zh?MxT<0np@I(_Esx$_q;Ub=jxFX;$WYOcz*?K^hv+P!D*zWoOd9%}6CKMa?WTE1fC zs?}@Ou3NuhUl}1Ca_>oicUW^cgc} z&5n(WPv}cZPD!1k4wX`GYwzgns_X9QZ2(#{VdA98t!hvyo$8wG+Pb{@f`-Q8rqZ(J zmWozYsFY1sc1~_yenDXo$O$Rs6_r)eP$}bx$f)QTkVT0gi_+3FGG!oA&c-gTZtfnQ zUfw>we*OW0LBS!Rl3`#edsSl{H5mzBZGHg&2Y5l|RAfu$_1%&o1hjX}W1225Go z+Cd`4RNP1m29(9kBqUTMCCn{AGKQi?GAgJ*N>$p}1SqAaAOYq}s;UEl6qv254|1ZW zvb>fm5U8n%YHN##N~?o7sygcGx(u>%^1>n@z^|aFsHh~YtRf{1RHv@0!N9}I2L=2B z0)j%qBBEkIw@XRO$TG08b8unb%707*qoM6N<$ Ef@$x|C;$Ke literal 0 HcmV?d00001 diff --git a/ground/src/plugins/map/images/uav.png b/ground/src/plugins/map/images/uav.png new file mode 100644 index 0000000000000000000000000000000000000000..f9e14fd7a13d0f6a72819b54c87cebe0c377854f GIT binary patch literal 1201 zcmeAS@N?(olHy`uVBq!ia0vp^;y^6Q!3-p4*|g3CQaUBB5hcz=sfi_-`FRQ`3|8jCa3=IBTTK>1O`EP4`-q-hFOw8eo zj1%eUCu?i}`}+QmkAF~D_^Q18V@k@86k4M>*u8W4Ob$GR{spFRCD>k*ulXfjWwzFvRuKY~b zTq!SGF1FMAewe+x^L^%w*;lylh}&hgK8&tt{MGmT?TVJvy*Cr%7VP_0m8zC+c7BgT z?e*uW;YW`p7N*B_)OytD+Zr#sm(s3LkgoT!G|_)givQm@ee?h4Z9jgu-8ub?xR7$h U@z&cWdKuQbRaP@AWC&^ATls9Fd#8FIx;vqF*G18FfcGM(W@YW00007bV*G` z2igV<5;ZYas%m2Z000SaNLh0L01EH`01EH{Laa2H00004XF*Lt006O%3;baP00081 zP)t-s|NsB~{{H9X-rw5Ny}PyH-POmyu*1BrtEi&e*3Pb_kgA}Iz`3gF=jPki&#R!0 ztDlR(xvKQ?@Z8tXucMTyoQc4;sQvx@?&|2)zOurVg2a$~#gl{E!o2hH^4!+Wte=jl zor%A;r}Ogf@$vD$tDUxcR>ycu-g`>wdP&%EO2KGMv~^^#os+AdjHsN3zqY3F@$k5o zcg=)I@s&~hl~ezbQ~!)p|A$lhfK%*sPqtb=lxR}Dw50U%@A>)pxTcWMj79vRP5+)v z|CmkxlTH7PP5+2Z|AS5ceNFXsOtn@z!LY03-`BW`PWGin|D{L&phy3kNB@{d|B^@l zj7R^5NB@CG|9nU5Z9}qgUc<7K&Xzv^uR;H+LI0&e|DZwtnnC}RLH~|H|A|5WgF*j& zLHc$q?2a$&hcE1cFYJ6T>~=55U@5bR zbhoR9zMo3ir775;DcGAS*p?~Sk}24XDcFZ8*n=t9eks^_Db{i+qF5-&v!~b7!?dGr z#GNz4lq18CBg2a$!-pfogCoO!Bg1(k!*wIWaU-^7B9dS`?C9pFpL@EdX|szVvW6Y9 zf*rDc9kO~IvUVM^aUHU49j|8{kysY?XZ5N?x z7oB4lg;X1weqrL_-Jg|mm4#D?Z!v{s6^djNfLRc8PZM}pD5aHv(apW1n0JeQR(fbU zhjmV;ntt8c(M;ARO#lD@0d!JMQvg8b*k%9#0WC>HK~#9!V_*OS@$RZD1~kxp=kC4x z4<0_UM;5$v`O4L6*Kgdsb=wdjcg^Mb1?K^kv-m`b#{sRXO9X@hY z94fkM^_sQo)^FIjY4et?+qUn3+CF>E+a7zP-HMMTAfFopT}1q87O qb8>O>@L~$Hvaxe8U + + images/uav.png + images/gsc.png + images/waypoint.png + + diff --git a/ground/src/plugins/map/mapgadgetwidget.cpp b/ground/src/plugins/map/mapgadgetwidget.cpp index 0169b653e..2f312aab0 100644 --- a/ground/src/plugins/map/mapgadgetwidget.cpp +++ b/ground/src/plugins/map/mapgadgetwidget.cpp @@ -30,27 +30,50 @@ #include #include "extensionsystem/pluginmanager.h" +// ************************************************************************************* +// constructor + MapGadgetWidget::MapGadgetWidget(QWidget *parent) : QWidget(parent) { int size = 256; - gscButton = 0; // added by cathy - uavButton = 0; // added by cathy + gscButton = NULL; + uavButton = NULL; - follow_uav = false; // added by cathy + follow_uav = false; + + gsc_pixmap.load(QString::fromUtf8(":/map/images/gsc.png")); + uav_pixmap.load(QString::fromUtf8(":/map/images/uav.png")); + waypoint_pixmap.load(QString::fromUtf8(":/map/images/waypoint.png")); +// waypoint_pixmap.load(QCoreApplication::applicationDirPath() + "/images/waypoint.png"); + + // test + if (gsc_pixmap.isNull()) QMessageBox::warning(this, tr("Image Error"), tr("Missing ") + QString::fromUtf8(":/map/images/gsc.png")); + if (uav_pixmap.isNull()) QMessageBox::warning(this, tr("Image Error"), tr("Missing ") + QString::fromUtf8(":/map/images/uav.png")); + if (waypoint_pixmap.isNull()) QMessageBox::warning(this, tr("Image Error"), tr("Missing ") + QString::fromUtf8(":/map/images/waypoint.png")); + + // test + gsc_pixmap.save(QCoreApplication::applicationDirPath() + "/images/gsc2.png", "PNG"); + + // Get required UAVObjects + ExtensionSystem::PluginManager* pm = ExtensionSystem::PluginManager::instance(); + UAVObjectManager* objManager = pm->getObject(); + m_positionActual = PositionActual::GetInstance(objManager); m_mc = new MapControl(QSize(size, size)); setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); +// setMouseTracking(true); + m_mc->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); m_mc->setMinimumSize(64, 64); m_mc->showScale(true); - m_mc->showLatLon(true); // added by cathy + m_mc->showLatLon(true); m_osmAdapter = new OSMMapAdapter(); - m_googleSatAdapter = new GoogleSatMapAdapter(); m_googleAdapter = new GoogleMapAdapter(); + m_googleSatAdapter = new GoogleSatMapAdapter(); m_yahooAdapter = new YahooMapAdapter(); m_osmLayer = new MapLayer("OpenStreetMap", m_osmAdapter); @@ -58,23 +81,46 @@ MapGadgetWidget::MapGadgetWidget(QWidget *parent) : QWidget(parent) m_googleSatLayer = new MapLayer("Google Sat", m_googleSatAdapter); m_yahooLayer = new MapLayer("Yahoo", m_yahooAdapter); + // gsc and uav position layer + m_positionLayer = new GeometryLayer("PositionsLayer", m_osmAdapter); + + // Waypoint layer + m_wayPointLayer = new GeometryLayer("WayPointsLayer", m_osmAdapter); + m_osmLayer->setVisible(true); m_googleLayer->setVisible(false); m_googleSatLayer->setVisible(false); m_yahooLayer->setVisible(false); + m_positionLayer->setVisible(true); + m_wayPointLayer->setVisible(true); m_mc->addLayer(m_osmLayer); m_mc->addLayer(m_googleLayer); m_mc->addLayer(m_googleSatLayer); m_mc->addLayer(m_yahooLayer); + m_mc->addLayer(m_wayPointLayer); + m_mc->addLayer(m_positionLayer); + + PositionActual::DataFields data = m_positionActual->getData(); // get current position data + + heading = data.Heading; + + addCompass(QPointF(100, 100), 200); + + // create and add the GSC icon + gscPoint = new ImagePoint(data.Longitude, data.Latitude, &gsc_pixmap, "GSC", Point::Middle); + m_positionLayer->addGeometry(gscPoint); + connect(gscPoint, SIGNAL(geometryClicked(Geometry*, QPoint)), this, SLOT(gsc_uav_ClickEvent(Geometry*, QPoint))); + + // create and add the UAV icon + uavPoint = new ImagePoint(data.Longitude, data.Latitude, &uav_pixmap, "UAV", Point::Middle); + m_positionLayer->addGeometry(uavPoint); + connect(uavPoint, SIGNAL(geometryClicked(Geometry*, QPoint)), this, SLOT(gsc_uav_ClickEvent(Geometry*, QPoint))); addUserControls(); - gscPosition.setX(5.718888888888); // longitude - gscPosition.setY(58.963333333333); // latitude - - m_mc->setView(gscPosition); - m_mc->setZoom(10); + m_mc->setView(gscPoint->coordinate()); + m_mc->setZoom(2); m_mc->updateRequestNew(); QVBoxLayout *layout = new QVBoxLayout; @@ -83,13 +129,9 @@ MapGadgetWidget::MapGadgetWidget(QWidget *parent) : QWidget(parent) layout->addWidget(m_mc); setLayout(layout); - // Get required UAVObjects - ExtensionSystem::PluginManager* pm = ExtensionSystem::PluginManager::instance(); - UAVObjectManager* objManager = pm->getObject(); - m_positionActual = PositionActual::GetInstance(objManager); + connect(m_mc, SIGNAL(mouseEventCoordinate(const QMouseEvent*, const QPointF)), this, SLOT(coordinateEvent(const QMouseEvent*, const QPointF))); - // added by cathy .. slot for receiving mouse click Coordinate events -// connect(m_mc, SIGNAL(mouseEventCoordinate(const QMouseEvent*, const QPointF)), this, SLOT(coordinateClicked(const QMouseEvent*, const QPointF))); // cmoss +// connect(m_wayPointLayer, SIGNAL(geometryClicked(Geometry*, QPoint)), this, SLOT(wayPointClickEvent(Geometry*, QPoint))); m_updateTimer = new QTimer(); m_updateTimer->setInterval(250); @@ -97,11 +139,16 @@ MapGadgetWidget::MapGadgetWidget(QWidget *parent) : QWidget(parent) m_updateTimer->start(); } +// ************************************************************************************* +// destructor + MapGadgetWidget::~MapGadgetWidget() { // Do nothing } +// ************************************************************************************* + void MapGadgetWidget::setZoom(int value) { m_mc->setZoom(value); @@ -114,19 +161,47 @@ void MapGadgetWidget::setPosition(QPointF pos) m_mc->updateRequestNew(); } -void MapGadgetWidget::updatePosition() -{ - if (follow_uav) - { - PositionActual::DataFields data = m_positionActual->getData(); - setPosition(QPointF(data.Longitude, data.Latitude)); - } -} - void MapGadgetWidget::setMapProvider(QString provider) { - foreach(QString layerName, m_mc->layers()) - m_mc->layer(layerName)->setVisible(layerName == provider); + foreach (QString layerName, m_mc->layers()) + { + Layer *layer = m_mc->layer(layerName); + MapAdapter *ma = (MapAdapter*)layer->mapadapter(); + + bool visible = layerName == provider; + + if (layerName == "WayPointsLayer" || layerName == "PositionsLayer") + { // leave the way points & positions layers visible + continue; + } + + layer->setVisible(visible); + + if (visible) + { // move the geomtery layers over to the selected map + m_positionLayer->setMapAdapter(ma); + m_wayPointLayer->setMapAdapter(ma); + } + } + + m_positionLayer->setVisible(true); + m_wayPointLayer->setVisible(true); + + m_mc->updateRequestNew(); +} + +// ************************************************************************************* + +void MapGadgetWidget::updatePosition() +{ + PositionActual::DataFields data = m_positionActual->getData(); // get current position data + + heading = data.Heading; // save the current UAV heading + + uavPoint->setCoordinate(QPointF(data.Longitude, data.Latitude)); // move the UAV icon + + if (follow_uav) + setPosition(uavPoint->coordinate()); // center the map onto the UAV } void MapGadgetWidget::resizeEvent(QResizeEvent *event) @@ -136,34 +211,34 @@ void MapGadgetWidget::resizeEvent(QResizeEvent *event) QWidget::resizeEvent(event); } +// ************************************************************************************* + void MapGadgetWidget::addUserControls() { // create the user controls - // cathy - gscButton = new QPushButton("GCS"); + gscButton = new QPushButton(tr("GCS")); gscButton->setMinimumWidth(50); gscButton->setMaximumWidth(50); - gscButton->setToolTip("Jump too ground station control"); + gscButton->setToolTip(tr("Center onto ground station control")); connect(gscButton, SIGNAL(clicked(bool)), this, SLOT(gscButtonClick())); - // cathy - uavButton = new QPushButton("UAV"); + uavButton = new QPushButton(tr("UAV")); uavButton->setMinimumWidth(50); uavButton->setMaximumWidth(50); uavButton->setCheckable(true); - uavButton->setToolTip("Stay centered on the UAV"); + uavButton->setToolTip(tr("Stay centered on the UAV")); connect(uavButton, SIGNAL(clicked(bool)), this, SLOT(uavButtonClick(bool))); QPushButton* zoomin = new QPushButton("+"); zoomin->setMinimumWidth(50); zoomin->setMaximumWidth(50); - zoomin->setToolTip("Zoom in"); + zoomin->setToolTip(tr("Zoom in")); connect(zoomin, SIGNAL(clicked(bool)), m_mc, SLOT(zoomIn())); QPushButton* zoomout = new QPushButton("-"); zoomout->setMinimumWidth(50); zoomout->setMaximumWidth(50); - zoomout->setToolTip("Zoom out"); + zoomout->setToolTip(tr("Zoom out")); connect(zoomout, SIGNAL(clicked(bool)), m_mc, SLOT(zoomOut())); // add zoom buttons to the layout of the MapControl @@ -180,63 +255,181 @@ void MapGadgetWidget::addUserControls() m_mc->setLayout(innerlayout); } -void MapGadgetWidget::gscButtonClick() // added by cathy +// ************************************************************************************* + +void MapGadgetWidget::gscButtonClick() { follow_uav = false; uavButton->setChecked(follow_uav); - // jump straight too the GSC location - setPosition(gscPosition); + setPosition(gscPoint->coordinate()); // center the map onto the ground station } -void MapGadgetWidget::uavButtonClick(bool checked) // added by cathy +// ************************************************************************************* + +void MapGadgetWidget::uavButtonClick(bool checked) { follow_uav = checked; -// follow_uav = uavButton->isChecked(); if (follow_uav) - { -// PositionActual::DataFields data = m_positionActual->getData(); -// setPosition(QPointF(data.Longitude, data.Latitude)); + { // immediately center the map onto the UAV .. rather than waiting for the timer to it +// PositionActual::DataFields data = m_positionActual->getData(); // get the current position data +// heading = data.Heading; // save the current UAV heading +// uavPoint->setCoordinate(QPointF(data.Longitude, data.Latitude)); // move the UAV icon +// setPosition(uavPoint->coordinate()); // center the map on the UAV } } -/* -// added by cathy .. comes here when the user mouse clicks on the map -void MapGadgetWidget::coordinateClicked(const QMouseEvent * evnt, const QPointF coordinate) // cmoss -{ - if (evnt->type() == QEvent::MouseButtonPress && evnt->buttons() == Qt::LeftButton) - { - QString coord_str = "lat " + QString::number(coordinate.y(), 'f', 6) + ", lon " + QString::number(coordinate.x(), 'f', 6); +// ************************************************************************************* - qDebug() << coordinate << ": " << evnt->x() << " / " << evnt->y() << " / " << coord_str; - - QMessageBox::information(this, "Coordinate Clicked", coord_str); - } -} -*/ -// added by cathy .. comes here when the user mouse clicks on an added geometry feature (ie, way points etc) -void MapGadgetWidget::geometryClicked(Geometry* geom, QPoint) // cmoss +void MapGadgetWidget::coordinateEvent(const QMouseEvent * evnt, const QPointF coordinate) // cmoss { - qDebug() << "parent: " << geom->parentGeometry(); - qDebug() << "Element clicked: " << geom->name(); - if (geom->hasClickedPoints()) + QString coord_str = "lat " + QString::number(coordinate.y(), 'f', 6) + ", lon " + QString::number(coordinate.x(), 'f', 6); + + if (evnt->type() == QEvent::MouseButtonPress) + { // mouse click event + if (evnt->buttons() == Qt::RightButton) { - QList pp = geom->clickedPoints(); - qDebug() << "number of child elements: " << pp.size(); - for (int i=0; iname(), pp.at(i)->name()); - } + qDebug() << coordinate << ": " << evnt->x() << " / " << evnt->y() << " / " << coord_str; + + QMessageBox::information(this, "Coordinate Clicked", coord_str); + } + } + else + { // mouse move event + qDebug() << coordinate << ": " << evnt->x() << " / " << evnt->y() << " / " << coord_str; + } +} + +// ************************************************************************************* +// comes here when the user mouse clicks on the GSC or the UAV + +void MapGadgetWidget::gsc_uav_ClickEvent(Geometry* geom, QPoint) +{ + qDebug() << "parent: " << geom->parentGeometry(); + qDebug() << "Element clicked: " << geom->name(); + + if (geom->hasClickedPoints()) + { + QList pp = geom->clickedPoints(); + + qDebug() << "number of child elements: " << pp.size(); + + for (int i=0; iname(), pp.at(i)->name()); + } + } + else + if (geom->GeometryType == "Point") + { + if (geom->name() == "UAV") + { + QMessageBox::information(this, geom->name(), tr("The UAV location")); } else - if (geom->GeometryType == "Point") + if (geom->name() == "GSC") { - QMessageBox::information(this, geom->name(), "just a point"); + QMessageBox::information(this, geom->name(), tr("The GSC location")); } + else + QMessageBox::information(this, geom->name(), tr("just a point")); + } } -// added by cathy +// ************************************************************************************* +// comes here when the user mouse clicks on a waypoint + +void MapGadgetWidget::wayPointClickEvent(Geometry* geom, QPoint) +{ + qDebug() << "parent: " << geom->parentGeometry(); + qDebug() << "Element clicked: " << geom->name(); + + if (geom->hasClickedPoints()) + { + QList pp = geom->clickedPoints(); + + qDebug() << "number of child elements: " << pp.size(); + + for (int i=0; iname(), pp.at(i)->name()); + } + } + else + if (geom->GeometryType == "Point") + { + QMessageBox::information(this, geom->name(), tr("just a point")); + } +} + +// ************************************************************************************* +// add a way point + +void MapGadgetWidget::addWayPoint(QPointF pos, QString name) +{ + if (waypoint_pixmap.isNull()) return; + + ImagePoint *waypoint = new ImagePoint(pos.x(), pos.y(), &waypoint_pixmap, name, qmapcontrol::Point::BottomRight); +// waypoint->setBaselevel(0); + connect(waypoint, SIGNAL(geometryClicked(Geometry *, QPoint)), this, SLOT(wayPointClickEvent(Geometry *, QPoint))); + + m_wayPointLayer->addGeometry(waypoint); +} + +// ************************************************************************************* +// add the compass + +void MapGadgetWidget::addCompass(QPointF pos, int size, QString name) +{ + + return; + +// if (compass_background_pixmap.isNull()) + { // create the compass background image + QImage image(size, size, QImage::Format_ARGB32_Premultiplied); + if (image.isNull()) return; + + image.fill(QColor(0, 0, 0, 0).rgba()); + + QPainter painter(&image); + painter.setRenderHints(QPainter::SmoothPixmapTransform | QPainter::Antialiasing | QPainter::HighQualityAntialiasing | QPainter::TextAntialiasing, true); + painter.setFont(font()); + + QPen pen = QPen(Qt::NoPen); + pen.setStyle(Qt::SolidLine); + pen.setWidth(1); + pen.setBrush(Qt::black); + painter.setPen(pen); + + QRadialGradient gradient(size / 2, size / 2, size / 2); + gradient.setColorAt(0.0, QColor(0, 0, 0, 0)); + gradient.setColorAt(0.05, QColor(0, 0, 0, 160)); + gradient.setColorAt(1.0, QColor(0, 0, 0, 160)); + +// QGradient gradient = QLinearGradient(0, 0, 0, 1); + gradient.setCoordinateMode(QGradient::ObjectBoundingMode); + gradient.setSpread(QGradient::PadSpread); + painter.setBrush(gradient); + +// painter.drawRect(image.rect()); + painter.drawEllipse(image.rect()); + + compass_background_pixmap = QPixmap::fromImage(image); + } + +// ImagePoint *compass = new ImagePoint(pos.x(), pos.y(), &compass_background_pixmap, name, qmapcontrol::Point::Middle); +// connect(compass, SIGNAL(geometryClicked(Geometry *, QPoint)), this, SLOT(compassClickEvent(Geometry *, QPoint))); + + m_compassImageOverlay = new FixedImageOverlay(0, 0, size, size, &compass_background_pixmap, "compass_background"); +// m_compassImageOverlay->setBaselevel(0); +// m_compassImageOverlay->setPen(); + + m_positionLayer->addGeometry(m_compassImageOverlay); +} + +// ************************************************************************************* + void MapGadgetWidget::keyPressEvent(QKeyEvent* event) { if (event->key() == Qt::Key_Escape) // ESC @@ -286,3 +479,5 @@ void MapGadgetWidget::keyPressEvent(QKeyEvent* event) qDebug() << event->key() << endl; } } + +// ************************************************************************************* diff --git a/ground/src/plugins/map/mapgadgetwidget.h b/ground/src/plugins/map/mapgadgetwidget.h index 78f1d32b0..4bcde1bc2 100644 --- a/ground/src/plugins/map/mapgadgetwidget.h +++ b/ground/src/plugins/map/mapgadgetwidget.h @@ -33,6 +33,8 @@ #include "uavobjects/uavobjectmanager.h" #include "uavobjects/positionactual.h" +#include + using namespace qmapcontrol; class MapGadgetWidget : public QWidget @@ -47,8 +49,9 @@ public: void setMapProvider(QString provider); public slots: -// void coordinateClicked(const QMouseEvent* evnt, const QPointF coordinate); // added by cathy - void geometryClicked(Geometry* geom, QPoint coord_px); // added by cathy + void coordinateEvent(const QMouseEvent* evnt, const QPointF coordinate); // added by cathy + void gsc_uav_ClickEvent(Geometry* geom, QPoint coord_px); // added by cathy + void wayPointClickEvent(Geometry* geom, QPoint coord_px); // added by cathy void gscButtonClick(); // added by cathy void uavButtonClick(bool checked); // added by cathy @@ -65,6 +68,8 @@ private: bool follow_uav; // true if the map is to stay centered on the UAV + double heading; // compass/uav heading + MapControl *m_mc; MapAdapter *m_osmAdapter; @@ -77,14 +82,29 @@ private: Layer *m_googleSatLayer; Layer *m_yahooLayer; + Layer *m_positionLayer; + Layer *m_wayPointLayer; + + FixedImageOverlay *m_compassImageOverlay; + + ImagePoint *gscPoint; + ImagePoint *uavPoint; + QTimer *m_updateTimer; PositionActual *m_positionActual; - QPointF gscPosition; - QPushButton *gscButton; // added by cathy QPushButton *uavButton; // added by cathy + + QPixmap gsc_pixmap; + QPixmap uav_pixmap; + QPixmap waypoint_pixmap; + QPixmap compass_background_pixmap; + QPixmap compass_needle_pixmap; + + void addWayPoint(QPointF pos, QString name); + void addCompass(QPointF pos, int size = 200, QString name = "compass"); }; #endif /* MAPGADGETWIDGET_H_ */