mirror of
https://github.com/OPM/ResInsight.git
synced 2026-11-02 09:00:14 -06:00
Prepare building with Qt6
* Fwk: Switch from delta to angleDelta for QWheelEvent * Fwk: Add option to build more libraries with Qt6 * Fwk: Remove unused includes of QtOpenGL * Fwk: Don't forward declare QStringList * Fwk: Store cursor position in QPoint variable * Fwk: Use QWheelEvent::position in Qt6
This commit is contained in:
1 parent
9f96cb9694
commit
ea27e952f5
10 files changed
+99
-39
No files matched your search
@@ -11,13 +11,23 @@ endif()
|
||||
# These headers need to go through Qt's MOC compiler
|
||||
set(MOC_HEADER_FILES cafViewer.h)
|
||||
|
||||
find_package(
|
||||
Qt5
|
||||
COMPONENTS
|
||||
REQUIRED Core Gui Widgets OpenGL
|
||||
)
|
||||
set(QT_LIBRARIES Qt5::Core Qt5::Gui Qt5::Widgets Qt5::OpenGL)
|
||||
qt5_wrap_cpp(MOC_SOURCE_FILES ${MOC_HEADER_FILES})
|
||||
if(CEE_USE_QT6)
|
||||
find_package(
|
||||
Qt6
|
||||
COMPONENTS
|
||||
REQUIRED Core Gui Widgets OpenGL
|
||||
)
|
||||
set(QT_LIBRARIES Qt6::Core Qt6::Gui Qt6::Widgets Qt6::OpenGL)
|
||||
qt_standard_project_setup()
|
||||
else()
|
||||
find_package(
|
||||
Qt5
|
||||
COMPONENTS
|
||||
REQUIRED Core Gui Widgets OpenGL
|
||||
)
|
||||
set(QT_LIBRARIES Qt5::Core Qt5::Gui Qt5::Widgets Qt5::OpenGL)
|
||||
qt5_wrap_cpp(MOC_SOURCE_FILES ${MOC_HEADER_FILES})
|
||||
endif()
|
||||
|
||||
add_library(
|
||||
${PROJECT_NAME}
|
||||
|
||||
@@ -144,16 +144,22 @@ bool caf::CadNavigation::handleInputEvent( QInputEvent* inputEvent )
|
||||
{
|
||||
QWheelEvent* we = static_cast<QWheelEvent*>( inputEvent );
|
||||
|
||||
updatePointOfInterestDuringZoomIfNecessary( we->x(), we->y() );
|
||||
#if ( QT_VERSION < QT_VERSION_CHECK( 5, 15, 0 ) )
|
||||
QPoint cursorPosition = we->pos();
|
||||
#else
|
||||
QPoint cursorPosition = we->position().toPoint();
|
||||
#endif
|
||||
|
||||
updatePointOfInterestDuringZoomIfNecessary( cursorPosition.x(), cursorPosition.y() );
|
||||
|
||||
if ( m_isRotCenterInitialized )
|
||||
{
|
||||
int translatedMousePosX, translatedMousePosY;
|
||||
cvfEventPos( we->x(), we->y(), &translatedMousePosX, &translatedMousePosY );
|
||||
cvfEventPos( cursorPosition.x(), cursorPosition.y(), &translatedMousePosX, &translatedMousePosY );
|
||||
|
||||
cvf::ref<cvf::Ray> ray = createZoomRay( translatedMousePosX, translatedMousePosY );
|
||||
|
||||
zoomAlongRay( ray.p(), -we->delta() );
|
||||
zoomAlongRay( ray.p(), -we->angleDelta().y() );
|
||||
}
|
||||
isEventHandled = true;
|
||||
}
|
||||
|
||||
@@ -200,13 +200,18 @@ void caf::CeetronNavigation::wheelEvent( QWheelEvent* event )
|
||||
if ( vpHeight <= 0 ) return;
|
||||
|
||||
int navDelta = vpHeight / 5;
|
||||
if ( event->delta() < 0 ) navDelta *= -1;
|
||||
if ( event->angleDelta().y() < 0 ) navDelta *= -1;
|
||||
|
||||
int posY = m_viewer->height() - event->y();
|
||||
#if ( QT_VERSION < QT_VERSION_CHECK( 5, 15, 0 ) )
|
||||
QPoint cursorPosition = event->pos();
|
||||
#else
|
||||
QPoint cursorPosition = event->position().toPoint();
|
||||
#endif
|
||||
int posY = m_viewer->height() - cursorPosition.y();
|
||||
|
||||
m_trackball->startNavigation( ManipulatorTrackball::WALK, event->x(), posY );
|
||||
m_trackball->startNavigation( ManipulatorTrackball::WALK, cursorPosition.x(), posY );
|
||||
|
||||
m_trackball->updateNavigation( event->x(), posY + navDelta );
|
||||
m_trackball->updateNavigation( cursorPosition.x(), posY + navDelta );
|
||||
m_trackball->endNavigation();
|
||||
|
||||
m_viewer->updateParallelProjectionHeightFromMoveZoom( m_pointOfInterest );
|
||||
|
||||
@@ -185,16 +185,22 @@ bool caf::CeetronPlusNavigation::handleInputEvent( QInputEvent* inputEvent )
|
||||
{
|
||||
QWheelEvent* we = static_cast<QWheelEvent*>( inputEvent );
|
||||
|
||||
updatePointOfInterestDuringZoomIfNecessary( we->x(), we->y() );
|
||||
#if ( QT_VERSION < QT_VERSION_CHECK( 5, 15, 0 ) )
|
||||
QPoint cursorPosition = we->pos();
|
||||
#else
|
||||
QPoint cursorPosition = we->position().toPoint();
|
||||
#endif
|
||||
|
||||
updatePointOfInterestDuringZoomIfNecessary( cursorPosition.x(), cursorPosition.y() );
|
||||
|
||||
if ( m_isRotCenterInitialized )
|
||||
{
|
||||
int translatedMousePosX, translatedMousePosY;
|
||||
cvfEventPos( we->x(), we->y(), &translatedMousePosX, &translatedMousePosY );
|
||||
cvfEventPos( cursorPosition.x(), cursorPosition.y(), &translatedMousePosX, &translatedMousePosY );
|
||||
|
||||
cvf::ref<cvf::Ray> ray = createZoomRay( translatedMousePosX, translatedMousePosY );
|
||||
|
||||
zoomAlongRay( ray.p(), we->delta() );
|
||||
zoomAlongRay( ray.p(), we->angleDelta().y() );
|
||||
}
|
||||
isEventHandled = true;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user