[Paraview-developers] Servermanager XML: Displaying a list of strings along with selection

Cory Quammen cory.quammen at kitware.com
Mon Aug 18 09:16:00 EDT 2014


Girish,

Is the list of strings fixed, or can it vary depending on the file?
There are three things you can do depending on what you need:

1). If you have a fixed set of strings, you can use an
IntVectorProperty, and set its domain as a list of strings with an
associated integer, i.e., an enumeration.

<IntVectorProperty command="SetVariableType"
                   default_values="0"
                   name="VariableType"
                   number_of_elements="1">
  <EnumerationDomain name="enum">
    <Entry text="Variable 1"
           value="0" />
    <Entry text="Variable 2"
           value="1" />
    <Entry text="Variable 3"
           value="2" />
  </EnumerationDomain>
</IntVectorProperty>

This generates a combo box in the UI, and only one element can be
selected at a time. It will expect your reader to have methods with
the signature

virtual void SetVariableType(int i);
virtual int GetVariableType();

Within your reader, you can use this enumeration value to do whatever
you'd like.

2). If you just have a list of strings generated in your reader and
want to enable the selection of one, you can use a
StringVectorProperty with a StringListDomain, e.g.

<StringVectorProperty command="GetAllDimensions"
                      information_only="1"
                      name="DimensionInfo">
  <StringArrayHelper />
</StringVectorProperty>
<StringVectorProperty animatelable="0"
                      command="SetDimensions"
                      name="Dimensions"
                      number_of_elements="1"
                      panel_visibility="default">
  <StringListDomain name="array_list">
    <RequiredProperties>
      <Property function="ArrayList"
                name="DimensionInfo" />
    </RequiredProperties>
  </StringListDomain>
</StringVectorProperty>

The first property here is an "information-only" property. ParaView
will invoke the method "GetAllDimensions" in your reader which should
return a vtkStringArray. The second property is responsible for
displaying the string array as a combobox, and invokes the method
"SetDimensions" with the value selected in the combobox. You need the
StringListDomain in the second property to connect the
information-only property to the second property.

3). If you need to populate the list depending on what is in the file
and be able to select/deselect list entries (e.g., to pick which
variables are loaded from the file), then see the XML file

ParaView/ParaViewCore/ServerManager/SMApplication/Resources/readers.xml

and search for the SourceProxy named "FlashReaderCore". You'll find
this XML property definition:

      <!--  Array Selection GUI Component -->
      <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>
      <StringVectorProperty information_only="1"
                            name="PointArrayInfo">
        <ArraySelectionInformationHelper attribute_name="Point" />
      </StringVectorProperty>

This XML is responsible for showing in the GUI the list of
cell-associated arrays. In the vtkAMRFlashReader, there are a number
of
methods that are defined to make this work. (These are actually
defined in vtkAMRFlashReader's parent class, vtkAMRBaseReader.h)

  // Description:
  // Get the data array selection tables used to configure which data
  // arrays are loaded by the reader.
  vtkGetObjectMacro(CellDataArraySelection, vtkDataArraySelection);

  // Description:
  // Get the number of point or cell arrays available in the input.
  int GetNumberOfCellArrays();

  // Description:
  // Get the name of the point or cell array with the given index in
  // the input.
  const char* GetCellArrayName(int index);

  // Description:
  // Get/Set whether the point or cell array with the given name is to
  // be read.
  int GetCellArrayStatus(const char* name);
  void SetCellArrayStatus(const char* name, int status);

The first method listed above might not be necessary in your reader;
I'm not sure. The rest are necessary.

Note in this XML and method definitions that "Cell" is the name of the
given to the association of array the reader can load. You can replace
all occurrences of "Cell" with whatever name is more appropriate for
your needs.

I hope that helps,
Cory

On Mon, Aug 18, 2014 at 5:46 AM, Girish Ramesh <rgirish28 at gmail.com> wrote:
> Hi,
>
> I have been breaking my head over this problem for a while now as there are
> no servermanager xml explanations anywhere. So, what I want to accomplish is
> populate a GUI list with a vtkStringArray and be able to select strings
> within the list in order to fill a variable . Can someone please help me or
> point me in the right direction in this task? I am writing my own plugin
> reader as you may have understood, but I'm stuck at this point for a while.
> Thanks.
>
> Regards,
> Girish
>
> _______________________________________________
> Paraview-developers mailing list
> Paraview-developers at paraview.org
> http://public.kitware.com/mailman/listinfo/paraview-developers
>


More information about the Paraview-developers mailing list