bluemira.display.displayer

api for plotting using CAD backend

Classes

ViewerBackend

CAD viewer backends.

DisplayCADOptions

The options that are available for displaying objects in 3D

BaseDisplayer

Displayer abstract class

DisplayableCAD

Mixin class to make a class displayable by imparting a show_cad method and options.

ComponentDisplayer

CAD displayer for Components

Functions

get_default_options([backend])

_validate_display_inputs(parts, options, labels)

Validate the lists of parts and options, applying some default options.

show_cad([parts, options, labels, backend])

The CAD display API.

_get_displayer_class(part)

Module Contents

class bluemira.display.displayer.ViewerBackend(*args, **kwds)

Bases: enum.Enum

Inheritance diagram of bluemira.display.displayer.ViewerBackend

CAD viewer backends.

FREECAD = 'bluemira.codes._freecadapi'
POLYSCOPE = 'bluemira.codes._polyscope'
get_module()

Load viewer module

Returns:

The loaded module.

Raises:
  • ModuleNotFoundError – Cannot find backend

  • FileNotFoundError – Cannot find backend

bluemira.display.displayer.get_default_options(backend=ViewerBackend.FREECAD)
Returns:

The default display options for the specified backend.

class bluemira.display.displayer.DisplayCADOptions(backend=ViewerBackend.FREECAD, **kwargs)

Bases: bluemira.display.tools.Options

Inheritance diagram of bluemira.display.displayer.DisplayCADOptions

The options that are available for displaying objects in 3D

Parameters:

backend – the backend viewer being used

__slots__ = ()
_options
bluemira.display.displayer._validate_display_inputs(parts, options, labels)

Validate the lists of parts and options, applying some default options.

Returns:

A tuple containing the list of parts, list of options and list of labels.

Raises:

DisplayError – Number of options not equal to number of parts

bluemira.display.displayer.show_cad(parts: bluemira.geometry.base.BluemiraGeo | list[bluemira.geometry.base.BluemiraGeo] | None = None, options: DisplayCADOptions | list[DisplayCADOptions] | list[dict[str, float | str | None]] | None = None, labels: str | list[str] | None = None, backend: str | ViewerBackend = ViewerBackend.FREECAD, **kwargs)

The CAD display API.

Parameters:
class bluemira.display.displayer.BaseDisplayer(options: DisplayCADOptions | None = None, **kwargs)

Bases: abc.ABC

Inheritance diagram of bluemira.display.displayer.BaseDisplayer

Displayer abstract class

Parameters:

options (DisplayCADOptions | None)

_CLASS_DISPLAY_OPTIONS: ClassVar
options
abstract show_cad(objs, **kwargs)

Display a CAD object

bluemira.display.displayer._get_displayer_class(part)
Returns:

the displayer class for an object

Raises:

DisplayError – Cannot display specific type

class bluemira.display.displayer.DisplayableCAD

Mixin class to make a class displayable by imparting a show_cad method and options.

_display_cad_options: DisplayCADOptions
property display_cad_options: DisplayCADOptions

returns: the options that will be used to display the object.

Return type:

DisplayCADOptions

property _displayer: BaseDisplayer

returns: the options that will be used to display the object.

Return type:

BaseDisplayer

show_cad(**kwargs) None

Default method to call display the object by calling into the Displayer’s display method.

Returns:

The axes that the plot has been displayed onto.

Return type:

axes

class bluemira.display.displayer.ComponentDisplayer(options: DisplayCADOptions | None = None, **kwargs)

Bases: BaseDisplayer

Inheritance diagram of bluemira.display.displayer.ComponentDisplayer

CAD displayer for Components

Parameters:

options (DisplayCADOptions | None)

static show_cad(comps, **kwargs)

Display the CAD of a component or iterable of components

Parameters:

comp (Union[Iterable[Component], Component]) – Component, or iterable of Components, to be displayed