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

Andrea Gavana andrea.gavana at polymtl.ca
Thu Jul 15 05:04:28 EDT 2004


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.

What the Python code does, is as follows:

1) Create a Tube Actor (to represent the wells, here called "profileactor"), it 
reads the coordinates from the file "mywells.vtk" attached here.
2) Create a vtkTextActor with the name of the first well in the grid.

If you use profileactor.SetScale(1.0,1.0,1.0), the position of the vtkTextActor 
is correct. Once you change it (try profileactor.SetScale(1.0,1.0,6.0), you 
loose the correct text position. Notice that the text is gone UP, far above the 
well position.

I attach the vtk file with the well's position.

Could anyone please tell me what I'm doing wrong?

Thank you a lot.
Andrea.

(SORRY I MISSED THE PYTHON CODE!!!!)


# BEGIN PYTHON CODE
import vtkpython

profileTubes = vtkpython.vtkTubeFilter()
profileTubes.SetRadius(70.0)

reader = vtkpython.vtkPolyDataReader()
reader.SetFileName("mywells.vtk")

profileTubes.SetNumberOfSides(80)
profileTubes.SetInput(reader.GetOutput())

profileMapper = vtkpython.vtkPolyDataMapper()
profileMapper.SetInput(profileTubes.GetOutput())

profileactor = vtkpython.vtkActor()
profileactor.SetMapper(profileMapper)
    
profileactor.GetProperty().SetColor(1,1,0)
profileactor.GetProperty().SetInterpolationToGouraud()
profileactor.GetProperty().SetBackfaceCulling(0)
profileactor.GetProperty().SetSpecular(.9)
profileactor.GetProperty().SetSpecularPower(10.0)
profileactor.GetProperty().SetAmbient(1.0)

# TRY TO CHANGE THE SCALE HERE AND SEE WHAT HAPPENS...
profileactor.SetScale(1.0,1.0,6.0)


# NO MATTER WHAT YOU DO ON textActor, ITS POISTION IS LOST
# ONCE YOU CHANGE THE SCALE OF THE TUBES

textActor = vtkpython.vtkTextActor()
textActor.ScaledTextOn()
textActor.SetScaledText(1)
textActor.SetInput("SE01")
textActor.SetWidth(0.03)

# NO MATTER WHAT YOU DO ON textActor, ITS POISTION IS LOST
# ONCE YOU CHANGE THE SCALE OF THE TUBES
textActor.ScaledTextOn()
textActor.SetScaledText(1)
textActor.SetMaximumLineHeight(0.5)

textActor.GetPositionCoordinate().SetCoordinateSystemToWorld()
textActor.GetPositionCoordinate().SetValue(14987.1376, -3008.2773, 4488.7157)
textActor.GetPositionCoordinate().SetCoordinateSystemToWorld()

hirenWin = vtkpython.vtkRenderWindow()
hiren = vtkpython.vtkRenderer()

hiren.AddActor(textActor)
hiren.AddActor(profileactor)

hiren.SetGlobalWarningDisplay(0)
hirenWin.AddRenderer(hiren)

iren = vtkpython.vtkRenderWindowInteractor()
iren.SetRenderWindow(hirenWin)
style = vtkpython.vtkInteractorStyleTrackballCamera()
iren.SetInteractorStyle(style)

iren.Initialize()
iren.Start()

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: mywells.vtk
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20040715/f036385f/attachment.asc>


More information about the vtkusers mailing list