On 4/24/13 11:09 PM, Utkarsh Ayachit wrote:
I'm am little confused, what is that you exactly want to see? I can
figure out how to show that.

Nothing visually complicated.  In my animation sequence I have data
time repeat over and over again as I represent it using different
methods.  I currently show that time value using the "AnnotateTime"
source, but I feel that that number gets lost in the shuffle, so I
want to have something that looks like a progress bar that is tied
to data-time and grows as we progress in the simulation.  And when
the simulation time resets to 0, the bar goes back to the beginning.

Like I said, very simple, yet very difficult.

I did more exploration with creating a string that I might use
instead of a polygonal object, but then I was foiled when I
realized that even though I can put a string into a Table output,
the "Manage Links" tool doesn't have an option to link data output
to a source/filter parameter.  Only parameter to parameter!

So I'm back to the polygonal object.

Utkarsh

        Thanks,
        Bill


On Wed, Apr 24, 2013 at 5:54 PM, Bill Sherman<sherm...@indiana.edu>  wrote:
Hello again Utkarsh, ParaView list people,


You cannot access animation scene from ProgrammableSource. Anything
from simple.py/servermanager.py cannot be accessed in
ProgrammableSource/Filter. You can add Python scripts as an animation
track, however. In the animation view, choose "Python" in the first
combo-box next to the "+" button.


Thanks again for this, this is a great tool to know about -- I was
doing animations stuff all day yesterday and didn't notice it.

I have a couple of updates:

First, with the Animation Python script, I'm not sure how the
geometry I generate can be placed into the scene.

Second, I managed to figure out a way to use a Programmable Filter
fed by an "AnnotateTime" source to make a geometry that is based on
time!  So that's the good news -- example Python script below.

The bad news is that I didn't quite think this through.  What I want
is basically a time/progress bar at the top, and I can do that now,
but what I forgot is that the camera moves in the animation, and I
don't want my progress bar to move!  I should have thought of that
from the outset!

I've been doing some research and experimenting with vanilla VTK, and
it doesn't seem to be the case that I can have a 2D geometric object
that is immune to the camera's movements.  (And if anyone knows anything
different than that, I'd love to hear about it.)

So, I decided to just try something simple for now, but of course nothing
is simple.  I was thinking that I'd just create a text representation of
time -- ie a bunch of ohs in a string ("oooooo..."), but now I don't
know if I can produce a Text object other than from a source -- ie. can
I programatically create a text object that will be immune to camera
moves (ie. using a vtkActor2D underneath the hood).

Thoughts? ...  Hang on, I just discovered that links can do more than
link cameras!  So any thoughts on how I might take advantage of a link
to create a text string in a programmable filter and pipe that into a
Text object?


As always when working with ParaView, even after I feel like I've learned
a lot, the amount of knowledge of what I don't know about it seems
to have expanded even more!

For example: the programmable filter has three places for scripts:
         - Script
         - RequestInformation Script
         - RequestUpdateExtent Script
Each have popups, but the message is self referential -- I have to
know what the RequestInformation pass or the RequestUpdateExtent pipeline
pass means to know how these work.


Okay, as promised, thanks to some code from Utkarsh, and a lot of
trial an error, I present a programmable filter script that modifies
the shape of this triangle based on animation time:

-----------------------------------------------------------
time = self.GetInput().GetValue(0,0).ToFloat();
#print time;


# Create a poly-data instance
#pd = vtk.vtkPolyData()

# Instead link to the poly-data created for the output
pd = self.GetPolyDataOutput();


# Set up the containter to save the
# point locations (geometry)
points = vtk.vtkPoints()
pd.SetPoints(points)

# Add the point coordinates
points.SetNumberOfPoints(3)
points.SetPoint(0, 0, 0, 0)
points.SetPoint(1, 2, time, 0)

points.SetPoint(2, 3, 0, 0)

# We are adding a single triangle with
# 3 points. Create a id-list to refer to
# the point ids that form the triangle.
ids = vtk.vtkIdList()
ids.SetNumberOfIds(3)
ids.SetId(0, 0)
ids.SetId(1, 1)
ids.SetId(2, 2)

# Since this polydata has only 1 cell,
# allocate it.
pd.Allocate(1, 1)

# Insert the cell giving its type and
# the point ids that form the cell.
pd.InsertNextCell(vtk.VTK_POLYGON, ids)
-----------------------------------------------------------

So, in order to get time, the Programmable Filter must have as its
input an "AnnotateTime" module that just outputs a numeric value for
time.  And then the output type for the filter must be set to "vtkPolyData".

Utkarsh


         more to learn, more to learn ... thanks!
         Bill



On Wed, Apr 24, 2013 at 10:02 AM, Bill Sherman<sherm...@indiana.edu>
wrote:

Hello,

I have a question about how to access internal ParaView data from the
Programmable Source source.

Specifically, I want to have a source that changes based on the animation
time, and so I would like to know how to get the current data-time
from within the python code of a Programmable Source.

So, using the Python_Scripting wiki entry on paraview.org, I have
found that from the Python Shell I can get information about the
current time of the animation using the GetAnimationScene() method,
so I'm hoping that there is a quick trick to accessing this data
from the ProgrammableSource python code.

Eg.
          >>>   scene=GetAnimationScene()
          >>>   print scene.AnimationTime
          30.0466

I think from there I can do some interesting stuff.

          Thanks in advance,
          Bill

--
Bill Sherman
Sr. Technology Advisor
Advanced Visualization Lab
Pervasive Technology Inst
Indiana University
sherm...@indiana.edu



_______________________________________________
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

Follow this link to subscribe/unsubscribe:
http://www.paraview.org/mailman/listinfo/paraview

Reply via email to