Auto-refreshing Graph Builder hack -- it lives!

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Auto-refreshing Graph Builder hack -- it lives!

jfabry
Hi all,

so I am impatient and I could not wait for Alex’s solution to my question of yesterday. I hacked something together that works most of the time, and now I have my scatterplot that updates itself quite quickly ! :- ) I give the core of the code below, and then report on a problem :-(

I have a builder instance variable, and an open and a refresh method. Open opens the first time, and refresh refreshes the view. (I call buildDataset, which builds the right dataset for the graph, that’s not relevant here).

open
        builder := RTGrapher new.
        builder add: self buildDataset.
        builder build open

refresh
        | view |
        view := builder view.
        view cleanAll.
        builder := RTGrapher new.
        builder view: view.
        builder add: self buildDataset.
        builder build
        view signalUpdate.

And if you want this animated, just make an infinite loop that calls refresh (with a delay in-between to not hog the CPU).

autorefresh
        self open.
        [[true] whileTrue: [self refresh. (Delay forMilliseconds: 100) wait]] fork

Et voila! C’est cool quoi! (Yes, I’m in France right now :-) )

There is sadly one problem: sometimes I get the red morph of death in the window :-( AthensCairoCanvas>>setShape: sends asAthensShapeOn: to nil. It’s not immediate, but after some time (variable) I always get it :-(. Any pointers on what it may be and how to fix it??

---> Save our in-boxes! http://emailcharter.org <---

Johan Fabry   -   http://pleiad.cl/~jfabry
PLEIAD lab  -  Computer Science Department (DCC)  -  University of Chile


_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev
Reply | Threaded
Open this post in threaded view
|

Re: Auto-refreshing Graph Builder hack -- it lives!

Ben Coman


On Thu, Jan 22, 2015 at 10:00 PM, Johan Fabry <[hidden email]> wrote:
There is sadly one problem: sometimes I get the red morph of death in the window :-( AthensCairoCanvas>>setShape: sends asAthensShapeOn: to nil. It’s not immediate, but after some time (variable) I always get it :-(. Any pointers on what it may be and how to fix it??


If you bring up halos on the broken morph there should be an option to debug it.
cheers -ben 

_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev
Reply | Threaded
Open this post in threaded view
|

Re: Auto-refreshing Graph Builder hack -- it lives!

Nicolai Hess
In reply to this post by jfabry

autorefresh
        self open.
        [[true] whileTrue: [self refresh. (Delay forMilliseconds: 100) wait]] fork

Et voila! C’est cool quoi! (Yes, I’m in France right now :-) )

There is sadly one problem: sometimes I get the red morph of death in the window :-( AthensCairoCanvas>>setShape: sends asAthensShapeOn: to nil. It’s not immediate, but after some time (variable) I always get it :-(. Any pointers on what it may be and how to fix it??

Calling "builder build" (in your refresh method) will reset all "path" objects, so it may happen that you reset the path objects while in the ui thread, they are used to draw the
shapes.

nicolai




_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev
Reply | Threaded
Open this post in threaded view
|

Re: Auto-refreshing Graph Builder hack -- it lives!

abergel
In reply to this post by jfabry
Hi Johan,

Indeed, your approach is technically the less optimal :-)
Destroying and rebuilding the whole World at each bit change :-)

Try the RTDynamicGrapher class we have just made. It should work.

Alexandre


> On Jan 22, 2015, at 11:00 AM, Johan Fabry <[hidden email]> wrote:
>
> Hi all,
>
> so I am impatient and I could not wait for Alex’s solution to my question of yesterday. I hacked something together that works most of the time, and now I have my scatterplot that updates itself quite quickly ! :- ) I give the core of the code below, and then report on a problem :-(
>
> I have a builder instance variable, and an open and a refresh method. Open opens the first time, and refresh refreshes the view. (I call buildDataset, which builds the right dataset for the graph, that’s not relevant here).
>
> open
> builder := RTGrapher new.
> builder add: self buildDataset.
> builder build open
>
> refresh
> | view |
> view := builder view.
> view cleanAll.
> builder := RTGrapher new.
> builder view: view.
> builder add: self buildDataset.
> builder build
> view signalUpdate.
>
> And if you want this animated, just make an infinite loop that calls refresh (with a delay in-between to not hog the CPU).
>
> autorefresh
> self open.
> [[true] whileTrue: [self refresh. (Delay forMilliseconds: 100) wait]] fork
>
> Et voila! C’est cool quoi! (Yes, I’m in France right now :-) )
>
> There is sadly one problem: sometimes I get the red morph of death in the window :-( AthensCairoCanvas>>setShape: sends asAthensShapeOn: to nil. It’s not immediate, but after some time (variable) I always get it :-(. Any pointers on what it may be and how to fix it??
>
> ---> Save our in-boxes! http://emailcharter.org <---
>
> Johan Fabry   -   http://pleiad.cl/~jfabry
> PLEIAD lab  -  Computer Science Department (DCC)  -  University of Chile
>
>
> _______________________________________________
> Moose-dev mailing list
> [hidden email]
> https://www.iam.unibe.ch/mailman/listinfo/moose-dev

--
_,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
Alexandre Bergel  http://www.bergel.eu
^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.




_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev
Reply | Threaded
Open this post in threaded view
|

Re: Auto-refreshing Graph Builder hack -- it lives!

jfabry
In reply to this post by Nicolai Hess

On Jan 22, 2015, at 20:50, Nicolai Hess <[hidden email]> wrote:

There is sadly one problem: sometimes I get the red morph of death in the window :-( AthensCairoCanvas>>setShape: sends asAthensShapeOn: to nil. It’s not immediate, but after some time (variable) I always get it :-(. Any pointers on what it may be and how to fix it??

Calling "builder build" (in your refresh method) will reset all "path" objects, so it may happen that you reset the path objects while in the ui thread, they are used to draw the
shapes.

Hi Nicolas,

thanks for the information! I don’t know anything about path objects, so I won’t have a quick fix, but now I know better where to look, hopefully I can find some time, because I still think this way of doing things is interesting.

---> Save our in-boxes! http://emailcharter.org <---

Johan Fabry   -   http://pleiad.cl/~jfabry
PLEIAD lab  -  Computer Science Department (DCC)  -  University of Chile


_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev
Reply | Threaded
Open this post in threaded view
|

Re: Auto-refreshing Graph Builder hack -- it lives!

jfabry
In reply to this post by abergel

> Indeed, your approach is technically the less optimal :-)
> Destroying and rebuilding the whole World at each bit change :-)

I am Johan … the destroyer of worlds :-)

> Try the RTDynamicGrapher class we have just made. It should work.

I did, see previous mail … ;-)

But I think my hack still has some merits: it is kind of generic so I guess (hope) that it can be used with any kind of builder. In that case we can do live updating with all other kinds of graphs for free.

Thinking about it, adding live updating can be simple! If we assume that we know what the min & max values of data will be, the only support this way of working needs is a way to remove all data points from the graph, and draw new data points. If a builder has these 2 extra methods (+ methods that fix the values for the axes), it should be composable with the live update logic out of the box. Right?


---> Save our in-boxes! http://emailcharter.org <---

Johan Fabry   -   http://pleiad.cl/~jfabry
PLEIAD lab  -  Computer Science Department (DCC)  -  University of Chile


_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev