diff --git a/src/AllPlot.cpp b/src/AllPlot.cpp index a16dde105..6696a0fff 100644 --- a/src/AllPlot.cpp +++ b/src/AllPlot.cpp @@ -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); diff --git a/src/AllPlotWindow.cpp b/src/AllPlotWindow.cpp index c9f8a9b0a..e15c4ced0 100644 --- a/src/AllPlotWindow.cpp +++ b/src/AllPlotWindow.cpp @@ -32,6 +32,7 @@ #include #include #include +#include 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 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 && stackWidthrideItem->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 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; diff --git a/src/AllPlotWindow.h b/src/AllPlotWindow.h index bc28e6027..38b2e1a7b 100644 --- a/src/AllPlotWindow.h +++ b/src/AllPlotWindow.h @@ -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; diff --git a/src/Settings.h b/src/Settings.h index cad3a8251..ce8bb9f17 100644 --- a/src/Settings.h +++ b/src/Settings.h @@ -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"