iblviewer.application
Classes
This class is the container and context for having an interactive VTK viewer with a controllable scene and objects. |
|
- class CameraModel(camera: vtkmodules.vtkRenderingCore.vtkCamera = None, autofocus: bool = True, target: Any = None, distance_factor: int = 3, orthographic_scale_factor: int = 1)[source]
Bases:
object
- camera: vtkmodules.vtkRenderingCore.vtkCamera = None
- autofocus: bool = True
- target: Any = None
- distance_factor: int = 3
- orthographic_scale_factor: int = 1
- class UIModel(visible: bool = True, embed: bool = False, embed_menu_x: int = 40, embed_menu_y: int = 50, embed_submenu_x: int = 200, embed_submenu_y: int = 50, embed_slider_width: int = 250, color: Any = '#000000', background_color: Any = '#ffffff', context: str = 'default', context_changed: bool = False, last_context: str = None, main_context: str = None, dark_mode: bool = False)[source]
Bases:
object
- DEFAULT = 'default'
- CAMERA = 'camera'
- SCENE = 'scene'
- OBJECT = 'object'
- DATA = 'data'
- EXPORT = 'export'
- visible: bool = True
- embed: bool = False
- embed_slider_width: int = 250
- color: Any = '#000000'
- background_color: Any = '#ffffff'
- contexts = {'camera': {}, 'data': {}, 'default': {}, 'export': {}, 'object': {}, 'scene': {}}
- font_path = 'C:\\Users\\Mayo\\anaconda3\\envs\\iblenv\\lib\\site-packages\\iblviewer_assets\\fonts'
- font = 'SourceSansPro-Regular'
- font_size = 15
- toggle_config = {'bc': ['#dddddd', '#ffffff'], 'bold': False, 'c': ['black', '#bbbbbb'], 'font': 'SourceSansPro-Regular', 'italic': False, 'size': 15}
- button_config = {'bc': ['#dddddd', '#dddddd'], 'bold': False, 'c': ['black', 'black'], 'font': 'SourceSansPro-Regular', 'italic': False, 'size': 15}
- slider_config = {'c': 'black', 'font': 'SourceSansPro-Regular'}
- context: str = 'default'
- context_changed: bool = False
- last_context: str = None
- main_context: str = None
- dark_mode: bool = False
- toggle_context(context=None)[source]
Toggles between current context and given one
- Parameters
context – A context string
- class ViewerModel(title: str = 'VTK Viewer', window_size: numpy.ndarray = array([1280, 720]), web_window_size: numpy.ndarray = array([960, 600]), web_ui: bool = False, offscreen: bool = False, ui: iblviewer.application.UIModel = <factory>, origin: numpy.ndarray = array([0., 0., 0.]), cameras: iblviewer.collection.Collection = <factory>, volumes: iblviewer.collection.Collection = <factory>, slicers: iblviewer.collection.Collection = <factory>, points: iblviewer.collection.Collection = <factory>, lines: iblviewer.collection.Collection = <factory>, surfaces: iblviewer.collection.Collection = <factory>, probes: iblviewer.collection.Collection = <factory>, luts: iblviewer.collection.Collection = <factory>, interactive_volume_subsampling: bool = False, runtime: datetime.datetime = datetime.datetime(2022, 11, 7, 11, 41, 42, 999993), timer_id: Any = None, playback_speed: int = 20, animation_playing: bool = False, animation_function: Any = None, time: float = 0.0, selection_changed: bool = False, selection_point_changed: bool = False, selection: Any = None, selection_type: Any = None, selection_point: Any = None, selection_relative_point: Any = None, selection_controller: Any = None, selection_value: float = None, selection_related_value: float = None, selection_related_name: str = None, selection_camera_position: Any = None, selection_marker_visible: bool = True, selection_text_visible: bool = True, selection_outline_visible: bool = True, selection_color_bar_visible: bool = True, probe_initial_point1: Any = None, probe_initial_point2: Any = None, outline_opacity: float = 1.0, outline_color: list = <factory>, outline_width: int = 3, pickings: list = <factory>, first_picked_position: numpy.ndarray = None, last_picked_position: numpy.ndarray = None, video_start_angle: float = 0.0, video_end_angle: float = 360.0, video_duration: float = 8.0, global_slicer: vtkmodules.vtkCommonDataModel.vtkPlaneCollection = None)[source]
Bases:
object
- POINT = 'point'
- LINE = 'line'
- SURFACE = 'surface'
- VOLUME = 'volume'
- UI = 'ui'
- OBJECTS_TYPE = {'line': 1, 'point': 0, 'surface': 2, 'ui': 4, 'volume': 3}
- X_UP = array([1., 0., 0.])
- Y_UP = array([0., 1., 0.])
- Z_UP = array([0., 0., 1.])
- X_DOWN = array([-1., 0., 0.])
- Y_DOWN = array([ 0., -1., 0.])
- Z_DOWN = array([ 0., 0., -1.])
- title: str = 'VTK Viewer'
- window_size: numpy.ndarray = array([1280, 720])
- web_window_size: numpy.ndarray = array([960, 600])
- web_ui: bool = False
- offscreen: bool = False
- origin: numpy.ndarray = array([0., 0., 0.])
- cameras: iblviewer.collection.Collection
- volumes: iblviewer.collection.Collection
- slicers: iblviewer.collection.Collection
- points: iblviewer.collection.Collection
- surfaces: iblviewer.collection.Collection
- probes: iblviewer.collection.Collection
- interactive_volume_subsampling: bool = False
- runtime: datetime.datetime = datetime.datetime(2022, 11, 7, 11, 41, 42, 999993)
- timer_id: Any = None
- playback_speed: int = 20
- animation_playing: bool = False
- animation_function: Any = None
- time: float = 0.0
- selection_changed: bool = False
- selection_point_changed: bool = False
- selection: Any = None
- selection_type: Any = None
- selection_point: Any = None
- selection_relative_point: Any = None
- selection_controller: Any = None
- selection_value: float = None
- selection_camera_position: Any = None
- selection_marker_visible: bool = True
- selection_text_visible: bool = True
- selection_outline_visible: bool = True
- selection_color_bar_visible: bool = True
- probe_initial_point1: Any = None
- probe_initial_point2: Any = None
- outline_opacity: float = 1.0
- outline_color: list
- outline_width: int = 3
- pickings: list
- first_picked_position: numpy.ndarray = None
- last_picked_position: numpy.ndarray = None
- video_start_angle: float = 0.0
- video_end_angle: float = 360.0
- video_duration: float = 8.0
- global_slicer: vtkmodules.vtkCommonDataModel.vtkPlaneCollection = None
- get_actor_type(actor)[source]
Get the type of the given actor Vedo does a similar thing for some of its events: “isPoints”: isinstance(actor, vedo.Points), “isMesh”: isinstance(actor, vedo.Mesh), “isAssembly”: isinstance(actor, vedo.Assembly), “isVolume”: isinstance(actor, vedo.Volume), “isPicture”: isinstance(actor, vedo.Picture), “isActor2D”: isinstance(actor, vtk.vtkActor2D),
- Parameters
actor – vtkActor
- Returns
String
- class Viewer[source]
Bases:
object
This class is the container and context for having an interactive VTK viewer with a controllable scene and objects.
- initialize(offscreen=False, jupyter=False, embed_ui=False, embed_font_size=15, plot=None, plot_window_id=0, num_windows=1, dark_mode=False, silent=False)[source]
Initialize the controller, main entry point to the viewer
- Parameters
context – Context of the visualization
embed_ui – Whether the UI is embed within the VTK window
embed_font_size – Embed font size. Defaults to 16 points. You might need larger values in case you have a small screen with high dpi (but VTK methods fail to detect that).
jupyter – Whether we’re running from a jupyter notebook or not
offscreen – Whether the rendering is done offscreen (headless) or not
plot – A vedo Plotter instance. You can either create it by yourself before hand, in case you want to have multiple windows with other stats or let the controller create a new one
plot_window_id – Sub-window id where the 3D visualization will be displayed
num_windows – Number of subwindows, in case you want to display your own stuff later
render – Whether rendering occurs at the end of the initialization or not. Defaults to False
dark_mode – Whether the viewer is in dark mode
auto_select_first_object – Auto select the first object displayed
silent – Whether printing to console is disabled or not
- handle_key_press(iren, event)[source]
Handle key press events
- Parameters
iren – vtk iren
event – vtk event
- set_renderer()[source]
Set VTK renderer, attempts to use OSPRay, if available OSPRay is not supported (2021) by default and there is no pip wheel for it with vtk, or paraview or any vtk-based tool. So you can only rely on OSPRay if you compile it alongside VTK.
- register_object(vtk_object, name=None, selectable=True)[source]
Register an object as selectable by the user in the UI
- Parameters
vtk_object – VTK object
name – Name or given id. IF None, the name of the
object is used
- get_unique_object_name(name, spacer='_')[source]
Get a unique key/name for selectable objects with similar names
- Parameters
name – Name (for instance ‘Points’)
spacer – Spacer char
- Returns
New name, for instance ‘Points_4’
- unregister_object(name)[source]
Unregister an object from the selectable objects list
- Parameters
name – Object name or given id or int or the object itself
- update_selection_slider(max_value=None)[source]
Update the selection slider max value
- Parameters
max_value – Max value. If None, the maximum value
is the length of the self.objects
- register_controller(controller, vtk_objects)[source]
Register/map VTK objects to a view
- Parameters
controller – A controller instance (like VolumeController)
vtk_objects – All objects directly related to this view
- get_window()[source]
Get the plot window object. This is useful for displaying this window in Jupyter notebooks for instance :return: iren window object
- render(save_to_file=None, width=None, height=None, scale=1)[source]
Render the current state of the viewer, optionally to a file. Supported formats are jpg, png, pdf, svg, eps
- Parameters
save_to_file – File path
width – Width of the rendered image
height – Height of the rendered image
scale – Rendering scale factor. Defaults to 1
- show(interactive=True, actors=None, at=0, **kwargs)[source]
Render the plot and let the user interact with it
- Parameters
interactive – Whether we render and make the window interactive
actors – List of actors to show. Use this parameter only if you know what you’re doing.
at – Which VTK window to use. Defaults to 0
- add_callback(event_name, func, priority=0.0)[source]
Add an event listener (aka callback method)
- Parameters
event_name – A VTK event name
func – Listener function
priority – Priority in event queue
- Returns
Callback id
- remove_callback(callback_id)[source]
Add an event listener (aka callback method)
- Parameters
callback_id_or_event_name – A VTK event name
- handle_timer(iren, event, **kwargs)[source]
Handle vtk timer event
- Parameters
iren – Render window
event – TimerEvent
- handle_left_mouse_press(event)[source]
Handle left mouse down event. The event is triggered for any “pickable” object
- Parameters
mesh – Selected object
- clear_depth_picking(return_element=None)[source]
Clear depth picking, making all objects put in depth queue pickable again
- Parameters
return_element – An element to be returned by its index of insertion
- Returns
object and picked 3d coordinates (only if return_element is valid)
- get_actor_type(actor)[source]
Get what type is the given actor
- Parameters
actor – vtkActor
- Returns
String
- handle_left_mouse_release(event)[source]
Handle left mouse up event.
- Parameters
event – vtkEvent
- Returns
Int value. 0 for invalid click, 1 for actor click,
2 for double click on actor
- handle_object_click(actor, state=1, event=None)[source]
Handle valid object selection
- Parameters
actor – Selected actor
state – Number of mouse clicks
event – Event given by vedo
- sub_selection_changed()[source]
Function called when for the same object, a new data point is selected
- get_selectable_key_by_id(value=0)[source]
Get an object by the id of the key (not by the key/name itself) This is useful for sliders :return: String
- select(target=None, allow_none=False)[source]
Select an object, either by its name (or subname) or by reference to the vtk object.
- Parameters
target – Either the vtk actor or its name or its index (an int from object.keys())
allow_none – Whether an invalid target is accepted as clicking on nothing (to cancel the current selection)
- get_selection_info()[source]
Get information about the current selection :return: Preformatted multiline text and a dictionary of extra data
- draw_outline(auto_hide_if_no_selection=True)[source]
Draw the bounding box of the current selection.
- Parameters
auto_hide_if_no_selection – Whether we hide the outline when there is no selection
- add_segments(points, end_points=None, line_width=2, values=None, color_map='Accent', name='Segments', use_origin=True, add_to_scene=True, relative_end_points=False, spherical_angles=None, radians=True)[source]
Add a set of segments (lines made of two points). The difference with add_lines() is that you have more options like giving spherical angles and setting relative end points.
- Parameters
points – 3D numpy array of points of length n
end_points – 3D numpy array of points of length n
line_width – Line width, defaults to 2px
values – 1D list of length n, for one scalar value per line
color_map – A color map, it can be a color map built by IBLViewer or a color map name (see vedo documentation), or a list of values, etc.
name – Name to give to the object
use_origin – Whether the current origin (not necessarily absolute 0) is used as offset
add_to_scene – Whether the new lines are added to scene/plot and rendered
relative_end_points – Whether the given end point is relative to the start point. False by default, except is spherical coordinates are given
spherical_angles – 3D numpy array of spherical angle data of length n In case end_points is None, this replaces end_points by finding the relative coordinate to each start point with the given radius/depth, theta and phi
radians – Whether the given spherical angle data is in radians or in degrees
- Returns
Lines
- add_lines(points, line_width=2, values=None, color_map='Accent', name='Lines', use_origin=True, add_to_scene=True)[source]
Create a set of lines with given point sets
- Parameters
points – List or 2D array of 3D coordinates
line_width – Line width, defaults to 2px
values – 1D list of length n, for one scalar value per line
color_map – A color map, it can be a color map built by IBLViewer or a color map name (see vedo documentation), or a list of values, etc.
name – Name to give to the object
use_origin – Whether the current origin (not necessarily absolute 0) is used as offset
add_to_scene – Whether the new lines are added to scene/plot and rendered
- Returns
objects.Lines
- add_spheres(positions, radius=10, values=None, color_map='Accent', name='Points', use_origin=True, add_to_scene=True, **kwargs)[source]
Add new spheres. This is a shortcut for add_points(screen_space=False)
- Parameters
positions – 3D array of coordinates
radius – List same length as positions of radii. The default size is 5um, or 5 pixels in case as_spheres is False.
values – 1D array of values, one per neuron or a time series of such 1D arrays (numpy format)
color_map – A color map, it can be a color map built by IBLViewer or a color map name (see vedo documentation), or a list of values, etc.
name – All point neurons are grouped into one object, you can give it a custom name
use_origin – Whether the current origin (not necessarily absolute 0) is used as offset
add_to_scene – Whether the new lines are added to scene/plot and rendered
- Returns
objects.Points
- add_points(positions, radius=10, values=None, color_map='Accent', name='Points', screen_space=True, use_origin=True, add_to_scene=True, **kwargs)[source]
Add new points, either as screen-space dots or as 3D spheres (see screen_space param)
- Parameters
positions – 3D array of coordinates
radius – List same length as positions of radii. The default size is 5um, or 5 pixels in case as_spheres is False.
values – 1D array of values, one per neuron or a time series of such 1D arrays (numpy format)
color_map – A color map, it can be a color map built by IBLViewer or a color map name (see vedo documentation), or a list of values, etc.
name – All point neurons are grouped into one object, you can give it a custom name
screen_space – Type of point, Defaults to True. If True then the points always occupy the same amount of pixels defined by the radius, this is the fastest method to display large amount of points. If False, then points are 3D spheres and you see them larger when you zoom closer to them with the camera.
use_origin – Whether the current origin (not necessarily absolute 0) is used as offset
add_to_scene – Whether the new lines are added to scene/plot and rendered
- Returns
objects.Points
- add_mesh(file_path, mesh_name=None, use_origin=True, add_to_scene=True)[source]
Add a surface mesh to the scene
- Parameters
file_path – Mesh file path (any kind of file supported by vedo)
mesh_name – Name of the mesh. If None, the file name will be used.
use_origin – Whether the origin is used in positioning the mesh
add_to_scene – Whether the new lines are added to scene/plot and rendered
- Returns
Mesh
- add_surface_mesh(file_path, mesh_name=None, use_origin=True, add_to_scene=True)[source]
Add a surface mesh to the scene
- Parameters
file_path – Mesh file path (any kind of file supported by vedo)
mesh_name – Name of the mesh. If None, the file name will be used.
use_origin – Whether the origin is used in positioning the mesh
add_to_scene – Whether the new lines are added to scene/plot and rendered
- Returns
Mesh
- add_volume(data=None, resolution=None, file_path=None, color_map='viridis', alpha_map=None, select=False, add_to_scene=True, transpose=None)[source]
Add a volume to the viewer with box clipping and slicing enabled by default
- Parameters
data – Volume image data or a file_path
resolution – Resoluton of the volume
file_path – File path of the volume. If you don’t provide an image volume data, then the file_path will be used to load the volume data
color_map – Color map for the volume
alpha_map – Alpha map for the volume. If None, it will assume that 0 values are transparent and maximum values are opaque
select – Whether the volume is selected
add_to_scene – Whether the volume is added to scene
transpose – Transposition parameter. If None. nothing happens. If True, then the default IBL transposition is applied. You can provide your own, that is, a list of 3 elements to reorder the volume as desired.
- Returns
VolumeController
- remove_object(target=None, unregister=False)[source]
Remove an object from the plot
- Parameters
target – Target object
unregister – Whether the object is also unregistered, which means that it’s not in the list of objects anymore and cannot be recovered using select(object_name)
Toggle menu and activate only one button in the set
Set the context from the main menu buttons
- Parameters
button_name – Which button is clicked
context – What context to activate
- set_selection_marker(marker_type='cross', size=500, cross_thickness=3)[source]
Set the selection marker type. Accepted values currently are ‘cross’ or ‘sphere’
- Parameters
marker_type – Marker type
- initialize_vtk_ui(x=40, y=50, sx=None, sy=None, sw=None)[source]
Initialize a per-context VTK UI.
- Parameters
x – Base screen-space x coordinate
y – Base screen-space y coordinate (starts from the bottom in VTK)
- add_camera_embed_ui(x, y, sw, nc=150)[source]
Add camera-context UI
- Parameters
x – Base X position
y – Base Y position (0 is at the bottom of the screen)
sw – Slider width
- add_scene_embed_ui(x, y, sw)[source]
Add scene-context UI
- Parameters
x – Base X position
y – Base Y position (0 is at the bottom of the screen)
sw – Slider width
- add_object_embed_ui(x, y, sw)[source]
Add object-context UI
- Parameters
x – Base X position
y – Base Y position (0 is at the bottom of the screen)
sw – Slider width
- add_data_embed_ui(x, y, sw)[source]
Add data-context UI
- Parameters
x – Base X position
y – Base Y position (0 is at the bottom of the screen)
sw – Slider width
- add_export_embed_ui(x, y, sw)[source]
Add export-context UI
- Parameters
x – Base X position
y – Base Y position (0 is at the bottom of the screen)
sw – Slider width
- update_scene_ui(context_elements)[source]
Update the scene-related UI
- Parameters
context_elements – Current UI context elements
- is_volume(target=None)[source]
Get whether the target object is a volume
- Parameters
target – vtkActor. If None, the current selected object is used.
- Returns
Boolean
- get_selection_opacity()[source]
Get the opacity of the current selected object :return: Float or None
- get_selection_slices_opacity()[source]
Get the opacity of the current volume slices :return: Float or None
- update_object_ui(context_elements)[source]
Update the object mode UI
- Parameters
context_elements – Current UI context elements
- update_data_ui(context_elements)[source]
Update data UI
- Parameters
context_elements – Current UI context elements
- get_time_series_info(target=None)[source]
Get the number of time series and id of the current one for a target. If None, then the current selection is used
- Parameters
target – a vtk object
- Returns
Int, Int
- set_color_bar_visibility(on=None)[source]
Show or hide the color bar
- Parameters
on – Visibility boolean
- set_element_visibility(element, visible=True)[source]
Set a UI element’s visibility
- Parameters
element – a vtk2DActor or something like that (changes for sliders, texts, etc.)
visible – Visible or not
- update_element_color(element)[source]
Set a UI element’s color
- Parameters
element – a vtk2DActor or something like that (changes for sliders, texts, etc.)
- set_ui_visibility(visible, exceptions=None, ui_button_visible=True)[source]
Set the UI visibility
- Parameters
visible – Whether the UI is visible or not
exceptions – Dictionary of objects that have to be the inverse of the given state
ui_button_visible – Whether the UI button is still visible or not, so that the user can restore the UI by clicking on it. This is not necessary in case of Jupyter NB
- add_text(name, text, pos, color=None, justify='top-left', context=None, **kwargs)[source]
Add a 2D text on scene
- Parameters
name – Name of the object
text – Text string
pos – Position on screen
color – Color of the font
justify – Type of justification
context – Context to register this object to
- Returns
Text2D
- add_button(name, event_handler, pos, label=None, toggle=False, state=0, context=None)[source]
Add a left-aligned button
- Parameters
name – Button name
event_handler – Event handler function
pos – Screen-space position
label – Button text label
toggle – Whether it’s a toggle button or not
- Returns
Button
- get_slider_bounds(x, y, length, horizontal=True)[source]
Get slider coordinates, releative to lower left corner of the window
- Parameters
x – X position
y – Y position
length – Length of the slider
horizontal – Whether the length is horizontal or vertical
- Returns
np 2d array with min and max coordinates
- add_slider(name, event_handler, min_value, max_value, value, pos, title=None, oid=None, precision=0, context=None, **kwargs)[source]
Add a slider to the UI
- Parameters
event_handler – Event handler function called when the slider is updated
min_value – Min slider value
max_value – Max slider value
value – Default value
size – Font size
pos – Position in the UI as a tuple or list, see get_slider_bounds for details
kwargs – Dictionary of kwargs, see vedo.addons.addSlider2D() for details
- Returns
2D Slider
- slider_value(element_id, value=None, widget=None)[source]
Abstract method to get or set a value on a VTK slider element
- Parameters
element_id – Element id (found in self.model.ui.get_elements().keys())
value – Value of Z slice, defaults to 0.0
widget – Widget instance (given by the event caller)
- Returns
Float value
- clip_to_bounds(bounds_obj, target=None)[source]
Clip a target object with the bounding box of another object
- Parameters
bounds_obj – a vtkActor
target – Target object. If None, the current selection is used
- isosurface(value=None, volume_controller=None, split_meshes=False, remove_existing=True)[source]
Generate mesh(es) for a given value in a volume
- Parameters
value – Value/label for which we want to generate an isosurface mesh
volume_controller – Volume controller. If None, the current one is used.
If the current one is None, then nothing happens. :param split_meshes: Whether manifold meshes are split if there are multiple ones :param remove_existing: Whether existing meshes are removed from the plot :return: List of meshes computed
- is_probe(probe=None)[source]
Check if an object is (the result of) a probe
- Parameters
probe – Probe object
- Returns
Boolean
- update_current_probe(widget=None, event=None, point1=None, point2=None)[source]
Update the current probe
- Parameters
widget – vtkLineWidget
event – vtkEvent
point1 – Point 1, this will override the widget’s point 1
point2 – Point 2, this will override the widget’s point 2
- update_px_slicer(widget=None, event=None, value=0.0)[source]
Event handler for Slicer on +X axis
- Parameters
widget – Widget instance (given by the event caller)
event – Event (given by the event caller)
value – Value of X slice, defaults to 0.0
- update_nx_slicer(widget=None, event=None, value=0.0)[source]
Event handler for Slicer on -X axis
- Parameters
widget – Widget instance (given by the event caller)
event – Event (given by the event caller)
value – Value of X slice, defaults to 0.0
- update_py_slicer(widget=None, event=None, value=0.0)[source]
Event handler for Slicer on +Y axis
- Parameters
widget – Widget instance (given by the event caller)
event – Event (given by the event caller)
value – Value of Y slice, defaults to 0.0
- update_ny_slicer(widget=None, event=None, value=0.0)[source]
Event handler for Slicer on -Y axis
- Parameters
widget – Widget instance (given by the event caller)
event – Event (given by the event caller)
value – Value of Y slice, defaults to 0.0
- update_pz_slicer(widget=None, event=None, value=0.0)[source]
Event handler for Slicer on +Z axis
- Parameters
widget – Widget instance (given by the event caller)
event – Event (given by the event caller)
value – Value of Z slice, defaults to 0.0
- update_nz_slicer(widget=None, event=None, value=0.0)[source]
Event handler for Slicer on -Z axis
- Parameters
widget – Widget instance (given by the event caller)
event – Event (given by the event caller)
value – Value of Z slice, defaults to 0.0
- toggle_slices(event=None)[source]
Toggle slicers visibility
- Parameters
widget – Widget instance (given by the event caller)
event – Event (given by the event caller)
- toggle_global_slicer(event=None)[source]
Toggle global slicer mode
- Parameters
widget – Widget instance (given by the event caller)
event – Event (given by the event caller)
- set_camera(quat, camera_distance=10000)[source]
TODO: make it possible to store and assign a camera transformation matrix
- update_camera(normal=None, view_up=None, scale_factor=1.5, min_distance=10000)[source]
Update the camera frustrum
- Parameters
normal – View normal
view_up – Up axis normal
scale_factor – Scale factor to make the camera closer to the target
Smaller values than 1 make the target closer to the camera.
- move_camera_pivot(point=None)[source]
Focus the camera on the current selection point
- Parameters
point – Point to focus on
- toggle_outline(event=None)[source]
Toggle outline visibility
- Parameters
event – Event (given by the event caller)
- set_info_text_visibility(on=True)[source]
Set info text visibility
- Parameters
on – Visibility boolean
- set_info_visibility(visible=True, actors=None, update_color_bar=True)[source]
Set the visibility of info data
- Parameters
visible – Whether info data is visible or not
actors – Any desired actors to be made visible/invisible
update_color_bar – Whether this method also affects the color bar
- select_object_by_id(widget=None, event=None, value=1.0)[source]
Select object by id (order in which objects were registered in this app)
- Parameters
widget – Widget instance (given by the event caller)
event – Event (given by the event caller)
value – Object id
- toggle_pickable(widget=None, event=None, value=1.0)[source]
Toggle the clickable state of an object
- Parameters
widget – Widget instance (given by the event caller)
event – Event (given by the event caller)
value – 0 for disabled, 1 for enabled
- update_opacity(widget=None, event=None, value=1.0)[source]
Update the alpha unit of the current volume, making it more or less transparent
- Parameters
widget – Widget instance (given by the event caller)
event – Event (given by the event caller)
value – alpha unit value. If none given by the event, the value defaults to 1.0
- update_slices_opacity(widget=None, event=None, value=1.0)[source]
Update the opacity of the current volume slices
- Parameters
widget – Widget instance (given by the event caller)
event – Event (given by the event caller)
value – alpha unit value. If none given by the event, the value defaults to 1.0
- play_time_series(widget=None, event=None)[source]
Play/pause time series
- Parameters
widget – Widget instance (given by the event caller)
event – Event (given by the event caller)
- previous_time_series(offset=1, loop=True)[source]
Previous time series
- Parameters
offset – Offset integer. If negative, then it’s like using next_time_series()
loop – Whether next() goes to 0 when it reached the end of the time series or not
- Returns
Returns whether the next time series is valid (within range of the time series)
- next_time_series(offset=1, loop=True)[source]
Next time series
- Parameters
offset – Offset integer, can be negative to go backwards
loop – Whether next() goes to 0 when it reached the end of the time series or not
- Returns
Returns whether the next time series is valid (within range of the time series)
- update_time_series(widget=None, event=None, value=None)[source]
Update the time series
- Parameters
widget – The slider widget (optional)
event – The slider event (optional)
value – The value to set. If None, then the slider value is used, if it’s given as widget param
- set_time_series(value, force_update=False)[source]
Set the time series for the current selected object
- Parameters
value – The given time step
force_update – Whether an update is forced even if the given value is the same as the existing time step
- assign_scalars(scalar_map=None, scalar_range=None, color_map='viridis', make_active=True)[source]
Assign a new data set and a color map to a target min_value=None, max_value=None
- handle_lut_update()[source]
Update the view with the given or current transfer function
- Parameters
lut_model – A LUTModel (whose table property is a vtkLookupTable) to set on the current volume. If None, the current one will be used.
- animation_callback(progress)[source]
You may override this function according to your needs
- Parameters
progress – ratio of total animation (from 0.0 to 1.0)
- update_video_duration(widget=None, event=None, value=None)[source]
Update the video duration
- Parameters
widget – The slider widget (optional)
event – The slider event (optional)
value – The value to set. If None, then the slider value is used, if it’s given as widget param
- update_video_start_angle(widget=None, event=None, value=None)[source]
Update the video start angle
- Parameters
widget – The slider widget (optional)
event – The slider event (optional)
value – The value to set. If None, then the slider value
is used, if it’s given as widget param
- update_video_end_angle(widget=None, event=None, value=None)[source]
Update the video end angle
- Parameters
widget – The slider widget (optional)
event – The slider event (optional)
value – The value to set. If None, then the slider value is used, if it’s given as widget param
- volumetric_lod(on=False)[source]
Enable or disable volumetric LOD subsampling. Turn this on when you want faster interactive visualizations
- Parameters
on – Whether volumetric subsampling is activated
- export_image(file_name='iblviewer.png', width=None, height=None, scale=2)[source]
Export the current image to a file
- Parameters
file_name – File name with extension. PNG by default
width – Width in pixels. If None, the width of the window is used.
height – Height in pixels. If None, the height of the window is used.
scale – Scale factor to make the image larger. Defaults to 2.
- export_turntable_video(file_name='iblviewer.mp4', start_angle=0, end_angle=360, duration=None, fps=25)[source]
Export a sagittal turntable video of the viewer.
- Parameters
file_name – File name
start_angle – Start angle
end_angle – End angle. If it’s the same value as start angle, then 360 is added
duration – Duration of the video
fps – Frames per second, defaults to 25