320 changes: 270 additions & 50 deletions src/Resources/xml/train-perspectives.xml

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions src/Train/ErgFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ bool ErgFile::isWorkout(QString name)
return false;
}
ErgFile::ErgFile(QString filename, int mode, Context *context) :
filename(filename), mode(mode), StrictGradient(true), context(context)
filename(filename), mode(mode), StrictGradient(true), fHasGPS(false), context(context)
{
if (context->athlete->zones("Bike")) {
int zonerange = context->athlete->zones("Bike")->whichRange(QDateTime::currentDateTime().date());
Expand All @@ -66,7 +66,7 @@ ErgFile::ErgFile(QString filename, int mode, Context *context) :
reload();
}

ErgFile::ErgFile(Context *context) : mode(0), StrictGradient(true), context(context)
ErgFile::ErgFile(Context *context) : mode(0), StrictGradient(true), fHasGPS(false), context(context)
{
if (context->athlete->zones("Bike")) {
int zonerange = context->athlete->zones("Bike")->whichRange(QDateTime::currentDateTime().date());
Expand Down Expand Up @@ -757,9 +757,9 @@ void ErgFile::parseFromRideFileFactory()
bool fHasKm = ride->areDataPresent()->km;
bool fHasLat = ride->areDataPresent()->lat;
bool fHasLon = ride->areDataPresent()->lon;
bool fHasGPS = fHasLat && fHasLon;
bool fHasAlt = ride->areDataPresent()->alt;
bool fHasSlope = ride->areDataPresent()->slope;
fHasGPS = fHasLat && fHasLon;

if (fHasKm && fHasSlope) {} // same as crs file
else if (fHasKm && fHasAlt) {} // derive slope from distance and alt
Expand Down Expand Up @@ -900,9 +900,9 @@ void ErgFile::parseTTS()

// Enumerate the data types that are available.
bool fHasKm = ttsReader.hasKm();
bool fHasGPS = ttsReader.hasGPS();
bool fHasAlt = ttsReader.hasElevation();
bool fHasSlope = ttsReader.hasGradient();
fHasGPS = ttsReader.hasGPS();

if (fHasKm && fHasSlope) {} // same as crs file
else if (fHasKm && fHasAlt) {} // derive slope from distance and alt
Expand Down
3 changes: 3 additions & 0 deletions src/Train/ErgFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ class ErgFile

bool hasGradient() const { return CRS == format; } // Has Gradient and Altitude
bool hasWatts() const { return ERG == format || MRC == format; }
bool hasGPS() const { return fHasGPS; } // Has Lat/Lon

private:
void sortLaps() const;
Expand Down Expand Up @@ -166,6 +167,7 @@ class ErgFile
bool valid; // did it parse ok?
int mode;
bool StrictGradient; // should gradient be strict or smoothed?
bool fHasGPS; // has Lat/Lon?

QList<ErgFilePoint> Points; // points in workout
mutable QList<ErgFileLap> Laps; // interval markers in the file
Expand Down Expand Up @@ -231,6 +233,7 @@ class ErgFileQueryAdapter {
// Const getters
bool hasGradient() const { return ergFile && ergFile->hasGradient(); }
bool hasWatts() const { return ergFile && ergFile->hasWatts(); }
bool hasGPS() const { return ergFile && ergFile->hasGPS(); }

double nextLap (double x) const { return !ergFile ? -1 : ergFile->nextLap(x); }
double prevLap (double x) const { return !ergFile ? -1 : ergFile->prevLap(x); }
Expand Down
4 changes: 3 additions & 1 deletion src/Train/TrainSidebar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1600,12 +1600,14 @@ void TrainSidebar::Connect()
// if everything has been initialised properly (aka lazy load)
// given the connect widget is on the train view it is unlikely
// below will ever be false, but no harm in checking
qDebug() << (trainView!=NULL) << (trainView->page()!=NULL);
if (trainView && trainView->page()) {

Perspective::switchenum want=Perspective::None;
if (mediafile != "") want=Perspective::Video; // if media file selected
else want = (mode == ERG || mode == MRC) ? Perspective::Erg : Perspective::Slope; // mode always known

if (want == Perspective::Slope && ergFileQueryAdapter.hasGPS()) want=Perspective::Map; // Map without Video
qDebug()<<want<<trainView->page()->trainSwitch();
// so we want a view type and the current page isn't what
// we want then lets go find one to switch to and switch
// to the first one that matches
Expand Down