vtkremoteview- how cliend get mouse position and notify python vtk server

I setup using paraviewwebclient and python server for vtk remote rendering. Want to learn more about how client communicatin with python server,

Now I can pass object from client to python server and get infomation from python server to client such as:

server side:

def updateResolution(self, resolution):

def getResolution(self):
    print('2222, get resolution called')
    return {'myKey': '1234'}
client side

this.session.call(‘vtk.cone.resolution.update’, [resolution])
this.session.call(‘vtk.cone.resolution.get’, []).then(
(result_resolution) => {
console.log(‘result_resolution:’, result_resolution);

      .catch((error) => {
      console.log('An error occurred:', error);
        // Handle any errors that occurred during the Promise resolution

So I basically can communicate between client and server, a lot of thing can do. But I couldnot find out, how javascript client can get mouse click position, and pass this event to python server, the python server can retrieve some information -----for example in case of image slice, return the image intensity value.( I operate on mouse event and overide interactor call back in C++ many times, for vtk.js client rendering, I can do this too). But I couldn’t find out how to do this javascrip/vtkremote rendering.
Thanks, I am appreciated for any example, any help


Let me update, on python side, if override mouse vtkWebMouseHandler, and register this protocol, I can get mouse screen corodinate from interactor, I then can get world cordinate. As long as in python or C++, I can figure it out.

class coneWebMouseHandler(protocols.vtkWebMouseHandler):

def __init__(self):
    self.x = None
    self.y = None
    self.interactor = None
def mouseInteraction(self, event):
    RPC Callback for mouse interactions.
    global renderer, renderWindow, renderWindowInteractor, cone, mapper, actor
    self.x = event['x']
    self.y = event['y']
    print(f"111 mousee interaction x={self.x}, y = {self.y} ")
    event_pos = renderWindowInteractor.GetEventPosition()
    print(f"222 render interactor x={event_pos[0]}, y = {event_pos[1]} ")

Again, how can I tell what I got from this mouse handler to client side. So far, I can let client to make session.call to get this corordinate, but this information should be poplute to client as long as mouse click.

This is the style that get set within the RemoteView in vtk.js

Thank you. But I am not able to make vtk.js work for remote rendering. I can only make one remote rendering example work ( dmreagan/vtk-remote-render: A simple example of a ParaViewWeb remote renderer. (github.com).

So what is the good way to use paraviewwebclient to get mouse event position, so can use vtkPicker to pick object and so on.

Now I can use interactor in python serve to process, then publish the information, client subscribe to get information automatically.

Sorry I thought you were using that example vtk.js

Another example of a full app using it is here as well.

The paraviewweb repo is deprecated. Everything that matter is now part of VTK or ParaView for the server side and vtk.js with wslink for the client side.

For simple, yet powerful solution, we tend to directly use trame which is part of the VTK/ParaView Web framework but superseed what we use to do when we develop the client and server separately for building an app.

1 Like