Fix savefig size and black image#331
Conversation
less indentation
… fixed on this branch
…hich are hardware problems
… is not lifted when saving an image + off_screen_rendering + wx
This reverts commit 4d85baf.
|
There may be a better way. |
|
The "better" way doesn't work. Never mind. |
|
This is good for review. |
|
Reviewing this one |
| # Remove OnPaint handler for PaintEvent, otherwise | ||
| # OnPaint tries to reset the size of the nonexisting | ||
| # renderwindow | ||
| wx.EVT_PAINT(self._vtk_control, None) |
There was a problem hiding this comment.
This one makes me a bit nervous because I checked the rest of the class, and nowhere it is enforced that self._vtk_control is not None. We have the same problem pretty much everywhere. I am generally fine with throwing an exception, but if None is an allowed value, we should react appropriately without throwing. If it's not, it's better to enforce the presence of a control at construction time.
There was a problem hiding this comment.
_create_control is called here https://github.com/enthought/mayavi/blob/fix-savefig-size-black-image/tvtk/pyface/tvtk_scene.py#L205 which assigns _vtk_control. Unless self._vtk_control = None is done somewhere outside of this function (which I have not checked), we can ensure _vtk_control is not None?
Fix simphony/simphony-mayavi#52, fix #257, potentially related to #75
Supersede #316 and #317 (the two issues are highly related that it has become impossible to separate the two)
Upon saving an image (snapshot), a new tvtkRenderWindow is created. This is motivated by the fact that under Mac OS, vtkCocoaRenderWindow is the render window being used and if the vtkRenderWindow is contained by an interactor, resizing the renderwindow leads to the resulting image to be rendered only within the initial size. Therefore a new tvtkRenderWindow is needed for saving an image in Mac.
This fix for Mac causes a side effect for Linux which is that when offscreen is off, saving an image will create a new window. Forcing offscreen to true for the dummy tvtkRenderWindow would enhance the user experience but render the savefig function completely unusable if the machine does not support offscreen.
Tested platforms:
Mac OS 10.11 + wxPython/PyQt + VTK 6.2
Ubuntu 12.02 LTS + VTK 5.10/6.2.0/6.3.0 + wxPython/PyQt