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
# -*- coding: utf-8 -*-

from paraview.simple import *

# color of the min value for Diverging
r=0.137255
g=0.239216
b=0.709804
# color of the max value for Diverging
r2=0.67451
g2=0.141176
b2=0.12549

stress = OpenDataFile( "stress.vtu" )

RenderView1 = GetRenderView()

DataRepresentation1 = Show()

RenderView1.CameraPosition = [-3.344502565751366, -21.258337353433895, 8.954519352664377]
RenderView1.CameraFocalPoint = [8.46943833484162, 3.0789531522629443, 2.692573262549846]
RenderView1.CameraViewUp = [0.07529291822539243, 0.21403873058575418, 0.9739190922629781]
RenderView1.CameraParallelScale = 8.696263565463044

# Set the field to display
ColorBy(DataRepresentation1, ("POINTS", 'SIGM'))

# Add the scalar bar
DataRepresentation1.SetScalarBarVisibility(RenderView1, True)
DataRepresentation1.RescaleTransferFunctionToDataRange(True)

# Display the 3rd component
id_comp = 2
lookup_table = GetColorTransferFunction('SIGM')
lookup_table.VectorMode = 'Component'
lookup_table.VectorComponent = id_comp

# The following lines are needed for Paraview 4.3.1

## 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)

Render()
_______________________________________________
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

Reply via email to