Smooth filling of TGProgressBar without performance hit

I know that this may sound silly, but does anybody know a way to fill a TGProgressBar in a smooth way with the kSolidFill option?

Currently, I have my GUI class (AdcWindow) and my serious, important AdcControl class that does the whole processing. The control class has a for-loop that does all the event generation. The way I implemented a progress bar in the gui, was to create it and pass the pointer to the control class. Therefore in the loop i have something like:


//got the pointer to the progress bar in the window and stored it in
//TGHProgessBar *pBar
...
for(int j=0;j<nevents;j++){

   pbar->Increment(1);
   gSystem->DispatchOneEvent(); //this needed to show the change or
  //else the progress bar remains empty till the end

.... //processing stuff

}

I needed to include the call to the DispatchOneEvent() call in the for loop, but this made the run 1000 times slower. Is there another way of doing this? Is there a proper way to connect the control class with the gui? For the time being and AdcControl object is passed to the gui to connect the two. So the AdcControl object is under the GUI : [code]
class AdcWindow : public TGTransientFrame {

private:
//…
AdcControl *con; //store the control object here

public:
AdcWindow(AdcControl* control); //constructor receives the required control object
//…
void processAll();//the function/signal that starts the process
};[/code]

Any advice/suggestion to the proper GUI/core binding will be greatly appreciated.

Should I not call gSystem->DispatchOneEvent() repeatedly in the control class? It looks like the problem is that the processing steals the focus off the gui and I am not sure how to make them run in parallel. ALso note that when I use block fill instead of solid fill, I get a better performance/behavior: the bar starts somehow at 25% and I have a relatively smooth fill till the end, without calling DispatchOneEvent() more than once.

Hi,

If it becomes 1000 times slower, it is probably because you are looping over a huge number of events… Then one solution would be something like this:
replacegSystem->DispatchOneEvent();
by something like this:if (!(j%100)) gSystem->ProcessEvents();
You can also adjust/compute the ratio to get a smooth filling.

Cheers,
Bertrand.