mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-02-13 16:18:42 +00:00
abstract "PF/PV Plot" tab into its own class
This commit is contained in:
@@ -22,7 +22,7 @@
|
||||
#include "ChooseCyclistDialog.h"
|
||||
#include "ConfigDialog.h"
|
||||
#include "CpintPlot.h"
|
||||
#include "PfPvPlot.h"
|
||||
#include "PfPvWindow.h"
|
||||
#include "DownloadRideDialog.h"
|
||||
#include "ManualRideDialog.h"
|
||||
#include "HistogramWindow.h"
|
||||
@@ -238,43 +238,8 @@ MainWindow::MainWindow(const QDir &home) :
|
||||
|
||||
//////////////////////// Pedal Force/Velocity Plot ////////////////////////
|
||||
|
||||
window = new QWidget;
|
||||
vlayout = new QVBoxLayout;
|
||||
QHBoxLayout *qaLayout = new QHBoxLayout;
|
||||
|
||||
pfPvPlot = new PfPvPlot();
|
||||
QLabel *qaCPLabel = new QLabel(tr("Watts:"), window);
|
||||
qaCPValue = new QLineEdit(QString("%1").arg(pfPvPlot->getCP()));
|
||||
qaCPValue->setValidator(new QIntValidator(0, 9999, qaCPValue));
|
||||
QLabel *qaCadLabel = new QLabel(tr("RPM:"), window);
|
||||
qaCadValue = new QLineEdit(QString("%1").arg(pfPvPlot->getCAD()));
|
||||
qaCadValue->setValidator(new QIntValidator(0, 999, qaCadValue));
|
||||
QLabel *qaClLabel = new QLabel(tr("Crank Length (m):"), window);
|
||||
qaClValue = new QLineEdit(QString("%1").arg(1000 * pfPvPlot->getCL()));
|
||||
shadeZonesPfPvCheckBox = new QCheckBox;
|
||||
shadeZonesPfPvCheckBox->setText("Shade zones");
|
||||
shadeZonesPfPvCheckBox->setCheckState(Qt::Checked);
|
||||
|
||||
qaLayout->addWidget(qaCPLabel);
|
||||
qaLayout->addWidget(qaCPValue);
|
||||
qaLayout->addWidget(qaCadLabel);
|
||||
qaLayout->addWidget(qaCadValue);
|
||||
qaLayout->addWidget(qaClLabel);
|
||||
qaLayout->addWidget(qaClValue);
|
||||
qaLayout->addWidget(shadeZonesPfPvCheckBox);
|
||||
|
||||
vlayout->addWidget(pfPvPlot);
|
||||
vlayout->addLayout(qaLayout);
|
||||
window->setLayout(vlayout);
|
||||
|
||||
connect(pfPvPlot, SIGNAL(changedCP(const QString&)),
|
||||
qaCPValue, SLOT(setText(const QString&)) );
|
||||
connect(pfPvPlot, SIGNAL(changedCAD(const QString&)),
|
||||
qaCadValue, SLOT(setText(const QString&)) );
|
||||
connect(pfPvPlot, SIGNAL(changedCL(const QString&)),
|
||||
qaClValue, SLOT(setText(const QString&)) );
|
||||
|
||||
tabWidget->addTab(window, tr("PF/PV Plot"));
|
||||
pfPvWindow = new PfPvWindow(this);
|
||||
tabWidget->addTab(pfPvWindow, tr("PF/PV Plot"));
|
||||
|
||||
|
||||
//////////////////////// Ride Notes ////////////////////////
|
||||
@@ -395,14 +360,6 @@ MainWindow::MainWindow(const QDir &home) :
|
||||
this, SLOT(splitterMoved()));
|
||||
connect(cpintSetCPButton, SIGNAL(clicked()),
|
||||
this, SLOT(cpintSetCPButtonClicked()));
|
||||
connect(shadeZonesPfPvCheckBox, SIGNAL(stateChanged(int)),
|
||||
this, SLOT(setShadeZonesPfPvFromCheckBox()));
|
||||
connect(qaCPValue, SIGNAL(editingFinished()),
|
||||
this, SLOT(setQaCPFromLineEdit()));
|
||||
connect(qaCadValue, SIGNAL(editingFinished()),
|
||||
this, SLOT(setQaCADFromLineEdit()));
|
||||
connect(qaClValue, SIGNAL(editingFinished()),
|
||||
this, SLOT(setQaCLFromLineEdit()));
|
||||
connect(tabWidget, SIGNAL(currentChanged(int)),
|
||||
this, SLOT(tabChanged(int)));
|
||||
connect(rideNotes, SIGNAL(textChanged()),
|
||||
@@ -751,9 +708,7 @@ MainWindow::rideSelected()
|
||||
|
||||
allPlotWindow->setData(ride);
|
||||
histogramWindow->setData(ride);
|
||||
pfPvPlot->setData(ride);
|
||||
// update the QLabel widget with the CP value set in PfPvPlot::setData()
|
||||
qaCPValue->setText(QString("%1").arg(pfPvPlot->getCP()));
|
||||
pfPvWindow->setData(ride);
|
||||
|
||||
// turn off tabs that don't make sense for manual file entry
|
||||
if (ride->ride && ride->ride->deviceType() == QString("Manual CSV")) {
|
||||
@@ -1249,9 +1204,7 @@ MainWindow::showOptions()
|
||||
histogramWindow->zonesChanged();
|
||||
|
||||
// force-versus-pedal velocity plot
|
||||
pfPvPlot->refreshZoneItems();
|
||||
pfPvPlot->replot();
|
||||
qaCPValue->setText(QString("%1").arg(pfPvPlot->getCP()));
|
||||
pfPvWindow->zonesChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1341,35 +1294,6 @@ MainWindow::cpintSetCPButtonClicked()
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
MainWindow::setShadeZonesPfPvFromCheckBox()
|
||||
{
|
||||
if (pfPvPlot->shadeZones() != shadeZonesPfPvCheckBox->isChecked()) {
|
||||
pfPvPlot->setShadeZones(shadeZonesPfPvCheckBox->isChecked());
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
MainWindow::setQaCPFromLineEdit()
|
||||
{
|
||||
int value = qaCPValue->text().toInt();
|
||||
pfPvPlot->setCP(value);
|
||||
}
|
||||
|
||||
void
|
||||
MainWindow::setQaCADFromLineEdit()
|
||||
{
|
||||
int value = qaCadValue->text().toInt();
|
||||
pfPvPlot->setCAD(value);
|
||||
}
|
||||
|
||||
void
|
||||
MainWindow::setQaCLFromLineEdit()
|
||||
{
|
||||
double value = qaClValue->text().toDouble();
|
||||
pfPvPlot->setCL(value);
|
||||
}
|
||||
|
||||
void
|
||||
MainWindow::tabChanged(int index)
|
||||
{
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
class AllPlotWindow;
|
||||
class CpintPlot;
|
||||
class HistogramWindow;
|
||||
class PfPvPlot;
|
||||
class PfPvWindow;
|
||||
class QwtPlotPanner;
|
||||
class QwtPlotPicker;
|
||||
class QwtPlotZoomer;
|
||||
@@ -71,10 +71,6 @@ class MainWindow : public QMainWindow
|
||||
void splitRide();
|
||||
void deleteRide();
|
||||
void cpintSetCPButtonClicked();
|
||||
void setQaCPFromLineEdit();
|
||||
void setQaCADFromLineEdit();
|
||||
void setQaCLFromLineEdit();
|
||||
void setShadeZonesPfPvFromCheckBox();
|
||||
void tabChanged(int index);
|
||||
void pickerMoved(const QPoint &);
|
||||
void aboutDialog();
|
||||
@@ -110,7 +106,6 @@ class MainWindow : public QMainWindow
|
||||
QLineEdit *cpintAllValue;
|
||||
QPushButton *cpintSetCPButton;
|
||||
QwtPlotPicker *picker;
|
||||
QCheckBox *shadeZonesPfPvCheckBox;
|
||||
QTreeWidgetItem *allRides;
|
||||
QwtPlot *weeklyPlot;
|
||||
QwtPlotCurve *weeklyDistCurve;
|
||||
@@ -126,10 +121,7 @@ class MainWindow : public QMainWindow
|
||||
Zones *zones;
|
||||
|
||||
// pedal force/pedal velocity scatter plot widgets
|
||||
PfPvPlot *pfPvPlot;
|
||||
QLineEdit *qaCPValue;
|
||||
QLineEdit *qaCadValue;
|
||||
QLineEdit *qaClValue;
|
||||
PfPvWindow *pfPvWindow;
|
||||
|
||||
QTextEdit *rideNotes;
|
||||
QString currentNotesFile;
|
||||
|
||||
115
src/PfPvWindow.cpp
Normal file
115
src/PfPvWindow.cpp
Normal file
@@ -0,0 +1,115 @@
|
||||
/*
|
||||
* Copyright (c) 2009 Sean C. Rhea (srhea@srhea.net)
|
||||
*
|
||||
* 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 "PfPvWindow.h"
|
||||
#include "PfPvPlot.h"
|
||||
#include "RideItem.h"
|
||||
#include <QtGui>
|
||||
|
||||
PfPvWindow::PfPvWindow(QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
QVBoxLayout *vlayout = new QVBoxLayout;
|
||||
QHBoxLayout *qaLayout = new QHBoxLayout;
|
||||
|
||||
pfPvPlot = new PfPvPlot();
|
||||
QLabel *qaCPLabel = new QLabel(tr("Watts:"), this);
|
||||
qaCPValue = new QLineEdit(QString("%1").arg(pfPvPlot->getCP()));
|
||||
qaCPValue->setValidator(new QIntValidator(0, 9999, qaCPValue));
|
||||
QLabel *qaCadLabel = new QLabel(tr("RPM:"), this);
|
||||
qaCadValue = new QLineEdit(QString("%1").arg(pfPvPlot->getCAD()));
|
||||
qaCadValue->setValidator(new QIntValidator(0, 999, qaCadValue));
|
||||
QLabel *qaClLabel = new QLabel(tr("Crank Length (m):"), this);
|
||||
qaClValue = new QLineEdit(QString("%1").arg(1000 * pfPvPlot->getCL()));
|
||||
shadeZonesPfPvCheckBox = new QCheckBox;
|
||||
shadeZonesPfPvCheckBox->setText("Shade zones");
|
||||
shadeZonesPfPvCheckBox->setCheckState(Qt::Checked);
|
||||
|
||||
qaLayout->addWidget(qaCPLabel);
|
||||
qaLayout->addWidget(qaCPValue);
|
||||
qaLayout->addWidget(qaCadLabel);
|
||||
qaLayout->addWidget(qaCadValue);
|
||||
qaLayout->addWidget(qaClLabel);
|
||||
qaLayout->addWidget(qaClValue);
|
||||
qaLayout->addWidget(shadeZonesPfPvCheckBox);
|
||||
|
||||
vlayout->addWidget(pfPvPlot);
|
||||
vlayout->addLayout(qaLayout);
|
||||
setLayout(vlayout);
|
||||
|
||||
connect(pfPvPlot, SIGNAL(changedCP(const QString&)),
|
||||
qaCPValue, SLOT(setText(const QString&)) );
|
||||
connect(pfPvPlot, SIGNAL(changedCAD(const QString&)),
|
||||
qaCadValue, SLOT(setText(const QString&)) );
|
||||
connect(pfPvPlot, SIGNAL(changedCL(const QString&)),
|
||||
qaClValue, SLOT(setText(const QString&)) );
|
||||
connect(qaCPValue, SIGNAL(editingFinished()),
|
||||
this, SLOT(setQaCPFromLineEdit()));
|
||||
connect(qaCadValue, SIGNAL(editingFinished()),
|
||||
this, SLOT(setQaCADFromLineEdit()));
|
||||
connect(qaClValue, SIGNAL(editingFinished()),
|
||||
this, SLOT(setQaCLFromLineEdit()));
|
||||
connect(shadeZonesPfPvCheckBox, SIGNAL(stateChanged(int)),
|
||||
this, SLOT(setShadeZonesPfPvFromCheckBox()));
|
||||
}
|
||||
|
||||
void
|
||||
PfPvWindow::setData(RideItem *ride)
|
||||
{
|
||||
pfPvPlot->setData(ride);
|
||||
// update the QLabel widget with the CP value set in PfPvPlot::setData()
|
||||
qaCPValue->setText(QString("%1").arg(pfPvPlot->getCP()));
|
||||
}
|
||||
|
||||
void
|
||||
PfPvWindow::zonesChanged()
|
||||
{
|
||||
pfPvPlot->refreshZoneItems();
|
||||
pfPvPlot->replot();
|
||||
qaCPValue->setText(QString("%1").arg(pfPvPlot->getCP()));
|
||||
}
|
||||
|
||||
void
|
||||
PfPvWindow::setShadeZonesPfPvFromCheckBox()
|
||||
{
|
||||
if (pfPvPlot->shadeZones() != shadeZonesPfPvCheckBox->isChecked()) {
|
||||
pfPvPlot->setShadeZones(shadeZonesPfPvCheckBox->isChecked());
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
PfPvWindow::setQaCPFromLineEdit()
|
||||
{
|
||||
int value = qaCPValue->text().toInt();
|
||||
pfPvPlot->setCP(value);
|
||||
}
|
||||
|
||||
void
|
||||
PfPvWindow::setQaCADFromLineEdit()
|
||||
{
|
||||
int value = qaCadValue->text().toInt();
|
||||
pfPvPlot->setCAD(value);
|
||||
}
|
||||
|
||||
void
|
||||
PfPvWindow::setQaCLFromLineEdit()
|
||||
{
|
||||
double value = qaClValue->text().toDouble();
|
||||
pfPvPlot->setCL(value);
|
||||
}
|
||||
|
||||
|
||||
56
src/PfPvWindow.h
Normal file
56
src/PfPvWindow.h
Normal file
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (c) 2009 Sean C. Rhea (srhea@srhea.net)
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#ifndef _GC_PfPvWindow_h
|
||||
#define _GC_PfPvWindow_h 1
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class PfPvPlot;
|
||||
class QCheckBox;
|
||||
class QLineEdit;
|
||||
class RideItem;
|
||||
|
||||
class PfPvWindow : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
PfPvWindow(QWidget *parent);
|
||||
void setData(RideItem *item);
|
||||
void zonesChanged();
|
||||
|
||||
protected slots:
|
||||
|
||||
void setQaCPFromLineEdit();
|
||||
void setQaCADFromLineEdit();
|
||||
void setQaCLFromLineEdit();
|
||||
void setShadeZonesPfPvFromCheckBox();
|
||||
|
||||
protected:
|
||||
|
||||
PfPvPlot *pfPvPlot;
|
||||
QCheckBox *shadeZonesPfPvCheckBox;
|
||||
QLineEdit *qaCPValue;
|
||||
QLineEdit *qaCadValue;
|
||||
QLineEdit *qaClValue;
|
||||
};
|
||||
|
||||
#endif // _GC_PfPvWindow_h
|
||||
|
||||
@@ -55,6 +55,7 @@ HEADERS += \
|
||||
DownloadRideDialog.h \
|
||||
MainWindow.h \
|
||||
PfPvPlot.h \
|
||||
PfPvWindow.h \
|
||||
PolarRideFile.h \
|
||||
PowerHist.h \
|
||||
HistogramWindow.h \
|
||||
@@ -104,6 +105,7 @@ SOURCES += \
|
||||
DownloadRideDialog.cpp \
|
||||
MainWindow.cpp \
|
||||
PfPvPlot.cpp \
|
||||
PfPvWindow.cpp \
|
||||
PolarRideFile.cpp \
|
||||
PowerHist.cpp \
|
||||
HistogramWindow.cpp \
|
||||
|
||||
Reference in New Issue
Block a user