From 50d596db0959a702dac4d517e453c300ceca07bb Mon Sep 17 00:00:00 2001 From: Damien Date: Thu, 17 Jan 2013 22:29:59 +0100 Subject: [PATCH] Add reveal controls for CP Plot and PfPv Plot --- src/AllPlotWindow.cpp | 3 +- src/CriticalPowerWindow.cpp | 79 +++++++++++++++++++++++++++++----- src/CriticalPowerWindow.h | 9 ++++ src/HistogramWindow.cpp | 1 - src/HrPwWindow.cpp | 3 ++ src/PfPvWindow.cpp | 84 ++++++++++++++++++++++++++++++++++++- src/PfPvWindow.h | 13 ++++++ 7 files changed, 178 insertions(+), 14 deletions(-) diff --git a/src/AllPlotWindow.cpp b/src/AllPlotWindow.cpp index b23f965e3..afee49d62 100644 --- a/src/AllPlotWindow.cpp +++ b/src/AllPlotWindow.cpp @@ -79,7 +79,7 @@ AllPlotWindow::AllPlotWindow(MainWindow *mainWindow) : // reveal widget revealControls = new QWidget(this); revealControls->setFixedHeight(50); - //revealControls->setStyleSheet("background-color: rgba(100%, 100%, 100%, 20%)"); + revealControls->setStyleSheet("background-color: rgba(100%, 100%, 100%, 70%)"); revealControls->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum); // reveal controls @@ -96,7 +96,6 @@ AllPlotWindow::AllPlotWindow(MainWindow *mainWindow) : // layout reveal controls QHBoxLayout *r = new QHBoxLayout; - r->setSpacing(4); r->setContentsMargins(0,0,0,0); r->addStretch(); r->addWidget(rSmooth); diff --git a/src/CriticalPowerWindow.cpp b/src/CriticalPowerWindow.cpp index e763f48eb..0e1a559f3 100644 --- a/src/CriticalPowerWindow.cpp +++ b/src/CriticalPowerWindow.cpp @@ -38,11 +38,42 @@ CriticalPowerWindow::CriticalPowerWindow(const QDir &home, MainWindow *parent, b { setInstanceName("Critical Power Window"); + // Main layout + QGridLayout *mainLayout = new QGridLayout(this); + mainLayout->setContentsMargins(0,0,0,0); + + // + // reveal controls widget + // + + // reveal widget + revealControls = new QWidget(this); + revealControls->setFixedHeight(50); + //revealControls->setStyleSheet("background-color: rgba(100%, 100%, 100%, 10%)"); + revealControls->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum); + + // layout reveal controls + QHBoxLayout *revealLayout = new QHBoxLayout; + revealLayout->setContentsMargins(0,0,0,0); + revealLayout->addStretch(); + + rCpintSetCPButton = new QPushButton(tr("&Save CP value"), this); + rCpintSetCPButton->setEnabled(false); + + revealLayout->addWidget(rCpintSetCPButton); + revealLayout->addStretch(); + + revealControls->setLayout(revealLayout); + + // hide them initially + revealControls->hide(); + + // main plot area QVBoxLayout *vlayout = new QVBoxLayout; cpintPlot = new CpintPlot(mainWindow, home.path(), mainWindow->zones()); vlayout->addWidget(cpintPlot); - setLayout(vlayout); + // controls QWidget *c = new QWidget; @@ -60,6 +91,20 @@ CriticalPowerWindow::CriticalPowerWindow(const QDir &home, MainWindow *parent, b cl->addWidget(new QLabel("")); //spacing #endif + // + // picker + // + + // picker widget + QWidget *pickerControls = new QWidget(this); + pickerControls->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); + + // picker layout + QVBoxLayout *pickerLayout = new QVBoxLayout(pickerControls); + QFormLayout *pcl = new QFormLayout; + pickerLayout->addSpacing(50); + pickerLayout->addLayout(pcl); + // picker details QLabel *cpintTimeLabel = new QLabel(tr("Duration:"), this); cpintTimeValue = new QLineEdit("0 s"); @@ -86,11 +131,11 @@ CriticalPowerWindow::CriticalPowerWindow(const QDir &home, MainWindow *parent, b cpintAllValue->setFont(font); cpintCPValue->setFont(font); - cl->addRow(cpintTimeLabel, cpintTimeValue); - cl->addRow(cpintTodayLabel, cpintTodayValue); - cl->addRow(cpintAllLabel, cpintAllValue); - cl->addRow(cpintCPLabel, cpintCPValue); - cl->addWidget(new QLabel("")); //spacing + pcl->addRow(cpintTimeLabel, cpintTimeValue); + pcl->addRow(cpintTodayLabel, cpintTodayValue); + pcl->addRow(cpintAllLabel, cpintAllValue); + pcl->addRow(cpintCPLabel, cpintCPValue); + pcl->addWidget(new QLabel("")); //spacing // tools /properties seriesCombo = new QComboBox(this); @@ -119,7 +164,7 @@ CriticalPowerWindow::CriticalPowerWindow(const QDir &home, MainWindow *parent, b cl->addWidget(new QLabel("")); //spacing cl->addRow(new QLabel(tr("Data series")), seriesCombo); - cl->addRow(new QLabel(""), cpintSetCPButton); + pcl->addRow(new QLabel(""), cpintSetCPButton); picker = new QwtPlotPicker(QwtPlot::xBottom, QwtPlot::yLeft, QwtPicker::VLineRubberBand, @@ -127,9 +172,18 @@ CriticalPowerWindow::CriticalPowerWindow(const QDir &home, MainWindow *parent, b picker->setStateMachine(new QwtPickerDragPointMachine); picker->setRubberBandPen(GColor(CPLOTTRACKER)); + mainLayout->addLayout(vlayout, 0, 0); + mainLayout->addWidget(pickerControls, 0, 0, Qt::AlignTop | Qt::AlignRight); + mainLayout->addWidget(revealControls,0,0, Qt::AlignTop); + pickerControls->raise(); + revealControls->raise(); + setLayout(mainLayout); + connect(picker, SIGNAL(moved(const QPoint &)), SLOT(pickerMoved(const QPoint &))); connect(cpintTimeValue, SIGNAL(editingFinished()), this, SLOT(cpintTimeValueEntered())); connect(cpintSetCPButton, SIGNAL(clicked()), this, SLOT(cpintSetCPButtonClicked())); + connect(rCpintSetCPButton, SIGNAL(clicked()), this, SLOT(cpintSetCPButtonClicked())); + if (rangemode) { connect(this, SIGNAL(dateRangeChanged(DateRange)), SLOT(dateRangeChanged(DateRange))); } else { @@ -193,6 +247,7 @@ CriticalPowerWindow::rideSelected() // apply latest colors picker->setRubberBandPen(GColor(CPLOTTRACKER)); cpintSetCPButton->setEnabled(cpintPlot->cp > 0); + rCpintSetCPButton->setEnabled(cpintPlot->cp > 0); } } @@ -366,10 +421,12 @@ void CriticalPowerWindow::addSeries() << RideFile::none; // XXX actually this shows energy (hack) foreach (RideFile::SeriesType x, seriesList) { - if (x==RideFile::none) + if (x==RideFile::none) { seriesCombo->addItem(tr("Energy"), static_cast(x)); - else + } + else { seriesCombo->addItem(RideFile::seriesName(x), static_cast(x)); + } } } @@ -397,7 +454,9 @@ CriticalPowerWindow::resetSeasons() } // restore previous selection int index = cComboSeason->findText(prev); - if (index != -1) cComboSeason->setCurrentIndex(index); + if (index != -1) { + cComboSeason->setCurrentIndex(index); + } } void diff --git a/src/CriticalPowerWindow.h b/src/CriticalPowerWindow.h index df8b2b9bc..d4a581cb9 100644 --- a/src/CriticalPowerWindow.h +++ b/src/CriticalPowerWindow.h @@ -58,6 +58,11 @@ class CriticalPowerWindow : public GcWindow CriticalPowerWindow(const QDir &home, MainWindow *parent, bool range = false); + // reveal + bool hasReveal() { return true; } + void reveal() { revealControls->show(); } + void unreveal() { revealControls->hide(); } + void deleteCpiFile(QString filename); // set/get properties @@ -121,6 +126,9 @@ class CriticalPowerWindow : public GcWindow void useThruToday(); private: + // reveal controls + QWidget *revealControls; + void updateCpint(double minutes); QString _dateRange; @@ -137,6 +145,7 @@ class CriticalPowerWindow : public GcWindow QComboBox *seriesCombo; QComboBox *cComboSeason; QPushButton *cpintSetCPButton; + QPushButton *rCpintSetCPButton; QwtPlotPicker *picker; void addSeries(); Seasons *seasons; diff --git a/src/HistogramWindow.cpp b/src/HistogramWindow.cpp index 1294d73d9..10e747b40 100644 --- a/src/HistogramWindow.cpp +++ b/src/HistogramWindow.cpp @@ -68,7 +68,6 @@ HistogramWindow::HistogramWindow(MainWindow *mainWindow, bool rangemode) : GcWin // layout reveal controls QHBoxLayout *r = new QHBoxLayout; - r->setSpacing(4); r->setContentsMargins(0,0,0,0); r->addStretch(); r->addWidget(rWidth); diff --git a/src/HrPwWindow.cpp b/src/HrPwWindow.cpp index 9bc835b4d..4328f74aa 100644 --- a/src/HrPwWindow.cpp +++ b/src/HrPwWindow.cpp @@ -89,6 +89,9 @@ HrPwWindow::HrPwWindow(MainWindow *mainWindow) : r->addStretch(); revealControls->setLayout(r); + // hide them initially + revealControls->hide(); + // // Chart layout // diff --git a/src/PfPvWindow.cpp b/src/PfPvWindow.cpp index b25fd6c42..3db956be4 100644 --- a/src/PfPvWindow.cpp +++ b/src/PfPvWindow.cpp @@ -33,11 +33,56 @@ PfPvWindow::PfPvWindow(MainWindow *mainWindow) : QVBoxLayout *cl = new QVBoxLayout(c); setControls(c); + // Main layout + QGridLayout *mainLayout = new QGridLayout(this); + mainLayout->setContentsMargins(0,0,0,0); + + // + // reveal controls widget + // + + // reveal widget + revealControls = new QWidget(this); + revealControls->setFixedHeight(50); + //revealControls->setStyleSheet("background-color: rgba(100%, 100%, 100%, 10%)"); + revealControls->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum); + + // layout reveal controls + QHBoxLayout *revealLayout = new QHBoxLayout; + revealLayout->setContentsMargins(0,0,0,0); + revealLayout->addStretch(); + + rShade = new QCheckBox(tr("Shade zones"), revealControls); + if (appsettings->value(this, GC_SHADEZONES, true).toBool() == true) + rShade->setCheckState(Qt::Checked); + else + rShade->setCheckState(Qt::Unchecked); + rMergeInterval = new QCheckBox; + rMergeInterval->setText(tr("Merge intervals")); + rMergeInterval->setCheckState(Qt::Unchecked); + rFrameInterval = new QCheckBox; + rFrameInterval->setText(tr("Frame intervals")); + rFrameInterval->setCheckState(Qt::Checked); + + revealLayout->addWidget(rShade); + revealLayout->addWidget(rMergeInterval); + revealLayout->addWidget(rFrameInterval); + revealLayout->addStretch(); + + revealControls->setLayout(revealLayout); + + // hide them initially + revealControls->hide(); + // the plot QVBoxLayout *vlayout = new QVBoxLayout; pfPvPlot = new PfPvPlot(mainWindow); vlayout->addWidget(pfPvPlot); - setLayout(vlayout); + + mainLayout->addLayout(vlayout,0,0); + mainLayout->addWidget(revealControls,0,0, Qt::AlignTop); + revealControls->raise(); + setLayout(mainLayout); // allow zooming pfpvZoomer = new QwtPlotZoomer(pfPvPlot->canvas()); @@ -100,10 +145,16 @@ PfPvWindow::PfPvWindow(MainWindow *mainWindow) : this, SLOT(setQaCLFromLineEdit())); connect(shadeZonesPfPvCheckBox, SIGNAL(stateChanged(int)), this, SLOT(setShadeZonesPfPvFromCheckBox())); + connect(rShade, SIGNAL(stateChanged(int)), + this, SLOT(setrShadeZonesPfPvFromCheckBox())); connect(mergeIntervalPfPvCheckBox, SIGNAL(stateChanged(int)), this, SLOT(setMergeIntervalsPfPvFromCheckBox())); + connect(rMergeInterval, SIGNAL(stateChanged(int)), + this, SLOT(setrMergeIntervalsPfPvFromCheckBox())); connect(frameIntervalPfPvCheckBox, SIGNAL(stateChanged(int)), this, SLOT(setFrameIntervalsPfPvFromCheckBox())); + connect(rFrameInterval, SIGNAL(stateChanged(int)), + this, SLOT(setrFrameIntervalsPfPvFromCheckBox())); //connect(mainWindow, SIGNAL(rideSelected()), this, SLOT(rideSelected())); connect(this, SIGNAL(rideItemChanged(RideItem*)), this, SLOT(rideSelected())); connect(mainWindow, SIGNAL(intervalSelected()), this, SLOT(intervalSelected())); @@ -152,6 +203,17 @@ PfPvWindow::setShadeZonesPfPvFromCheckBox() { if (pfPvPlot->shadeZones() != shadeZonesPfPvCheckBox->isChecked()) { pfPvPlot->setShadeZones(shadeZonesPfPvCheckBox->isChecked()); + rShade->setChecked(shadeZonesPfPvCheckBox->isChecked()); + } + pfPvPlot->replot(); +} + +void +PfPvWindow::setrShadeZonesPfPvFromCheckBox() +{ + if (pfPvPlot->shadeZones() != rShade->isChecked()) { + pfPvPlot->setShadeZones(rShade->isChecked()); + shadeZonesPfPvCheckBox->setChecked(rShade->isChecked()); } pfPvPlot->replot(); } @@ -161,6 +223,16 @@ PfPvWindow::setMergeIntervalsPfPvFromCheckBox() { if (pfPvPlot->mergeIntervals() != mergeIntervalPfPvCheckBox->isChecked()) { pfPvPlot->setMergeIntervals(mergeIntervalPfPvCheckBox->isChecked()); + rMergeInterval->setChecked(mergeIntervalPfPvCheckBox->isChecked()); + } +} + +void +PfPvWindow::setrMergeIntervalsPfPvFromCheckBox() +{ + if (pfPvPlot->mergeIntervals() != rMergeInterval->isChecked()) { + pfPvPlot->setMergeIntervals(rMergeInterval->isChecked()); + mergeIntervalPfPvCheckBox->setChecked(rMergeInterval->isChecked()); } } @@ -169,6 +241,16 @@ PfPvWindow::setFrameIntervalsPfPvFromCheckBox() { if (pfPvPlot->frameIntervals() != frameIntervalPfPvCheckBox->isChecked()) { pfPvPlot->setFrameIntervals(frameIntervalPfPvCheckBox->isChecked()); + rFrameInterval->setChecked(frameIntervalPfPvCheckBox->isChecked()); + } +} + +void +PfPvWindow::setrFrameIntervalsPfPvFromCheckBox() +{ + if (pfPvPlot->frameIntervals() != rFrameInterval->isChecked()) { + pfPvPlot->setFrameIntervals(rFrameInterval->isChecked()); + frameIntervalPfPvCheckBox->setChecked(rFrameInterval->isChecked()); } } diff --git a/src/PfPvWindow.h b/src/PfPvWindow.h index 1de82f28f..6063475cf 100644 --- a/src/PfPvWindow.h +++ b/src/PfPvWindow.h @@ -43,6 +43,11 @@ class PfPvWindow : public GcWindow PfPvWindow(MainWindow *mainWindow); + // reveal + bool hasReveal() { return true; } + void reveal() { revealControls->show(); } + void unreveal() { revealControls->hide(); } + // get/set properties QString watts() const { return qaCPValue->text(); } void setWatts(QString x) { qaCPValue->setText(x); } @@ -69,8 +74,11 @@ class PfPvWindow : public GcWindow void setQaCADFromLineEdit(); void setQaCLFromLineEdit(); void setShadeZonesPfPvFromCheckBox(); + void setrShadeZonesPfPvFromCheckBox(); void setMergeIntervalsPfPvFromCheckBox(); + void setrMergeIntervalsPfPvFromCheckBox(); void setFrameIntervalsPfPvFromCheckBox(); + void setrFrameIntervalsPfPvFromCheckBox(); protected: @@ -84,6 +92,11 @@ class PfPvWindow : public GcWindow QLineEdit *qaCadValue; QLineEdit *qaClValue; RideItem *current; + + private: + // reveal controls + QWidget *revealControls; + QCheckBox *rShade, *rMergeInterval, *rFrameInterval; }; #endif // _GC_PfPvWindow_h