Commit 2e4907e6 authored by Shawn Waldon's avatar Shawn Waldon

AnnotateAttributeData: change UI to set association and array name together

This is part of #17973.
parent 4a75887e
......@@ -6,8 +6,7 @@ e = Elevation(LowPoint=[-0.5,-0.5,-0.5],
UpdatePipeline()
a = AnnotateAttributeData(
Prefix="Hello: ",
ArrayName= "Elevation",
ArrayAssociation="Point Data",
SelectInputArray= ('POINTS', 'Elevation'),
ElementId=0,
ProcessId=0
)
......@@ -19,8 +18,7 @@ assert annotatedValue[0:14] == "Hello: 0.66666"
text1 = Text()
annotateAttributeData1 = AnnotateAttributeData(Input=text1)
annotateAttributeData1.ArrayName = 'Text'
annotateAttributeData1.ArrayAssociation = 'Row Data'
annotateAttributeData1.SelectInputArray = ('ROWS', 'Text')
UpdatePipeline()
annotatedValue = annotateAttributeData1.GetClientSideObject().GetComputedAnnotationValue()
......
......@@ -613,7 +613,7 @@ struct Process_5_4_to_5_5
{
return LockScalarRange(document) && CalculatorAttributeMode(document) &&
CGNSReaderUpdates(document) && HeadlightToAdditionalLight(document) &&
DataBoundsInflateScaleFactor(document);
DataBoundsInflateScaleFactor(document) && AnnotateAttributesInput(document);
}
bool LockScalarRange(xml_document& document)
......@@ -661,6 +661,53 @@ struct Process_5_4_to_5_5
return true;
}
bool AnnotateAttributesInput(xml_document& document)
{
pugi::xpath_node_set proxy_nodes =
document.select_nodes("//ServerManagerState/Proxy[@group='filters' and "
"@type='AnnotateAttributeData']");
for (auto iter = proxy_nodes.begin(); iter != proxy_nodes.end(); ++iter)
{
pugi::xml_node proxy_node = iter->node();
pugi::xml_node association_node =
proxy_node.find_child_by_attribute("Property", "name", "ArrayAssociation");
pugi::xml_node arrayname_node =
proxy_node.find_child_by_attribute("Property", "name", "ArrayName");
if (!association_node || !arrayname_node)
{
continue;
}
pugi::xml_node newInputNode = proxy_node.append_child("Property");
newInputNode.append_attribute("name").set_value("SelectInputArray");
newInputNode.append_attribute("number_of_elements").set_value(5);
pugi::xml_node childNode = newInputNode.append_child("Element");
childNode.append_attribute("index").set_value(0);
childNode.append_attribute("value").set_value("");
childNode = newInputNode.append_child("Element");
childNode.append_attribute("index").set_value(1);
childNode.append_attribute("value").set_value("");
childNode = newInputNode.append_child("Element");
childNode.append_attribute("index").set_value(2);
childNode.append_attribute("value").set_value("");
childNode = newInputNode.append_child("Element");
childNode.append_attribute("index").set_value(3);
childNode.append_attribute("value").set_value(
association_node.child("Element").attribute("value").as_int());
childNode = newInputNode.append_child("Element");
childNode.append_attribute("index").set_value(4);
childNode.append_attribute("value").set_value(
arrayname_node.child("Element").attribute("value").as_string());
}
return true;
}
bool CalculatorAttributeMode(xml_document& document)
{
pugi::xpath_node_set proxy_nodes =
......
......@@ -173,28 +173,26 @@ annotation text.
currently.
</Documentation>
</InputProperty>
<IntVectorProperty command="SetArrayAssociation"
default_values="2"
name="ArrayAssociation"
number_of_elements="1">
<Documentation>Select the attribute to use to popular array names from.</Documentation>
<EnumerationDomain name="enum">
<Entry text="Point Data" value="0" />
<Entry text="Cell Data" value="1" />
<Entry text="Field Data" value="2" />
<Entry text="Row Data" value="6" />
</EnumerationDomain>
</IntVectorProperty>
<StringVectorProperty command="SetArrayName"
name="ArrayName"
number_of_elements="1">
<ArrayListDomain name="array_list">
<StringVectorProperty animateable="0"
command="SetInputArrayToProcess"
element_types="0 0 0 0 2"
name="SelectInputArray"
number_of_elements="5">
<ArrayListDomain attribute_type="Scalars"
name="array_list">
<RequiredProperties>
<Property function="Input"
name="Input" />
</RequiredProperties>
</ArrayListDomain>
<Documentation>Choose arrays that is going to be displayed</Documentation>
<FieldDataDomain name="field_list">
<RequiredProperties>
<Property function="Input"
name="Input" />
</RequiredProperties>
</FieldDataDomain>
<Documentation>This property indicates the name of the array from which
to compute the histogram.</Documentation>
</StringVectorProperty>
<IntVectorProperty name="ElementId"
command="SetElementId"
......
......@@ -197,6 +197,40 @@ def setattr(proxy, pname, value):
"'DataBoundsInflateFactor' is obsolete as of ParaView 5.5. Use the "\
"'DataBoundsScaleFactor' property to modify the axes gris data bounds instead.")
if proxy.SMProxy and proxy.SMProxy.GetXMLName() == "AnnotateAttributeData":
# in 5.5, Annotate Attribute Data changed how it sets the array to annotate
if pname == "ArrayAssociation":
if paraview.compatibility.GetVersion() <= 5.4:
paraview.print_warning(\
"'ArrayAssociation' is obsolete. Use 'SelectInputArray' property of AnnotateAttributeData instead.")
if value == "Point Data":
value = "POINTS"
elif value == "Cell Data":
value = "CELLS"
elif value == "Field Data":
value = "FIELD"
elif value == "Row Data":
value = "ROWS"
arrayProp = proxy.GetProperty("SelectInputArray")
proxy.GetProperty("SelectInputArray").SetData((value, arrayProp[1]))
raise Continue()
else:
raise NotSupportedException(\
"'ArrayAssociation' is obsolete as of ParaView 5.5. Use 'SelectInputArray' instead.")
elif pname == "ArrayName":
if paraview.compatibility.GetVersion() <= 5.4:
paraview.print_warning(\
"'ArrayName' is obsolete. Use 'SelectInputArray' property of AnnotateAttributeData instead.")
arrayProp = proxy.GetProperty("SelectInputArray")
proxy.GetProperty("SelectInputArray").SetData((arrayProp[0], value))
raise Continue()
else:
raise NotSupportedException(\
"'ArrayName' is obsolete as of ParaView 5.5. Use 'SelectInputArray' instead.")
if not hasattr(proxy, pname):
raise AttributeError()
proxy.__dict__[pname] = value
......@@ -366,6 +400,33 @@ def getattr(proxy, pname):
'The DataBoundsInflateFactorproperty has been removed in ParaView '\
'5.4. Please use the DataBoundsScaleFactor property instead.')
if proxy.SMProxy and proxy.SMProxy.GetXMLName() == "AnnotateAttributeData":
# in 5.5, Annotate Attribute Data changed how it sets the array to annotate
if pname == "ArrayAssociation":
if paraview.compatibility.GetVersion() <= 5.4:
paraview.print_warning(\
"'ArrayAssociation' is obsolete. Use 'SelectInputArray' property of AnnotateAttributeData instead.")
value = proxy.GetProperty("SelectInputArray")[0]
if value == "CELLS":
return "Cell Data"
elif value == "FIELD":
return "Field Data"
elif value == "ROWS":
return "Row Data"
else:
return "Point Data"
else:
raise NotSupportedException(\
"'ArrayAssociation' is obsolete as of ParaView 5.5. Use 'SelectInputArray' instead.")
elif pname == "ArrayName":
if paraview.compatibility.GetVersion() <= 5.4:
paraview.print_warning(\
"'ArrayName' is obsolete. Use 'SelectInputArray' property of AnnotateAttributeData instead.")
return proxy.GetProperty("SelectInputArray")[1]
else:
raise NotSupportedException(\
"'ArrayName' is obsolete as of ParaView 5.5. Use 'SelectInputArray' instead.")
raise Continue()
def GetProxy(module, key):
......
......@@ -82,6 +82,7 @@ def execute(self):
return True
inputs = [dsa.WrapDataObject(inputDO)]
association = self.GetArrayAssociation()
ns = _get_ns(self, inputs[0], association)
......@@ -156,16 +157,20 @@ def execute_on_attribute_data(self, evaluate_locally):
return True
inputs = [dsa.WrapDataObject(inputDO)]
association = self.GetArrayAssociation()
info = self.GetInputArrayInformation(0)
association = info.Get(vtkDataObject.FIELD_ASSOCIATION())
array_name = info.Get(vtkDataObject.FIELD_NAME())
ns = _get_ns(self, inputs[0], association)
if self.GetArrayName() not in ns:
print("Failed to locate array '%s'." % self.GetArrayName(), file=sys.stderr)
if array_name not in ns:
print("Failed to locate array '%s'." % array_name, file=sys.stderr)
raise RuntimeError("Failed to locate array")
if not evaluate_locally:
return True
array = ns[self.GetArrayName()]
array = ns[array_name]
chosen_element = array.GetValue(self.GetElementId())
expression = self.GetPrefix() if self.GetPrefix() else ""
expression += str(chosen_element)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment