void OdroidReader::updateCurve(int row, int col) { if (col != 0) return; bool enable = ui->sensors->item(row,col)->checkState() == Qt::Checked; if (enable && graphs.at(row) == nullptr) { if (origcols.count() == 0) { ui->sensors->item(row,col)->setCheckState(Qt::Unchecked); return; } QColor color = origcols.takeFirst(); QCPGraph* graph = ui->globalPlot->addGraph(); DataSeries* series = data[rowMap[row]]; graph->setName(series->descriptor->name()); graph->setProperty("unit",series->descriptor->unit()); graph->setPen(color); graph->setData(series->getTimestamps(), series->getValues()); connect(series,&DataSeries::newValue,[graph,this](double time, double value) { graph->addData(time,value); ui->globalPlot->rescaleAxes(); ui->globalPlot->yAxis->scaleRange(1.2,ui->globalPlot->yAxis->range().center()); ui->globalPlot->replot(); }); graphs[row] = graph; ui->sensors->item(row,col)->setBackgroundColor(color); } else if (!enable && graphs.at(row) != nullptr){ disconnect(data.at(rowMap[row]),SIGNAL(newValue(double,double)),0,0); origcols.push_front(graphs.at(row)->pen().color()); ui->globalPlot->removeGraph(graphs.at(row)); graphs[row] = nullptr; ui->sensors->item(row,col)->setBackgroundColor(Qt::white); }
void DataExplorer::updateDetails() { //qDebug() << "SELECT!"; ui->runPlot->clearPlottables(); QVector<QString> labels; QVector<double> ticks; int colid = 0; switch (ui->detailType->currentIndex()) { case 0: ui->runPlot->xAxis->setAutoTicks(true); ui->runPlot->xAxis->setAutoTickLabels(true); for (QCPAbstractPlottable *p : ui->selectEnvironment->selectedPlottables()) { int unitid = p->property("UID").toInt(); int envid = p->property("EID").toInt(); DataSeries v = exp->runs.keys().at(envid)->run(unitid,ui->runNo->value(),exp); QCPGraph *g = ui->runPlot->addGraph(); g->setName(v.descriptor->name()+" @ "+exp->runs.keys().at(envid)->label); g->setProperty("Unit",v.descriptor->unit()); g->setPen(origcols[colid++%origcols.size()]); g->setData(v.getTimestamps(),v.getValues()); } break; case 1: for (QCPAbstractPlottable *p : ui->selectEnvironment->selectedPlottables()) { int unitid = p->property("UID").toInt(); int envid = p->property("EID").toInt(); StatisticalSet vals = exp->runs.keys().at(envid)->integral(unitid,exp); QCPStatisticalBox* b = new QCPStatisticalBox(ui->runPlot->xAxis,ui->runPlot->yAxis); b->setData(colid,vals.min(),vals.quantile(0.25),vals.median(),vals.quantile(0.75),vals.max()); b->setProperty("StdDev",vals.getStdDev()); b->setProperty("avg",vals.avg()); b->setProperty("avgTime",vals.avgTime()); qWarning() << exp->data.at(unitid)->descriptor->name() << exp->runs.keys().at(envid)->label << vals.avg() << vals.avgTime() << vals.getStdDev(); ui->runPlot->addPlottable(b); labels.append(QString("%1 @ %2").arg(exp->data.at(unitid)->descriptor->name(),exp->runs.keys().at(envid)->label)); ticks.append(colid++); ui->runPlot->xAxis->setAutoTicks(false); ui->runPlot->xAxis->setAutoTickLabels(false); ui->runPlot->xAxis->setSubTickCount(0); ui->runPlot->xAxis->setTickLength(0, 4); ui->runPlot->xAxis->setTickLabelRotation(90); ui->runPlot->xAxis->setTickVector(ticks); ui->runPlot->xAxis->setTickVectorLabels(labels); } break; case 2: break; } ui->runPlot->rescaleAxes(); if (ui->axisFromZero->isChecked()) ui->runPlot->yAxis->setRangeLower(0); ui->runPlot->replot(); }