mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-11-30 08:24:11 +01:00
OP-52 Ground/GPS Display: better data formatting, added display of location on tiny worldmap.
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1528 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
d3b677298c
commit
a378621666
@ -29,6 +29,7 @@
|
||||
#include "extensionsystem/pluginmanager.h"
|
||||
#include "uavobjects/uavobjectmanager.h"
|
||||
|
||||
|
||||
#include <iostream>
|
||||
#include <QtGui>
|
||||
#include <QDebug>
|
||||
@ -45,6 +46,13 @@ GpsDisplayWidget::GpsDisplayWidget(QWidget *parent) : QWidget(parent)
|
||||
QPixmap earthpix( ":/gpsgadget/images/flatEarth.png" );
|
||||
fescene->addPixmap( earthpix );
|
||||
flatEarth->setScene(fescene);
|
||||
marker = new QGraphicsSvgItem();
|
||||
QSvgRenderer *renderer = new QSvgRenderer();
|
||||
renderer->load(QString(":/gpsgadget/images/marker.svg"));
|
||||
marker->setSharedRenderer(renderer);
|
||||
fescene->addItem(marker);
|
||||
double scale = earthpix.width()/(marker->boundingRect().width()*20);
|
||||
marker->setScale(scale);
|
||||
}
|
||||
|
||||
GpsDisplayWidget::~GpsDisplayWidget()
|
||||
@ -53,9 +61,11 @@ GpsDisplayWidget::~GpsDisplayWidget()
|
||||
|
||||
void GpsDisplayWidget::setSpeedHeading(double speed, double heading)
|
||||
{
|
||||
speed_value->setText(QString::number(speed,'g',10));
|
||||
QString str;
|
||||
str.sprintf("%.02f m/s",speed);
|
||||
speed_value->setText(str);
|
||||
speed_value->adjustSize();
|
||||
bear_value->setText(QString::number(heading,'g',10));
|
||||
bear_value->setText(str.sprintf("%.02f deg",heading));
|
||||
bear_value->adjustSize();
|
||||
|
||||
}
|
||||
@ -66,8 +76,11 @@ void GpsDisplayWidget::setDateTime(double date, double time)
|
||||
dstring.insert(6,".");
|
||||
dstring.insert(4,".");
|
||||
gdate_value->setText(dstring);
|
||||
//gdate_value->adjustSize();
|
||||
gtime_value->setText(QString::number(time,'g',10));
|
||||
gdate_value->adjustSize();
|
||||
dstring = QString::number(time,'g',10);
|
||||
dstring.insert(dstring.length()-2,":");
|
||||
dstring.insert(dstring.length()-5,":");
|
||||
gtime_value->setText(dstring + " GMT");
|
||||
gdate_value->adjustSize();
|
||||
|
||||
}
|
||||
@ -92,18 +105,29 @@ void GpsDisplayWidget::setSVs(int sv)
|
||||
|
||||
void GpsDisplayWidget::setPosition(double lat, double lon, double alt)
|
||||
{
|
||||
QString temp = "Position: ";
|
||||
temp.append(QString::number(lat,'g',10));
|
||||
temp.append(" ");
|
||||
temp.append(QString::number(lon,'g',10));
|
||||
temp.append(" ");
|
||||
temp.append(QString::number(alt,'g',10));
|
||||
lat_value->setText(QString::number(lat,'g',10));
|
||||
lat *= 1E-7;
|
||||
lon *= 1E-7;
|
||||
double deg = (lat>0) ? floor(lat):ceil(lat);
|
||||
double min = fabs(lat-deg)*60;
|
||||
QString str;
|
||||
str.sprintf("%.0f%c%.3f'", deg,0x00b0, min);
|
||||
lat_value->setText(str);
|
||||
lat_value->adjustSize();
|
||||
long_value->setText(QString::number(lon,'g',10));
|
||||
deg = floor(fabs(lon)); // ABS takes an int.
|
||||
min = fabs(lon-deg)*60;
|
||||
str.sprintf("%.0f%c%.3f'", deg,0x00b0, min);
|
||||
if (lon>0)
|
||||
str.append("E");
|
||||
else
|
||||
str.append("W");
|
||||
long_value->setText(str);
|
||||
long_value->adjustSize();
|
||||
//alt_value->setText(QString::number(alt,'g',10));
|
||||
//alt_value->adjustSize();
|
||||
|
||||
//textBrowser->append(temp);
|
||||
// Now place the marker:
|
||||
double wscale = flatEarth->sceneRect().width()/360;
|
||||
double hscale = flatEarth->sceneRect().height()/180;
|
||||
QPointF opd = QPointF((lon+180)*wscale-marker->boundingRect().width()*marker->scale()/2,
|
||||
(90-lat)*hscale-marker->boundingRect().height()*marker->scale()/2);
|
||||
marker->setTransform(QTransform::fromTranslate( opd.x(), opd.y()) , false);
|
||||
|
||||
}
|
||||
|
@ -56,5 +56,6 @@ private slots:
|
||||
|
||||
private:
|
||||
GpsConstellationWidget * gpsConstellation;
|
||||
QGraphicsSvgItem * marker;
|
||||
};
|
||||
#endif /* GPSDISPLAYWIDGET_H_ */
|
||||
|
84
ground/src/plugins/gpsdisplay/images/marker.svg
Normal file
84
ground/src/plugins/gpsdisplay/images/marker.svg
Normal file
@ -0,0 +1,84 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="264.91373"
|
||||
height="266.91373"
|
||||
id="svg2"
|
||||
version="1.1"
|
||||
inkscape:version="0.47 r22583"
|
||||
sodipodi:docname="marker.svg">
|
||||
<defs
|
||||
id="defs4">
|
||||
<inkscape:perspective
|
||||
sodipodi:type="inkscape:persp3d"
|
||||
inkscape:vp_x="0 : 526.18109 : 1"
|
||||
inkscape:vp_y="0 : 1000 : 0"
|
||||
inkscape:vp_z="744.09448 : 526.18109 : 1"
|
||||
inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
|
||||
id="perspective10" />
|
||||
</defs>
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="0.49497475"
|
||||
inkscape:cx="-190.24238"
|
||||
inkscape:cy="166.06585"
|
||||
inkscape:document-units="px"
|
||||
inkscape:current-layer="layer1"
|
||||
showgrid="false"
|
||||
inkscape:window-width="1366"
|
||||
inkscape:window-height="693"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="24"
|
||||
inkscape:window-maximized="1" />
|
||||
<metadata
|
||||
id="metadata7">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title />
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
inkscape:label="Layer 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1"
|
||||
transform="translate(-81.1701,-431.51432)">
|
||||
<path
|
||||
style="fill:#ff0000;fill-opacity:1;stroke:#ff0000;stroke-width:10;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
|
||||
d="m 140.0395,436.51432 74.24621,90.91372 74.24621,-90.91372 -148.49242,0 z"
|
||||
id="path2816"
|
||||
sodipodi:nodetypes="cccc" />
|
||||
<path
|
||||
sodipodi:nodetypes="cccc"
|
||||
id="path3592"
|
||||
d="m 140.0395,693.42804 74.24621,-90.91372 74.24621,90.91372 -148.49242,0 z"
|
||||
style="fill:#ff0000;fill-opacity:1;stroke:#ff0000;stroke-width:10;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
|
||||
<path
|
||||
style="fill:#ff0000;fill-opacity:1;stroke:#ff0000;stroke-width:10;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
|
||||
d="m 341.08382,639.82266 -90.91372,-74.24621 90.91372,-74.24621 0,148.49242 z"
|
||||
id="path3594"
|
||||
sodipodi:nodetypes="cccc" />
|
||||
<path
|
||||
sodipodi:nodetypes="cccc"
|
||||
id="path3598"
|
||||
d="m 86.1701,639.82266 90.91372,-74.24621 -90.91372,-74.24621 0,148.49242 z"
|
||||
style="fill:#ff0000;fill-opacity:1;stroke:#ff0000;stroke-width:10;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 3.1 KiB |
@ -2,5 +2,6 @@
|
||||
<qresource prefix="/gpsgadget">
|
||||
<file>images/gpsEarth.svg</file>
|
||||
<file>images/flatEarth.png</file>
|
||||
<file>images/marker.svg</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
Loading…
Reference in New Issue
Block a user