Adding a custom 3D Widget to a ParaView plugin

Hello,

I am working on a project where I need an interactive widget in a custom plugin within ParaView. My plugin is C++ based (built with CMake) and will be loaded into ParaView (built from source). The end goal here is to use two input datasets where one is used to generate the 3D widget, and then through user interaction of the widget, modify the other dataset. However, I’m not sure where to begin! Are there examples or resources for how to

  1. build custom 3D widgets for interacting with the ParaView viewport
  2. adding 3D interactive widgets to C++ based plugins
  3. initializing widgets with data from an input port within the plugin

Thanks in advance!

So widget in the VTK sense, not the Qt sense ?

Definitely not an easy unless you already know about VTK widgets.
Starting point would be to take a look into the design of existing widgets in VTK.

Modern widgets uses a widget/representation duality. You can take a look at
VTK/Interaction/Widgets/vtkLightWidget\Representation

Once you are implemented your widget, you need to expose it into ParaView: Remoting/Views/Resources/3dwidgets_remotingviews.xml
and
Qt/ApplicationComponents/pqLightPropertyWidget.cxx

All this can be done in a plugin with a design similar to Examples/Plugins/PropertyWidget

hth.

Thank you so much for the quick response! This helps a lot.

In the file Qt/ApplicationComponents/pqLightPropertyWidget.cxx \ line 33, where does the file ui_pqLightPropertyWidget.h get included from?

Edit: forgot the critical qt5_wrap_ui(ui_srcs pqLightPropertyWidget.ui) line in the CMakeLists.txt

1 Like

Alright, so I have what I think is a pretty good handle on creating custom widgets and running them in ParaView. Now the third point on my initial post is where I am held up. Within my filter, I have a vtkPolyData coming in on port 1 (I have 2 ports each with their own vtkPolyData, but I am focusing on the second one here) which I would like to use to initialize the representation of my widget with.

For ease of illustration, let’s say the vtkPolyData on port 1 is just a poly line, and I would like to initialize the customized vtkPolyLineRepresentation defining the widget with that poly line.

From what I’ve gathered, the interfacing class vtk3DWidgetRepresentation specifically has zero input ports interfacing with the ParaView pipeline. Within my ServerManagerConfiguration xml file, I have this widget representation proxy setup pointing at the default vtk3DWidgetRepresentation class:

 <ProxyGroup name="representations">
   <NewWidgetRepresentationProxy class="vtk3DWidgetRepresentation"
                                 name="MyPolyLineWidgetRepresentation">
    ...
  </NewWidgetRepresentationProxy>

And under this configuration, everything runs in paraview, though with the default behavior of an uninitialized poly line widget.

I have tried creating a new class which inherits from vtk3DWidgetRepresentation and adding it as such:

 <ProxyGroup name="representations">
   <NewWidgetRepresentationProxy class="vtkMyPolyLineWidgetRepresentation"
                                 name="MyPolyLineWidgetRepresentation">
     ...
   </NewWidgetRepresentationProxy>

where the class vtkMyPolyLineWidgetRepresentation is a vtk3DWidgetRepresentation but with the constructor asking for two ports instead of zero. this compiles, but immediately crashes in ParaView when the plugin is selected from the Filters menu. It also immediately crashes if vtkMyPolyLineWidgetRepresentation is does nothing different, and simply calls the superclass constructor at initialization.

I’m not entirely sure where to go from here. I have investigated with reliance of vtkSMNewWidgetRepresentationProxy on vtk3DWidgetRepresentation, and I feel like my problem may be something to do with that relationship, but its possible there is also something much deeper I am missing, or something much easier I should be doing.

Thanks in advance for any advice!