[Paraview] custom reader (c++ with custom panel) and python wrapping

Felipe Bordeu felipe.bordeu at ec-nantes.fr
Tue Apr 12 09:38:37 EDT 2011


hello,

I have a custom reader (c++ plus custom panel) working well in ParaView 
GUI.

Now want to use the python wrapping capabilities of paraview, but I have 
same problems with the python object.

in my custom panel I have a <widget class="QTreeWidget" 
name="SpacePGDDimsStatus">

in my xml I have

     ....
<StringVectorProperty  name="SpacePGDDimsInfo"  information_only="1">
<ArraySelectionInformationHelper attribute_name="SpacePGDDims"/>
</StringVectorProperty>

<StringVectorProperty
         name="SpacePGDDimsStatus"
         command="SetSpacePGDDimsStatus"
         number_of_elements="0"
         repeat_command="1"

         number_of_elements_per_command="2"
         element_types="2 0"
         information_property="SpacePGDDimsInfo"
         animateable="1"
         label="Space PGD Dims"
 >

<ArraySelectionDomain name="array_list" >
<RequiredProperties>
<Property name="SpacePGDDimsInfo" function="ArrayList"/>
</RequiredProperties>
</ArraySelectionDomain>
<Documentation>
          This property lists which PGDDimensions are used for the space.
</Documentation>
</StringVectorProperty>
    .....

and in my reader I have (c++):

     int GetNumberOfSpacePGDDimsArrays();
     const char* GetSpacePGDDimsArrayName(int index);

     int GetSpacePGDDimsArrayStatus(const char* name);
     void SetSpacePGDDimsStatus(const char* name, int status);

If I do (in python):

 >>> from paraview.simple import *
 >>> 
paraview.simple.LoadPlugin('/Big/fbordeu/builds/PXDMFReader_bin_git/libPXDMFReaderPython.so')
 >>> reader = 
servermanager.sources.PXDMFReader(FileName='/home/fbordeu/projects/wiimote_vtk/demo1/SolPGD.pxdmf')

 >>> dir(reader)
['CellData', 'FieldData', 'FileName', 'FileNameChanged', 
'GetCellDataInformation', 'GetDataInformation', 
'GetFieldDataInformation', 'GetPointDataInformation', 'GetProperty', 
'GetPropertyValue', 'Initialize', 'InitializeFromProxy', 
'ListProperties', 'Observed', 'ObserverTag', 'PGDDimsPosDataInfo', 
'PointData', 'Port', 'SMProxy', 'SetPropertyWithName', 'SpacePGDDims', 
'Stride', 'TimePGDDims', 'TimestepValues', 'UpdatePipeline', 
'UpdatePipelineInformation', '_Proxy__ConvertArgumentsAndCall', 
'_Proxy__GetActiveCamera', '_Proxy__LastAttrName', '_Proxy__Properties', 
'__class__', '__del__', '__delattr__', '__dict__', '__doc__', '__eq__', 
'__format__', '__getattr__', '__getattribute__', '__getitem__', 
'__hash__', '__init__', '__iter__', '__module__', '__ne__', '__new__', 
'__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', 
'__str__', '__subclasshook__', '__weakref__', 'add_attribute']

 >>> reader.ListProperties()
['CellArrayInfo', 'CellArrays', 'FileName', 'PGDDimsDataInfo', 
'PGDDimsMaxRangeDataInfo', 'PGDDimsMinRangeDataInfo', 
'PGDDimsNameDataInfo', 'PGDDimsPosDataInfo', 'PGD_Dims', 
'PointArrayInfo', 'PointArrays', 'SpacePGDDimsInfo', 'SpacePGDDims', 
'Stride', 'TimePGDDimsInfo', 'TimePGDDims', 'TimestepValues', 'UseStride']


 >>> dir(reader.GetProperty('SpacePGDDimsStatus'))
['Available', 'Clear', 'ConvertValue', 'DeselectAll', 'GetAvailable', 
'GetData', 'GetElement', 'Name', 'Proxy', 'SMProperty', 'SelectAll', 
'SetData', '_ArrayListProperty__arrays', '_FindPropertyName', 
'_UpdateProperty', '__call__', '__class__', '__delattr__', '__dict__', 
'__doc__', '__format__', '__getattr__', '__getattribute__', 
'__getitem__', '__hash__', '__init__', '__iter__', '__len__', 
'__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', 
'__setattr__', '__setitem__', '__sizeof__', '__str__', 
'__subclasshook__', '__weakref__']

 >>> reader.GetProperty('SpacePGDDimsStatus').GetAvailable()
['PGD0 size : 1 ( X ) ', 'PGD1 size : 1 ( Y ) ', 'PGD2 size : 1 ( W ) ']

in python I can use  
"reader.GetProperty('SpacePGDDimsStatus').SelectAll()" to select all, 
but how can I select only one (the first for example)???.

For now I'm using
reader.GetProperty('SpacePGDDimsStatus').SetData(reader.GetProperty('SpacePGDDimsStatus').GetAvailable()[0:2])
but I don't know if is the correct way to do it.

also I am really confused with all the option in the xml file ( 
repeat_command, element_types, animateable, 
number_of_elements_per_command...)

Using:  Linux  x86_64 2.6.32-30-generic, and Paraview 3.11 (git version).

Thanks,

-- 

Felipe Bordeu Weldt
Ingénieur de Recherche
-------------------------------------
Tél. : 33 (0)2 40 37 16 57
Fax. : 33 (0)2 40 74 74 06
Felipe.Bordeu at ec-nantes.fr
Institut GeM - UMR CNRS 6183
École Centrale Nantes
1 Rue de La Noë, 44321 Nantes, FRANCE
-------------------------------------



More information about the ParaView mailing list