From 835cf4a53c7a8b5e15228ea60b1925f401190cab Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Wed, 2 Oct 2024 11:03:10 +0200 Subject: [PATCH] Qt6: Fix QMouseEvent.x() and .y() deprecation. --- .../RicBoxManipulatorEventHandler.cpp | 2 +- .../RicPointTangentManipulator.cpp | 5 +++-- ApplicationLibCode/UserInterface/RiuViewer.cpp | 4 ++-- .../UserInterface/RiuWellLogTrack.cpp | 4 ++-- Fwk/AppFwk/CommonCode/cafMouseState.cpp | 10 ++++++---- Fwk/AppFwk/cafViewer/cafCadNavigation.cpp | 6 +++--- Fwk/AppFwk/cafViewer/cafCeetronNavigation.cpp | 10 +++++----- .../cafViewer/cafCeetronPlusNavigation.cpp | 16 ++++++++-------- .../cafViewer/cafTrackBallBasedNavigation.cpp | 12 ++++++------ Fwk/VizFwk/LibGuiQt/cvfqtMouseState.cpp | 8 ++++---- 10 files changed, 40 insertions(+), 37 deletions(-) diff --git a/ApplicationLibCode/Commands/IntersectionBoxCommands/RicBoxManipulatorEventHandler.cpp b/ApplicationLibCode/Commands/IntersectionBoxCommands/RicBoxManipulatorEventHandler.cpp index 0623e5185a..578479fbaa 100644 --- a/ApplicationLibCode/Commands/IntersectionBoxCommands/RicBoxManipulatorEventHandler.cpp +++ b/ApplicationLibCode/Commands/IntersectionBoxCommands/RicBoxManipulatorEventHandler.cpp @@ -137,7 +137,7 @@ bool RicBoxManipulatorEventHandler::eventFilter( QObject* obj, QEvent* inputEven QMouseEvent* mouseEvent = static_cast( inputEvent ); cvf::ref rayIS = - viewer->rayIntersectSpecFromWindowCoordinates( mouseEvent->pos().x(), mouseEvent->pos().y() ); + viewer->rayIntersectSpecFromWindowCoordinates( mouseEvent->position().x(), mouseEvent->position().y() ); if ( rayIS.notNull() ) { diff --git a/ApplicationLibCode/Commands/WellPathCommands/PointTangentManipulator/RicPointTangentManipulator.cpp b/ApplicationLibCode/Commands/WellPathCommands/PointTangentManipulator/RicPointTangentManipulator.cpp index 9e2648285c..8e1b0f56d0 100644 --- a/ApplicationLibCode/Commands/WellPathCommands/PointTangentManipulator/RicPointTangentManipulator.cpp +++ b/ApplicationLibCode/Commands/WellPathCommands/PointTangentManipulator/RicPointTangentManipulator.cpp @@ -128,8 +128,9 @@ bool RicPointTangentManipulator::eventFilter( QObject* obj, QEvent* inputEvent ) { auto* mouseEvent = static_cast( inputEvent ); - cvf::ref rayIs = - m_viewer->rayIntersectSpecFromWindowCoordinates( mouseEvent->pos().x(), mouseEvent->pos().y(), m_isDraggingInComparisonView ); + cvf::ref rayIs = m_viewer->rayIntersectSpecFromWindowCoordinates( mouseEvent->position().x(), + mouseEvent->position().y(), + m_isDraggingInComparisonView ); if ( !rayIs.isNull() && rayIs->ray() ) { diff --git a/ApplicationLibCode/UserInterface/RiuViewer.cpp b/ApplicationLibCode/UserInterface/RiuViewer.cpp index 9f4810a832..1b5ef641f0 100644 --- a/ApplicationLibCode/UserInterface/RiuViewer.cpp +++ b/ApplicationLibCode/UserInterface/RiuViewer.cpp @@ -1076,8 +1076,8 @@ void RiuViewer::mouseMoveEvent( QMouseEvent* mouseEvent ) RimViewLinker* viewLinker = m_rimView->assosiatedViewLinker(); if ( viewLinker ) { - int translatedMousePosX = mouseEvent->pos().x(); - int translatedMousePosY = height() - mouseEvent->pos().y(); + int translatedMousePosX = mouseEvent->position().x(); + int translatedMousePosY = height() - mouseEvent->position().y(); cvf::Vec3d displayCoord( 0, 0, 0 ); if ( mainCamera()->unproject( cvf::Vec3d( static_cast( translatedMousePosX ), static_cast( translatedMousePosY ), 0 ), diff --git a/ApplicationLibCode/UserInterface/RiuWellLogTrack.cpp b/ApplicationLibCode/UserInterface/RiuWellLogTrack.cpp index ddbf344884..6de9beacac 100644 --- a/ApplicationLibCode/UserInterface/RiuWellLogTrack.cpp +++ b/ApplicationLibCode/UserInterface/RiuWellLogTrack.cpp @@ -139,11 +139,11 @@ void RiuWellLogTrack::onMouseMoveEvent( QMouseEvent* mouseEvent ) double depth = 0.0; if ( depthTrackPlot->depthOrientation() == RiaDefines::Orientation::HORIZONTAL ) { - depth = axisMap.invTransform( mouseEvent->pos().x() ); + depth = axisMap.invTransform( mouseEvent->position().x() ); } else { - depth = axisMap.invTransform( mouseEvent->pos().y() ); + depth = axisMap.invTransform( mouseEvent->position().y() ); } depthTrackPlot->setDepthMarkerPosition( depth ); diff --git a/Fwk/AppFwk/CommonCode/cafMouseState.cpp b/Fwk/AppFwk/CommonCode/cafMouseState.cpp index 53348763e2..0f6b1982ad 100644 --- a/Fwk/AppFwk/CommonCode/cafMouseState.cpp +++ b/Fwk/AppFwk/CommonCode/cafMouseState.cpp @@ -91,8 +91,8 @@ void QtMouseState::updateFromMouseEvent( QMouseEvent* event ) if ( numMouseButtonsInState( m_mouseButtonState ) == 1 ) { m_cleanButtonPressButton = buttonPressed; - m_cleanButtonPressPosX = event->x(); - m_cleanButtonPressPosY = event->y(); + m_cleanButtonPressPosX = event->position().x(); + m_cleanButtonPressPosY = event->position().y(); } } @@ -109,8 +109,10 @@ void QtMouseState::updateFromMouseEvent( QMouseEvent* event ) m_cleanButtonPressPosY != cvf::UNDEFINED_INT ) { // We have a candidate, check if movement is within tolerance - if ( cvf::Math::abs( double( ( m_cleanButtonPressPosX - event->x() ) ) ) <= m_cleanButtonClickTolerance && - cvf::Math::abs( double( ( m_cleanButtonPressPosY - event->y() ) ) ) <= m_cleanButtonClickTolerance ) + if ( cvf::Math::abs( double( ( m_cleanButtonPressPosX - event->position().x() ) ) ) <= + m_cleanButtonClickTolerance && + cvf::Math::abs( double( ( m_cleanButtonPressPosY - event->position().y() ) ) ) <= + m_cleanButtonClickTolerance ) { m_cleanButtonClickButton = buttonReleased; } diff --git a/Fwk/AppFwk/cafViewer/cafCadNavigation.cpp b/Fwk/AppFwk/cafViewer/cafCadNavigation.cpp index 416e13ea97..9ea86459e4 100644 --- a/Fwk/AppFwk/cafViewer/cafCadNavigation.cpp +++ b/Fwk/AppFwk/cafViewer/cafCadNavigation.cpp @@ -72,11 +72,11 @@ bool caf::CadNavigation::handleInputEvent( QInputEvent* inputEvent ) QMouseEvent* me = static_cast( inputEvent ); int translatedMousePosX, translatedMousePosY; - cvfEventPos( me->x(), me->y(), &translatedMousePosX, &translatedMousePosY ); + cvfEventPos( me->position().x(), me->position().y(), &translatedMousePosX, &translatedMousePosY ); if ( me->button() == Qt::MiddleButton && me->modifiers() == Qt::NoModifier && isRotationEnabled() ) { - this->pickAndSetPointOfInterest( me->x(), me->y() ); + this->pickAndSetPointOfInterest( me->position().x(), me->position().y() ); m_trackball->startNavigation( cvf::ManipulatorTrackball::ROTATE, translatedMousePosX, translatedMousePosY ); m_roationSensitivityCalculator.init( me ); @@ -120,7 +120,7 @@ bool caf::CadNavigation::handleInputEvent( QInputEvent* inputEvent ) QMouseEvent* me = static_cast( inputEvent ); int translatedMousePosX, translatedMousePosY; - cvfEventPos( me->x(), me->y(), &translatedMousePosX, &translatedMousePosY ); + cvfEventPos( me->position().x(), me->position().y(), &translatedMousePosX, &translatedMousePosY ); if ( m_isNavigating ) { diff --git a/Fwk/AppFwk/cafViewer/cafCeetronNavigation.cpp b/Fwk/AppFwk/cafViewer/cafCeetronNavigation.cpp index e511934184..42d385e7c3 100644 --- a/Fwk/AppFwk/cafViewer/cafCeetronNavigation.cpp +++ b/Fwk/AppFwk/cafViewer/cafCeetronNavigation.cpp @@ -141,8 +141,8 @@ void caf::CeetronNavigation::mouseMoveEvent( QMouseEvent* event ) { if ( !m_viewer->canRender() ) return; initializeRotationCenter(); - int posX = event->x(); - int posY = m_viewer->height() - event->y(); + int posX = event->position().x(); + int posY = m_viewer->height() - event->position().y(); ManipulatorTrackball::NavigationType navType = getNavigationTypeFromMouseButtons( event->buttons() ); if ( navType != m_trackball->activeNavigation() ) @@ -166,8 +166,8 @@ void caf::CeetronNavigation::mousePressEvent( QMouseEvent* event ) { if ( !m_viewer->canRender() ) return; initializeRotationCenter(); - int posX = event->x(); - int posY = m_viewer->height() - event->y(); + int posX = event->position().x(); + int posY = m_viewer->height() - event->position().y(); ManipulatorTrackball::NavigationType navType = getNavigationTypeFromMouseButtons( event->buttons() ); m_trackball->startNavigation( navType, posX, posY ); @@ -183,7 +183,7 @@ void caf::CeetronNavigation::mouseReleaseEvent( QMouseEvent* event ) if ( !m_viewer->canRender() ) return; initializeRotationCenter(); ManipulatorTrackball::NavigationType navType = getNavigationTypeFromMouseButtons( event->buttons() ); - m_trackball->startNavigation( navType, event->x(), event->y() ); + m_trackball->startNavigation( navType, event->position().x(), event->position().y() ); setCursorFromCurrentState(); } diff --git a/Fwk/AppFwk/cafViewer/cafCeetronPlusNavigation.cpp b/Fwk/AppFwk/cafViewer/cafCeetronPlusNavigation.cpp index b55c1f72de..6165014011 100644 --- a/Fwk/AppFwk/cafViewer/cafCeetronPlusNavigation.cpp +++ b/Fwk/AppFwk/cafViewer/cafCeetronPlusNavigation.cpp @@ -75,11 +75,11 @@ bool caf::CeetronPlusNavigation::handleInputEvent( QInputEvent* inputEvent ) QMouseEvent* me = static_cast( inputEvent ); int translatedMousePosX, translatedMousePosY; - cvfEventPos( me->x(), me->y(), &translatedMousePosX, &translatedMousePosY ); + cvfEventPos( me->position().x(), me->position().y(), &translatedMousePosX, &translatedMousePosY ); if ( me->button() == Qt::RightButton && isRotationEnabled() ) { - this->pickAndSetPointOfInterest( me->x(), me->y() ); + this->pickAndSetPointOfInterest( me->position().x(), me->position().y() ); m_trackball->startNavigation( cvf::ManipulatorTrackball::ROTATE, translatedMousePosX, translatedMousePosY ); m_roationSensitivityCalculator.init( me ); @@ -103,8 +103,8 @@ bool caf::CeetronPlusNavigation::handleInputEvent( QInputEvent* inputEvent ) if ( me->modifiers() == Qt::NoModifier ) { QMouseEvent* we = static_cast( inputEvent ); - m_lastPosX = we->x(); - m_lastPosY = we->y(); + m_lastPosX = we->position().x(); + m_lastPosY = we->position().y(); m_zoomRay = createZoomRay( translatedMousePosX, translatedMousePosY ); @@ -150,16 +150,16 @@ bool caf::CeetronPlusNavigation::handleInputEvent( QInputEvent* inputEvent ) QMouseEvent* me = static_cast( inputEvent ); int translatedMousePosX, translatedMousePosY; - cvfEventPos( me->x(), me->y(), &translatedMousePosX, &translatedMousePosY ); + cvfEventPos( me->position().x(), me->position().y(), &translatedMousePosX, &translatedMousePosY ); if ( m_isNavigating ) { if ( m_isZooming ) { - int delta = 3 * ( m_lastPosY - me->y() ); + int delta = 3 * ( m_lastPosY - me->position().y() ); this->zoomAlongRay( m_zoomRay.p(), delta ); - m_lastPosX = me->x(); - m_lastPosY = me->y(); + m_lastPosX = me->position().x(); + m_lastPosY = me->position().y(); } else { diff --git a/Fwk/AppFwk/cafViewer/cafTrackBallBasedNavigation.cpp b/Fwk/AppFwk/cafViewer/cafTrackBallBasedNavigation.cpp index 125133c225..50fc023bad 100644 --- a/Fwk/AppFwk/cafViewer/cafTrackBallBasedNavigation.cpp +++ b/Fwk/AppFwk/cafViewer/cafTrackBallBasedNavigation.cpp @@ -332,8 +332,8 @@ bool caf::TrackBallBasedNavigation::shouldRaytraceForNewPoiDuringWheelZoom( int //-------------------------------------------------------------------------------------------------- void caf::RotationSensitivityCalculator::init( QMouseEvent* eventAtRotationStart ) { - m_lastPosX = eventAtRotationStart->x(); - m_lastPosY = eventAtRotationStart->y(); + m_lastPosX = eventAtRotationStart->position().x(); + m_lastPosY = eventAtRotationStart->position().y(); m_lastTime = eventAtRotationStart->timestamp(); } @@ -353,8 +353,8 @@ double caf::RotationSensitivityCalculator::calculateSensitivity( QMouseEvent* ev unsigned long timeSinceLast = presentTime - m_lastTime; if ( timeSinceLast == 0 ) timeSinceLast = 1; // one millisecond - int deltaX = eventWhenRotating->x() - m_lastPosX; - int deltaY = eventWhenRotating->y() - m_lastPosY; + int deltaX = eventWhenRotating->position().x() - m_lastPosX; + int deltaY = eventWhenRotating->position().y() - m_lastPosY; cvf::Vec2d mouseVelocity( deltaX, deltaY ); mouseVelocity /= 1.0e-3 * timeSinceLast; @@ -367,8 +367,8 @@ double caf::RotationSensitivityCalculator::calculateSensitivity( QMouseEvent* ev if ( mouseVelocityLengthCorr < slowLimit ) sensitivity = mouseVelocityLengthCorr * mouseVelocityLengthCorr / ( slowLimit * slowLimit ); - m_lastPosX = eventWhenRotating->x(); - m_lastPosY = eventWhenRotating->y(); + m_lastPosX = eventWhenRotating->position().x(); + m_lastPosY = eventWhenRotating->position().y(); m_lastTime = eventWhenRotating->timestamp(); m_lastMouseVelocityLenght = 0.8 * mouseVelocityLength + 0.2 * m_lastMouseVelocityLenght; } diff --git a/Fwk/VizFwk/LibGuiQt/cvfqtMouseState.cpp b/Fwk/VizFwk/LibGuiQt/cvfqtMouseState.cpp index cc28ad140b..06cd98ca6c 100644 --- a/Fwk/VizFwk/LibGuiQt/cvfqtMouseState.cpp +++ b/Fwk/VizFwk/LibGuiQt/cvfqtMouseState.cpp @@ -96,8 +96,8 @@ void MouseState::updateFromMouseEvent(QMouseEvent* event) if (numMouseButtonsInState(m_mouseButtonState) == 1) { m_cleanButtonPressButton = buttonPressed; - m_cleanButtonPressPosX = event->x(); - m_cleanButtonPressPosY = event->y(); + m_cleanButtonPressPosX = event->position().x(); + m_cleanButtonPressPosY = event->pos().y(); } } @@ -115,8 +115,8 @@ void MouseState::updateFromMouseEvent(QMouseEvent* event) m_cleanButtonPressPosY != cvf::UNDEFINED_INT) { // We have a candidate, check if movement is within tolerance - if (cvf::Math::abs(double((m_cleanButtonPressPosX - event->x()))) <= m_cleanButtonClickTolerance && - cvf::Math::abs(double((m_cleanButtonPressPosY - event->y()))) <= m_cleanButtonClickTolerance) + if (cvf::Math::abs(double((m_cleanButtonPressPosX - event->position().x()))) <= m_cleanButtonClickTolerance && + cvf::Math::abs(double((m_cleanButtonPressPosY - event->pos().y()))) <= m_cleanButtonClickTolerance) { m_cleanButtonClickButton = buttonReleased; }