From e849b4fd817ffca983506727a53a2a4dd585bfaa Mon Sep 17 00:00:00 2001 From: Ale Martinez Date: Fri, 2 Apr 2021 14:50:23 -0300 Subject: [PATCH] Workout Editor - round decimal watts for qwkcode and remove cues Decimal watts, which tipically happens when a workout is scaled, play havoc with qwkcode, so lets avoid them. Text cues are not supported either in qwkcode yet, adding them was my mistake, so I commented out them for now. Fixes #3846 --- src/Train/WorkoutWidget.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/Train/WorkoutWidget.cpp b/src/Train/WorkoutWidget.cpp index f36c86a1e..a42bcf731 100644 --- a/src/Train/WorkoutWidget.cpp +++ b/src/Train/WorkoutWidget.cpp @@ -1791,6 +1791,8 @@ WorkoutWidget::qwkcode() // 5x30s@450r30s - 5 times 30seconds at 450w followed by 30s at 'recovery' // 20m@100-400 - 20 minutes going from 100w to 400w // + // NOTE: only integer watts are supported, floating point numbers are + // rounded when qwkcode is generated. // // XXX COME AND FIX THIS EXAMPLE XXX // A complete workout example; @@ -1805,7 +1807,7 @@ WorkoutWidget::qwkcode() // just loop through for now doing xx@yy and optionally add rxx if (points_.count() == 1) { // just a single point? - codeStrings << QString("%1@%2").arg(qduration(points_[0]->x)).arg(points_[0]->y); + codeStrings << QString("%1@%2").arg(qduration(points_[0]->x)).arg(round(points_[0]->y)); codePoints<<0; } @@ -1841,7 +1843,7 @@ WorkoutWidget::qwkcode() if (i==0 || points_[i]->x - points_[i-1]->x <= 0) { // its a block - section = QString("0@%1-%2").arg(points_[i]->y).arg(points_[i+1]->y); + section = QString("0@%1-%2").arg(round(points_[i]->y)).arg(round(points_[i+1]->y)); ap = points_[i]->y; } else { @@ -1855,14 +1857,14 @@ WorkoutWidget::qwkcode() if (doubles_equal(points_[i+1]->y, points_[i]->y)) { // its a block - section = QString("%1@%2").arg(qduration(duration)).arg(points_[i]->y); + section = QString("%1@%2").arg(qduration(duration)).arg(round(points_[i]->y)); ap = points_[i]->y; } else { // its a rise section = QString("%1@%2-%3").arg(qduration(duration)) - .arg(points_[i]->y) - .arg(points_[i+1]->y); + .arg(round(points_[i]->y)) + .arg(round(points_[i+1]->y)); ap = ((points_[i]->y + points_[i+1]->y) / 2); } @@ -1910,6 +1912,7 @@ WorkoutWidget::qwkcode() break; // stop when end of matches } + /* Text cues are not supported on qwkcode yet foreach (const ErgFileText cue, texts_) { int secs = i > 0 ? points_[sectionp[i-1]]->x : 0; int offset = cue.x/1000 - secs; @@ -1920,6 +1923,7 @@ WorkoutWidget::qwkcode() codePoints << sectionp[i]; } } + */ // multiple or no .. if (count > 1) {