nanover.websocket.client.selection_client module

class nanover.websocket.client.selection_client.SelectionClient(*args, **kwargs)

Bases: WebsocketClient

Mixin of methods for selection manipulation with a WebSocketClient.

clear_selections()

Remove all selections in the system

create_selection(name: str, particle_ids: Iterable[int] | None = None) RenderingSelection

Create a particle selection with the given name.

Parameters:
  • name – The user-friendly name of the selection.

  • particle_ids – The indices of the particles to include in the selection.

Returns:

The selection that was created.

get_selection(selection_id: str) RenderingSelection

Get the selection with the given selection id, throwing a KeyError if it is not present. For the root selection, use the root_selection property.

Parameters:

selection_id – The id of the selection

Returns:

The selection if it is present

remove_selection(selection: RenderingSelection)

Delete the given selection

property root_selection: RenderingSelection

Get the root selection, creating it if it does not exist yet.

Returns:

The selection representing the root selection of the system

property selections: Iterable[RenderingSelection]

Get all selections which are stored in the shared key store.

Returns:

An iterable of all the selections stored in the shared key store.

update_selection(selection: RenderingSelection)

Applies changes to the given selection to the shared key store.

Parameters:

selection – The selection to update.