[Paraview] Rescale to data range on a field's component in python in Paraview 4.3.1

Utkarsh Ayachit utkarsh.ayachit at kitware.com
Wed May 20 10:35:33 EDT 2015


Good point. If I remember correctly, the 4.2 code worked only when
doing the same through Python shell in the UI, not from
pvpython/pvbatch, is that correct?

Here's what you can do for 4.3 case:

lookup_table = GetColorTransferFunction('SIGM')

#change array component used for coloring
id_comp = 2
lookup_table.VectorComponent = id_comp
lookup_table.VectorMode = 'Component'

repr = (the display-properties/repr object from which to get the data ranges).
repr.RescaleTransferFunctionToDataRange()
lookup_table.UpdateScalarBarsComponentTitle(repr.GetArrayInformationForColorArray())

Looking at this, it may make sense to add a new API to the repr to
SetScalarColoring with ability to change the component mode.

Utkarsh


On Mon, May 18, 2015 at 9:31 AM, Christophe Bourcier
<christophe.bourcier.pv at gmail.com> wrote:
> Hi,
>
> In 4.2.0, the following code was enough to display a field's component
> instead of its magnitude and set the right scalar bar:
>
> lookup_table = GetColorTransferFunction('SIGM')
>
> #change array component used for coloring
> id_comp = 2
> lookup_table.VectorComponent = id_comp
> lookup_table.VectorMode = 'Component'
>
>
> In 4.3.1, we have to explicitly get the min and max of the field and
> change the scalar bar name:
>
> # Update the scalar bar range
> source_array = stress.PointData.GetArray("SIGM")
> comp_name = source_array.GetComponentName(id_comp)
> mini, maxi = source_array.GetComponentRange(id_comp)
> lookup_table.RGBPoints = [mini, r, g, b, maxi, r2, g2, b2]
>
> # Update the scalar bar name
> ScalarBar1 = GetScalarBar(lookup_table)
> SetProperties(ScalarBar1, ComponentTitle=comp_name)
>
> Is this a bug, or am I missing something?
>
> In attachment, a script to load in Paraview 4.2.0 and 4.3.1. The
> sample file can be downloaded here: http://bourcier.eu/stress.vtu
>
> Thanks.
>
> Christophe
>
> _______________________________________________
> 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
>
> Search the list archives at: http://markmail.org/search/?q=ParaView
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/paraview
>


More information about the ParaView mailing list