49 QGraphicsScene *fescene =
new QGraphicsScene(
this);
50 QPixmap earthpix(
":/gpsgadget/images/flatEarth.png");
51 fescene->addPixmap(earthpix);
52 flatEarth->setScene(fescene);
53 marker =
new QGraphicsSvgItem();
54 QSvgRenderer *renderer =
new QSvgRenderer();
55 renderer->load(QString(
":/gpsgadget/images/marker.svg"));
56 marker->setSharedRenderer(renderer);
57 fescene->addItem(marker);
58 double scale = earthpix.width() / (marker->boundingRect().width() * 20);
59 marker->setScale(scale);
66 void GpsDisplayWidget::setSpeedHeading(
double speed,
double heading)
70 speed_value->setText(str.sprintf(
"%.02f m/s", speed));
71 bear_value->setText(str.sprintf(
"%.02f deg", heading));
74 void GpsDisplayWidget::setDateTime(
double date,
double time)
76 QString dstring1, dstring2;
78 dstring1.sprintf(
"%06.0f", date);
79 dstring1.insert(dstring1.length() - 2,
".");
80 dstring1.insert(dstring1.length() - 5,
".");
81 dstring2.sprintf(
"%06.0f", time);
82 dstring2.insert(dstring2.length() - 2,
":");
83 dstring2.insert(dstring2.length() - 5,
":");
84 time_value->setText(dstring1 +
" " + dstring2 +
" GMT");
87 void GpsDisplayWidget::setFixType(
const QString &fixtype)
89 if (fixtype ==
"NoGPS") {
90 fix_value->setText(
"No GPS");
91 }
else if (fixtype ==
"NoFix") {
92 fix_value->setText(
"Fix not available");
93 }
else if (fixtype ==
"Fix2D") {
94 fix_value->setText(
"2D");
95 }
else if (fixtype ==
"Fix3D") {
96 fix_value->setText(
"3D");
98 fix_value->setText(
"Unknown");
102 void GpsDisplayWidget::setSVs(
int sv)
106 temp.append(QString::number(sv));
107 status_value->setText(temp);
108 status_value->adjustSize();
111 void GpsDisplayWidget::setDOP(
double hdop,
double vdop,
double pdop)
115 str.sprintf(
"%.2f / %.2f / %.2f", hdop, vdop, pdop);
116 dop_value->setText(str);
119 void GpsDisplayWidget::setPosition(
double lat,
double lon,
double alt)
123 double deg = floor(fabs(lat));
124 double min = (fabs(lat) - deg) * 60;
127 str1.sprintf(
"%.0f%c%.3f' ", deg, 0x00b0, min);
133 coord_value->setText(str1);
134 deg = floor(fabs(lon));
135 min = (fabs(lon) - deg) * 60;
137 str2.sprintf(
"%.0f%c%.3f' ", deg, 0x00b0, min);
143 coord_value_2->setText(str2);
145 str3.sprintf(
"%.2f m", alt);
146 coord_value_3->setText(str3);
149 double wscale = flatEarth->sceneRect().width() / 360;
150 double hscale = flatEarth->sceneRect().height() / 180;
152 QPointF((lon + 180) * wscale - marker->boundingRect().width() * marker->scale() / 2,
153 (90 - lat) * hscale - marker->boundingRect().height() * marker->scale() / 2);
154 marker->setTransform(QTransform::fromTranslate(opd.x(), opd.y()),
false);
GpsDisplayWidget(QWidget *parent=nullptr)