# Working with markups

**URL:** https://discourse.slicer.org/t/working-with-markups/21023
**Category:** Development
**Created:** [December 12, 2021, 1:18am UTC](https://discourse.slicer.org/t/working-with-markups/21023 "2021-12-12T01:18:04Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![keri](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/keri/32/11618_2.png) [@keri](https://discourse.slicer.org/u/keri)
#### Post date: [December 12, 2021, 1:18am UTC](https://discourse.slicer.org/t/working-with-markups/21023/1 "2021-12-12T01:18:04Z")

</div>

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:

```cpp
  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:

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

```

Appreciate for advice.

---

<div class="post-metadata">

### Author: ![keri](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/keri/32/11618_2.png) [@keri](https://discourse.slicer.org/u/keri)
#### Post date: [December 14, 2021, 2:46am UTC](https://discourse.slicer.org/t/working-with-markups/21023/2 "2021-12-14T02:46:47Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)
#### Post date: [December 14, 2021, 6:25pm UTC](https://discourse.slicer.org/t/working-with-markups/21023/3 "2021-12-14T18:25:58Z")

</div>

> [@keri](#):
>
> 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.

---

<div class="post-metadata">

### Author: ![keri](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/keri/32/11618_2.png) [@keri](https://discourse.slicer.org/u/keri)
#### Post date: [December 18, 2021, 12:22am UTC](https://discourse.slicer.org/t/working-with-markups/21023/4 "2021-12-18T00:22:47Z")

</div>

[Added the PR](https://github.com/Slicer/Slicer/pull/6085)
