! 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
| 2598 | simplify explicitly set to false. |
| 2599 | */ |
| 2600 | void QCPDataSelection::simplify() |
| 2601 | { |
| 2602 | // remove any empty ranges: |
| 2603 | for (int i=mDataRanges.size()-1; i>=0; --i) |
| 2604 | { |
| 2605 | if (mDataRanges.at(i).isEmpty()) |
| 2606 | mDataRanges.removeAt(i); |
| 2607 | } |
| 2608 | if (mDataRanges.isEmpty()) |
| 2609 | return; |
| 2610 | |
| 2611 | // sort ranges by starting value, ascending: |
| 2612 | std::sort(mDataRanges.begin(), mDataRanges.end(), lessThanDataRangeBegin); |
| 2613 | |
| 2614 | // join overlapping/contiguous ranges: |
| 2615 | int i = 1; |
| 2616 | while (i < mDataRanges.size()) |
| 2617 | { |
| 2618 | 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 |
| 2619 | { |
| 2620 | mDataRanges[i-1].setEnd(qMax(mDataRanges.at(i-1).end(), mDataRanges.at(i).end())); |
| 2621 | mDataRanges.removeAt(i); |
| 2622 | } else |
| 2623 | ++i; |
| 2624 | } |
| 2625 | } |
| 2626 | |
| 2627 | /*! |
| 2628 | Makes sure this data selection conforms to the specified \a type selection type. Before the type |
no test coverage detected