mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-02-14 08:38:45 +00:00
The training view has a number of improvements, most notable of which is the workout plot now plots the telemetry as you ride. This enables you to view your performance against the workout as you ride. In developing and testing this I found and fixed a number of other minor issues; * The workout plot didn't have any axes * The workout plot title didn't reflect the workout selected * The workout plot markers didn't honour preferences * Values didn't reset on stop/start of workout * The rolling 30 second power plot in realtime was broken * Lap numbers were not available for display In addition, some minor changes were made; * Save workout is no longer optional - it always saves * The control buttons/margins did not resize nicely * The workout plot uses colour to distinguish between workouts that are time or distance based. * A new default train layout for new users to avoid having to muck about with layouts * Removed the race servers since they are not used and steal screen estate. Will re-introduce when multi-rider or internet racing is implemented. I have also added a few workout files into the test/workouts directory, we should think about how we can distribute these and allow users to share and contribute them in the future. Fixes #493.
187 lines
5.1 KiB
C++
187 lines
5.1 KiB
C++
/*
|
|
* Copyright (c) 2010 Mark Liversedge (liversedge@gmail.com)
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
* under the terms of the GNU General Public License as published by the Free
|
|
* Software Foundation; either version 2 of the License, or (at your option)
|
|
* any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
* more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License along
|
|
* with this program; if not, write to the Free Software Foundation, Inc., 51
|
|
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
*/
|
|
|
|
|
|
#include "DialWindow.h"
|
|
|
|
DialWindow::DialWindow(MainWindow *mainWindow) :
|
|
GcWindow(mainWindow), mainWindow(mainWindow)
|
|
{
|
|
setContentsMargins(0,0,0,0);
|
|
setInstanceName("Dial");
|
|
|
|
QWidget *c = new QWidget;
|
|
QVBoxLayout *cl = new QVBoxLayout(c);
|
|
setControls(c);
|
|
|
|
// setup the controls
|
|
QFormLayout *controlsLayout = new QFormLayout();
|
|
controlsLayout->setSpacing(0);
|
|
controlsLayout->setContentsMargins(5,5,5,5);
|
|
cl->addLayout(controlsLayout);
|
|
|
|
// data series selection
|
|
QLabel *seriesLabel = new QLabel(tr("Data Series"), this);
|
|
seriesLabel->setAutoFillBackground(true);
|
|
seriesSelector = new QComboBox(this);
|
|
foreach (RealtimeData::DataSeries x, RealtimeData::listDataSeries()) {
|
|
seriesSelector->addItem(RealtimeData::seriesName(x), static_cast<int>(x));
|
|
}
|
|
controlsLayout->addRow(seriesLabel, seriesSelector);
|
|
|
|
// display label...
|
|
QVBoxLayout *layout = new QVBoxLayout(this);
|
|
valueLabel = new QLabel(this);
|
|
valueLabel->setAlignment(Qt::AlignCenter | Qt::AlignVCenter);
|
|
layout->addWidget(valueLabel);
|
|
|
|
// get updates..
|
|
connect(mainWindow, SIGNAL(telemetryUpdate(RealtimeData)), this, SLOT(telemetryUpdate(RealtimeData)));
|
|
connect(seriesSelector, SIGNAL(currentIndexChanged(int)), this, SLOT(seriesChanged()));
|
|
connect(mainWindow, SIGNAL(configChanged()), this, SLOT(seriesChanged()));
|
|
connect(mainWindow, SIGNAL(stop()), this, SLOT(stop()));
|
|
connect(mainWindow, SIGNAL(start()), this, SLOT(start()));
|
|
|
|
// setup colors
|
|
seriesChanged();
|
|
|
|
// setup fontsize etc
|
|
resizeEvent(NULL);
|
|
|
|
// set to zero
|
|
resetValues();
|
|
}
|
|
|
|
void
|
|
DialWindow::lap(int lapnumber)
|
|
{
|
|
lapNumber = lapnumber;
|
|
avgLap = 0;
|
|
}
|
|
|
|
void
|
|
DialWindow::start()
|
|
{
|
|
resetValues();
|
|
}
|
|
|
|
void
|
|
DialWindow::stop()
|
|
{
|
|
resetValues();
|
|
}
|
|
|
|
void
|
|
DialWindow::pause()
|
|
{
|
|
}
|
|
|
|
void
|
|
DialWindow::telemetryUpdate(const RealtimeData &rtData)
|
|
{
|
|
// we got some!
|
|
RealtimeData::DataSeries series = static_cast<RealtimeData::DataSeries>
|
|
(seriesSelector->itemData(seriesSelector->currentIndex()).toInt());
|
|
|
|
double value = rtData.value(series);
|
|
|
|
switch (series) {
|
|
|
|
case RealtimeData::Time:
|
|
case RealtimeData::LapTime:
|
|
{
|
|
long msecs = value;
|
|
valueLabel->setText(QString("%1:%2:%3.%4").arg(msecs/3600000)
|
|
.arg((msecs%3600000)/60000,2,10,QLatin1Char('0'))
|
|
.arg((msecs%60000)/1000,2,10,QLatin1Char('0'))
|
|
.arg((msecs%1000)/100));
|
|
}
|
|
break;
|
|
|
|
case RealtimeData::Distance:
|
|
valueLabel->setText(QString("%1").arg(value, 0, 'f', 3));
|
|
break;
|
|
|
|
default:
|
|
valueLabel->setText(QString("%1").arg(round(value)));
|
|
break;
|
|
|
|
}
|
|
}
|
|
|
|
void DialWindow::resizeEvent(QResizeEvent * )
|
|
{
|
|
|
|
if (geometry().height()-37 < 0) return;
|
|
|
|
QFont font;
|
|
font.setPointSize((geometry().height()-37));
|
|
font.setWeight(QFont::Bold);
|
|
valueLabel->setFont(font);
|
|
}
|
|
|
|
void DialWindow::seriesChanged()
|
|
{
|
|
// we got some!
|
|
RealtimeData::DataSeries series = static_cast<RealtimeData::DataSeries>
|
|
(seriesSelector->itemData(seriesSelector->currentIndex()).toInt());
|
|
|
|
// the series selector changed so update the colors
|
|
switch(series) {
|
|
|
|
case RealtimeData::Time:
|
|
case RealtimeData::LapTime:
|
|
case RealtimeData::Distance:
|
|
case RealtimeData::Lap:
|
|
case RealtimeData::None:
|
|
foreground = GColor(CPLOTMARKER);
|
|
break;
|
|
|
|
case RealtimeData::Load:
|
|
foreground = Qt::blue;
|
|
break;
|
|
|
|
case RealtimeData::XPower:
|
|
case RealtimeData::Joules:
|
|
case RealtimeData::BikeScore:
|
|
case RealtimeData::Watts:
|
|
foreground = GColor(CPOWER);
|
|
break;
|
|
|
|
case RealtimeData::Speed:
|
|
foreground = GColor(CSPEED);
|
|
break;
|
|
|
|
case RealtimeData::Cadence:
|
|
foreground = GColor(CCADENCE);
|
|
break;
|
|
|
|
case RealtimeData::HeartRate:
|
|
foreground = GColor(CHEARTRATE);
|
|
break;
|
|
}
|
|
|
|
// ugh. we use style sheets becuase palettes don't work on labels
|
|
background = GColor(CRIDEPLOTBACKGROUND);
|
|
setProperty("color", background);
|
|
QString sh = QString("QLabel { background: %1; color: %2; }")
|
|
.arg(background.name())
|
|
.arg(foreground.name());
|
|
valueLabel->setStyleSheet(sh);
|
|
}
|