[vtkusers] Update ChartXY Data and re-render in real-time

Marcus D. Hanwell marcus.hanwell at kitware.com
Fri Jan 20 10:29:43 EST 2012


Hi,

On Thu, Jan 12, 2012 at 6:02 AM, ajp <andrew.parker2 at baesystems.com> wrote:
> Hi,
>
> I'm teaching myself to use vtk plotting within a small c++ code by using:
>
> http://www.vtk.org/Wiki/VTK/Examples/Cxx/Plotting/LinePlot
>
> Everything works fine.  However, I would like to have control returned to
> the main code after start() is called, rather than not returning until I
> kill the window, and then after start() add some code to modify, say, the
> cosine curve and see it automatically update the chart (after calling
> something appropriate in the vtk api).
>
> I understand I need to get to grips with event loops, probably need to use
> multi-threading etc, that's all fine, just need a few pointers to get
> started....
>
> As a concrete example could somebody post some code that modifies the above
> example and add some suitable code after start() so that the cosine for
> example moves and I see it updated in the chart?  I still would not want the
> program to not exit until I close the render window.
>
> That would be really helpful,
>
It would be good to get some examples up there, and Eric has already
posted a nice example in Python. The thing to remember is that all
rendering must happen in the main GUI thread, and the GUI has an event
loop which will never return. The most common way to animate or change
things is to use a timer which will call a function at predefined
intervals. There is actually no need to use multiple threads to
animate - it could all be done in the main thread using timers.

I have just returned to the office after a couple of weeks away, but
will see if I can put a simple example together some time soon as I
think it would make a nice self-contained test. If using threads you
need to be careful about multiple threads accessing the same data.

Marcus



More information about the vtkusers mailing list