! Returns a data selection which is the exact inverse of this data selection, with \a outerRange defining the base range on which to invert. If \a outerRange is smaller than the \ref span of this data selection, it is expanded accordingly. For example, this method can be used to retrieve all unselected segments by setting \a outerRange to the full data range of the plottable, and callin
| 2737 | selected segments. |
| 2738 | */ |
| 2739 | QCPDataSelection QCPDataSelection::inverse(const QCPDataRange &outerRange) const |
| 2740 | { |
| 2741 | if (isEmpty()) |
| 2742 | return QCPDataSelection(outerRange); |
| 2743 | QCPDataRange fullRange = outerRange.expanded(span()); |
| 2744 | |
| 2745 | QCPDataSelection result; |
| 2746 | // first unselected segment: |
| 2747 | if (mDataRanges.first().begin() != fullRange.begin()) |
| 2748 | result.addDataRange(QCPDataRange(fullRange.begin(), mDataRanges.first().begin()), false); |
| 2749 | // intermediate unselected segments: |
| 2750 | for (int i=1; i<mDataRanges.size(); ++i) |
| 2751 | result.addDataRange(QCPDataRange(mDataRanges.at(i-1).end(), mDataRanges.at(i).begin()), false); |
| 2752 | // last unselected segment: |
| 2753 | if (mDataRanges.last().end() != fullRange.end()) |
| 2754 | result.addDataRange(QCPDataRange(mDataRanges.last().end(), fullRange.end()), false); |
| 2755 | result.simplify(); |
| 2756 | return result; |
| 2757 | } |
| 2758 | /* end of 'src/selection.cpp' */ |
| 2759 | |
| 2760 |