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

Method mouseMoveEvent

src/backend/worksheet/plots/cartesian/CartesianPlot.cpp:3899–3949  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3897}
3898
3899void CartesianPlotPrivate::mouseMoveEvent(QGraphicsSceneMouseEvent* event) {
3900 const auto* cSystem{defaultCoordinateSystem()};
3901 auto* w = static_cast<Worksheet*>(q->parent(AspectType::Worksheet))->currentSelection();
3902 int index = CartesianPlot::cSystemIndex(w);
3903 if (index >= 0)
3904 cSystem = static_cast<CartesianCoordinateSystem*>(q->m_coordinateSystems.at(index));
3905
3906 if (mouseMode == CartesianPlot::MouseMode::Selection) {
3907 if (panningStarted && dataRect.contains(event->pos())) {
3908 // don't retransform on small mouse movement deltas
3909 const int deltaXScene = (m_panningStart.x() - event->pos().x());
3910 const int deltaYScene = (m_panningStart.y() - event->pos().y());
3911 if (std::abs(deltaXScene) < 5 && std::abs(deltaYScene) < 5)
3912 return;
3913
3914 if (!cSystem->isValid())
3915 return;
3916 const QPointF logicalEnd = cSystem->mapSceneToLogical(event->pos());
3917 const QPointF logicalStart = cSystem->mapSceneToLogical(m_panningStart);
3918 m_panningStart = event->pos();
3919 Q_EMIT q->mouseMoveSelectionModeSignal(logicalStart, logicalEnd);
3920 } else
3921 QGraphicsItem::mouseMoveEvent(event);
3922 } else if (mouseMode == CartesianPlot::MouseMode::ZoomSelection || mouseMode == CartesianPlot::MouseMode::ZoomXSelection
3923 || mouseMode == CartesianPlot::MouseMode::ZoomYSelection) {
3924 QGraphicsItem::mouseMoveEvent(event);
3925 if (!boundingRect().contains(event->pos())) {
3926 q->info(QString());
3927 return;
3928 }
3929 if (!cSystem->isValid())
3930 return;
3931 const QPointF logicalPos = cSystem->mapSceneToLogical(event->pos(), AbstractCoordinateSystem::MappingFlag::Limit);
3932 Q_EMIT q->mouseMoveZoomSelectionModeSignal(logicalPos);
3933
3934 } else if (mouseMode == CartesianPlot::MouseMode::Cursor) {
3935 QGraphicsItem::mouseMoveEvent(event);
3936 if (!boundingRect().contains(event->pos())) {
3937 q->info(i18n("Not inside of the bounding rect"));
3938 return;
3939 }
3940
3941 // updating treeview data and cursor position
3942 // updating cursor position is done in Worksheet, because
3943 // multiple plots must be updated
3944 if (!cSystem->isValid())
3945 return;
3946 const QPointF logicalPos = cSystem->mapSceneToLogical(event->pos(), AbstractCoordinateSystem::MappingFlag::Limit);
3947 Q_EMIT q->mouseMoveCursorModeSignal(selectedCursor, logicalPos);
3948 }
3949}
3950
3951bool CartesianPlotPrivate::translateRange(int xIndex, int yIndex, const QPointF& logicalStart, const QPointF& logicalEnd, bool translateX, bool translateY) {
3952 // handle the change in x

Callers

nothing calls this directly

Calls 9

currentSelectionMethod · 0.80
xMethod · 0.80
QStringClass · 0.50
parentMethod · 0.45
containsMethod · 0.45
yMethod · 0.45
isValidMethod · 0.45
mapSceneToLogicalMethod · 0.45
infoMethod · 0.45

Tested by

no test coverage detected