Paul Edwards a écrit :
Hi Patrick,

Have you tried adding a StringVectorProperty to your XML for a filename (with <FileListDomain name="files"/>) and having a GUI XML file for adding a reader? I think someone suggested you look at the helix source xml (http://paraview.org/gitweb?p=ParaView.git;a=blob;f=Examples/Plugins/HelixSource/helix.xml;h=d6c385561d9cdffc5298ced17d700bae8bc167b6;hb=HEAD) and you can see how to add the GUI XML file in the other reader example (http://paraview.org/gitweb?p=ParaView.git;a=tree;f=Examples/Plugins/Reader;hb=HEAD)

Hi Paul,

Thanks to share your experience on this topic.
As I wrote to another paraview user,
my python code is a small 200 lines using netCDF4, numpy
and its conversion is not as straightforward as it could be because I use
many numpy functions.
Of course, I can do it but the python approach is more attrative.

I have tried to add
    <StringVectorProperty
       name="FileName"
       animateable="0"
       command="SetFileName"
       number_of_elements="1">
       <FileListDomain name="files"/>
    </StringVectorProperty>

to the helix.xml example but
when I load it nothing appears in the source menu.

What I would like is a Python Reader example.
If someone has this to share, I am very interested.

Patrick

--
LSCE/IPSL, Laboratoire CEA-CNRS-UVSQ
Data Analysis and Visualization Engineer
IPSL Global Climate Modelling Group
--

<ServerManagerConfiguration>
  <ProxyGroup name="sources">

  <!-- server manager xml for a python script that creates a helix 
       the auto generated panel for this exposes everything more than we want so
       a custom panel would be good -->
    <SourceProxy name="HelixSource" class="vtkPythonProgrammableFilter"
                 label="Helix Source">
      <Documentation
         long_help="Creates a helix using a python script using parameters filled in by the user."
         short_help="Creates a helix.">
           This source will execute a python script to produce a helix dataset.
      </Documentation>
      
      <!-- data set type -->
      <IntVectorProperty 
        name="OutputDataSetType" 
        command="SetOutputDataSetType" 
        number_of_elements="1"
        default_values="0"> 
        <!-- value of 0 means vtkPolyData -->
      </IntVectorProperty>

      <!-- the script -->
     <StringVectorProperty 
        name="Script" 
        command="SetScript"
        number_of_elements="1"
        default_values="import math;&#xa;pdo = self.GetPolyDataOutput()&#xa;&#xa;newPts = vtk.vtkPoints()&#xa;for i in range(0, numPts):&#xa;   x = i*float(length)/float(numPts)&#xa;   y = math.sin(i*rounds*2*math.pi/numPts)&#xa;   z = math.cos(i*rounds*2*math.pi/numPts)&#xa;   newPts.InsertPoint(i, x,y,z)&#xa;&#xa;pdo.SetPoints(newPts)&#xa;aPolyLine = vtk.vtkPolyLine()&#xa;&#xa;aPolyLine.GetPointIds().SetNumberOfIds(numPts)&#xa;for i in range(0,numPts):&#xa;   aPolyLine.GetPointIds().SetId(i, i)&#xa;&#xa;pdo.Allocate(1, 1)&#xa;pdo.InsertNextCell(aPolyLine.GetCellType(), aPolyLine.GetPointIds())&#xa;">
       <Hints>
         <Widget type="multi_line"/>
       </Hints>
     </StringVectorProperty>

     <!-- python script references a variable "numPts" 
          we expose this as a property allowing the user to set it -->
     <StringVectorProperty
       name="NumberOfPoints"
       command="SetParameter"
       number_of_elements="2"
       default_values_delimiter=";"
       default_values="numPts;80">
     </StringVectorProperty>

     <StringVectorProperty
	name="FileName"
	animateable="0"
	command="SetFileName"
	number_of_elements="1">
	<FileListDomain name="files"/>
     </StringVectorProperty>

     <!-- python script references a variable "length" 
          we expose this as a property allowing the user to set it -->
     <StringVectorProperty
       name="Length"
       command="SetParameter"
       number_of_elements="2"
       default_values_delimiter=";"
       default_values="length;2.0">
     </StringVectorProperty>
     
     <!-- python script references a variable "rounds" 
          we expose this as a property allowing the user to set it -->
     <StringVectorProperty
       name="NumberOfRounds"
       command="SetParameter"
       number_of_elements="2"
       default_values_delimiter=";"
       default_values="rounds;3">
     </StringVectorProperty>

    <!-- End HelixSource -->
    </SourceProxy>
  </ProxyGroup>
</ServerManagerConfiguration>


_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the ParaView Wiki at: 
http://paraview.org/Wiki/ParaView

Follow this link to subscribe/unsubscribe:
http://www.paraview.org/mailman/listinfo/paraview

Reply via email to