void plot_analytics::plotAnalyze( QCPGraph *target, plotStats *stats, QCPRange keyRange) { QCPGraphDataContainer::const_iterator plotIterator = target->data().data()->findBegin(keyRange.lower,true); QCPGraphDataContainer::const_iterator targetDataEnd = target->data().data()->findEnd(keyRange.upper,true); QCPGraphData currentPoint, prevPoint; //Find the data ranges currentPoint.key = keyRange.lower; prevPoint = QCPGraphData(plotIterator->key, plotIterator->value); while(plotIterator != targetDataEnd && (keyRange.contains(plotIterator->key) || stats->totalData_entrys < 2)) { currentPoint = QCPGraphData(plotIterator->key, plotIterator->value); handlePoints(currentPoint, prevPoint, stats); //Value is weighted to account for datapoints that may not be equally spaced if(!isInvalidData(currentPoint.value) && !isInvalidData(prevPoint.value)) stats->avgValue += currentPoint.value*(currentPoint.key-prevPoint.key); prevPoint = QCPGraphData(plotIterator->key, plotIterator->value); ++plotIterator; } //Divide by total seconds stats->avgValue /= stats->totalData_seconds; }
void plot_analytics::plotAnalyze( QCPGraph *target, QVector<plotStats> *stats, QCPRange keyRange, double iterator) { plotStats currentRangeStats; QCPRange currentRange = keyRange; currentRange.upper = currentRange.lower + iterator; while(keyRange.contains(currentRange.upper)) { //Gernate and append the stats plotAnalyze( target, ¤tRangeStats, currentRange); stats->append(currentRangeStats); //Update working range currentRange.lower = currentRange.upper; currentRange.upper += iterator; } }
void plot_analytics::clearUnwantedPoints(QCPGraph *target, QCPGraph *enableReference, QCPRange valueEnableRange) { QCPGraphDataContainer::iterator plotIterator = target->data()->begin(); QCPGraphDataContainer::const_iterator refIterator; //First we scan and any time the reference plot is not in range wipe the plot data. //TODO: This will break the plot, do we clone the plot? That could be a huge amount of data... while(plotIterator != target->data()->end()) { //Find closest reference point refIterator = enableReference->data().data()->findBegin(plotIterator->key, true); if (!valueEnableRange.contains(refIterator->value)) plotIterator->value = std::numeric_limits<double>::quiet_NaN(); ++plotIterator; } }