Slicing in response to time change
This script shows how you can use Python callbacks to change a slice plane as a function of the current time state. We create a plot, slice it along its X-axis, and then install a Python callback function that modifies the slice plane as a function of the new time state.
# Set up a plot
OpenDatabase("~/data/wave/wave.visit")
AddPlot("Pseudocolor", "pressure")
# Add a slice operator that keeps the slice in 3D and slices along the
# X-axis as a percentage of the extents.
AddOperator("Slice")
s = SliceAttributes()
s.project2d = 0
s.originType = s.Percent
s.axisType = s.XAxis
SetOperatorOptions(s)
DrawPlots()
# This callback function computes the percent through the time series for the
# current time state and uses that percentage as a percentage for the slice
def onSetTimeSliderState(timeState, userData):
nts = TimeSliderGetNStates()
percent = 0.
if nts > 1:
percent = float(timeState) / float(TimeSliderGetNStates()-1)
s.originPercent = percent * 100.
SetOperatorOptions(s)
RegisterCallback("SetTimeSliderStateRPC", onSetTimeSliderState, s)