MCPcopy Create free account
hub / github.com/CloudCompare/CloudCompare / processRectSelection

Method processRectSelection

qCC/extern/QCustomPlot/qcustomplot.cpp:16030–16105  ·  view source on GitHub ↗

! \internal This slot is connected to the selection rect's \ref QCPSelectionRect::accepted signal when \ref setSelectionRectMode is set to \ref QCP::srmSelect. First, it determines which axis rect was the origin of the selection rect judging by the starting point of the selection. Then it goes through the plottables (\ref QCPAbstractPlottable1D to be precise) associated with that axi

Source from the content-addressed store, hash-verified

16028 \see processRectZoom
16029*/
16030void QCustomPlot::processRectSelection(QRect rect, QMouseEvent *event)
16031{
16032 typedef QPair<QCPAbstractPlottable*, QCPDataSelection> SelectionCandidate;
16033 typedef QMultiMap<int, SelectionCandidate> SelectionCandidates; // map key is number of selected data points, so we have selections sorted by size
16034
16035 bool selectionStateChanged = false;
16036
16037 if (mInteractions.testFlag(QCP::iSelectPlottables))
16038 {
16039 SelectionCandidates potentialSelections;
16040 QRectF rectF(rect.normalized());
16041 if (QCPAxisRect *affectedAxisRect = axisRectAt(rectF.topLeft()))
16042 {
16043 // determine plottables that were hit by the rect and thus are candidates for selection:
16044 foreach (QCPAbstractPlottable *plottable, affectedAxisRect->plottables())
16045 {
16046 if (QCPPlottableInterface1D *plottableInterface = plottable->interface1D())
16047 {
16048 QCPDataSelection dataSel = plottableInterface->selectTestRect(rectF, true);
16049 if (!dataSel.isEmpty())
16050 potentialSelections.insert(dataSel.dataPointCount(), SelectionCandidate(plottable, dataSel));
16051 }
16052 }
16053
16054 if (!mInteractions.testFlag(QCP::iMultiSelect))
16055 {
16056 // only leave plottable with most selected points in map, since we will only select a single plottable:
16057 if (!potentialSelections.isEmpty())
16058 {
16059 SelectionCandidates::iterator it = potentialSelections.begin();
16060 while (it != std::prev(potentialSelections.end())) // erase all except last element
16061 it = potentialSelections.erase(it);
16062 }
16063 }
16064
16065 bool additive = event->modifiers().testFlag(mMultiSelectModifier);
16066 // deselect all other layerables if not additive selection:
16067 if (!additive)
16068 {
16069 // emit deselection except to those plottables who will be selected afterwards:
16070 foreach (QCPLayer *layer, mLayers)
16071 {
16072 foreach (QCPLayerable *layerable, layer->children())
16073 {
16074 if ((potentialSelections.isEmpty() || potentialSelections.constBegin()->first != layerable) && mInteractions.testFlag(layerable->selectionCategory()))
16075 {
16076 bool selChanged = false;
16077 layerable->deselectEvent(&selChanged);
16078 selectionStateChanged |= selChanged;
16079 }
16080 }
16081 }
16082 }
16083
16084 // go through selections in reverse (largest selection first) and emit select events:
16085 SelectionCandidates::const_iterator it = potentialSelections.constEnd();
16086 while (it != potentialSelections.constBegin())
16087 {

Callers

nothing calls this directly

Calls 15

plottablesMethod · 0.80
dataPointCountMethod · 0.80
constEndMethod · 0.80
constBeginMethod · 0.80
selectionCategoryMethod · 0.80
selectEventMethod · 0.80
replotMethod · 0.80
layerMethod · 0.80
foreachFunction · 0.70
normalizedMethod · 0.45
selectTestRectMethod · 0.45
isEmptyMethod · 0.45

Tested by

no test coverage detected