nanover.app.selection module
- class nanover.app.selection.RenderingSelection(id: str, name: str = 'Unnamed Selection')
Bases:
objectA local representation of a selection in a NanoverIMD simulation.
Not intended to be created directly, but rather via the
NanoverImdClient, which handles synchronising the state of the selections with the server.Changes to this selection are only applied when a call to flush_changes() is made, or modifications are made within a modify(): context manager.
- add_particles(particle_ids: Iterable[int])
Add more particles to this selection, appending the previous selection.
- Parameters:
particle_ids
- clear_particles()
Clear all particles in this selection.
- flush_changes()
Flushes all changes by notifying any listeners that this selection has changed.
- classmethod from_dictionary(dict: Dict) RenderingSelection
Decode a dictionary into a selection.
- Parameters:
dict – A dictionary of selection data.
- Returns:
A selection decoded from the given dictionary
- property hide: bool
Should this renderer be hidden
- property interaction_method: str
The interaction method for NanoVer iMD
- modify()
Gives a context in which the selection can have multiple modifications made to it, and which calls flush_changes() when the context is left
- read_from_dictionary(dict: Dict)
- read_hide_from_dictionary(dict: Dict)
- read_interaction_method_from_dictionary(dict: Dict)
- read_renderer_from_dictionary(dict: Dict)
- read_selected_particles_from_dictionary(dict: Dict)
- read_velocity_reset_from_dictionary(dict: Dict)
- remove()
Remove this selection from the server.
- property renderer: str | Dict
The renderer to be used for this selection. Either a string name of a predefined visualiser, or a dictionary describing one.
- property selected_particle_ids: Set[int]
Set of particles indices that are in this selection
- property selection_id: str
The unique selection ID
- property selection_name: str
User readable name of the selection
- set_particles(particle_ids: Iterable[int] | None = None)
Set the particles in this selection, replacing the previous selection.
- Parameters:
particle_ids
- to_dictionary() Dict
Encode this selection into a nested dictionary.
- Returns:
A dictionary representation of this selection.
- property velocity_reset: bool
Should the velocities be reset for this interaction
- nanover.app.selection.get_nested_or_default(dict: Dict, default: T, *keys: Iterable[str]) T
Iterate down a nested dictionary by accessing subsequent keys, returning the default if at any point a key is not found.
- Parameters:
dict – The dictionary to iterate.
default – The default value if a key is not found.
keys – The keys to look up recursively in the dictionary.
- Returns:
The value found in the dictionary, or the default