Skip to content

Commit 992a42e

Browse files
committed
Port to Qt6
Status: done libqvr qvr-example-opengl qvr-example-opengl-minimal qvr-example-outputplugin qvr-identify-displays qvr-sceneviewer qvr-vncviewer Status: compiles, but runtime OpenGL errors (maybe because of new Qt GL abstraction) qvr-example-openscenegraph qvr-example-vtk Status: not done yet (because of substantial changes in Qt Multimedia) qvr-videoplayer The plan is to port qvr-videoplayer next, and ignore openscenegraph and vtk problems for now.
1 parent d768274 commit 992a42e

File tree

19 files changed

+277
-157
lines changed

19 files changed

+277
-157
lines changed

libqvr/CMakeLists.txt

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (C) 2016, 2017, 2018, 2019, 2020, 2021
1+
# Copyright (C) 2016, 2017, 2018, 2019, 2020, 2021, 2022
22
# Computer Graphics Group, University of Siegen
33
# Written by Martin Lambers <[email protected]>
44
#
@@ -13,23 +13,24 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
1313

1414
# Project
1515
project(libqvr)
16-
set(QVR_VERSION 3.0.2)
17-
set(QVR_LIBVERSION 3.0.2)
18-
set(QVR_SOVERSION 3)
16+
set(QVR_VERSION 4.0.0)
17+
set(QVR_LIBVERSION 4.0.0)
18+
set(QVR_SOVERSION 4)
1919

2020
# Build options
2121
option(QVR_BUILD_DOCUMENTATION "Build API reference documentation (requires Doxygen)" OFF)
2222

2323
# Required libraries
24-
find_package(Qt5 5.12.0 COMPONENTS Gui Network OPTIONAL_COMPONENTS Gamepad)
24+
find_package(Qt6 6.2.0 COMPONENTS Gui OpenGL Network OPTIONAL_COMPONENTS Gamepad)
25+
add_definitions(-DQT_DEPRECATED_WARNINGS)
2526

2627
# Optional libraries
2728
find_package(VRPN QUIET)
2829
find_package(OCULUS QUIET)
2930
find_package(OPENVR QUIET)
3031

