From: <and...@us...> - 2008-10-12 21:28:24
|
Revision: 8887 http://plplot.svn.sourceforge.net/plplot/?rev=8887&view=rev Author: andrewross Date: 2008-10-12 21:28:14 +0000 (Sun, 12 Oct 2008) Log Message: ----------- Ocaml patch from commited by ANR on behalf of Hez Carty. This patch 1) Fixes plgfci support for ocaml. 2) Tidies up the 3D API for plmesh, plsurf3d and plot3d. 3) Cleans up the examples to remove some outdated comments. Modified Paths: -------------- trunk/bindings/ocaml/plplot.idl trunk/bindings/ocaml/plplot_h trunk/bindings/ocaml/plplot_h.inc trunk/bindings/ocaml/touchup.ml trunk/examples/ocaml/x08.ml trunk/examples/ocaml/x09.ml trunk/examples/ocaml/x11.ml trunk/examples/ocaml/x21.ml trunk/examples/ocaml/x23.ml trunk/examples/ocaml/x28.ml Modified: trunk/bindings/ocaml/plplot.idl =================================================================== --- trunk/bindings/ocaml/plplot.idl 2008-10-12 19:58:13 UTC (rev 8886) +++ trunk/bindings/ocaml/plplot.idl 2008-10-12 21:28:14 UTC (rev 8887) @@ -17,6 +17,22 @@ along with ocaml-plplot. If not, see <http://www.gnu.org/licenses/>. */ +// Taken from the plplot.h 3D plot style definitions +enum plplot3d_style_enum { + PL_DIFFUSE = 0, + PL_DRAW_LINEX = 1, + PL_DRAW_LINEY = 2, + PL_DRAW_LINEXY = 3, + PL_MAG_COLOR = 4, + PL_BASE_CONT = 8, + PL_TOP_CONT = 16, + PL_SURF_CONT = 32, + PL_DRAW_SIDES = 64, + PL_FACETED = 128, + PL_MESH = 256 +}; +typedef [set] enum plplot3d_style_enum plplot3d_style; + // This is a simplified and modified version of the plplot.h file. #include "plplot_h.inc" @@ -141,11 +157,3 @@ RAW_ML(external plgriddata : float array -> float array -> float array -> float array -> float array -> plplot_grid_method_type -> float -> float array array = "ml_plgriddata_bytecode" "ml_plgriddata") RAW_ML(external plparseopts : string array -> plplot_parse_method_type array -> int = "ml_plparseopts") -// Taken from the plplot.h 3D plot style definitions -// XXX TODO This is currently unused... -/* -enum plot_style_enum { DRAW_LINEX = 1, DRAW_LINEY = 2, DRAW_LINEXY = 3, MAG_COLOR = 4, - BASE_CONT = 8, TOP_CONT = 16, SURF_CONT = 32, DRAW_SIDES = 64, - FACETED = 128, MESH = 256 }; -typedef [set] enum plot_style_enum plot_style; -*/ Modified: trunk/bindings/ocaml/plplot_h =================================================================== --- trunk/bindings/ocaml/plplot_h 2008-10-12 19:58:13 UTC (rev 8886) +++ trunk/bindings/ocaml/plplot_h 2008-10-12 21:28:14 UTC (rev 8887) @@ -3,7 +3,7 @@ //typedef unsigned int PLUNICODE; //typedef int PLINT; -#define PLUNICODE unsigned int +#define PLUNICODE long long #define PLINT int //typedef PLINT PLBOOL; @@ -257,10 +257,10 @@ */ void -c_plmesh(PLFLT *x, PLFLT *y, PLFLT **z, PLINT nx, PLINT ny, PLINT opt); +c_plmesh(PLFLT *x, PLFLT *y, PLFLT **z, PLINT nx, PLINT ny, plplot3d_style opt); void -c_plmeshc(PLFLT *x, PLFLT *y, PLFLT **z, PLINT nx, PLINT ny, PLINT opt, +c_plmeshc(PLFLT *x, PLFLT *y, PLFLT **z, PLINT nx, PLINT ny, plplot3d_style opt, PLFLT *clevel, PLINT nlevel); void @@ -276,11 +276,11 @@ void c_plot3d(PLFLT *x, PLFLT *y, PLFLT **z, - PLINT nx, PLINT ny, PLINT opt, PLBOOL side); + PLINT nx, PLINT ny, plplot3d_style opt, PLBOOL side); void c_plot3dc(PLFLT *x, PLFLT *y, PLFLT **z, - PLINT nx, PLINT ny, PLINT opt, + PLINT nx, PLINT ny, plplot3d_style opt, PLFLT *clevel, PLINT nlevel); /* @@ -530,7 +530,7 @@ void c_plsurf3d(PLFLT *x, PLFLT *y, PLFLT **z, PLINT nx, PLINT ny, - PLINT opt, PLFLT *clevel, PLINT nlevel); + plplot3d_style opt, PLFLT *clevel, PLINT nlevel); /* void Modified: trunk/bindings/ocaml/plplot_h.inc =================================================================== --- trunk/bindings/ocaml/plplot_h.inc 2008-10-12 19:58:13 UTC (rev 8886) +++ trunk/bindings/ocaml/plplot_h.inc 2008-10-12 21:28:14 UTC (rev 8887) @@ -35,7 +35,7 @@ [mlname(plgdidev)] void c_plgdidev ( [out] double * p_mar, [out] double * p_aspect, [out] double * p_jx, [out] double * p_jy ); [mlname(plgdiori)] void c_plgdiori ( [out] double * p_rot ); [mlname(plgdiplt)] void c_plgdiplt ( [out] double * p_xmin, [out] double * p_ymin, [out] double * p_xmax, [out] double * p_ymax ); -[mlname(plgfci)] void c_plgfci ( [out, int64] unsigned int * pfci ); +[mlname(plgfci)] void c_plgfci ( [out] long long * pfci ); [mlname(plgfam)] void c_plgfam ( [out] int * p_fam, [out] int * p_num, [out] int * p_bmax ); [mlname(plgfnam)] void c_plgfnam ( [string, out, length_is(1024)] char * fnam ); [mlname(plgfont)] void c_plgfont ( [out] int * p_family, [out] int * p_style, [out] int * p_weight ); @@ -60,13 +60,13 @@ [mlname(plline)] void c_plline ( int n, [in, size_is(n)] double * x, [in, size_is(n)] double * y ); [mlname(plline3)] void c_plline3 ( int n, [in, size_is(n)] double * x, [in, size_is(n)] double * y, [in, size_is(n)] double * z ); [mlname(pllsty)] void c_pllsty ( int lin ); -[mlname(plmesh)] void c_plmesh ( [size_is(nx), in] double * x, [size_is(ny), in] double * y, [size_is(nx, ny), in] double ** z, int nx, int ny, int opt ); -[mlname(plmeshc)] void c_plmeshc ( [size_is(nx), in] double * x, [size_is(ny), in] double * y, [size_is(nx, ny), in] double ** z, int nx, int ny, int opt, [size_is(nlevel), in] double * clevel, int nlevel ); +[mlname(plmesh)] void c_plmesh ( [size_is(nx), in] double * x, [size_is(ny), in] double * y, [size_is(nx, ny), in] double ** z, int nx, int ny, plplot3d_style opt ); +[mlname(plmeshc)] void c_plmeshc ( [size_is(nx), in] double * x, [size_is(ny), in] double * y, [size_is(nx, ny), in] double ** z, int nx, int ny, plplot3d_style opt, [size_is(nlevel), in] double * clevel, int nlevel ); [mlname(plmkstrm)] void c_plmkstrm ( [out] int * p_strm ); [mlname(plmtex)] void c_plmtex ( [string] const char * side, double disp, double pos, double just, [string] const char * text ); [mlname(plmtex3)] void c_plmtex3 ( [string] const char * side, double disp, double pos, double just, [string] const char * text ); -[mlname(plot3d)] void c_plot3d ( [size_is(nx), in] double * x, [size_is(ny), in] double * y, [size_is(nx, ny), in] double ** z, int nx, int ny, int opt, boolean side ); -[mlname(plot3dc)] void c_plot3dc ( [size_is(nx), in] double * x, [size_is(ny), in] double * y, [size_is(nx, ny), in] double ** z, int nx, int ny, int opt, [size_is(nlevel), in] double * clevel, int nlevel ); +[mlname(plot3d)] void c_plot3d ( [size_is(nx), in] double * x, [size_is(ny), in] double * y, [size_is(nx, ny), in] double ** z, int nx, int ny, plplot3d_style opt, boolean side ); +[mlname(plot3dc)] void c_plot3dc ( [size_is(nx), in] double * x, [size_is(ny), in] double * y, [size_is(nx, ny), in] double ** z, int nx, int ny, plplot3d_style opt, [size_is(nlevel), in] double * clevel, int nlevel ); [mlname(plpat)] void c_plpat ( int nlin, [in, size_is(nlin)] int * inc, [in, size_is(nlin)] int * del ); [mlname(plpoin)] void c_plpoin ( int n, [in, size_is(n)] double * x, [in, size_is(n)] double * y, int code ); [mlname(plpoin3)] void c_plpoin3 ( int n, [in, size_is(n)] double * x, [in, size_is(n)] double * y, [in, size_is(n)] double * z, int code ); @@ -101,7 +101,7 @@ [mlname(plsdiplz)] void c_plsdiplz ( double xmin, double ymin, double xmax, double ymax ); [mlname(plsesc)] void c_plsesc ( char esc ); [mlname(plsfam)] void c_plsfam ( int fam, int num, int bmax ); -[mlname(plsfci)] void c_plsfci ( [int64] unsigned int fci ); +[mlname(plsfci)] void c_plsfci ( long long fci ); [mlname(plsfnam)] void c_plsfnam ( [string] const char * fnam ); [mlname(plsfont)] void c_plsfont ( int family, int style, int weight ); [mlname(plsmaj)] void c_plsmaj ( double def, double scale ); @@ -118,7 +118,7 @@ [mlname(plstripd)] void c_plstripd ( int id ); [mlname(plimage)] void c_plimage ( [in, size_is(nx, ny)] double ** idata, int nx, int ny, double xmin, double xmax, double ymin, double ymax, double zmin, double zmax, double Dxmin, double Dxmax, double Dymin, double Dymax ); [mlname(plstyl)] void c_plstyl ( int nms, [size_is(nms)] int * mark, [size_is(nms)] int * space ); -[mlname(plsurf3d)] void c_plsurf3d ( [size_is(nx), in] double * x, [size_is(ny), in] double * y, [size_is(nx, ny), in] double ** z, int nx, int ny, int opt, [size_is(nlevel), in] double * clevel, int nlevel ); +[mlname(plsurf3d)] void c_plsurf3d ( [size_is(nx), in] double * x, [size_is(ny), in] double * y, [size_is(nx, ny), in] double ** z, int nx, int ny, plplot3d_style opt, [size_is(nlevel), in] double * clevel, int nlevel ); [mlname(plsvpa)] void c_plsvpa ( double xmin, double xmax, double ymin, double ymax ); [mlname(plsxax)] void c_plsxax ( int digmax, int digits ); void plsxwin ( int window_id ); Modified: trunk/bindings/ocaml/touchup.ml =================================================================== --- trunk/bindings/ocaml/touchup.ml 2008-10-12 19:58:13 UTC (rev 8886) +++ trunk/bindings/ocaml/touchup.ml 2008-10-12 21:28:14 UTC (rev 8887) @@ -239,8 +239,8 @@ misc. check (anything, as long as it's a bool) attributes, if all of the above are true *) - (* "PLUNICODE" parameters need at least unsigned int32 width ints, - so use Int64.t values to be safe. *) + (* OCaml does not support unsigned integer values in its standard library + so use Int64.t values for unsigned ints to be safe. *) true, pmatch "unsigned int" p_type, true, Modified: trunk/examples/ocaml/x08.ml =================================================================== --- trunk/examples/ocaml/x08.ml 2008-10-12 19:58:13 UTC (rev 8886) +++ trunk/examples/ocaml/x08.ml 2008-10-12 21:28:14 UTC (rev 8887) @@ -160,22 +160,20 @@ "bcdmnstuv" "z axis" 0.0 0; plcol0 2; - (* NOTE: As of now, the named variables for the opt parameter options - have not been defined in the OCaml interface. *) match ifshade with 0 -> (* diffuse light surface plot *) cmap1_init true; - plsurf3d x y z 0 [||]; + plsurf3d x y z [PL_DIFFUSE] [||]; | 1 -> (* magnitude colored plot *) cmap1_init false; - plsurf3d x y z 4 [||]; + plsurf3d x y z [PL_MAG_COLOR] [||]; | 2 -> (* magnitude colored plot with faceted squares *) cmap1_init false; - plsurf3d x y z (4 + 128) [||]; + plsurf3d x y z [PL_MAG_COLOR; PL_FACETED] [||]; | _ -> (* magnitude colored plot with contours *) cmap1_init false; - plsurf3d x y z (4 + 32 + 8) clevel; + plsurf3d x y z [PL_MAG_COLOR; PL_SURF_CONT; PL_BASE_CONT] clevel; done done; Modified: trunk/examples/ocaml/x09.ml =================================================================== --- trunk/examples/ocaml/x09.ml 2008-10-12 19:58:13 UTC (rev 8886) +++ trunk/examples/ocaml/x09.ml 2008-10-12 21:28:14 UTC (rev 8887) @@ -87,8 +87,6 @@ let lev = Array.init 10 (fun i -> 0.05 +. 0.10 *. float_of_int i) in plcol0 2; - (* TODO FIXME XXX: This is not correct because pltr2 is not properly - implemented in OCaml at this point. *) plset_pltr (fun x y -> pltr2 x y xg yg); plcont z 1 rpts 1 thetapts lev; plunset_pltr (); Modified: trunk/examples/ocaml/x11.ml =================================================================== --- trunk/examples/ocaml/x11.ml 2008-10-12 19:58:13 UTC (rev 8886) +++ trunk/examples/ocaml/x11.ml 2008-10-12 21:28:14 UTC (rev 8887) @@ -28,10 +28,7 @@ let ypts = 46 (* Data points in y *) let levels = 10 -(* FIXME TODO: The plot style #define statements have not been brought over to - the OCaml interface yet. This example uses the constant values until they - are properly carried over. *) -let opt = [|3; 3|] +let opt = [|PL_DRAW_LINEXY; PL_DRAW_LINEXY|] let alt = [|33.0; 17.0|] let az = [|24.0; 115.0|] @@ -47,7 +44,6 @@ let l = [|0.6; 0.6|] in let s = [|0.8; 0.8|] in plscmap1n 256; - (* TODO: The first argument to plscmap1l should be a boolean value *) plscmap1l false i h l s None; () @@ -116,16 +112,16 @@ let () = match i with 0 -> - plmesh x y z opt.(k) + plmesh x y z [opt.(k)] | 1 -> (* magnitude colored wireframe plot *) - plmesh x y z (opt.(k) lor 4) + plmesh x y z [opt.(k); PL_MAG_COLOR] | 2 -> (* magnitude colored wireframe plot with sides *) - plot3d x y z (opt.(k) lor 4) true + plot3d x y z [opt.(k); PL_MAG_COLOR] true | 3 -> (* magnitude colored wireframe plot with base contour *) - plmeshc x y z (opt.(k) lor 4 lor 8) clevel + plmeshc x y z [opt.(k); PL_MAG_COLOR; PL_BASE_CONT] clevel | _ -> raise (Failure "You let i get too big!") in Modified: trunk/examples/ocaml/x21.ml =================================================================== --- trunk/examples/ocaml/x21.ml 2008-10-12 19:58:13 UTC (rev 8886) +++ trunk/examples/ocaml/x21.ml 2008-10-12 21:28:14 UTC (rev 8887) @@ -229,8 +229,7 @@ "bcdfntu" "Z" 0.5 0; plcol0 15; pllab "" "" title.(alg - 1); - (* TODO FIXME -- The proper PLplot constants should be used here... *) - plot3dc xg yg zg (3 lor 4 lor 8) clev; + plot3dc xg yg zg [PL_DRAW_LINEXY; PL_MAG_COLOR; PL_BASE_CONT] clev; ); done done; Modified: trunk/examples/ocaml/x23.ml =================================================================== --- trunk/examples/ocaml/x23.ml 2008-10-12 19:58:13 UTC (rev 8886) +++ trunk/examples/ocaml/x23.ml 2008-10-12 21:28:14 UTC (rev 8887) @@ -274,7 +274,8 @@ (* Demonstrate methods of getting the current fonts *) let fci_old = plgfci () in let ifamily, istyle, iweight = plgfont () in - printf "For example 23 prior to page 12 the FCI is 0x%x\n" fci_old; + printf "For example 23 prior to page 12 the FCI is 0x%lx\n" + (Int64.to_int32 fci_old); printf "For example 23 prior to page 12 the font family, style and weight are %s %s %s\n" family.(ifamily) style.(istyle) weight.(iweight); Modified: trunk/examples/ocaml/x28.ml =================================================================== --- trunk/examples/ocaml/x28.ml 2008-10-12 19:58:13 UTC (rev 8886) +++ trunk/examples/ocaml/x28.ml 2008-10-12 21:28:14 UTC (rev 8887) @@ -138,7 +138,7 @@ 0.0 " revolution"; done; (* Draw minimal 3D grid to finish defining the 3D box. *) - plmesh x y z 3; + plmesh x y z [PL_DRAW_LINEXY]; (* Page 2: Demonstrate rotation of string around its axis. *) pladv 0; @@ -205,7 +205,7 @@ 0.5 "rotation for z = z#dmin#u"; done; (* Draw minimal 3D grid to finish defining the 3D box. *) - plmesh x y z 3; + plmesh x y z [PL_DRAW_LINEXY]; (* Page 3: Demonstrate shear of string along its axis. *) (* Work around xcairo and pngcairo (but not pscairo) problems for @@ -276,7 +276,7 @@ 0.5 "shear for z = z#dmin#u"; done; (* Draw minimal 3D grid to finish defining the 3D box. *) - plmesh x y z 3; + plmesh x y z [PL_DRAW_LINEXY]; (* Page 4: Demonstrate drawing a string on a 3D path. *) pladv 0; @@ -324,7 +324,7 @@ done; (* Draw minimal 3D grid to finish defining the 3D box. *) - plmesh x y z 3; + plmesh x y z [PL_DRAW_LINEXY]; (* Page 5: Demonstrate plmtex3 axis labelling capability *) pladv 0; @@ -351,7 +351,7 @@ plmtex3 "zs" (-2.5) 0.5 0.5 "Arbitrarily displaced"; plmtex3 "zs" (-1.0) 0.5 0.5 "secondary Z-axis label"; (* Draw minimal 3D grid to finish defining the 3D box. *) - plmesh x y z 3; + plmesh x y z [PL_DRAW_LINEXY]; (* Clean up. *) plend (); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |