| 499 | } |
| 500 | |
| 501 | void DatapickerImageView::mouseMoveEvent(QMouseEvent* event) { |
| 502 | // show the selection band |
| 503 | if (m_selectionBandIsShown) { |
| 504 | QRect rect = QRect(m_selectionStart, m_selectionEnd).normalized(); |
| 505 | m_selectionEnd = event->pos(); |
| 506 | rect = rect.united(QRect(m_selectionStart, m_selectionEnd).normalized()); |
| 507 | int penWidth = 5 / transform().m11(); |
| 508 | rect.setX(rect.x() - penWidth); |
| 509 | rect.setY(rect.y() - penWidth); |
| 510 | rect.setHeight(rect.height() + 2 * penWidth); |
| 511 | rect.setWidth(rect.width() + 2 * penWidth); |
| 512 | viewport()->repaint(rect); |
| 513 | return; |
| 514 | } |
| 515 | |
| 516 | QPointF pos = mapToScene(event->pos()); |
| 517 | |
| 518 | // show the current coordinates under the mouse cursor in the status bar |
| 519 | if (m_image->plotPointsType() == DatapickerImage::PointsType::CurvePoints) { |
| 520 | Vector3D logicalPos = m_transform->mapSceneToLogical(pos, m_image->axisPoints()); |
| 521 | if (m_image->axisPoints().type == DatapickerImage::GraphType::Ternary) { |
| 522 | Q_EMIT statusInfo(QStringLiteral("a =") + QString::number(logicalPos.x()) + QStringLiteral(", b =") + QString::number(logicalPos.y()) |
| 523 | + QStringLiteral(", c =") + QString::number(logicalPos.z())); |
| 524 | } else { |
| 525 | QString xLabel(QStringLiteral("x")); |
| 526 | QString yLabel(QStringLiteral("y")); |
| 527 | if (m_image->axisPoints().type == DatapickerImage::GraphType::PolarInDegree) { |
| 528 | xLabel = QStringLiteral("r"); |
| 529 | yLabel = QStringLiteral("y(deg)"); |
| 530 | } else if (m_image->axisPoints().type == DatapickerImage::GraphType::PolarInRadians) { |
| 531 | xLabel = QStringLiteral("r"); |
| 532 | yLabel = QStringLiteral("y(rad)"); |
| 533 | } |
| 534 | |
| 535 | if (m_datapicker->activeCurve()) { |
| 536 | QString statusText = i18n("%1, active curve \"%2\": %3=%4, %5=%6", |
| 537 | m_datapicker->name(), |
| 538 | m_datapicker->activeCurve()->name(), |
| 539 | xLabel, |
| 540 | QString::number(logicalPos.x()), |
| 541 | yLabel, |
| 542 | QString::number(logicalPos.y())); |
| 543 | Q_EMIT statusInfo(statusText); |
| 544 | } |
| 545 | } |
| 546 | } |
| 547 | |
| 548 | // show the magnification window |
| 549 | if (magnificationFactor && m_image->isLoaded && sceneRect().contains(pos)) { |
| 550 | if (!m_image->m_magnificationWindow) { |
| 551 | m_image->m_magnificationWindow = new QGraphicsPixmapItem; |
| 552 | scene()->addItem(m_image->m_magnificationWindow); |
| 553 | m_image->m_magnificationWindow->setZValue(std::numeric_limits<int>::max()); |
| 554 | } |
| 555 | |
| 556 | updateMagnificationWindow(); |
| 557 | } else if (m_image->m_magnificationWindow) |
| 558 | m_image->m_magnificationWindow->setVisible(false); |
nothing calls this directly
no test coverage detected