Progressbar

Dear Rooters

The enclosed library and macro shows my attempt to create a
“pseudo” progressbar “|########|” in a for loop of class MyProgress.

1, What do I need to do so that the progressbar is printed during
execution of the for loop?

2, My ultimate goal is to use the static variable fgProgress in my
gui application in order to use a real TGHProgressBar in a messagebox.
Do you have any hints how I can achieve this?

Thank you in advance.
Best regards
Christian
MyProgress.tar.gz (2.02 KB)

[quote]1, What do I need to do so that the progressbar is printed during
execution of the for loop?
[/quote]

Hi Christian,

You need to have some changes in the MyProgress::Test method. Please see the attached file. I will try to answer your second question asap. BTW you can create a progress bar as a part of the status bar widget in an application too.

Best regards, Ilka

Dear Ilka

Thank you for your answer to the first part of my problem.
I did not know that it is so simple, simply replacing:
cout << “#”;
with:
cerr << “#”;
So I was searching and found a second solution:
cout << “#” << flush;

I am looking forward to your answer to my second problem.

Best regards
Christian

Dear Ilka, dear Rooters

Meanwhile I have expanded my example to include a library and a
gui application, see attached file.

To run the macro do:

make -f Makefile4MyProgress
root
root [0] .L macroMyProgress.C         
root [1] Init()                       
root [2] Test("MyTest", 34)
root [3] Compute("MyCompute.root", 23)

To run the gui application do:

make -f Makefile4MyGui
./MyGui &

Pressing button “Test” will run a progressbar.

Pressing button “Run” creates a root file and fills it with trees.
While filling the file with trees it should display a progressbar,
but sorrowly this does not work.
Do you know how I could display a progressbar w/o using threads?

Pressing button “Thread” creates a root file and fills it with trees.
While filling the file with trees it displays a progressbar.
However, I would prefer a solution w/o threads, since I am not sure
how save my operations in my library are when I am using threads?

While the progressbar is displayed I would like the user to prevent
using the gui, i.e. the progressbar should be displayed in a modal
dialog box. What do I have to do to achieve this behavior?

Thank you in advance.
Best regards
Christian
MyProgress.tar.gz (6.68 KB)

Hi Christian,

Having the second Makefile4MyGui + $ROOTSYS/test/Makefile.arch files I am getting still errors:
MyProgress > make -f Makefile4MyGui
g++ -O -Wall -fPIC -pthread -I/home/antcheva/root/include -c MyGuiDict.cxx
g++ -O MyGui.o MyGuiDict.o -L. -lMyProgress -L/home/antcheva/root/lib -lCore -lCint -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lGui -pthread -lm -ldl -rdynamic -lThread -o MyGui
/usr/bin/ld: cannot find -lMyProgress
collect2: ld returned 1 exit status
make: *** [MyGui(ExeSuf)] Error 1

Cheers, Ilka

Dear Ilka

I am sorry that you still get errors. I am attaching two new makefiles, which
need the makefile “makefile.arch” from root/test. I am compiling the library
and the gui independently, using:

make -f Makefile4MyProgress
make -f Makefile4MyGui
./MyGui

If you still get errors, then I do not know what could be the error, since I am
calling my library in Makefile4MyGui in line 10:
MYLIB = -L$(LPATH) -lMyProgress

Please let me know if this will work.

Thank you.
Best regards
Christian
Makefile4MyGui.txt (1.43 KB)
Makefile4MyProgress.txt (1.37 KB)

Hi Chrictian,

The good news: both examples compiled when I have used the last provided makefiles. The macro macroMyProgress.C runs fine also.

Bad news: I got following when I tried the second example ./MyGui
Warning: Re-initialization enforced macro G__CINTVERSION FILE: LINE:0

*** Break *** segmentation violation
Generating stack trace…
0x08050b9b in main + 0x9d from ./MyGui
0x034f578a in __libc_start_main + 0xda from /lib/tls/libc.so.6
0x0804d77d in operator new(unsigned int) + 0x31 from ./MyGui
Abort (core dumped)

Cheers, Ilka
++ many thanks for your patience

[quote]Warning: Re-initialization enforced macro G__CINTVERSION FILE: LINE:0 [/quote]This usually means that you need to regenerate the dictionary file.

Cheers,
Philippe.

Dear Ilka

I have just deleted everything and recompiled both libraries with root 5.03/01.
Everything works without any problems. I am afraid that I do not know the reason for your problem.
Maybe, the suggestion from Philippe may be useful.

Thank you for your efforts.
Christian

Hi Christian,

I will investigate tomorrow the reason and will let you know.

Philippe, thank you for the hint.

Best regards, Ilka

Hi Christian,

With last make files I run your example.
The progressbar is displayed in a modal dialog box in the attached file MyGui.cxx (taken from the provided tar file by you). The line: gSystem->ProcessEvents(); in MyProgressBox::HandleTest() was changed to gClient->ProcessEventsFor(fMain);

About the progress bars synchronization without threads , I propose you to try that with signals/slots mechanizm implementing the corresponding methods in both classes.

Thank you for your patience.
Best regards, Ilka

Dear Ilka

I have just tested my program with your change. While pressing button "Test"
displays the progressbar, pressing button “Run” still does not display the progressbar.

Best regards
Christian

Hi Christian,

I did not change anything in the code related to the click on the Run button. My proposal was for using signals/slots. If you want me to try that please reduce the code to an simple example showing only this problem.

Thank you, Ilka