Hi all,
If you create a markup node(vtkMRMLMarkupsNode) and add control points to it, the control points are named using a default format(“%N-%d”) with respect to the current name of the markup node.
Renaming a markup node doesn’t modify the names of the existing control points of the respective markup. If there was any event in vtkMRMLMarkupsNode or its parents that fires when the node is renamed, I could react to it and update the labels.
I was able to achieve what I wanted using vtkCommand::ModifiedEvent; however, this event also fires for several other cases. I just wanted to ask if there was an event I missed, so that my function is not called for every vtkCommand::ModifiedEvent and is more optimized.
What would you like to achieve? Rename all the other control points if the user renames one control point (e.g., user specifies for one vertebra that it is T5 and you want to update the labels for all the others accordingly)?
Thanks for the additional information. There is no separate event for node rename, but you can easily fulfill your needs without it.
A simple option is to do a delayed update whenever a node is changed: add an observer to the Modified event of all the markup nodes you are interested and connect that to reset of a single-shot QTimer with a short timeout (500ms whenever). In the timer callback check if the markup control point names are up-to-date and update them if needed.
You can avoid this if you capture the node rename event in the GUI. For example, the qMRMLNodeComboBox widget emits a signal if the user rename the current node. You also get notified about a node rename if you add a dedicated button for it in your module GUI.
It would not be hard to implement auto-rename of control points that were named using the “default name format” whenever a node name changes; or add a node renamed event to vtkMRMLNode, but the need just has not come up frequently enough and there are alternative solutions.