From: Torquil M. <to...@gm...> - 2008-01-17 20:40:22
|
Hello, I have a C++ program that simulates the movements of polygons. It runs a=20 plotting function e.g. every 100 iterations of the simulation. Why is it th= at=20 when I use PLPLOT there is lots of flickering, but with PGPLOT it looks gre= at=20 without any flickering? Is PGPLOT much faster than PLPLOT or am I doing=20 something wrong? With plplot it is too much flickering to be able to watch= =20 the polygons move around. I have tried setting the xwin device options=20 nobuffering and sync, but there was no difference. Here is a description of the code: void new_page() { plclear(); plbox("bcinst", 0, 0, "bcinst", 0, 0); } void plot() { new_page(); {..calculate plot quantitie here...} {... some plline() functions...} } =09 int main() { plsdev("xwin"); plinit(); plenv(xmin, xmax, ymin, ymax, 1, -2); for(int i =3D 0; i !=3D i_max; ++i) { {...simulation_code here...} if(i % 100 =3D=3D 0) plot(); } plend(); return(0); } Best regards, Torquil S=F8rensen |
From: Arjen M. <arj...@wl...> - 2008-01-18 08:02:19
|
> Hello, > > I have a C++ program that simulates the movements of polygons. It runs a > plotting function e.g. every 100 iterations of the simulation. Why is it > that > when I use PLPLOT there is lots of flickering, but with PGPLOT it looks > great > without any flickering? Is PGPLOT much faster than PLPLOT or am I doing > something wrong? With plplot it is too much flickering to be able to watch > the polygons move around. I have tried setting the xwin device options > nobuffering and sync, but there was no difference. > Hello Torquil, the usual solution to avoid such flickering is using double-buffering. I am not sure if PLplot has any device drivers that support that. Which system are you working on and with what device drivers? Regards, Arjen |
From: Maurice L. <mj...@br...> - 2008-01-18 08:10:57
|
On Thursday, January 17, 2008 at 21:40:20 (+0100) Torquil Macdonald S=F8= rensen writes: > Hello, >=20 > I have a C++ program that simulates the movements of polygons. It ru= ns a=20 > plotting function e.g. every 100 iterations of the simulation. Why i= s it that=20 > when I use PLPLOT there is lots of flickering, but with PGPLOT it lo= oks great=20 > without any flickering? Is PGPLOT much faster than PLPLOT or am I do= ing=20 > something wrong? With plplot it is too much flickering to be able to= watch=20 > the polygons move around. I have tried setting the xwin device optio= ns=20 > nobuffering and sync, but there was no difference. >=20 > Here is a description of the code: > ... The xwin device with double buffering set (-db from the command line) s= hould do the trick. Do not use sync, that slows the processing of commands b= y the X server way down. Another thing to keep in mind is that the axes should= remain fixed throughout the run, else there will be flickering caused by the t= icks & axis labels moving back & forth. This technique works extremely well on sufficiently simple plots, and n= ot too badly on plots of medium complexity either. To see it in action, try z= ooming & panning using the TK driver / plframe extended TK. > void new_page() { > =09plclear(); > =09plbox("bcinst", 0, 0, "bcinst", 0, 0); > } >=20 > void plot() { > =09new_page(); > =09{..calculate plot quantitie here...} > =09{... some plline() functions...} > } > =09 > int main() { > =09plsdev("xwin"); > =09plinit(); > =09plenv(xmin, xmax, ymin, ymax, 1, -2); >=20 > =09for(int i =3D 0; i !=3D i_max; ++i) { > =09=09{...simulation_code here...} > =09=09if(i % 100 =3D=3D 0) plot(); > =09} >=20 > =09plend(); > =09return(0); > } >=20 > Best regards, > Torquil S=F8rensen --=20 Maurice LeBrun |
From: Werner S. <sm...@ia...> - 2008-01-18 12:22:08
|
Hi, > the usual solution to avoid such flickering is using double-buffering. > I am not sure if PLplot has any device drivers that support that. The wxWidgets driver does also support double buffering. Werner -- Dr. Werner Smekal Institut fuer Allgemeine Physik Technische Universitaet Wien Wiedner Hauptstr 8-10 A-1040 Wien Austria email: sm...@ia... web: http://www.iap.tuwien.ac.at/~smekal phone: +43-(0)1-58801-13463 (office), +43-(0)1-58801-13469 (laboratory) fax: +43-(0)1-58801-13499 |
From: Torquil M. <to...@gm...> - 2008-01-19 12:53:05
|
On Friday 18 January 2008, Werner Smekal wrote: > Hi, > > > the usual solution to avoid such flickering is using double-buffering. > > I am not sure if PLplot has any device drivers that support that. > > The wxWidgets driver does also support double buffering. > > Werner > My previous message got bounced. Let's see if this one goes through :-) Thanks four your suggestions regarding double-buffering, Arjen, Maurice and= =20 Werner. I'm using Debian Sid (kernel 2.6.23) with PLPlot 5.8.0-6. I have an IBM T42= =20 with ATI Mobility Radeon 9600 M10, using the open source radeon X-driver, b= ut=20 the problem is the same on my stationary machine (Debian Sid/kernel 2-6-22)= =20 with an NVIDIA FX5600 card using the driver from NVIDIA. The effect of using double-buffering with the xwin driver was that it did n= ot=20 plot anything until all the for-loop iterations were finished. Then it plot= ted=20 just the last frame. Using the TK driver gives the same result. It also onl= y=20 plots the last frame when using -db. I have made an example program with a rotating radial line that displays a= =20 comparable flickering problem as my simulation, with some comments for the= =20 three different drivers I tried: #include <plplot/plplot.h> #include <cmath> using namespace std; int main(int argc, char *argv[]) { double x[2], y[2]; // Coordinates to plot x[0] =3D 0; y[0] =3D 0; // These are fixed x[1] =3D 1; y[1] =3D 0; // Starting position plparseopts(&argc, argv, PL_PARSE_FULL); =20 /* Driver xwin: Fast. Lots of flickering. When using -db, the plot is black until the loop has finished. Then the last frame in the animation appears. */ // plsdev("xwin"); /* Driver xcairo: About twice as slow as xwin, but still fast enough for my needs. Less flickering but far from perfect. Using -db has no effect on the amount of flickering. */ // plsdev("xcairo"); /* Driver wxwidgets: Much slower than xcairo when not including plsetopt("drvopt", "smooth=3D0"), else about as as fast as xcairo, maybe a tad faster. With pgclear() as below: it only plots some of the box plus the tickmark-numbers, very flickering, with no lines inside the plot. Only the first frame has a clearly visible box (a different problem that is fixed using the smooth=3D0 option). Using -db has no effect. Without pgclear(): Makes a plot that filles a disk, but very slowly compared to xwin and xcairo. -db has no effect. Since pgclear() doesn't work, I found I could use pgadv(0) together with the -np option. Gives lots of flickering, more than xcairo */ plsdev("wxwidgets"); plsetopt("drvopt", "smooth=3D0"); plinit(); plenv(-1, 1, -1, 1, 1, -2); plbox("bcinst", 0, 0, "bcinst", 0, 0); plline(2, x, y); // Plot starting position for(int i =3D 0; i !=3D 1000; ++i) { // New position x[1] =3D cos(double(i)/100); y[1] =3D sin(double(i)/100); // Plot plclear(); // Doesn't work with wxwidgets. //pladv(0); plbox("bcinst", 0, 0, "bcinst", 0, 0); plline(2, x, y); } =20 plend(); return(0); } Best regards, Torquil S=F8rensen |
From: Maurice L. <mj...@br...> - 2008-01-21 09:27:57
|
On Saturday, January 19, 2008 at 13:53:12 (+0100) Torquil Macdonald S=F8= rensen writes: > The effect of using double-buffering with the xwin driver was that i= t did not=20 > plot anything until all the for-loop iterations were finished. Then = it plotted=20 > just the last frame. Using the TK driver gives the same result. It a= lso only=20 > plots the last frame when using -db. The xwin driver only plots at end of page if double buffering is on (i.= e. it plots to the pixmap and then when done it pops it to the display) so yo= u need to do an end of page at the end of each plot. It's safest in my book t= o always use plbop/pleop for individual plots, i.e.: plbop(); .. plot here .. pleop(); Indeed, if you change the plot lines in your for loop to: plbop();=20 plbox("bcinst", 0, 0, "bcinst", 0, 0);=20 plline(2, x, y);=20 pleop();=20 and then invoke with both the -db and -np option, it animates cleanly with the xwin driver. --=20 Maurice LeBrun |
From: Werner S. <sm...@ia...> - 2008-01-21 09:32:31
|
Hi Torquil, thanks again for this report. I made changes to wxwidgets driver which should at least partially resolve your problems. > > /* Driver wxwidgets: Much slower than xcairo when not > including plsetopt("drvopt", "smooth=0"), else about as > as fast as xcairo, maybe a tad faster. If you don't set the smooth option to 0 (it's set to 1 by default), the font will be plotted antialized. This looks rather pretty, but is very slow compared to the non-antialized case. So in your case, set smooth always to 0. You should also be able to improve the plotting speed a little bit, by setting the antialized option to 0 (it's also set to 1 by default) - here the lines, etc. are plotted antialized, looks very nice, but has small impact on the speed (about 10-20%). Only in case your plplot version supports this option. > > With pgclear() as below: it only plots some of the box plus > the tickmark-numbers, very flickering, with no > lines inside the plot. Only the first frame has a clearly > visible box (a different problem that is fixed using the > smooth=0 option). Using -db has no effect. There is no db option in the wxwidgets driver, since it's used by default. In order to improve the time needed for a plot, the wxWidgets driver plots into a memory canvas and only updates the window after about 5000 commands (lines, fills, etc.). It also doesn't copy the whole window, only parts of it, which changed. The reason why you didn't see much when using pgclear() was, that I didn't update the window before I cleared it :) Therefore much of what was plotted never made it to the screen :). Anyway, I commited the change to the svn repository and if you compile plplot from the repository, there should be now no flickering and nice animation of your plot. > > Without pgclear(): Makes a plot that filles a disk, but > very slowly compared to xwin and xcairo. -db has no > effect. Sure. But shouldn't be much slower if you use the smooth=0 option. > > Since pgclear() doesn't work, I found I could use pgadv(0) > together with the -np option. Gives lots of flickering, more > than xcairo */ I can see that too, but I have still to investigate why this happens. > > Regards, Werner -- Dr. Werner Smekal Institut fuer Allgemeine Physik Technische Universitaet Wien Wiedner Hauptstr 8-10 A-1040 Wien Austria email: sm...@ia... web: http://www.iap.tuwien.ac.at/~smekal phone: +43-(0)1-58801-13463 (office), +43-(0)1-58801-13469 (laboratory) fax: +43-(0)1-58801-13499 |
From: Torquil M. <to...@gm...> - 2008-01-21 17:26:43
|
On Monday 21 January 2008, Werner Smekal wrote: > Hi Torquil, > > thanks again for this report. I made changes to wxwidgets driver which > should at least partially resolve your problems. > > > /* Driver wxwidgets: Much slower than xcairo when not > > including plsetopt("drvopt", "smooth=0"), else about as > > as fast as xcairo, maybe a tad faster. > > If you don't set the smooth option to 0 (it's set to 1 by default), > the font will be plotted antialized. This looks rather pretty, but is > very slow compared to the non-antialized case. So in your case, set > smooth always to 0. You should also be able to improve the plotting > speed a little bit, by setting the antialized option to 0 (it's also > set to 1 by default) - here the lines, etc. are plotted antialized, > looks very nice, but has small impact on the speed (about 10-20%). > Only in case your plplot version supports this option. > > > With pgclear() as below: it only plots some of the box plus > > the tickmark-numbers, very flickering, with no > > lines inside the plot. Only the first frame has a clearly > > visible box (a different problem that is fixed using the > > smooth=0 option). Using -db has no effect. > > There is no db option in the wxwidgets driver, since it's used by > default. In order to improve the time needed for a plot, the wxWidgets > driver plots into a memory canvas and only updates the window after > about 5000 commands (lines, fills, etc.). It also doesn't copy the > whole window, only parts of it, which changed. The reason why you > didn't see much when using pgclear() was, that I didn't update the > window before I cleared it :) Therefore much of what was plotted never > made it to the screen :). > > Anyway, I commited the change to the svn repository and if you compile > plplot from the repository, there should be now no flickering and nice > animation of your plot. Thanks Werner! I have just tried todays SVN. I now always use smooth=0 with wxwidgets. pgclear() now works. I can choose between enclosing each plot iteration with plbop()....pleop(), or using plclear(). There is no longer any flickering in the surrounding box. When using plclear() between each plot there is some flickering in the elements that I can see. But I no longer see the "x" and "y", and other changing text that I write with pllab("x", "y", "top"); and plmtex(...) (plmtex writes a number that increases with the iterations of the simulation), but I _can_ see the text "top" at the top of the plot. It also flickers along with the tickmark-numbers. When using plbop().....pleop() around each plot iteration, I can see all the text that should be there, but with quite alot of flickering in them. As I said, the surrounding box does not flicker in any of these cases. But there is another problem that has arisen: Now pgclear() doesn't work with the xwin-driver + double-buffering. Only part of the box around the plot is then displayed. For xwin I now have to enclose the plot commands in plbop().......pleop() to get a correct plot. I'm not quite sure but I think it worked before with only plclear() and xwin+db. -Torquil |
From: Werner S. <sm...@ia...> - 2008-01-22 19:39:02
|
Hi Torquil, > Thanks Werner! I have just tried todays SVN. I now always use smooth=0 with > wxwidgets. pgclear() now works. I can choose between enclosing each plot > iteration with plbop()....pleop(), or using plclear(). There is no longer any > flickering in the surrounding box. > > When using plclear() between each plot there is some flickering in the > elements that I can see. But I no longer see the "x" and "y", and other > changing text that I write with pllab("x", "y", "top"); and plmtex(...) > (plmtex writes a number that increases with the iterations of the > simulation), but I _can_ see the text "top" at the top of the plot. It also > flickers along with the tickmark-numbers. > > When using plbop().....pleop() around each plot iteration, I can see all the > text that should be there, but with quite alot of flickering in them. For me, when I use plbop/pleop I also see flickering (in the moment I only test on Windows XP, which might be different to wxGTK/Linux) and so far I haven't had the chance to dig into this case, maybe tomorrow or the day after. > > As I said, the surrounding box does not flicker in any of these cases. > > But there is another problem that has arisen: Now pgclear() doesn't work with > the xwin-driver + double-buffering. Only part of the box around the plot is > then displayed. For xwin I now have to enclose the plot commands in > plbop().......pleop() to get a correct plot. I'm not quite sure but I think > it worked before with only plclear() and xwin+db. I'm quite sure, that there were no changes regarding the xwin driver the last months, therefore there should be no difference, between svn-plplot and plplot 5.8.0. You could try to have a look at drivers/xwin.c and see if you can find something, the xwin driver code is quite huge, but if you look just at the interface code to the plplot library (pl_init/pl_line/pl_polyline or something like that) you should soon get an idea about how the driver works. Maybe you spot some problems. Regards, Werner > > -Torquil > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2008. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > Plplot-general mailing list > Plp...@li... > https://lists.sourceforge.net/lists/listinfo/plplot-general -- Dr. Werner Smekal Institut fuer Allgemeine Physik Technische Universitaet Wien Wiedner Hauptstr 8-10 A-1040 Wien Austria email: sm...@ia... web: http://www.iap.tuwien.ac.at/~smekal phone: +43-(0)1-58801-13463 (office) +43-(0)1-58801-13469 (laboratory) fax: +43-(0)1-58801-13499 |