diff --git a/src/Resources/xml/video-layout.xml b/src/Resources/xml/video-layout.xml
index 6fe8b562d..257882b6b 100644
--- a/src/Resources/xml/video-layout.xml
+++ b/src/Resources/xml/video-layout.xml
@@ -93,6 +93,105 @@
+
+
+
+
+
+ 220.0
+ 6
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 280.0
+
+
+
+
+
+
+
+
+
+
+ watts
+
+
+
+
+
+
+ 280.0
+ 30
+
+
+
+
+
+
+
+
+
+
+ rpm
+
+
+
+
+
+
+
+
+
+
+ bpm
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ load
+
+
+
+
+
+
+
+
+
+
+
+ 16
+
+
+
diff --git a/src/Train/MeterWidget.cpp b/src/Train/MeterWidget.cpp
index 907d278ab..53d498028 100644
--- a/src/Train/MeterWidget.cpp
+++ b/src/Train/MeterWidget.cpp
@@ -23,6 +23,8 @@
#include "Context.h"
#include "Units.h"
+#include
+
MeterWidget::MeterWidget(QString Name, QWidget *parent, QString Source) : QWidget(parent), m_Name(Name), m_container(parent), m_Source(Source)
{
setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
@@ -50,6 +52,7 @@ MeterWidget::MeterWidget(QString Name, QWidget *parent, QString Source) : QWidge
m_RangeMax = 100;
m_Angle = 180.0;
m_SubRange = 10;
+ m_Zoom = 16;
boundingRectVisibility = false;
forceSquareRatio = true;
}
@@ -429,9 +432,9 @@ void ElevationMeterWidget::paintEvent(QPaintEvent* paintevent)
painter.setPen(m_OutlinePen);
painter.drawLine(cyclistX, 0.0, cyclistX, (double)m_Height-bubbleSize);
- // Display grade as #.#%
- QString gradientString = ((-1.0 < this->gradientValue && this->gradientValue < 0.0) ? QString("-"):QString("")) +
- QString::number((int) this->gradientValue) + QString(".") + QString::number(abs((int)(this->gradientValue * 10.0) % 10)) + QString("%");
+ // Display grade as #.#%
+ QString gradientString = ((-1.0 < this->gradientValue && this->gradientValue < 0.0) ? QString("-") : QString("")) + QString::number((int)this->gradientValue) +
+ QString(".") + QString::number(abs((int)(this->gradientValue * 10.0) % 10)) + QString("%");
// Display gradient text to the right of the line until the middle, then display to the left of the line
double gradientDrawX = cyclistX;
@@ -463,3 +466,87 @@ void ElevationMeterWidget::paintEvent(QPaintEvent* paintevent)
painter.drawText(distanceDrawX, distanceDrawY, distanceString);
}
+
+
+LiveMapWidget::LiveMapWidget(QString Name, QWidget *parent, QString Source) : MeterWidget(Name, parent, Source)
+{
+ forceSquareRatio = false;
+ liveMapView = new QWebEngineView(this);
+ liveMapInitialized = false;
+}
+
+void LiveMapWidget::resizeEvent(QResizeEvent *)
+{
+ liveMapView->resize(m_Width, m_Height);
+}
+
+void LiveMapWidget::plotNewLatLng(double dLat, double dLon)
+{
+ if ( ! liveMapInitialized ) initLiveMap(dLat, dLon);
+
+ QString sLat = QString::number(dLat);
+ QString sLon = QString::number(dLon);
+ QString code = QString("moveMarker(" + sLat + " , " + sLon + ")");
+
+ liveMapView->page()->runJavaScript(code);
+}
+
+void LiveMapWidget::initLiveMap(double dLat, double dLon)
+{
+ createHtml(dLat, dLon, m_Zoom);
+ liveMapView->page()->setHtml(currentPage);
+ liveMapView->show();
+ liveMapInitialized = true;
+}
+
+void LiveMapWidget::createHtml(double dLat, double dLon, int iMapZoom)
+{
+ QString sLat = QString::number(dLat);
+ QString sLon = QString::number(dLon);
+ QString sWidth = QString::number(m_Width);
+ QString sHeight = QString::number(m_Height);
+ QString sMapZoom = QString::number(iMapZoom);
+ currentPage = "";
+
+ currentPage = QString("\n"
+ " \n"
+ "\n"
+ "GoldenCheetah LiveMap - TrainView\n");
+ //Leaflet CSS and JS
+ currentPage += QString("\n"
+ "\n"
+ "\n");
+
+ // local functions
+ currentPage += QString("\n"
+ "\n"
+ "\n");
+}
diff --git a/src/Train/MeterWidget.h b/src/Train/MeterWidget.h
index c9057e754..0b02d03b4 100644
--- a/src/Train/MeterWidget.h
+++ b/src/Train/MeterWidget.h
@@ -21,6 +21,9 @@
#include
#include "Context.h"
+#include
+#include
+#include
class MeterWidget : public QWidget
{
@@ -62,6 +65,7 @@ class MeterWidget : public QWidget
float m_RangeMin, m_RangeMax;
float m_Angle;
int m_SubRange;
+ int m_Zoom;
bool forceSquareRatio;
QColor m_MainColor;
@@ -127,8 +131,23 @@ class ElevationMeterWidget : public MeterWidget
public:
explicit ElevationMeterWidget(QString name, QWidget *parent = 0, QString Source = QString("None"), Context *context = NULL);
void setContext(Context* context) { this->context = context; }
-
float gradientValue;
};
+class LiveMapWidget : public MeterWidget
+{
+ public:
+ explicit LiveMapWidget(QString name, QWidget *parent = 0, QString Source = QString("None"));
+ void plotNewLatLng (double newLat, double newLong);
+
+ protected:
+ void createHtml(double sLon, double sLat, int mapZoom);
+ void initLiveMap(double sLon, double sLat);
+ void resizeEvent(QResizeEvent *);
+
+ bool liveMapInitialized;
+ QWebEngineView *liveMapView;
+ QString currentPage;
+};
+
#endif // _MeterWidget_h
diff --git a/src/Train/VideoLayoutParser.cpp b/src/Train/VideoLayoutParser.cpp
index f16bd2a7d..91574964e 100644
--- a/src/Train/VideoLayoutParser.cpp
+++ b/src/Train/VideoLayoutParser.cpp
@@ -150,6 +150,10 @@ bool VideoLayoutParser::startElement( const QString&, const QString&,
{
meterWidget = new ElevationMeterWidget(meterName, containerWidget, source);
}
+ else if (meterType == QString("LiveMap"))
+ {
+ meterWidget = new LiveMapWidget(meterName, containerWidget, source);
+ }
else
{
qDebug() << QObject::tr("Error creating meter");
@@ -233,6 +237,8 @@ bool VideoLayoutParser::endElement( const QString&, const QString&, const QStrin
meterWidget->m_Angle = buffer.toFloat();
else if (qName == "SubRange")
meterWidget->m_SubRange = buffer.toInt();
+ else if (qName == "Zoom")
+ meterWidget->m_Zoom = buffer.toInt();
else if (qName == "Text")
meterWidget->Text = QString(buffer);
diff --git a/src/Train/VideoWindow.cpp b/src/Train/VideoWindow.cpp
index 2db10f67a..32fc06213 100644
--- a/src/Train/VideoWindow.cpp
+++ b/src/Train/VideoWindow.cpp
@@ -26,7 +26,6 @@
#include "MeterWidget.h"
#include "VideoLayoutParser.h"
-
VideoWindow::VideoWindow(Context *context) :
GcChartWindow(context), context(context), m_MediaChanged(false)
{
@@ -323,6 +322,8 @@ void VideoWindow::telemetryUpdate(RealtimeData rtd)
foreach(MeterWidget* p_meterWidget , m_metersWidget)
{
+ QString myQstr1 = p_meterWidget->Source();
+ std::string smyStr1 = myQstr1.toStdString();
if (p_meterWidget->Source() == QString("None"))
{
//Nothing
@@ -350,6 +351,20 @@ void VideoWindow::telemetryUpdate(RealtimeData rtd)
elevationMeterWidget->gradientValue = rtd.getSlope();
}
}
+ else if (p_meterWidget->Source() == QString("LiveMap"))
+ {
+ LiveMapWidget* liveMapWidget = dynamic_cast(p_meterWidget);
+ if (!liveMapWidget)
+ qDebug() << "Error: LiveMap keyword used but widget is not LiveMap type";
+ else
+ {
+ double dLat = rtd.getLatitude();
+ double dLon = rtd.getLongitude();
+
+ if (dLat && dLon) liveMapWidget->plotNewLatLng(dLat, dLon);
+ else liveMapWidget->hide();
+ }
+ }
else if (p_meterWidget->Source() == QString("Cadence"))
{
p_meterWidget->Value = rtd.getCadence();