1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-20 10:54:14 +01:00

GCS/Map Implemented read time updates from GPS object

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@680 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
vassilis 2010-05-30 01:49:51 +00:00 committed by vassilis
parent 198045b292
commit 3fae030433
3 changed files with 25 additions and 1 deletions

View File

@ -3,6 +3,7 @@ TARGET = MapGadget
include(../../openpilotgcsplugin.pri)
include(../../plugins/coreplugin/coreplugin.pri)
include(../../libs/qmapcontrol/qmapcontrol.pri)
include(../../plugins/uavobjects/uavobjects.pri)
HEADERS += mapplugin.h \
mapgadgetconfiguration.h \
mapgadget.h \

View File

@ -28,6 +28,7 @@
#include <QStringList>
#include <QtGui/QVBoxLayout>
#include <QtGui/QPushButton>
#include "extensionsystem/pluginmanager.h"
MapGadgetWidget::MapGadgetWidget(QWidget *parent) : QWidget(parent)
{
@ -63,6 +64,16 @@ MapGadgetWidget::MapGadgetWidget(QWidget *parent) : QWidget(parent)
layout->setContentsMargins(0, 0, 0, 0);
layout->addWidget(m_mc);
setLayout(layout);
// Get required UAVObjects
ExtensionSystem::PluginManager* pm = ExtensionSystem::PluginManager::instance();
UAVObjectManager* objManager = pm->getObject<UAVObjectManager>();
m_gpsObj = GpsObject::GetInstance(objManager);
m_updateTimer = new QTimer();
m_updateTimer->setInterval(250);
connect(m_updateTimer, SIGNAL(timeout()), this, SLOT(updatePosition()));
m_updateTimer->start();
}
MapGadgetWidget::~MapGadgetWidget()
@ -81,6 +92,12 @@ void MapGadgetWidget::setPosition(QPointF pos)
m_mc->updateRequestNew();
}
void MapGadgetWidget::updatePosition()
{
GpsObject::DataFields data = m_gpsObj->getData();
setPosition(QPointF(data.Longitude, data.Latitude));
}
void MapGadgetWidget::setMapProvider(QString provider)
{
foreach(QString layerName, m_mc->layers())

View File

@ -30,7 +30,8 @@
#include "qmapcontrol/qmapcontrol.h"
#include <QtGui/QWidget>
#include "uavobjects/uavobjectmanager.h"
#include "uavobjects/gpsobject.h"
using namespace qmapcontrol;
@ -49,6 +50,9 @@ public:
protected:
void resizeEvent(QResizeEvent *event);
private slots:
void updatePosition();
private:
void addZoomButtons();
@ -61,6 +65,8 @@ private:
Layer *m_googleLayer;
Layer *m_googleSatLayer;
Layer *m_yahooLayer;
QTimer *m_updateTimer;
GpsObject *m_gpsObj;
};
#endif /* MAPGADGETWIDGET_H_ */