MCPcopy Create free account
hub / github.com/collin80/SavvyCAN / enforceType

Method enforceType

qcustomplot.cpp:2610–2649  ·  view source on GitHub ↗

! Makes sure this data selection conforms to the specified \a type selection type. Before the type is enforced, \ref simplify is called. Depending on \a type, enforcing means adding new data points that were previously not part of the selection, or removing data points from the selection. If the current selection already conforms to \a type, the data selection is not changed. \se

Source from the content-addressed store, hash-verified

2608 \see QCP::SelectionType
2609*/
2610void QCPDataSelection::enforceType(QCP::SelectionType type)
2611{
2612 simplify();
2613 switch (type)
2614 {
2615 case QCP::stNone:
2616 {
2617 mDataRanges.clear();
2618 break;
2619 }
2620 case QCP::stWhole:
2621 {
2622 // whole selection isn't defined by data range, so don't change anything (is handled in plottable methods)
2623 break;
2624 }
2625 case QCP::stSingleData:
2626 {
2627 // reduce all data ranges to the single first data point:
2628 if (!mDataRanges.isEmpty())
2629 {
2630 if (mDataRanges.size() > 1)
2631 mDataRanges = QList<QCPDataRange>() << mDataRanges.first();
2632 if (mDataRanges.first().length() > 1)
2633 mDataRanges.first().setEnd(mDataRanges.first().begin()+1);
2634 }
2635 break;
2636 }
2637 case QCP::stDataRange:
2638 {
2639 if (!isEmpty())
2640 mDataRanges = QList<QCPDataRange>() << span();
2641 break;
2642 }
2643 case QCP::stMultipleDataRanges:
2644 {
2645 // this is the selection type that allows all concievable combinations of ranges, so do nothing
2646 break;
2647 }
2648 }
2649}
2650
2651/*!
2652 Returns true if the data selection \a other is contained entirely in this data selection, i.e.

Callers 2

setSelectionMethod · 0.80
setSelectableMethod · 0.80

Calls 5

isEmptyFunction · 0.85
clearMethod · 0.45
isEmptyMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected