Working with markups

Hi,

My understanding about markups is pretty limited and I don’t have much experience yet.

From C++ I need to visualize points of constant size regardless of the zoom.
Probably it would be pretty nice if every point could have its name and multiple points are set in the list with the ability to add/delete points.
Also the points must be undraggable by user (locked).

I think I could try to use markups especially vtkMRMLMarkupsNode with LockedOn() method enabled. I have made some attempts to avoid using vtkMRMLMarkupsModuleLogic and instead I linked to vtkSlicerMarkupsModuleMRML. The code that I used:

  vtkNew<vtkMRMLMarkupsNode> mNode;
  mNode->SetCenterPosition(0, 0 0);
  mNode->LockedOn();

  this->GetMRMLScene()->AddNode(mNode);
  mNode->CreateDefaultDisplayNodes();

but the application has broken when I triggered this function.

Do I need to use markups logic instead? Or something like:

vtkSmartPointr<vtkMRMLMarkupsNode> mNode = 
vtkMRMLMarkupsNode::SafeDownCast(
this->GetMRMLScene()->AddNewNodeByClass("vtkMRMLMarkupsNode"));

Appreciate for advice.

To solve this problem I needed to use vtkMRMLMarkupsFiducialNode instead.

The class is pretty straightforward: each instance of that class stores points of type vtkMRMLMarkupsNode::ControlPoint wich is a struct with some fields like name, description, locked etc.
One may add/remove points and there are events when point added or removed.

One nuance:
is it possible to add event like PointAboutToBeRemovedEvent? When I use PointRemovedEvent I get index of a point that is already deleted so I cannot retrieve insformation about deleted point (like name or description).
I can’t say that I’m stuck with that as when I’was struggling with markups my logic used to poor and now I have found a better solution for my use case that doesn’t involve using markups events. But probably in the future this PointAboutToBeRemovedEvent will help me.

That sounds like a reasonable event to add. If you want to make a PR we can review.

1 Like

Added the PR