49 #pragma warning(disable:4127)
50 #pragma warning(disable:4512)
54 #include "QVTKInteractor.h"
57 #include <QSignalMapper>
59 #include <QResizeEvent>
61 #include "vtkCommand.h"
70 : QObject(parentObject)
80 if(iren == NULL || e == NULL)
83 const QEvent::Type t = e->type();
85 if(t == QEvent::Resize)
87 QResizeEvent* e2 =
static_cast<QResizeEvent*
>(e);
88 QSize size = e2->size();
89 iren->SetSize(size.width(), size.height());
93 if(t == QEvent::FocusIn)
96 QVTKInteractor* qiren = QVTKInteractor::SafeDownCast(iren);
99 qiren->StartListening();
104 if(t == QEvent::FocusOut)
107 QVTKInteractor* qiren = QVTKInteractor::SafeDownCast(iren);
110 qiren->StopListening();
116 if(!iren->GetEnabled())
119 if(t == QEvent::MouseButtonPress ||
120 t == QEvent::MouseButtonRelease ||
121 t == QEvent::MouseButtonDblClick ||
122 t == QEvent::MouseMove)
124 QMouseEvent* e2 =
static_cast<QMouseEvent*
>(e);
127 iren->SetEventInformationFlipY(e2->x(), e2->y(),
128 (e2->modifiers() & Qt::ControlModifier) > 0 ? 1 : 0,
129 (e2->modifiers() & Qt::ShiftModifier ) > 0 ? 1 : 0,
131 e2->type() == QEvent::MouseButtonDblClick ? 1 : 0);
133 if(t == QEvent::MouseMove)
135 iren->InvokeEvent(vtkCommand::MouseMoveEvent, e2);
137 else if(t == QEvent::MouseButtonPress || t == QEvent::MouseButtonDblClick)
142 iren->InvokeEvent(vtkCommand::LeftButtonPressEvent, e2);
146 iren->InvokeEvent(vtkCommand::MiddleButtonPressEvent, e2);
149 case Qt::RightButton:
150 iren->InvokeEvent(vtkCommand::RightButtonPressEvent, e2);
157 else if(t == QEvent::MouseButtonRelease)
162 iren->InvokeEvent(vtkCommand::LeftButtonReleaseEvent, e2);
166 iren->InvokeEvent(vtkCommand::MiddleButtonReleaseEvent, e2);
169 case Qt::RightButton:
170 iren->InvokeEvent(vtkCommand::RightButtonReleaseEvent, e2);
180 if(t == QEvent::Enter)
182 iren->InvokeEvent(vtkCommand::EnterEvent, e);
186 if(t == QEvent::Leave)
188 iren->InvokeEvent(vtkCommand::LeaveEvent, e);
192 if(t == QEvent::KeyPress || t == QEvent::KeyRelease)
194 QKeyEvent* e2 =
static_cast<QKeyEvent*
>(e);
197 int ascii_key = e2->text().length() ? e2->text().unicode()->toLatin1() : 0;
200 e2->modifiers() == Qt::KeypadModifier)
213 iren->SetKeyEventInformation(
214 (e2->modifiers() & Qt::ControlModifier),
215 (e2->modifiers() & Qt::ShiftModifier),
216 ascii_key, e2->count(), keysym);
218 if(t == QEvent::KeyPress)
221 iren->InvokeEvent(vtkCommand::KeyPressEvent, e2);
226 iren->InvokeEvent(vtkCommand::CharEvent, e2);
231 iren->InvokeEvent(vtkCommand::KeyReleaseEvent, e2);
236 if(t == QEvent::Wheel)
238 QWheelEvent* e2 =
static_cast<QWheelEvent*
>(e);
240 iren->SetEventInformationFlipY(e2->x(), e2->y(),
241 (e2->modifiers() & Qt::ControlModifier) > 0 ? 1 : 0,
242 (e2->modifiers() & Qt::ShiftModifier ) > 0 ? 1 : 0);
248 iren->InvokeEvent(vtkCommand::MouseWheelForwardEvent, e2);
252 iren->InvokeEvent(vtkCommand::MouseWheelBackwardEvent, e2);
257 if(t == QEvent::ContextMenu)
259 QContextMenuEvent* e2 =
static_cast<QContextMenuEvent*
>(e);
262 iren->SetEventInformationFlipY(e2->x(), e2->y(),
263 (e2->modifiers() & Qt::ControlModifier) > 0 ? 1 : 0,
264 (e2->modifiers() & Qt::ShiftModifier ) > 0 ? 1 : 0);
267 iren->InvokeEvent(QVTKInteractor::ContextMenuEvent, e2);
272 if(t == QEvent::DragEnter)
274 QDragEnterEvent* e2 =
static_cast<QDragEnterEvent*
>(e);
277 iren->InvokeEvent(QVTKInteractor::DragEnterEvent, e2);
282 if(t == QEvent::DragLeave)
284 QDragLeaveEvent* e2 =
static_cast<QDragLeaveEvent*
>(e);
287 iren->InvokeEvent(QVTKInteractor::DragLeaveEvent, e2);
292 if(t == QEvent::DragMove)
294 QDragMoveEvent* e2 =
static_cast<QDragMoveEvent*
>(e);
297 iren->SetEventInformationFlipY(e2->pos().x(), e2->pos().y());
300 iren->InvokeEvent(QVTKInteractor::DragMoveEvent, e2);
304 if(t == QEvent::Drop)
306 QDropEvent* e2 =
static_cast<QDropEvent*
>(e);
309 iren->SetEventInformationFlipY(e2->pos().x(), e2->pos().y());
312 iren->InvokeEvent(QVTKInteractor::DropEvent, e2);
322 0, 0, 0, 0, 0, 0, 0, 0, 0,
"Tab", 0, 0, 0, 0, 0, 0,
323 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
324 "space",
"exclam",
"quotedbl",
"numbersign",
325 "dollar",
"percent",
"ampersand",
"quoteright",
326 "parenleft",
"parenright",
"asterisk",
"plus",
327 "comma",
"minus",
"period",
"slash",
328 "0",
"1",
"2",
"3",
"4",
"5",
"6",
"7",
329 "8",
"9",
"colon",
"semicolon",
"less",
"equal",
"greater",
"question",
330 "at",
"A",
"B",
"C",
"D",
"E",
"F",
"G",
331 "H",
"I",
"J",
"K",
"L",
"M",
"N",
"O",
332 "P",
"Q",
"R",
"S",
"T",
"U",
"V",
"W",
333 "X",
"Y",
"Z",
"bracketleft",
334 "backslash",
"bracketright",
"asciicircum",
"underscore",
335 "quoteleft",
"a",
"b",
"c",
"d",
"e",
"f",
"g",
336 "h",
"i",
"j",
"k",
"l",
"m",
"n",
"o",
337 "p",
"q",
"r",
"s",
"t",
"u",
"v",
"w",
338 "x",
"y",
"z",
"braceleft",
"bar",
"braceright",
"asciitilde",
"Delete",
339 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
340 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
341 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
342 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
343 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
344 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
345 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
346 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
357 #define QVTK_HANDLE(x,y) \
362 #define QVTK_HANDLE_KEYPAD(x, y, z) \
364 ret = (modifiers & Qt::KeypadModifier) ? (y) : (z); \
static const char * AsciiToKeySymTable[]
QVTKMitkInteractorAdapter(QObject *parent)
static const char * qt_key_to_key_sym(Qt::Key, Qt::KeyboardModifiers modifiers)
#define QVTK_HANDLE_KEYPAD(x, y, z)
static const char * ascii_to_key_sym(int)
bool ProcessEvent(QEvent *e, vtkRenderWindowInteractor *iren)
#define QVTK_HANDLE(x, y)
~QVTKMitkInteractorAdapter()