From: <and...@us...> - 2008-12-16 13:22:19
|
Revision: 9127 http://plplot.svn.sourceforge.net/plplot/?rev=9127&view=rev Author: andrewross Date: 2008-12-16 11:40:32 +0000 (Tue, 16 Dec 2008) Log Message: ----------- Further updates to C examples to more fully test the common API. Modified Paths: -------------- trunk/doc/docbook/src/api.xml trunk/examples/c/x01c.c trunk/examples/c/x03c.c trunk/examples/c/x13c.c trunk/examples/c/x29c.c trunk/examples/c/x31c.c Modified: trunk/doc/docbook/src/api.xml =================================================================== --- trunk/doc/docbook/src/api.xml 2008-12-15 21:41:52 UTC (rev 9126) +++ trunk/doc/docbook/src/api.xml 2008-12-16 11:40:32 UTC (rev 9127) @@ -339,7 +339,7 @@ </para> <para> - This function is used in examples 1,2,4,6-12,14-18,20,21,23-27,29. + This function is used in examples 1,2,4,6-12,14-18,20,21,23-27,29,31. </para> </sect1> @@ -1499,7 +1499,7 @@ </para> <para> - This function is not used in any examples. + This function is used in example 31. </para> </sect1> @@ -3565,7 +3565,7 @@ </para> <para> - This function is not used in any examples. + This function is used in example 31. </para> </sect1> @@ -3646,7 +3646,7 @@ </variablelist> <para> - This function is not used in any examples. + This function is used in example 31. </para> </sect1> @@ -3693,7 +3693,7 @@ </para> <para> - This function is not used in any examples. + This function is used in example 31. </para> </sect1> @@ -3827,7 +3827,7 @@ </para> <para> - This function is not used in any examples. + This function is used in example 31. </para> </sect1> @@ -3968,7 +3968,7 @@ </para> <para> - This function is not used in any examples. + This function is used in example 31. </para> </sect1> @@ -4039,7 +4039,7 @@ </para> <para> - This function is not used in any examples. + This function is used in example 31. </para> </sect1> @@ -4130,7 +4130,7 @@ </para> <para> - This function is not used in any examples. + This function is used in example 31. </para> </sect1> @@ -4279,7 +4279,7 @@ </para> <para> - This function is not used in any examples. + This function is used in example 31. </para> </sect1> @@ -4386,7 +4386,7 @@ </para> <para> - This function is not used in any examples. + This function is used in example 31. </para> </sect1> @@ -4957,7 +4957,7 @@ </para> <para> - This function is not used in any examples. + This function is used in example 31. </para> </sect1> @@ -5049,7 +5049,7 @@ </para> <para> - This function is not used in any examples. + This function is used in example 31. </para> </sect1> @@ -5115,7 +5115,7 @@ </para> <para> - This function is not used in any examples. + This function is used in example 31. </para> </sect1> @@ -5176,7 +5176,7 @@ </para> <para> - This function is not used in any examples. + This function is used in example 31. </para> </sect1> @@ -5237,7 +5237,7 @@ </para> <para> - This function is not used in any examples. + This function is used in example 31. </para> </sect1> @@ -9057,7 +9057,7 @@ </para> <para> - This function is not used in any examples. + This function is used in example 31. </para> </sect1> @@ -9154,7 +9154,7 @@ </variablelist> <para> - This function is not used in any examples. + This function is used in example 31. </para> </sect1> @@ -9754,7 +9754,7 @@ </para> <para> - This function is used in example 15. + This function is used in examples 15,31. </para> </sect1> @@ -9836,7 +9836,7 @@ </variablelist> <para> - This function is not used in any examples. + This function is used in example 31. </para> </sect1> @@ -9882,7 +9882,7 @@ </para> <para> - This function is not used in any examples. + This function is used in example 31. </para> </sect1> @@ -9930,7 +9930,7 @@ </para> <para> - This function is not used in any examples. + This function is used in example 31. </para> </sect1> @@ -10065,7 +10065,7 @@ </para> <para> - This function is not used in any examples. + This function is used in example 31. </para> </sect1> @@ -10312,7 +10312,7 @@ </para> <para> - This function is not used in any examples. + This function is used in example 31. </para> </sect1> @@ -10401,7 +10401,7 @@ </para> <para> - This function is not used in any examples. + This function is used in example 31. </para> </sect1> @@ -10510,7 +10510,7 @@ </para> <para> - This function is not used in any examples. + This function is used in example 29. </para> </sect1> @@ -10645,7 +10645,7 @@ </para> <para> - This function is not used in any examples. + This function is used in example 31. </para> </sect1> @@ -12027,7 +12027,7 @@ </para> <para> - This function is not used in any examples. + This function is used in example 3. </para> </sect1> @@ -12135,7 +12135,7 @@ </para> <para> - This function is not used in any examples. + This function is used in example 31. </para> </sect1> @@ -12410,7 +12410,7 @@ </para> <para> - This function is not used in any examples. + This function is used in example 1. </para> </sect1> @@ -13423,7 +13423,7 @@ </para> <para> - This function is not used in any examples. + This function is used in example 31. </para> </sect1> @@ -13486,7 +13486,7 @@ </para> <para> - This function is used in examples 1,14. + This function is used in examples 1,14,31. </para> </sect1> @@ -13635,7 +13635,7 @@ </para> <para> - This function is not used in any examples. + This function is used in example 31. </para> </sect1> @@ -13825,7 +13825,7 @@ </para> <para> - This function is not used in any examples. + This function is used in example 13. </para> </sect1> @@ -14142,7 +14142,7 @@ </para> <para> - This function is used in examples 2,6-8,10,11,15,16,18,21,23,24,26,27. + This function is used in examples 2,6-8,10,11,15,16,18,21,23,24,26,27,31. </para> </sect1> @@ -14501,7 +14501,7 @@ </para> <para> - This function is used in examples 1,2,4,6-12,14-16,18,21,23-27,29. + This function is used in examples 1,2,4,6-12,14-16,18,21,23-27,29,31. </para> </sect1> Modified: trunk/examples/c/x01c.c =================================================================== --- trunk/examples/c/x01c.c 2008-12-15 21:41:52 UTC (rev 9126) +++ trunk/examples/c/x01c.c 2008-12-16 11:40:32 UTC (rev 9127) @@ -111,10 +111,7 @@ char ver[80]; /* plplot initialization */ -/* Divide page into 2x2 plots unless user overrides */ - plssub(2, 2); - /* Parse and process command line arguments */ plMergeOpts(options, "x01c options", notes); @@ -126,8 +123,10 @@ fprintf(stdout, "PLplot library version: %s\n", ver); /* Initialize plplot */ +/* Divide page into 2x2 plots */ +/* Note: calling plstar replaces separate calls to plssub and plinit */ + plstar(2,2); - plinit(); /* Select font set as per input flag */ if (fontset) Modified: trunk/examples/c/x03c.c =================================================================== --- trunk/examples/c/x03c.c 2008-12-15 21:41:52 UTC (rev 9126) +++ trunk/examples/c/x03c.c 2008-12-16 11:40:32 UTC (rev 9127) @@ -30,6 +30,10 @@ (void) plparseopts(&argc, argv, PL_PARSE_FULL); +/* Set orientation to landscape - note not all device drivers + * support this, in particular most interactive drivers do not */ + plsori(1); + /* Initialize plplot */ plinit(); Modified: trunk/examples/c/x13c.c =================================================================== --- trunk/examples/c/x13c.c 2008-12-15 21:41:52 UTC (rev 9126) +++ trunk/examples/c/x13c.c 2008-12-16 11:40:32 UTC (rev 9127) @@ -41,7 +41,12 @@ plinit(); - plenv(0., 10., 0., 10., 1, -2); + pladv(0); + /* Ensure window has aspect ratio of one so circle is + * plotted as a circle. */ + plvasp(1.0); + plwind(0., 10., 0., 10.); + //plenv(0., 10., 0., 10., 1, -2); plcol0(2); /* n.b. all theta quantities scaled by 2*M_PI/500 to be integers to avoid * floating point logic problems. */ Modified: trunk/examples/c/x29c.c =================================================================== --- trunk/examples/c/x29c.c 2008-12-15 21:41:52 UTC (rev 9126) +++ trunk/examples/c/x29c.c 2008-12-16 11:40:32 UTC (rev 9127) @@ -60,6 +60,9 @@ /* Initialize plplot */ plinit(); + /* Change the escape character to a '@' instead of the default '#' + plsesc('@'); + plot1(); plot2(); @@ -114,7 +117,7 @@ plbox("bcnstd", 3.0*60*60, 3, "bcnstv", 1, 5); plcol0(3); - pllab("Time (hours:mins)", "Temperature (degC)", "#frPLplot Example 29 - Daily temperature"); + pllab("Time (hours:mins)", "Temperature (degC)", "@frPLplot Example 29 - Daily temperature"); plcol0(4); @@ -168,7 +171,7 @@ plcol0(3); - pllab("Date", "Hours of daylight", "#frPLplot Example 29 - Hours of daylight at 51.5N"); + pllab("Date", "Hours of daylight", "@frPLplot Example 29 - Hours of daylight at 51.5N"); plcol0(4); @@ -239,7 +242,7 @@ plbox("bcnstd", 14*24.0*60.0*60.0,14, "bcnstv", 1, 4); plcol0(3); - pllab("Date", "Hours of television watched", "#frPLplot Example 29 - Hours of television watched in Dec 2005 / Jan 2006"); + pllab("Date", "Hours of television watched", "@frPLplot Example 29 - Hours of television watched in Dec 2005 / Jan 2006"); plcol0(4); Modified: trunk/examples/c/x31c.c =================================================================== --- trunk/examples/c/x31c.c 2008-12-15 21:41:52 UTC (rev 9126) +++ trunk/examples/c/x31c.c 2008-12-16 11:40:32 UTC (rev 9127) @@ -14,25 +14,178 @@ int main(int argc, const char *argv[]) { - PLFLT xmin, xmax, ymin, ymax; + PLFLT xmin, xmax, ymin, ymax, wx, wy; + PLFLT mar, aspect, jx, jy, ori; + PLINT win, level, digmax, digits, compression; + PLFLT xp, yp, xp2, yp2; + PLINT xleng, yleng, xoff, yoff, xleng2, yleng2; + PLINT fam, num, bmax, r, g, b; + PLFLT a; + PLINT r1[] = {0, 255}; + PLINT g1[] = {255, 0}; + PLINT b1[] = {0, 0}; + PLFLT a1[] = {1.0, 1.0}; + char fnam[80]; + /* Parse and process command line arguments */ (void) plparseopts(&argc, argv, PL_PARSE_FULL); + /* Test setting / getting page size */ + plgpage(&xp, &yp, &xleng, &yleng, &xoff, &yoff); + xp2 = xp*0.9; + yp2 = yp*0.9; + xleng2 = (PLINT)(xleng*0.9); + yleng2 = (PLINT)(yleng*0.9); + plspage(xp2, yp2, xleng2, yleng2, xoff, yoff); + plgpage(&xp, &yp, &xleng, &yleng, &xoff, &yoff); + if (xp != xp2 || yp != yp2 || xleng != xleng2 || yleng != yleng2) { + fputs("plgpage test failed\n",stderr); + plend(); + exit(1); + } + + plscompression(1); + plgcompression(&compression); + if (compression != 1) { + fputs("plgcompression test failed\n",stderr); + plend(); + exit(1); + } + + plsfam(1,1,100000); + plgfam(&fam, &num, &bmax); + if (fam != 1 || num != 1 || bmax != 100000) { + fputs("plgfam test failed\n",stderr); + plend(); + exit(1); + } + /* Initialize plplot */ plinit(); + plscolor(1); + + plscol0(1, 255, 0, 0); + + plscmap1(r1,g1,b1,2); + plscmap1a(r1,g1,b1,a1,2); + + plglevel(&level); + if (level != 1) { + fprintf(stderr,"plglevel test failed. Level is %d, but 1 expected.\n",level); + plend(); + exit(1); + } + pladv(0); plvpor(0.0, 1.0, 0.0, 1.0); plwind(0.2, 0.3, 0.4, 0.5); plgvpw(&xmin, &xmax, &ymin, &ymax); if (xmin != 0.2 || xmax != 0.3 || ymin != 0.4 || ymax != 0.5) { - fprintf(stderr, "%s\n", "plgvpw test failed"); + fputs("plgvpw test failed\n",stderr); plend(); exit(1); } + + plgvpd(&xmin, &xmax, &ymin, &ymax); + if (xmin != 0.0 || xmax != 1.0 || ymin != 0.0 || ymax != 1.0) { + fputs("plgvpd test failed\n",stderr); + plend(); + exit(1); + } + + /* Get world coordinates for 0.5,0.5 which is in the middle of + * the window */ + plcalc_world(0.5,0.5,&wx,&wy,&win); + if (fabs(wx-0.25)>1.0E-5 || fabs(wy-0.45)>1.0E-5) { + fputs("plcalc_world test failed\n",stderr); + plend(); + exit(1); + } + + /* Retrieve and print the name of the output file (if any) */ + plgfnam(fnam); + printf("Output file name is %s\n",fnam); + + /* Set and get the number of digits used to display axis labels */ + /* Note digits is currently ignored in pls[xyz]ax and + therefore it does not make sense to test the returned + value */ + plsxax(3,0); + plgxax(&digmax,&digits); + if (digmax != 3) { + fputs("plgxax test failed\n",stderr); + plend(); + exit(1); + } + + plsyax(3,0); + plgyax(&digmax,&digits); + if (digmax != 3) { + fputs("plgyax test failed\n",stderr); + plend(); + exit(1); + } + + plszax(3,0); + plgzax(&digmax,&digits); + if (digmax != 3) { + fputs("plgzax test failed\n",stderr); + plend(); + exit(1); + } + + plsdidev(0.05, PL_NOTSET, 0.0, 0.0); + plgdidev(&mar, &aspect, &jx, &jy); + if (mar != 0.05 || jx != 0.0 || jy != 0.0) { + fputs("plgdidev test failed\n",stderr); + plend(); + exit(1); + } + + plsdiori(1.0); + plgdiori(&ori); + if (ori != 1.0) { + fputs("plgdiori test failed\n",stderr); + plend(); + exit(1); + } + + plsdiplt(0.1, 0.1, 0.9, 0.9); + plgdiplt(&xmin, &ymin, &xmax, &ymax); + if (xmin != 0.1 || xmax != 0.9 || ymin != 0.1 || ymax != 0.9) { + fputs("plgdiplt test failed\n",stderr); + plend(); + exit(1); + } + + plsdiplz(0.1, 0.1, 0.9, 0.9); + plgdiplt(&xmin, &ymin, &xmax, &ymax); + if (xmin != 0.1+0.8*0.1 || xmax != 0.1+0.8*0.9 || ymin != 0.1+0.8*0.1 || ymax != 0.1+0.8*0.9) { + fputs("plsdiplz test failed\n",stderr); + plend(); + exit(1); + } + + plscolbg(0,0,0); + plgcolbg(&r, &g, &b); + if (r != 0 || g != 0 || b != 0) { + fputs("plgcolbg test failed\n",stderr); + plend(); + exit(1); + } + + plscolbga(0,0,0,1.0); + plgcolbga(&r, &g, &b, &a); + if (r != 0 || g != 0 || b != 0 || a != 1.0) { + fputs("plgcolbga test failed\n",stderr); + plend(); + exit(1); + } + plend(); exit(0); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |