Skip to content

Commit

Permalink
User selectable map route line color and switchable route line out & …
Browse files Browse the repository at this point in the history
…back opacity (#4030)
  • Loading branch information
paulj49457 committed Jun 10, 2022
1 parent c85054e commit dd5bc51
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 7 deletions.
22 changes: 18 additions & 4 deletions src/Charts/RideMapWindow.cpp
Expand Up @@ -71,6 +71,8 @@ RideMapWindow::RideMapWindow(Context *context, int mapType) : GcChartWindow(cont
hideShadedZonesCk->setChecked(false);
hideYellowLineCk = new QCheckBox();
hideYellowLineCk->setChecked(false);
hideRouteLineOpacityCk = new QCheckBox();
hideRouteLineOpacityCk->setChecked(false);
showInt = new QCheckBox();
showInt->setChecked(true);

Expand All @@ -79,6 +81,7 @@ RideMapWindow::RideMapWindow(Context *context, int mapType) : GcChartWindow(cont
commonLayout->addRow(new QLabel(tr("Show Full Plot")), showFullPlotCk);
commonLayout->addRow(new QLabel(tr("Hide Shaded Zones")), hideShadedZonesCk);
commonLayout->addRow(new QLabel(tr("Hide Yellow Line")), hideYellowLineCk);
commonLayout->addRow(new QLabel(tr("Hide Out & Back Route Opacity")), hideRouteLineOpacityCk);
commonLayout->addRow(new QLabel(tr("Show Intervals Overlay")), showInt);
commonLayout->addRow(new QLabel(""));

Expand Down Expand Up @@ -115,6 +118,7 @@ RideMapWindow::RideMapWindow(Context *context, int mapType) : GcChartWindow(cont
connect(showFullPlotCk, SIGNAL(stateChanged(int)), this, SLOT(showFullPlotChanged(int)));
connect(hideShadedZonesCk, SIGNAL(stateChanged(int)), this, SLOT(hideShadedZonesChanged(int)));
connect(hideYellowLineCk, SIGNAL(stateChanged(int)), this, SLOT(hideYellowLineChanged(int)));
connect(hideRouteLineOpacityCk, SIGNAL(stateChanged(int)), this, SLOT(hideRouteLineOpacityChanged(int)));
connect(osmTSUrl, SIGNAL(editingFinished()), this, SLOT(osmCustomTSURLEditingFinished()));
connect(tileCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(tileTypeSelected(int)));

Expand Down Expand Up @@ -288,6 +292,14 @@ RideMapWindow::hideYellowLineChanged(int value)
Q_UNUSED(value);
forceReplot();
}

void
RideMapWindow::hideRouteLineOpacityChanged(int value)
{
Q_UNUSED(value);
forceReplot();
}

void
RideMapWindow::osmCustomTSURLEditingFinished()
{
Expand All @@ -313,12 +325,14 @@ RideMapWindow::osmCustomTSURLEditingFinished()
}

void
RideMapWindow::configChanged(qint32)
RideMapWindow::configChanged(qint32 value)
{
setProperty("color", GColor(CPLOTBACKGROUND));
#ifndef Q_OS_MAC
overlayIntervals->setStyleSheet(AbstractView::ourStyleSheet());
#endif

if (value & CONFIG_APPEARANCE) forceReplot();
}

void
Expand Down Expand Up @@ -749,7 +763,7 @@ void RideMapWindow::createHtml()

QColor RideMapWindow::GetColor(int watts)
{
if (range < 0 || hideShadedZones()) return Qt::red;
if (range < 0 || hideShadedZones()) return GColor(MAPROUTELINE);
else return zoneColor(context->athlete->zones(myRideItem ? myRideItem->sport : "Bike")->whichZone(range, watts), 7);
}

Expand Down Expand Up @@ -829,7 +843,7 @@ RideMapWindow::drawShadedRoute()
"polyline.on('mouseover', function(event) { webBridge.hoverPath(event.latlng.lat, event.latlng.lng); });\n"
"path = polyline.getLatLngs();\n"
"}\n").arg(color.name())
.arg(0.5);
.arg(hideRouteLineOpacity() ? 1.0 : 0.5f);
} else if (mapCombo->currentIndex() == GOOGLE) {
// color the polyline
code += QString("var polyOptions = {\n"
Expand All @@ -840,7 +854,7 @@ RideMapWindow::drawShadedRoute()
"}\n"
"polyline.setOptions(polyOptions);\n"
"}\n").arg(color.name())
.arg(0.5f);
.arg(hideRouteLineOpacity() ? 1.0 : 0.5f);

}
view->page()->runJavaScript(code);
Expand Down
7 changes: 6 additions & 1 deletion src/Charts/RideMapWindow.h
Expand Up @@ -111,6 +111,7 @@ class RideMapWindow : public GcChartWindow
Q_PROPERTY(bool showintervals READ showIntervals WRITE setShowIntervals USER true)
Q_PROPERTY(bool hideShadedZones READ hideShadedZones WRITE setHideShadedZones USER true)
Q_PROPERTY(bool hideYellowLine READ hideYellowLine WRITE setHideYellowLine USER true)
Q_PROPERTY(bool hideRouteLineOpacity READ hideRouteLineOpacity WRITE setRouteLineOpacity USER true)
Q_PROPERTY(int osmts READ osmTS WRITE setOsmTS USER true)
Q_PROPERTY(QString googleKey READ googleKey WRITE setGoogleKey USER true)

Expand Down Expand Up @@ -138,6 +139,9 @@ class RideMapWindow : public GcChartWindow
bool hideYellowLine() const { return hideYellowLineCk->isChecked(); }
void setHideYellowLine(bool x) { hideYellowLineCk->setChecked(x); }

bool hideRouteLineOpacity() const { return hideRouteLineOpacityCk->isChecked(); }
void setRouteLineOpacity(bool x) { hideRouteLineOpacityCk->setChecked(x); }

bool showMarkers() const { return ( showMarkersCk->checkState() == Qt::Checked); }
void setShowMarkers(bool x) { if (x) showMarkersCk->setCheckState(Qt::Checked); else showMarkersCk->setCheckState(Qt::Unchecked) ;}

Expand All @@ -161,6 +165,7 @@ class RideMapWindow : public GcChartWindow
void showFullPlotChanged(int value);
void hideShadedZonesChanged(int value);
void hideYellowLineChanged(int value);
void hideRouteLineOpacityChanged(int value);
void showIntervalsChanged(int value);
void osmCustomTSURLEditingFinished();

Expand All @@ -181,7 +186,7 @@ class RideMapWindow : public GcChartWindow

QComboBox *mapCombo, *tileCombo;
QCheckBox *showMarkersCk, *showFullPlotCk, *showInt;
QCheckBox* hideShadedZonesCk, * hideYellowLineCk;
QCheckBox* hideShadedZonesCk, * hideYellowLineCk, * hideRouteLineOpacityCk;
QLabel *osmTSTitle, *osmTSLabel, *osmTSUrlLabel;
QLineEdit *osmTSUrl;

Expand Down
4 changes: 3 additions & 1 deletion src/Gui/Colors.cpp
Expand Up @@ -249,6 +249,7 @@ void GCColor::setupColors()
{ tr("Gui"), tr("Chartbar background"), "CCHARTBAR", Qt::lightGray },
{ tr("Gui"), tr("Overview Tile Background Alternate"), "CCARDBACKGROUND2", QColor(0,0,0) },
{ tr("Gui"), tr("Overview Tile Background Vibrant"), "CCARDBACKGROUND3", QColor(52,52,52) },
{ tr("Gui"), tr("Map Route Line"), "MAPROUTELINE", Qt::red },
{ "", "", "", QColor(0,0,0) },
};

