How to access to a plugin properties panel?

Hi,

I would like to develop a plugin based on VTKPythonAlgorithmBase.
This plugin take as input a vtkDataset and 3 coordinates representing the position of a camera.

With the following code, I’ve managed to expose these 3 coordinates in Paraview’s properties panel:

    @smproperty.doublevector(name="Camera", default_values=[1, 1, 1], label="Camera")
    @smdomain.doublerange()
    def Set1_Camera(self, x, y, z):
        value = np.r_[x, y, z]
        if not np.allclose(self._camera, value) :
            self._camera = value
            self.Modified()

I also succeed in adding a button which prints the position of the camera in the output window:

    @smproperty.xml('''<Property name="Print Camera Position" command="CameraButton" panel_widget="command_button"></Property>''')
    def CameraButton(self, *args):
        import paraview.simple
        camera = paraview.simple.GetActiveCamera()
        print('Camera position : ', camera.GetPosition())  

Instead of printing the camera position in the output window, I would like to fill the properties panel with these values.
How can I access to theses properties from the CameraButton function ?

Thanks for your help,

Regards,

Loic

This is incorrect! One should not access paraview.simple module in the algorithms like so. I won’t go into details, but this is a big no-no in client-server configurations.

There’s no way to support this the way you’re implementing. The only reasonable solution would be add a custom property widget for the SetCamera property that then uses a custom pqPropertyWidget subclass that can access the active view and camera from the client side and then set the value to it. That will require C++ code, however, and cannot be done simply in VTKPythonAlgorithmBase subclass.

Could someone explain to me the reason? I develop Python algorithms (subclassing VTKPythonAlgorithmBase) that partially rely on paraview.simple. I faced one problem only (although I haven’t tested it in client-server mode yet): using Show in RequestInformation or RequestData leads to infinite recursion. On the other hand, I can use Show from a separate method, e.g. a method decorated with an XML property that creates a push button in the Properties panel. So which functions should we avoid using in a Python plugin? After a discussion with Kitware, I learnt that it is better that a Python algorithm only deals with the data management, not the GUI functionalities. But I would like to understand why this is the case.

It is a core design principle of ParaView.

server side handle data. Programmable filter are run server side.
client side handle UI. Python scripts are run client side.

Thank you. So it means that I should separate the functionalities into two: one VTKPythonAlgorithmBase-based plugin that does not rely on the client and a Python script that does the automations in the ParaView GUI.

Yes