Hi everyone,
I’m trying to implement (in a not-so-elegant way) a “browser” for TH1 objects, created starting from data stored in a file, as a stand-alone program. I need to Draw() on a canvas the waveform associated to an event and then moving through the others either by hitting “return” (next event) or by typing “-” and then hitting return (previous event). Since I’m not so familiar with The TCanvas::Update(), TCanvas::ForceUpdate() or TCanvas::Flush() functions I’m not able to display anything until the TApplication::Run() instruction. Here’s my code:
[code]include
// …
int main() {
// stuff...
chain.GetEntry(0);
wf = event->GetWaveform(0);
hist = wf->GimmeHist();
hist->Draw();
can.Update();
int N = chain.GetEntries();
int i =  1;
while ( 1 == 1 ) {
    
    cout << "event " << i << ": ";
    chain.GetEntry(i);
    wf = event->GetWaveform(0);
    
    hist = wf->GimmeHist();
    can.Update();
    int choice = waitForEnter();
    if ( choice == 1 ) break;
    if ( choice == 2 && i < N ) i++;
    if ( choice == 2 && i == N ) continue;
    if ( choice == 3 && i > 0 ) i--;
    if ( choice == 3 && i == 0 ) continue;
    if ( choice == 4 ) {
        cout << "           Go to: ";
        cin >> i;
    }
}
cout << "Close the ROOT session to exit the program";
app.Run(kFALSE);
return 0;
}
int waitForEnter() {
string input;
getline( cin , input );
if ( input.compare(“exit”) == 0 ) return 1;
if ( input.compare("-") == 0 )    return 3;
if ( input.compare(“goto”) == 0 ) return 4;
else return 2;
}[/code]
As you can see I also tried to draw the first event before the loop and call TCanvas::Update(), but the only thing I can reproduce inside the loop is a blank canvas. What TCanvas member function I should use to update it?
loopOverList.cc (3.37 KB)