3132
# The QVR library
32-
qt5_add_resources(QVRRESOURCES qvr.qrc)
33+
qt6_add_resources(QVRRESOURCES qvr.qrc)
3334
add_library(libqvr SHARED
3435
manager.hpp manager.cpp
3536
config.hpp config.cpp
@@ -48,10 +49,10 @@ set_target_properties(libqvr PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
4849
set_target_properties(libqvr PROPERTIES OUTPUT_NAME qvr)
4950
set_target_properties(libqvr PROPERTIES VERSION ${QVR_LIBVERSION})
5051
set_target_properties(libqvr PROPERTIES SOVERSION ${QVR_SOVERSION})
51-
target_link_libraries(libqvr Qt5::Gui Qt5::Network)
52-
if(Qt5Gamepad_FOUND)
52+
target_link_libraries(libqvr Qt6::Gui Qt6::OpenGL Qt6::Network)
53+
if(Qt6Gamepad_FOUND)
5354
add_definitions(-DHAVE_QGAMEPAD)
54-
target_link_libraries(libqvr Qt5::Gamepad)
55+
target_link_libraries(libqvr Qt6::Gamepad)
5556
endif()
5657
if(VRPN_FOUND)
5758
add_definitions(-DHAVE_VRPN)

libqvr/event.cpp

Lines changed: 128 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -30,80 +30,123 @@
3030
QVREvent::QVREvent() :
3131
type(QVR_Event_KeyPress),
3232
context(),
33-
keyEvent(QEvent::None, 0, Qt::NoModifier),
34-
mouseEvent(QEvent::None, QPointF(), Qt::NoButton, Qt::NoButton, Qt::NoModifier),
35-
wheelEvent(QPointF(), QPointF(), QPoint(), QPoint(), Qt::NoButton, Qt::NoModifier, Qt::NoScrollPhase, false),
36-
deviceEvent(QVRDevice(), -1, -1)
33+
deviceEvent(QVRDevice(), -1, -1),
34+
keyEventType(QEvent::None),
35+
keyEventKey(0),
36+
keyEventModifiers(Qt::NoModifier),
37+
keyEventNativeScanCode(0),
38+
keyEventNativeVirtualKey(0),
39+
keyEventNativeModifiers(0),
40+
keyEventText(),
41+
keyEventAutorepeat(false),
42+
keyEventCount(0)
43+
{}
44+
45+
QVREvent::QVREvent(QVREventType t, const QVRDeviceEvent& e) :
46+
type(t),
47+
context(),
48+
deviceEvent(e)
3749
{}
3850

3951
QVREvent::QVREvent(QVREventType t, const QVRRenderContext& c, const QKeyEvent& e) :
4052
type(t),
4153
context(c),
42-
keyEvent(e),
43-
mouseEvent(QEvent::None, QPointF(), Qt::NoButton, Qt::NoButton, Qt::NoModifier),
44-
wheelEvent(QPointF(), QPointF(), QPoint(), QPoint(), Qt::NoButton, Qt::NoModifier, Qt::NoScrollPhase, false),
45-
deviceEvent(QVRDevice(), -1, -1)
54+
deviceEvent(QVRDevice(), -1, -1),
55+
keyEventType(e.type()),
56+
keyEventKey(e.key()),
57+
keyEventModifiers(e.modifiers()),
58+
keyEventNativeScanCode(e.nativeScanCode()),
59+
keyEventNativeVirtualKey(e.nativeVirtualKey()),
60+
keyEventNativeModifiers(e.nativeModifiers()),
61+
keyEventText(e.text()),
62+
keyEventAutorepeat(e.isAutoRepeat()),
63+
keyEventCount(e.count())
4664
{}
4765

4866
QVREvent::QVREvent(QVREventType t, const QVRRenderContext& c, const QMouseEvent& e) :
4967
type(t),
5068
context(c),
51-
keyEvent(QEvent::None, 0, Qt::NoModifier),
52-
mouseEvent(e),
53-
wheelEvent(QPointF(), QPointF(), QPoint(), QPoint(), Qt::NoButton, Qt::NoModifier, Qt::NoScrollPhase, false),
54-
deviceEvent(QVRDevice(), -1, -1)
69+
deviceEvent(QVRDevice(), -1, -1),
70+
mouseEventType(e.type()),
71+
mouseEventPosition(e.position()),
72+
mouseEventScenePosition(e.scenePosition()),
73+
mouseEventGlobalPosition(e.globalPosition()),
74+
mouseEventButton(e.button()),
75+
mouseEventButtons(e.buttons()),
76+
mouseEventModifiers(e.modifiers())
5577
{}
5678

5779
QVREvent::QVREvent(QVREventType t, const QVRRenderContext& c, const QWheelEvent& e) :
5880
type(t),
5981
context(c),
60-
keyEvent(QEvent::None, 0, Qt::NoModifier),
61-
mouseEvent(QEvent::None, QPointF(), Qt::NoButton, Qt::NoButton, Qt::NoModifier),
62-
wheelEvent(e),
63-
deviceEvent(QVRDevice(), -1, -1)
82+
deviceEvent(QVRDevice(), -1, -1),
83+
wheelEventPosition(e.position()),
84+
wheelEventGlobalPosition(e.globalPosition()),
85+
wheelEventPixelDelta(e.pixelDelta()),
86+
wheelEventAngleDelta(e.angleDelta()),
87+
wheelEventButtons(e.buttons()),
88+
wheelEventModifiers(e.modifiers()),
89+
wheelEventPhase(e.phase()),
90+
wheelEventInverted(e.inverted())
6491
{}
6592

66-
QVREvent::QVREvent(QVREventType t, const QVRDeviceEvent& e) :
67-
type(t),
68-
context(),
69-
keyEvent(QEvent::None, 0, Qt::NoModifier),
70-
mouseEvent(QEvent::None, QPointF(), Qt::NoButton, Qt::NoButton, Qt::NoModifier),
71-
wheelEvent(QPointF(), QPointF(), QPoint(), QPoint(), Qt::NoButton, Qt::NoModifier, Qt::NoScrollPhase, false),
72-
deviceEvent(e)
73-
{}
93+
QKeyEvent* QVREvent::createKeyEvent() const
94+
{
95+
return new QKeyEvent(keyEventType, keyEventKey, keyEventModifiers,
96+
keyEventNativeScanCode, keyEventNativeVirtualKey, keyEventNativeModifiers,
97+
keyEventText, keyEventAutorepeat, keyEventCount);
98+
}
99+
100+
QMouseEvent* QVREvent::createMouseEvent() const
101+
{
102+
return new QMouseEvent(mouseEventType, mouseEventPosition, mouseEventScenePosition,
103+
mouseEventGlobalPosition, mouseEventButton, mouseEventButtons, mouseEventModifiers);
104+
}
105+
106+
QWheelEvent* QVREvent::createWheelEvent() const
107+
{
108+
return new QWheelEvent(wheelEventPosition, wheelEventGlobalPosition, wheelEventPixelDelta,
109+
wheelEventAngleDelta, wheelEventButtons, wheelEventModifiers, wheelEventPhase,
110+
wheelEventInverted);
111+
}
74112

75113
QDataStream &operator<<(QDataStream& ds, const QVREvent& e)
76114
{
77-
ds << static_cast<int>(e.type);
115+
ds << static_cast<int>(e.type) << e.context;
78116
switch (e.type) {
79117
case QVR_Event_KeyPress:
80118
case QVR_Event_KeyRelease:
81-
ds << e.context
82-
<< static_cast<int>(e.keyEvent.type())
83-
<< e.keyEvent.key()
84-
<< static_cast<int>(e.keyEvent.modifiers());
119+
ds << static_cast<int>(e.keyEventType)
120+
<< e.keyEventKey
121+
<< static_cast<int>(e.keyEventModifiers)
122+
<< e.keyEventNativeScanCode
123+
<< e.keyEventNativeVirtualKey
124+
<< e.keyEventNativeModifiers
125+
<< e.keyEventText
126+
<< e.keyEventAutorepeat
127+
<< e.keyEventCount;
85128
break;
86129
case QVR_Event_MouseMove:
87130
case QVR_Event_MousePress:
88131
case QVR_Event_MouseRelease:
89132
case QVR_Event_MouseDoubleClick:
90-
ds << e.context
91-
<< static_cast<int>(e.mouseEvent.type())
92-
<< e.mouseEvent.localPos()
93-
<< static_cast<int>(e.mouseEvent.button())
94-
<< static_cast<int>(e.mouseEvent.buttons())
95-
<< static_cast<int>(e.mouseEvent.modifiers());
133+
ds << static_cast<int>(e.mouseEventType)
134+
<< e.mouseEventPosition
135+
<< e.mouseEventScenePosition
136+
<< e.mouseEventGlobalPosition
137+
<< static_cast<int>(e.mouseEventButton)
138+
<< static_cast<int>(e.mouseEventButtons)
139+
<< static_cast<int>(e.mouseEventModifiers);
96140
break;
97141
case QVR_Event_Wheel:
98-
ds << e.context
99-
<< e.wheelEvent.position()
100-
<< e.wheelEvent.globalPosition()
101-
<< e.wheelEvent.pixelDelta()
102-
<< e.wheelEvent.angleDelta()
103-
<< static_cast<int>(e.wheelEvent.buttons())
104-
<< static_cast<int>(e.wheelEvent.modifiers())
105-
<< static_cast<int>(e.wheelEvent.phase())
106-
<< static_cast<int>(e.wheelEvent.inverted());
142+
ds << e.wheelEventPosition
143+
<< e.wheelEventGlobalPosition
144+
<< e.wheelEventPixelDelta
145+
<< e.wheelEventAngleDelta
146+
<< static_cast<int>(e.wheelEventButtons)
147+
<< static_cast<int>(e.wheelEventModifiers)
148+
<< static_cast<int>(e.wheelEventPhase)
149+
<< e.wheelEventInverted;
107150
break;
108151
case QVR_Event_DeviceButtonPress:
109152
case QVR_Event_DeviceButtonRelease:
@@ -120,60 +163,62 @@ QDataStream &operator>>(QDataStream& ds, QVREvent& e)
120163
int type;
121164
ds >> type;
122165
e.type = static_cast<QVREventType>(type);
166+
ds >> e.context;
123167

124-
int ke[3];
125-
int me[4];
126-
QPointF mepf;
127-
QPointF wepf[2];
128-
QPoint wep[2];
129-
int we[4];
130-
QVRDevice d;
131-
int de[2];
132-
168+
int intval;
133169
switch (e.type) {
134170
case QVR_Event_KeyPress:
135171
case QVR_Event_KeyRelease:
136-
ds >> e.context
137-
>> ke[0]
138-
>> ke[1]
139-
>> ke[2];
140-
e.keyEvent = QKeyEvent(static_cast<QEvent::Type>(ke[0]), ke[1], static_cast<Qt::KeyboardModifier>(ke[2]));
172+
ds >> intval;
173+
e.keyEventType = static_cast<QEvent::Type>(intval);
174+
ds >> e.keyEventKey;
175+
ds >> intval;
176+
e.keyEventModifiers = static_cast<Qt::KeyboardModifiers>(intval);
177+
ds >> e.keyEventNativeScanCode
178+
>> e.keyEventNativeVirtualKey
179+
>> e.keyEventNativeModifiers
180+
>> e.keyEventText
181+
>> e.keyEventAutorepeat
182+
>> e.keyEventCount;
141183
break;
142184
case QVR_Event_MouseMove:
143185
case QVR_Event_MousePress:
144186
case QVR_Event_MouseRelease:
145187
case QVR_Event_MouseDoubleClick:
146-
ds >> e.context
147-
>> me[0]
148-
>> mepf
149-
>> me[1]
150-
>> me[2]
151-
>> me[3];
152-
e.mouseEvent = QMouseEvent(static_cast<QEvent::Type>(me[0]), mepf,
153-
static_cast<Qt::MouseButton>(me[1]), static_cast<Qt::MouseButtons>(me[2]),
154-
static_cast<Qt::KeyboardModifier>(me[3]));
188+
ds >> intval;
189+
e.mouseEventType = static_cast<QEvent::Type>(intval);
190+
ds >> e.mouseEventPosition
191+
>> e.mouseEventScenePosition
192+
>> e.mouseEventGlobalPosition
193+
>> intval;
194+
e.mouseEventButton = static_cast<Qt::MouseButton>(intval);
195+
ds >> intval;
196+
e.mouseEventButtons = static_cast<Qt::MouseButtons>(intval);
197+
ds >> intval;
198+
e.mouseEventModifiers = static_cast<Qt::KeyboardModifiers>(intval);
155199
break;
156200
case QVR_Event_Wheel:
157-
ds >> e.context
158-
>> wepf[0]
159-
>> wepf[1]
160-
>> wep[0]
161-
>> wep[1]
162-
>> we[0]
163-
>> we[1]
164-
>> we[2]
165-
>> we[3];
166-
e.wheelEvent = QWheelEvent(wepf[0], wepf[1], wep[0], wep[1],
167-
static_cast<Qt::MouseButtons>(we[0]), static_cast<Qt::KeyboardModifier>(we[1]),
168-
static_cast<Qt::ScrollPhase>(we[2]), static_cast<bool>(we[3]));
201+
ds >> e.wheelEventPosition
202+
>> e.wheelEventGlobalPosition
203+
>> e.wheelEventPixelDelta
204+
>> e.wheelEventAngleDelta
205+
>> intval;
206+
e.wheelEventButtons = static_cast<Qt::MouseButtons>(intval);
207+
ds >> intval;
208+
e.wheelEventModifiers = static_cast<Qt::KeyboardModifiers>(intval);
209+
ds >> intval;
210+
e.wheelEventPhase = static_cast<Qt::ScrollPhase>(intval);
211+
ds >> e.wheelEventInverted;
169212
break;
170213
case QVR_Event_DeviceButtonPress:
171214
case QVR_Event_DeviceButtonRelease:
172215
case QVR_Event_DeviceAnalogChange:
173-
ds >> d
174-
>> de[0]
175-
>> de[1];
176-
e.deviceEvent = QVRDeviceEvent(d, de[0], de[1]);
216+
{
217+
QVRDevice d;
218+
int de[2];
219+
ds >> d >> de[0] >> de[1];
220+
e.deviceEvent = QVRDeviceEvent(d, de[0], de[1]);
221+
}
177222
break;
178223
}
179224
return ds;

libqvr/event.hpp

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
2-
* Copyright (C) 2016, 2017 Computer Graphics Group, University of Siegen
2+
* Copyright (C) 2016, 2017, 2018, 2019, 2020, 2021, 2022
3+
* Computer Graphics Group, University of Siegen
34
* Written by Martin Lambers <[email protected]>
45
*
56
* Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -27,7 +28,6 @@
2728
#include <QKeyEvent>
2829
#include <QMouseEvent>
2930
#include <QWheelEvent>
30-
#include <QMatrix4x4>
3131

3232
#include "device.hpp"
3333
#include "rendercontext.hpp"
@@ -52,16 +52,44 @@ class QVREvent
5252
public:
5353
QVREventType type;
5454
QVRRenderContext context;
55-
QKeyEvent keyEvent;
56-
QMouseEvent mouseEvent;
57-
QWheelEvent wheelEvent;
5855
QVRDeviceEvent deviceEvent;
56+
/* for QKeyEvent: */
57+
QEvent::Type keyEventType;
58+
int keyEventKey;
59+
Qt::KeyboardModifiers keyEventModifiers;
60+
quint32 keyEventNativeScanCode;
61+
quint32 keyEventNativeVirtualKey;
62+
quint32 keyEventNativeModifiers;
63+
QString keyEventText;
64+
bool keyEventAutorepeat;
65+
quint16 keyEventCount;
66+
/* for QMouseEvent: */
67+
QEvent::Type mouseEventType;
68+
QPointF mouseEventPosition;
69+
QPointF mouseEventScenePosition;
70+
QPointF mouseEventGlobalPosition;
71+
Qt::MouseButton mouseEventButton;
72+
Qt::MouseButtons mouseEventButtons;
73+
Qt::KeyboardModifiers mouseEventModifiers;
74+
/* for QWheelEvent: */
75+
QPointF wheelEventPosition;
76+
QPointF wheelEventGlobalPosition;
77+
QPoint wheelEventPixelDelta;
78+
QPoint wheelEventAngleDelta;
79+
Qt::MouseButtons wheelEventButtons;
80+
Qt::KeyboardModifiers wheelEventModifiers;
81+
Qt::ScrollPhase wheelEventPhase;
82+
bool wheelEventInverted;
5983

6084
QVREvent();
85+
QVREvent(QVREventType t, const QVRDeviceEvent& e);
6186
QVREvent(QVREventType t, const QVRRenderContext& c, const QKeyEvent& e);
6287
QVREvent(QVREventType t, const QVRRenderContext& c, const QMouseEvent& e);
6388
QVREvent(QVREventType t, const QVRRenderContext& c, const QWheelEvent& e);
64-
QVREvent(QVREventType t, const QVRDeviceEvent& e);
89+
90+
QKeyEvent* createKeyEvent() const;
91+
QMouseEvent* createMouseEvent() const;
92+
QWheelEvent* createWheelEvent() const;
6593
};
6694

6795
QDataStream &operator<<(QDataStream& ds, const QVREvent& e);

0 commit comments

Comments
 (0)