Expand Down Expand Up @@ -377,7 +378,8 @@ void GCColor::setupColors()
LightDefaultColorList[102].color = QColor(134,74,255); // 102:Respiratory Frequency
LightDefaultColorList[103].color = QColor(255,46,46); // 103:FeO2
LightDefaultColorList[106].color = QColor(180,180,180); // 106:Tile Alternate
LightDefaultColorList[107].color = QColor(0xee,0xf8,0xff); // 107:Tile Vibrant
LightDefaultColorList[107].color = QColor(238,248,255); // 107:Tile Vibrant
LightDefaultColorList[108].color = QColor(255, 0, 0); // 105:MapRouteLine
}

// default settings for fonts etc
Expand Down
3 changes: 2 additions & 1 deletion src/Gui/Colors.h
Expand Up @@ -186,7 +186,7 @@ class ColorEngine : public QObject
#define GColor(x) GCColor::getColor(x)

// Define how many cconfigurable metric colors are available
#define CNUMOFCFGCOLORS 108
#define CNUMOFCFGCOLORS 109

#define CPLOTBACKGROUND 0
#define CRIDEPLOTBACKGROUND 1
Expand Down Expand Up @@ -296,4 +296,5 @@ class ColorEngine : public QObject
#define CCHARTBAR 105
#define CCARDBACKGROUND2 106
#define CCARDBACKGROUND3 107
#define MAPROUTELINE 108
#endif

0 comments on commit dd5bc51

Please sign in to comment.