ParaviewWeb selection error

I want to pick a cell on the client side.First, I get the position of the mouse click on the canvas, using the following methods:

var rect = canvas.getBoundingClientRect();
var x= event.clientX - rect.left * (canvas.width / rect.width);
var y= event.clientY - rect.top * (canvas.height / rect.height);

Then call the server-side protocol:

@exportRPC("pvwsdprotocol.pick.point")
def pickCone(self, positionx, positiony):
selection.SelectSurfaceCells(Rectangle=[positionx,positiony,positionx,positiony])
self.getApplication().InvokeEvent('UpdateEvent')

But the results are not precise. Does the canvas position contradict the SelectSurfaceCells parameter requirement? Thank you for you help in advance!

I think your issue is related to the fact that Y needs to be swap. (y=0 => bottom)

1 Like

After the modification, it really works!
I want to ask, is there a way to select the whole object?Just like the PropPicker in VTK. Thanks again for your guidance!

I would think so, just need to pick the right selection object.

But I’ve only found a way to select point and cell, and maybe map from there to the whole object, right?

You should ask on the main ParaView topic “How to perform actor/block selection from Python?”.
I know that is possible but I will have to dig into the code to see how to do it as I don’t know it on top of my head.