Open Inventor Release 2024.2.1
 
Loading...
Searching...
No Matches
QtEventToSoEvent.h
1#pragma once
2
3#include <QKeyEvent>
4#include <QMouseEvent>
5#include <QTouchEvent>
6#include <QWheelEvent>
7
8#include <Inventor/ViewerComponents/SoEventBuilder.h>
9
13class QTVIEWERCOMPONENTS_API QtEventToSoEvent
14{
15public:
21 static SoMouseButtonEvent*
22 getMousePressEvent( QMouseEvent* qevent, QPoint eventPosition )
23 {
24 return m_ivEvent.getMousePressEvent( eventPosition.x(),
25 eventPosition.y(),
26 getButtonId( qevent ),
27 qevent->modifiers() & Qt::AltModifier,
28 qevent->modifiers() & Qt::ControlModifier,
29 qevent->modifiers() & Qt::ShiftModifier );
30 }
31
37 static SoMouseButtonEvent*
38 getMouseReleaseEvent( QMouseEvent* qevent, QPoint eventPosition )
39 {
40 return m_ivEvent.getMouseReleaseEvent( eventPosition.x(),
41 eventPosition.y(),
42 getButtonId( qevent ),
43 qevent->modifiers() & Qt::AltModifier,
44 qevent->modifiers() & Qt::ControlModifier,
45 qevent->modifiers() & Qt::ShiftModifier );
46 }
47
53 static SoMouseButtonEvent*
54 getMouseDoubleClickEvent( QMouseEvent* qevent, QPoint eventPosition )
55 {
56 return m_ivEvent.getMouseDoubleClickEvent( eventPosition.x(),
57 eventPosition.y(),
58 getButtonId( qevent ),
59 qevent->modifiers() & Qt::AltModifier,
60 qevent->modifiers() & Qt::ControlModifier,
61 qevent->modifiers() & Qt::ShiftModifier );
62 }
63
68 static SoMouseWheelEvent*
69 getMouseWheelEvent( QWheelEvent* qevent )
70 {
71 return m_ivEvent.getMouseWheelEvent( qevent->angleDelta().y(),
72 qevent->modifiers() & Qt::AltModifier,
73 qevent->modifiers() & Qt::ControlModifier,
74 qevent->modifiers() & Qt::ShiftModifier );
75 }
76
82 static SoLocation2Event*
83 getMouseMoveEvent( QMouseEvent* qevent, QPoint eventPosition )
84 {
85 return m_ivEvent.getMouseMoveEvent( eventPosition.x(),
86 eventPosition.y(),
87 qevent->modifiers() & Qt::AltModifier,
88 qevent->modifiers() & Qt::ControlModifier,
89 qevent->modifiers() & Qt::ShiftModifier );
90 }
91
95 static SoLocation2Event*
97 {
98 return m_ivEvent.getMouseEnterEvent( 0, 0, false, false, false );
99 }
100
104 static SoLocation2Event*
106 {
107 return m_ivEvent.getMouseLeaveEvent( 0, 0, false, false, false );
108 }
109
115 static SoLocation2Event*
116 getHoverMouseEvent( QHoverEvent* qevent, QPoint eventPosition )
117 {
118 return m_ivEvent.getMouseMoveEvent( eventPosition.x(),
119 eventPosition.y(),
120 qevent->modifiers() & Qt::AltModifier,
121 qevent->modifiers() & Qt::ControlModifier,
122 qevent->modifiers() & Qt::ShiftModifier );
123 }
124
129 static SoKeyboardEvent*
130 getKeyPressEvent( QKeyEvent* qevent )
131 {
132 SoKeyboardEvent::Key ivKey = getIvKey( qevent );
133 return m_ivEvent.getKeyPressEvent( ivKey,
134 qevent->modifiers() & Qt::AltModifier,
135 qevent->modifiers() & Qt::ControlModifier,
136 qevent->modifiers() & Qt::ShiftModifier );
137 }
138
143 static SoKeyboardEvent*
144 getKeyReleaseEvent( QKeyEvent* qevent )
145 {
146 SoKeyboardEvent::Key ivKey = getIvKey( qevent );
147 return m_ivEvent.getKeyReleaseEvent( ivKey,
148 qevent->modifiers() & Qt::AltModifier,
149 qevent->modifiers() & Qt::ControlModifier,
150 qevent->modifiers() & Qt::ShiftModifier );
151 }
152
158 const std::vector<const SoEvent*>& getTouchEvents( QTouchEvent* qevent, int height );
159
160private:
161
166 static SoMouseButtonEvent::Button getButtonId( QMouseEvent* qevent );
167
171 static SoEventBuilder m_ivEvent;
172
173private:
174 static bool initClass();
175 static bool s_init;
176
177 static SoKeyboardEvent::Key getIvKey( QKeyEvent* qevent );
178
179 std::vector<const SoEvent*> m_soeventlist;
180
181 // Mapping from QT virtual keys to SoKeyboardEvent::Key enum
182 static SoKeyboardEvent::Key keyMap[256];
183 static SoKeyboardEvent::Key keyMap2[97];
184 static int keyMapInitFlag;
185};
static SoMouseButtonEvent * getMouseReleaseEvent(QMouseEvent *qevent, QPoint eventPosition)
Transform QMouseReleaseEvent to SoMouseButtonEvent.
static SoKeyboardEvent * getKeyPressEvent(QKeyEvent *qevent)
Transform QKeyEvent press to SoKeyboardEvent.
static SoMouseButtonEvent * getMousePressEvent(QMouseEvent *qevent, QPoint eventPosition)
Transform QMousePressEvent to SoMouseButtonEvent.
static SoLocation2Event * getMouseLeaveEvent()
Transform mouse leave event to SoLocation2Event.
const std::vector< const SoEvent * > & getTouchEvents(QTouchEvent *qevent, int height)
Transform QTouchEvent to a list of SoEvent representing the touch event.
static SoKeyboardEvent * getKeyReleaseEvent(QKeyEvent *qevent)
Transform QKeyEvent release to SoKeyboardEvent.
static SoLocation2Event * getMouseEnterEvent()
Transform mouse enter event to SoLocation2Event.
static SoLocation2Event * getHoverMouseEvent(QHoverEvent *qevent, QPoint eventPosition)
Transform QHoverEvent to SoLocation2Event.
static SoMouseButtonEvent * getMouseDoubleClickEvent(QMouseEvent *qevent, QPoint eventPosition)
Transform QMouseDoubleClickEvent to SoMouseButtonEvent.
static SoLocation2Event * getMouseMoveEvent(QMouseEvent *qevent, QPoint eventPosition)
Transform QMouseEvent to SoLocation2Event.
static SoMouseWheelEvent * getMouseWheelEvent(QWheelEvent *qevent)
Transform QWheelEvent to SoMouseWheelEvent.
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Utility class th...
Keyboard key press and release events.
Key
The keyboard keys.
2D location events.
Mouse button press and release events.
Mouse wheel events.