ParaView/Extending ParaView at Compile Time

From KitwarePublic
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.

Build code as part of ParaView

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>

As described in the plugins documentation, we need to add GUI xml to tell ParaView about the supported extensions.

<source lang="xml"> <ParaViewReaders>

 <Reader name="MyFancyReader"
         extensions="myfan"
         file_description="My Fancy Files">
 </Reader>

</ParaViewReaders> </source>