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