mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-02-13 08:08:42 +00:00
Filtering of data in Critical Plot based on Seasons
Based on the defined dates per season, CP displays all plot only for that Season.
This commit is contained in:
committed by
Sean Rhea
parent
c630d281d3
commit
08c232d70b
@@ -29,6 +29,7 @@
|
||||
#include "LogTimeScaleDraw.h"
|
||||
#include "LogTimeScaleEngine.h"
|
||||
#include "RideFile.h"
|
||||
#include "Season.h"
|
||||
|
||||
CpintPlot::CpintPlot(
|
||||
QString p
|
||||
@@ -695,6 +696,7 @@ CpintPlot::calculate(RideItem *rideItem)
|
||||
QStringList filters;
|
||||
filters << "*.cpi";
|
||||
QStringList list = dir.entryList(filters, QDir::Files, QDir::Name);
|
||||
list = filterForSeason(list, startDate, endDate);
|
||||
progress->setLabelText(
|
||||
existing + tr("Aggregating over all files."));
|
||||
progress->setRange(0, list.size());
|
||||
@@ -814,3 +816,39 @@ CpintPlot::showGrid(int state)
|
||||
grid->setVisible(state == Qt::Checked);
|
||||
replot();
|
||||
}
|
||||
|
||||
QStringList
|
||||
CpintPlot::filterForSeason(QStringList cpints, QDate startDate, QDate endDate)
|
||||
{
|
||||
QString cpi;
|
||||
QDate cpiDate;
|
||||
QStringListIterator cpis(cpints);
|
||||
QStringList returnList;
|
||||
|
||||
//Check to see if no date was assigned.
|
||||
QDate nilDate;
|
||||
if(startDate == nilDate)
|
||||
return cpints;
|
||||
|
||||
while (cpis.hasNext())
|
||||
{
|
||||
cpi = cpis.next();
|
||||
cpiDate = cpi_filename_to_date(cpi);
|
||||
if(cpiDate > startDate && cpiDate < endDate)
|
||||
returnList << cpi;
|
||||
|
||||
}
|
||||
return returnList;
|
||||
}
|
||||
|
||||
void
|
||||
CpintPlot::setStartDate(QDate _startDate)
|
||||
{
|
||||
startDate = _startDate;
|
||||
}
|
||||
|
||||
void
|
||||
CpintPlot::setEndDate(QDate _endDate)
|
||||
{
|
||||
endDate = _endDate;
|
||||
}
|
||||
|
||||
@@ -52,7 +52,8 @@ class CpintPlot : public QwtPlot
|
||||
double cp, tau, t0; // CP model parameters
|
||||
void deriveCPParameters(); // derive the CP model parameters
|
||||
bool deleteCpiFile(QString filename); // delete a CPI file and clean up
|
||||
|
||||
void setStartDate(QDate);
|
||||
void setEndDate(QDate);
|
||||
|
||||
public slots:
|
||||
|
||||
@@ -78,11 +79,13 @@ class CpintPlot : public QwtPlot
|
||||
QList <QwtPlotCurve *> allCurves;
|
||||
QList <QwtPlotMarker *> allZoneLabels;
|
||||
void clear_CP_Curves();
|
||||
|
||||
QStringList filterForSeason(QStringList cpints, QDate startDate, QDate endDate);
|
||||
QwtPlotGrid *grid;
|
||||
|
||||
|
||||
QVector<double> bests;
|
||||
QVector<QDate> bestDates;
|
||||
QDate startDate;
|
||||
QDate endDate;
|
||||
|
||||
Zones **zones; // pointer to power zones added djconnel 24Apr2009
|
||||
|
||||
|
||||
@@ -23,12 +23,19 @@
|
||||
#include "TimeUtils.h"
|
||||
#include <qwt_picker.h>
|
||||
#include <qwt_plot_picker.h>
|
||||
#include <QFile>
|
||||
#include "Season.h"
|
||||
#include "SeasonParser.h"
|
||||
#include <QXmlInputSource>
|
||||
#include <QXmlSimpleReader>
|
||||
|
||||
CriticalPowerWindow::CriticalPowerWindow(const QDir &home, MainWindow *parent) :
|
||||
QWidget(parent), home(home), mainWindow(parent)
|
||||
{
|
||||
QVBoxLayout *vlayout = new QVBoxLayout;
|
||||
QHBoxLayout *cpintPickerLayout = new QHBoxLayout;
|
||||
QLabel *cSeasonLabel = new QLabel(tr("Season"), this);
|
||||
cComboSeason = new QComboBox(this);
|
||||
QLabel *cpintTimeLabel = new QLabel(tr("Interval Duration:"), this);
|
||||
cpintTimeValue = new QLineEdit("0 s");
|
||||
QLabel *cpintTodayLabel = new QLabel(tr("Today:"), this);
|
||||
@@ -42,6 +49,10 @@ CriticalPowerWindow::CriticalPowerWindow(const QDir &home, MainWindow *parent) :
|
||||
cpintSetCPButton = new QPushButton(tr("&Save CP value"), this);
|
||||
cpintSetCPButton->setEnabled(false);
|
||||
|
||||
addSeasons();
|
||||
|
||||
cpintPickerLayout->addWidget(cSeasonLabel);
|
||||
cpintPickerLayout->addWidget(cComboSeason);
|
||||
cpintPickerLayout->addWidget(cpintTimeLabel);
|
||||
cpintPickerLayout->addWidget(cpintTimeValue);
|
||||
cpintPickerLayout->addWidget(cpintTodayLabel);
|
||||
@@ -64,6 +75,9 @@ CriticalPowerWindow::CriticalPowerWindow(const QDir &home, MainWindow *parent) :
|
||||
SLOT(pickerMoved(const QPoint &)));
|
||||
connect(cpintSetCPButton, SIGNAL(clicked()),
|
||||
this, SLOT(cpintSetCPButtonClicked()));
|
||||
connect(cComboSeason, SIGNAL(currentIndexChanged(int)),
|
||||
this, SLOT(seasonSelected(int)));
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
@@ -82,6 +96,7 @@ CriticalPowerWindow::deleteCpiFile(QString rideFilename)
|
||||
void
|
||||
CriticalPowerWindow::setData(RideItem *ride)
|
||||
{
|
||||
currentRide = ride;
|
||||
cpintPlot->calculate(ride);
|
||||
cpintSetCPButton->setEnabled(cpintPlot->cp > 0);
|
||||
}
|
||||
@@ -158,3 +173,37 @@ CriticalPowerWindow::pickerMoved(const QPoint &pos)
|
||||
}
|
||||
}
|
||||
|
||||
void CriticalPowerWindow::addSeasons()
|
||||
{
|
||||
QFile seasonFile(home.absolutePath() + "/seasons.xml");
|
||||
QXmlInputSource source( &seasonFile );
|
||||
QXmlSimpleReader xmlReader;
|
||||
SeasonParser( handler );
|
||||
xmlReader.setContentHandler(&handler);
|
||||
xmlReader.setErrorHandler(&handler);
|
||||
bool ok = xmlReader.parse( source );
|
||||
if(!ok)
|
||||
qWarning("Failed to parse seasons.xml");
|
||||
|
||||
seasons = handler.getSeasons();
|
||||
Season season;
|
||||
season.setName("All Seasons");
|
||||
seasons.insert(0,season);
|
||||
|
||||
for (int i = 0; i < seasons.size(); ++i)
|
||||
{
|
||||
season = seasons.at(i);
|
||||
cComboSeason->addItem(season.getName());
|
||||
}
|
||||
}
|
||||
|
||||
void CriticalPowerWindow::seasonSelected(int iSeason)
|
||||
{
|
||||
Season season = seasons.at(iSeason);
|
||||
cpintPlot->setStartDate(season.getStart());
|
||||
cpintPlot->setEndDate(season.getEnd());
|
||||
cpintPlot->needToScanRides = true;
|
||||
cpintPlot->calculate(currentRide);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#define _GC_CriticalPowerWindow_h 1
|
||||
|
||||
#include <QtGui>
|
||||
#include "Season.h"
|
||||
|
||||
class CpintPlot;
|
||||
class MainWindow;
|
||||
@@ -42,6 +43,7 @@ class CriticalPowerWindow : public QWidget
|
||||
|
||||
void cpintSetCPButtonClicked();
|
||||
void pickerMoved(const QPoint &pos);
|
||||
void seasonSelected(int season);
|
||||
|
||||
protected:
|
||||
|
||||
@@ -51,8 +53,12 @@ class CriticalPowerWindow : public QWidget
|
||||
QLineEdit *cpintTimeValue;
|
||||
QLineEdit *cpintTodayValue;
|
||||
QLineEdit *cpintAllValue;
|
||||
QComboBox *cComboSeason;
|
||||
QPushButton *cpintSetCPButton;
|
||||
QwtPlotPicker *picker;
|
||||
void addSeasons();
|
||||
QList<Season> seasons;
|
||||
RideItem *currentRide;
|
||||
};
|
||||
|
||||
#endif // _GC_CriticalPowerWindow_h
|
||||
|
||||
Reference in New Issue
Block a user