#4220 Apply picking cursor only when over a 3d View

This commit is contained in:
Gaute Lindkvist 2019-03-22 15:55:51 +01:00
parent ef182da8a9
commit 44f3882ecb
5 changed files with 52 additions and 10 deletions

View File

@ -20,6 +20,7 @@
#include "RiaApplication.h" #include "RiaApplication.h"
#include "RiuViewerCommands.h" #include "RiuViewerCommands.h"
#include "RiuViewer.h"
#include "Rim3dView.h" #include "Rim3dView.h"
#include "RimIntersection.h" #include "RimIntersection.h"
@ -49,7 +50,7 @@ RicMeasurementPickEventHandler* RicMeasurementPickEventHandler::instance()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RicMeasurementPickEventHandler::registerAsPickEventHandler() void RicMeasurementPickEventHandler::registerAsPickEventHandler()
{ {
RiaApplication::instance()->setOverrideCursor(Qt::CrossCursor); RiuViewer::setHoverCursor(Qt::CrossCursor);
RiuViewerCommands::setPickEventHandler(RicMeasurementPickEventHandler::instance()); RiuViewerCommands::setPickEventHandler(RicMeasurementPickEventHandler::instance());
} }
@ -58,7 +59,7 @@ void RicMeasurementPickEventHandler::registerAsPickEventHandler()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RicMeasurementPickEventHandler::unregisterAsPickEventHandler() void RicMeasurementPickEventHandler::unregisterAsPickEventHandler()
{ {
RiaApplication::instance()->restoreOverrideCursor(); RiuViewer::clearHoverCursor();
RiuViewerCommands::removePickEventHandlerIfActive(RicMeasurementPickEventHandler::instance()); RiuViewerCommands::removePickEventHandlerIfActive(RicMeasurementPickEventHandler::instance());
} }

View File

