MCPcopy Create free account
hub / github.com/KDE/labplot / activatePlot

Method activatePlot

src/backend/worksheet/plots/cartesian/XYCurve.cpp:2546–2647  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2544}
2545
2546bool XYCurvePrivate::activatePlot(QPointF mouseScenePos, double maxDist) {
2547 if (!isVisible())
2548 return false;
2549
2550 int rowCount{0};
2551 if (lineType != XYCurve::LineType::NoLine && m_lines.size() > 1)
2552 rowCount = m_lines.count();
2553 else if (symbol->style() != Symbol::Style::NoSymbols) {
2554 calculateScenePoints();
2555 rowCount = m_scenePoints.size();
2556 } else
2557 return false;
2558
2559 if (rowCount == 0)
2560 return false;
2561
2562 if (maxDist < 0)
2563 maxDist = (line->pen().width() < 10) ? 10. : line->pen().width();
2564
2565 const double maxDistSquare = gsl_pow_2(maxDist);
2566
2567 const bool noLines = lineType == XYCurve::LineType::NoLine || (lineType != XYCurve::LineType::NoLine && m_lines.isEmpty());
2568 if (noLines)
2569 calculateScenePoints();
2570
2571 const auto& properties = q->xColumn()->properties();
2572 if (properties == AbstractColumn::Properties::No || properties == AbstractColumn::Properties::NonMonotonic) {
2573 // assumption: points exist if no line. otherwise previously returned false
2574 if (noLines) {
2575 QPointF curvePosPrevScene = m_scenePoints.at(0);
2576 QPointF curvePosScene = curvePosPrevScene;
2577 for (int row = 0; row < rowCount; row++) {
2578 if (gsl_pow_2(mouseScenePos.x() - curvePosScene.x()) + gsl_pow_2(mouseScenePos.y() - curvePosScene.y()) <= maxDistSquare)
2579 return true;
2580
2581 curvePosPrevScene = curvePosScene;
2582 curvePosScene = m_scenePoints.at(row);
2583 }
2584 } else {
2585 for (const auto& line : m_lines) {
2586 if (pointLiesNearLine(line.p1(), line.p2(), mouseScenePos, maxDist))
2587 return true;
2588 }
2589 }
2590 } else if (properties == AbstractColumn::Properties::MonotonicIncreasing || properties == AbstractColumn::Properties::MonotonicDecreasing) {
2591 bool increase{true};
2592 if (properties == AbstractColumn::Properties::MonotonicDecreasing)
2593 increase = false;
2594
2595 double x{mouseScenePos.x() - maxDist};
2596 int index{0};
2597
2598 QPointF curvePosScene;
2599 QPointF curvePosPrevScene;
2600
2601 if (noLines) {
2602 curvePosScene = m_scenePoints.at(index);
2603 curvePosPrevScene = curvePosScene;

Callers 1

mousePressEventMethod · 0.45

Calls 7

xMethod · 0.80
sizeMethod · 0.45
countMethod · 0.45
widthMethod · 0.45
isEmptyMethod · 0.45
propertiesMethod · 0.45
yMethod · 0.45

Tested by

no test coverage detected