Re: TPad::WaitPrimitive comments

From: Maxim Nikulin <nikulin_at_gorodok.net>
Date: Wed, 26 Apr 2006 23:41:22 +0700


Hi Rene,

I'm sorry that my message was not clear enough.

Rene Brun wrote:

> 
> -Could you indicate what type of problems you faced?
> -What is the problem that you are trying to solve?

Sometimes I want to have a look at intermediate results and then continue calculation. Adding the statement gPad->WaitPrimitive() to a script I expect to get pause at that point. The problem is that in some cases ROOT continues execution of the script. E.g. this script doesn't stop at all:

{

    h = new TH1F ("h", "h", 10, 0, 1);
    h->Draw();
    t = new TText(0.5, 0.5, "Text");
    t->Draw();
    for (Int_t i = 0; i < 10; ++i)
    {

       h->Fill(i/10. + 0.01);
       c1->Modified();
       c1->Update();
       c1->WaitPrimitive();

    }
}

Another case is more subtle. Let's remove TText object: {

    h = new TH1F ("h", "h", 10, 0, 1);
    h->Draw();
    for (Int_t i = 0; i < 10; ++i)
    {

       h->Fill(i/10. + 0.01);
       c1->Modified();
       c1->Update();
       c1->WaitPrimitive();

    }
}
During the first iteration the script always stops. If I press a key (E.g. [space]) the next 9 steps are passed without pauses. In case of double clicks the script usually passes two or three iterations. I think that actually it runs until double click events is replaced by mouse move.

Another issue that closing of the window during processing of WaitPrimitive() obviously leads to segmentation violation.

> What you show is certainly not a solution to any problem.
> If you just want to interact with the window while filling the histograms
> simply call gSystem->ProcessEvents();

No, the goal is to stop calculation until user presses a key. Fill() was added just to have different plots.

> On Mon, 24 Apr 2006, Maxim Nikulin wrote:
> 

>> Hi,
>>

>> I faced several problems during my attempts to use the
>> TPad::WaitPrimitive() method and I think these issues should be
>> mentioned in the documentation. I've written a script demonstrating a
>> possible solution, I hope it will be useful for someone.
>>

>> {
>> h = new TH1F ("h", "h", 10, 0, 1);
>> h->Draw();
>> t = new TText(0.5, 0.5, "Text");
>> t->SetName("t"); // otherwise it has empty name ""
>> // and WaitPrimitive() returns immediately
>> // TText is not the only class having the empty
>> // name by default
>> t->Draw();
>> for (Int_t i = 0; i < 10; ++i)
>> {
>> h->Fill(i/10. + 0.01);
>> c1->Modified();
>> c1->Update();
>> c1->WaitPrimitive();
>> c1->HandleInput(kNoEvent, 0, 0); // next call of WaitPrimitive()
>> // often receives the same event
>> // so no pause happens
>> cout << i << endl;
>> }
>> }
>>

>> Another point is that the canvas can be closed while WaitPrimitive()
>> is executed. Probably the code should handle this case.
>>

>> I don't think input event processing significantly varies for
>> different window managers, but just to be precise. I use Black box
>> window manager, ROOT 5.10/00 and Fedora Core 2 on a Pentium 4 box.
-- 
Maxim Nikulin

P.S. Rene, I beg you pardon that first time I sent this letter to you 
instead of roottalk.
Received on Wed Apr 26 2006 - 18:42:08 MEST

This archive was generated by hypermail 2.2.0 : Mon Jan 01 2007 - 16:31:58 MET