# Display text near points

**URL:** https://discourse.slicer.org/t/display-text-near-points/20960
**Category:** Development
**Created:** [December 8, 2021, 2:49am UTC](https://discourse.slicer.org/t/display-text-near-points/20960 "2021-12-08T02:49:31Z")
**Posts on this page:** 3
**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 8, 2021, 2:49am UTC](https://discourse.slicer.org/t/display-text-near-points/20960/1 "2021-12-08T02:49:31Z")

</div>

Hi,

I’m looking for a way to display text at each point from point cloud. In the best scenario the text should have the constant size regardless of the distance between camera position and point and the text should be faced to the camera. Something similar to [LabeledDataMapper vtk example](https://kitware.github.io/vtk-examples/site/Cxx/Visualization/LabeledDataMapper)

Is `vtkLabeledDataMapper` the right choice? I guess in that case I would need to implement custom displayable manager right?

---

<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:34am UTC](https://discourse.slicer.org/t/display-text-near-points/20960/2 "2021-12-14T02:34:14Z")

</div>

Solved that with `vtkCaptionActor2D`. I’ve found it [by the link](https://discourse.vtk.org/t/how-to-fix-the-font-actor-size-that-is-the-font-size-does-not-change-when-the-camera-distance-is-changed/2965).  
`vtkCaptionActor2D` neither affected by zoom nor by inequal aspect ratio. Thus it is pretty good for me.

Adding observers to caption actor allows to react on events like `TransformModifiedEvent` (when the node is transformed/moved for example), or `DisplayModifiedEvent` (when visibility of node is changed).

This is implemented in displayable manager thus `::OnMRMLSceneNodeAdded()` and `::OnMRMLSceneNodeRemoved()` maybe used to create/delete caption actor when necessary.

![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/2/f/2fc6712fa58b9fed05d659f22dddd4b59266452c.png)

Also there is a `vtkMRMLNode::IDChangedEvent` but no `NameChanged` am I right? Or there is something different that may be used when the node’s name is changed?

---

<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:23pm UTC](https://discourse.slicer.org/t/display-text-near-points/20960/3 "2021-12-14T18:23:33Z")

</div>

> [@keri](#):
>
> Also there is a `vtkMRMLNode::IDChangedEvent` but no `NameChanged` am I right? Or there is something different that may be used when the node’s name is changed?

When there’s no fine-grained event to observe you can typically just observe `ModifiedEvent`. If you end up getting too many events from that you could propose to add a more specialized event.
