sfepy.postprocess.viewer module

class sfepy.postprocess.viewer.ClosingHandler[source]
object_button_quit_changed(self, info)[source]
class sfepy.postprocess.viewer.ReloadSource[source]
class sfepy.postprocess.viewer.SetStep[source]
init_seq_selection(self, name, new)[source]
is_adjust = False
step = None
time = None
class sfepy.postprocess.viewer.Viewer(filename, watch=False, ffmpeg_options=None, output_dir='.', offscreen=False)[source]

Class to automate visualization of various data using Mayavi.

It can use any format that mlab.pipeline.open() handles, e.g. a VTK format. After opening a data file, all data (point, cell, scalars, vectors, tensors) are plotted in a grid layout.

Parameters:

watchbool

If True, watch the file for changes and update the mayavi pipeline automatically.

ffmpeg_optionsstr

The ffmpeg animation encoding options.

output_dirstr

The output directory, where view snapshots will be saved.

Examples:

>>> view = Viewer('file.vtk')
>>> view() # view with default parameters
>>> view(layout='col') # use column layout
build_mlab_pipeline(self, file_source=None, is_3d=False, layout='rowcol', scalar_mode='iso_surface', vector_mode='arrows_norm', rel_scaling=None, clamping=False, ranges=None, is_scalar_bar=False, is_wireframe=False, opacity=None, subdomains_args=None, rel_text_width=None, filter_names=None, group_names=None, only_names=None, domain_specific=None, **kwargs)[source]

Sets self.source, self.is_3d_data

call_empty(self, *args, **kwargs)[source]
call_mlab(self, scene=None, show=True, is_3d=False, view=None, roll=None, parallel_projection=False, fgcolor=(0.0, 0.0, 0.0), bgcolor=(1.0, 1.0, 1.0), colormap='blue-red', layout='rowcol', scalar_mode='iso_surface', vector_mode='arrows_norm', rel_scaling=None, clamping=False, ranges=None, is_scalar_bar=False, is_wireframe=False, opacity=None, subdomains_args=None, rel_text_width=None, fig_filename='view.png', resolution=None, filter_names=None, only_names=None, group_names=None, step=None, time=None, anti_aliasing=None, domain_specific=None)[source]

By default, all data (point, cell, scalars, vectors, tensors) are plotted in a grid layout, except data named ‘node_groups’, ‘mat_id’ which are usually not interesting.

Parameters
showbool

Call mlab.show().

is_3dbool

If True, use scalar cut planes instead of surface for certain datasets. Also sets 3D view mode.

viewtuple

Azimuth, elevation angles, distance and focal point as in mlab.view().

rollfloat

Roll angle tuple as in mlab.roll().

parallel_projection: bool

If True, use parallel projection.

fgcolortuple of floats (R, G, B)

The foreground color, that is the color of all text annotation labels (axes, orientation axes, scalar bar labels).

bgcolortuple of floats (R, G, B)

The background color.

colormapstr

The colormap name.

layoutstr

Grid layout for placing the datasets. Possible values are: ‘row’, ‘col’, ‘rowcol’, ‘colrow’.

scalar_modestr

Mode for plotting scalars and tensor magnitudes, one of ‘cut_plane’, ‘iso_surface’, ‘both’.

vector_modestr

Mode for plotting vectors, one of ‘arrows’, ‘norm’, ‘arrows_norm’, ‘warp_norm’.

rel_scalingfloat

Relative scaling of glyphs for vector datasets.

clampingbool

Clamping for vector datasets.

rangesdict

List of data ranges in the form {name : (min, max), …}.

is_scalar_barbool

If True, show a scalar bar for each data.

is_wireframebool

If True, show a wireframe of mesh surface bar for each data.

opacityfloat

Global surface and wireframe opacity setting in [0.0, 1.0],

subdomains_argstuple

Tuple of (mat_id_name, threshold_limits, single_color), see add_subdomains_surface(), or None.

rel_text_widthfloat

Relative text width.

fig_filenamestr

File name for saving the resulting scene figure.

resolutiontuple

Scene and figure resolution. If None, it is set automatically according to the layout.

filter_nameslist of strings

Omit the listed datasets. If None, it is initialized to [‘node_groups’, ‘mat_id’]. Pass [] if you need no filtering.

only_nameslist of strings

Draw only the listed datasets. If None, it is initialized all names besides those in filter_names.

group_nameslist of tuples

List of data names in the form [(name1, …, nameN), (…)]. Plots of data named in each group are superimposed. Repetitions of names are possible.

stepint, optional

If not None, the time step to display. The closest higher step is used if the desired one is not available. Has precedence over time.

timefloat, optional

If not None, the time of the time step to display. The closest higher time is used if the desired one is not available.

anti_aliasingint

Value of anti-aliasing.

domain_specificdict

Domain-specific drawing functions and configurations.

encode_animation(self, filename, format, ffmpeg_options=None)[source]
get_animation_info(self, filename, add_output_dir=True, last_step=None)[source]
get_data_names(self, source=None, detailed=False)[source]
get_size_hint(self, layout, resolution=None)[source]
render_scene(self, scene, options)[source]

Render the scene, preferably after it has been activated.

reset_view(self)[source]
save_animation(self, filename, steps=None, times=None)[source]

Animate the current scene view for the selected time steps or times and save a snapshot of each view.

save_image(self, filename)[source]

Save a snapshot of the current scene.

set_source_filename(self, filename)[source]
show_scalar_bars(self, scalar_bars)[source]
class sfepy.postprocess.viewer.ViewerGUI(fgcolor=(0.0, 0.0, 0.0), bgcolor=(1.0, 1.0, 1.0), **traits)[source]
sfepy.postprocess.viewer.add_glyphs(obj, position, bbox, rel_scaling=None, scale_factor='auto', clamping=False, color=None)[source]
sfepy.postprocess.viewer.add_iso_surface(obj, position, contours=10, opacity=1.0)[source]
sfepy.postprocess.viewer.add_scalar_cut_plane(obj, position, normal, opacity=1.0)[source]
sfepy.postprocess.viewer.add_subdomains_surface(obj, position, mat_id_name='mat_id', threshold_limits=(None, None), **kwargs)[source]
sfepy.postprocess.viewer.add_surf(obj, position, opacity=1.0)[source]
sfepy.postprocess.viewer.add_text(obj, position, text, width=None, color=(0, 0, 0))[source]
sfepy.postprocess.viewer.add_vector_cut_plane(obj, position, normal, bbox, rel_scaling=None, scale_factor='auto', clamping=False, opacity=1.0)[source]
sfepy.postprocess.viewer.get_glyphs_scale_factor(rng, rel_scaling, bbox)[source]
sfepy.postprocess.viewer.get_opacities(opacity)[source]

Provide defaults for all supported opacity settings.

sfepy.postprocess.viewer.get_position_counts(n_data, layout)[source]
sfepy.postprocess.viewer.make_animation(filename, view, roll, anim_format, options, steps=None, times=None, reuse_viewer=None)[source]
sfepy.postprocess.viewer.set_colormap(source, colormap_name)[source]

Set the given colormap to all look-up tables depending on the given source.