vtkSIProxy doesn't find my custom widget representation.

I am developing a custom widget using widget/representation design pattern inside a ParaView plugin.
I have representation, widget, and xml which exposes them to the server. But I still got

[paraview ] vtkSIProxy.cxx:422 ERR| vtkSIProxy (000002868960E060): Failed to create 'vtkMyAnnotationRepresentation'. This typically means that ParaView does not know about the request class to create an instance of if. Ensure that it has been correctly wrapped using the client-server wrappers and the wrapping has been initialized. Note class names are case-sensitive. Check for typos. Aborting for debugging purposes.

First, I have my XML file.

MyWidget.xml

<ServerManagerConfiguration>
  <ProxyGroup name="representations">
    <NewWidgetRepresentationProxy class="vtk3DWidgetRepresentation"
                                  name="MyAnnotationWidgetRepresentation">
      <IntVectorProperty command="SetEnabled"
                         default_values="0"
                         name="Enabled"
                         number_of_elements="1">
        <BooleanDomain name="bool" />
        <Documentation>Enable/Disable widget interaction.</Documentation>
      </IntVectorProperty>
      <SubProxy>
        <Proxy name="Prop"
               proxygroup="3d_widget_representations"
               proxyname="MyAnnotationRepresentation"></Proxy>
        <ExposedProperties>
          <Property name="PlaceWidget" />
          <Property name="Visibility" />
          <Property name="HandlePositions" />
          <Property name="HandlePositionsInfo" />
          <Property name="Closed" />
          <Property name="LineColor" />
          <Property name="CurrentHandleIndex" />
          <Property name="CurrentHandleIndexInfo" />
        </ExposedProperties>
      </SubProxy>
      <SubProxy>
        <Proxy name="Widget"
               proxygroup="3d_widgets"
               proxyname="MyAnnotationWidget"></Proxy>
      </SubProxy>
      <!-- End of PolyLineWidgetRepresentation -->
    </NewWidgetRepresentationProxy>
  </ProxyGroup>

  <!-- Define representation for the widget  -->
  <ProxyGroup name="3d_widget_representations">
    <Proxy class="vtkMyAnnotationRepresentation"
           name="MyAnnotationRepresentation">
      <Documentation>Representation for poly line source.</Documentation>
    </Proxy>
  </ProxyGroup>

  <!-- Define 3D widget -->
  <ProxyGroup name="3d_widgets">
    <Proxy base_proxygroup="3d_widgets"
          base_proxyname="WidgetBase"
          class="vtkMyAnnotationWidget"
          name="MyAnnotationWidget"></Proxy>
  </ProxyGroup>

  this is where I use MyAnnotationWidget
  <ProxyGroup name="sources">    
    <SourceProxy name="MyDummySource"
                 class="vtkDummySource">
      <DoubleVectorProperty command="SetPoint"
                            default_values="0 0 0 1 0 0"
                            name="Points"
                            number_of_elements="6"
                            number_of_elements_per_command="3"
                            repeat_command="1"
                            set_number_command="SetNumberOfPoints"
                            use_index="1">
      </DoubleVectorProperty>
      <IntVectorProperty command="SetClosed"
                         default_values="0"
                         name="Closed"
                         number_of_elements="1">
        <BooleanDomain name="bool" />
      </IntVectorProperty>
   
      <PropertyGroup label="Annotation widget" panel_widget="my_annotation_widget">
        <Property function="HandlePositions" name="Points" />
        <Property function="Closed" name="Closed" />
      </PropertyGroup>

    </SourceProxy>
  </ProxyGroup>
</ServerManagerConfiguration>

Next I have vtkMyAnnotationWidget.h/cxx and vtkMyAnnotationRepresentation.h/cxx (in this example, they are the same as vtkPolyLineWidget and vtkPolyLineRepresentation)

Then, I have pqMyAnnotationWidget.h/cxx which are the same as pqSplinePropertyWidget except that in the constrcutor widget_smname is set to MyAnnotationRepresetation.

CMakeLists.txt of vtk module


paraview_add_server_manager_xmls (
XMLS MyWidget.xml)

Set(classes 
  vtkMyAnnotationRepresentation
  vtkMyAnnotationWidget
)

vtk_module_add_module(VTK::MyPlugins
  CLASSES ${classes}
)

CMakeLists.txt of plugin

set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
list(APPEND CMAKE_AUTOUIC_SEARCH_PATHS
  "${CMAKE_CURRENT_SOURCE_DIR}/Qt/UI")

set(ui_files)
set(qrc_files)
set(sources)
set(interfaces)

# add ui files
list(APPEND ui_files 
        Qt/UI/pqMyAnnotationWidget.ui
)

# add widget interface
list(APPEND sources
       Qt/pqMyAnnotationWidget.cxx
       Qt/pqMyAnnotationWidget.h
)

paraview_plugin_add_property_widget(
        KIND GROUP_WIDGET
        TYPE "my_annotation_widget"
        CLASS_NAME pqMyAnnotationWidget
        INTERFACES property_interfaces
        SOURCES property_sources)
list(APPEND interfaces
        ${property_interfaces})
list(APPEND sources
        ${property_sources})

paraview_add_plugin(MyPVPlugin
  REQUIRED_ON_CLIENT
  REQUIRED_ON_SERVER
  VERSION "1.0"
  UI_FILES ${ui_files}
  UI_INTERFACES ${interfaces}
  UI_RESOURCES ${qrc_files}
  SOURCES ${sources}
  MODULES VTK::MyPlugins
  MODULE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/vtk.module"
  XML_DOCUMENTATION OFF)

I managed to get this far by reading the source code portion regarding how widget and representation is created. But I am not sure why the server is still not aware of vtkMyAnnotationRepresentation. What am I missing here?

Thanks,
Cam

Do you list as a dependency (in both your CMakeLists.txt and paraview.plugin files) the library containing the base class your widget inherits? If not, the wrapping generated may be empty. This has bitten me a few times. You should look in your build directory for the fooClientServer.cxx source code (where “foo” is your widget’s class name) and verify it is not empty.

1 Like

Hi David,

Thank you so much. I added VTK::InteractionWidgets which is the module contains the base class of my widget. Now everything works as expected. But how did it pass compilation though?

Cam

The problem is that sometimes the base class should be ignored as many classes should not be wrapped at all; if the wrapper complained whenever a base class was ignored, you would be swamped with irrelevant warnings and the build would be significantly slower. But we should definitely provide some way to ensure warnings are emitted when some classes are not wrapped.

1 Like

Thanks for the explanation. So the vtk_module_add_module behaves differently when you add representations other than other vtkObjects? What normally happens to me is that, if I don’t include the VTK::MODULE where the base class exists, the intellisense will complain about not finding the header of my base class and for sure it will not compile after the project has been configured.