From 0e1bec38aa58caafa5531bd2e9a624971a25698b Mon Sep 17 00:00:00 2001 From: Ale Martinez Date: Sun, 21 Jun 2020 13:17:00 -0300 Subject: [PATCH] Enable GoldenCheetah JSON files as Workouts and VideoSync Any other activity file format GC supports can be imported, conditioned using Fix Elevation, Fix GPS, etc. and exported to GoldenCheetah .json format to be used for simulated rides with synchronized video and position tracking. Complements #3469, Fixes #3376 --- src/Train/ErgFile.cpp | 30 +++++------------------------- src/Train/Library.cpp | 2 +- src/Train/VideoSyncFile.cpp | 17 ++--------------- 3 files changed, 8 insertions(+), 41 deletions(-) diff --git a/src/Train/ErgFile.cpp b/src/Train/ErgFile.cpp index 16f9ec85d..f84d5b923 100644 --- a/src/Train/ErgFile.cpp +++ b/src/Train/ErgFile.cpp @@ -42,18 +42,7 @@ static bool setSupported() ::supported << ".zwo"; ::supported << ".gpx"; ::supported << ".tts"; - - // Additional supportable ridefile types. Uncomment to enable. - //::supported << ".bin"; - //::supported << ".bin2"; - //::supported << ".fit"; - //::supported << ".fitlog"; - //::supported << ".hrm"; - //::supported << ".pwx"; - //::supported << ".srd"; - //::supported << ".srm"; - //::supported << ".tcx"; - //::supported << ".wko"; + ::supported << ".json"; return true; } @@ -67,7 +56,7 @@ bool ErgFile::isWorkout(QString name) return false; } ErgFile::ErgFile(QString filename, int mode, Context *context) : - filename(filename), mode(mode), context(context), StrictGradient(true) + filename(filename), mode(mode), StrictGradient(true), context(context) { if (context->athlete->zones(false)) { int zonerange = context->athlete->zones(false)->whichRange(QDateTime::currentDateTime().date()); @@ -76,7 +65,7 @@ ErgFile::ErgFile(QString filename, int mode, Context *context) : reload(); } -ErgFile::ErgFile(Context *context) : mode(0), context(context), StrictGradient(true) +ErgFile::ErgFile(Context *context) : mode(0), StrictGradient(true), context(context) { if (context->athlete->zones(false)) { int zonerange = context->athlete->zones(false)->whichRange(QDateTime::currentDateTime().date()); @@ -123,7 +112,7 @@ void ErgFile::reload() // All file endings that can be loaded as ergfile from rideFileFactory. // Actual permitted file types are controlled by ::supported list at // top of this file. - QRegExp fact(".+[.](gpx|bin|bin2|fit|fitlog|hrm|pwx|srd|srm|tcx|wko)$", Qt::CaseInsensitive); + QRegExp fact(".+[.](gpx|json)$", Qt::CaseInsensitive); // which parser to call? NOTE: we should look at moving to an ergfile factory // like we do with ride files if we end up with lots of different formats @@ -714,17 +703,8 @@ void ErgFile::parseComputrainer(QString p) // and which contains gps data, altitude or slope. // // File types supported: -// .bin Joule GPS File -// .bin2 Joule GPS File -// .fit Garmin FIT -// .fitlog Sporttracks FITLOG // .gpx GPS Track -// .hrm Polar Precision -// .pwx TrainingPeaks PWX -// .srd Polar SRD -// .srm SRM Powercontrol -// .tcx Garmin TCX -// .wko TrainingPeaks WKO +// .json GoldenCheetah JSON void ErgFile::parseFromRideFileFactory() { // Initialise diff --git a/src/Train/Library.cpp b/src/Train/Library.cpp index e3e994f06..ac735333a 100644 --- a/src/Train/Library.cpp +++ b/src/Train/Library.cpp @@ -261,7 +261,7 @@ LibrarySearchDialog::LibrarySearchDialog(Context *context) : context(context) findWorkouts->setChecked(true); findMedia = new QCheckBox(tr("Video files (.mp4, .avi etc)"), this); findMedia->setChecked(true); - findVideoSyncs = new QCheckBox(tr("VideoSync files (.rlv)"), this); + findVideoSyncs = new QCheckBox(tr("VideoSync files (.rlv, .tts etc)"), this); findVideoSyncs->setChecked(true); addPath = new QPushButton("+", this); removePath = new QPushButton("-", this); diff --git a/src/Train/VideoSyncFile.cpp b/src/Train/VideoSyncFile.cpp index 8dbd90947..1f93c006e 100644 --- a/src/Train/VideoSyncFile.cpp +++ b/src/Train/VideoSyncFile.cpp @@ -30,20 +30,7 @@ static bool setSupported() { ::supported << ".rlv"; ::supported << ".tts"; - - // Additional file types that are supportable as videosync file. - // Uncomment to enable. - //::supported << ".gpx"; - //::supported << ".bin"; - //::supported << ".bin2"; - //::supported << ".fit"; - //::supported << ".fitlog"; - //::supported << ".hrm"; - //::supported << ".pwx"; - //::supported << ".srd"; - //::supported << ".srm"; - //::supported << ".tcx"; - //::supported << ".wko"; + ::supported << ".json"; return true; } @@ -70,7 +57,7 @@ VideoSyncFile::VideoSyncFile(Context *context) : context(context) void VideoSyncFile::reload() { // These types are enabled using ::supported list at top of this file. - QRegExp fact(".+[.](gpx|bin|bin2|fit|fit|fitlog|hrm|pwx|srd|srm|tcx|wko)$", Qt::CaseInsensitive); + QRegExp fact(".+[.](gpx|json)$", Qt::CaseInsensitive); // which parser to call? if (filename.endsWith(".rlv", Qt::CaseInsensitive)) parseRLV();