# Annotation in 3D view (like slice view)?

**URL:** <https://discourse.slicer.org/t/annotation-in-3d-view-like-slice-view/20285>\
**Category:** Development\
**Created:** [October 21, 2021, 1:19pm UTC](https://discourse.slicer.org/t/annotation-in-3d-view-like-slice-view/20285 "2021-10-21T13:19:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![hherhold](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/hherhold/32/12199_2.png) [@hherhold](https://discourse.slicer.org/u/hherhold)\
**Post date:** [October 21, 2021, 1:19pm UTC](https://discourse.slicer.org/t/annotation-in-3d-view-like-slice-view/20285/1 "2021-10-21T13:19:14Z")

</div>

Is there a way (in python is fine, doesn’t need to be a feature add) to add an annotation to the bottom left (or right, or top; any corner, really) of the 3D view? This post: [Display text in a 3D view](https://discourse.slicer.org/t/display-text-in-a-3d-view/13018) seems to talk about a Corner Annotation module, but it looks like that has been deprecated. Mostly looking for something like the label in the slice view:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/9/3/935924a247395fa821234230e95e3c0046f683b1.jpeg)

Thanks!!!

---

<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:** [October 21, 2021, 5:59pm UTC](https://discourse.slicer.org/t/annotation-in-3d-view-like-slice-view/20285/2 "2021-10-21T17:59:43Z")

</div>

You can probably find a way to make this work. I’ve never tried changing them but here’s the code where they are implemented. If you really only need this once you could just edit the code with the annotation you want and restart Slicer.

> <https://github.com/Slicer/Slicer/blob/master/Modules/Scripted/DataProbe/DataProbeLib/SliceViewAnnotations.py#L18-L114>

---

<div class="post-metadata">

**Author:** ![mikebind](https://avatars.discourse-cdn.com/v4/letter/m/71e660/32.png) [@mikebind](https://discourse.slicer.org/u/mikebind)\
**Post date:** [October 21, 2021, 6:20pm UTC](https://discourse.slicer.org/t/annotation-in-3d-view-like-slice-view/20285/3 "2021-10-21T18:20:36Z")

</div>

I do this all the time to better label screenshots. Here is the code I use which could be pasted into the logic of your own module or taken apart to use in the interactor. As it is, it adds a text label in the upper left and upper right of all slice views and the first 3D view, though it’s probably obvious how to customize it to do any simple variation on that.

```auto
def addCornerAnnotation(self, textToAdd, textColor=(0,1,1)):
    ''' Add annotation to upper right and upper left of slice views and 3D view'''
    lm = slicer.app.layoutManager()
    sliceViewNames = lm.sliceViewNames()
    for sliceName in sliceViewNames:
      view = lm.sliceWidget(sliceName).sliceView()
      view.cornerAnnotation().SetText(vtk.vtkCornerAnnotation.UpperRight,textToAdd)
      view.cornerAnnotation().SetText(vtk.vtkCornerAnnotation.UpperLeft,textToAdd)
      textProperty = view.cornerAnnotation().GetTextProperty()
      textProperty.SetColor(*textColor)
      view.forceRender()
    # Same for 3D view
    view=slicer.app.layoutManager().threeDWidget(0).threeDView()
    view.cornerAnnotation().SetText(vtk.vtkCornerAnnotation.UpperRight,textToAdd)
    view.cornerAnnotation().SetText(vtk.vtkCornerAnnotation.UpperLeft,textToAdd)
    textProperty = view.cornerAnnotation().GetTextProperty()
    textProperty.SetColor(*textColor)
    view.forceRender()

  def clearCornerAnnotation(self):
    '''Removes corner annotations by placing empty strings there'''
    self.addCornerAnnotation('')

```

---

<div class="post-metadata">

**Author:** ![hherhold](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/hherhold/32/12199_2.png) [@hherhold](https://discourse.slicer.org/u/hherhold)\
**Post date:** [October 21, 2021, 7:04pm UTC](https://discourse.slicer.org/t/annotation-in-3d-view-like-slice-view/20285/4 "2021-10-21T19:04:09Z")

</div>

Perfect - THANKS!!

-Hollister
