LTMWindow::LTMWindow(Context *context) : GcChartWindow(context), context(context), dirty(true), stackDirty(true), compareDirty(true) { useToToday = useCustom = false; plotted = DateRange(QDate(01,01,01), QDate(01,01,01)); // the plot QVBoxLayout *mainLayout = new QVBoxLayout; ltmPlot = new LTMPlot(this, context, true); // the stack of plots QPalette palette; palette.setBrush(QPalette::Background, QBrush(GColor(CPLOTBACKGROUND))); plotsWidget = new QWidget(this); plotsWidget->setPalette(palette); plotsLayout = new QVBoxLayout(plotsWidget); plotsLayout->setSpacing(0); plotsLayout->setContentsMargins(0,0,0,0); plotArea = new QScrollArea(this); #ifdef Q_OS_WIN QStyle *cde = QStyleFactory::create(OS_STYLE); plotArea->setStyle(cde); #endif plotArea->setAutoFillBackground(false); plotArea->setWidgetResizable(true); plotArea->setWidget(plotsWidget); plotArea->setFrameStyle(QFrame::NoFrame); plotArea->setContentsMargins(0,0,0,0); plotArea->setPalette(palette); // the data table dataSummary = new QWebView(this); dataSummary->setContentsMargins(0,0,0,0); dataSummary->page()->view()->setContentsMargins(0,0,0,0); dataSummary->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); dataSummary->setAcceptDrops(false); QFont defaultFont; // mainwindow sets up the defaults.. we need to apply dataSummary->settings()->setFontSize(QWebSettings::DefaultFontSize, defaultFont.pointSize()+1); dataSummary->settings()->setFontFamily(QWebSettings::StandardFont, defaultFont.family()); // compare plot page compareplotsWidget = new QWidget(this); compareplotsWidget->setPalette(palette); compareplotsLayout = new QVBoxLayout(compareplotsWidget); compareplotsLayout->setSpacing(0); compareplotsLayout->setContentsMargins(0,0,0,0); compareplotArea = new QScrollArea(this); #ifdef Q_OS_WIN cde = QStyleFactory::create(OS_STYLE); compareplotArea->setStyle(cde); #endif compareplotArea->setAutoFillBackground(false); compareplotArea->setWidgetResizable(true); compareplotArea->setWidget(compareplotsWidget); compareplotArea->setFrameStyle(QFrame::NoFrame); compareplotArea->setContentsMargins(0,0,0,0); compareplotArea->setPalette(palette); // the stack stackWidget = new QStackedWidget(this); stackWidget->addWidget(ltmPlot); stackWidget->addWidget(dataSummary); stackWidget->addWidget(plotArea); stackWidget->addWidget(compareplotArea); stackWidget->setCurrentIndex(0); mainLayout->addWidget(stackWidget); setChartLayout(mainLayout); // reveal controls QHBoxLayout *revealLayout = new QHBoxLayout; revealLayout->setContentsMargins(0,0,0,0); revealLayout->addStretch(); revealLayout->addWidget(new QLabel(tr("Group by"),this)); rGroupBy = new QxtStringSpinBox(this); QStringList strings; strings << tr("Days") << tr("Weeks") << tr("Months") << tr("Years") << tr("Time Of Day") << tr("All"); rGroupBy->setStrings(strings); rGroupBy->setValue(0); revealLayout->addWidget(rGroupBy); rData = new QCheckBox(tr("Data Table"), this); rStack = new QCheckBox(tr("Stacked"), this); QVBoxLayout *checks = new QVBoxLayout; checks->setSpacing(2); checks->setContentsMargins(0,0,0,0); checks->addWidget(rData); checks->addWidget(rStack); revealLayout->addLayout(checks); revealLayout->addStretch(); setRevealLayout(revealLayout); // the controls QWidget *c = new QWidget; c->setContentsMargins(0,0,0,0); QVBoxLayout *cl = new QVBoxLayout(c); cl->setContentsMargins(0,0,0,0); cl->setSpacing(0); setControls(c); // the popup popup = new GcPane(); ltmPopup = new LTMPopup(context); QVBoxLayout *popupLayout = new QVBoxLayout(); popupLayout->addWidget(ltmPopup); popup->setLayout(popupLayout); ltmTool = new LTMTool(context, &settings); // initialise settings.ltmTool = ltmTool; settings.data = NULL; settings.groupBy = LTM_DAY; settings.legend = ltmTool->showLegend->isChecked(); settings.events = ltmTool->showEvents->isChecked(); settings.shadeZones = ltmTool->shadeZones->isChecked(); settings.showData = ltmTool->showData->isChecked(); settings.stack = ltmTool->showStack->isChecked(); settings.stackWidth = ltmTool->stackSlider->value(); rData->setChecked(ltmTool->showData->isChecked()); rStack->setChecked(ltmTool->showStack->isChecked()); cl->addWidget(ltmTool); connect(this, SIGNAL(dateRangeChanged(DateRange)), this, SLOT(dateRangeChanged(DateRange))); connect(ltmTool, SIGNAL(filterChanged()), this, SLOT(filterChanged())); connect(context, SIGNAL(homeFilterChanged()), this, SLOT(filterChanged())); connect(ltmTool->groupBy, SIGNAL(currentIndexChanged(int)), this, SLOT(groupBySelected(int))); connect(rGroupBy, SIGNAL(valueChanged(int)), this, SLOT(rGroupBySelected(int))); connect(ltmTool->applyButton, SIGNAL(clicked(bool)), this, SLOT(applyClicked(void))); connect(ltmTool->shadeZones, SIGNAL(stateChanged(int)), this, SLOT(shadeZonesClicked(int))); connect(ltmTool->showData, SIGNAL(stateChanged(int)), this, SLOT(showDataClicked(int))); connect(rData, SIGNAL(stateChanged(int)), this, SLOT(showDataClicked(int))); connect(ltmTool->showStack, SIGNAL(stateChanged(int)), this, SLOT(showStackClicked(int))); connect(rStack, SIGNAL(stateChanged(int)), this, SLOT(showStackClicked(int))); connect(ltmTool->stackSlider, SIGNAL(valueChanged(int)), this, SLOT(zoomSliderChanged())); connect(ltmTool->showLegend, SIGNAL(stateChanged(int)), this, SLOT(showLegendClicked(int))); connect(ltmTool->showEvents, SIGNAL(stateChanged(int)), this, SLOT(showEventsClicked(int))); connect(ltmTool, SIGNAL(useCustomRange(DateRange)), this, SLOT(useCustomRange(DateRange))); connect(ltmTool, SIGNAL(useThruToday()), this, SLOT(useThruToday())); connect(ltmTool, SIGNAL(useStandardRange()), this, SLOT(useStandardRange())); connect(ltmTool, SIGNAL(curvesChanged()), this, SLOT(refresh())); connect(context, SIGNAL(filterChanged()), this, SLOT(refresh())); // comparing things connect(context, SIGNAL(compareDateRangesStateChanged(bool)), this, SLOT(compareChanged())); connect(context, SIGNAL(compareDateRangesChanged()), this, SLOT(compareChanged())); connect(context, SIGNAL(rideAdded(RideItem*)), this, SLOT(refresh(void))); connect(context, SIGNAL(rideDeleted(RideItem*)), this, SLOT(refresh(void))); connect(context, SIGNAL(configChanged()), this, SLOT(configChanged())); connect(context, SIGNAL(presetSelected(int)), this, SLOT(presetSelected(int))); configChanged(); }
PfPvWindow::PfPvWindow(Context *context) : GcChartWindow(context), context(context), current(NULL), compareStale(true), stale(false) { QWidget *c = new QWidget; HelpWhatsThis *helpConfig = new HelpWhatsThis(c); c->setWhatsThis(helpConfig->getWhatsThisText(HelpWhatsThis::ChartRides_PFvV)); QVBoxLayout *cl = new QVBoxLayout(c); setControls(c); // // reveal controls widget // // layout reveal controls QHBoxLayout *revealLayout = new QHBoxLayout; revealLayout->setContentsMargins(0,0,0,0); rShade = new QCheckBox(tr("Shade zones")); 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); rMergeInterval->hide(); // lets not - its not that useful rFrameInterval = new QCheckBox; rFrameInterval->setText(tr("Frame intervals")); rFrameInterval->setCheckState(Qt::Checked); QVBoxLayout *checks = new QVBoxLayout; checks->addStretch(); checks->addWidget(rShade); checks->addWidget(rMergeInterval); checks->addWidget(rFrameInterval); checks->addStretch(); revealLayout->addStretch(); revealLayout->addLayout(checks); revealLayout->addStretch(); setRevealLayout(revealLayout); // the plot QVBoxLayout *vlayout = new QVBoxLayout; pfPvPlot = new PfPvPlot(context); vlayout->addWidget(pfPvPlot); HelpWhatsThis *help = new HelpWhatsThis(pfPvPlot); pfPvPlot->setWhatsThis(help->getWhatsThisText(HelpWhatsThis::ChartRides_PFvV)); setChartLayout(vlayout); setAutoFillBackground(true); // allow zooming pfpvZoomer = new QwtPlotZoomer(pfPvPlot->canvas()); pfpvZoomer->setRubberBand(QwtPicker::RectRubberBand); pfpvZoomer->setRubberBandPen(GColor(CPLOTSELECT)); pfpvZoomer->setTrackerMode(QwtPicker::AlwaysOff); pfpvZoomer->setEnabled(true); pfpvZoomer->setMousePattern(QwtEventPattern::MouseSelect1, Qt::LeftButton); pfpvZoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlModifier); pfpvZoomer->setMousePattern(QwtEventPattern::MouseSelect3, Qt::RightButton); // double click doubleClickPicker = new PfPvDoubleClickPicker(pfPvPlot); // the controls QFormLayout *f = new QFormLayout; cl->addLayout(f); QLabel *qaCPLabel = new QLabel(tr("Watts:"), this); qaCPValue = new QLineEdit(QString("%1").arg(pfPvPlot->getCP())); qaCPValue->setValidator(new QIntValidator(0, 9999, qaCPValue)); f->addRow(qaCPLabel, qaCPValue); QLabel *qaCadLabel = new QLabel(tr("RPM:"), this); qaCadValue = new QLineEdit(QString("%1").arg(pfPvPlot->getCAD())); qaCadValue->setValidator(new QIntValidator(0, 999, qaCadValue)); f->addRow(qaCadLabel, qaCadValue); QLabel *qaClLabel = new QLabel(tr("Crank Length (m):"), this); qaClValue = new QLineEdit(QString("%1").arg(1000 * pfPvPlot->getCL())); f->addRow(qaClLabel, qaClValue); shadeZonesPfPvCheckBox = new QCheckBox; shadeZonesPfPvCheckBox->setText(tr("Shade zones")); if (appsettings->value(this, GC_SHADEZONES, true).toBool() == true) shadeZonesPfPvCheckBox->setCheckState(Qt::Checked); else shadeZonesPfPvCheckBox->setCheckState(Qt::Unchecked); cl->addWidget(shadeZonesPfPvCheckBox); mergeIntervalPfPvCheckBox = new QCheckBox; mergeIntervalPfPvCheckBox->setText(tr("Merge intervals")); mergeIntervalPfPvCheckBox->setCheckState(Qt::Unchecked); cl->addWidget(mergeIntervalPfPvCheckBox); frameIntervalPfPvCheckBox = new QCheckBox; frameIntervalPfPvCheckBox->setText(tr("Frame intervals")); frameIntervalPfPvCheckBox->setCheckState(Qt::Checked); cl->addWidget(frameIntervalPfPvCheckBox); gearRatioDisplayPfPvCheckBox = new QCheckBox; gearRatioDisplayPfPvCheckBox->setText(tr("Gear Ratio Display")); gearRatioDisplayPfPvCheckBox->setCheckState(Qt::Checked); cl->addWidget(gearRatioDisplayPfPvCheckBox); cl->addStretch(); 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())); 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(gearRatioDisplayPfPvCheckBox, SIGNAL(stateChanged(int)), this, SLOT(setGearRatioDisplayPfPvFromCheckBox())); connect(doubleClickPicker, SIGNAL(doubleClicked(int, int)), this, SLOT(doubleClicked(int, int))); // GC signals connect(this, SIGNAL(rideItemChanged(RideItem*)), this, SLOT(rideSelected())); connect(context, SIGNAL(rideChanged(RideItem*)), this, SLOT(forceReplot())); connect(context, SIGNAL(intervalSelected()), this, SLOT(intervalSelected())); connect(context, SIGNAL(intervalsChanged()), this, SLOT(intervalSelected())); connect(context, SIGNAL(intervalHover(IntervalItem*)), this, SLOT(intervalHover(IntervalItem*))); connect(context->athlete, SIGNAL(zonesChanged()), this, SLOT(zonesChanged())); connect(context, SIGNAL(configChanged(qint32)), this, SLOT(configChanged(qint32))); connect(context, SIGNAL(configChanged(qint32)), pfPvPlot, SLOT(configChanged(qint32))); // comparing things connect(context, SIGNAL(compareIntervalsStateChanged(bool)), this, SLOT(compareChanged())); connect(context, SIGNAL(compareIntervalsChanged()), this, SLOT(compareChanged())); configChanged(CONFIG_APPEARANCE); // share current setting with Plot setGearRatioDisplayPfPvFromCheckBox(); }
LTMWindow::LTMWindow(Context *context) : GcChartWindow(context), context(context), dirty(true), stackDirty(true), compareDirty(true) { useToToday = useCustom = false; plotted = DateRange(QDate(01,01,01), QDate(01,01,01)); lastRefresh = QTime::currentTime().addSecs(-10); // the plot QVBoxLayout *mainLayout = new QVBoxLayout; QPalette palette; palette.setBrush(QPalette::Background, QBrush(GColor(CTRENDPLOTBACKGROUND))); // single plot plotWidget = new QWidget(this); plotWidget->setPalette(palette); QVBoxLayout *plotLayout = new QVBoxLayout(plotWidget); plotLayout->setSpacing(0); plotLayout->setContentsMargins(0,0,0,0); ltmPlot = new LTMPlot(this, context, true); spanSlider = new QxtSpanSlider(Qt::Horizontal, this); spanSlider->setFocusPolicy(Qt::NoFocus); spanSlider->setHandleMovementMode(QxtSpanSlider::NoOverlapping); spanSlider->setLowerValue(0); spanSlider->setUpperValue(15); QFont smallFont; smallFont.setPointSize(6); scrollLeft = new QPushButton("<", this); scrollLeft->setFont(smallFont); scrollLeft->setAutoRepeat(true); scrollLeft->setFixedHeight(16); scrollLeft->setFixedWidth(16); scrollLeft->setContentsMargins(0,0,0,0); scrollRight = new QPushButton(">", this); scrollRight->setFont(smallFont); scrollRight->setAutoRepeat(true); scrollRight->setFixedHeight(16); scrollRight->setFixedWidth(16); scrollRight->setContentsMargins(0,0,0,0); QHBoxLayout *span = new QHBoxLayout; span->addWidget(scrollLeft); span->addWidget(spanSlider); span->addWidget(scrollRight); plotLayout->addWidget(ltmPlot); plotLayout->addLayout(span); #ifdef Q_OS_MAC // BUG in QMacStyle and painting of spanSlider // so we use a plain style to avoid it, but only // on a MAC, since win and linux are fine #if QT_VERSION > 0x5000 QStyle *style = QStyleFactory::create("fusion"); #else QStyle *style = QStyleFactory::create("Cleanlooks"); #endif spanSlider->setStyle(style); scrollLeft->setStyle(style); scrollRight->setStyle(style); #endif // the stack of plots plotsWidget = new QWidget(this); plotsWidget->setPalette(palette); plotsLayout = new QVBoxLayout(plotsWidget); plotsLayout->setSpacing(0); plotsLayout->setContentsMargins(0,0,0,0); plotArea = new QScrollArea(this); #ifdef Q_OS_WIN QStyle *cde = QStyleFactory::create(OS_STYLE); plotArea->setStyle(cde); #endif plotArea->setAutoFillBackground(false); plotArea->setWidgetResizable(true); plotArea->setWidget(plotsWidget); plotArea->setFrameStyle(QFrame::NoFrame); plotArea->setContentsMargins(0,0,0,0); plotArea->setPalette(palette); // the data table QFont defaultFont; // mainwindow sets up the defaults.. we need to apply #ifdef NOWEBKIT dataSummary = new QWebEngineView(this); dataSummary->settings()->setFontSize(QWebEngineSettings::DefaultFontSize, defaultFont.pointSize()+1); dataSummary->settings()->setFontFamily(QWebEngineSettings::StandardFont, defaultFont.family()); #else dataSummary = new QWebView(this); dataSummary->settings()->setFontSize(QWebSettings::DefaultFontSize, defaultFont.pointSize()+1); dataSummary->settings()->setFontFamily(QWebSettings::StandardFont, defaultFont.family()); #endif dataSummary->setContentsMargins(0,0,0,0); dataSummary->page()->view()->setContentsMargins(0,0,0,0); dataSummary->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); dataSummary->setAcceptDrops(false); // compare plot page compareplotsWidget = new QWidget(this); compareplotsWidget->setPalette(palette); compareplotsLayout = new QVBoxLayout(compareplotsWidget); compareplotsLayout->setSpacing(0); compareplotsLayout->setContentsMargins(0,0,0,0); compareplotArea = new QScrollArea(this); #ifdef Q_OS_WIN cde = QStyleFactory::create(OS_STYLE); compareplotArea->setStyle(cde); #endif compareplotArea->setAutoFillBackground(false); compareplotArea->setWidgetResizable(true); compareplotArea->setWidget(compareplotsWidget); compareplotArea->setFrameStyle(QFrame::NoFrame); compareplotArea->setContentsMargins(0,0,0,0); compareplotArea->setPalette(palette); // the stack stackWidget = new QStackedWidget(this); stackWidget->addWidget(plotWidget); stackWidget->addWidget(dataSummary); stackWidget->addWidget(plotArea); stackWidget->addWidget(compareplotArea); stackWidget->setCurrentIndex(0); mainLayout->addWidget(stackWidget); setChartLayout(mainLayout); HelpWhatsThis *helpStack = new HelpWhatsThis(stackWidget); stackWidget->setWhatsThis(helpStack->getWhatsThisText(HelpWhatsThis::ChartTrends_MetricTrends)); // reveal controls QHBoxLayout *revealLayout = new QHBoxLayout; revealLayout->setContentsMargins(0,0,0,0); revealLayout->addStretch(); revealLayout->addWidget(new QLabel(tr("Group by"),this)); rGroupBy = new QxtStringSpinBox(this); QStringList strings; strings << tr("Days") << tr("Weeks") << tr("Months") << tr("Years") << tr("Time Of Day") << tr("All"); rGroupBy->setStrings(strings); rGroupBy->setValue(0); revealLayout->addWidget(rGroupBy); rData = new QCheckBox(tr("Data Table"), this); rStack = new QCheckBox(tr("Stacked"), this); QVBoxLayout *checks = new QVBoxLayout; checks->setSpacing(2); checks->setContentsMargins(0,0,0,0); checks->addWidget(rData); checks->addWidget(rStack); revealLayout->addLayout(checks); revealLayout->addStretch(); setRevealLayout(revealLayout); // add additional menu items before setting // controls since the menu is SET from setControls QAction *exportData = new QAction(tr("Export Chart Data..."), this); addAction(exportData); // the controls QWidget *c = new QWidget; c->setContentsMargins(0,0,0,0); HelpWhatsThis *helpConfig = new HelpWhatsThis(c); c->setWhatsThis(helpConfig->getWhatsThisText(HelpWhatsThis::ChartTrends_MetricTrends)); QVBoxLayout *cl = new QVBoxLayout(c); cl->setContentsMargins(0,0,0,0); cl->setSpacing(0); setControls(c); // the popup popup = new GcPane(); ltmPopup = new LTMPopup(context); QVBoxLayout *popupLayout = new QVBoxLayout(); popupLayout->addWidget(ltmPopup); popup->setLayout(popupLayout); ltmTool = new LTMTool(context, &settings); // initialise settings.ltmTool = ltmTool; settings.groupBy = LTM_DAY; settings.legend = ltmTool->showLegend->isChecked(); settings.events = ltmTool->showEvents->isChecked(); settings.shadeZones = ltmTool->shadeZones->isChecked(); settings.showData = ltmTool->showData->isChecked(); settings.stack = ltmTool->showStack->isChecked(); settings.stackWidth = ltmTool->stackSlider->value(); rData->setChecked(ltmTool->showData->isChecked()); rStack->setChecked(ltmTool->showStack->isChecked()); cl->addWidget(ltmTool); connect(this, SIGNAL(dateRangeChanged(DateRange)), this, SLOT(dateRangeChanged(DateRange))); connect(this, SIGNAL(styleChanged(int)), this, SLOT(styleChanged(int))); connect(ltmTool, SIGNAL(filterChanged()), this, SLOT(filterChanged())); connect(context, SIGNAL(homeFilterChanged()), this, SLOT(filterChanged())); connect(ltmTool->groupBy, SIGNAL(currentIndexChanged(int)), this, SLOT(groupBySelected(int))); connect(rGroupBy, SIGNAL(valueChanged(int)), this, SLOT(rGroupBySelected(int))); connect(ltmTool->applyButton, SIGNAL(clicked(bool)), this, SLOT(applyClicked(void))); connect(ltmTool->shadeZones, SIGNAL(stateChanged(int)), this, SLOT(shadeZonesClicked(int))); connect(ltmTool->showData, SIGNAL(stateChanged(int)), this, SLOT(showDataClicked(int))); connect(rData, SIGNAL(stateChanged(int)), this, SLOT(showDataClicked(int))); connect(ltmTool->showStack, SIGNAL(stateChanged(int)), this, SLOT(showStackClicked(int))); connect(rStack, SIGNAL(stateChanged(int)), this, SLOT(showStackClicked(int))); connect(ltmTool->stackSlider, SIGNAL(valueChanged(int)), this, SLOT(zoomSliderChanged())); connect(ltmTool->showLegend, SIGNAL(stateChanged(int)), this, SLOT(showLegendClicked(int))); connect(ltmTool->showEvents, SIGNAL(stateChanged(int)), this, SLOT(showEventsClicked(int))); connect(ltmTool, SIGNAL(useCustomRange(DateRange)), this, SLOT(useCustomRange(DateRange))); connect(ltmTool, SIGNAL(useThruToday()), this, SLOT(useThruToday())); connect(ltmTool, SIGNAL(useStandardRange()), this, SLOT(useStandardRange())); connect(ltmTool, SIGNAL(curvesChanged()), this, SLOT(refresh())); connect(context, SIGNAL(filterChanged()), this, SLOT(filterChanged())); connect(context, SIGNAL(refreshUpdate(QDate)), this, SLOT(refreshUpdate(QDate))); connect(context, SIGNAL(refreshEnd()), this, SLOT(refresh())); // comparing things connect(context, SIGNAL(compareDateRangesStateChanged(bool)), this, SLOT(compareChanged())); connect(context, SIGNAL(compareDateRangesChanged()), this, SLOT(compareChanged())); connect(context, SIGNAL(rideAdded(RideItem*)), this, SLOT(refresh(void))); connect(context, SIGNAL(rideDeleted(RideItem*)), this, SLOT(refresh(void))); connect(context, SIGNAL(rideSaved(RideItem*)), this, SLOT(refresh(void))); connect(context, SIGNAL(configChanged(qint32)), this, SLOT(configChanged(qint32))); connect(context, SIGNAL(presetSelected(int)), this, SLOT(presetSelected(int))); // custom menu item connect(exportData, SIGNAL(triggered()), this, SLOT(exportData())); // normal view connect(spanSlider, SIGNAL(lowerPositionChanged(int)), this, SLOT(spanSliderChanged())); connect(spanSlider, SIGNAL(upperPositionChanged(int)), this, SLOT(spanSliderChanged())); connect(scrollLeft, SIGNAL(clicked()), this, SLOT(moveLeft())); connect(scrollRight, SIGNAL(clicked()), this, SLOT(moveRight())); configChanged(CONFIG_APPEARANCE); }
HrPwWindow::HrPwWindow(Context *context) : GcChartWindow(context), context(context), current(NULL) { setControls(NULL); // // reveal controls widget // // reveal controls rDelay = new QLabel(tr("HR Delay")); rDelayEdit = new QLineEdit(); rDelayEdit->setFixedWidth(30); rDelaySlider = new QSlider(Qt::Horizontal); rDelaySlider->setTickPosition(QSlider::TicksBelow); rDelaySlider->setTickInterval(10); rDelaySlider->setMinimum(1); rDelaySlider->setMaximum(100); rDelayEdit->setValidator(new QIntValidator(rDelaySlider->minimum(), rDelaySlider->maximum(), rDelayEdit)); rSmooth = new QLabel(tr("Smooth")); rSmoothEdit = new QLineEdit(); rSmoothEdit->setFixedWidth(30); rSmoothSlider = new QSlider(Qt::Horizontal); rSmoothSlider->setTickPosition(QSlider::TicksBelow); rSmoothSlider->setTickInterval(50); rSmoothSlider->setMinimum(1); rSmoothSlider->setMaximum(500); rSmoothEdit->setValidator(new QIntValidator(rSmoothSlider->minimum(), rSmoothSlider->maximum(), rSmoothEdit)); // layout reveal controls QHBoxLayout *r = new QHBoxLayout; r->setSpacing(4); r->setContentsMargins(0,0,0,0); r->addStretch(); r->addWidget(rDelay); r->addWidget(rDelayEdit); r->addWidget(rDelaySlider); r->addSpacing(5); r->addWidget(rSmooth); r->addWidget(rSmoothEdit); r->addWidget(rSmoothSlider); r->addStretch(); setRevealLayout(r); // // Chart layout // QVBoxLayout *vlayout = new QVBoxLayout; // main plot hrPwPlot = new HrPwPlot(context, this); // tooltip on hover over point hrPwPlot->tooltip = new LTMToolTip(QwtPlot::xBottom, QwtPlot::yLeft, QwtPicker::VLineRubberBand, QwtPicker::AlwaysOn, hrPwPlot->canvas(), ""); hrPwPlot->tooltip->setRubberBand(QwtPicker::VLineRubberBand); hrPwPlot->tooltip->setMousePattern(QwtEventPattern::MouseSelect1, Qt::LeftButton, Qt::ShiftModifier); hrPwPlot->tooltip->setTrackerPen(QColor(Qt::black)); hrPwPlot->_canvasPicker = new LTMCanvasPicker(hrPwPlot); // setup the plot QColor inv(Qt::white); inv.setAlpha(0); hrPwPlot->tooltip->setRubberBandPen(inv); hrPwPlot->tooltip->setEnabled(true); vlayout->addWidget(hrPwPlot); vlayout->setStretch(0, 100); // just the hr and power as a plot smallPlot = new SmallPlot(this); smallPlot->setMaximumHeight(200); smallPlot->setMinimumHeight(100); vlayout->addWidget(smallPlot); vlayout->setStretch(1, 20); setChartLayout(vlayout); // // the controls // QWidget *c = new QWidget(this); setControls(c); QFormLayout *cl = new QFormLayout(c); QLabel *delayLabel = new QLabel(tr("HR delay"), this); delayEdit = new QLineEdit(this); delayEdit->setFixedWidth(30); cl->addRow(delayLabel, delayEdit); delaySlider = new QSlider(Qt::Horizontal); delaySlider->setTickPosition(QSlider::TicksBelow); delaySlider->setTickInterval(1); delaySlider->setMinimum(1); delaySlider->setMaximum(100); delayEdit->setValidator(new QIntValidator(delaySlider->minimum(), delaySlider->maximum(), delayEdit)); cl->addRow(delaySlider); smooth = 240; QLabel *smoothLabel = new QLabel(tr("Smooth"), this); smoothEdit = new QLineEdit(this); smoothEdit->setFixedWidth(30); smoothEdit->setText(QString("%1").arg(smooth)); cl->addRow(smoothLabel, smoothEdit); smoothSlider = new QSlider(Qt::Horizontal); smoothSlider->setTickPosition(QSlider::TicksBelow); smoothSlider->setTickInterval(10); smoothSlider->setMinimum(0); smoothSlider->setMaximum(500); smoothSlider->setValue(smooth); smoothEdit->setValidator(new QIntValidator(smoothSlider->minimum(), smoothSlider->maximum(), smoothEdit)); cl->addRow(smoothSlider); joinlineCheckBox = new QCheckBox(this);; joinlineCheckBox->setText(tr("Join points")); joinlineCheckBox->setCheckState(Qt::Unchecked); setJoinLineFromCheckBox(); cl->addRow(joinlineCheckBox); shadeZones = new QCheckBox(this);; shadeZones->setText(tr("Shade Zones")); shadeZones->setCheckState(Qt::Checked); setShadeZones(); cl->addRow(shadeZones); fullplot = new QCheckBox(this);; fullplot->setText(tr("Show Full Plot")); fullplot->setCheckState(Qt::Checked); showHidePlot(); cl->addRow(fullplot); // connect them all up now initialised connect(hrPwPlot->_canvasPicker, SIGNAL(pointHover(QwtPlotCurve*, int)), hrPwPlot, SLOT(pointHover(QwtPlotCurve*, int))); connect(joinlineCheckBox, SIGNAL(stateChanged(int)), this, SLOT(setJoinLineFromCheckBox())); connect(shadeZones, SIGNAL(stateChanged(int)), this, SLOT(setShadeZones())); connect(fullplot, SIGNAL(stateChanged(int)), this, SLOT(showHidePlot())); connect(smoothEdit, SIGNAL(editingFinished()), this, SLOT(setSmoothingFromLineEdit())); connect(smoothSlider, SIGNAL(valueChanged(int)), this, SLOT(setSmoothingFromSlider())); connect(delayEdit, SIGNAL(editingFinished()), this, SLOT(setDelayFromLineEdit())); connect(delaySlider, SIGNAL(valueChanged(int)), this, SLOT(setDelayFromSlider())); connect(rSmoothEdit, SIGNAL(editingFinished()), this, SLOT(setrSmoothingFromLineEdit())); connect(rSmoothSlider, SIGNAL(valueChanged(int)), this, SLOT(setrSmoothingFromSlider())); connect(rDelayEdit, SIGNAL(editingFinished()), this, SLOT(setrDelayFromLineEdit())); connect(rDelaySlider, SIGNAL(valueChanged(int)), this, SLOT(setrDelayFromSlider())); connect(this, SIGNAL(rideItemChanged(RideItem*)), this, SLOT(rideSelected())); }
// // Constructor // HistogramWindow::HistogramWindow(Context *context, bool rangemode) : GcChartWindow(context), context(context), stale(true), source(NULL), active(false), bactive(false), rangemode(rangemode), useCustom(false), useToToday(false), precision(99) { QWidget *c = new QWidget; c->setContentsMargins(0,0,0,0); QFormLayout *cl = new QFormLayout(c); cl->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow); cl->setSpacing(5); setControls(c); // // reveal controls widget // // reveal controls rWidth = new QLabel(tr("Bin Width")); rBinEdit = new QLineEdit(); rBinEdit->setFixedWidth(40); rBinSlider = new QSlider(Qt::Horizontal); rBinSlider->setTickPosition(QSlider::TicksBelow); rBinSlider->setTickInterval(10); rBinSlider->setMinimum(1); rBinSlider->setMaximum(100); rShade = new QCheckBox(tr("Shade zones")); rZones = new QCheckBox(tr("Show in zones")); // layout reveal controls QHBoxLayout *r = new QHBoxLayout; r->setContentsMargins(0,0,0,0); r->addStretch(); r->addWidget(rWidth); r->addWidget(rBinEdit); r->addWidget(rBinSlider); QVBoxLayout *v = new QVBoxLayout; v->addWidget(rShade); v->addWidget(rZones); r->addSpacing(20); r->addLayout(v); r->addStretch(); setRevealLayout(r); // plot QVBoxLayout *vlayout = new QVBoxLayout; vlayout->setSpacing(10); powerHist = new PowerHist(context); vlayout->addWidget(powerHist); setChartLayout(vlayout); #ifdef GC_HAVE_LUCENE // search filter box isfiltered = false; searchBox = new SearchFilterBox(this, context); connect(searchBox, SIGNAL(searchClear()), this, SLOT(clearFilter())); connect(searchBox, SIGNAL(searchResults(QStringList)), this, SLOT(setFilter(QStringList))); if (!rangemode) searchBox->hide(); else { cl->addRow(new QLabel(tr("Filter")), searchBox); cl->addWidget(new QLabel("")); } #endif // date selection dateSetting = new DateSettingsEdit(this); if (rangemode) { cl->addRow(new QLabel(tr("Date Range")), dateSetting); cl->addWidget(new QLabel("")); // spacing // default to data series! data = new QRadioButton(tr("Ride Data Samples")); metric = new QRadioButton(tr("Ride Metrics")); data->setChecked(true); metric->setChecked(false); QHBoxLayout *radios = new QHBoxLayout; radios->addWidget(data); radios->addWidget(metric); cl->addRow(new QLabel(tr("Plot")), radios); connect(data, SIGNAL(toggled(bool)), this, SLOT(dataToggled(bool))); connect(metric, SIGNAL(toggled(bool)), this, SLOT(metricToggled(bool))); } // data series seriesCombo = new QComboBox(); addSeries(); if (rangemode) comboLabel = new QLabel(""); else comboLabel = new QLabel(tr("Data Series")); cl->addRow(comboLabel, seriesCombo); if (rangemode) { // TOTAL METRIC totalMetricTree = new QTreeWidget; #ifdef Q_OS_MAC totalMetricTree->setAttribute(Qt::WA_MacShowFocusRect, 0); #endif totalMetricTree->setColumnCount(2); totalMetricTree->setColumnHidden(1, true); totalMetricTree->setSelectionMode(QAbstractItemView::SingleSelection); totalMetricTree->header()->hide(); //totalMetricTree->setFrameStyle(QFrame::NoFrame); //totalMetricTree->setAlternatingRowColors (true); totalMetricTree->setIndentation(5); totalMetricTree->setContextMenuPolicy(Qt::CustomContextMenu); // ALL METRIC distMetricTree = new QTreeWidget; #ifdef Q_OS_MAC distMetricTree->setAttribute(Qt::WA_MacShowFocusRect, 0); #endif distMetricTree->setColumnCount(2); distMetricTree->setColumnHidden(1, true); distMetricTree->setSelectionMode(QAbstractItemView::SingleSelection); distMetricTree->header()->hide(); //distMetricTree->setFrameStyle(QFrame::NoFrame); distMetricTree->setIndentation(5); distMetricTree->setContextMenuPolicy(Qt::CustomContextMenu); // add them all const RideMetricFactory &factory = RideMetricFactory::instance(); for (int i = 0; i < factory.metricCount(); ++i) { const RideMetric *m = factory.rideMetric(factory.metricName(i)); QTextEdit processHTML(m->name()); // process html encoding of(TM) QString processed = processHTML.toPlainText(); QTreeWidgetItem *add; add = new QTreeWidgetItem(distMetricTree->invisibleRootItem()); add->setText(0, processed); add->setText(1, m->symbol()); // we only want totalising metrics if (m->type() != RideMetric::Total) continue; add = new QTreeWidgetItem(totalMetricTree->invisibleRootItem()); add->setText(0, processed); add->setText(1, m->symbol()); } QHBoxLayout *labels = new QHBoxLayout; metricLabel1 = new QLabel(tr("Total (x-axis)")); labels->addWidget(metricLabel1); metricLabel1->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum); metricLabel2 = new QLabel(tr("Distribution (y-axis)")); metricLabel2->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum); labels->addWidget(metricLabel2); cl->addRow((blankLabel1=new QLabel("")), labels); QHBoxLayout *trees = new QHBoxLayout; trees->addWidget(totalMetricTree); trees->addWidget(distMetricTree); cl->addRow((blankLabel2 = new QLabel("")), trees); colorButton = new ColorButton(this, "Color", QColor(Qt::blue)); colorLabel = new QLabel(tr("Color")); connect(colorButton, SIGNAL(colorChosen(QColor)), this, SLOT(updateChart())); cl->addRow(colorLabel, colorButton); // by default select number of rides by duration // which are the metrics workout_time and ride_count selectTotal("ride_count"); selectMetric("workout_time"); } showSumY = new QComboBox(); showSumY->addItem(tr("Absolute Time")); showSumY->addItem(tr("Percentage Time")); showLabel = new QLabel(tr("Show")); cl->addRow(showLabel, showSumY); showLnY = new QCheckBox; showLnY->setText(tr("Log Y")); cl->addRow(blankLabel3 = new QLabel(""), showLnY); showZeroes = new QCheckBox; showZeroes->setText(tr("With zeros")); cl->addRow(blankLabel4 = new QLabel(""), showZeroes); shadeZones = new QCheckBox; shadeZones->setText(tr("Shade zones")); cl->addRow(blankLabel5 = new QLabel(""), shadeZones); showInZones = new QCheckBox; showInZones->setText(tr("Show in zones")); cl->addRow(blankLabel6 = new QLabel(""), showInZones); // bin width QHBoxLayout *binWidthLayout = new QHBoxLayout; QLabel *binWidthLabel = new QLabel(tr("Bin width"), this); binWidthLineEdit = new QLineEdit(this); binWidthLineEdit->setFixedWidth(40); binWidthLayout->addWidget(binWidthLineEdit); binWidthSlider = new QSlider(Qt::Horizontal); binWidthSlider->setTickPosition(QSlider::TicksBelow); binWidthSlider->setTickInterval(1); binWidthSlider->setMinimum(1); binWidthSlider->setMaximum(100); binWidthLayout->addWidget(binWidthSlider); cl->addRow(binWidthLabel, binWidthLayout); // sort out default values setBinEditors(); showLnY->setChecked(powerHist->islnY()); showZeroes->setChecked(powerHist->withZeros()); shadeZones->setChecked(powerHist->shade); binWidthSlider->setValue(powerHist->binWidth()); rBinSlider->setValue(powerHist->binWidth()); rShade->setChecked(powerHist->shade); // fixup series selected by default seriesChanged(); // hide/show according to default mode switchMode(); // does nothing if not in rangemode // set the defaults etc updateChart(); // the bin slider/input update each other // only the input box triggers an update to the chart connect(binWidthSlider, SIGNAL(valueChanged(int)), this, SLOT(setBinWidthFromSlider())); connect(binWidthLineEdit, SIGNAL(editingFinished()), this, SLOT(setBinWidthFromLineEdit())); connect(rBinSlider, SIGNAL(valueChanged(int)), this, SLOT(setrBinWidthFromSlider())); connect(rBinEdit, SIGNAL(editingFinished()), this, SLOT(setrBinWidthFromLineEdit())); connect(rZones, SIGNAL(stateChanged(int)), this, SLOT(setZoned(int))); connect(rShade, SIGNAL(stateChanged(int)), this, SLOT(setShade(int))); // when season changes we need to retrieve data from the cache then update the chart if (rangemode) { connect(this, SIGNAL(dateRangeChanged(DateRange)), this, SLOT(dateRangeChanged(DateRange))); connect(dateSetting, SIGNAL(useCustomRange(DateRange)), this, SLOT(useCustomRange(DateRange))); connect(dateSetting, SIGNAL(useThruToday()), this, SLOT(useThruToday())); connect(dateSetting, SIGNAL(useStandardRange()), this, SLOT(useStandardRange())); connect(distMetricTree, SIGNAL(itemSelectionChanged()), this, SLOT(treeSelectionChanged())); connect(totalMetricTree, SIGNAL(itemSelectionChanged()), this, SLOT(treeSelectionChanged())); lagger = new QTimer; lagger->setSingleShot(true); connect(lagger, SIGNAL(timeout()), this, SLOT(treeSelectionTimeout())); } else { dateSetting->hide(); connect(this, SIGNAL(rideItemChanged(RideItem*)), this, SLOT(rideSelected())); connect(context, SIGNAL(intervalSelected()), this, SLOT(intervalSelected())); } // if any of the controls change we pass the chart everything connect(showLnY, SIGNAL(stateChanged(int)), this, SLOT(updateChart())); connect(showZeroes, SIGNAL(stateChanged(int)), this, SLOT(updateChart())); connect(seriesCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(seriesChanged())); connect(showInZones, SIGNAL(stateChanged(int)), this, SLOT(setZoned(int))); connect(showInZones, SIGNAL(stateChanged(int)), this, SLOT(updateChart())); connect(shadeZones, SIGNAL(stateChanged(int)), this, SLOT(setShade(int))); connect(shadeZones, SIGNAL(stateChanged(int)), this, SLOT(updateChart())); connect(showSumY, SIGNAL(currentIndexChanged(int)), this, SLOT(updateChart())); connect(context->athlete, SIGNAL(zonesChanged()), this, SLOT(zonesChanged())); connect(context, SIGNAL(configChanged()), powerHist, SLOT(configChanged())); connect(context, SIGNAL(rideAdded(RideItem*)), this, SLOT(rideAddorRemove(RideItem*))); connect(context, SIGNAL(rideDeleted(RideItem*)), this, SLOT(rideAddorRemove(RideItem*))); connect(context, SIGNAL(filterChanged()), this, SLOT(forceReplot())); connect(context, SIGNAL(homeFilterChanged()), this, SLOT(forceReplot())); }
ScatterWindow::ScatterWindow(MainWindow *parent, const QDir &home) : GcChartWindow(parent), home(home), main(parent), ride(NULL), current(NULL) { setInstanceName("2D Window"); // // reveal controls widget // // reveal controls QLabel *rxLabel = new QLabel(tr("X-Axis:"), this); rxSelector = new QxtStringSpinBox(); addrStandardChannels(rxSelector); QLabel *ryLabel = new QLabel(tr("Y-Axis:"), this); rySelector = new QxtStringSpinBox(); addrStandardChannels(rySelector); rIgnore = new QCheckBox(tr("Ignore Zero")); rIgnore->setChecked(true); rIgnore->hide(); rFrameInterval = new QCheckBox(tr("Frame intervals")); rFrameInterval->setChecked(true); // layout reveal controls QHBoxLayout *r = new QHBoxLayout; r->setContentsMargins(0,0,0,0); r->addStretch(); r->addWidget(rxLabel); r->addWidget(rxSelector); r->addWidget(ryLabel); r->addWidget(rySelector); r->addSpacing(5); r->addWidget(rIgnore); r->addWidget(rFrameInterval); r->addStretch(); setRevealLayout(r); QWidget *c = new QWidget; QFormLayout *cl = new QFormLayout(c); setControls(c); // the plot widget scatterPlot= new ScatterPlot(main); QVBoxLayout *vlayout = new QVBoxLayout; vlayout->addWidget(scatterPlot); setChartLayout(vlayout); // labels xLabel = new QLabel(tr("X-Axis:"), this); xSelector = new QComboBox; addStandardChannels(xSelector); xSelector->setCurrentIndex(0); // power rxSelector->setValue(0); cl->addRow(xLabel, xSelector); yLabel = new QLabel(tr("Y-Axis:"), this); ySelector = new QComboBox; addStandardChannels(ySelector); ySelector->setCurrentIndex(2); // heartrate rySelector->setValue(2); cl->addRow(yLabel, ySelector); timeLabel = new QLabel(tr("00:00:00"), this); timeSlider = new QSlider(Qt::Horizontal); timeSlider->setTickPosition(QSlider::TicksBelow); timeSlider->setTickInterval(1); timeSlider->setMinimum(0); timeSlider->setTickInterval(5); timeSlider->setMaximum(100); timeSlider->setValue(0); timeSlider->setTracking(true); cl->addRow(timeLabel, timeSlider); // selectors ignore = new QCheckBox(tr("Ignore Zero")); ignore->setChecked(true); cl->addRow(ignore); grid = new QCheckBox(tr("Show Grid")); grid->setChecked(true); cl->addRow(grid); frame = new QCheckBox(tr("Frame Intervals")); frame->setChecked(true); cl->addRow(frame); // now connect up the widgets //connect(main, SIGNAL(rideSelected()), this, SLOT(rideSelected())); connect(this, SIGNAL(rideItemChanged(RideItem*)), this, SLOT(rideSelected())); connect(main, SIGNAL(intervalSelected()), this, SLOT(intervalSelected())); connect(main, SIGNAL(intervalsChanged()), this, SLOT(intervalSelected())); connect(xSelector, SIGNAL(currentIndexChanged(int)), this, SLOT(setData())); connect(ySelector, SIGNAL(currentIndexChanged(int)), this, SLOT(setData())); connect(rxSelector, SIGNAL(valueChanged(int)), this, SLOT(rxSelectorChanged(int))); connect(rySelector, SIGNAL(valueChanged(int)), this, SLOT(rySelectorChanged(int))); connect(timeSlider, SIGNAL(valueChanged(int)), this, SLOT(setTime(int))); connect(grid, SIGNAL(stateChanged(int)), this, SLOT(setGrid())); //connect(legend, SIGNAL(stateChanged(int)), this, SLOT(setLegend())); connect(frame, SIGNAL(stateChanged(int)), this, SLOT(setFrame())); connect(ignore, SIGNAL(stateChanged(int)), this, SLOT(setIgnore())); connect(rFrameInterval, SIGNAL(stateChanged(int)), this, SLOT(setrFrame())); connect(rIgnore, SIGNAL(stateChanged(int)), this, SLOT(setrIgnore())); }