Events
- class mechanica.MxEventBase(*args, **kwargs)
- last_fired
Record of last time fired
- times_fired
Record of how many times fired
- remove() void
Designates event for removal
- mechanica.Event
alias of
mechanica.mechanica.MxEventPy
- class mechanica.MxEvent(*args)
Bases:
mechanica.mechanica.MxEventBaseConstruct an instance using functions
- Parameters
invokeMethod (MxEventMethod) – an invoke function
predicateMethod (MxEventMethod) – a predicate function
- class mechanica.MxEventPy(invokeExecutor: mechanica.mechanica.MxEventPyInvokePyExecutor, predicateExecutor: Optional[mechanica.mechanica.MxEventPyPredicatePyExecutor] = None)
- mechanica.on_event(invoke_method, predicate_method=None)
Creates and registers an event using prescribed invoke and predicate python function executors
- Parameters
invoke_method (PyObject) – an invoke method; evaluated when an event occurs. Takes an
MxEventinstance as argument and returns 0 on success, 1 on errorpredicate_method – optional predicate method; decides if an event occurs. Takes a
MxEventinstance as argument and returns 1 to trigger event, -1 on error and 0 otherwise
- mechanica.TimeEvent
alias of
mechanica.mechanica.MxTimeEventPy
- class mechanica.MxTimeEventPy(period: double const &, invokeExecutor: MxTimeEventPyInvokePyExecutor, predicateExecutor: MxTimeEventPyPredicatePyExecutor = None, nextTimeSetter: MxTimeEventNextTimeSetter * = None, start_time: double const & = 0, end_time: double const & = -1)
Bases:
mechanica.mechanica.MxEventBase- next_time
Next time of evaluation
- period
Period of evaluation
- start_time
Start time of evaluations
- end_time
End time of evaluations
- mechanica.on_time(period, invoke_method, predicate_method=None, distribution='default', start_time=0.0, end_time=- 1.0)
Like
on_event, but for an event that occurs at regular intervals.- Parameters
period (float) – period of event
invoke_method (PyObject) – an invoke method; evaluated when an event occurs. Takes an
MxTimeEventinstance as argument and returns 0 on success, 1 on errorpredicate_method – optional predicate method; decides if an event occurs. Takes a
MxTimeEventinstance as argument and returns 1 to trigger event, -1 on error and 0 otherwisedistribution (str) – distribution by which the next event time is selected
start_time (float) – time after which the event can occur
end_time (float) – time before which the event can occur; a negative value is interpreted as until ‘forever’
- mechanica.ParticleEvent
- class mechanica.MxParticleEvent(*args)
Bases:
mechanica.mechanica.MxEventBase- targetType
Target particle type of this event
- targetParticle
Target particle of an event evaluation
- class mechanica.MxParticleEventPy(*args)
- mechanica.on_particle(ptype, invoke_method, predicate_method=None, selector='default', single: bool = False)
Like
on_event, but for a particle of a particular particle type.- Parameters
ptype (MxParticleType) – the type of particle to select
invoke_method (PyObject) – an invoke method; evaluated when an event occurs. Takes an
MxParticleEventinstance as argument and returns 0 on success, 1 on errorpredicate_method – optional predicate method; decides if an event occurs. Takes a
MxParticleEventinstance as argument and returns 1 to trigger event, -1 on error and 0 otherwiseselector (str) – name of particle selector
single (bool) – flag to only trigger event once and then return
- mechanica.ParticleTimeEvent
- class mechanica.MxParticleTimeEvent(*args)
Bases:
mechanica.mechanica.MxEventBase- targetType
Target particle type of this event
- targetParticle
Target particle of an event evaluation
- next_time
Next time at which an evaluation occurs
- period
Period of event evaluations
- start_time
Time at which evaluations begin
- end_time
Time at which evaluations stop
- class mechanica.MxParticleTimeEventPy(*args)
- mechanica.on_particletime(ptype, period, invoke_method, predicate_method=None, distribution='default', start_time=0.0, end_time=- 1.0, selector='default')
A combination of
on_timeandon_particle.- Parameters
ptype (MxParticleType) – the type of particle to select
period (float) – period of event
invoke_method (PyObject) – an invoke method; evaluated when an event occurs. Takes an
MxTimeEventinstance as argument and returns 0 on success, 1 on errorpredicate_method – optional predicate method; decides if an event occurs. Takes a
MxTimeEventinstance as argument and returns 1 to trigger event, -1 on error and 0 otherwisedistribution (str) – distribution by which the next event time is selected
start_time (str) – time after which the event can occur
end_time (float) – time before which the event can occur; a negative value is interpreted as until ‘forever’
selector (float) – name of particle selector
- mechanica.KeyEvent
alias of
mechanica.mechanica.MxKeyEvent
- class mechanica.MxKeyEvent(glfw_event: Magnum::Platform::GlfwApplication::KeyEvent * = None)
- property key_name: str
Key pressed for this event
- property key_alt: bool
Flag for whether Alt key is pressed
- property key_ctrl: bool
Flag for whether Ctrl key is pressed
- property key_shift: bool
Flag for whether Shift key is pressed
- mechanica.on_keypress(invoke_method)
Registers a callback for handling keyboard events
- Parameters
invoke_method (PyObject) – an invoke method; evaluated when an event occurs. Takes an
MxKeyEventinstance as argument and returns None