MCPcopy Create free account
hub / github.com/CieNTi/serial_port_plotter / simplify

Method simplify

qcustomplot/qcustomplot.cpp:2573–2598  ·  view source on GitHub ↗

! Sorts all data ranges by range begin index in ascending order, and then joins directly adjacent or overlapping ranges. This can reduce the number of individual data ranges in the selection, and prevents possible double-counting when iterating over the data points held by the data ranges. This method is automatically called when using the addition/subtraction operators. The only case w

Source from the content-addressed store, hash-verified

2571 simplify explicitly set to false.
2572*/
2573void QCPDataSelection::simplify()
2574{
2575 // remove any empty ranges:
2576 for (int i=mDataRanges.size()-1; i>=0; --i)
2577 {
2578 if (mDataRanges.at(i).isEmpty())
2579 mDataRanges.removeAt(i);
2580 }
2581 if (mDataRanges.isEmpty())
2582 return;
2583
2584 // sort ranges by starting value, ascending:
2585 std::sort(mDataRanges.begin(), mDataRanges.end(), lessThanDataRangeBegin);
2586
2587 // join overlapping/contiguous ranges:
2588 int i = 1;
2589 while (i < mDataRanges.size())
2590 {
2591 if (mDataRanges.at(i-1).end() >= mDataRanges.at(i).begin()) // range i overlaps/joins with i-1, so expand range i-1 appropriately and remove range i from list
2592 {
2593 mDataRanges[i-1].setEnd(qMax(mDataRanges.at(i-1).end(), mDataRanges.at(i).end()));
2594 mDataRanges.removeAt(i);
2595 } else
2596 ++i;
2597 }
2598}
2599
2600/*!
2601 Makes sure this data selection conforms to the specified \a type selection type. Before the type

Callers 8

addDataRangeMethod · 0.95
intersectionMethod · 0.80
inverseMethod · 0.80
selectTestRectMethod · 0.80
getDataSegmentsMethod · 0.80
selectTestRectMethod · 0.80
selectTestMethod · 0.80
getDataSegmentsMethod · 0.80

Calls 9

rowCountFunction · 0.85
columnCountFunction · 0.85
atMethod · 0.80
removeAtMethod · 0.80
endMethod · 0.80
clearMethod · 0.60
sizeMethod · 0.45
isEmptyMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected