MCPcopy Create free account
hub / github.com/LUX-Core/lux / processRectSelection

Method processRectSelection

src/qt/qcustomplot.cpp:15272–15344  ·  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

15270 \see processRectZoom
15271*/
15272void QCustomPlot::processRectSelection(QRect rect, QMouseEvent *event)
15273{
15274 bool selectionStateChanged = false;
15275
15276 if (mInteractions.testFlag(QCP::iSelectPlottables))
15277 {
15278 QMap<int, QPair<QCPAbstractPlottable*, QCPDataSelection> > potentialSelections; // map key is number of selected data points, so we have selections sorted by size
15279 QRectF rectF(rect.normalized());
15280 if (QCPAxisRect *affectedAxisRect = axisRectAt(rectF.topLeft()))
15281 {
15282 // determine plottables that were hit by the rect and thus are candidates for selection:
15283 Q_FOREACH (QCPAbstractPlottable *plottable, affectedAxisRect->plottables())
15284 {
15285 if (QCPPlottableInterface1D *plottableInterface = plottable->interface1D())
15286 {
15287 QCPDataSelection dataSel = plottableInterface->selectTestRect(rectF, true);
15288 if (!dataSel.isEmpty())
15289 potentialSelections.insertMulti(dataSel.dataPointCount(), QPair<QCPAbstractPlottable*, QCPDataSelection>(plottable, dataSel));
15290 }
15291 }
15292
15293 if (!mInteractions.testFlag(QCP::iMultiSelect))
15294 {
15295 // only leave plottable with most selected points in map, since we will only select a single plottable:
15296 if (!potentialSelections.isEmpty())
15297 {
15298 QMap<int, QPair<QCPAbstractPlottable*, QCPDataSelection> >::iterator it = potentialSelections.begin();
15299 while (it != potentialSelections.end()-1) // erase all except last element
15300 it = potentialSelections.erase(it);
15301 }
15302 }
15303
15304 bool additive = event->modifiers().testFlag(mMultiSelectModifier);
15305 // deselect all other layerables if not additive selection:
15306 if (!additive)
15307 {
15308 // emit deselection except to those plottables who will be selected afterwards:
15309 Q_FOREACH (QCPLayer *layer, mLayers)
15310 {
15311 Q_FOREACH (QCPLayerable *layerable, layer->children())
15312 {
15313 if ((potentialSelections.isEmpty() || potentialSelections.constBegin()->first != layerable) && mInteractions.testFlag(layerable->selectionCategory()))
15314 {
15315 bool selChanged = false;
15316 layerable->deselectEvent(&selChanged);
15317 selectionStateChanged |= selChanged;
15318 }
15319 }
15320 }
15321 }
15322
15323 // go through selections in reverse (largest selection first) and emit select events:
15324 QMap<int, QPair<QCPAbstractPlottable*, QCPDataSelection> >::const_iterator it = potentialSelections.constEnd();
15325 while (it != potentialSelections.constBegin())
15326 {
15327 --it;
15328 if (mInteractions.testFlag(it.value().first->selectionCategory()))
15329 {

Callers

nothing calls this directly

Calls 15

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

Tested by

no test coverage detected