But, I don’t want to change the position of the line. The position of (1, 0, 0) indicate a position in the real world, and the line has the reality meaning.
I want to display a 3D text for the line ( (0, 0, 0), (1, 0, 0) ). How to display the 3D text?
I find the vtkVectorText can also display 3D text, but I can not change the display preporty for it: color, font size, font family. In a world, vtkVectorText do not have vtkTextProperty.
vtkTextActor3D renders the text as a texture and the texture is applied to a rectangle. Being rendered as a texture means the text is rasterized according to the font settings. Setting its font size to 2, that would mean a very small text with very few pixels tall hence the bad results.
I’d keep the txt3D.GetTextProperty().SetFontSize(20) call, but I’d rescale the txt3D actor: txt3D.SetScale(0.1). You’ll likely need to add code to compute an adequate scale factor that will fit your (0,0,0)-(1,0,0) line. Either this or use another class to render your text without involving the use of textures.
vtkVectorText can be used to generate a vtkPolyData object from a string. You won’t have texture issues, but you’ll have a more computationally expensive scene. If you expect to have too many characters in your scene, vtkTextActor3D is a better choice.
I have tried vtkVectorText, but I can’t find how to set the font size, font family, line spacing and some properties which has been provided by vtkTextProperty. Can I use vtkTextProperty for vtkVectorText?