remember user's preference for stacked view

...and add zoom.

fixes #58
This commit is contained in:
Damien Grauser
2010-03-10 14:43:59 +01:00
committed by Sean Rhea
parent bd28d3b28e
commit ff3a232863
4 changed files with 79 additions and 12 deletions

View File

@@ -603,19 +603,18 @@ AllPlot::setDataP(AllPlot *plot, int startidx, int stopidx)
cadCurve->setData(xaxis, smoothCad);
altCurve->setData(xaxis, smoothAltitude);
setYMax();
setAxisMaxMajor(yLeft, 5);
setAxisMaxMajor(yLeft2, 5);
setAxisMaxMajor(yRight, 5);
setAxisMaxMajor(yRight2, 5);
wattsCurve->setVisible(plot->wattsCurve->isVisible());
hrCurve->setVisible(plot->hrCurve->isVisible());
speedCurve->setVisible(plot->speedCurve->isVisible());
cadCurve->setVisible(plot->cadCurve->isVisible());
altCurve->setVisible(plot->altCurve->isVisible());
setYMax();
setAxisMaxMajor(yLeft, 5);
setAxisMaxMajor(yLeft2, 5);
setAxisMaxMajor(yRight, 5);
setAxisMaxMajor(yRight2, 5);
if (!smoothWatts.empty()) wattsCurve->attach(this);
if (!smoothHr.empty()) hrCurve->attach(this);
if (!smoothSpeed.empty()) speedCurve->attach(this);

View File

@@ -32,6 +32,7 @@
#include <qwt_plot_zoomer.h>
#include <qwt_plot_picker.h>
#include <qwt_plot_marker.h>
#include <qwt_arrow_button.h>
AllPlotWindow::AllPlotWindow(MainWindow *mainWindow) :
QWidget(mainWindow), mainWindow(mainWindow)
@@ -43,11 +44,32 @@ AllPlotWindow::AllPlotWindow(MainWindow *mainWindow) :
showLayout->addWidget(showLabel);
showStack = new QCheckBox(tr("Stacked view"), this);
showStack->setCheckState(Qt::Unchecked);
boost::shared_ptr<QSettings> settings = GetApplicationSettings();
if (settings->value(GC_RIDE_PLOT_STACK).toInt())
showStack->setCheckState(Qt::Checked);
else
showStack->setCheckState(Qt::Unchecked);
showLayout->addWidget(showStack);
stackWidth = 15;
QLabel *labelspacer = new QLabel(this);
labelspacer->setFixedWidth(5);
showLayout->addWidget(labelspacer);
stackZoomUp = new QwtArrowButton(1, Qt::UpArrow,this);
stackZoomUp->setFixedHeight(15);
stackZoomUp->setFixedWidth(15);
stackZoomUp->setEnabled(false);
showLayout->addWidget(stackZoomUp);
stackZoomDown = new QwtArrowButton(1, Qt::DownArrow,this);
stackZoomDown->setFixedHeight(15);
stackZoomDown->setFixedWidth(15);
stackZoomDown->setEnabled(false);
showLayout->addWidget(stackZoomDown);
QCheckBox *showGrid = new QCheckBox(tr("Grid"), this);
showGrid->setCheckState(Qt::Checked);
showLayout->addWidget(showGrid);
@@ -185,6 +207,12 @@ AllPlotWindow::AllPlotWindow(MainWindow *mainWindow) :
this, SLOT(setShowGrid(int)));
connect(showStack, SIGNAL(stateChanged(int)),
this, SLOT(setShowStack(int)));
connect(stackZoomUp, SIGNAL(clicked()),
this, SLOT(setStackZoomUp()));
connect(stackZoomDown, SIGNAL(clicked()),
this, SLOT(setStackZoomDown()));
connect(comboDistance, SIGNAL(currentIndexChanged(int)),
this, SLOT(setByDistance(int)));
connect(smoothSlider, SIGNAL(valueChanged(int)),
@@ -617,10 +645,41 @@ AllPlotWindow::resetStackedDatas()
}
}
void
AllPlotWindow::setStackZoomUp()
{
if (stackWidth<200 && stackWidth<allPlot->rideItem->ride()->dataPoints().last()->secs/60) {
stackWidth = ceil(stackWidth * 1.25);
stackZoomDown->setEnabled(true);
setShowStack(false);
setShowStack(true);
if (stackWidth>=200 || stackWidth>=allPlot->rideItem->ride()->dataPoints().last()->secs/60)
stackZoomUp->setEnabled(false);
}
}
void
AllPlotWindow::setStackZoomDown()
{
if (stackWidth>4) {
stackWidth = floor(stackWidth / 1.25);
stackZoomUp->setEnabled(true);
setShowStack(false);
setShowStack(true);
if (stackWidth<=4)
stackZoomDown->setEnabled(false);
}
}
void
AllPlotWindow::setShowStack(int value)
{
boost::shared_ptr<QSettings> settings = GetApplicationSettings();
settings->setValue(GC_RIDE_PLOT_STACK, value);
if (value) {
stackZoomUp->setEnabled(true);
stackZoomDown->setEnabled(true);
int _stackWidth = stackWidth;
if (allPlot->byDistance())
_stackWidth = stackWidth/3;
@@ -657,18 +716,18 @@ AllPlotWindow::setShowStack(int value)
// Update AllPlot for stacked view
_allPlot->setDataP(allPlot, startIndex, stopIndex);
_allPlot->setAxisScale(QwtPlot::xBottom, _stackWidth*i, _stackWidth*(i+1), 1);
_allPlot->setAxisScale(QwtPlot::xBottom, _stackWidth*i, _stackWidth*(i+1), 15/stackWidth);
if (i==0){
// First plot view title and legend
_allPlot->setTitle(allPlot->title());
_allPlot->plotLayout()->setLegendPosition(QwtPlot::TopLegend);
_allPlot->setFixedHeight(200);
_allPlot->setFixedHeight(120+stackWidth*2+50);
}
else {
_allPlot->setTitle("");
_allPlot->insertLegend(NULL);
_allPlot->setFixedHeight(150);
_allPlot->setFixedHeight(120+stackWidth*2);
}
// No x axis titles
@@ -699,7 +758,7 @@ AllPlotWindow::setShowStack(int value)
stackFrame->hide();
allPlot->show();
if (allPlots.count()>1) {
if (allPlots.count()>0) {
foreach (AllPlot *plot, allPlots) {
//layout()->removeWidget(plot);
delete plot;

View File

@@ -27,6 +27,7 @@ class QwtPlotPanner;
class QwtPlotZoomer;
class QwtPlotPicker;
class QwtPlotMarker;
class QwtArrowButton;
class RideItem;
class IntervalItem;
@@ -53,6 +54,9 @@ class AllPlotWindow : public QWidget
void zonesChanged();
void intervalsChanged();
void setStackZoomUp();
void setStackZoomDown();
void setShowStack(int state);
void setShowPower(int state);
void setShowHr(int state);
@@ -82,6 +86,10 @@ class AllPlotWindow : public QWidget
QwtPlotPicker *allPicker;
int selection;
QCheckBox *showStack;
QwtArrowButton *stackZoomDown;
QwtArrowButton *stackZoomUp;
QCheckBox *showHr;
QCheckBox *showSpeed;
QCheckBox *showCad;

View File

@@ -32,6 +32,7 @@
#define GC_TABS_TO_HIDE "mainwindow/tabsToHide"
#define GC_SETTINGS_INTERVAL_METRICS "rideSummaryWindow/intervalMetrics"
#define GC_RIDE_PLOT_SMOOTHING "ridePlot/Smoothing"
#define GC_RIDE_PLOT_STACK "ridePlot/Stack"
#define GC_PERF_MAN_METRIC "performanceManager/metric"
#define GC_HIST_BIN_WIDTH "histogamWindow/binWidth"
#define GC_SETTINGS_INTERVAL_METRICS_DEFAULT "workout_time,total_distance,total_work,average_power,skiba_xpower,max_power,average_hr,ninety_five_percent_hr,average_cad,average_speed"