void IntervalSummaryWindow::intervalSelected() { // if no ride available don't bother - just reset for color changes if (context->currentRideItem() == NULL || context->currentRide() == NULL) { // no ride just update the colors QString html = GCColor::css(); html += "<body></body>"; setHtml(html); return; } QString html = GCColor::css(); html += "<body>"; if (context->athlete->allIntervalItems() != NULL) { for (int i=0; i<context->athlete->allIntervalItems()->childCount(); i++) { IntervalItem *current = dynamic_cast<IntervalItem*>(context->athlete->allIntervalItems()->child(i)); if (current != NULL) { if (current->isSelected()) { calcInterval(current, html); } } } } if (html == GCColor::css()+"<body>") { html += "<i>" + tr("select an interval for summary info") + "</i>"; } html += "</body>"; setHtml(html); return; }
void ModelWindow::setData(bool adjustPlot) { settings.ride = ride; settings.x = xSelector->itemData(xSelector->currentIndex()).toInt(); settings.y = ySelector->itemData(ySelector->currentIndex()).toInt(); settings.z = zSelector->itemData(zSelector->currentIndex()).toInt(); settings.color = colorSelector->itemData(colorSelector->currentIndex()).toInt(); settings.xbin = binWidthSlider->value(); // XXX fixed to single bin width settings.ybin = binWidthSlider->value(); // XXX due to issues with bar geometry settings.crop = false; // XXX not implemented settings.zpane = 0; settings.ignore = ignore->isChecked(); settings.gridlines = grid->isChecked(); settings.frame = frame->isChecked(); settings.legend = legend->isChecked(); settings.adjustPlot = adjustPlot; zpane->setValue(0); // reset it! // any intervals to plot? settings.intervals.clear(); for (int i=0; i<main->allIntervalItems()->childCount(); i++) { IntervalItem *current = dynamic_cast<IntervalItem *>(main->allIntervalItems()->child(i)); if (current != NULL && current->isSelected() == true) settings.intervals.append(current); } modelPlot->setData(&settings); setClean(); }
void ScatterWindow::setData() { settings.ride = ride; settings.x = xSelector->itemData(xSelector->currentIndex()).toInt(); settings.y = ySelector->itemData(ySelector->currentIndex()).toInt(); settings.ignore = ignore->isChecked(); settings.gridlines = grid->isChecked(); settings.frame = frame->isChecked(); /* Not a blank state ? Just no data and we can change series ? if ((setting.x == MODEL_POWER || setting.y == MODEL_POWER ) && !ride->ride()->isDataPresent(RideFile::watts)) setIsBlank(true); else if ((setting.x == MODEL_CADENCE || setting.y == MODEL_CADENCE ) && !ride->ride()->isDataPresent(RideFile::cad)) setIsBlank(true); else if ((setting.x == MODEL_HEARTRATE || setting.y == MODEL_HEARTRATE ) && !ride->ride()->isDataPresent(RideFile::hr)) setIsBlank(true); else if ((setting.x == MODEL_SPEED || setting.y == MODEL_SPEED ) && !ride->ride()->isDataPresent(RideFile::kph)) setIsBlank(true); else setIsBlank(false); */ // any intervals to plot? settings.intervals.clear(); for (int i=0; i<main->allIntervalItems()->childCount(); i++) { IntervalItem *current = dynamic_cast<IntervalItem *>(main->allIntervalItems()->child(i)); if (current != NULL && current->isSelected() == true) settings.intervals.append(current); } scatterPlot->setData(&settings); }
// ------------------------------------------------------------------------------------------------------------ // note this is operating on the children of allIntervals and not the // intervalWidget (QTreeWidget) -- this is why we do not use the // selectedItems() member. N starts a one not zero. // ------------------------------------------------------------------------------------------------------------ IntervalItem *IntervalAerolabData::intervalNum ( int number ) const { int highlighted = 0; const QTreeWidgetItem *allIntervals = context->athlete->allIntervalItems(); for ( int ii = 0; ii < allIntervals->childCount(); ii++) { IntervalItem *current = (IntervalItem *) allIntervals->child( ii ); if ( current == NULL) { return NULL; } if ( current->isSelected() == true ) { ++highlighted; } if ( highlighted == number ) { return current; } } return NULL; }
QList<TimeInterval*> IntervalEditImpl::intervals() const { QList<TimeInterval*> l; int cnt = intervalList->topLevelItemCount(); for (int i=0; i < cnt; ++i) { IntervalItem *item = static_cast<IntervalItem*>(intervalList->topLevelItem(i)); l.append(new TimeInterval(item->interval().first, item->interval().second)); } return l; }
void IntervalEditImpl::slotIntervalSelectionChanged() { QList<QTreeWidgetItem*> lst = intervalList->selectedItems(); if (lst.count() == 0) return; IntervalItem *ii = static_cast<IntervalItem *>(lst[0]); startTime->setTime(ii->interval().first); length->setValue((double)(ii->interval().second) / (1000.*60.*60.)); enableButtons(); }
// how many intervals selected? int PfPvPlot::intervalCount() const { int highlighted; highlighted = 0; if (context->athlete->allIntervalItems() == NULL) return 0; // not inited yet! for (int i=0; i<context->athlete->allIntervalItems()->childCount(); i++) { IntervalItem *current = dynamic_cast<IntervalItem *>(context->athlete->allIntervalItems()->child(i)); if (current != NULL) { if (current->isSelected() == true) { ++highlighted; } } } return highlighted; }
void ModelWindow::setData(bool adjustPlot) { settings.ride = ride; settings.x = xSelector->itemData(xSelector->currentIndex()).toInt(); settings.y = ySelector->itemData(ySelector->currentIndex()).toInt(); settings.z = zSelector->itemData(zSelector->currentIndex()).toInt(); settings.color = colorSelector->itemData(colorSelector->currentIndex()).toInt(); settings.xbin = binWidthSlider->value(); settings.ybin = binWidthSlider->value(); settings.crop = false; // not implemented yet settings.zpane = 0; settings.ignore = ignore->isChecked(); settings.gridlines = grid->isChecked(); settings.frame = frame->isChecked(); settings.legend = legend->isChecked(); settings.adjustPlot = adjustPlot; zpane->setValue(0); // reset it! // any intervals to plot? settings.intervals.clear(); for (int i=0; i<main->allIntervalItems()->childCount(); i++) { IntervalItem *current = dynamic_cast<IntervalItem *>(main->allIntervalItems()->child(i)); if (current != NULL && current->isSelected() == true) settings.intervals.append(current); } setUpdatesEnabled(false); // reset the model parameters modelPlot->setData(&settings); // if setdata resulted in the plot being hidden // then the settings were not valid. if (modelPlot->basicModelPlot->isHidden()) { zpane->hide(); nodata->show(); } else { zpane->show(); nodata->hide(); } setClean(); setUpdatesEnabled(true); }
void Athlete::updateRideFileIntervals() { // iterate over context->athlete->allIntervals as they are now defined // and update the RideFile->intervals RideItem *which = (RideItem *)treeWidget->selectedItems().first(); RideFile *current = which->ride(); current->clearIntervals(); for (int i=0; i < allIntervals->childCount(); i++) { // add the intervals as updated IntervalItem *it = (IntervalItem *)allIntervals->child(i); current->addInterval(it->start, it->stop, it->text(0)); } // emit signal for interval data changed context->notifyIntervalsChanged(); // set dirty which->setDirty(true); }
// ------------------------------------------------------------------------------------------------------------ // how many intervals selected? // ------------------------------------------------------------------------------------------------------------ int IntervalAerolabData::intervalCount() const { int highlighted = 0; if ( context->athlete->allIntervalItems() != NULL ) { const QTreeWidgetItem *allIntervals = context->athlete->allIntervalItems(); for ( int ii = 0; ii < allIntervals->childCount(); ii++) { IntervalItem *current = (IntervalItem *) allIntervals->child( ii ); if ( current != NULL ) { if ( current->isSelected() == true ) { ++highlighted; } } } } return highlighted; }
void IntervalSummaryWindow::intervalSelected() { // if no ride available don't bother if (mainWindow->currentRideItem() == NULL || mainWindow->currentRide() == NULL) return; QString html; if (mainWindow->allIntervalItems() != NULL) { for (int i=0; i<mainWindow->allIntervalItems()->childCount(); i++) { IntervalItem *current = dynamic_cast<IntervalItem*>(mainWindow->allIntervalItems()->child(i)); if (current != NULL) { if (current->isSelected()) { calcInterval(current, html); } } } } if (html.length() == 0) html = "<i>" + tr("select an interval for summary info") + "</i>"; setHtml(html); return; }
void Tab::rideSelected(RideItem*) { // update the ride property on all widgets // to let them know they need to replot new // selected ride setRide(context->ride); if (!context->ride) return; // refresh interval list for bottom left // first lets wipe away the existing intervals QList<QTreeWidgetItem *> intervals = context->athlete->allIntervals->takeChildren(); for (int i=0; i<intervals.count(); i++) delete intervals.at(i); // now add the intervals for the current ride if (context->ride) { // only if we have a ride pointer RideFile *selected = context->ride->ride(); if (selected) { // get all the intervals in the currently selected RideFile QList<RideFileInterval> intervals = selected->intervals(); for (int i=0; i < intervals.count(); i++) { // add as a child to context->athlete->allIntervals IntervalItem *add = new IntervalItem(selected, intervals.at(i).name, intervals.at(i).start, intervals.at(i).stop, selected->timeToDistance(intervals.at(i).start), selected->timeToDistance(intervals.at(i).stop), context->athlete->allIntervals->childCount()+1); add->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsDragEnabled); context->athlete->allIntervals->addChild(add); } } } }
void ScatterPlot::setData (ScatterSettings *settings) { // get application settings cranklength = appsettings->value(this, GC_CRANKLENGTH, 0.0).toDouble() / 1000.0; // if there are no settings or incomplete settings // create a null data plot if (settings == NULL || settings->ride == NULL || settings->ride->ride() == NULL || settings->x == 0 || settings->y == 0 ) { return; } // if its not setup or no settings exist default to 175mm cranks if (cranklength == 0.0) cranklength = 0.175; // // Create Main Plot dataset - used to frame intervals // int points=0; x.clear(); y.clear(); x.resize(settings->ride->ride()->dataPoints().count()); y.resize(settings->ride->ride()->dataPoints().count()); double maxY = maxX = -65535; double minY = minX = 65535; foreach(const RideFilePoint *point, settings->ride->ride()->dataPoints()) { double xv = x[points] = pointType(point, settings->x, context->athlete->useMetricUnits, cranklength); double yv = y[points] = pointType(point, settings->y, context->athlete->useMetricUnits, cranklength); // skip zeroes? if (!(settings->ignore && (x[points] == 0 || y[points] == 0))) { points++; if (yv > maxY) maxY = yv; if (yv < minY) minY = yv; if (xv > maxX) maxX = xv; if (xv < minX) minX = xv; } } QwtSymbol sym; sym.setStyle(QwtSymbol::Ellipse); sym.setSize(6); sym.setPen(GCColor::invert(GColor(CPLOTBACKGROUND))); sym.setBrush(QBrush(Qt::NoBrush)); QPen p; p.setColor(GColor(CPLOTSYMBOL)); sym.setPen(p); // wipe away existing if (all) { all->detach(); delete all; } // setup the framing curve if (settings->frame) { all = new QwtPlotCurve(); all->setSymbol(new QwtSymbol(sym)); all->setStyle(QwtPlotCurve::Dots); all->setRenderHint(QwtPlotItem::RenderAntialiased); all->setData(x.constData(), y.constData(), points); all->attach(this); } else { all = NULL; } QPen gridPen(GColor(CPLOTGRID)); gridPen.setStyle(Qt::DotLine); if (grid) { grid->detach(); delete grid; } if (settings->gridlines) { grid = new QwtPlotGrid(); grid->setPen(gridPen); grid->enableX(true); grid->enableY(true); grid->attach(this); } else { grid = NULL; } setAxisTitle(yLeft, describeType(settings->y, true, useMetricUnits)); setAxisTitle(xBottom, describeType(settings->x, true, useMetricUnits)); // truncate PfPv values to make easier to read if (settings->y == MODEL_AEPF) setAxisScale(yLeft, 0, 600); else setAxisScale(yLeft, minY, maxY); if (settings->x == MODEL_CPV) setAxisScale(xBottom, 0, 3); else setAxisScale(xBottom, minX, maxX); // // Create Interval Plot dataset - used to frame intervals // // clear out any interval curves which are presently defined if (intervalCurves.size()) { QListIterator<QwtPlotCurve *> i(intervalCurves); while (i.hasNext()) { QwtPlotCurve *curve = i.next(); curve->detach(); delete curve; } } intervalCurves.clear(); // which ones are highlighted then? QVector<int> intervals; QMap<int,int> displaySequence; for (int child=0; child<context->athlete->allIntervalItems()->childCount(); child++) { IntervalItem *current = dynamic_cast<IntervalItem *>(context->athlete->allIntervalItems()->child(child)); if ((current != NULL) && current->isSelected()) { intervals.append(child); displaySequence.insert(current->displaySequence, intervals.count()-1); } } if (intervals.count() > 0) { // interval data in here QVector<QVector<double> > xvals(intervals.count()); // array of curve x arrays QVector<QVector<double> > yvals(intervals.count()); // array of curve x arrays QVector<int> points(intervals.count()); // points in eac curve // extract interval data foreach(const RideFilePoint *point, settings->ride->ride()->dataPoints()) { double x = pointType(point, settings->x, useMetricUnits, cranklength); double y = pointType(point, settings->y, useMetricUnits, cranklength); if (!(settings->ignore && (x == 0 && y ==0))) { // which interval is it in? for (int idx=0; idx<intervals.count(); idx++) { IntervalItem *current = dynamic_cast<IntervalItem *>(context->athlete->allIntervalItems()->child(intervals[idx])); if (point->secs+settings->ride->ride()->recIntSecs() > current->start && point->secs< current->stop) { xvals[idx].append(x); yvals[idx].append(y); points[idx]++; } } } } // now we have the interval data lets create the curves QMapIterator<int, int> order(displaySequence); while (order.hasNext()) { order.next(); int idx = order.value(); QPen pen; QColor intervalColor; intervalColor.setHsv((255/context->athlete->allIntervalItems()->childCount()) * (intervals[idx]), 255,255); pen.setColor(intervalColor); sym.setPen(pen); QwtPlotCurve *curve = new QwtPlotCurve(); curve->setSymbol(new QwtSymbol(sym)); curve->setStyle(QwtPlotCurve::Dots); curve->setRenderHint(QwtPlotItem::RenderAntialiased); curve->setData(xvals[idx].constData(), yvals[idx].constData(), points[idx]); curve->attach(this); intervalCurves.append(curve); } }