void SituationModel::setSituationSeries(const int theValue, bool update) { if (theValue != m_situationSeries) { if (debugLevel & 1 << MODEL) std::cout << "Situation " << this << " Series " << m_seriesNames[theValue].toStdString() << std::endl; m_situationSeries = (Series) theValue; foreach(TrackModel *track, m_tracks) { track->setSeries(m_situationSeries, true); } if (update) emit seriesChanged(m_situationSeries); }
// display label... QVBoxLayout *layout = new QVBoxLayout(this); layout->setSpacing(0); layout->setContentsMargins(3,3,3,3); valueLabel = new QLabel(this); valueLabel->setAlignment(Qt::AlignCenter | Qt::AlignVCenter); layout->addWidget(valueLabel); // get updates.. connect(mainWindow, SIGNAL(telemetryUpdate(RealtimeData)), this, SLOT(telemetryUpdate(RealtimeData))); connect(seriesSelector, SIGNAL(currentIndexChanged(int)), this, SLOT(seriesChanged())); connect(averageSlider, SIGNAL(valueChanged(int)),this, SLOT(setAverageFromSlider())); connect(averageEdit, SIGNAL(textChanged(const QString)), this, SLOT(setAverageFromText(const QString))); connect(mainWindow, SIGNAL(configChanged()), this, SLOT(seriesChanged())); connect(mainWindow, SIGNAL(stop()), this, SLOT(stop())); connect(mainWindow, SIGNAL(start()), this, SLOT(start())); connect(mainWindow, SIGNAL(newLap()), this, SLOT(onNewLap())); // setup colors seriesChanged(); // setup fontsize etc resizeEvent(NULL); // set to zero resetValues(); } void
averageLayout->addWidget(averageEdit); controlsLayout->addRow(averageLabel, averageLayout); // display label... QVBoxLayout *layout = new QVBoxLayout; layout->setSpacing(0); layout->setContentsMargins(3,3,3,3); valueLabel = new QLabel(this); valueLabel->setAlignment(Qt::AlignCenter | Qt::AlignVCenter); layout->addWidget(valueLabel); setChartLayout(layout); // get updates.. connect(context, SIGNAL(telemetryUpdate(RealtimeData)), this, SLOT(telemetryUpdate(RealtimeData))); connect(context, SIGNAL(configChanged(qint32)), this, SLOT(seriesChanged())); connect(context, SIGNAL(stop()), this, SLOT(stop())); connect(context, SIGNAL(start()), this, SLOT(start())); connect(context, SIGNAL(newLap()), this, SLOT(onNewLap())); connect(seriesSelector, SIGNAL(currentIndexChanged(int)), this, SLOT(seriesChanged())); connect(averageSlider, SIGNAL(valueChanged(int)),this, SLOT(setAverageFromSlider())); connect(averageEdit, SIGNAL(textChanged(const QString)), this, SLOT(setAverageFromText(const QString))); // setup colors seriesChanged(); // setup fontsize etc resizeEvent(NULL); // set to zero
void HistogramWindow::switchMode() { if (!rangemode) return; // ! only valid in rangemode if (data->isChecked()) { // hide all the metric controls blankLabel1->hide(); blankLabel2->hide(); distMetricTree->hide(); totalMetricTree->hide(); metricLabel1->hide(); metricLabel2->hide(); colorLabel->hide(); colorButton->hide(); // show all the data series controls comboLabel->show(); seriesCombo->show(); blankLabel3->show(); blankLabel4->show(); blankLabel5->show(); blankLabel6->show(); showSumY->show(); showLabel->show(); showLnY->show(); showZeroes->show(); shadeZones->show(); showInZones->show(); // select the series.. seriesChanged(); } else { // hide all the data series controls comboLabel->hide(); seriesCombo->hide(); blankLabel3->hide(); blankLabel4->hide(); blankLabel5->hide(); blankLabel6->hide(); showSumY->hide(); showLabel->hide(); showLnY->hide(); showZeroes->hide(); shadeZones->hide(); showInZones->hide(); // show all the metric controls blankLabel1->show(); blankLabel2->show(); metricLabel1->show(); metricLabel2->show(); distMetricTree->show(); totalMetricTree->show(); colorLabel->show(); colorButton->show(); // select the series.. (but without the half second delay) treeSelectionTimeout(); } stale = true; updateChart(); // to whatever is currently selected. }
// // 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())); }