PLplot  5.13.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
plplot_impl.c
Go to the documentation of this file.
1 //
2 // Copyright 2007, 2008, 2009, 2010, 2011 Hezekiah M. Carty
3 //
4 // This file is part of PLplot.
5 //
6 // PLplot is free software: you can redistribute it and/or modify
7 // it under the terms of the GNU Lesser General Public License as published by
8 // the Free Software Foundation, either version 2 of the License, or
9 // (at your option) any later version.
10 //
11 // PLplot is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public License
17 // along with PLplot. If not, see <http://www.gnu.org/licenses/>.
18 //
19 
20 // The "usual" OCaml includes
21 #include <caml/alloc.h>
22 #include <caml/callback.h>
23 #include <caml/fail.h>
24 #include <caml/memory.h>
25 #include <caml/misc.h>
26 #include <caml/mlvalues.h>
27 #include <caml/bigarray.h>
28 
29 #include <plplotP.h>
30 #include <plplot.h>
31 
32 #undef snprintf
33 
34 #include <stdio.h>
35 
36 #define MAX_EXCEPTION_MESSAGE_LENGTH 1000
37 #define CAML_PLPLOT_PLOTTER_FUNC_NAME "caml_plplot_plotter"
38 #define CAML_PLPLOT_MAPFORM_FUNC_NAME "caml_plplot_mapform"
39 #define CAML_PLPLOT_DEFINED_FUNC_NAME "caml_plplot_defined"
40 #define CAML_PLPLOT_LABEL_FUNC_NAME "caml_plplot_customlabel"
41 #define CAML_PLPLOT_ABORT_FUNC_NAME "caml_plplot_abort"
42 #define CAML_PLPLOT_EXIT_FUNC_NAME "caml_plplot_exit"
43 #define CAML_PLPLOT_TRANSFORM_FUNC_NAME "caml_plplot_transform"
44 
45 typedef void ( *ML_PLOTTER_FUNC )( PLFLT, PLFLT, PLFLT*, PLFLT*, PLPointer );
46 typedef PLINT ( *ML_DEFINED_FUNC )( PLFLT, PLFLT );
47 typedef void ( *ML_MAPFORM_FUNC )( PLINT, PLFLT*, PLFLT* );
48 typedef void ( *ML_LABEL_FUNC )( PLINT, PLFLT, char*, PLINT, PLPointer );
49 typedef PLINT ( *ML_VARIANT_FUNC )( PLINT );
50 
51 //
52 //
53 // CALLBACK WRAPPERS
54 //
55 //
56 
57 // A simple routine to wrap a properly registered OCaml callback in a form
58 // usable by PLPlot routines. If an appropriate callback is not registered
59 // then the PLPlot built-in pltr0 function is used instead.
60 void ml_plotter( PLFLT x, PLFLT y, PLFLT *tx, PLFLT *ty, PLPointer pltr_data )
61 {
62  CAMLparam0();
63  CAMLlocal1( result );
64 
65  // Get the OCaml callback function (if there is one)
66  static value * pltr = NULL;
67  if ( pltr == NULL )
68  pltr = caml_named_value( CAML_PLPLOT_PLOTTER_FUNC_NAME );
69 
70  // No check to see if a callback function has been designated yet,
71  // because that is checked before we get to this point.
72  result =
73  caml_callback2( *pltr, caml_copy_double( x ), caml_copy_double( y ) );
74  double new_x, new_y;
75  new_x = Double_val( Field( result, 0 ) );
76  new_y = Double_val( Field( result, 1 ) );
77 
78  *tx = new_x;
79  *ty = new_y;
80 
81  CAMLreturn0;
82 }
83 
84 // A simple routine to wrap a properly registered OCaml callback in a form
85 // usable by PLPlot routines. If an appropriate callback is not registered
86 // then the result is always 1 (the data point is defined).
87 // This function is used in the plshade* functions to determine if a given data
88 // point is valid/defined or not.
90 {
91  CAMLparam0();
92  CAMLlocal1( result );
93 
94  // The result which will be returned to the user.
95  PLINT is_it_defined;
96 
97  // Get the OCaml callback function (if there is one)
98  static value * defined = NULL;
99  if ( defined == NULL )
100  defined = caml_named_value( CAML_PLPLOT_DEFINED_FUNC_NAME );
101 
102  // No check to see if a callback function has been designated yet,
103  // because that is checked before we get to this point.
104  result =
105  caml_callback2( *defined, caml_copy_double( x ), caml_copy_double( y ) );
106  is_it_defined = Int_val( result );
107 
108  CAMLreturn( is_it_defined );
109 }
110 
111 // A simple routine to wrap a properly registered OCaml callback in a form
112 // usable by PLPlot routines. If an appropriate callback is not registered
113 // then nothing is done.
114 void ml_mapform( PLINT n, PLFLT *x, PLFLT *y )
115 {
116  CAMLparam0();
117  CAMLlocal1( result );
118 
119  // Get the OCaml callback function (if there is one)
120  static value * mapform = NULL;
121  if ( mapform == NULL )
122  mapform = caml_named_value( CAML_PLPLOT_MAPFORM_FUNC_NAME );
123 
124  // No check to see if a callback function has been designated yet,
125  // because that is checked before we get to this point.
126  int i;
127  for ( i = 0; i < n; i++ )
128  {
129  result =
130  caml_callback2( *mapform,
131  caml_copy_double( x[i] ), caml_copy_double( y[i] ) );
132 
133  double new_x, new_y;
134  new_x = Double_val( Field( result, 0 ) );
135  new_y = Double_val( Field( result, 1 ) );
136 
137  x[i] = new_x;
138  y[i] = new_y;
139  }
140 
141  CAMLreturn0;
142 }
143 
144 // A simple routine to wrap a properly registered OCaml callback in a form
145 // usable by PLPlot routines.
146 void ml_labelfunc( PLINT axis, PLFLT n, char *label, PLINT length, PLPointer d )
147 {
148  CAMLparam0();
149  CAMLlocal1( result );
150 
151  // Get the OCaml callback function (if there is one)
152  static value * callback = NULL;
153  if ( callback == NULL )
154  callback = caml_named_value( CAML_PLPLOT_LABEL_FUNC_NAME );
155 
156  // No check to see if a callback function has been designated yet,
157  // because that is checked before we get to this point.
158  result =
159  caml_callback2( *callback, Val_int( axis - 1 ), caml_copy_double( n ) );
160 
161  // Copy the OCaml callback output to the proper location.
162  snprintf( label, length, "%s", String_val( result ) );
163 
164  CAMLreturn0;
165 }
166 
167 // OCaml callback for plsabort
168 void ml_abort( const char* message )
169 {
170  CAMLparam0();
171  CAMLlocal1( result );
172 
173  // Get the OCaml callback function (if there is one)
174  static value * handler = NULL;
175  if ( handler == NULL )
176  handler = caml_named_value( CAML_PLPLOT_ABORT_FUNC_NAME );
177 
178  // No check to see if a callback function has been designated yet,
179  // because that is checked before we get to this point.
180  result =
181  caml_callback( *handler, caml_copy_string( message ) );
182 
183  CAMLreturn0;
184 }
185 
186 // OCaml callback for plsexit
187 int ml_exit( const char* message )
188 {
189  CAMLparam0();
190  CAMLlocal1( result );
191 
192  // Get the OCaml callback function (if there is one)
193  static value * handler = NULL;
194  if ( handler == NULL )
195  handler = caml_named_value( CAML_PLPLOT_EXIT_FUNC_NAME );
196 
197  // No check to see if a callback function has been designated yet,
198  // because that is checked before we get to this point.
199  result =
200  caml_callback( *handler, caml_copy_string( message ) );
201 
202  CAMLreturn( Int_val( result ) );
203 }
204 
205 // A simple routine to wrap a properly registered OCaml callback in a form
206 // usable by PLPlot routines. If an appropriate callback is not registered
207 // then nothing is done.
208 void ml_transform( PLFLT x, PLFLT y, PLFLT *xt, PLFLT *yt, PLPointer data )
209 {
210  CAMLparam0();
211  CAMLlocal1( result );
212 
213  // Get the OCaml callback function (if there is one)
214  static value * transform = NULL;
215  if ( transform == NULL )
216  transform = caml_named_value( CAML_PLPLOT_TRANSFORM_FUNC_NAME );
217 
218  // No check to see if a callback function has been designated yet,
219  // because that is checked before we get to this point.
220  result =
221  caml_callback2( *transform, caml_copy_double( x ), caml_copy_double( y ) );
222 
223  *xt = Double_val( Field( result, 0 ) );
224  *yt = Double_val( Field( result, 1 ) );
225 
226  CAMLreturn0;
227 }
228 
229 // Check if the matching OCaml callback is defined. Return NULL if it is not,
230 // and the proper function pointer if it is.
232 {
233  static value * pltr = NULL;
234  if ( pltr == NULL )
235  pltr = caml_named_value( CAML_PLPLOT_PLOTTER_FUNC_NAME );
236 
237  if ( pltr == NULL || Val_int( 0 ) == *pltr )
238  {
239  // No plotter defined
240  return NULL;
241  }
242  else
243  {
244  // Plotter is defined
245  return ml_plotter;
246  }
247 }
249 {
250  static value * defined = NULL;
251  if ( defined == NULL )
252  defined = caml_named_value( CAML_PLPLOT_DEFINED_FUNC_NAME );
253 
254  if ( defined == NULL || Val_int( 0 ) == *defined )
255  {
256  // No plotter defined
257  return NULL;
258  }
259  else
260  {
261  // Plotter is defined
262  return ml_defined;
263  }
264 }
266 {
267  static value * mapform = NULL;
268  if ( mapform == NULL )
269  mapform = caml_named_value( CAML_PLPLOT_MAPFORM_FUNC_NAME );
270 
271  if ( mapform == NULL || Val_int( 0 ) == *mapform )
272  {
273  // No plotter defined
274  return NULL;
275  }
276  else
277  {
278  // Plotter is defined
279  return ml_mapform;
280  }
281 }
282 
283 // Custom wrapper for plslabelfunc
285 {
286  CAMLparam1( unit );
287  static value * label = NULL;
288  if ( label == NULL )
289  label = caml_named_value( CAML_PLPLOT_LABEL_FUNC_NAME );
290 
291  if ( label == NULL || Val_int( 0 ) == *label )
292  {
293  // No plotter defined
294  plslabelfunc( NULL, NULL );
295  }
296  else
297  {
298  // Plotter is defined
299  plslabelfunc( ml_labelfunc, NULL );
300  }
301 
302  CAMLreturn( Val_unit );
303 }
304 
305 // Custom wrappers for plsabort and plsexit
307 {
308  CAMLparam1( unit );
309  static value * handler = NULL;
310  if ( handler == NULL )
311  handler = caml_named_value( CAML_PLPLOT_ABORT_FUNC_NAME );
312 
313  if ( handler == NULL || Val_int( 0 ) == *handler )
314  {
315  // No handler defined
316  plsabort( NULL );
317  }
318  else
319  {
320  // Handler is defined
321  plsabort( ml_abort );
322  }
323  CAMLreturn( Val_unit );
324 }
326 {
327  CAMLparam1( unit );
328  static value * handler = NULL;
329  if ( handler == NULL )
330  handler = caml_named_value( CAML_PLPLOT_EXIT_FUNC_NAME );
331 
332  if ( handler == NULL || Val_int( 0 ) == *handler )
333  {
334  // No handler defined
335  plsexit( NULL );
336  }
337  else
338  {
339  // Handler is defined
340  plsexit( ml_exit );
341  }
342  CAMLreturn( Val_unit );
343 }
344 
345 // Set a global coordinate transform
347 {
348  CAMLparam1( unit );
349  static value * handler = NULL;
350  if ( handler == NULL )
351  handler = caml_named_value( CAML_PLPLOT_TRANSFORM_FUNC_NAME );
352 
353  if ( handler == NULL || Val_int( 0 ) == *handler )
354  {
355  // No handler defined
356  plstransform( NULL, NULL );
357  }
358  else
359  {
360  // Handler is defined
361  plstransform( ml_transform, NULL );
362  }
363  CAMLreturn( Val_unit );
364 }
365 
366 //
367 //
368 // CONTOURING, SHADING and IMAGE FUNCTIONS
369 //
370 //
371 
372 //
373 // void
374 // c_plcont(PLFLT **f, PLINT nx, PLINT ny, PLINT kx, PLINT lx,
375 // PLINT ky, PLINT ly, PLFLT *clevel, PLINT nlevel,
376 // void (*pltr) (PLFLT, PLFLT, PLFLT *, PLFLT *, PLPointer),
377 // PLPointer pltr_data);
378 //
379 void ml_plcont( const PLFLT **f, PLINT nx, PLINT ny,
380  PLINT kx, PLINT lx, PLINT ky, PLINT ly,
381  PLFLT *clevel, PLINT nlevel )
382 {
383  if ( get_ml_plotter_func() == NULL )
384  {
385  // This is handled in PLplot, but the error is raised here to clarify
386  // what the user needs to do since the custom plotter is defined
387  // separately from the call to plcont.
388  caml_invalid_argument( "A custom plotter must be defined \
389  before calling plcont" );
390  }
391  else
392  {
393  c_plcont( f, nx, ny, kx, lx, ky, ly, clevel, nlevel,
394  get_ml_plotter_func(), (void *) 1 );
395  }
396 }
397 
398 //
399 // void
400 // c_plshade(PLFLT **a, PLINT nx, PLINT ny, PLINT (*defined) (PLFLT, PLFLT),
401 // PLFLT left, PLFLT right, PLFLT bottom, PLFLT top,
402 // PLFLT shade_min, PLFLT shade_max,
403 // PLINT sh_cmap, PLFLT sh_color, PLINT sh_width,
404 // PLINT min_color, PLINT min_width,
405 // PLINT max_color, PLINT max_width,
406 // void (*fill) (PLINT, PLFLT *, PLFLT *), PLBOOL rectangular,
407 // void (*pltr) (PLFLT, PLFLT, PLFLT *, PLFLT *, PLPointer),
408 // PLPointer pltr_data);
409 //
410 void ml_plshade( const PLFLT **a, PLINT nx, PLINT ny,
411  PLFLT left, PLFLT right, PLFLT bottom, PLFLT top,
412  PLFLT shade_min, PLFLT shade_max,
413  PLINT sh_cmap, PLFLT sh_color, PLFLT sh_width,
414  PLINT min_color, PLFLT min_width,
415  PLINT max_color, PLFLT max_width,
416  PLBOOL rectangular )
417 {
418  c_plshade( a, nx, ny,
420  left, right, bottom, top,
421  shade_min, shade_max,
422  sh_cmap, sh_color, sh_width, min_color, min_width,
423  max_color, max_width, plfill, rectangular,
424  get_ml_plotter_func(), (void *) 1 );
425 }
426 
427 //
428 // void
429 // c_plshade1(PLFLT *a, PLINT nx, PLINT ny, PLINT (*defined) (PLFLT, PLFLT),
430 // PLFLT left, PLFLT right, PLFLT bottom, PLFLT top,
431 // PLFLT shade_min, PLFLT shade_max,
432 // PLINT sh_cmap, PLFLT sh_color, PLINT sh_width,
433 // PLINT min_color, PLINT min_width,
434 // PLINT max_color, PLINT max_width,
435 // void (*fill) (PLINT, PLFLT *, PLFLT *), PLBOOL rectangular,
436 // void (*pltr) (PLFLT, PLFLT, PLFLT *, PLFLT *, PLPointer),
437 // PLPointer pltr_data);
438 //
439 
440 //
441 // void
442 // c_plshades( PLFLT **a, PLINT nx, PLINT ny, PLINT (*defined) (PLFLT, PLFLT),
443 // PLFLT xmin, PLFLT xmax, PLFLT ymin, PLFLT ymax,
444 // PLFLT *clevel, PLINT nlevel, PLINT fill_width,
445 // PLINT cont_color, PLINT cont_width,
446 // void (*fill) (PLINT, PLFLT *, PLFLT *), PLBOOL rectangular,
447 // void (*pltr) (PLFLT, PLFLT, PLFLT *, PLFLT *, PLPointer),
448 // PLPointer pltr_data);
449 //
450 void ml_plshades( const PLFLT **a, PLINT nx, PLINT ny,
451  PLFLT xmin, PLFLT xmax, PLFLT ymin, PLFLT ymax,
452  PLFLT *clevel, PLINT nlevel, PLFLT fill_width,
453  PLINT cont_color, PLFLT cont_width,
454  PLBOOL rectangular )
455 {
456  c_plshades( a, nx, ny,
458  xmin, xmax, ymin, ymax,
459  clevel, nlevel, fill_width,
460  cont_color, cont_width,
461  plfill, rectangular,
463  (void *) 1 );
464 }
465 
466 //
467 // void
468 // c_plimagefr(PLFLT **idata, PLINT nx, PLINT ny,
469 // PLFLT xmin, PLFLT xmax, PLFLT ymin, PLFLT ymax, PLFLT zmin, PLFLT zmax,
470 // PLFLT valuemin, PLFLT valuemax,
471 // void (*pltr) (PLFLT, PLFLT, PLFLT *, PLFLT *, PLPointer),
472 // PLPointer pltr_data);
473 //
474 void ml_plimagefr( const PLFLT **idata, PLINT nx, PLINT ny,
475  PLFLT xmin, PLFLT xmax, PLFLT ymin, PLFLT ymax,
476  PLFLT zmin, PLFLT zmax,
477  PLFLT valuemin, PLFLT valuemax )
478 {
479  c_plimagefr( idata, nx, ny,
480  xmin, xmax, ymin, ymax,
481  zmin, zmax,
482  valuemin, valuemax,
484  (void *) 1 );
485 }
486 
487 //
488 // void
489 // c_plvect(PLFLT **u, PLFLT **v, PLINT nx, PLINT ny, PLFLT scale,
490 // void (*pltr) (PLFLT, PLFLT, PLFLT *, PLFLT *, PLPointer),
491 // PLPointer pltr_data);
492 //
493 void ml_plvect( const PLFLT **u, const PLFLT **v, PLINT nx, PLINT ny, PLFLT scale )
494 {
495  c_plvect( u, v, nx, ny, scale,
497  (void *) 1 );
498 }
499 
500 //
501 // Wrapper to reset vector rendering
502 //
504 {
505  c_plsvect( NULL, NULL, 0, 0 );
506 }
507 
508 //
509 // void
510 // c_plmap( void (*mapform)(PLINT, PLFLT *, PLFLT *), const char *type,
511 // PLFLT minlong, PLFLT maxlong, PLFLT minlat, PLFLT maxlat );
512 //
513 void ml_plmap( const char *type,
514  PLFLT minlong, PLFLT maxlong, PLFLT minlat, PLFLT maxlat )
515 {
517  type, minlong, maxlong, minlat, maxlat );
518 }
519 
520 //
521 // void
522 // c_plmeridians( void (*mapform)(PLINT, PLFLT *, PLFLT *),
523 // PLFLT dlong, PLFLT dlat,
524 // PLFLT minlong, PLFLT maxlong, PLFLT minlat, PLFLT maxlat );
525 //
526 void ml_plmeridians( PLFLT dlong, PLFLT dlat,
527  PLFLT minlong, PLFLT maxlong, PLFLT minlat, PLFLT maxlat )
528 {
530  dlong, dlat, minlong, maxlong, minlat, maxlat );
531 }
532 
533 //
534 // void
535 // c_plgriddata(PLFLT *x, PLFLT *y, PLFLT *z, PLINT npts,
536 // PLFLT *xg, PLINT nptsx, PLFLT *yg, PLINT nptsy,
537 // PLFLT **zg, PLINT type, PLFLT data);
538 //
539 // This one is currently wrapped by hand, as I am not sure how to get camlidl
540 // to allocate zg in a way that makes plgriddata happy and doesn't require the
541 // user to pre-allocate the space.
543  value xg, value yg,
544  value type, value data )
545 {
546  CAMLparam5( x, y, z, xg, yg );
547  CAMLxparam2( type, data );
548 
549  // zg holds the OCaml float array array.
550  // y_ml_array is a temporary structure which will be used to form each
551  // float array making up zg.
552  CAMLlocal2( zg, y_ml_array );
553 
554  PLFLT **zg_local;
555 
556  int npts, nptsx, nptsy;
557  int i, j;
558 
559  // Check to make sure x, y and z are all the same length.
560  npts = Wosize_val( x ) / Double_wosize;
561  if ( ( Wosize_val( y ) / Double_wosize != Wosize_val( z ) / Double_wosize ) ||
562  ( Wosize_val( y ) / Double_wosize != npts ) ||
563  ( Wosize_val( z ) / Double_wosize != npts )
564  )
565  {
566  caml_failwith( "ml_plgriddata: x, y, z must all have the same dimensions" );
567  }
568 
569  nptsx = Wosize_val( xg ) / Double_wosize;
570  nptsy = Wosize_val( yg ) / Double_wosize;
571 
572  // Allocate the 2D grid in a way that will make PLplot happy
573  plAlloc2dGrid( &zg_local, nptsx, nptsy );
574 
575  // Using "type + 1" because "type" is passed in as a variant type, so
576  // the indexing starts from 0 rather than 1.
577  c_plgriddata( (double *) x, (double *) y, (double *) z, npts, (double *) xg, nptsx,
578  (double *) yg, nptsy, zg_local, Int_val( type ) + 1,
579  Double_val( data ) );
580 
581  // Allocate the X-dimension of the to-be-returned OCaml array
582  zg = caml_alloc( nptsx, 0 );
583 
584  for ( i = 0; i < nptsx; i++ )
585  {
586  // Allocate each Y-dimension array of the OCaml array
587  y_ml_array = caml_alloc( nptsy * Double_wosize, Double_array_tag );
588  for ( j = 0; j < nptsy; j++ )
589  {
590  Store_double_field( y_ml_array, j, zg_local[i][j] );
591  }
592  caml_modify( &Field( zg, i ), y_ml_array );
593  }
594 
595  // Free the memory used by the C array
596  plFree2dGrid( zg_local, nptsx, nptsy );
597 
598  CAMLreturn( zg );
599 }
600 
602 {
603  return ml_plgriddata( argv[0], argv[1], argv[2], argv[3], argv[4],
604  argv[5], argv[6] );
605 }
606 
607 //
608 // void
609 // c_plpoly3(PLINT n, PLFLT *x, PLFLT *y, PLFLT *z, PLBOOL *draw, PLBOOL ifcc);
610 //
611 // plpoly3 is wrapped by hand because draw has a length of (n - 1) and camlidl
612 // does not have a way to indicate this automatically.
613 void ml_plpoly3( PLINT n, PLFLT *x, PLFLT *y, PLFLT *z, PLINT ndraw, PLBOOL *draw, PLBOOL ifcc )
614 {
615  plpoly3( n, x, y, z, draw, ifcc );
616 }
617 
618 // Raise Invalid_argument if the given value is <> 0
619 void plplot_check_nonzero_result( int result )
620 {
621  if ( result != 0 )
622  {
623  char exception_message[MAX_EXCEPTION_MESSAGE_LENGTH];
624  sprintf( exception_message, "Error, return code %d", result );
625  caml_invalid_argument( exception_message );
626  }
627  return;
628 }
629 
630 // Translate the integer version of the OCaml variant to the appropriate
631 // PLplot constant.
632 int translate_parse_option( int parse_option )
633 {
634  int translated_option;
635  switch ( parse_option )
636  {
637  case 0: translated_option = PL_PARSE_PARTIAL; break;
638  case 1: translated_option = PL_PARSE_FULL; break;
639  case 2: translated_option = PL_PARSE_QUIET; break;
640  case 3: translated_option = PL_PARSE_NODELETE; break;
641  case 4: translated_option = PL_PARSE_SHOWALL; break;
642  case 5: translated_option = PL_PARSE_OVERRIDE; break;
643  case 6: translated_option = PL_PARSE_NOPROGRAM; break;
644  case 7: translated_option = PL_PARSE_NODASH; break;
645  case 8: translated_option = PL_PARSE_SKIP; break;
646  default: translated_option = -1;
647  }
648  return translated_option;
649 }
650 
651 // Copy to a const string array
652 #define INIT_STRING_ARRAY( o ) \
653  int o ## _length; \
654  o ## _length = Wosize_val( o ); \
655  const char *c_ ## o[o ## _length]; \
656  for ( i = 0; i < o ## _length; i++ ) { c_ ## o[i] = String_val( Field( o, i ) ); }
657 
658 // Copy to a non-const string array
659 #define INIT_NC_STRING_ARRAY( o ) \
660  int o ## _length; \
661  o ## _length = Wosize_val( o ); \
662  char *c_ ## o[o ## _length]; \
663  for ( i = 0; i < o ## _length; i++ ) { c_ ## o[i] = String_val( Field( o, i ) ); }
664 
665 // Copy an int array, o, of n element to the C array c
666 #define INIT_INT_ARRAY( o ) \
667  int o ## _length; \
668  o ## _length = Wosize_val( o ); \
669  int c_ ## o[o ## _length]; \
670  for ( i = 0; i < ( o ## _length ); i++ ) { ( c_ ## o )[i] = Int_val( Field( ( o ), i ) ); }
671 
672 // Copy an int array, o, of n element to the C array c
673 #define INIT_INT_ARRAYS( o ) \
674  int o ## _length, o ## _inner; \
675  o ## _length = Wosize_val( o ); \
676  int *c_ ## o[o ## _length]; \
677  for ( i = 0; i < ( o ## _length ); i++ ) { \
678  INIT_INT_ARRAY( o ## _subarray ); \
679  ( c_ ## o )[i] = c_ ## o ## _subarray; \
680  }
681 
682 int lor_ml_list( value list, ML_VARIANT_FUNC variant_f )
683 {
684  CAMLparam1( list );
685  int result;
686 
687  result = 0;
688  while ( list != Val_emptylist )
689  {
690  // Accumulate the elements of the list
691  result = result | variant_f( Int_val( Field( list, 0 ) ) );
692  // Point to the tail of the list for the next loop
693  list = Field( list, 1 );
694  }
695 
696  CAMLreturn( result );
697 }
698 
700 {
701  CAMLparam2( argv, parse_method );
702  int i;
703  PLINT result;
704  int combined_parse_method;
705  // Make a copy of the command line argument strings
706  INIT_NC_STRING_ARRAY( argv )
707 
708  // OR the elements of the parse_method list together
709  combined_parse_method = lor_ml_list( parse_method, translate_parse_option );
710 
711  result = plparseopts( &argv_length, c_argv, combined_parse_method );
712  if ( result != 0 )
713  {
714  char exception_message[MAX_EXCEPTION_MESSAGE_LENGTH];
715  sprintf( exception_message, "Invalid arguments in plparseopts, error %d", result );
716  caml_invalid_argument( exception_message );
717  }
718  CAMLreturn( Val_unit );
719 }
720 
721 value ml_plstripc( value xspec, value yspec, value xmin, value xmax, value xjump,
722  value ymin, value ymax, value xlpos, value ylpos, value y_ascl,
723  value acc, value colbox, value collab, value colline, value styline,
724  value legline, value labx, value laby, value labtop )
725 {
726  // Function parameters
727  CAMLparam5( xspec, yspec, xmin, xmax, xjump );
728  CAMLxparam5( ymin, ymax, xlpos, ylpos, y_ascl );
729  CAMLxparam5( acc, colbox, collab, colline, styline );
730  CAMLxparam4( legline, labx, laby, labtop );
731  // Line attribute array copies
732  int colline_copy[4];
733  int styline_copy[4];
734  const char* legend_copy[4];
735  int i;
736  for ( i = 0; i < 4; i++ )
737  {
738  colline_copy[i] = Int_val( Field( colline, i ) );
739  styline_copy[i] = Int_val( Field( styline, i ) );
740  legend_copy[i] = String_val( Field( legline, i ) );
741  }
742  // The returned value
743  int id;
744  plstripc( &id, String_val( xspec ), String_val( yspec ),
745  Double_val( xmin ), Double_val( xmax ),
746  Double_val( xjump ), Double_val( ymin ), Double_val( ymax ),
747  Double_val( xlpos ), Double_val( ylpos ), Bool_val( y_ascl ),
748  Bool_val( acc ), Int_val( colbox ), Int_val( collab ),
749  colline_copy, styline_copy, legend_copy,
750  String_val( labx ), String_val( laby ), String_val( labtop ) );
751  // Make me do something!
752  CAMLreturn( Val_int( id ) );
753 }
754 
756 {
757  return ml_plstripc( argv[0], argv[1], argv[2], argv[3], argv[4],
758  argv[5], argv[6], argv[7], argv[8], argv[9],
759  argv[10], argv[11], argv[12], argv[13], argv[14],
760  argv[15], argv[16], argv[17], argv[18] );
761 }
762 
763 int translate_legend_option( int legend_option )
764 {
765  int translated_option;
766  switch ( legend_option )
767  {
768  case 0: translated_option = PL_LEGEND_NONE; break;
769  case 1: translated_option = PL_LEGEND_COLOR_BOX; break;
770  case 2: translated_option = PL_LEGEND_LINE; break;
771  case 3: translated_option = PL_LEGEND_SYMBOL; break;
772  case 4: translated_option = PL_LEGEND_TEXT_LEFT; break;
773  case 5: translated_option = PL_LEGEND_BACKGROUND; break;
774  case 6: translated_option = PL_LEGEND_BOUNDING_BOX; break;
775  case 7: translated_option = PL_LEGEND_ROW_MAJOR; break;
776  default: translated_option = -1;
777  }
778  return translated_option;
779 }
780 
781 int translate_colorbar_option( int colorbar_option )
782 {
783  int translated_option;
784  switch ( colorbar_option )
785  {
786  case 0: translated_option = PL_COLORBAR_LABEL_LEFT; break;
787  case 1: translated_option = PL_COLORBAR_LABEL_RIGHT; break;
788  case 2: translated_option = PL_COLORBAR_LABEL_TOP; break;
789  case 3: translated_option = PL_COLORBAR_LABEL_BOTTOM; break;
790  case 4: translated_option = PL_COLORBAR_IMAGE; break;
791  case 5: translated_option = PL_COLORBAR_SHADE; break;
792  case 6: translated_option = PL_COLORBAR_GRADIENT; break;
793  case 7: translated_option = PL_COLORBAR_CAP_NONE; break;
794  case 8: translated_option = PL_COLORBAR_CAP_LOW; break;
795  case 9: translated_option = PL_COLORBAR_CAP_HIGH; break;
796  case 10: translated_option = PL_COLORBAR_SHADE_LABEL; break;
797  case 11: translated_option = PL_COLORBAR_ORIENT_RIGHT; break;
798  case 12: translated_option = PL_COLORBAR_ORIENT_TOP; break;
799  case 13: translated_option = PL_COLORBAR_ORIENT_LEFT; break;
800  case 14: translated_option = PL_COLORBAR_ORIENT_BOTTOM; break;
801  case 15: translated_option = PL_COLORBAR_BACKGROUND; break;
802  case 16: translated_option = PL_COLORBAR_BOUNDING_BOX; break;
803  default: translated_option = -1;
804  }
805  return translated_option;
806 }
807 
808 int translate_position_option( int position_option )
809 {
810  int translated_option;
811  switch ( position_option )
812  {
813  case 0: translated_option = PL_POSITION_LEFT; break;
814  case 1: translated_option = PL_POSITION_RIGHT; break;
815  case 2: translated_option = PL_POSITION_TOP; break;
816  case 3: translated_option = PL_POSITION_BOTTOM; break;
817  case 4: translated_option = PL_POSITION_INSIDE; break;
818  case 5: translated_option = PL_POSITION_OUTSIDE; break;
819  case 6: translated_option = PL_POSITION_VIEWPORT; break;
820  case 7: translated_option = PL_POSITION_SUBPAGE; break;
821  default: translated_option = -1;
822  }
823  return translated_option;
824 }
825 
826 value ml_pllegend( value opt, value position, value x, value y, value plot_width,
827  value bg_color,
828  value bb_color, value bb_style,
829  value nrow, value ncolumn,
830  value opt_array,
831  value text_offset, value text_scale, value text_spacing,
832  value text_justification, value text_colors, value text,
833  value box_colors, value box_patterns, value box_scales,
834  value box_line_widths,
835  value line_colors, value line_styles, value line_widths,
836  value symbol_colors, value symbol_scales,
837  value symbol_numbers, value symbols )
838 {
839  CAMLparam5( position, opt, x, y, plot_width );
840  CAMLxparam5( bg_color, bb_color, bb_style, nrow, ncolumn );
841  CAMLxparam5( opt_array, text_offset, text_scale, text_spacing, text_justification );
842  CAMLxparam5( text_colors, text, box_colors, box_patterns, box_scales );
843  CAMLxparam5( box_line_widths, line_colors, line_styles, line_widths, symbol_colors );
844  CAMLxparam3( symbol_scales, symbol_numbers, symbols );
845  CAMLlocal1( result );
846  result = caml_alloc( 2, 0 );
847 
848  // Counter
849  int i;
850  // General legend options
851  int c_position, c_opt;
852  // Number of legend entries
853  int n_legend;
854  n_legend = Wosize_val( opt_array );
855  // Options for each legend entry
856  int c_opt_array[n_legend];
857 
858  // Assume that the dimensions all line up on the OCaml side, so we don't
859  // need to do any further dimension checks.
860 
861  // Define and initialize all of the C arrays to pass in to pllegend
862  INIT_STRING_ARRAY( text )
863  INIT_INT_ARRAY( text_colors )
864  INIT_INT_ARRAY( box_colors )
865  INIT_INT_ARRAY( box_patterns )
866  INIT_INT_ARRAY( line_colors )
867  INIT_INT_ARRAY( line_styles )
868  INIT_INT_ARRAY( symbol_colors )
869  INIT_INT_ARRAY( symbol_numbers )
870  INIT_STRING_ARRAY( symbols )
871 
872  // Translate the legend configuration options
873  c_opt = lor_ml_list( opt, translate_legend_option );
874  c_position = lor_ml_list( position, translate_position_option );
875 
876  for ( i = 0; i < n_legend; i++ )
877  {
878  c_opt_array[i] =
879  lor_ml_list( Field( opt_array, i ), translate_legend_option );
880  }
881 
882  // The returned width and height of the legend
883  PLFLT width, height;
884 
885  pllegend( &width, &height, c_opt, c_position, Double_val( x ), Double_val( y ),
886  Double_val( plot_width ), Int_val( bg_color ),
887  Int_val( bb_color ), Int_val( bb_style ),
888  Int_val( nrow ), Int_val( ncolumn ),
889  n_legend, c_opt_array,
890  Double_val( text_offset ), Double_val( text_scale ),
891  Double_val( text_spacing ),
892  Double_val( text_justification ),
893  c_text_colors, c_text,
894  c_box_colors, c_box_patterns, (double *) box_scales,
895  (double *) box_line_widths,
896  c_line_colors, c_line_styles, (double *) line_widths,
897  c_symbol_colors, (double *) symbol_scales, c_symbol_numbers,
898  c_symbols );
899 
900  // Return a tuple with the legend's size
901  Store_field( result, 0, caml_copy_double( width ) );
902  Store_field( result, 1, caml_copy_double( height ) );
903 
904  CAMLreturn( result );
905 }
906 
908 {
909  return ml_pllegend( argv[0], argv[1], argv[2], argv[3], argv[4],
910  argv[5], argv[6], argv[7], argv[8], argv[9],
911  argv[10], argv[11], argv[12], argv[13], argv[14],
912  argv[15], argv[16], argv[17], argv[18], argv[19],
913  argv[20], argv[21], argv[22], argv[23], argv[24],
914  argv[25], argv[26], argv[27] );
915 }
916 
917 value ml_plcolorbar( value opt, value position, value x, value y,
918  value x_length, value y_length,
919  value bg_color, value bb_color, value bb_style,
920  value low_cap_color, value high_cap_color,
921  value cont_color, value cont_width,
922  value label_opts, value label,
923  value axis_opts,
924  value ticks, value sub_ticks,
925  value values )
926 {
927  CAMLparam5( opt, position, x, y, x_length );
928  CAMLxparam5( y_length, bg_color, bb_color, bb_style, low_cap_color );
929  CAMLxparam5( high_cap_color, cont_color, cont_width, label_opts, label );
930  CAMLxparam4( axis_opts, ticks, sub_ticks, values );
931  CAMLlocal1( result );
932  result = caml_alloc( 2, 0 );
933 
934  // Counter
935  int i;
936  // General colorbar options
937  int c_opt, c_position;
938  // Number of labels
939  int n_labels;
940  n_labels = Wosize_val( label_opts );
941  // Number of axes and value ranges
942  int n_axes;
943  n_axes = Wosize_val( axis_opts );
944 
945  // Translate configuration options
946  c_opt = lor_ml_list( opt, translate_colorbar_option );
947  c_position = lor_ml_list( position, translate_position_option );
948 
949  // Assume that the dimensions all line up on the OCaml side, so we don't
950  // need to do any further dimension checks.
951 
952  // Define and initialize all of the C arrays to pass into plcolorbar
953  INIT_STRING_ARRAY( label )
954  INIT_STRING_ARRAY( axis_opts )
955  INIT_INT_ARRAY( sub_ticks );
956 
957  // Label options
958  int c_label_opts[ n_labels ];
959  for ( i = 0; i < n_labels; i++ )
960  {
961  c_label_opts[i] = lor_ml_list( Field( label_opts, i ), translate_colorbar_option );
962  }
963 
964  // Copy the axis/range values
965  double **c_values;
966  int n_values[ n_axes ];
967  c_values = malloc( n_axes * sizeof ( double * ) );
968  // TODO: Add allocation failure check
969  for ( i = 0; i < n_axes; i++ )
970  {
971  c_values[i] = (double *) Field( values, i );
972  n_values[i] = Wosize_val( Field( values, i ) ) / Double_wosize;
973  }
974 
975  // Return values
976  PLFLT width, height;
977 
978  plcolorbar( &width, &height,
979  c_opt, c_position, Double_val( x ), Double_val( y ),
980  Double_val( x_length ), Double_val( y_length ),
981  Int_val( bg_color ), Int_val( bb_color ), Int_val( bb_style ),
982  Double_val( low_cap_color ), Double_val( high_cap_color ),
983  Int_val( cont_color ), Double_val( cont_width ),
984  n_labels, c_label_opts, c_label,
985  n_axes, c_axis_opts,
986  (double *) ticks, c_sub_ticks,
987  n_values, (const PLFLT * const *) c_values );
988 
989  // Return a tuple with the colorbar's size
990  Store_field( result, 0, caml_copy_double( width ) );
991  Store_field( result, 1, caml_copy_double( height ) );
992 
993  CAMLreturn( result );
994 }
995 
997 {
998  return ml_plcolorbar( argv[0], argv[1], argv[2], argv[3], argv[4],
999  argv[5], argv[6], argv[7], argv[8], argv[9],
1000  argv[10], argv[11], argv[12], argv[13], argv[14],
1001  argv[15], argv[16], argv[17], argv[18] );
1002 }
1003 
1004 // pltr* function implementations
1005 void ml_pltr0( double x, double y, double* tx, double* ty )
1006 {
1007  pltr0( x, y, tx, ty, NULL );
1008 }
1009 
1011 {
1012  CAMLparam4( xg, yg, x, y );
1013  CAMLlocal1( tx_ty );
1014  tx_ty = caml_alloc( 2, 0 );
1015  double tx;
1016  double ty;
1017  PLcGrid grid;
1018  grid.xg = (double *) xg;
1019  grid.yg = (double *) yg;
1020  grid.nx = Wosize_val( xg ) / Double_wosize;
1021  grid.ny = Wosize_val( yg ) / Double_wosize;
1022  pltr1( Double_val( x ), Double_val( y ), &tx, &ty, ( PLPointer ) & grid );
1023 
1024  // Allocate a tuple and return it with the results
1025  Store_field( tx_ty, 0, caml_copy_double( tx ) );
1026  Store_field( tx_ty, 1, caml_copy_double( ty ) );
1027  CAMLreturn( tx_ty );
1028 }
1029 
1031 {
1032  CAMLparam4( xg, yg, x, y );
1033  CAMLlocal1( tx_ty );
1034  tx_ty = caml_alloc( 2, 0 );
1035  double ** c_xg;
1036  double ** c_yg;
1037  int i;
1038  int length1;
1039  int length2;
1040  PLcGrid2 grid;
1041  double tx;
1042  double ty;
1043 
1044  // TODO: As of now, you will probably get a segfault of the xg and yg
1045  // dimensions don't match up properly.
1046  // Build the grid.
1047  // Length of "outer" array
1048  length1 = Wosize_val( xg );
1049  // Length of the "inner" arrays
1050  length2 = Wosize_val( Field( xg, 0 ) ) / Double_wosize;
1051  c_xg = malloc( length1 * sizeof ( double* ) );
1052  for ( i = 0; i < length1; i++ )
1053  {
1054  c_xg[i] = (double *) Field( xg, i );
1055  }
1056  c_yg = malloc( length1 * sizeof ( double* ) );
1057  for ( i = 0; i < length1; i++ )
1058  {
1059  c_yg[i] = (double *) Field( yg, i );
1060  }
1061  grid.xg = c_xg;
1062  grid.yg = c_yg;
1063  grid.nx = length1;
1064  grid.ny = length2;
1065 
1066  pltr2( Double_val( x ), Double_val( y ), &tx, &ty, ( PLPointer ) & grid );
1067 
1068  // Clean up
1069  free( c_xg );
1070  free( c_yg );
1071 
1072  // Allocate a tuple and return it with the results
1073  Store_field( tx_ty, 0, caml_copy_double( tx ) );
1074  Store_field( tx_ty, 1, caml_copy_double( ty ) );
1075  CAMLreturn( tx_ty );
1076 }
1077 
1078 // XXX Non-core functions follow XXX
1079 //*
1080 // The following functions are here for (my?) convenience. As far as I can
1081 // tell, they are not defined in the core PLplot library.
1082 //
1083 
1084 // Get the current color map 0 color index
1085 int plg_current_col0( void )
1086 {
1087  return plsc->icol0;
1088 }
1089 
1090 // Get the current color map 1 color index
1092 {
1093  return plsc->icol1;
1094 }
1095 
1096 // Get the current pen width. TODO: Remove this, as I think this information
1097 // can be retrieved from another proper PLplot function.
1099 {
1100  return plsc->width;
1101 }
1102 
1103 // Get the current character (text) height in mm. TODO: Remove this, as I
1104 // think this information can be retrieved from another proper PLplot
1105 // function
1107 {
1108  return plsc->chrht;
1109 }
void ml_pltr0(double x, double y, double *tx, double *ty)
Definition: plplot_impl.c:1005
PLFLT plgchrht(void)
Definition: plplot_impl.c:1106
value ml_plcolorbar_byte(value *argv, int argn)
Definition: plplot_impl.c:996
static char ** argv
Definition: qt.cpp:40
#define PL_PARSE_NOPROGRAM
Definition: plplot.h:367
void ml_plshade(const PLFLT **a, PLINT nx, PLINT ny, PLFLT left, PLFLT right, PLFLT bottom, PLFLT top, PLFLT shade_min, PLFLT shade_max, PLINT sh_cmap, PLFLT sh_color, PLFLT sh_width, PLINT min_color, PLFLT min_width, PLINT max_color, PLFLT max_width, PLBOOL rectangular)
Definition: plplot_impl.c:410
void ml_mapform(PLINT n, PLFLT *x, PLFLT *y)
Definition: plplot_impl.c:114
void(* ML_LABEL_FUNC)(PLINT, PLFLT, char *, PLINT, PLPointer)
Definition: plplot_impl.c:48
value ml_plstripc(value xspec, value yspec, value xmin, value xmax, value xjump, value ymin, value ymax, value xlpos, value ylpos, value y_ascl, value acc, value colbox, value collab, value colline, value styline, value legline, value labx, value laby, value labtop)
Definition: plplot_impl.c:721
#define PL_LEGEND_LINE
Definition: plplot.h:1311
#define PL_COLORBAR_LABEL_TOP
Definition: plplot.h:1321
PLINT ml_defined(PLFLT x, PLFLT y)
Definition: plplot_impl.c:89
#define PL_PARSE_QUIET
Definition: plplot.h:362
void c_plsvect(PLFLT_VECTOR arrowx, PLFLT_VECTOR arrowy, PLINT npts, PLBOOL fill)
Definition: plvect.c:49
PLDLLIMPEXP void c_plmap(PLMAPFORM_callback mapform, PLCHAR_VECTOR name, PLFLT minx, PLFLT maxx, PLFLT miny, PLFLT maxy)
#define CAML_PLPLOT_TRANSFORM_FUNC_NAME
Definition: plplot_impl.c:43
#define PL_PARSE_NODASH
Definition: plplot.h:368
#define CAML_PLPLOT_LABEL_FUNC_NAME
Definition: plplot_impl.c:40
#define pllegend
Definition: plplot.h:757
void mapform(PLINT n, PLFLT *x, PLFLT *y)
Definition: tclAPI.c:3693
void ml_plshades(const PLFLT **a, PLINT nx, PLINT ny, PLFLT xmin, PLFLT xmax, PLFLT ymin, PLFLT ymax, PLFLT *clevel, PLINT nlevel, PLFLT fill_width, PLINT cont_color, PLFLT cont_width, PLBOOL rectangular)
Definition: plplot_impl.c:450
#define CAML_PLPLOT_DEFINED_FUNC_NAME
Definition: plplot_impl.c:39
value ml_plstransform(value unit)
Definition: plplot_impl.c:346
#define plfill
Definition: plplot.h:714
void ml_plvect(const PLFLT **u, const PLFLT **v, PLINT nx, PLINT ny, PLFLT scale)
Definition: plplot_impl.c:493
#define PL_POSITION_BOTTOM
Definition: plplot.h:1302
#define PL_LEGEND_BACKGROUND
Definition: plplot.h:1314
PLDLLIMPEXP void c_plmeridians(PLMAPFORM_callback mapform, PLFLT dlong, PLFLT dlat, PLFLT minlong, PLFLT maxlong, PLFLT minlat, PLFLT maxlat)
int lor_ml_list(value list, ML_VARIANT_FUNC variant_f)
Definition: plplot_impl.c:682
value ml_pllegend_byte(value *argv, int argn)
Definition: plplot_impl.c:907
#define plpoly3
Definition: plplot.h:781
#define PL_COLORBAR_ORIENT_TOP
Definition: plplot.h:1331
ML_MAPFORM_FUNC get_ml_mapform_func()
Definition: plplot_impl.c:265
#define PL_LEGEND_SYMBOL
Definition: plplot.h:1312
#define PL_COLORBAR_BACKGROUND
Definition: plplot.h:1334
#define PL_POSITION_LEFT
Definition: plplot.h:1299
#define PL_PARSE_NODELETE
Definition: plplot.h:363
#define plparseopts
Definition: plplot.h:777
void(* ML_PLOTTER_FUNC)(PLFLT, PLFLT, PLFLT *, PLFLT *, PLPointer)
Definition: plplot_impl.c:45
void * PLPointer
Definition: plplot.h:202
#define PL_COLORBAR_SHADE
Definition: plplot.h:1324
void ml_plsvect_reset()
Definition: plplot_impl.c:503
#define CAML_PLPLOT_MAPFORM_FUNC_NAME
Definition: plplot_impl.c:38
void plsabort(void(*handler)(PLCHAR_VECTOR))
Definition: plctrl.c:1928
PLINT ny
Definition: plplot.h:533
#define PL_LEGEND_BOUNDING_BOX
Definition: plplot.h:1315
ML_PLOTTER_FUNC get_ml_plotter_func()
Definition: plplot_impl.c:231
value ml_plsexit(value unit)
Definition: plplot_impl.c:325
#define PL_LEGEND_NONE
Definition: plplot.h:1309
PLFLT plg_current_col1(void)
Definition: plplot_impl.c:1091
value ml_plgriddata(value x, value y, value z, value xg, value yg, value type, value data)
Definition: plplot_impl.c:542
int PLINT
Definition: plplot.h:174
value ml_pltr2(value xg, value yg, value x, value y)
Definition: plplot_impl.c:1030
#define MAX_EXCEPTION_MESSAGE_LENGTH
Definition: plplot_impl.c:36
PLINT PLBOOL
Definition: plplot.h:197
#define PL_POSITION_OUTSIDE
Definition: plplot.h:1304
ML_DEFINED_FUNC get_ml_defined_func()
Definition: plplot_impl.c:248
#define PL_POSITION_RIGHT
Definition: plplot.h:1300
int ml_exit(const char *message)
Definition: plplot_impl.c:187
#define PL_COLORBAR_LABEL_LEFT
Definition: plplot.h:1319
#define PL_LEGEND_ROW_MAJOR
Definition: plplot.h:1316
PLFLT_NC_MATRIX yg
Definition: plplot.h:532
PLINT ny
Definition: plplot.h:521
#define INIT_INT_ARRAY(o)
Definition: plplot_impl.c:666
void c_plcont(PLFLT_MATRIX f, PLINT nx, PLINT ny, PLINT kx, PLINT lx, PLINT ky, PLINT ly, PLFLT_VECTOR clevel, PLINT nlevel, PLTRANSFORM_callback pltr, PLPointer pltr_data)
Definition: plcont.c:508
#define PL_PARSE_PARTIAL
Definition: plplot.h:360
void ml_plmeridians(PLFLT dlong, PLFLT dlat, PLFLT minlong, PLFLT maxlong, PLFLT minlat, PLFLT maxlat)
Definition: plplot_impl.c:526
#define PL_COLORBAR_SHADE_LABEL
Definition: plplot.h:1329
value ml_plgriddata_bytecode(value *argv, int argn)
Definition: plplot_impl.c:601
#define PL_COLORBAR_ORIENT_BOTTOM
Definition: plplot.h:1333
#define PL_POSITION_VIEWPORT
Definition: plplot.h:1305
#define INIT_NC_STRING_ARRAY(o)
Definition: plplot_impl.c:659
#define PL_COLORBAR_GRADIENT
Definition: plplot.h:1325
#define snprintf
Definition: plplotP.h:235
void plFree2dGrid(PLFLT **f, PLINT nx, PLINT PL_UNUSED(ny))
Definition: plmem.c:85
void ml_plcont(const PLFLT **f, PLINT nx, PLINT ny, PLINT kx, PLINT lx, PLINT ky, PLINT ly, PLFLT *clevel, PLINT nlevel)
Definition: plplot_impl.c:379
void c_plimagefr(PLFLT_MATRIX idata, PLINT nx, PLINT ny, PLFLT xmin, PLFLT xmax, PLFLT ymin, PLFLT ymax, PLFLT zmin, PLFLT zmax, PLFLT valuemin, PLFLT valuemax, PLTRANSFORM_callback pltr, PLPointer pltr_data)
Definition: plimage.c:238
void c_plgriddata(PLFLT_VECTOR x, PLFLT_VECTOR y, PLFLT_VECTOR z, PLINT npts, PLFLT_VECTOR xg, PLINT nptsx, PLFLT_VECTOR yg, PLINT nptsy, PLFLT **zg, PLINT type, PLFLT data)
Definition: plgridd.c:116
#define PL_POSITION_SUBPAGE
Definition: plplot.h:1306
PLFLT_NC_FE_POINTER yg
Definition: plplot.h:520
#define plstransform
Definition: plplot.h:842
#define PL_COLORBAR_CAP_NONE
Definition: plplot.h:1326
value ml_pltr1(value xg, value yg, value x, value y)
Definition: plplot_impl.c:1010
PLINT nx
Definition: plplot.h:533
#define INIT_STRING_ARRAY(o)
Definition: plplot_impl.c:652
#define PL_COLORBAR_ORIENT_LEFT
Definition: plplot.h:1332
value ml_plcolorbar(value opt, value position, value x, value y, value x_length, value y_length, value bg_color, value bb_color, value bb_style, value low_cap_color, value high_cap_color, value cont_color, value cont_width, value label_opts, value label, value axis_opts, value ticks, value sub_ticks, value values)
Definition: plplot_impl.c:917
#define CAML_PLPLOT_PLOTTER_FUNC_NAME
Definition: plplot_impl.c:37
void ml_plmap(const char *type, PLFLT minlong, PLFLT maxlong, PLFLT minlat, PLFLT maxlat)
Definition: plplot_impl.c:513
void plsexit(int(*handler)(PLCHAR_VECTOR))
Definition: plctrl.c:1977
#define PL_POSITION_INSIDE
Definition: plplot.h:1303
void c_plshades(PLFLT_MATRIX a, PLINT nx, PLINT ny, PLDEFINED_callback defined, PLFLT xmin, PLFLT xmax, PLFLT ymin, PLFLT ymax, PLFLT_VECTOR clevel, PLINT nlevel, PLFLT fill_width, PLINT cont_color, PLFLT cont_width, PLFILL_callback fill, PLINT rectangular, PLTRANSFORM_callback pltr, PLPointer pltr_data)
Definition: plshade.c:216
#define plstripc
Definition: plplot.h:846
PLFLT plgwidth(void)
Definition: plplot_impl.c:1098
static PLFLT value(double n1, double n2, double hue)
Definition: plctrl.c:1209
int translate_legend_option(int legend_option)
Definition: plplot_impl.c:763
#define PL_COLORBAR_CAP_HIGH
Definition: plplot.h:1328
#define CAML_PLPLOT_EXIT_FUNC_NAME
Definition: plplot_impl.c:42
#define PL_COLORBAR_ORIENT_RIGHT
Definition: plplot.h:1330
PLINT(* ML_VARIANT_FUNC)(PLINT)
Definition: plplot_impl.c:49
float PLFLT
Definition: plplot.h:157
#define PL_PARSE_FULL
Definition: plplot.h:361
value ml_plparseopts(value argv, value parse_method)
Definition: plplot_impl.c:699
#define PL_LEGEND_TEXT_LEFT
Definition: plplot.h:1313
void plplot_check_nonzero_result(int result)
Definition: plplot_impl.c:619
void plAlloc2dGrid(PLFLT ***f, PLINT nx, PLINT ny)
Definition: plmem.c:60
int plg_current_col0(void)
Definition: plplot_impl.c:1085
#define PL_PARSE_SKIP
Definition: plplot.h:369
#define PL_COLORBAR_CAP_LOW
Definition: plplot.h:1327
void ml_transform(PLFLT x, PLFLT y, PLFLT *xt, PLFLT *yt, PLPointer data)
Definition: plplot_impl.c:208
#define plcolorbar
Definition: plplot.h:701
PLFLT_NC_FE_POINTER xg
Definition: plplot.h:520
value ml_pllegend(value opt, value position, value x, value y, value plot_width, value bg_color, value bb_color, value bb_style, value nrow, value ncolumn, value opt_array, value text_offset, value text_scale, value text_spacing, value text_justification, value text_colors, value text, value box_colors, value box_patterns, value box_scales, value box_line_widths, value line_colors, value line_styles, value line_widths, value symbol_colors, value symbol_scales, value symbol_numbers, value symbols)
Definition: plplot_impl.c:826
void ml_plpoly3(PLINT n, PLFLT *x, PLFLT *y, PLFLT *z, PLINT ndraw, PLBOOL *draw, PLBOOL ifcc)
Definition: plplot_impl.c:613
void c_plvect(PLFLT_MATRIX u, PLFLT_MATRIX v, PLINT nx, PLINT ny, PLFLT scale, PLTRANSFORM_callback pltr, PLPointer pltr_data)
Definition: plvect.c:261
void ml_abort(const char *message)
Definition: plplot_impl.c:168
#define PL_PARSE_SHOWALL
Definition: plplot.h:365
void c_plshade(PLFLT_MATRIX a, PLINT nx, PLINT ny, PLDEFINED_callback defined, PLFLT xmin, PLFLT xmax, PLFLT ymin, PLFLT ymax, PLFLT shade_min, PLFLT shade_max, PLINT sh_cmap, PLFLT sh_color, PLFLT sh_width, PLINT min_color, PLFLT min_width, PLINT max_color, PLFLT max_width, PLFILL_callback fill, PLINT rectangular, PLTRANSFORM_callback pltr, PLPointer pltr_data)
Definition: plshade.c:352
int translate_parse_option(int parse_option)
Definition: plplot_impl.c:632
value ml_plstripc_byte(value *argv, int argn)
Definition: plplot_impl.c:755
#define PL_LEGEND_COLOR_BOX
Definition: plplot.h:1310
PLFLT_NC_MATRIX xg
Definition: plplot.h:532
#define PL_COLORBAR_LABEL_BOTTOM
Definition: plplot.h:1322
void ml_plimagefr(const PLFLT **idata, PLINT nx, PLINT ny, PLFLT xmin, PLFLT xmax, PLFLT ymin, PLFLT ymax, PLFLT zmin, PLFLT zmax, PLFLT valuemin, PLFLT valuemax)
Definition: plplot_impl.c:474
#define PL_POSITION_TOP
Definition: plplot.h:1301
#define PL_PARSE_OVERRIDE
Definition: plplot.h:366
void ml_labelfunc(PLINT axis, PLFLT n, char *label, PLINT length, PLPointer d)
Definition: plplot_impl.c:146
#define CAML_PLPLOT_ABORT_FUNC_NAME
Definition: plplot_impl.c:41
int translate_colorbar_option(int colorbar_option)
Definition: plplot_impl.c:781
#define PL_COLORBAR_BOUNDING_BOX
Definition: plplot.h:1335
#define PL_COLORBAR_IMAGE
Definition: plplot.h:1323
PLINT(* ML_DEFINED_FUNC)(PLFLT, PLFLT)
Definition: plplot_impl.c:46
#define PL_COLORBAR_LABEL_RIGHT
Definition: plplot.h:1320
value ml_plslabelfunc(value unit)
Definition: plplot_impl.c:284
void(* ML_MAPFORM_FUNC)(PLINT, PLFLT *, PLFLT *)
Definition: plplot_impl.c:47
#define plslabelfunc
Definition: plplot.h:826
PLINT nx
Definition: plplot.h:521
void ml_plotter(PLFLT x, PLFLT y, PLFLT *tx, PLFLT *ty, PLPointer pltr_data)
Definition: plplot_impl.c:60
int translate_position_option(int position_option)
Definition: plplot_impl.c:808
value ml_plsabort(value unit)
Definition: plplot_impl.c:306