I am trying to implement a mouse interaction wherein the user clicks on a model from the 3D viewer and the model which was clicked is made available so that it can be modified in some way (such as colour change, etc.). I was able to find a similar example here from the VTK examples page but have not been able to reproduce the behaviour with vtkMRMLModelNodes within Slicer.
Hi Andras,
Is the modelnode selection function available.
I have a model and selected nodes with using fiducials. Is there a way to left mouse click the fiducial and save that fiducial coordinates. For example if the user has model and selected nodes but the user needs the location of only few control points. is it possible to get the location by only left mouse click on the fiducial.
Iâd probably try to use the PointEndInteractionEvent event to get notified about the click, and by getting the active control point index you know which one was clicked.
Hi,
I am having trouble with connecting mouse click.
How can I attach the mouse click event with this method or may be I am understanding it wrong.
in main process code I have
markupsNode = slicer.util.getNode(inputFiducial.GetID())
print(markupsNode)
markupsNode.AddObserver(slicer.vtkMRMLMarkupsNode.PointEndInteractionEvent, self.onMarkupEndInteraction)
You didnât say anything about what the problem was, but from the code you pasted (which is identical to what we can see in the script repository) the problem I see is that you added an argument self to the onMarkupEndInteraction function, which wonât work outside of a class. Of course I can make assumptions all day but it would be easier if you told us what is the problem. Thanks.
Hi Pinter,
I have the markup control points already defined for the model nodes. I want a program where user can click on the markup point and can get the node number along with the x,y,z coordinates.
Hi,
I got the control point I am clicking but why it is printing it multiple times. here are the lines of code.
In the main def process:
markupsNode = slicer.util.getNode(inputFiducial.GetID())
markupsNode.AddObserver(slicer.vtkMRMLMarkupsNode.PointEndInteractionEvent, self.onMarkupEndInteraction)
in the method within the class, def
def onMarkupEndInteraction(self, caller, event): #print(âinsideâ)
markupsNode = caller
sliceView = markupsNode.GetAttribute(âMarkups.MovingInSliceViewâ)
movingMarkupIndex = markupsNode.GetDisplayNode().GetActiveControlPoint()
print(movingMarkupIndex)
I am having problem with the slicer everytime I reload the application is not reloading properly to show the changes in the code i have to restart the slicer every time i do changes in the code so that it reflects inside the slicer application.
Any thing how i can fix this?
If I understand correctly you successfully solved the problem in this topic. Correct?
Your next question is unrelated, but as a quick advice, you can use the Reload button on the top of your module UI, or add some code to your .slicerrc.py so that Slicer sets up your scene correctly before continuing with testing/development. If you have more questions about this please do a search in the forum first then open a new topic if you donât find an answer.