Plugin module

This module simphony_mayavi.plugin provides a set of tools to visualize CUDS objects. The tools are also available as a visualisation plug-in to the simphony library.

Classes

EngineManagerStandalone Standalone non-GUI manager for visualising datasets from a Simphony Modeling Engine, running the engine and animating the results.
EngineManagerStandaloneUI Standalone GUI for visualising datasets from a modeling engine,

Functions

show Show the cuds objects using the default visualisation.
snapshot Save a snapshot of the cuds object using the default visualisation.
adapt2cuds Adapt a TVTK dataset to a CUDS container.
load Load the file data into a CUDS container.
add_engine_to_mayavi2 Add an ABCModelingEngine instance to the Mayavi2 plugin for
get_simphony_panel Return the SimPhoNy panel object sitting in Mayavi2
restore_scene Restore the current scene and modules settings according to the scene saved in a visualisation file.

Description

simphony_mayavi.plugin.show(cuds)[source]

Show the cuds objects using the default visualisation.

Parameters:cuds – A top level cuds object (e.g. a mesh). The method will detect the type of object and create the appropriate visualisation.
simphony_mayavi.plugin.snapshot(cuds, filename)[source]

Save a snapshot of the cuds object using the default visualisation.

Parameters:
  • cuds – A top level cuds object (e.g. a mesh). The method will detect the type of object and create the appropriate visualisation.
  • filename (string) – The filename to use for the output file.
simphony_mayavi.plugin.adapt2cuds(data_set, name='CUDS dataset', kind=None, rename_arrays=None)[source]

Adapt a TVTK dataset to a CUDS container.

Parameters:
  • data_set (tvtk.Dataset) – The dataset to import and wrap into CUDS dataset.
  • name (str) – The name of the CUDS dataset. Default is ‘CUDS dataset’.
  • kind (str) – The kind {‘mesh’, ‘lattice’, ‘particles’} of the container to return. Default is None, where the function will use some heuristics to infer the most appropriate type of CUDS container to return
  • rename_array (dict) –

    Dictionary mapping the array names used in the dataset object to their related CUBA keywords that will be used in the returned CUDS dataset. Default is None.

    Note

    When set a shallow copy of the input data_set is created and used by the related vtk -> cuds wrapper.

Raises:
  • ValueError – When kind is not a valid CUDS container type.
  • TypeError – When it is not possible to wrap the provided data_set.
simphony_mayavi.plugin.load(filename, name=None, kind=None, rename_arrays=None)[source]

Load the file data into a CUDS container.

Parameters:
  • filename (str) – The file name of the file to load.
  • name (str) – The name of the returned CUDS container. Default is ‘CUDS container’.
  • kind (str) – The kind {‘mesh’, ‘lattice’, ‘particles’} of the container to return. Default is None, where the function will use some heuristics to infer the most appropriate type of CUDS container to return (using adapt2cuds).
  • rename_array (dict) –

    Dictionary mapping the array names used in the dataset object to their related CUBA keywords that will be used in the returned CUDS container.

    Note

    Only CUBA keywords are supported for array names so use this option to provide a translation mapping to the CUBA keys.

simphony_mayavi.plugin.add_engine_to_mayavi2(name, engine)[source]

Add an ABCModelingEngine instance to the Mayavi2 plugin for SimPhoNy

Parameters:
  • name (str) – Name of the Simphony Modeling Engine
  • engine (ABCModelingEngine) – Simphony Modeling Engine
simphony_mayavi.plugin.get_simphony_panel()[source]

Return the SimPhoNy panel object sitting in Mayavi2

Returns:panel (EngineManagerMayavi2)
Raises:
RuntimeError
If the Mayavi2 application is not found or the SimPhoNy panel is not found in the application
simphony_mayavi.plugin.restore_scene(saved_visualisation, scene_index=0)[source]

Restore the current scene and modules settings according to the scene saved in a visualisation file.

Unmatched data sources are ignored. Say the current scene has only two data sources while the saved scene has three, setting for the third data source is ignored.

Parameters:
  • saved_visualisation (file or fileobj) –
  • scene_index (int) – index of the scene in the saved visualisation. default is 0 (first scene)
class simphony_mayavi.plugin.EngineManagerStandalone(engine, mayavi_engine=None)[source]

Bases: object

Standalone non-GUI manager for visualising datasets from a Simphony Modeling Engine, running the engine and animating the results.

Parameters:
  • engine (ABCModelingEngine) –
  • mayavi_engine (mayavi.api.Engine) – default to be mayavi.mlab.get_engine()
add_dataset_to_scene(*args, **kwargs)

Add a dataset from the engine to Mayavi

Parameters:name (str) – Name of the CUDS dataset to be loaded from the modeling engine
**kwargs :
Keyword arguments accepted by CUDSSource
animate(*args, **kwargs)

Run the modeling engine, and animate the scene. If there is no source in the scene or none of the sources belongs to the selected Engine engine, a RuntimeError is raised.

Parameters:
  • number_of_runs (int) – the number of times the engine.run() is called
  • delay (int) – delay between each run. If None, use previous setting or the Mayavi’s default (500)
  • ui (bool) – whether an UI is shown, default is False
  • update_all_scenes (bool) – whether all scenes are updated, default is False: i.e. only the current scene is updated
Raises:
RuntimeError
if nothing in scene(s) belongs to engine
class simphony_mayavi.plugin.EngineManagerStandaloneUI(engine_name='', engine=None, mayavi_engine=None)[source]

Bases: simphony_mayavi.plugins.engine_manager.EngineManager

Standalone GUI for visualising datasets from a modeling engine, running the engine and animating the results

Parameters:
  • engine_name (str) – Name of the Simphony Modeling Engine wrapper
  • engine (ABCModelingEngine) – Simphony Modeling Engine wrapper
  • mayavi_engine (mayavi.api.engine) – Default to be mayavi.mlab.get_engine()
add_engine(name, modeling_engine)

Add a Simphony Engine to the manager

Parameters:
  • name (str) – Name to be associated with the modeling engine
  • modeling_engine (ABCModelingEngine) – Simphony Engine Wrapper
remove_engine(name)

Remove a modeling engine from the manager. If modeling engine to be removed is currently selected, select the one of the remaining engines

Parameters:name (str) – Name associated with the engine to be removed