Aerolab: Add a constant altitude option

This commit is contained in:
Damien
2013-09-26 00:04:58 +02:00
committed by Gareth Coco
parent 847fd004e1
commit 506caf89dc
4 changed files with 42 additions and 6 deletions

View File

@@ -334,7 +334,7 @@ Aerolab::setData(RideItem *_rideItem, bool new_zoom) {
int npoints = ride->dataPoints().size();
double dt = ride->recIntSecs();
veArray.resize(dataPresent->watts ? npoints : 0);
altArray.resize(dataPresent->alt ? npoints : 0);
altArray.resize(dataPresent->alt || constantAlt ? npoints : 0);
timeArray.resize(dataPresent->watts ? npoints : 0);
distanceArray.resize(dataPresent->watts ? npoints : 0);
@@ -355,7 +355,7 @@ Aerolab::setData(RideItem *_rideItem, bool new_zoom) {
if (!altArray.empty()) {
have_recorded_alt_curve = true;
altCurve->attach(this);
altCurve->setVisible(dataPresent->alt);
altCurve->setVisible(dataPresent->alt || constantAlt );
}
// Fill the virtual elevation profile with data from the ride data:
@@ -368,10 +368,19 @@ Aerolab::setData(RideItem *_rideItem, bool new_zoom) {
e = eoffset;
timeArray[arrayLength] = p1->secs / 60.0;
if ( have_recorded_alt_curve )
altArray[arrayLength] = (useMetricUnits
if ( have_recorded_alt_curve ) {
if ( constantAlt && arrayLength > 0) {
altArray[arrayLength] = altArray[arrayLength-1];
}
else {
if ( constantAlt && !dataPresent->alt)
altArray[arrayLength] = 0;
else
altArray[arrayLength] = (useMetricUnits
? p1->alt
: p1->alt * FEET_PER_METER);
}
}
// Unpack:
double power = max(0, p1->watts);
@@ -605,6 +614,12 @@ Aerolab::setAutoEoffset(int value)
adjustEoffset();
}
void
Aerolab::setConstantAlt(int value)
{
constantAlt = value;
}
void
Aerolab::setByDistance(int value) {
bydist = value;
@@ -788,7 +803,7 @@ QString Aerolab::estimateCdACrr(RideItem *rideItem)
if(ride) {
const RideFileDataPresent *dataPresent = ride->areDataPresent();
if(dataPresent->alt && dataPresent->watts) {
if(( dataPresent->alt || constantAlt ) && dataPresent->watts) {
double dt = ride->recIntSecs();
int npoints = ride->dataPoints().size();
double X1[npoints], X2[npoints], Egain[npoints];

View File

@@ -65,6 +65,7 @@ class Aerolab : public QwtPlot {
public slots:
void setAutoEoffset(int value);
void setConstantAlt(int value);
void setByDistance(int value);
void configChanged();
@@ -102,6 +103,7 @@ class Aerolab : public QwtPlot {
int smooth;
bool bydist;
bool autoEoffset;
bool constantAlt;
int arrayLength;
int iCrr;
int iCda;

View File

@@ -112,6 +112,7 @@ AerolabWindow::AerolabWindow(MainWindow *mainWindow) :
//etaLayout->addWidget( etaQLCDNumber );
etaLayout->addWidget( etaSlider );
// Add to leftControls:
leftControls->addLayout( crrLayout );
leftControls->addLayout( cdaLayout );
@@ -190,9 +191,16 @@ AerolabWindow::AerolabWindow(MainWindow *mainWindow) :
//eoffsetLayout->addWidget( eoffsetQLCDNumber );
eoffsetLayout->addWidget( eoffsetSlider );
QVBoxLayout *checkboxLayout = new QVBoxLayout;
QCheckBox *eoffsetAuto = new QCheckBox(tr("eoffset auto"), this);
eoffsetAuto->setCheckState(Qt::Checked);
eoffsetLayout->addWidget(eoffsetAuto);
checkboxLayout->addWidget(eoffsetAuto);
QCheckBox *constantAlt = new QCheckBox(tr("Constant altitude (velodrome,...)"), this);
checkboxLayout->addWidget(constantAlt);
eoffsetLayout->addLayout(checkboxLayout);
QHBoxLayout *smoothLayout = new QHBoxLayout;
QComboBox *comboDistance = new QComboBox();
@@ -239,6 +247,7 @@ AerolabWindow::AerolabWindow(MainWindow *mainWindow) :
connect(eoffsetSlider, SIGNAL(valueChanged(int)), this, SLOT(setEoffsetFromSlider()));
connect(eoffsetLineEdit, SIGNAL(textChanged(const QString)), this, SLOT(setEoffsetFromText(const QString)));
connect(eoffsetAuto, SIGNAL(stateChanged(int)), this, SLOT(setAutoEoffset(int)));
connect(constantAlt, SIGNAL(stateChanged(int)), this, SLOT(setConstantAlt(int)));
connect(comboDistance, SIGNAL(currentIndexChanged(int)), this, SLOT(setByDistance(int)));
connect(btnEstCdACrr, SIGNAL(clicked()), this, SLOT(doEstCdACrr()));
connect(mainWindow, SIGNAL(configChanged()), aerolab, SLOT(configChanged()));
@@ -462,6 +471,15 @@ AerolabWindow::setAutoEoffset(int value)
aerolab->setAutoEoffset(value);
}
void
AerolabWindow::setConstantAlt(int value)
{
aerolab->setConstantAlt(value);
// refresh
RideItem *ride = myRideItem;
aerolab->setData(ride, false);
}
void
AerolabWindow::setByDistance(int value)
{

View File

@@ -61,6 +61,7 @@ class AerolabWindow : public GcWindow {
void setEoffsetFromText(const QString text);
void doEstCdACrr();
void setAutoEoffset(int value);
void setConstantAlt(int value);
void setByDistance(int value);
void rideSelected();
void zoomChanged();