[Paraview] Animated Parameter Annotation

Utkarsh Ayachit utkarsh.ayachit at kitware.com
Wed Apr 16 10:50:53 EDT 2008


Here's how to add a callback function

def myCallback(obj, calldata):
   """obj is the vtkObject that fired the event"""
   print "Event fired!"
   return

CP.AddObserver( "PropertyModifiedEvent", myCallback )

Utkarsh

Kent Eschenberg wrote:
> Utkarsh Ayachit wrote:
>> Hmmm, very interesting; it could be done using python.
>> Here a plan:
>>
>> * create a simple "Text" source proxy.
>> * add observer to the animated properties vtkCommand::ModifiedEvent.
>> * in the call-back, change the text of the text source proxy to match 
>> the value of the property.
>>
>> A caveat: python event-observers/callbacks don't work in python shell 
>> in the paraview GUI. However, should work fine with pvpython/pvbatch.
>>
>> Utkarsh
> 
> Thanks! Here's what I think you are suggesting. In this case the Z 
> coordinate of the plane's origin will be animated:
> 
> ===================================
> from paraview import servermanager
> servermanager.Connect(
> implFuncModule = servermanager._createModule( "implicit_functions" )
> 
> # Create plane used to make the cut (used by "Cut" filter)
> CP = implFuncModule.Plane()
> CP.Origin = [ 0, 0, 0 ]
> CP.Normal = [ 0, 0, 1 ]
> 
> # Create the text (missing: location, size, etc.)
> T = servermanager.sources.TextSource()
> T.Text = "Z = 0.0"
> 
> # Called during the animation as the cut is changed
> class mycallback( servermodule.vtkCommand )
>   T.Text = "Z = %3.1f" % CP.Origin[2]
> 
> CP.AddObserver( "PropertyModifiedEvent", myCallback )
> ...
> ===================================
> 
> The one detail I haven't solved is that I cannot find the vtkCommand 
> class in the servermanager. Or am I going at this the wrong way?
> 
> Kent
> Pittsburgh Supercomputing Center
> 


More information about the ParaView mailing list