Skip to content

Fix savefig size and black image#331

Merged
stefanoborini merged 36 commits into
masterfrom
fix-savefig-size-black-image
Apr 21, 2016
Merged

Fix savefig size and black image#331
stefanoborini merged 36 commits into
masterfrom
fix-savefig-size-black-image

Conversation

@kitchoi
Copy link
Copy Markdown
Contributor

@kitchoi kitchoi commented Mar 31, 2016

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

kitchoi and others added 27 commits March 15, 2016 17:11
… is not lifted when

saving an image + off_screen_rendering + wx
This reverts commit 4d85baf.
@kitchoi kitchoi mentioned this pull request Mar 31, 2016
@kitchoi kitchoi closed this Apr 1, 2016
@kitchoi
Copy link
Copy Markdown
Contributor Author

kitchoi commented Apr 1, 2016

There may be a better way.

@kitchoi kitchoi reopened this Apr 1, 2016
@kitchoi
Copy link
Copy Markdown
Contributor Author

kitchoi commented Apr 1, 2016

The "better" way doesn't work. Never mind.

@kitchoi
Copy link
Copy Markdown
Contributor Author

kitchoi commented Apr 1, 2016

This is good for review.

@stefanoborini
Copy link
Copy Markdown
Contributor

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)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_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?

Copy link
Copy Markdown
Contributor Author

@kitchoi kitchoi Apr 21, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On other hand, this change is meant to silent error message on Linux + wx 2.8.10 (see message in #346)
The same error does not occur on OSX with wxpython 3.0.2, so I have omitted this change in the reimplementation #346

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good. Merging.

@stefanoborini stefanoborini merged commit 3bccaaf into master Apr 21, 2016
@stefanoborini stefanoborini deleted the fix-savefig-size-black-image branch April 21, 2016 14:12
@kitchoi kitchoi restored the fix-savefig-size-black-image branch April 21, 2016 14:13
@kitchoi
Copy link
Copy Markdown
Contributor Author

kitchoi commented Apr 21, 2016

This fix requires more investigation as the implementation is not ideal (too many dummy renderer/window).
See #346, #347

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

offscreen rendering outputs black image unless new renderwindow created Default snapshot size is not respected

2 participants