[Paraview] Insert text source into view in a script
M. Nawijn
nawijn at gmail.com
Wed Jul 15 16:01:11 EDT 2009
Hello,
I am a newbie in Paraview Python scripting, so I apologize upfront if
this is a trivial question.
I am processing a set of datafiles obtained from an optical
measurement system. I so far succeeded in loading the data file,
adding a color legend and storing the resulting view in a image file.
Sample code is posted below.
What I would like to do next is add a text source to the view to
provide some contextual information about the data (in particular the
external load level at which the data was captured). I managed to add
a text source to an "empty" view (so without first reading the data),
but I cannot find a way to have the data and text source together.
Can someone explain how I can add this to the view?
Kind regards,
Marco
#==== What I have so far ===================================================
from paraview.simple import *
lt = MakeBlueToRedLT(-1.0, 1.0)
bar = servermanager.rendering.ScalarBarWidgetRepresentation()
bar.LookupTable = lt
bar.LabelColor = [0.0, 1.0, 0.0]
bar.Title = r'W [mm]'
bar.TitleColor = [0.0, 1.0, 0.0]
bar.LabelFontSize = 14
bar.AspectRatio = 15.0
bar.AutomaticLabelFormat = 0
reader = XMLUnstructuredGridReader(FileName='disp-stage-%d.vtu' % 17)
Show()
#UpdatePipeline()
view = GetActiveView()
view.Background = [0,0,0]
ResetCamera(view)
view.UseOffscreenRenderingForScreenshots = 0
dp = GetDisplayProperties()
dp.ColorArrayName = 'W'
rep = GetRepresentation()
rep.LookupTable = lt
view.Representations.append(bar)
load = 100.0
# Don't know how to get this into the view
text = Text()
text.Text = "Load %6.3f" % load
# Image does not show the text
WriteImage('test.png')
More information about the ParaView
mailing list