Qt widget wrapping only propagates resizeEvent to the interactor, not the render window
Hello,
A python script is provided for reproducing the issue on Win10.
I am using an observer on the render window for the "WindowResizeEvent". Its purpose is to update a watermark position on the render window, responding to any resize of the VTK widget.
My issue (only Win10, Linux is OK) is that when the QVTKRenderWindowInteractor
needs to resize for the first time (because main windows resizes or even during instanciation) interactor the render window size is not updated.
Let's focus on QVTKRenderWindowInteractor.resizeEvent
specifically on line 472 vtkRenderWindow.SetSize(self._RenderWindow, w, h)
:
- I guess the "WindowResizeEvent" is invoked during the render window's
SetSize
call. In the observer I am not really expecting the interactor to have the correct size since itsSetSize
has not been called yet. The issue is that render window'sGetSize
returns the old values as if theSetSize
did nothing. - Later it seems the interactor "ConfigureEvent" is invoked. In a second attached observer I can see the interactor having the expected size while the render window size has not updated yet!
My workaround for this specific issue is simply to observe the interactor "ConfigureEvent" and use the interactor size (should be equal to the render window size) for computing the watermark new position.
Overall I think this can hide bigger issue:
- At some point some colleagues have witnessed black areas in the render window that disappear as soon as you resize the window. For me this is directly linked to the render window reporting erroneous size and not painting outside its bounds, leaving black areas.
- Using another
SetSize
signature solves the issue! Use an array/list instead of 2 separate intsvtkRenderWindow.SetSize(self._RenderWindow, (w, h))
(notice the use of parenthesize around "w" and "h", could be list as well).
Inspecting interactor vs render window size in any of the observers mentioned will show different values, as if the render window was using the previous values.
- The use of the class/static method seems to go as far back as f4ff4fb2
- Render window setting new size: 1d8dc6dc
- First Qt wrapper? bae05540
An old discussion about dodging X/Win32 code using the class method: https://marc.info/?l=vtk-developers&m=131466818029037
I did not go too far down the VTK C++ inheritance graph of vtkRenderWindow::SetSize
. Maybe the discussion is not relevant anymore and we could use super()
. Maybe some ::SetSize
implementations/inheritances are broken (Win32 vs X11) ? Maybe just using the ::SetSize(int a[2])
instead of SetSize(int width, int height)
is the solution?
Sorry for the long post but this size inconsistency seemed fishy to me.
Thank you.
Best regards,