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:
Eirik Marthinsen 2024-03-06 08:32:27 +01:00 committed by GitHub
parent 9f96cb9694
commit ea27e952f5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 99 additions and 39 deletions

View File

@ -14,13 +14,23 @@ find_package(OpenGL)
# These headers need to go through Qt's MOC compiler
set(MOC_HEADER_FILES cafMessagePanel.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}

View File

@ -58,8 +58,6 @@
#include "cvfTextureImage.h"
#include "cvfUniform.h"
#include <QtOpenGL/QGLFormat>
namespace caf
{
//#############################################################################################################################

View File

@ -42,8 +42,6 @@
#include <QLineEdit>
#include <QRegularExpression>
#include <QtOpenGL/QGLContext>
#include <QFileDialog>
#include <QMessageBox>

View File

@ -38,9 +38,10 @@
#include <vector>
#include <QStringList>
class QLineEdit;
class QString;
class QStringList;
namespace caf
{

View File

@ -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}

View File

@ -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;
}

View File

@ -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 );

View File

@ -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;
}

View File

@ -10,13 +10,26 @@ endif()
find_package(OpenGL)
# Qt
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()
set_property(
SOURCE cafTransparentWBRenderConfiguration.cpp PROPERTY SKIP_AUTOMOC ON
)
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}

View File

@ -32,9 +32,22 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNO_DEBUG")
endif()
find_package(Qt5 COMPONENTS REQUIRED Core Gui OpenGL Widgets)
set(QT_LIBRARIES Qt5::Core Qt5::Gui Qt5::OpenGL Qt5::Widgets)
if(CEE_USE_QT6)
find_package(
Qt6
COMPONENTS
REQUIRED Core Gui OpenGL Widgets
)
set(QT_LIBRARIES Qt6::Core Qt6::Gui Qt6::OpenGL Qt6::Widgets)
qt_standard_project_setup()
else()
find_package(
Qt5
COMPONENTS
REQUIRED Core Gui OpenGL Widgets
)
set(QT_LIBRARIES Qt5::Core Qt5::Gui Qt5::OpenGL Qt5::Widgets)
endif()
# Libraries
add_subdirectory(AppFwk/cafProjectDataModel/cafPdmCore)