[wxVTK] Redraw problems with wxVTK and wxMAC: perhaps a solution!
Brought to you by:
malat
From: Pierre F. <Pie...@so...> - 2007-02-19 14:22:42
|
Hi! First of all, thank you Mathieu for providing us with this wx interface to VTK! Since I started using wxWidgets and wxVTK on a MAC, I realized (others might have experienced this also) that the display was sometimes not updated properly. I am using wxMAC 2.8.0, VTK 5.0.2 and MacOSX 10.4.8. I used wxVTK versions from 0.8 to 1.2, the problem remains in all versions. The problem occurs when at least two wxVTK windows are embedded in a window (case of the SplitSample for example). When one slowly resizes it, there is no problem, i.e. everything is repainted correctly. However, when one resizes the window very fast, (for instance when the window is put in full screen mode), then some parts of the wxVTK windows are not redrawn, even worse, the background is painted over the window. The only way to refresh the wxVTK windows is to slowly downsize the frame. I tried to overload the OnPaint event to force a call to Render() or simulate a resizing, nothing worked. It was starting to drive me crazy since the redraw problem was really annoying when one wanted for instance, to put a view in full screen, and then back to normal... I finally found a solution: one needs to call the "UpdageGLRegion()" method of the vtkCarbonRenderWindow (assuming that you're using the Carbon version of wxMAC, I haven't tried the other ports, but they seem to be less complete anyway) during the OnPaint() method of the wxVTKRenderWindowInteractor class. Here is what I put at the end of the OnPaint() method: #ifdef __WXMAC__ vtkCarbonRenderWindow* rwin = vtkCarbonRenderWindow::SafeDownCast(RenderWindow); if( rwin ) { rwin->UpdateGLRegion(); } #endif That might not be the most elegant way to bypass this redraw problem, but at least it works. And goodbye the ugly background painted over the VTK windows. I hope this was helpful to some Mac users. Maybe the problem is completely related to my hardware / software version. In this case, I apologize for the inconvenience. Pierre Fillard, INRIA Sophia Antipolis, France. http://www-sop.inria.fr/asclepios/software/MedINRIA. |