I want to create a feature that interacts with a modelNode through the mouse. Specifically, when the mouse hovers over a model, I want its color to change, and when clicked, I want the camera to center on that model.
I have come across several similar questions, but I couldn’t find a solution, and some of the example links were invalid.
I thought knowing the mouse (cursor) position would be the starting point, so I found the following code that allows me to get the mouse coordinates:
for viewName in [“View1”]:
threeDView = slicer.app.layoutManager().threeDWidget(viewName).threeDView()
tag = threeDView.interactor().AddObserver(vtk.vtkCommand.MouseMoveEvent , lambda caller, event, viewName=viewName: onMouseMoved(viewName))
However, I am having difficulty determining if the mouse is over a specific model with these coordinates (do I need to write code to compare the coordinates with all points of the model? This seems to take too long).
I believe that the features I mentioned are already implemented in the markups module. Therefore, I would appreciate it if you could provide a code snippet or some tips.