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

Method processRectSelection

projects/gui/3rdparty/qcustomplot/qcustomplot.cpp:16049–16124  ·  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

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

Callers

nothing calls this directly

Calls 15

normalizedMethod · 0.80
plottablesMethod · 0.80
dataPointCountMethod · 0.80
endMethod · 0.80
constEndMethod · 0.80
constBeginMethod · 0.80
selectionCategoryMethod · 0.80
valueMethod · 0.80
selectEventMethod · 0.80
layerMethod · 0.80
foreachFunction · 0.70
selectTestRectMethod · 0.45

Tested by

no test coverage detected