mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-11-30 08:24:11 +01:00
GCS GpsDisplay: Display PRN numbers in constellation, and some cleanup.
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1721 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
e4d317f40e
commit
d9dc37ad33
@ -30,8 +30,6 @@
|
||||
#include <QtGui>
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Initialize the widget
|
||||
*/
|
||||
@ -53,30 +51,43 @@ GpsConstellationWidget::GpsConstellationWidget(QWidget *parent) : QGraphicsView(
|
||||
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
|
||||
QGraphicsScene *scene = new QGraphicsScene(this);
|
||||
QSvgRenderer *renderer = new QSvgRenderer();
|
||||
world = new QGraphicsSvgItem();
|
||||
renderer->load(QString(":/gpsgadget/images/gpsEarth.svg"));
|
||||
|
||||
world = new QGraphicsSvgItem();
|
||||
world->setSharedRenderer(renderer);
|
||||
world->setElementId("map");
|
||||
|
||||
scene = new QGraphicsScene(this);
|
||||
scene->addItem(world);
|
||||
scene->setSceneRect(world->boundingRect());
|
||||
setScene(scene);
|
||||
|
||||
// Now create 16 satellite icons which we will move around on the map:
|
||||
for (int i=0; i<16;i++) {
|
||||
satIcons[i] = new QGraphicsSvgItem();
|
||||
// Now create 'maxSatellites' satellite icons which we will move around on the map:
|
||||
for (int i=0; i < MAX_SATTELITES;i++) {
|
||||
satellites[i][0] = 0;
|
||||
satellites[i][1] = 0;
|
||||
satellites[i][2] = 0;
|
||||
satellites[i][3] = 0;
|
||||
|
||||
satIcons[i] = new QGraphicsSvgItem(world);
|
||||
satIcons[i]->setSharedRenderer(renderer);
|
||||
satIcons[i]->setElementId("sat-notSeen");
|
||||
satIcons[i]->setParentItem(world);
|
||||
satIcons[i]->hide();
|
||||
}
|
||||
|
||||
satTexts[i] = new QGraphicsSimpleTextItem("##",satIcons[i]);
|
||||
satTexts[i]->setBrush(QColor("Black"));
|
||||
satTexts[i]->setFont(QFont("Courier"));
|
||||
}
|
||||
}
|
||||
|
||||
GpsConstellationWidget::~GpsConstellationWidget()
|
||||
{
|
||||
delete scene;
|
||||
scene = 0;
|
||||
|
||||
delete renderer;
|
||||
renderer = 0;
|
||||
}
|
||||
|
||||
void GpsConstellationWidget::showEvent(QShowEvent *event)
|
||||
@ -101,8 +112,9 @@ void GpsConstellationWidget::resizeEvent(QResizeEvent* event)
|
||||
|
||||
void GpsConstellationWidget::updateSat(int index, int prn, int elevation, int azimuth, int snr)
|
||||
{
|
||||
if (index >= 16) {
|
||||
return; // A bit of error checking never hurts.
|
||||
if (index >= MAX_SATTELITES) {
|
||||
// A bit of error checking never hurts.
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: add range checking
|
||||
@ -116,12 +128,27 @@ void GpsConstellationWidget::updateSat(int index, int prn, int elevation, int az
|
||||
opd += QPointF(-satIcons[index]->boundingRect().center().x(),
|
||||
-satIcons[index]->boundingRect().center().y());
|
||||
satIcons[index]->setTransform(QTransform::fromTranslate(opd.x(),opd.y()), false);
|
||||
if (snr)
|
||||
if (snr) {
|
||||
satIcons[index]->setElementId("satellite");
|
||||
else
|
||||
} else {
|
||||
satIcons[index]->setElementId("sat-notSeen");
|
||||
}
|
||||
satIcons[index]->show();
|
||||
|
||||
QRectF iconRect = satIcons[index]->boundingRect();
|
||||
QString prnString = QString().number(prn);
|
||||
if(prnString.length() == 1) {
|
||||
prnString = "0" + prnString;
|
||||
}
|
||||
satTexts[index]->setText(prnString);
|
||||
QRectF textRect = satTexts[index]->boundingRect();
|
||||
|
||||
QTransform matrix;
|
||||
qreal scale = 0.70 * (iconRect.width() / textRect.width());
|
||||
matrix.translate(iconRect.width()/2, iconRect.height()/2);
|
||||
matrix.scale(scale,scale);
|
||||
matrix.translate(-textRect.width()/2,-textRect.height()/2);
|
||||
satTexts[index]->setTransform(matrix,false);
|
||||
} else {
|
||||
satIcons[index]->hide();
|
||||
}
|
||||
|
@ -48,10 +48,14 @@ public slots:
|
||||
private slots:
|
||||
|
||||
private:
|
||||
int satellites[16][4];
|
||||
QGraphicsSvgItem* satIcons[16];
|
||||
QGraphicsSvgItem *world;
|
||||
QGraphicsView *gpsConstellation;
|
||||
static const int MAX_SATTELITES = 16;
|
||||
int satellites[MAX_SATTELITES][4];
|
||||
QGraphicsScene *scene;
|
||||
QSvgRenderer *renderer;
|
||||
QGraphicsSvgItem* world;
|
||||
QGraphicsSvgItem* satIcons[MAX_SATTELITES];
|
||||
QGraphicsSimpleTextItem* satTexts[MAX_SATTELITES];
|
||||
|
||||
QPointF polarToCoord(int elevation, int azimuth);
|
||||
|
||||
protected:
|
||||
|
Loading…
Reference in New Issue
Block a user