Commit bd87fdd0 authored by Shawn Waldon's avatar Shawn Waldon

Add formatting option to Annotate Global Data Filter

parent b704c468
......@@ -43,6 +43,8 @@ vtkAnnotateGlobalDataFilter::vtkAnnotateGlobalDataFilter()
this->Prefix = 0;
this->Postfix = 0;
this->FieldArrayName = 0;
this->Format = 0;
this->SetFormat("%7.5g");
this->SetArrayAssociation(vtkDataObject::FIELD);
}
......
......@@ -65,6 +65,14 @@ public:
vtkGetStringMacro(Postfix);
//@}
//@{
/**
* Set the format to use when displaying the field value
*/
vtkSetStringMacro(Format);
vtkGetStringMacro(Format);
//@}
protected:
vtkAnnotateGlobalDataFilter();
~vtkAnnotateGlobalDataFilter();
......@@ -74,6 +82,7 @@ protected:
char* Prefix;
char* Postfix;
char* FieldArrayName;
char* Format;
private:
vtkAnnotateGlobalDataFilter(const vtkAnnotateGlobalDataFilter&) VTK_DELETE_FUNCTION;
......
......@@ -116,6 +116,14 @@ timestep.
<Documentation>Text that is used as a prefix to the field
value</Documentation>
</StringVectorProperty>
<StringVectorProperty command="SetFormat"
default_values="%7.5g"
name="Format"
number_of_elements="1">
<Documentation>Text that is used as a format string passed
to the Python string formatter (% operator). Used to format
the data.</Documentation>
</StringVectorProperty>
<StringVectorProperty command="SetPostfix"
default_values=""
name="Suffix"
......
......@@ -139,7 +139,7 @@ def execute_on_global_data(self):
chosen_element = chosen_element.GetValue(0)
except: pass
expression = self.GetPrefix() if self.GetPrefix() else ""
expression += str(chosen_element)
expression += self.GetFormat() % (chosen_element,)
expression += self.GetPostfix() if self.GetPostfix() else ""
self.SetComputedAnnotationValue(expression)
return True
......
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