Adding a label to an actor in VTK

(A.T.) #1

Hi,

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.
Thanks.

(Luca Pallozzi Lavorante) #2

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:

https://lorensen.github.io/VTKExamples/site/Cxx/Modelling/FinanceFieldData/
https://lorensen.github.io/VTKExamples/site/Cxx/Annotation/TextOrigin/

Greetings

Luca

(A.T.) #3

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!

(Luca Pallozzi Lavorante) #4

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.T.) #5

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!

(Luca Pallozzi Lavorante) #6

You are welcome.:slightly_smiling_face: