fix(ui): several scenes in the same window break interactors
Description
Having more than one scene in an application completely breaks the interactors. Especially the trackball one. Some events are not managed, some are not triggered, some simply do not do what they are expected to.
The key code is there:
void Window::keyReleaseEvent(QKeyEvent* _e)
{
sight::viz::scene3d::IWindowInteractor::InteractionInfo info;
info.interactionType = sight::viz::scene3d::IWindowInteractor::InteractionInfo::KEYRELEASE;
info.modifiers = convertModifiers(QApplication::keyboardModifiers());
info.key = _e->key();
auto cursorPosition = getCursorPosition(this); //<-------------------------------------------------
info.x = static_cast<int>(cursorPosition.x() * this->devicePixelRatio());
info.y = static_cast<int>(cursorPosition.y() * this->devicePixelRatio());
Q_EMIT interacted(info);
}
cursorPosition
receives (0, 0)
, which breaks everything (rotations, etc.).
Why ?
It's computed like that:
static inline QPoint getCursorPosition(const QWindow* const _w)
{
const auto globalCursorPosition = QCursor::pos();
const auto widgetCursorPosition = _w->mapFromGlobal(globalCursorPosition);
if(_w->geometry().contains(widgetCursorPosition))
{
return widgetCursorPosition;
}
return QPoint();
}
See the problem?
When there's only one view, no problem of course.
But when there's two (like in interius
), the coordinate system of two windows are not the same. Which means it will return QPoint()
erroneously.
BUT because we check if an event occurs in a layer (there for example), that tests fails and strange stuffs happens.
Steps to reproduce
Duplicate SightViewer scene and try to interact with the one on the right (key press, rotate the volume, etc.).
Proposal
TBA
Functional specifications
-
I expect 2 scenes in the same window to behave the same independently of their position in the layout, i.e:
- Mouse coordinates should be properly passed regardless of the scene position in the window
- All interactors should receive correct information regardless of the context they are used in.
-
TBA
Technical specifications
TBA
Test plan
TBA