narupa.app.selection module¶
-
class
narupa.app.selection.RenderingSelection(id: str, name: str = 'Unnamed Selection')¶ Bases:
objectA local representation of a selection in a NarupaIMD simulation.
Not intended to be created directly, but rather via the
NarupaImdClient, 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[KT, VT]) → narupa.app.selection.RenderingSelection¶ Decode a dictionary into a selection.
Parameters: dict – A dictionary, such as json or a protobuf value. Returns: A selection decoded from the given dictionary
-
hide¶ Should this renderer be hidden
-
interaction_method¶ The interaction method for Narupa 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[KT, VT])¶
-
read_hide_from_dictionary(dict: Dict[KT, VT])¶
-
read_interaction_method_from_dictionary(dict: Dict[KT, VT])¶
-
read_renderer_from_dictionary(dict: Dict[KT, VT])¶
-
read_selected_particles_from_dictionary(dict: Dict[KT, VT])¶
-
read_velocity_reset_from_dictionary(dict: Dict[KT, VT])¶
-
remove()¶ Remove this selection from the server.
-
removed¶ Event which is invoked when this selection is removed
-
renderer¶ The renderer to be used for this selection. Either a string name of a predefined visualiser, or a dictionary describing one.
-
selected_particle_ids¶ Set of particles indices that are in this selection
-
selection_id¶ The unique selection ID
-
selection_name¶ User readable name of the selection
-
set_particles(particle_ids: Optional[Iterable[int]] = None)¶ Set the particles in this selection, replacing the previous selection.
Parameters: particle_ids –
-
to_dictionary() → Dict[KT, VT]¶ Encode this selection into a nested dictionary.
Returns: A dictionary representation of this selection.
-
updated¶ Event which is invoked when modifications to this selections are applied
-
velocity_reset¶ Should the velocities be reset for this interaction
-
-
narupa.app.selection.get_nested_or_default(dict: Dict[KT, VT], default: T, *keys) → 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