diff --git a/src/ErgFile.cpp b/src/ErgFile.cpp index c3ad61d3b..9ff18c616 100644 --- a/src/ErgFile.cpp +++ b/src/ErgFile.cpp @@ -19,11 +19,10 @@ #include "ErgFile.h" -ErgFile::ErgFile(QString filename, int &mode) +ErgFile::ErgFile(QString filename, int &mode, double Cp) { QFile ergFile(filename); int section = NOMANSLAND; // section 0=init, 1=header data, 2=course data - double Cp=285; // default to 285 if zones are not set leftPoint=rightPoint=0; MaxWatts = Ftp = 0; int lapcounter = 0; @@ -33,11 +32,6 @@ ErgFile::ErgFile(QString filename, int &mode) long rdist = 0; // running total for distance long ralt = 200; // always start at 200 meters just to prettify the graph - // Get users CP for relative watts calculations - QDate today = QDate::currentDate(); - int range = mainwindow->zones()->whichRange(today); - if (range != -1) Cp = mainwindow->zones()->getCP(range); - // open the file if (ergFile.open(QIODevice::ReadOnly | QIODevice::Text) == false) { valid = false; diff --git a/src/ErgFile.h b/src/ErgFile.h index d8a162a7c..be3ade371 100644 --- a/src/ErgFile.h +++ b/src/ErgFile.h @@ -29,7 +29,6 @@ #include #include #include "Zones.h" // For zones ... see below vvvv -#include "MainWindow.h" // gets access to mainwindow to read zones info // which section of the file are we in? #define NOMANSLAND 0 @@ -61,7 +60,7 @@ class ErgFileLap class ErgFile { public: - ErgFile(QString, int&); // constructor uses filename + ErgFile(QString, int&, double Cp); // constructor uses filename ~ErgFile(); // delete the contents bool isValid(); // is the file valid or not? diff --git a/src/RealtimeWindow.cpp b/src/RealtimeWindow.cpp index fbbb9f46d..a71642a8a 100644 --- a/src/RealtimeWindow.cpp +++ b/src/RealtimeWindow.cpp @@ -716,7 +716,13 @@ RealtimeWindow::SelectWorkout(int index) tr("Open Workout File"), home.dirName(), tr("Workout Files (*.erg *.mrc *.crs)")); if (!filename.isEmpty()) { - ergFile = new ErgFile(filename, mode); + // Get users CP for relative watts calculations + QDate today = QDate::currentDate(); + double Cp=285; // default to 285 if zones are not set + int range = main->zones()->whichRange(today); + if (range != -1) Cp = main->zones()->getCP(range); + + ergFile = new ErgFile(filename, mode, Cp); if (ergFile->isValid()) { // success! we have a load file