From: <sm...@us...> - 2009-05-11 14:08:21
|
Revision: 9963 http://plplot.svn.sourceforge.net/plplot/?rev=9963&view=rev Author: smekal Date: 2009-05-11 14:08:05 +0000 (Mon, 11 May 2009) Log Message: ----------- Further improvements on D bindings. Changed examples accordingly. Modified Paths: -------------- trunk/bindings/d/plplot.d trunk/examples/d/x12d.d trunk/examples/d/x13d.d trunk/examples/d/x24d.d trunk/examples/d/x25d.d trunk/examples/d/x29d.d trunk/examples/d/x30d.d Modified: trunk/bindings/d/plplot.d =================================================================== --- trunk/bindings/d/plplot.d 2009-05-11 08:29:49 UTC (rev 9962) +++ trunk/bindings/d/plplot.d 2009-05-11 14:08:05 UTC (rev 9963) @@ -40,15 +40,25 @@ void plbin(PLFLT[] x, PLFLT[] y, PLINT opt) { PLINT nbin = x.length; - assert(nbin==y.length, "Arrays must be of same length!"); - c_plbin(nbin, cast(PLFLT*)x, cast(PLFLT*)y, opt); + assert(nbin==y.length, "plbin(): Arrays must be of same length!"); + c_plbin(nbin, x.ptr, y.ptr, opt); } /* This draws a box around the current viewport. */ -//void c_plbox(char *xopt, PLFLT xtick, PLINT nxsub, char *yopt, PLFLT ytick, PLINT nysub); +void plbox(string xopt, PLFLT xtick, PLINT nxsub, string yopt, PLFLT ytick, PLINT nysub) +{ + c_plbox(toStringz(xopt), xtick, nxsub, toStringz(yopt), ytick, nysub); +} /* This is the 3-d analogue of plbox(). */ -//void c_plbox3(char *xopt, char *xlabel, PLFLT xtick, PLINT nsubx, char *yopt, char *ylabel, PLFLT ytick, PLINT nsuby, char *zopt, char *zlabel, PLFLT ztick, PLINT nsubz); +void plbox3(string xopt, string xlabel, PLFLT xtick, PLINT nsubx, + string yopt, string ylabel, PLFLT ytick, PLINT nsuby, + string zopt, string zlabel, PLFLT ztick, PLINT nsubz) +{ + c_plbox3(toStringz(xopt), toStringz(xlabel), xtick, nsubx, + toStringz(yopt), toStringz(ylabel), ytick, nsuby, + toStringz(zopt), toStringz(zlabel), ztick, nsubz); +} /* Draws a contour plot from data in f(nx,ny). Is just a front-end to * plfcont, with a particular choice for f2eval and f2eval_data. @@ -62,16 +72,39 @@ //void plfcont(PLFLT function(PLINT , PLINT , PLPointer )f2eval, PLPointer f2eval_data, PLINT nx, PLINT ny, PLINT kx, PLINT lx, PLINT ky, PLINT ly, PLFLT *clevel, PLINT nlevel, void function(PLFLT , PLFLT , PLFLT *, PLFLT *, PLPointer )pltr, PLPointer pltr_data); /* Plot horizontal error bars (xmin(i),y(i)) to (xmax(i),y(i)) */ -//void c_plerrx(PLINT n, PLFLT *xmin, PLFLT *xmax, PLFLT *y); +void plerrx(PLFLT[] xmin, PLFLT[] xmax, PLFLT[] y) +{ + PLINT n=y.length; + assert(n==xmin.length, "plerrx(): Arrays must be of same length!"); + assert(n==xmax.length, "plerrx(): Arrays must be of same length!"); + c_plerrx(n, xmin.ptr, xmax.ptr, y.ptr); +} /* Plot vertical error bars (x,ymin(i)) to (x(i),ymax(i)) */ -//void c_plerry(PLINT n, PLFLT *x, PLFLT *ymin, PLFLT *ymax); +void plerry(PLFLT[] x, PLFLT[] ymin, PLFLT[] ymax) +{ + PLINT n=x.length; + assert(n==ymin.length, "plerry(): Arrays must be of same length!"); + assert(n==ymax.length, "plerry(): Arrays must be of same length!"); + c_plerry(n, x.ptr, ymin.ptr, ymax.ptr); +} /* Pattern fills the polygon bounded by the input points. */ -//void c_plfill(PLINT n, PLFLT *x, PLFLT *y); +void plfill(PLFLT[] x, PLFLT[] y) +{ + PLINT n=x.length; + assert(n==y.length, "plfill(): Arrays must be of same length!"); + c_plfill(n, x.ptr, y.ptr); +} /* Pattern fills the 3d polygon bounded by the input points. */ -//void c_plfill3(PLINT n, PLFLT *x, PLFLT *y, PLFLT *z); +void plfill3(PLFLT[] x, PLFLT[] y, PLFLT[] z) +{ + PLINT n=x.length; + assert(n==y.length, "plfill3(): Arrays must be of same length!"); + assert(n==z.length, "plfill3(): Arrays must be of same length!"); + c_plfill3(n, x.ptr, y.ptr, z.ptr); +} /* Get the current device (keyword) name */ //void c_plgdev(char *p_dev); @@ -89,14 +122,17 @@ //void c_plhist(PLINT n, PLFLT *data, PLFLT datmin, PLFLT datmax, PLINT nbin, PLINT opt); /* Simple routine for labelling graphs. */ -//void c_pllab(char *xlabel, char *ylabel, char *tlabel); +void pllab(string xlabel, string ylabel, string tlabel) +{ + c_pllab(toStringz(xlabel), toStringz(ylabel), toStringz(tlabel)); +} /* Draws line segments connecting a series of points. */ void plline(PLFLT[] x, PLFLT[] y) { PLINT n = x.length; - assert(n==y.length, "Arrays must be of same length!"); - c_plline(n, cast(PLFLT*)x, cast(PLFLT*)y); + assert(n==y.length, "plline(): Arrays must be of same length!"); + c_plline(n, x.ptr, y.ptr); } /* Draws a line in 3 space. */ @@ -684,8 +720,8 @@ alias c_plaxes plaxes; //alias c_plbin plbin; alias c_plbop plbop; -alias c_plbox plbox; -alias c_plbox3 plbox3; +//alias c_plbox plbox; +//alias c_plbox3 plbox3; alias c_plcalc_world plcalc_world; alias c_plclear plclear; alias c_plcol0 plcol0; @@ -698,11 +734,11 @@ alias c_plenv plenv; alias c_plenv0 plenv0; alias c_pleop pleop; -alias c_plerrx plerrx; -alias c_plerry plerry; +//alias c_plerrx plerrx; +//alias c_plerry plerry; alias c_plfamadv plfamadv; -alias c_plfill plfill; -alias c_plfill3 plfill3; +//alias c_plfill plfill; +//alias c_plfill3 plfill3; alias c_plflush plflush; alias c_plfont plfont; alias c_plfontld plfontld; @@ -739,7 +775,7 @@ alias c_plimagefr plimagefr; alias c_plinit plinit; alias c_pljoin pljoin; -alias c_pllab pllab; +//alias c_pllab pllab; alias c_pllightsource pllightsource; //alias c_plline plline; alias c_plline3 plline3; @@ -876,7 +912,6 @@ /* This functions similarly to plbox() except that the origin of the axes */ /* is placed at the user-specified point (x0, y0). */ - void c_plaxes(PLFLT x0, PLFLT y0, char *xopt, PLFLT xtick, PLINT nxsub, char *yopt, PLFLT ytick, PLINT nysub); /* Flags for plbin() - opt argument */ @@ -893,13 +928,11 @@ void c_plbop(); /* This draws a box around the current viewport. */ +void c_plbox(char *xopt, PLFLT xtick, PLINT nxsub, char *yopt, PLFLT ytick, PLINT nysub); -void c_plbox(char *xopt, PLFLT xtick, PLINT nxsub, char *yopt, PLFLT ytick, PLINT nysub); - /* This is the 3-d analogue of plbox(). */ +void c_plbox3(char *xopt, char *xlabel, PLFLT xtick, PLINT nsubx, char *yopt, char *ylabel, PLFLT ytick, PLINT nsuby, char *zopt, char *zlabel, PLFLT ztick, PLINT nsubz); -void c_plbox3(char *xopt, char *xlabel, PLFLT xtick, PLINT nsubx, char *yopt, char *ylabel, PLFLT ytick, PLINT nsuby, char *zopt, char *zlabel, PLFLT ztick, PLINT nsubz); - /* Calculate world coordinates and subpage from relative device coordinates. */ void c_plcalc_world(PLFLT rx, PLFLT ry, PLFLT *wx, PLFLT *wy, PLINT *window); @@ -968,25 +1001,21 @@ void c_pleop(); /* Plot horizontal error bars (xmin(i),y(i)) to (xmax(i),y(i)) */ +void c_plerrx(PLINT n, PLFLT *xmin, PLFLT *xmax, PLFLT *y); -void c_plerrx(PLINT n, PLFLT *xmin, PLFLT *xmax, PLFLT *y); - /* Plot vertical error bars (x,ymin(i)) to (x(i),ymax(i)) */ +void c_plerry(PLINT n, PLFLT *x, PLFLT *ymin, PLFLT *ymax); -void c_plerry(PLINT n, PLFLT *x, PLFLT *ymin, PLFLT *ymax); - /* Advance to the next family file on the next new page */ void c_plfamadv(); /* Pattern fills the polygon bounded by the input points. */ +void c_plfill(PLINT n, PLFLT *x, PLFLT *y); -void c_plfill(PLINT n, PLFLT *x, PLFLT *y); - /* Pattern fills the 3d polygon bounded by the input points. */ +void c_plfill3(PLINT n, PLFLT *x, PLFLT *y, PLFLT *z); -void c_plfill3(PLINT n, PLFLT *x, PLFLT *y, PLFLT *z); - /* Flushes the output stream. Use sparingly, if at all. */ void c_plflush(); @@ -1141,9 +1170,8 @@ void c_pljoin(PLFLT x1, PLFLT y1, PLFLT x2, PLFLT y2); /* Simple routine for labelling graphs. */ +void c_pllab(char *xlabel, char *ylabel, char *tlabel); -void c_pllab(char *xlabel, char *ylabel, char *tlabel); - /* Sets position of the light source */ void c_pllightsource(PLFLT x, PLFLT y, PLFLT z); Modified: trunk/examples/d/x12d.d =================================================================== --- trunk/examples/d/x12d.d 2009-05-11 08:29:49 UTC (rev 9962) +++ trunk/examples/d/x12d.d 2009-05-11 14:08:05 UTC (rev 9963) @@ -54,7 +54,7 @@ PLFLT[4] x = [x0, x0, x0+1.0, x0+1.0];; PLFLT[4] y = [0.0, y0, y0, 0.0]; - plfill( 4, cast(PLFLT*)x, cast(PLFLT*)y ); + plfill(x, y); plcol0( 1 ); pllsty( 1 ); plline(x, y); Modified: trunk/examples/d/x13d.d =================================================================== --- trunk/examples/d/x13d.d 2009-05-11 08:29:49 UTC (rev 9962) +++ trunk/examples/d/x13d.d 2009-05-11 14:08:05 UTC (rev 9963) @@ -52,7 +52,7 @@ } plcol0( i+1 ); plpsty( (i+3)%8+1 ); - plfill( j, cast(PLFLT*)x, cast(PLFLT*)y ); + plfill(x, y); plcol0( 1 ); plline(x, y); just = (2.*PI/500.)*(theta0 + theta1)/2.; Modified: trunk/examples/d/x24d.d =================================================================== --- trunk/examples/d/x24d.d 2009-05-11 08:29:49 UTC (rev 9962) +++ trunk/examples/d/x24d.d 2009-05-11 14:08:05 UTC (rev 9963) @@ -139,7 +139,7 @@ for(int i = 0; i < 4; i++ ) { plcol0(i + 1); - plfill(4, cast(PLFLT*)px, cast(PLFLT*)py); + plfill(px, py); for(int j = 0; j < py.length; j++) py[j] += 1.0/4.0; Modified: trunk/examples/d/x25d.d =================================================================== --- trunk/examples/d/x25d.d 2009-05-11 08:29:49 UTC (rev 9962) +++ trunk/examples/d/x25d.d 2009-05-11 14:08:05 UTC (rev 9963) @@ -80,7 +80,7 @@ plbox("bc", 1.0, 0, "bcnv", 10.0, 0); plcol0(1); plpsty(0); - plfill(x0.length, cast(PLFLT*)x0, cast(PLFLT*)y0); + plfill(x0, y0); plcol0(2); pllsty(1); plline(x0, y0); Modified: trunk/examples/d/x29d.d =================================================================== --- trunk/examples/d/x29d.d 2009-05-11 08:29:49 UTC (rev 9962) +++ trunk/examples/d/x29d.d 2009-05-11 14:08:05 UTC (rev 9963) @@ -132,9 +132,9 @@ plline(x, y); plcol0(2); - plerrx(npts, cast(PLFLT*)xerr1, cast(PLFLT*)xerr2, cast(PLFLT*)y); + plerrx(xerr1, xerr2, y); plcol0(3); - plerry(npts, cast(PLFLT*)x, cast(PLFLT*)yerr1, cast(PLFLT*)yerr2); + plerry(x, yerr1, yerr2); /* Rescale major / minor tick marks back to default */ plsmin(0.0, 1.0); Modified: trunk/examples/d/x30d.d =================================================================== --- trunk/examples/d/x30d.d 2009-05-11 08:29:49 UTC (rev 9962) +++ trunk/examples/d/x30d.d 2009-05-11 14:08:05 UTC (rev 9963) @@ -81,7 +81,7 @@ plcol0(icol); /* Draw the rectangle */ - plfill(4, cast(PLFLT*)px, cast(PLFLT*)py); + plfill(px, py); /* Shift the rectangles coordinates */ for(int j=0; j<4; j++) { @@ -125,7 +125,7 @@ py[1] = py[0]; py[2] = py[0] + 0.1; py[3] = py[2]; - plfill(4, cast(PLFLT*)px, cast(PLFLT*)py); + plfill(px, py); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |