Allow plot functions to dynamically enter or leave animation mode
As discussed in utopia!85 (merged), there are scenarios in which it would be useful if ExternalPlotCreator
plot functions that were configured to perform an animation are able to not perform the animation but just do the regular plot.
The prerequisites for allowing such behaviour are already given:
- The plot function only registers an animation function, invocation is controlled by the
PlotHelper
- No data is written inside the plot functions that could lead to any unintended side effects
- Repeated invocation of a plot function is not an issue
Proposal
- Add a custom exception type that conveys to
ExternalPlotCreator
that the animation mode is to be changed- Names could be
EnableAnimation
andDisableAnimation
; it should clearly convey what happens - ("start", "cancel", "abort", ... are not suitable, because they suggest that the animation would then start or has already started, respectively)
- Names could be
- Add methods to the
PlotHelper
that invoke such an exception:disable_animation
/enable_animation
- This additional level of indirection not only uses the same interface as
hlpr.register_animation_update
, but it would allow to take care of other tasks that need to happen alongside
- This additional level of indirection not only uses the same interface as
- Adjust the main plotting routine of
ExternalPlotCreator
to handle those exceptions and switch between the modes- Ensure that switching back and forth multiple times is not possible
- Add corresponding documentation and tests