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

Adds a method to shift the focal point of the camera #62

Merged
merged 2 commits into from
Oct 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions visualpic/visualization/vtk_visualizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def __init__(self, show_axes=True, show_cube_axes=True,
'um': 0.1,
'c/\\omega_p': 1}
self.forced_norm_factor = forced_norm_factor
self.camera_props = {'zoom': 1}
self.camera_props = {'zoom': 1, 'focus_shift': None}
self.volume_field_list = []
self.scatter_species_list = []
self.colorbar_list = []
Expand Down Expand Up @@ -469,7 +469,18 @@ def set_camera_zoom(self, zoom):

"""
self.camera_props['zoom'] = zoom
self.camera.Zoom(zoom)

def set_camera_shift(self, shift):
"""
Shift the focal point of the camera in three directions.

Parameters
----------

shift : list
The three components of the shift vector.
"""
self.camera_props['focus_shift'] = shift

def get_possible_timesteps(self):
"""
Expand Down Expand Up @@ -925,6 +936,10 @@ def _setup_cube_axes_and_bbox(self):
def _setup_camera(self):
self.renderer.ResetCamera()
self.camera.Zoom(self.camera_props['zoom'])
if self.camera_props['focus_shift'] is not None:
focus = np.array(self.camera.GetFocalPoint()) \
+ self.camera_props['focus_shift']
self.camera.SetFocalPoint(focus[0], focus[1], focus[2])

def _set_background_colors(self, color, color_2=None):
"""
Expand Down
Loading