mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -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:
parent
9f96cb9694
commit
ea27e952f5
@ -14,6 +14,15 @@ find_package(OpenGL)
|
|||||||
# These headers need to go through Qt's MOC compiler
|
# These headers need to go through Qt's MOC compiler
|
||||||
set(MOC_HEADER_FILES cafMessagePanel.h)
|
set(MOC_HEADER_FILES cafMessagePanel.h)
|
||||||
|
|
||||||
|
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(
|
find_package(
|
||||||
Qt5
|
Qt5
|
||||||
COMPONENTS
|
COMPONENTS
|
||||||
@ -21,6 +30,7 @@ find_package(
|
|||||||
)
|
)
|
||||||
set(QT_LIBRARIES Qt5::Core Qt5::Gui Qt5::Widgets Qt5::OpenGL)
|
set(QT_LIBRARIES Qt5::Core Qt5::Gui Qt5::Widgets Qt5::OpenGL)
|
||||||
qt5_wrap_cpp(MOC_SOURCE_FILES ${MOC_HEADER_FILES})
|
qt5_wrap_cpp(MOC_SOURCE_FILES ${MOC_HEADER_FILES})
|
||||||
|
endif()
|
||||||
|
|
||||||
add_library(
|
add_library(
|
||||||
${PROJECT_NAME}
|
${PROJECT_NAME}
|
||||||
|
@ -58,8 +58,6 @@
|
|||||||
#include "cvfTextureImage.h"
|
#include "cvfTextureImage.h"
|
||||||
#include "cvfUniform.h"
|
#include "cvfUniform.h"
|
||||||
|
|
||||||
#include <QtOpenGL/QGLFormat>
|
|
||||||
|
|
||||||
namespace caf
|
namespace caf
|
||||||
{
|
{
|
||||||
//#############################################################################################################################
|
//#############################################################################################################################
|
||||||
|
@ -42,8 +42,6 @@
|
|||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
|
|
||||||
#include <QtOpenGL/QGLContext>
|
|
||||||
|
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
|
||||||
|
@ -38,9 +38,10 @@
|
|||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include <QStringList>
|
||||||
|
|
||||||
class QLineEdit;
|
class QLineEdit;
|
||||||
class QString;
|
class QString;
|
||||||
class QStringList;
|
|
||||||
|
|
||||||
namespace caf
|
namespace caf
|
||||||
{
|
{
|
||||||
|
@ -11,6 +11,15 @@ endif()
|
|||||||
# These headers need to go through Qt's MOC compiler
|
# These headers need to go through Qt's MOC compiler
|
||||||
set(MOC_HEADER_FILES cafViewer.h)
|
set(MOC_HEADER_FILES cafViewer.h)
|
||||||
|
|
||||||
|
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(
|
find_package(
|
||||||
Qt5
|
Qt5
|
||||||
COMPONENTS
|
COMPONENTS
|
||||||
@ -18,6 +27,7 @@ find_package(
|
|||||||
)
|
)
|
||||||
set(QT_LIBRARIES Qt5::Core Qt5::Gui Qt5::Widgets Qt5::OpenGL)
|
set(QT_LIBRARIES Qt5::Core Qt5::Gui Qt5::Widgets Qt5::OpenGL)
|
||||||
qt5_wrap_cpp(MOC_SOURCE_FILES ${MOC_HEADER_FILES})
|
qt5_wrap_cpp(MOC_SOURCE_FILES ${MOC_HEADER_FILES})
|
||||||
|
endif()
|
||||||
|
|
||||||
add_library(
|
add_library(
|
||||||
${PROJECT_NAME}
|
${PROJECT_NAME}
|
||||||
|
@ -144,16 +144,22 @@ bool caf::CadNavigation::handleInputEvent( QInputEvent* inputEvent )
|
|||||||
{
|
{
|
||||||
QWheelEvent* we = static_cast<QWheelEvent*>( 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 )
|
if ( m_isRotCenterInitialized )
|
||||||
{
|
{
|
||||||
int translatedMousePosX, translatedMousePosY;
|
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 );
|
cvf::ref<cvf::Ray> ray = createZoomRay( translatedMousePosX, translatedMousePosY );
|
||||||
|
|
||||||
zoomAlongRay( ray.p(), -we->delta() );
|
zoomAlongRay( ray.p(), -we->angleDelta().y() );
|
||||||
}
|
}
|
||||||
isEventHandled = true;
|
isEventHandled = true;
|
||||||
}
|
}
|
||||||
|
@ -200,13 +200,18 @@ void caf::CeetronNavigation::wheelEvent( QWheelEvent* event )
|
|||||||
if ( vpHeight <= 0 ) return;
|
if ( vpHeight <= 0 ) return;
|
||||||
|
|
||||||
int navDelta = vpHeight / 5;
|
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_trackball->endNavigation();
|
||||||
|
|
||||||
m_viewer->updateParallelProjectionHeightFromMoveZoom( m_pointOfInterest );
|
m_viewer->updateParallelProjectionHeightFromMoveZoom( m_pointOfInterest );
|
||||||
|
@ -185,16 +185,22 @@ bool caf::CeetronPlusNavigation::handleInputEvent( QInputEvent* inputEvent )
|
|||||||
{
|
{
|
||||||
QWheelEvent* we = static_cast<QWheelEvent*>( 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 )
|
if ( m_isRotCenterInitialized )
|
||||||
{
|
{
|
||||||
int translatedMousePosX, translatedMousePosY;
|
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 );
|
cvf::ref<cvf::Ray> ray = createZoomRay( translatedMousePosX, translatedMousePosY );
|
||||||
|
|
||||||
zoomAlongRay( ray.p(), we->delta() );
|
zoomAlongRay( ray.p(), we->angleDelta().y() );
|
||||||
}
|
}
|
||||||
isEventHandled = true;
|
isEventHandled = true;
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,18 @@ endif()
|
|||||||
find_package(OpenGL)
|
find_package(OpenGL)
|
||||||
|
|
||||||
# Qt
|
# Qt
|
||||||
|
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(
|
find_package(
|
||||||
Qt5
|
Qt5
|
||||||
COMPONENTS
|
COMPONENTS
|
||||||
@ -17,6 +29,7 @@ find_package(
|
|||||||
)
|
)
|
||||||
set(QT_LIBRARIES Qt5::Core Qt5::Gui Qt5::Widgets Qt5::OpenGL)
|
set(QT_LIBRARIES Qt5::Core Qt5::Gui Qt5::Widgets Qt5::OpenGL)
|
||||||
qt5_wrap_cpp(MOC_SOURCE_FILES ${MOC_HEADER_FILES})
|
qt5_wrap_cpp(MOC_SOURCE_FILES ${MOC_HEADER_FILES})
|
||||||
|
endif()
|
||||||
|
|
||||||
add_library(
|
add_library(
|
||||||
${PROJECT_NAME}
|
${PROJECT_NAME}
|
||||||
|
@ -32,9 +32,22 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
|||||||
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNO_DEBUG")
|
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNO_DEBUG")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(CEE_USE_QT6)
|
||||||
find_package(Qt5 COMPONENTS REQUIRED Core Gui OpenGL Widgets)
|
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)
|
set(QT_LIBRARIES Qt5::Core Qt5::Gui Qt5::OpenGL Qt5::Widgets)
|
||||||
|
endif()
|
||||||
|
|
||||||
# Libraries
|
# Libraries
|
||||||
add_subdirectory(AppFwk/cafProjectDataModel/cafPdmCore)
|
add_subdirectory(AppFwk/cafProjectDataModel/cafPdmCore)
|
||||||
|
Loading…
Reference in New Issue
Block a user