jone
March 18, 2021, 9:06am
1
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!
jourdain
(Sebastien Jourdain)
March 18, 2021, 5:26pm
2
I think your issue is related to the fact that Y needs to be swap. (y=0 => bottom)
1 Like
jone
March 19, 2021, 1:21am
3
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!
jourdain
(Sebastien Jourdain)
March 22, 2021, 9:13pm
4
I would think so, just need to pick the right selection object.
jone
March 23, 2021, 12:29am
5
But I’ve only found a way to select point and cell, and maybe map from there to the whole object, right?
jourdain
(Sebastien Jourdain)
March 23, 2021, 3:16pm
6
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.