How to select one of multiple data sources?

Hi, experts!
I tried to use SelectSurfaceCells() to select one of several data sources and found that it was not what I expected. The following code do not get the same source, assuming I selecte the same source:

selectedRepresentations = vtk.vtkCollection()
selectionSources = vtk.vtkCollection()
region = [int(x),int(y),int(x),int(y)]
self.renderview.SelectSurfaceCells(region,selectedRepresentations, selectionSources)
self.source = selectionSources.GetItemAsObject(0)
self.source1 = simple.GetActiveSource()

How do you use select to get a data source like source1? I am very confused. Hope to get your help!

Source is an IDselectionSource. This is different from source1. Is there a way to get source1 directly by selecting it?

Or can we get the data source through its VTKSMRepresentationProxy?

Perhaps with a solution, I could take the ID of the VTKSMRepresentationProxy I got and compare it with the VTKSMRepresentationProxy of all the sources, and then get the data source I wanted.
I don’t know if this isn’t the best solution to the problem, right?

Please clarify:

  1. What are you trying to do
  2. What have you been able to achieve
  3. What is not working

I want to use the mouse click location to get one of the multiple data sources in the pipeline, and then do something to the selected data source, such as clip.

I’ve used the Pick() method in VTKSMRepresentationProxy to get the representation of the data source(VTKSMRepresentationProxy) I want to select. I get the source by comparing the global ID of the source’s representation with the global ID of all the source’s representations in the pipeline. I think this approach may be one way, may not be the best.

That was my initial question. The source I get from using selectSurfaceCells () is an IdSelectionSource. I don’t think it’s an active source because it can’t be used with filters.

I hope this clarifies my problem.

Yes, this is very clear. You are trying to select an active source by clicking on it in the render view.

I’ve used the Pick() method in VTKSMRepresentationProxy to get the representation of the data source(VTKSMRepresentationProxy) I want to select. I get the source by comparing the global ID of the source’s representation with the global ID of all the source’s representations in the pipeline. I think this approach may be one way, may not be the best.

Correct, but this should work.

That was my initial question. The source I get from using selectSurfaceCells () is an IdSelectionSource. I don’t think it’s an active source because it can’t be used with filters.

The IDSelectionSource should ave an input, this should be the correct source you are looking for.

Indeed. But I did not find a way to get the input of the idSelectionSource, so I chose to use Pick().
Thank you very much for your reply!

the representation proxy’s “Input” is indeed what you’re looking for. Something like the following should do the trick:

...

smdisplay = selectedRepresentations.GetItemAsObject(0)
display = servermanager._getPyProxy(smdisplay)
source = display.Input