I am writing a python plugin which should show different properties in an ArraySelectionDomain depending on which time step is currently selected in Paraview. I have tried but I cannot seem to figure out how to update the ArraySelectionDomain when selecting a new time step. I have made a small mock-up example below, but this does not update the array selection domain when switching time steps. Instead, it updates the list when I select/deselect an entry in the array selection domain and press apply. My desired behaviour is as follows:
If the selected time = 0, the selectable options should be “A”, “B”, “C”
If the selected time = 3, the selectable options should be “D”, “E”, “F”
If the selected time = 6, the selectable options should be “G”, “H”, “I”
What should I change so I can get this behaviour? Thanks!
from paraview.util.vtkAlgorithm import smproperty, smproxy
from vtkmodules.util.vtkAlgorithm import VTKPythonAlgorithmBase
@smproxy.source(label="test_time")
class Test(VTKPythonAlgorithmBase):
def __init__(self):
super().__init__(nInputPorts=0, nOutputPorts=1)
self.time_steps = [0.0, 3.0, 6.0]
self.data = []
self.data0 = ["A", "B", "C"]
self.data3 = ["D", "E", "F"]
self.data6 = ["G", "H", "I"]
@smproperty.xml("""
<StringVectorProperty information_only="1"
name="CellArrayInfo">
<ArraySelectionInformationHelper attribute_name="Cell" />
</StringVectorProperty>
<StringVectorProperty command="SetCellArrayStatus"
element_types="2 0"
information_property="CellArrayInfo"
label="Cell Arrays"
name="CellArrayStatus"
number_of_elements="0"
number_of_elements_per_command="2"
repeat_command="1">
<ArraySelectionDomain name="array_list">
<RequiredProperties>
<Property function="ArrayList"
name="CellArrayInfo" />
</RequiredProperties>
</ArraySelectionDomain>
<Documentation>This property lists which cell-centered arrays to
read.</Documentation>
</StringVectorProperty>
""")
def SetCellArrayStatus(self, array, status):
if status == 1:
print(f"selected array {array}")
def GetNumberOfCellArrays(self):
return len(self.data)
def GetCellArrayName(self, idx) -> str:
return self.data[idx]
def GetCellArrayStatus(self, *args):
return 1
@smproperty.doublevector(
name="TimestepValues", information_only="1", si_class="vtkSITimeStepsProperty"
)
def GetTimestepValues(self):
return self.time_steps
def RequestInformation(self, request, inInfo, outInfo):
executive = self.GetExecutive()
outInfo = outInfo.GetInformationObject(0)
outInfo.Remove(executive.TIME_STEPS())
outInfo.Remove(executive.TIME_RANGE())
outInfo.Set(executive.TIME_STEPS(), self.time_steps, len(self.time_steps))
outInfo.Set(
executive.TIME_RANGE(), [self.time_steps[0], self.time_steps[-1]], 2
)
return 1
def RequestData(self, request, inInfo, outInfo):
executive = self.GetExecutive()
info = outInfo.GetInformationObject(0)
time_step = info.Get(executive.UPDATE_TIME_STEP())
print(f"Selected timestep: {time_step}")
if time_step == 0:
self.data = self.data0
elif time_step == 3:
self.data = self.data3
else:
self.data = self.data6
return 1