[Paraview] Color by array component from Python script not working
Matei Stroila
matei.stroila at gmail.com
Thu Aug 20 18:54:27 EDT 2015
Hi,
I am using ParaView 4.3.1 on Mac OSX.
I used to be able to loop through the components of an attribute array and
change the color of the representation. I am not sure why this is no longer
working (don't recall when it was working, maybe 4.2?). It does work from
GUI. This is the GUI trace for changing the color attribute three times:
#### import the simple module from the paraview
from paraview.simple import *
#### disable automatic camera reset on 'Show'
paraview.simple._DisableFirstRenderCameraReset()
# get color transfer function/color map for 'SpeedArray'
speedArrayLUT = GetColorTransferFunction('SpeedArray')
speedArrayLUT.InterpretValuesAsCategories = 0
speedArrayLUT.EnableOpacityMapping = 0
speedArrayLUT.RGBPoints = [0.0, 1.0, 0.0, 0.0, 150.0, 0.0, 0.0, 1.0]
speedArrayLUT.UseLogScale = 0
speedArrayLUT.LockScalarRange = 1
speedArrayLUT.ColorSpace = 'HSV'
speedArrayLUT.UseBelowRangeColor = 0
speedArrayLUT.BelowRangeColor = [0.0, 0.0, 0.0]
speedArrayLUT.UseAboveRangeColor = 0
speedArrayLUT.AboveRangeColor = [1.0, 1.0, 1.0]
speedArrayLUT.NanColor = [0.498039, 0.498039, 0.498039]
speedArrayLUT.Discretize = 1
speedArrayLUT.NumberOfTableValues = 256
speedArrayLUT.ScalarRangeInitialized = 1.0
speedArrayLUT.HSVWrap = 0
speedArrayLUT.VectorComponent = 96
speedArrayLUT.VectorMode = 'Component'
speedArrayLUT.AllowDuplicateScalars = 1
speedArrayLUT.Annotations = []
speedArrayLUT.IndexedColors = []
# get opacity transfer function/opacity map for 'SpeedArray'
speedArrayPWF = GetOpacityTransferFunction('SpeedArray')
speedArrayPWF.Points = [0.0, 0.0, 0.5, 0.0, 150.0, 1.0, 0.5, 0.0]
speedArrayPWF.AllowDuplicateScalars = 1
speedArrayPWF.ScalarRangeInitialized = 1
#change array component used for coloring
speedArrayLUT.RGBPoints = [2.0, 1.0, 0.0, 0.0, 134.079086144, 0.0, 0.0, 1.0]
speedArrayLUT.VectorComponent = 111
# Properties modified on speedArrayPWF
speedArrayPWF.Points = [2.0, 0.0, 0.5, 0.0, 134.079086144, 1.0, 0.5, 0.0]
#change array component used for coloring
speedArrayLUT.RGBPoints = [2.0, 1.0, 0.0, 0.0, 131.302099153, 0.0, 0.0, 1.0]
speedArrayLUT.VectorComponent = 127
# Properties modified on speedArrayPWF
speedArrayPWF.Points = [2.0, 0.0, 0.5, 0.0, 131.302099153, 1.0, 0.5, 0.0]
#change array component used for coloring
speedArrayLUT.RGBPoints = [2.0, 1.0, 0.0, 0.0, 143.468496117, 0.0, 0.0, 1.0]
speedArrayLUT.VectorComponent = 175
# Properties modified on speedArrayPWF
speedArrayPWF.Points = [2.0, 0.0, 0.5, 0.0, 143.468496117, 1.0, 0.5, 0.0]
#### uncomment the following to render all views
# RenderAllViews()
# alternatively, if you want to write images, you can use SaveScreenshot(...).
I try to do the same from a script, this time keeping the color map the
same (not rescaling), and that does not work, the color of the geometry
stays the same:
###############
*speedArrayLUT = GetColorTransferFunction('SpeedArray')*
*speedArrayLUT.RGBPoints = [0.0, 1.0, 0.0, 0.0, 150.0, 0.0, 0.0, 1.0]*
*speedArrayLUT.LockScalarRange = 1*
*speedArrayLUT.ColorSpace = 'HSV'*
*speedArrayLUT.NanColor = [0.498039, 0.498039, 0.498039]*
*speedArrayLUT.ScalarRangeInitialized = 1.0*
*speedArrayLUT.VectorComponent = 671*
*speedArrayLUT.VectorMode = 'Component'*
*speedArrayPWF = GetOpacityTransferFunction('SpeedArray')*
*speedArrayPWF.Points = [0.0, 0.0, 0.5, 0.0, 150.0, 1.0, 0.5, 0.0]*
*speedArrayPWF.ScalarRangeInitialized = 1*
*attributesLUTColorBar = GetScalarBar(speedArrayLUT, renderView1)*
*attributesLUTColorBar.Title = 'Speed (km/h)'*
*for i in range_15min: *
* speedArrayLUT.VectorComponent = i*
* Render()*
#################
If I add:
*readerDisplay.RescaleTransferFunctionToDataRange() *
in the loop, I do see the range of the color bar changing with each
iteration, but the color of the rendered geometry does not change. Is there
a way to force an update on the readerDisplay (where, *readerDisplay =
GetDisplayProperties(reader, view=renderView1)*)
Thanks for any suggestions.
Matei
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/paraview/attachments/20150820/2fd7cc2b/attachment.html>
More information about the ParaView
mailing list