[Paraview] Changing Chart Series Visibilities from Python

pat marion pat.marion at kitware.com
Thu Oct 6 16:10:59 EDT 2011


Thanks Greg.  I can reproduce this.  I'm observing the same thing- if the
chart is created by hand, things are ok, but when created via python
commands, not working correctly.  I'll investigate the problem.  Hopefully
I'll find an easy work around too so that you don't have to wait for the
next release to get the bugfix.

Pat

On Thu, Oct 6, 2011 at 4:07 PM, Greg Schussman
<schussman at slac.stanford.edu>wrote:

> **
> Hi, Pat.
>
> Here is an example that recreates the problem.  Using this as a CSV file:
>
> AAA,BBB,CCC,DDD
> 0.0,1.0,2.0,3.0
> 0.0,2.0,4.0,8.0
> 0.0,3.5,2.5,1.5
>
> and this (modified python trace) as a script run from the python shell in
> paraview:
> ----------------------------------------------------------------
>
> try: paraview.simple
> except: from paraview.simple import *
> paraview.simple._DisableFirstRenderCameraReset()
>
> test_csv = CSVReader( FileName=['test.csv'] )
>
> AnimationScene1 = GetAnimationScene()
> RenderView1 = GetRenderView()
> Delete(RenderView1)
> SpreadSheetView1 = CreateRenderView()
> SpreadSheetView1.ViewTime = 0.0
>
> AnimationScene1.ViewModules = SpreadSheetView1
>
> PlotData1 = PlotData()
>
> XYChartView1 = CreateXYPlotView()
> XYChartView1.ViewTime = 0.0
>
> DataRepresentation2 = Show()
> DataRepresentation2.XArrayName = 'AAA'
> DataRepresentation2.AttributeType = 'Row Data'
> DataRepresentation2.SeriesVisibility = ['vtkOriginalIndices', '0']
>
> AnimationScene1.ViewModules = [ SpreadSheetView1, XYChartView1 ]
>
> Render()
>
> p = DataRepresentation2.SMProxy.GetProperty("SeriesNamesInfo")
>
> series_names = [p.GetElement(i) for i in xrange(p.GetNumberOfElements())]
> print "series_names:", series_names
> ----------------------------------------------------------------
>
> I get back
>
>   series_names: []
>
> Thanks for any suggestions.
>
> Greg
>
>
>
> On 10/06/2011 12:46 PM, Greg Schussman wrote:
>
> Hi, Pat.
>
> On further checking, there's still some sort of problem.
>
> When I use your example below, it works in ParaView's Python Shell, if the
> PlotData filter was created via the ParaView gui.   However, if it was
> created in the macro (using the text from a python trace of how it was
> created via the gui), then your example produces an empty list.   The
> PlotData filter created in the macro does show up on the screen and look
> correct; but the series names aren't accessible.
>
> Does this provide any useful clues?
>
> Thanks.
>
> Greg
>
> On 10/06/2011 11:49 AM, pat marion wrote:
>
> Hi Greg,
>
> I think I found a bug, or else I don't quite understand what is happening.
> It seems that under certain circumstances the python layer fails to wrap all
> the properties of a proxy.  I look into this, but for now you can work
> around the issue by accessing the c++ api:
>
> >>> p =
> rep.SMProxy.GetProperty("SeriesNamesInfo")
>
> >>> series_names = [p.GetElement(i) for i in
> xrange(p.GetNumberOfElements())]
>
>
> Pat
>
> On Thu, Oct 6, 2011 at 2:34 PM, Greg Schussman <
> schussman at slac.stanford.edu> wrote:
>
>>  Hi, Pat.
>>
>> I tried plotting directly from the CSVReader, and then it all works.   But
>> when my programmable filter is in between, there's a problem.  When I apply
>> the plot filter  (via ParaView's GUI) to my programmable filter, the plot
>> works fine in the gui, but the GetProperty("SeriesNameInfo") returns None.
>> However, if I skip the programmable filter, and plot the CSV reader
>> directly, then GetProperty("SeriesNameInfo") does what you say it should.
>>
>> Anyway, I think I can skip my programmable filter for now, and get this
>> working dircetly.
>>
>> Thanks so much for what you've provided.
>>
>>
>> Greg
>>
>>
>> On 10/06/2011 11:10 AM, pat marion wrote:
>>
>> Are you sure that the chart view is the active view when you call
>> GetDisplayProperties(p)?   If the render view is active, you'll get the
>> wrong representation.  I verified that this works for Wavelet --> Plot Data
>> filter using PV 3.10.1.
>>
>> Pat
>>
>> On Thu, Oct 6, 2011 at 2:03 PM, Greg Schussman <
>> schussman at slac.stanford.edu> wrote:
>>
>>>  On 10/06/2011 07:33 AM, pat marion wrote:
>>>
>>> series_names = [name for name in d.GetProperty("SeriesNamesInfo")]
>>>
>>>
>>> Hi, Pat.
>>>
>>> Thanks for the helpful pointers.
>>>
>>> After setting everything up in ParaView (3.10.1, 64-bit), I'm not getting
>>> results.  Here is what I did from the ParaView Python Shell:
>>>
>>>  >>> p
>>> =
>>>
>>> FindSource("PlotData1")
>>>
>>> >>> rep
>>> =
>>>
>>> GetDisplayProperties(p)
>>>
>>> >>>
>>>
>>> rep.GetProperty("SeriesNamesInfo")
>>>
>>> None
>>>
>>> >>>
>>>
>>> While, at the same time, the Object Inspector shows 27 series, each with
>>> the correct name.
>>>
>>> Does something need to be updated or refreshed first?  I notice in the
>>> pvblot script, there is a
>>>
>>>   rep.Update()
>>>
>>> but when I try that in ParaView's python shell (after getting the
>>> representation the way I showed above), it tells me:
>>>
>>>
>>> >>>
>>> rep.Update()
>>>
>>> Traceback
>>> (most recent call last):
>>>
>>> File
>>> "<console>", line 1, in
>>>
>>> <module>
>>>
>>> File
>>>
>>> "/usr/lib64/paraview/site-packages/paraview/servermanager.py",
>>>
>>> line 370, in __getattr__
>>>
>>> return
>>> getattr(self.SMProxy, name)
>>>
>>> AttributeError:
>>> Update
>>>
>>> >>>
>>>
>>> Thanks!
>>>
>>> Greg
>>>
>>>
>>>
>>
>>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.paraview.org/pipermail/paraview/attachments/20111006/1d3d317c/attachment.htm>


More information about the ParaView mailing list