mirror of
git://projects.qi-hardware.com/nanomap.git
synced 2024-11-22 08:12:48 +02:00
draw different symbol if gps device got no fix
This commit is contained in:
parent
0dd2f334d0
commit
889c3fbc87
19
gpslayer.cpp
19
gpslayer.cpp
@ -27,10 +27,11 @@
|
||||
GpsLayer::GpsLayer(MapWidget *map) :
|
||||
AbstractLayer(map),
|
||||
m_gps(new GpsClient(this)),
|
||||
m_pos(QPointF(9.8, 54)),
|
||||
m_pos(QPointF(0, 0)),
|
||||
m_alt(0),
|
||||
m_track(0),
|
||||
m_speed(0)
|
||||
m_speed(0),
|
||||
m_fix(false)
|
||||
{
|
||||
setVisible(false);
|
||||
connect(m_gps, SIGNAL(position(QPointF)), this, SLOT(position(QPointF)));
|
||||
@ -39,6 +40,7 @@ GpsLayer::GpsLayer(MapWidget *map) :
|
||||
connect(m_gps, SIGNAL(speed(qreal)), this, SLOT(speed(qreal)));
|
||||
connect(m_gps, SIGNAL(connected()), this, SLOT(connected()));
|
||||
connect(m_gps, SIGNAL(disconnected()), this, SLOT(disconnected()));
|
||||
connect(m_gps, SIGNAL(fixed(bool)), this, SLOT(fixed(bool)));
|
||||
m_gps->connectGps();
|
||||
}
|
||||
|
||||
@ -60,11 +62,11 @@ void GpsLayer::keyPressed(QKeyEvent *event)
|
||||
void GpsLayer::paint(QPainter *painter)
|
||||
{
|
||||
QPoint pos = map()->geo2screen(m_pos.x(), m_pos.y());
|
||||
|
||||
painter->setRenderHint(QPainter::Antialiasing, true);
|
||||
painter->setPen(QPen(QColor(0, 0, 255, 110), 4));
|
||||
painter->drawEllipse(pos, 8, 8);
|
||||
|
||||
if (m_fix) {
|
||||
painter->setPen(QPen(QColor(0, 0, 255, 210), 2, Qt::SolidLine, Qt::RoundCap, Qt::MiterJoin));
|
||||
painter->translate(pos);
|
||||
painter->rotate(m_track);
|
||||
@ -72,6 +74,9 @@ void GpsLayer::paint(QPainter *painter)
|
||||
painter->drawLine(QPoint(-4, 3), QPoint(0, -7));
|
||||
painter->drawLine(QPoint(4, 3), QPoint(0, 0));
|
||||
painter->drawLine(QPoint(-4, 3), QPoint(0, 0));
|
||||
} else {
|
||||
painter->drawText(pos.x()-8, pos.y()-8, 16, 16, Qt::AlignCenter, "?");
|
||||
}
|
||||
}
|
||||
|
||||
void GpsLayer::position(const QPointF &pos)
|
||||
@ -118,3 +123,11 @@ void GpsLayer::disconnected()
|
||||
map()->update();
|
||||
}
|
||||
|
||||
void GpsLayer::fixed(bool fix)
|
||||
{
|
||||
m_fix = fix;
|
||||
if (isVisible()) {
|
||||
map()->update();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -45,11 +45,13 @@ private slots:
|
||||
void speed(qreal speed);
|
||||
void connected();
|
||||
void disconnected();
|
||||
void fixed(bool fix);
|
||||
|
||||
private:
|
||||
GpsClient *m_gps;
|
||||
QPointF m_pos;
|
||||
qreal m_alt, m_track, m_speed;
|
||||
bool m_fix;
|
||||
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user