Adding a label to an actor in VTK


I am creating a GUI with some VTK renderings. Say I want to render multiple cubes and I want to keep track of the order, I would add a label to each of the cubes signifying the order they were placed. Is it possible to add a label attribute to a vtkActor object so that when the cubes are rendered, the label is shown? Does anyone have a solution.

I would really appreciate any help.

Hi A.T.! I think you’ll need separate actors for that. You can use vtkFollower! I successfully used it to label wells in a geoscientific application.

Take a look at the following examples:



Thank you so much Luca! vtkFollower is perfect! Do you know how to specify the coordinates of the vtkFollower text so that it doesn’t intersect/ get obscured by the object I am trying to annotate?

Many thanks!

I have the same problem with the labels associated with my objects. So far I have not found a solution to that… It seems the labels generated by vtkFollower are positioned near the point you provide to the actor. In fact, the labels are a polygonal representation of the text, that is, a 3D Object. So, if another object is closer to the camera it will appear in front of the text.

A friend told me that vtkCaptionActor2D works well for him. I haven’t implemented it myself, but I thought I should tell you.

Thanks so much for your help Luca!

You are welcome.:slightly_smiling_face: