qSlicerMarkupsPlaceWidget - Get control point coordinates


I’m building a module for Slicer and using qSlicerMarkupsPlaceWidget() to let the user place a control point on the image. The ideia is just to get the coordinates of this control point, but I’m not sure how to acces this information and store it. I would appreciate some help.

Thanks in advance.

There is a Script repository that contains hundreds of little code examples, including this: Script repository — 3D Slicer documentation

Btw I just posted a piece of code in another thread that among other things gets the position of a control point. You could use it as inspiration. Here it is: Exporting a model to STL with markups - #2 by cpinter

1 Like

@cpinter Great it worked just fine, and the repository will help me a lot, huge thank you!

1 Like

Sorry I put the wrong link in my comment. I fixed it in case someone needs it in the future.

@cpinter I having trouble to understand one thing. On the script you mentioned from the other thread, on this line fiducialNode = getNode('F') your node name is ‘F’, so if there’s n control points they all would be on node F?

On my case, I need to get the coordinates from a user inserted control point (they can only insert one, but I will deal with that later). Is there a way to get the coordinates without having to pass the name of the node? If we suppose that there’s only one.

Edit: I have one more question, how can I get the coordinates in pixels?

You need to get the node somehow so that you can do operations on it. If you are sure you only have one node, you can use this function Slicer: vtkMRMLScene Class Reference
Feel free to look at other scripted modules for inspiration. They all use nodes.

See here: Script repository — 3D Slicer documentation
The script repository is a very valuable resource, I recommend that too.