@ -19,6 +19,7 @@
#include "RiaApplication.h" #include "RiaApplication.h"
#include "Rim3dView.h" #include "Rim3dView.h"
#include "RiuViewer.h"
#include "cafDisplayCoordTransform.h" #include "cafDisplayCoordTransform.h"
#include "cafSelectionManager.h" #include "cafSelectionManager.h"
@ -52,7 +53,7 @@ bool RicVec3dPickEventHandler::handle3dPickEvent(const Ric3dPickEvent& eventObje
void RicVec3dPickEventHandler::registerAsPickEventHandler() void RicVec3dPickEventHandler::registerAsPickEventHandler()
{ {
Ric3dViewPickEventHandler::registerAsPickEventHandler(); Ric3dViewPickEventHandler::registerAsPickEventHandler();
RiaApplication::instance()->setOverrideCursor(Qt::CrossCursor); RiuViewer::setHoverCursor(Qt::CrossCursor);
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -60,5 +61,5 @@ void RicVec3dPickEventHandler::registerAsPickEventHandler()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RicVec3dPickEventHandler::notifyUnregistered() void RicVec3dPickEventHandler::notifyUnregistered()
{ {
RiaApplication::instance()->restoreOverrideCursor(); RiuViewer::clearHoverCursor();
} }

View File

@ -29,6 +29,7 @@
#include "RimUserDefinedPolylinesAnnotation.h" #include "RimUserDefinedPolylinesAnnotation.h"
#include "RiuViewerCommands.h" #include "RiuViewerCommands.h"
#include "RiuViewer.h"
#include "RivPolylinesAnnotationSourceInfo.h" #include "RivPolylinesAnnotationSourceInfo.h"
@ -55,7 +56,7 @@ RicPolylineTargetsPickEventHandler::~RicPolylineTargetsPickEventHandler() {}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RicPolylineTargetsPickEventHandler::registerAsPickEventHandler() void RicPolylineTargetsPickEventHandler::registerAsPickEventHandler()
{ {
RiaApplication::instance()->setOverrideCursor(Qt::CrossCursor); RiuViewer::setHoverCursor(Qt::CrossCursor);
Ric3dViewPickEventHandler::registerAsPickEventHandler(); Ric3dViewPickEventHandler::registerAsPickEventHandler();
} }
@ -64,7 +65,7 @@ void RicPolylineTargetsPickEventHandler::registerAsPickEventHandler()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RicPolylineTargetsPickEventHandler::notifyUnregistered() void RicPolylineTargetsPickEventHandler::notifyUnregistered()
{ {
RiaApplication::instance()->restoreOverrideCursor(); RiuViewer::clearHoverCursor();
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@ -77,6 +77,8 @@ using cvf::ManipulatorTrackball;
const double RI_MIN_NEARPLANE_DISTANCE = 0.1; const double RI_MIN_NEARPLANE_DISTANCE = 0.1;
std::unique_ptr<QCursor> RiuViewer::s_hoverCursor;
//================================================================================================== //==================================================================================================
/// ///
/// \class RiuViewer /// \class RiuViewer
@ -841,11 +843,24 @@ void RiuViewer::mouseMoveEvent(QMouseEvent* mouseEvent)
caf::Viewer::mouseMoveEvent(mouseEvent); caf::Viewer::mouseMoveEvent(mouseEvent);
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuViewer::enterEvent(QEvent*)
{
if (s_hoverCursor)
{
QApplication::setOverrideCursor(*s_hoverCursor);
}
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RiuViewer::leaveEvent(QEvent*) void RiuViewer::leaveEvent(QEvent*)
{ {
QApplication::restoreOverrideCursor();
if (m_rimView && m_rimView->assosiatedViewLinker()) if (m_rimView && m_rimView->assosiatedViewLinker())
{ {
RimViewLinker* viewLinker = m_rimView->assosiatedViewLinker(); RimViewLinker* viewLinker = m_rimView->assosiatedViewLinker();
@ -1026,6 +1041,22 @@ void RiuViewer::showScaleLegend(bool show)
updateLegendLayout(); updateLegendLayout();
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuViewer::setHoverCursor(const QCursor& cursor)
{
s_hoverCursor.reset(new QCursor(cursor));
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuViewer::clearHoverCursor()
{
s_hoverCursor.reset();
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@ -21,15 +21,17 @@
#pragma once #pragma once
#include "RiuViewerToViewInterface.h" #include "RiuViewerToViewInterface.h"
#include "cafViewer.h" #include "RiuInterfaceToViewWindow.h"
#include "cafMouseState.h"
#include "cafPdmObject.h" #include "cafPdmObject.h"
#include "cafPdmPointer.h" #include "cafPdmPointer.h"
#include "cafPdmInterfacePointer.h" #include "cafPdmInterfacePointer.h"
#include "cafViewer.h"
#include "cafMouseState.h"
#include "cvfStructGrid.h" #include "cvfStructGrid.h"
#include "RiuInterfaceToViewWindow.h"
#include <memory>
class RicCommandFeature; class RicCommandFeature;
class Rim3dView; class Rim3dView;
@ -127,6 +129,9 @@ public:
void showScaleLegend(bool show); void showScaleLegend(bool show);
static void setHoverCursor(const QCursor& cursor);
static void clearHoverCursor();
public slots: public slots:
void slotSetCurrentFrame(int frameIndex) override; void slotSetCurrentFrame(int frameIndex) override;
void slotEndAnimation() override; void slotEndAnimation() override;
@ -135,7 +140,8 @@ protected:
void optimizeClippingPlanes() override; void optimizeClippingPlanes() override;
void resizeGL(int width, int height) override; void resizeGL(int width, int height) override;
void mouseMoveEvent(QMouseEvent* e) override; void mouseMoveEvent(QMouseEvent* e) override;
void leaveEvent(QEvent *) override; void enterEvent(QEvent*) override;
void leaveEvent(QEvent*) override;
private: private:
void updateLegendLayout(); void updateLegendLayout();
@ -191,5 +197,7 @@ private:
bool m_isNavigationRotationEnabled; bool m_isNavigationRotationEnabled;
cvf::ref<caf::OverlayScaleLegend> m_scaleLegend; cvf::ref<caf::OverlayScaleLegend> m_scaleLegend;
static std::unique_ptr<QCursor> s_hoverCursor;
}; };