Why does ArrayPlotData not propagate notifications?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Why does ArrayPlotData not propagate notifications?

Hoogendoorn, Eelco

I want to animate a 2D image. The natural thing to do seem to create a backing trait Property(Array), and hook it up to an imageplot. I can get that working by reassigning the data to the plot and forcing it to redraw every time my Array changes, but why does ArrayPlotData not propagate changes in its contained data by default? Or is there some subclass that does do this out of the box? I read somewhere you can hook up these events manually, but why does a noob like me have to bother with that? I makes me feel like I am missing some architectural subtleties that make this somehow a bad idea. Am I?

Regards,
Eelco Hoogendoorn
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: Why does ArrayPlotData not propagate notifications?

Jonathan March
Traits does not do automatic dependency analysis, so it does not know that,
when you change your imageplot, your Property trait also changes. If I'm
understanding your situation, this is easily remedied by specifying the
dependency explicitly:
backing_trait = Property(Array, depends_on='myimageplot')

-- Jonathan

On Mon, Jun 13, 2011 at 5:08 PM, Hoogendoorn, Eelco <[hidden email]>wrote:

>
> I want to animate a 2D image. The natural thing to do seem to create a
> backing trait Property(Array), and hook it up to an imageplot. I can get
> that working by reassigning the data to the plot and forcing it to redraw
> every time my Array changes, but why does ArrayPlotData not propagate
> changes in its contained data by default? Or is there some subclass that
> does do this out of the box? I read somewhere you can hook up these events
> manually, but why does a noob like me have to bother with that? I makes me
> feel like I am missing some architectural subtleties that make this somehow
> a bad idea. Am I?
>
> Regards,
> Eelco Hoogendoorn
> _______________________________________________
> Enthought-Dev mailing list
> [hidden email]
> https://mail.enthought.com/mailman/listinfo/enthought-dev
>
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: Why does ArrayPlotData not propagate notifications?

Hoogendoorn, Eelco
In reply to this post by Hoogendoorn, Eelco

> Traits does not do automatic dependency analysis, so it does not know that,
> when you change your imageplot, your Property trait also changes. If I'm
> understanding your situation, this is easily remedied by specifying the
> dependency explicitly:
> backing_trait = Property(Array, depends_on='myimageplot')

Its the other way around: I dont want to, say, draw on a canvas and have that reflected in a backing property; I want some independent mechanism updating my imagedata, and have my plot be aware of that.
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: Why does ArrayPlotData not propagate notifications?

Didrik Pinte-2
On Tue, Jun 14, 2011 at 10:22 AM, Hoogendoorn, Eelco
<[hidden email]> wrote:
>
>> Traits does not do automatic dependency analysis, so it does not know that,
>> when you change your imageplot, your Property trait also changes. If I'm
>> understanding your situation, this is easily remedied by specifying the
>> dependency explicitly:
>> backing_trait = Property(Array, depends_on='myimageplot')
>
> Its the other way around: I dont want to, say, draw on a canvas and have that reflected in a backing property; I want some independent mechanism updating my imagedata, and have my plot be aware of that.

Updating the ArrayPlotData container like this :

    self.plot_data.set_data('image', new_array)

do trigger a refresh of the plot for all the plots that do use the
'image' dataset as input.

A good example of that (not on 2d but 1d dataset) is the
advanced/spectrum.py example.

When you mean changes, do you mean changing the full array or just
some values in the array itself. If it is the latter, you need to
trigger the refresh by hand as you do not go through the set_data
method and the Array trait does not trigger changes when its content
is changed.

-- Didrik
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev