diff --git a/ApplicationCode/Commands/MeasurementCommands/RicMeasurementPickEventHandler.cpp b/ApplicationCode/Commands/MeasurementCommands/RicMeasurementPickEventHandler.cpp index 1e4fb0782d..96a75f546f 100644 --- a/ApplicationCode/Commands/MeasurementCommands/RicMeasurementPickEventHandler.cpp +++ b/ApplicationCode/Commands/MeasurementCommands/RicMeasurementPickEventHandler.cpp @@ -20,6 +20,7 @@ #include "RiaApplication.h" #include "RiuViewerCommands.h" +#include "RiuViewer.h" #include "Rim3dView.h" #include "RimIntersection.h" @@ -49,7 +50,7 @@ RicMeasurementPickEventHandler* RicMeasurementPickEventHandler::instance() //-------------------------------------------------------------------------------------------------- void RicMeasurementPickEventHandler::registerAsPickEventHandler() { - RiaApplication::instance()->setOverrideCursor(Qt::CrossCursor); + RiuViewer::setHoverCursor(Qt::CrossCursor); RiuViewerCommands::setPickEventHandler(RicMeasurementPickEventHandler::instance()); } @@ -58,7 +59,7 @@ void RicMeasurementPickEventHandler::registerAsPickEventHandler() //-------------------------------------------------------------------------------------------------- void RicMeasurementPickEventHandler::unregisterAsPickEventHandler() { - RiaApplication::instance()->restoreOverrideCursor(); + RiuViewer::clearHoverCursor(); RiuViewerCommands::removePickEventHandlerIfActive(RicMeasurementPickEventHandler::instance()); } diff --git a/ApplicationCode/Commands/RicVec3dPickEventHandler.cpp b/ApplicationCode/Commands/RicVec3dPickEventHandler.cpp index 1ddc5b835d..249fb7a006 100644 --- a/ApplicationCode/Commands/RicVec3dPickEventHandler.cpp +++ b/ApplicationCode/Commands/RicVec3dPickEventHandler.cpp @@ -19,6 +19,7 @@ #include "RiaApplication.h" #include "Rim3dView.h" +#include "RiuViewer.h" #include "cafDisplayCoordTransform.h" #include "cafSelectionManager.h" @@ -52,7 +53,7 @@ bool RicVec3dPickEventHandler::handle3dPickEvent(const Ric3dPickEvent& eventObje void RicVec3dPickEventHandler::registerAsPickEventHandler() { Ric3dViewPickEventHandler::registerAsPickEventHandler(); - RiaApplication::instance()->setOverrideCursor(Qt::CrossCursor); + RiuViewer::setHoverCursor(Qt::CrossCursor); } //-------------------------------------------------------------------------------------------------- @@ -60,5 +61,5 @@ void RicVec3dPickEventHandler::registerAsPickEventHandler() //-------------------------------------------------------------------------------------------------- void RicVec3dPickEventHandler::notifyUnregistered() { - RiaApplication::instance()->restoreOverrideCursor(); + RiuViewer::clearHoverCursor(); } diff --git a/ApplicationCode/Commands/WellPathCommands/RicPolylineTargetsPickEventHandler.cpp b/ApplicationCode/Commands/WellPathCommands/RicPolylineTargetsPickEventHandler.cpp index 72cc9849e7..ad8b2011e4 100644 --- a/ApplicationCode/Commands/WellPathCommands/RicPolylineTargetsPickEventHandler.cpp +++ b/ApplicationCode/Commands/WellPathCommands/RicPolylineTargetsPickEventHandler.cpp @@ -29,6 +29,7 @@ #include "RimUserDefinedPolylinesAnnotation.h" #include "RiuViewerCommands.h" +#include "RiuViewer.h" #include "RivPolylinesAnnotationSourceInfo.h" @@ -55,7 +56,7 @@ RicPolylineTargetsPickEventHandler::~RicPolylineTargetsPickEventHandler() {} //-------------------------------------------------------------------------------------------------- void RicPolylineTargetsPickEventHandler::registerAsPickEventHandler() { - RiaApplication::instance()->setOverrideCursor(Qt::CrossCursor); + RiuViewer::setHoverCursor(Qt::CrossCursor); Ric3dViewPickEventHandler::registerAsPickEventHandler(); } @@ -64,7 +65,7 @@ void RicPolylineTargetsPickEventHandler::registerAsPickEventHandler() //-------------------------------------------------------------------------------------------------- void RicPolylineTargetsPickEventHandler::notifyUnregistered() { - RiaApplication::instance()->restoreOverrideCursor(); + RiuViewer::clearHoverCursor(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/UserInterface/RiuViewer.cpp b/ApplicationCode/UserInterface/RiuViewer.cpp index be6e222b60..51a241b204 100644 --- a/ApplicationCode/UserInterface/RiuViewer.cpp +++ b/ApplicationCode/UserInterface/RiuViewer.cpp @@ -77,6 +77,8 @@ using cvf::ManipulatorTrackball; const double RI_MIN_NEARPLANE_DISTANCE = 0.1; +std::unique_ptr RiuViewer::s_hoverCursor; + //================================================================================================== /// /// \class RiuViewer @@ -841,11 +843,24 @@ void RiuViewer::mouseMoveEvent(QMouseEvent* mouseEvent) caf::Viewer::mouseMoveEvent(mouseEvent); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuViewer::enterEvent(QEvent*) +{ + if (s_hoverCursor) + { + QApplication::setOverrideCursor(*s_hoverCursor); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RiuViewer::leaveEvent(QEvent*) { + QApplication::restoreOverrideCursor(); + if (m_rimView && m_rimView->assosiatedViewLinker()) { RimViewLinker* viewLinker = m_rimView->assosiatedViewLinker(); @@ -1026,6 +1041,22 @@ void RiuViewer::showScaleLegend(bool show) updateLegendLayout(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuViewer::setHoverCursor(const QCursor& cursor) +{ + s_hoverCursor.reset(new QCursor(cursor)); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuViewer::clearHoverCursor() +{ + s_hoverCursor.reset(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/UserInterface/RiuViewer.h b/ApplicationCode/UserInterface/RiuViewer.h index 7441c47315..fb4892f989 100644 --- a/ApplicationCode/UserInterface/RiuViewer.h +++ b/ApplicationCode/UserInterface/RiuViewer.h @@ -21,15 +21,17 @@ #pragma once #include "RiuViewerToViewInterface.h" -#include "cafViewer.h" +#include "RiuInterfaceToViewWindow.h" +#include "cafMouseState.h" #include "cafPdmObject.h" #include "cafPdmPointer.h" #include "cafPdmInterfacePointer.h" +#include "cafViewer.h" -#include "cafMouseState.h" #include "cvfStructGrid.h" -#include "RiuInterfaceToViewWindow.h" + +#include class RicCommandFeature; class Rim3dView; @@ -127,6 +129,9 @@ public: void showScaleLegend(bool show); + static void setHoverCursor(const QCursor& cursor); + static void clearHoverCursor(); + public slots: void slotSetCurrentFrame(int frameIndex) override; void slotEndAnimation() override; @@ -135,7 +140,8 @@ protected: void optimizeClippingPlanes() override; void resizeGL(int width, int height) override; void mouseMoveEvent(QMouseEvent* e) override; - void leaveEvent(QEvent *) override; + void enterEvent(QEvent*) override; + void leaveEvent(QEvent*) override; private: void updateLegendLayout(); @@ -191,5 +197,7 @@ private: bool m_isNavigationRotationEnabled; cvf::ref m_scaleLegend; + + static std::unique_ptr s_hoverCursor; };