ParaView/Plugin HowTo: Difference between revisions

From KitwarePublic
Jump to navigationJump to search
No edit summary
No edit summary
Line 20: Line 20:
Where CMake will ask for the ParaView_DIR which you point to your ParaView build.  The PARAVIEW_USE_FILE includes build parameters and macros for building plugins.
Where CMake will ask for the ParaView_DIR which you point to your ParaView build.  The PARAVIEW_USE_FILE includes build parameters and macros for building plugins.


=== Adding a custom filter ===
=== Adding a custom filter, reader or writer ===
Standard VTK procedure is followed for writing these classes.  XML for ParaView must also be written, and an example of that can be found at [[ParaView:Extend]].  If we have a class vtkMyFilter with MyFilter.xml, we put that in a server plugin as follows:
FIND_PACKAGE(ParaView REQUIRED)
INCLUDE(${PARAVIEW_USE_FILE})
ADD_PARAVIEW_PLUGIN(MyFilterSMPlugin "1.0"
                    SERVER_MANAGER_XML MyFilter.xml
                    SERVER_MANAGER_SOURCES vtkMyFilter.cxx )
 
The plugin library will be named MyFilterSMPlugin.dll, libMyFilterSMPlugin.so or named as appropriate for the platform.  The name is arbitrary.  The XML, though client-side, is embedded into the plugin.  When the ParaView server loads the plugin, the XML will be given to the client.
 
For readers and writers, we also need to make a client plugin.  We create an XML file defining the reader or writer information.
<ParaViewReaders>
  <Reader name="MyReader"
          extensions="myreader mr"
          file_description="My Reader Files">
  </Reader>
</ParaViewReaders>
The name corresponds with the name found in the server manager XML.  The extensions is to define what file extensions for file types and is used by the file dialog for filtering.  The file_description is also used by the file dialog to give a friendly name for filtering.
 
We can have multiple client side XML files for different readers, writers, etc...  We embed those into a Qt resource in an qrc file as follows:
<RCC>
  <qresource prefix="/ParaViewResources" >
    <file>MyReader.xml</file>
  </qresource>
<RCC>
 
Then we create the CMakeLists.txt file to build the client side plugin for the reader.
FIND_PACKAGE(ParaView REQUIRED)
INCLUDE(${PARAVIEW_USE_FILE})
ADD_PARAVIEW_PLUGIN(MyFilterGUIPlugin "1.0"
                    GUI_RESOURCE MyReader.qrc )

Revision as of 21:17, 6 March 2007

Overview

Plugins can be used to extend ParaView in several ways

  • Add new VTK objects (readers, writers, filters, etc...)
  • Add custom Qt widgets
  • Add custom toolbars
  • Add custom views in addition to the existing render view, line chart and bar chart.

Types of plugins

  • Server plugins - extend the paraview server
  • Client plugins - extend the paraview client
  • A plugin may contain both client and server extensions and work if the appropriate client side libraries are on the server.

Building Plugins

To create a plugin, one must have their own build of ParaView3. Binary downloads do not include header files or import libraries (on applicable platforms).

The beginning of a CMakeLists.txt file contains

FIND_PACKAGE(ParaView REQUIRED)
INCLUDE(${PARAVIEW_USE_FILE})

Where CMake will ask for the ParaView_DIR which you point to your ParaView build. The PARAVIEW_USE_FILE includes build parameters and macros for building plugins.

Adding a custom filter, reader or writer

Standard VTK procedure is followed for writing these classes. XML for ParaView must also be written, and an example of that can be found at ParaView:Extend. If we have a class vtkMyFilter with MyFilter.xml, we put that in a server plugin as follows:

FIND_PACKAGE(ParaView REQUIRED)
INCLUDE(${PARAVIEW_USE_FILE})
ADD_PARAVIEW_PLUGIN(MyFilterSMPlugin "1.0" 
                    SERVER_MANAGER_XML MyFilter.xml
                    SERVER_MANAGER_SOURCES vtkMyFilter.cxx )

The plugin library will be named MyFilterSMPlugin.dll, libMyFilterSMPlugin.so or named as appropriate for the platform. The name is arbitrary. The XML, though client-side, is embedded into the plugin. When the ParaView server loads the plugin, the XML will be given to the client.

For readers and writers, we also need to make a client plugin. We create an XML file defining the reader or writer information.

<ParaViewReaders>
  <Reader name="MyReader"
          extensions="myreader mr"
          file_description="My Reader Files">
  </Reader>
</ParaViewReaders>

The name corresponds with the name found in the server manager XML. The extensions is to define what file extensions for file types and is used by the file dialog for filtering. The file_description is also used by the file dialog to give a friendly name for filtering.

We can have multiple client side XML files for different readers, writers, etc... We embed those into a Qt resource in an qrc file as follows:

<RCC>
  <qresource prefix="/ParaViewResources" >
    <file>MyReader.xml</file>
  </qresource>
<RCC>

Then we create the CMakeLists.txt file to build the client side plugin for the reader.

FIND_PACKAGE(ParaView REQUIRED)
INCLUDE(${PARAVIEW_USE_FILE})
ADD_PARAVIEW_PLUGIN(MyFilterGUIPlugin "1.0" 
                    GUI_RESOURCE MyReader.qrc )