ParaView/Extending ParaView at Compile Time

From KitwarePublic
< ParaView
Revision as of 21:01, 11 September 2008 by Utkarsh (talk | contribs)
Jump to navigationJump to search

Plugins can be used to extend ParaView functionality. However, that requires that ParaView is built with shared libraries. It is also possible to extend ParaView at compile time by compiling extra source into it. This documents describes how that can be done.


Let's say we have a file format called MyFancy and we require a reader for it. The file format is something completely new, so we cannot reuse any other class. So we write our own VTK reader and now we want to use it in the ParaView. Let's say the header file for the reader looks like this:

<source lang="cpp">

  1. ifndef __vtkMyFancyReader_h
  2. define __vtkMyFancyReader_h
  1. include "vtkUnstructuredGridAlgorithm.h"

...

class VTK_EXPORT vtkMyFancyReader : public vtkUnstructuredGridAlgorithm { public:

 static vtkMyFancyReader *New();
 vtkTypeMacro(vtkMyFancyReader,vtkUnstructuredGridAlgorithm);
 void PrintSelf(ostream& os, vtkIndent indent);
 // Description:
 // Specify file name of the MyFancy file.
 vtkSetStringMacro(FileName);
 vtkGetStringMacro(FileName);
 ...

protected:

 vtkMyFancyReader();
 ~vtkMyFancyReader();
 ...

private:

 vtkMyFancyReader(const vtkMyFancyReader&); // Not implemented
 void operator=(const vtkMyFancyReader&); // Not implemented

};

  1. endif

</source>

First, we need to write the server manager configuration XML describing the interface.

<source lang="xml">

 <ServerManagerConfiguration>
   <ProxyGroup name="sources">
     <SourceProxy name="MyFancyReader" 
                  class="vtkMyFanceReader">
       <StringVectorProperty name="FileName"
                             command="SetFileName"
                             number_of_elements="1">
          <FileListDomain name="files"/>
         <Documentation>
           This property specifies the file name for the PNG reader.
         </Documentation>
       </StringVectorProperty>
     </SourceProxy>
 </ProxyGroup>

</ServerManagerConfiguration> </source>

Readers, Writers, and Filters also require additional GUI side XML to describe file extensions associated with those file types.

<ParaViewReaders>
  <Reader name="MyFancyReader"
          extensions="myfan"
          file_description="My Fancy Files">
  </Reader>
</ParaViewReaders>
<ParaViewFilters>
  <Filter name="MyFancyFilter" />
</ParaViewFilters>