[vtkusers] vtkTextActor (Was vtkFollower/vtkVectorText and SetScale Problem...)

Vladan Bato vbato at ieee.org
Thu Jul 15 05:54:14 EDT 2004


Andrea Gavana wrote:
> Hello NG,
> 
>       thanks for all the suggestions regarding vtkVectorText and vtkTextActor. 
> I think I found the problem on the code, but I don't know the solution. I post 
> here a simple Python code that reproduce the problem, together with a small VTK 
> file (needed for the position of my wells in my 3D grid). If someone of you 
> would like to run the code and tell me what is wrong, that could help me A LOT. 
> I'm crashing my head on a wall.

The probelm you have is due to the fact that scaling the actor changes 
its coordinates. Since you put the text actor where the wells were 
*before* scaling, it is in the wrong position.

The problem could be easily solved by just scaling the text actor 
position by the same factor. I however think that you shouldn't scale 
the wells actor, but the input data instead. The reason for this, is 
that the geometry of the tubes is scaled too. You might not notice this 
if you scale only the Z axis, but try a scale of (6.0,1.0,1.0) and see 
what happens. The tubes are now flat on one side!

The approach I use, is to scale the input data at the start of the 
pipeline with a vtkTransform and vtkTransformFilter. This way the tubes 
are always nice and round. You can then use the same vtkTransform to 
scale the coordinates of the text actor. I'm attaching a modified 
version of your python code that does this.

Notice, however, that all the coordinates will be scaled so you must 
always convert between *real* and scaled ones. If for example you use
vtkCubeAxesActor2D, you will have to use the scaled coordinates, but set 
the ranges for the axes manually, with the original bounds.

N.B. If you want to change the scale more than once, always call 
vtkTransform.Identity() before vtkTransform.Scale(), as the effects of 
Scale() are cumulative.

I hope this helps,

-- 
Vladan Bato
vbato at ieee.org
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: modified.py
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20040715/77dd8f49/attachment.txt>


More information about the vtkusers mailing list