Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parallel projection (2D rendering) #337

Closed
laserman781 opened this issue Jul 31, 2019 · 3 comments
Closed

parallel projection (2D rendering) #337

laserman781 opened this issue Jul 31, 2019 · 3 comments
Labels
feature-request Please add this cool feature!

Comments

@laserman781
Copy link

laserman781 commented Jul 31, 2019

Can I view the 2D plane as a parallel projection? I know this can be done in paraview so I assume it can also be done in pyvista.

@banesullivan banesullivan changed the title Grid planar view & parallel projection parallel projection (2D rendering) Jul 31, 2019
@banesullivan
Copy link
Member

This isn't currently implemented, but we can put it on the todo list!

@banesullivan banesullivan added the feature-request Please add this cool feature! label Jul 31, 2019
@banesullivan
Copy link
Member

@laserman781 - there is actually a pretty simple solution to this which I am about to implement. All you need to do is call .SetParallelProjection(True) on the active camera:

import pyvista as pv
from pyvista import examples
mesh = examples.download_st_helens().warp_by_scalar()

p = pv.Plotter(notebook=False)
p.add_mesh(mesh)
p.camera_position = 'xy'
p.camera.SetParallelProjection(True)
p.show()

I just implemented some helper methods to make this easier and also be able to toggle it with the BackgroundPlotter in e7ec9f0. The new methods are enable_parallel_projection() and disable_parallel_projection() which can be called from any plotter:

p = pv.Plotter(notebook=False)
p.add_mesh(mesh)
p.enable_parallel_projection()
p.show()

Or better yet, check out the menus in the BackgroundPlotter:

p = pv.BackgroundPlotter()
p.add_mesh(mesh)
p.show()

2019-08-02 10 07 38

@banesullivan
Copy link
Member

banesullivan commented Aug 2, 2019

Also, you might be interested in the enable_image_style() function on the plotters which makes the rendering truly 2D with parallel projection:

import pyvista as pv
from pyvista import examples

# This is a 2D image on the XY plane
mesh = examples.download_st_helens()

p = pv.Plotter(notebook=False)
p.add_mesh(mesh)
p.enable_parallel_projection()
p.enable_image_style()
p.view_xy()
p.show()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Please add this cool feature!
Projects
None yet
Development

No branches or pull requests

2 participants