[Paraview] Insert text source into view in a script
Utkarsh Ayachit
utkarsh.ayachit at kitware.com
Wed Jul 15 16:17:56 EDT 2009
"Text" is a data source similar to the reader. You need to "Show" it
to add it to the active view.
Just do:
load = 100.0
# Don't know how to get this into the view
text = Text()
text.Text = "Load %6.3f" % load
Show()
Utkarsh
On Wed, Jul 15, 2009 at 4:01 PM, M. Nawijn<nawijn at gmail.com> wrote:
> 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')
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the ParaView Wiki at: http://paraview.org/Wiki/ParaView
>
> Follow this link to subscribe/unsubscribe:
> http://www.paraview.org/mailman/listinfo/paraview
>
More information about the ParaView
mailing list