~ubuntu-branches/ubuntu/intrepid/plplot/intrepid

« back to all changes in this revision

Viewing changes to bindings/python/plmodule.c

  • Committer: Bazaar Package Importer
  • Author(s): Rafael Laboissiere
  • Date: 2006-11-04 10:19:34 UTC
  • mfrom: (2.1.8 edgy)
  • Revision ID: james.westby@ubuntu.com-20061104101934-mlirvdg4gpwi6i5q
Tags: 5.6.1-10
* Orphaning the package
* debian/control: Changed the maintainer to the Debian QA Group

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*      plmodule.c 
2
 
 
3
 
        Permission granted to copy and distribute this work provided that this 
4
 
        notice remains intact.
5
 
 
6
 
        Python interface bindings
7
 
        Written by: interran@uluru.Stanford.EDU (John Interrante) 
8
 
                         et@appl-math.tu-muenchen.de (Thomas Schwaller)*/
9
 
 
10
 
/*  Additional changes under LGPL by Geoffrey Furnish and Alan W. Irwin */
11
 
 
12
 
/*      Rules for translating C PLplot function calls into Python PLplot:
13
 
          - All names are the the same (plot3d modified to plplot3d for uniformity), but
14
 
           now for uniformity with C API change back to plot3d---AWI.
15
 
          - C arrays are replaced by Python matrices or objects which can be 
16
 
           converted to matrices.
17
 
          - Array and Matrix lengths are eliminated since matrices know how long they are.
18
 
          - Output parameters are replaced by function return values or tuples.
19
 
 
20
 
      Thanxs to Jim Fulton, James Hugunin, Konrad Hinsen and all the other people in the
21
 
      Python Matrix SIG for the stimulating talks and the same spirit of mind!
22
 
 
23
 
*/
24
 
 
25
 
#include "plplot/plmodule.h"
26
 
 
27
 
/*static*/ int pl_PyArray_AsFloatArray(PyObject **op, PLFLT **pitems, 
28
 
                                       PLINT *pn)
29
 
{
30
 
    PyArrayObject *mp;
31
 
    mp = (PyArrayObject *) 
32
 
     PyArray_ContiguousFromObject (*op, PyArray_PLFLT, 0, 1);
33
 
    if (!mp) return 0;
34
 
    *pitems =(PLFLT*) (mp->data);
35
 
    *pn = mp->dimensions[0];
36
 
    *op = (PyObject*) mp;
37
 
    return 1;
38
 
}
39
 
 
40
 
/*static*/ int pl_PyArray_AsIntArray(PyObject **op, PLINT **pitems, PLINT *pn)
41
 
{
42
 
    PyArrayObject *mp;
43
 
    mp = (PyArrayObject *) PyArray_ContiguousFromObject (*op, PyArray_INT, 0, 1);
44
 
    if (!mp) return 0;
45
 
    *pitems =(PLINT*) (mp->data);
46
 
    *pn = mp->dimensions[0];
47
 
    *op = (PyObject*) mp;
48
 
    return 1;
49
 
}
50
 
 
51
 
/* Thanxs to James Hugunin for helping me with that! */
52
 
 
53
 
/*static*/ int  pl_PyArray_AsFloatMatrix (PyObject **op, PLINT* m, PLINT* n, PLFLT*** pitems)
54
 
{
55
 
    char *dp, **dpp;
56
 
    int j, size;
57
 
    PyArrayObject *mp;
58
 
    mp = (PyArrayObject *) PyArray_ContiguousFromObject (*op, PyArray_PLFLT, 2, 2);
59
 
    if (!mp) return 0;
60
 
    *m = mp->dimensions[0];
61
 
    *n = mp->dimensions[1];
62
 
    dp = mp->data;
63
 
    size = *n * sizeof(PLFLT);
64
 
    if (!(dpp = PyMem_NEW(char*, *m))) {
65
 
        PyErr_NoMemory();
66
 
        Py_DECREF(mp);
67
 
        return 0;
68
 
    }
69
 
    for(j=0; j< *m; j++) 
70
 
        dpp[j] = dp+size*j;
71
 
    *pitems = (PLFLT**) dpp;
72
 
    *op = (PyObject*) mp;
73
 
    return 1;
74
 
}
75
 
 
76
 
/* Convert a Python list of strings to a C array.  Code copied from stdwinmodule.c. */
77
 
 
78
 
/*static*/ int pl_PyList_AsStringArray(PyObject *list, char ***pitems, int *pn)
79
 
{
80
 
    char **items;
81
 
    int n, i;
82
 
    n = PyList_Size(list);
83
 
    items = PyMem_NEW(char*, n + 1);
84
 
    if (items == NULL) {
85
 
        PyErr_NoMemory();
86
 
        return 0;
87
 
    }
88
 
    for (i = 0; i < n; i++) {
89
 
        PyObject *item = PyList_GetItem(list, i);
90
 
        if (!PyString_Check(item)) {
91
 
            PyErr_SetString(PyExc_TypeError, "list of strings expected");
92
 
            return 0;
93
 
        }
94
 
        items[i] = PyString_AsString(item);
95
 
    }
96
 
    items[n] = NULL;            /* Obey convention of NULL-terminated argv */
97
 
    *pitems = items;
98
 
    *pn = n;
99
 
    return 1;
100
 
}
101
 
 
102
 
/* Store a C array back into a Python list of strings.  Code copied from stdwinmodule.c. */
103
 
 
104
 
/*static*/ int pl_PyList_SetFromStringArray(PyObject *list, char **items, int n)
105
 
{
106
 
    int i, oldsize = PyList_Size(list);
107
 
    PyObject *newlist;
108
 
    if (n == oldsize) return 1;
109
 
    newlist = PyList_New(n);
110
 
    for (i = 0; i < n && newlist != NULL; i++) {
111
 
        if (items[i]) {
112
 
            PyObject *item = PyString_FromString(items[i]);
113
 
            if (item == NULL) {
114
 
                Py_DECREF(newlist);
115
 
                newlist = NULL;
116
 
            } else
117
 
                PyList_SetItem(newlist, i, item);
118
 
        } else {
119
 
            /* plParseOpts is buggy; it can return NULLs in the
120
 
               middle of the argument list.  We still have n - i args
121
 
               left to store, so skip over the NULL. */
122
 
            items++;
123
 
            i--;
124
 
        }
125
 
    }
126
 
    if (newlist == NULL) return 0;
127
 
    PyList_SetSlice(list, 0, oldsize, newlist);
128
 
    Py_DECREF(newlist);
129
 
    return 1;
130
 
}
131
 
 
132
 
static char doc_pladv[] = "Advance to subpage \"page\", or to the next one if \"page\" = 0";
133
 
 
134
 
static PyObject * pl_adv(PyObject *self, PyObject *args)
135
 
{
136
 
    PLINT page;
137
 
    TRY (PyArg_ParseTuple(args, "i", &page));
138
 
    pladv(page);
139
 
    Py_INCREF(Py_None);
140
 
    return Py_None;
141
 
}
142
 
 
143
 
static char doc_plarrows[] = "simple arrow plotter";
144
 
 
145
 
static PyObject * pl_arrows(PyObject *self, PyObject *args)
146
 
{
147
 
    PLFLT *u, *v, *x, *y, scale, dx, dy;
148
 
    PLINT un, vn, xn, yn;
149
 
    PyObject *uop, *vop, *xop, *yop;
150
 
    TRY (PyArg_ParseTuple(args, PL_ARGS("OOOOddd", "OOOOfff"), 
151
 
                                              &uop, &vop, &xop, &yop, &scale, &dx, &dy));
152
 
    TRY (pl_PyArray_AsFloatArray(&uop, &u, &un));
153
 
    TRY (pl_PyArray_AsFloatArray(&vop, &v, &vn));
154
 
    TRY (pl_PyArray_AsFloatArray(&xop, &x, &xn));
155
 
    TRY (pl_PyArray_AsFloatArray(&yop, &y, &yn));
156
 
     if ((un != vn) || (vn != xn) || (xn != yn)) {
157
 
            PyErr_SetString(PyExc_ValueError, "first 4 arguments should have the same length");
158
 
          Py_DECREF(uop);
159
 
          Py_DECREF(vop);
160
 
          Py_DECREF(xop);
161
 
          Py_DECREF(yop);
162
 
            return NULL;
163
 
    }
164
 
    plarrows(u, v, x, y, un, scale, dx, dy);
165
 
    Py_DECREF(uop);
166
 
    Py_DECREF(vop);
167
 
    Py_DECREF(xop);
168
 
    Py_DECREF(yop);                                   
169
 
    Py_INCREF(Py_None);
170
 
    return Py_None;
171
 
}
172
 
 
173
 
static char doc_plaxes[]=" This functions similarly to plbox() except that the origin of the axes is placed at the user-specified point (x0, y0)";
174
 
 
175
 
static PyObject * pl_axes(PyObject *self, PyObject *args)
176
 
{
177
 
    PLFLT x0, y0, xtick, ytick;
178
 
    PLINT nxsub, nysub;
179
 
    const char *xopt, *yopt;
180
 
    TRY (PyArg_ParseTuple(args, PL_ARGS("ddsdisdi", "ffsfisfi"), &x0, &y0, &xopt, &xtick, 
181
 
                                                                                           &nxsub, &yopt, &ytick, &nysub));
182
 
    plaxes(x0, y0, xopt, xtick, nxsub, yopt, ytick, nysub);
183
 
    Py_INCREF(Py_None);
184
 
    return Py_None;
185
 
}
186
 
 
187
 
static char doc_plbin[]="Plot a histogram using x to store data values and y to store frequencies";
188
 
 
189
 
static PyObject * pl_bin(PyObject *self, PyObject *args)
190
 
{
191
 
    PLINT nbin, center, ylen;
192
 
    PLFLT *x, *y;
193
 
    PyObject *xop, *yop;
194
 
    TRY (PyArg_ParseTuple(args, "OOi", &xop, &yop, &center));
195
 
    TRY (pl_PyArray_AsFloatArray(&xop, &x, &nbin));
196
 
    TRY (pl_PyArray_AsFloatArray(&yop, &y, &ylen));
197
 
    if (nbin != ylen) {
198
 
          PyErr_SetString(PyExc_ValueError, "args 1 and 2 should have the same length");
199
 
        Py_DECREF(xop);
200
 
        Py_DECREF(yop);
201
 
          return NULL;
202
 
    }
203
 
    plbin(nbin, x, y, center);
204
 
    Py_DECREF(xop);
205
 
    Py_DECREF(yop);
206
 
    Py_INCREF(Py_None);
207
 
    return Py_None;
208
 
}
209
 
 
210
 
static char doc_plbop[]="Start new page.  Should only be used with pleop()";
211
 
 
212
 
static PyObject * pl_bop(PyObject *self, PyObject *args)
213
 
{
214
 
    TRY (PyArg_ParseTuple(args, ""));
215
 
    plbop();
216
 
    Py_INCREF(Py_None);
217
 
    return Py_None;
218
 
}
219
 
 
220
 
static char doc_plbox[]="This draws a box around the current viewport";
221
 
 
222
 
static PyObject * pl_box(PyObject *self, PyObject *args)
223
 
{
224
 
    const char *xopt, *yopt;
225
 
    PLFLT xtick, ytick;
226
 
    PLINT nxsub, nysub;
227
 
    TRY (PyArg_ParseTuple(args, PL_ARGS("sdisdi", "sfisfi"),
228
 
                                             &xopt, &xtick, &nxsub, &yopt, &ytick, &nysub));
229
 
    plbox(xopt, xtick, nxsub, yopt, ytick, nysub);
230
 
    Py_INCREF(Py_None);
231
 
    return Py_None;
232
 
}
233
 
 
234
 
static char doc_plcalc_world[]="Calculate world coordinates";
235
 
 
236
 
static PyObject * pl_calc_world(PyObject *self, PyObject *args)
237
 
{
238
 
        PLFLT rx, ry, wx, wy;
239
 
        PLINT window;
240
 
        TRY (PyArg_ParseTuple(args, PL_ARGS("dd", "ff"), &rx, &ry));
241
 
        plcalc_world(rx, ry, &wx, &wy, &window);        
242
 
        return Py_BuildValue(PL_ARGS("(ddi)", "(ffi)"), wx, wy, window);
243
 
}
244
 
 
245
 
 
246
 
static char doc_plbox3[]="This is the 3-d analogue of plbox()";
247
 
 
248
 
static PyObject * pl_box3(PyObject *self, PyObject *args)
249
 
{
250
 
    const char *xopt, *xlabel, *yopt, *ylabel, *zopt, *zlabel;
251
 
    PLFLT xtick, ytick, ztick;
252
 
    PLINT nsubx, nsuby, nsubz;
253
 
    TRY (PyArg_ParseTuple(args, PL_ARGS("ssdissdissdi", "ssfissfissfi"),
254
 
                     &xopt, &xlabel, &xtick, &nsubx, &yopt, &ylabel, &ytick, &nsuby,
255
 
                     &zopt, &zlabel, &ztick, &nsubz));
256
 
    plbox3(xopt, xlabel, xtick, nsubx, yopt, ylabel, ytick, nsuby, zopt, zlabel, ztick, nsubz);
257
 
    Py_INCREF(Py_None);
258
 
    return Py_None;
259
 
}
260
 
 
261
 
static char doc_plcol0[]="Set color, map 0.  Argument is integer between 0 and 15";
262
 
 
263
 
static PyObject * pl_col0(PyObject *self, PyObject *args)
264
 
{
265
 
    PLINT icol0;
266
 
    TRY (PyArg_ParseTuple(args, "i", &icol0));
267
 
    plcol0(icol0);
268
 
    Py_INCREF(Py_None);
269
 
    return Py_None;
270
 
}
271
 
 
272
 
static char doc_plcol1[]="Set color, map 1.  Argument is a float between 0. and 1";
273
 
 
274
 
static PyObject * pl_col1(PyObject *self, PyObject *args)
275
 
{
276
 
    PLFLT col1;
277
 
    TRY (PyArg_ParseTuple(args, PL_ARGS("d", "f"), &col1));
278
 
    plcol1(col1);
279
 
    Py_INCREF(Py_None);
280
 
    return Py_None;
281
 
}
282
 
 
283
 
/* superseded by plcont
284
 
static char doc_plcont_ts[]="Draws a contour plot from data in f(nx,ny).  Is just a front-end to plfcont, with a particular choice for f2eval and f2eval_data";
285
 
 
286
 
static void pypltr(PLFLT x, PLFLT y, PLFLT *tx, PLFLT *ty, PLPointer data)
287
 
{
288
 
    PyObject *ret, *value;
289
 
    value = Py_BuildValue(PL_ARGS("(dd)", "(ff)"), x, y);
290
 
    ret = PyEval_CallObject( (PyObject*) data, value); 
291
 
    PyArg_ParseTuple(ret, PL_ARGS("dd", "ff"), tx, ty);
292
 
    Py_DECREF(value);
293
 
    Py_DECREF(ret);
294
 
}
295
 
 
296
 
static PyObject * pl_cont_ts(PyObject *self, PyObject *args)
297
 
{
298
 
    PLINT nx, ny, kx, lx, ky, ly, nlevel;
299
 
    PLFLT **z, *clevel; 
300
 
    PyObject *op, *levelop, *f;
301
 
    TRY (PyArg_ParseTuple(args, "OiiiiOO!", &op, &kx, &lx, &ky, &ly, &levelop, 
302
 
                          &PyFunction_Type, &f));
303
 
    TRY (pl_PyArray_AsFloatMatrix(&op, &nx, &ny, &z));
304
 
    TRY (pl_PyArray_AsFloatArray(&levelop, &clevel, &nlevel));
305
 
    plcont(z, nx, ny, kx, lx, ky, ly, clevel, nlevel, pypltr, f);
306
 
    Py_DECREF(op);
307
 
    Py_DECREF(levelop);
308
 
    PyMem_DEL(z);
309
 
    if (PyErr_Occurred()) {
310
 
        PyErr_SetString(PyExc_RuntimeError, "Check your plotter function!");
311
 
        return NULL;
312
 
    }
313
 
    Py_INCREF(Py_None);
314
 
    return Py_None;
315
 
}
316
 
*/
317
 
 
318
 
static char doc_plcont2[]="Draws a contour plot from data in f(nx,ny).  Is just a front-end to plfcont, with a particular choice for f2eval and f2eval_data";
319
 
 
320
 
static void
321
 
pyt0(PLFLT x, PLFLT y, PLFLT *tx, PLFLT *ty, PLPointer pltr_data)
322
 
{
323
 
/*    printf( "evaluating tr0(%lf,%lf)\n", x, y );
324
 
 */    *tx = x;
325
 
    *ty = y;
326
 
}
327
 
 
328
 
/* static int pl_pymateval_modx, pl_pymateval_mody; */
329
 
 
330
 
/*--------------------------------------------------------------------------*\
331
 
 * plf2eval2()
332
 
 *
333
 
 * Does a lookup from a 2d function array.  Array is of type (PLFLT **),
334
 
 * and is column dominant (normal C ordering).
335
 
\*--------------------------------------------------------------------------*/
336
 
 
337
 
PLFLT
338
 
pyf2eval2(PLINT ix, PLINT iy, PLPointer plf2eval_data)
339
 
{
340
 
    PLFLT value;
341
 
    PLfGrid2 *grid = (PLfGrid2 *) plf2eval_data;
342
 
 
343
 
/*    printf( "In pyf2eval2(%d,%d)=%lf\n",
344
 
            ix, iy, grid->f[ix][iy] );
345
 
            */
346
 
    ix = ix % grid->nx;
347
 
    iy = iy % grid->ny;
348
 
 
349
 
    value = grid->f[ix][iy];
350
 
 
351
 
    return value;
352
 
}
353
 
 
354
 
static PyObject * pl_cont2(PyObject *self, PyObject *args)
355
 
{
356
 
    PLINT nx, ny, kx, lx, ky, ly, nlevel;
357
 
    PLFLT **z, *clevel; 
358
 
    PyObject *op, *levelop;
359
 
    PLfGrid2 grid;
360
 
 
361
 
/*    printf( "In Geoff's plcont2.\n" );*/
362
 
 
363
 
    TRY( PyArg_ParseTuple( args, "OiiiiO",
364
 
                           &op, &kx, &lx, &ky, &ly, &levelop ) );
365
 
    TRY (pl_PyArray_AsFloatMatrix(&op, &nx, &ny, &z));
366
 
    TRY (pl_PyArray_AsFloatArray(&levelop, &clevel, &nlevel));
367
 
 
368
 
/*    printf( "nx=%d ny=%d kx=%d lx=%d ky=%d ly=%d\n",
369
 
            nx, ny, kx, lx, ky, ly );
370
 
    printf( "nlevel=%d\n", nlevel );
371
 
    for( i=0; i < nlevel; i++ )
372
 
        printf( "level[%d] = %lf\n", i, clevel[i] );
373
 
 
374
 
    for( i=kx-1; i < lx; i++ ) {
375
 
        int j;
376
 
        for( j=ky-1; j < ly; j++ ) {
377
 
            printf( " data(%d,%d) = %lf\n", i, j, z[i][j] );
378
 
        }
379
 
    }*/
380
 
 
381
 
    grid.f = z;
382
 
 
383
 
/*    plcont(z, nx, ny, kx, lx, ky, ly, clevel, nlevel, pyt0, NULL );*/
384
 
    plcontf( pyf2eval2, (PLPointer) &grid, 
385
 
            nx, ny, kx, lx, ky, ly, clevel, nlevel,
386
 
            pyt0, NULL );
387
 
    Py_DECREF(op);
388
 
    Py_DECREF(levelop);
389
 
    PyMem_DEL(z);
390
 
    if (PyErr_Occurred()) {
391
 
        PyErr_SetString(PyExc_RuntimeError, "Check your plotter function!");
392
 
        return NULL;
393
 
    }
394
 
    Py_INCREF(Py_None);
395
 
    return Py_None;
396
 
}
397
 
 
398
 
/*
399
 
static char doc_plcont[]="Draws a contour plot using the function evaluator f2eval and data stored by way of the f2eval_data pointer. This allows arbitrary organizations of 2d array data to beused.";
400
 
 
401
 
void plfcont(PLFLT (*f2eval) (PLINT, PLINT, PLPointer),
402
 
        PLPointer f2eval_data,
403
 
        PLINT nx, PLINT ny, PLINT kx, PLINT lx,
404
 
        PLINT ky, PLINT ly, PLFLT *clevel, PLINT nlevel,
405
 
        void (*pltr) (PLFLT, PLFLT, PLFLT *, PLFLT *, PLPointer),
406
 
        PLPointer pltr_data);
407
 
*/
408
 
 
409
 
static char doc_plcpstrm[]="Copies state parameters from the reference stream to the current stream";
410
 
 
411
 
static PyObject * pl_cpstrm(PyObject *self, PyObject *args)
412
 
{
413
 
    PLINT iplsr, flags;
414
 
    TRY (PyArg_ParseTuple(args, "ii", &iplsr, &flags));
415
 
    plcpstrm(iplsr, flags);
416
 
    Py_INCREF(Py_None);
417
 
    return Py_None;
418
 
}
419
 
 
420
 
static char doc_pldid2pc[]="Converts input values from relative device coordinates to relative plot coordinates";
421
 
 
422
 
static PyObject * pl_did2pc(PyObject *self, PyObject *args)
423
 
{
424
 
    PLFLT xmin, ymin, xmax, ymax;
425
 
    TRY (PyArg_ParseTuple(args, PL_ARGS("dddd","ffff"), 
426
 
                                              &xmin, &ymin, &xmax, &ymax));
427
 
    pldid2pc(&xmin, &ymin, &xmax, &ymax);
428
 
    return Py_BuildValue(PL_ARGS("(dddd)", "(ffff)"), xmin, ymin, xmax, ymax);
429
 
}
430
 
 
431
 
static char doc_pldip2dc[]="Converts input values from relative plot coordinates to relative device coordinates";
432
 
 
433
 
static PyObject * pl_dip2dc(PyObject *self, PyObject *args)
434
 
{
435
 
    PLFLT xmin, ymin, xmax, ymax;
436
 
    TRY (PyArg_ParseTuple(args, PL_ARGS("dddd", "ffff"),
437
 
                                                  &xmin, &ymin, &xmax, &ymax));
438
 
    pldip2dc(&xmin, &ymin, &xmax, &ymax);
439
 
    return Py_BuildValue(PL_ARGS("(dddd)", "(ffff)"), xmin, ymin, xmax, ymax);
440
 
}
441
 
 
442
 
static char doc_plend[]="End a plotting session for all open streams";
443
 
 
444
 
static PyObject * pl_end(PyObject *self, PyObject *args)
445
 
{
446
 
    TRY (PyArg_ParseTuple(args, ""));
447
 
    plend();
448
 
    Py_INCREF(Py_None);
449
 
    return Py_None;
450
 
}
451
 
 
452
 
static char doc_plend1[]="End a plotting session for the current stream only";
453
 
 
454
 
static PyObject * pl_end1(PyObject *self, PyObject *args)
455
 
{
456
 
    TRY (PyArg_ParseTuple(args, ""));
457
 
    plend1();
458
 
    Py_INCREF(Py_None);
459
 
    return Py_None;
460
 
}
461
 
 
462
 
static char doc_plenv[]="Simple interface for defining viewport and window";
463
 
 
464
 
static PyObject * pl_env(PyObject *self, PyObject *args)
465
 
{
466
 
    PLFLT xmin, ymin, xmax, ymax;
467
 
    PLINT just, axis;
468
 
    TRY (PyArg_ParseTuple(args, PL_ARGS("ddddii", "ffffii"),
469
 
                                                 &xmin, &xmax, &ymin, &ymax, &just, &axis));
470
 
    plenv(xmin, xmax, ymin, ymax, just, axis);
471
 
    Py_INCREF(Py_None);
472
 
    return Py_None;
473
 
}
474
 
 
475
 
static char doc_pleop[]="End current page. Should only be used with plbop()";
476
 
 
477
 
static PyObject * pl_eop(PyObject *self, PyObject *args)
478
 
{
479
 
    TRY (PyArg_ParseTuple(args, ""));
480
 
    pleop();
481
 
    Py_INCREF(Py_None);
482
 
    return Py_None;
483
 
}
484
 
 
485
 
static char doc_plerrx[]="Plot horizontal error bars (xmin(i),y(i)) to (xmax(i),y(i))";
486
 
 
487
 
static PyObject * pl_errx(PyObject *self, PyObject *args)
488
 
{
489
 
    PLINT n, xmaxlen, ylen;
490
 
    PLFLT *xmin, *xmax, *y;
491
 
    PyObject *xminop, *xmaxop, *yop;
492
 
    TRY (PyArg_ParseTuple(args, "OOO", &xminop, &xmaxop, &yop));
493
 
    TRY (pl_PyArray_AsFloatArray(&xminop, &xmin, &n));
494
 
    TRY (pl_PyArray_AsFloatArray(&xmaxop, &xmax, &xmaxlen));
495
 
    TRY (pl_PyArray_AsFloatArray(&yop, &y, &ylen));
496
 
    if (n != xmaxlen || n != ylen) {
497
 
          PyErr_SetString(PyExc_ValueError, "args 1, 2, and 3 should have the same length");
498
 
        Py_DECREF(xminop);
499
 
        Py_DECREF(xmaxop);
500
 
        Py_DECREF(yop);
501
 
          return NULL;
502
 
    }
503
 
    plerrx(n, xmin, xmax, y);
504
 
    Py_DECREF(xminop);
505
 
    Py_DECREF(xmaxop);
506
 
    Py_DECREF(yop);
507
 
    Py_INCREF(Py_None);
508
 
    return Py_None;
509
 
}
510
 
 
511
 
static char doc_plerry[]="Plot vertical error bars (x,ymin(i)) to (x(i),ymax(i))";
512
 
 
513
 
static PyObject * pl_erry(PyObject *self, PyObject *args)
514
 
{
515
 
    PLINT n, yminlen, ymaxlen;
516
 
    PLFLT *x, *ymin, *ymax;
517
 
    PyObject *xop, *yminop, *ymaxop;
518
 
    TRY (PyArg_ParseTuple(args, "OOO", &xop, &yminop, &ymaxop));
519
 
    TRY (pl_PyArray_AsFloatArray(&xop, &x, &n));
520
 
    TRY (pl_PyArray_AsFloatArray(&yminop, &ymin, &yminlen));
521
 
    TRY (pl_PyArray_AsFloatArray(&ymaxop, &ymax, &ymaxlen));
522
 
    if (n != yminlen || n != ymaxlen) {
523
 
          PyErr_SetString(PyExc_ValueError, "args 1, 2, and 3 should have the same length");
524
 
        Py_DECREF(xop);
525
 
        Py_DECREF(yminop);
526
 
        Py_DECREF(ymaxop);
527
 
          return NULL;
528
 
    }
529
 
    plerry(n, x, ymin, ymax);
530
 
    Py_DECREF(xop);
531
 
    Py_DECREF(yminop);
532
 
    Py_DECREF(ymaxop);
533
 
    Py_INCREF(Py_None);
534
 
    return Py_None;
535
 
}
536
 
 
537
 
static char doc_plfamadv[]="Advance to the next family file on the next new page";
538
 
 
539
 
static PyObject * pl_famadv(PyObject *self, PyObject *args)
540
 
{
541
 
    TRY (PyArg_ParseTuple(args, ""));
542
 
    plfamadv();
543
 
    Py_INCREF(Py_None);
544
 
    return Py_None;
545
 
}
546
 
 
547
 
static char doc_plfill[]="Pattern fills the polygon bounded by the input points";
548
 
 
549
 
static PyObject * pl_fill(PyObject *self, PyObject *args)
550
 
{
551
 
    PLINT n, ylen;
552
 
    PLFLT *x, *y;
553
 
    PyObject *xop, *yop;
554
 
    TRY (PyArg_ParseTuple(args, "OO", &xop, &yop));
555
 
    TRY (pl_PyArray_AsFloatArray(&xop, &x, &n));
556
 
    TRY (pl_PyArray_AsFloatArray(&yop, &y, &ylen));
557
 
    if (n != ylen) {
558
 
          PyErr_SetString(PyExc_ValueError, "args 1 and 2 should have the same length");
559
 
        Py_DECREF(xop);
560
 
        Py_DECREF(yop);
561
 
          return NULL;
562
 
    }
563
 
    plfill(n, x, y);
564
 
    Py_DECREF(xop);
565
 
    Py_DECREF(yop);
566
 
    Py_INCREF(Py_None);
567
 
    return Py_None;
568
 
}
569
 
 
570
 
static char doc_plflush[]="Flushes the output stream.  Use sparingly, if at all.";
571
 
 
572
 
static PyObject * pl_flush(PyObject *self, PyObject *args)
573
 
{
574
 
    TRY (PyArg_ParseTuple(args, ""));
575
 
    plflush();
576
 
    Py_INCREF(Py_None);
577
 
    return Py_None;
578
 
}
579
 
 
580
 
static char doc_plfont[]="Sets the global font flag to 'ifont'";
581
 
 
582
 
static PyObject * pl_font(PyObject *self, PyObject *args)
583
 
{
584
 
    PLINT ifont;
585
 
    TRY (PyArg_ParseTuple(args, "i", &ifont));
586
 
    plfont(ifont);
587
 
    Py_INCREF(Py_None);
588
 
    return Py_None;
589
 
}
590
 
 
591
 
static char doc_plfontld[]="Load specified font set.";
592
 
 
593
 
static PyObject * pl_fontld(PyObject *self, PyObject *args)
594
 
{
595
 
    PLINT fnt;
596
 
    TRY (PyArg_ParseTuple(args, "i", &fnt));
597
 
    plfontld(fnt);
598
 
    Py_INCREF(Py_None);
599
 
    return Py_None;
600
 
}
601
 
 
602
 
static char doc_plgchr[]="Get character default height and current (scaled) height";
603
 
 
604
 
static PyObject * pl_gchr(PyObject *self, PyObject *args)
605
 
{
606
 
    PLFLT def, ht;
607
 
    TRY (PyArg_ParseTuple(args, ""));
608
 
    plgchr(&def, &ht);
609
 
    return Py_BuildValue(PL_ARGS("(dd)", "(ff)"), def, ht);
610
 
}
611
 
 
612
 
static char doc_plgcol0[]="Returns 8 bit RGB values for given color from color map 0";
613
 
 
614
 
static PyObject * pl_gcol0(PyObject *self, PyObject *args)
615
 
{
616
 
    PLINT icol0, r, b, g;
617
 
    TRY (PyArg_ParseTuple(args, "i", &icol0));
618
 
    plgcol0(icol0, &r, &g, &b);
619
 
    return Py_BuildValue("(iii)", r, g, b);
620
 
}
621
 
 
622
 
static char doc_plgcolbg[]="Returns the background color by 8 bit RGB value";
623
 
 
624
 
static PyObject * pl_gcolbg(PyObject *self, PyObject *args)
625
 
{
626
 
    PLINT r, g, b;
627
 
    TRY (PyArg_ParseTuple(args, ""));
628
 
    plgcolbg(&r, &g, &b);
629
 
    return Py_BuildValue("(iii)", r, g, b);
630
 
}
631
 
 
632
 
static char doc_plgdidev[]="Retrieve current window into device space";
633
 
 
634
 
static PyObject * pl_gdidev(PyObject *self, PyObject *args)
635
 
{
636
 
    PLFLT mar, aspect, jx, jy;
637
 
    TRY (PyArg_ParseTuple(args, ""));
638
 
    plgdidev(&mar, &aspect, &jx, &jy);
639
 
    return Py_BuildValue(PL_ARGS("(dddd)", "(ffff)"), mar, aspect, jx, jy);
640
 
}
641
 
 
642
 
static char doc_plgdiori[]="Get plot orientation";
643
 
 
644
 
static PyObject * pl_gdiori(PyObject *self, PyObject *args)
645
 
{
646
 
    PLFLT rot;
647
 
    TRY (PyArg_ParseTuple(args, ""));
648
 
    plgdiori(&rot);
649
 
    return Py_BuildValue(PL_ARGS("d", "f"), rot);
650
 
}
651
 
 
652
 
static char doc_plgdiplt[]="Retrieve current window into plot space";
653
 
 
654
 
static PyObject * pl_gdiplt(PyObject *self, PyObject *args)
655
 
{
656
 
    PLFLT xmin, ymin, xmax, ymax;
657
 
    TRY (PyArg_ParseTuple(args, ""));
658
 
    plgdiplt(&xmin, &ymin, &xmax, &ymax);
659
 
    return Py_BuildValue(PL_ARGS("(dddd)", "(ffff)"), xmin, ymin, xmax, ymax);
660
 
}
661
 
 
662
 
static char doc_plgfam[]="Get family file parameters";
663
 
 
664
 
static PyObject * pl_gfam(PyObject *self, PyObject *args)
665
 
{
666
 
    PLINT fam, num, bmax;
667
 
    TRY (PyArg_ParseTuple(args, ""));
668
 
    plgfam(&fam, &num, &bmax);
669
 
    return Py_BuildValue("(iii)", fam, num, bmax);
670
 
}
671
 
 
672
 
static char doc_plgfnam[]="Get the (current) output file name.  Must be preallocated to >80 bytes";
673
 
 
674
 
static PyObject * pl_gfnam(PyObject *self, PyObject *args)
675
 
{
676
 
    char fnam[81];
677
 
    TRY (PyArg_ParseTuple(args, ""));
678
 
    plgfnam(fnam);
679
 
    return Py_BuildValue("s", fnam);
680
 
}
681
 
 
682
 
static char doc_plgpage[]="Get output device parameters";
683
 
 
684
 
static PyObject * pl_gpage(PyObject *self, PyObject *args)
685
 
{
686
 
    PLFLT xp, yp;
687
 
    PLINT xleng, yleng, xoff, yoff;
688
 
    TRY (PyArg_ParseTuple(args, ""));
689
 
    plgpage(&xp, &yp, &xleng, &yleng, &xoff, &yoff);
690
 
    return Py_BuildValue(PL_ARGS("(ddiiii)", "(ffiiii)"), xp, yp, xleng, yleng, xoff, yoff);
691
 
}
692
 
 
693
 
static char doc_plgra[]="Switches to graphics screen.";
694
 
 
695
 
static PyObject * pl_gra(PyObject *self, PyObject *args)
696
 
{
697
 
    TRY (PyArg_ParseTuple(args, ""));
698
 
    plgra();
699
 
    Py_INCREF(Py_None);
700
 
    return Py_None;
701
 
}
702
 
 
703
 
static char doc_plgspa[]="Get subpage boundaries in absolute coordinates";
704
 
 
705
 
static PyObject * pl_gspa(PyObject *self, PyObject *args)
706
 
{
707
 
    PLFLT xmin, xmax, ymin, ymax;
708
 
    TRY (PyArg_ParseTuple(args, ""));
709
 
    plgspa(&xmin, &xmax, &ymin, &ymax);
710
 
    return Py_BuildValue(PL_ARGS("(dddd)", "(ffff)"), xmin, xmax, ymin, ymax);
711
 
}
712
 
 
713
 
static char doc_plgstrm[]="Get current stream number.";
714
 
 
715
 
static PyObject * pl_gstrm(PyObject *self, PyObject *args)
716
 
{
717
 
    PLINT strm;
718
 
    TRY (PyArg_ParseTuple(args, ""));
719
 
    plgstrm(&strm);
720
 
    return Py_BuildValue("i", strm);
721
 
}
722
 
 
723
 
static char doc_plgver[]="Get the current library version number";
724
 
 
725
 
static PyObject * pl_gver(PyObject *self, PyObject *args)
726
 
{
727
 
    char p_ver[80];
728
 
    TRY (PyArg_ParseTuple(args, ""));
729
 
    plgver(p_ver);
730
 
    return Py_BuildValue("s", p_ver);
731
 
}
732
 
 
733
 
static char doc_plgvpd[]="Get viewport boundaries in normalized device coordinates";
734
 
 
735
 
static PyObject * pl_gvpd(PyObject *self, PyObject *args)
736
 
{
737
 
    PLFLT xmin, xmax, ymin, ymax;
738
 
    TRY (PyArg_ParseTuple(args, ""));
739
 
    plgvpd(&xmin, &xmax, &ymin, &ymax);
740
 
    return Py_BuildValue(PL_ARGS("(dddd)", "(ffff)"), xmin, xmax, ymin, ymax);
741
 
}
742
 
 
743
 
static char doc_plgvpw[]="Get viewport boundaries in world coordinates";
744
 
 
745
 
static PyObject * pl_gvpw(PyObject *self, PyObject *args)
746
 
{
747
 
    PLFLT xmin, xmax, ymin, ymax;
748
 
    TRY (PyArg_ParseTuple(args, ""));
749
 
    plgvpw(&xmin, &xmax, &ymin, &ymax);
750
 
    return Py_BuildValue(PL_ARGS("(dddd)", "(ffff)"), xmin, xmax, ymin, ymax);
751
 
}
752
 
 
753
 
static char doc_plgxax[]="Get x axis labeling parameters";
754
 
 
755
 
static PyObject * pl_gxax(PyObject *self, PyObject *args)
756
 
{
757
 
    PLINT digmax, digits;
758
 
    TRY (PyArg_ParseTuple(args, ""));
759
 
    plgxax(&digmax, &digits);
760
 
    return Py_BuildValue("(ii)", digmax, digits);
761
 
}
762
 
 
763
 
static char doc_plgyax[]="Get y axis labeling parameters";
764
 
 
765
 
static PyObject * pl_gyax(PyObject *self, PyObject *args)
766
 
{
767
 
    PLINT digmax, digits;
768
 
    TRY (PyArg_ParseTuple(args, ""));
769
 
    plgyax(&digmax, &digits);
770
 
    return Py_BuildValue("(ii)", digmax, digits);
771
 
}
772
 
 
773
 
static char doc_plgzax[]="Get z axis labeling parameters";
774
 
 
775
 
static PyObject * pl_gzax(PyObject *self, PyObject *args)
776
 
{
777
 
    PLINT digmax, digits;
778
 
    TRY (PyArg_ParseTuple(args, ""));
779
 
    plgzax(&digmax, &digits);
780
 
    return Py_BuildValue("(ii)", digmax, digits);
781
 
}
782
 
 
783
 
static char doc_plhist[]="Draws a histogram of n values of a variable in array data[0..n-1]";
784
 
 
785
 
static PyObject * pl_hist(PyObject *self, PyObject *args)
786
 
{
787
 
    PLINT n, nbin, oldwin;
788
 
    PLFLT *data, datmin, datmax;
789
 
    PyObject *op;
790
 
    TRY (PyArg_ParseTuple(args, PL_ARGS("Oddii", "O!ffii"), 
791
 
                                             &op, &datmin, &datmax, &nbin, &oldwin));
792
 
    TRY (pl_PyArray_AsFloatArray(&op, &data, &n));
793
 
    plhist(n, data, datmin, datmax, nbin, oldwin);
794
 
    Py_DECREF(op);
795
 
    Py_INCREF(Py_None);
796
 
    return Py_None;
797
 
}
798
 
 
799
 
static char doc_plhls[]="Set current color (map 0) by hue, lightness, and saturation";
800
 
 
801
 
static PyObject * pl_hls(PyObject *self, PyObject *args)
802
 
{
803
 
    PLFLT h, l, s;
804
 
    TRY (PyArg_ParseTuple(args, PL_ARGS("ddd", "fff"), &h, &l, &s));
805
 
    plhls(h, l, s);
806
 
    Py_INCREF(Py_None);
807
 
    return Py_None;
808
 
}
809
 
 
810
 
static char doc_plinit[]="Initializes PLplot, using preset or default options";
811
 
 
812
 
static PyObject * pl_init(PyObject *self, PyObject *args)
813
 
{
814
 
    TRY (PyArg_ParseTuple(args, ""));
815
 
    plinit();
816
 
    Py_INCREF(Py_None);
817
 
    return Py_None;
818
 
}
819
 
 
820
 
static char doc_pljoin[]="Draws a line segment from (x1, y1) to (x2, y2)";
821
 
 
822
 
static PyObject * pl_join(PyObject *self, PyObject *args)
823
 
{
824
 
    PLFLT x1, y1, x2, y2;
825
 
    TRY (PyArg_ParseTuple(args, PL_ARGS("dddd", "ffff"), &x1, &y1, &x2, &y2));
826
 
    pljoin(x1, y1, x2, y2);
827
 
    Py_INCREF(Py_None);
828
 
    return Py_None;
829
 
}
830
 
 
831
 
static char doc_pllab[]="Simple routine for labelling graphs";
832
 
 
833
 
static PyObject * pl_lab(PyObject *self, PyObject *args)
834
 
{
835
 
    const char *xlabel, *ylabel, *tlabel;
836
 
    TRY (PyArg_ParseTuple(args, "sss", &xlabel, &ylabel, &tlabel));
837
 
    pllab(xlabel, ylabel, tlabel);
838
 
    Py_INCREF(Py_None);
839
 
    return Py_None;
840
 
}
841
 
 
842
 
static char doc_pllightsource[]="Sets the 3D position of the light source for use with plotsh3d";
843
 
 
844
 
static PyObject * pl_lightsource(PyObject *self, PyObject *args)
845
 
{
846
 
    PLFLT x, y, z;
847
 
    TRY (PyArg_ParseTuple(args, PL_ARGS("ddd", "fff"), &x, &y, &z));
848
 
    pllightsource(x, y, z);
849
 
    Py_INCREF(Py_None);
850
 
    return Py_None;
851
 
}
852
 
 
853
 
static char doc_plline[]="Draws line segments connecting a series of points";
854
 
 
855
 
static PyObject * pl_line(PyObject *self, PyObject *args)
856
 
{
857
 
    PLINT n, ylen;
858
 
    PLFLT *x,*y;
859
 
    PyObject *xop, *yop;
860
 
    TRY (PyArg_ParseTuple(args, "OO", &xop, &yop));      
861
 
    TRY (pl_PyArray_AsFloatArray(&xop, &x, &n));
862
 
    TRY (pl_PyArray_AsFloatArray(&yop, &y, &ylen));
863
 
    if (n != ylen) {
864
 
          PyErr_SetString(PyExc_ValueError, "args 1 and 2 should have the same length");
865
 
        Py_DECREF(xop);
866
 
        Py_DECREF(yop);
867
 
          return NULL;
868
 
    }
869
 
    plline(n, x, y);
870
 
    Py_DECREF(xop);
871
 
    Py_DECREF(yop);
872
 
    Py_INCREF(Py_None);
873
 
    return Py_None;
874
 
}
875
 
 
876
 
static char doc_plline3[]="Draws a line in 3 space";
877
 
 
878
 
static PyObject * pl_line3(PyObject *self, PyObject *args)
879
 
{
880
 
    PLINT n, ylen, zlen;
881
 
    PLFLT *x, *y, *z;
882
 
    PyObject *xop, *yop, *zop;
883
 
    TRY (PyArg_ParseTuple(args, "OOO", &xop, &yop, &zop));
884
 
    TRY (pl_PyArray_AsFloatArray(&xop, &x, &n));
885
 
    TRY (pl_PyArray_AsFloatArray(&yop, &y, &ylen));
886
 
    TRY (pl_PyArray_AsFloatArray(&zop, &z, &zlen));
887
 
    if (n != ylen || n != zlen) {
888
 
          PyErr_SetString(PyExc_ValueError, "args 1, 2, and 3 should have the same length");
889
 
        Py_DECREF(xop);
890
 
        Py_DECREF(yop);
891
 
        Py_DECREF(zop);
892
 
          return NULL;
893
 
    }
894
 
    plline3(n, x, y, z);
895
 
    Py_DECREF(xop);
896
 
    Py_DECREF(yop);
897
 
    Py_DECREF(zop);
898
 
    Py_INCREF(Py_None);
899
 
    return Py_None;
900
 
}
901
 
 
902
 
static char doc_pllsty[]="Set line style";
903
 
 
904
 
static PyObject * pl_lsty(PyObject *self, PyObject *args)
905
 
{
906
 
    PLINT lin;
907
 
    TRY (PyArg_ParseTuple(args, "i", &lin));
908
 
    pllsty(lin);
909
 
    Py_INCREF(Py_None);
910
 
    return Py_None;
911
 
}
912
 
 
913
 
/*
914
 
Not done yet...
915
 
 
916
 
static char doc_plmap[]="plot continental outline in world coordinates 
917
 
 
918
 
void plmap(void (*mapform)(PLINT, PLFLT *, PLFLT *), char *type,
919
 
      PLFLT minlong, PLFLT maxlong, PLFLT minlat, PLFLT maxlat);
920
 
*/
921
 
 
922
 
/*
923
 
Not done yet... 
924
 
 
925
 
static char doc_plmeridians[]="Plot the latitudes and longitudes on the background";
926
 
 
927
 
void  plmeridians(void (*mapform)(PLINT, PLFLT *, PLFLT *), 
928
 
            PLFLT dlong, PLFLT dlat,
929
 
            PLFLT minlong, PLFLT maxlong, PLFLT minlat, PLFLT maxlat);
930
 
*/
931
 
 
932
 
static char doc_plmesh[]="Plots a mesh representation of the function z[x][y]";
933
 
 
934
 
static PyObject * pl_mesh(PyObject *self, PyObject *args)
935
 
{
936
 
    PLFLT *x, *y, **z;
937
 
    PLINT nx, ny, opt;
938
 
    PyObject *xop, *yop, *zop;
939
 
    TRY (PyArg_ParseTuple(args, "OOOi", &xop, &yop, &zop, &opt));
940
 
    TRY (pl_PyArray_AsFloatArray(&xop, &x, &nx));
941
 
    TRY (pl_PyArray_AsFloatArray(&yop, &y, &ny));
942
 
    TRY (pl_PyArray_AsFloatMatrix(&zop, &nx, &ny, &z));
943
 
    plmesh(x, y, z, nx, ny, opt);
944
 
    PyMem_DEL(z);
945
 
    Py_DECREF(xop);
946
 
    Py_DECREF(yop);
947
 
    Py_DECREF(zop);
948
 
    Py_INCREF(Py_None);
949
 
    return Py_None;
950
 
}
951
 
 
952
 
static char doc_plmkstrm[]="Creates a new stream and makes it the default";
953
 
 
954
 
static PyObject * pl_mkstrm(PyObject *self, PyObject *args)
955
 
{
956
 
    PLINT strm;
957
 
    TRY (PyArg_ParseTuple(args, ""));
958
 
    plmkstrm(&strm);
959
 
    return Py_BuildValue("i", strm);
960
 
}
961
 
 
962
 
static char doc_plmtex[]="Prints out \"text\" at specified position relative to viewport";
963
 
 
964
 
static PyObject * pl_mtex(PyObject *self, PyObject *args)
965
 
{
966
 
    const char *side, *text;
967
 
    PLFLT disp, pos, just;
968
 
    TRY (PyArg_ParseTuple(args, PL_ARGS("sddds", "sfffs"), 
969
 
                                              &side, &disp, &pos, &just, &text));
970
 
    plmtex(side, disp, pos, just, text);
971
 
    Py_INCREF(Py_None);
972
 
    return Py_None;
973
 
}
974
 
 
975
 
static char doc_plot3d[]="Plots a 3-d representation of the function z[x][y]";
976
 
 
977
 
static PyObject * pl_ot3d(PyObject *self, PyObject *args)
978
 
{
979
 
    PLFLT *x, *y, **z;
980
 
    PLINT nx, ny, opt, side;
981
 
    PyObject *xop, *yop, *zop;
982
 
    TRY (PyArg_ParseTuple(args, "OOOii", &xop, &yop, &zop, &opt, &side));
983
 
    TRY (pl_PyArray_AsFloatArray(&xop, &x, &nx));
984
 
    TRY (pl_PyArray_AsFloatArray(&yop, &y, &ny));
985
 
    TRY (pl_PyArray_AsFloatMatrix(&zop, &nx, &ny, &z));
986
 
    plot3d(x, y, z, nx, ny, opt, side);
987
 
    PyMem_DEL(z);
988
 
    Py_DECREF(xop);
989
 
    Py_DECREF(yop);
990
 
    Py_DECREF(zop);
991
 
    Py_INCREF(Py_None);
992
 
    return Py_None;
993
 
}
994
 
 
995
 
static char doc_plotsh3d[]="Plot shaded 3-d surface plot";
996
 
 
997
 
static PyObject * pl_otsh3d(PyObject *self, PyObject *args)
998
 
{
999
 
    PLFLT *x, *y, **z;
1000
 
    PLINT nx, ny, side;
1001
 
    PyObject *xop, *yop, *zop;
1002
 
    TRY (PyArg_ParseTuple(args, "OOOi", &xop, &yop, &zop, &side));
1003
 
    TRY (pl_PyArray_AsFloatArray(&xop, &x, &nx));
1004
 
    TRY (pl_PyArray_AsFloatArray(&yop, &y, &ny));
1005
 
    TRY (pl_PyArray_AsFloatMatrix(&zop, &nx, &ny, &z));
1006
 
    plotsh3d(x, y, z, nx, ny, side);
1007
 
    PyMem_DEL(z);
1008
 
    Py_DECREF(xop);
1009
 
    Py_DECREF(yop);
1010
 
    Py_DECREF(zop);
1011
 
    Py_INCREF(Py_None);
1012
 
    return Py_None;
1013
 
}
1014
 
 
1015
 
static char doc_plpat[]="Set fill pattern directly";
1016
 
 
1017
 
static PyObject * pl_pat(PyObject *self, PyObject *args)
1018
 
{
1019
 
    PLINT nlin, *inc, *del, dellen;
1020
 
    PyObject *incop, *delop;
1021
 
    TRY (PyArg_ParseTuple(args, "OO", &incop, &delop));
1022
 
    TRY (pl_PyArray_AsIntArray(&incop, &inc, &nlin));
1023
 
    TRY (pl_PyArray_AsIntArray(&delop, &del, &dellen));
1024
 
    if (nlin != dellen) {
1025
 
        PyErr_SetString(PyExc_ValueError, "args 1 and 2 should have the same length");
1026
 
        Py_DECREF(incop);
1027
 
        Py_DECREF(delop);
1028
 
        return NULL;
1029
 
    }
1030
 
    plpat(nlin, inc, del);
1031
 
    Py_DECREF(incop);
1032
 
    Py_DECREF(delop);
1033
 
    Py_INCREF(Py_None);
1034
 
    return Py_None;
1035
 
}
1036
 
 
1037
 
static char doc_plpoin[]="Plots array y against x for n points using ASCII code \"code\"";
1038
 
 
1039
 
static PyObject * pl_poin(PyObject *self, PyObject *args)
1040
 
{
1041
 
    PLINT n, code, ylen;
1042
 
    PLFLT*x, *y;
1043
 
    PyObject *xop, *yop;
1044
 
    TRY (PyArg_ParseTuple(args, "OOi", &xop, &yop, &code));
1045
 
    TRY (pl_PyArray_AsFloatArray(&xop, &x, &n));
1046
 
    TRY (pl_PyArray_AsFloatArray(&yop, &y, &ylen));
1047
 
    if (n != ylen) {
1048
 
          PyErr_SetString(PyExc_ValueError, "args 1 and 2 should have the same length");
1049
 
        Py_DECREF(xop);
1050
 
        Py_DECREF(yop);
1051
 
          return NULL;
1052
 
    }
1053
 
    plpoin(n, x, y, code);
1054
 
    Py_DECREF(xop);
1055
 
    Py_DECREF(yop);
1056
 
    Py_INCREF(Py_None);
1057
 
    return Py_None;
1058
 
}
1059
 
 
1060
 
static char doc_plpoin3[]="Draws a series of points in 3 space";
1061
 
 
1062
 
static PyObject * pl_poin3(PyObject *self, PyObject *args)
1063
 
{
1064
 
    PLINT n, code, ylen, zlen;
1065
 
    PLFLT *x, *y, *z;
1066
 
    PyObject *xop, *yop, *zop;
1067
 
    TRY (PyArg_ParseTuple(args, "OOOi", &xop, &yop, &zop, &code));
1068
 
    TRY (pl_PyArray_AsFloatArray(&xop, &x, &n));
1069
 
    TRY (pl_PyArray_AsFloatArray(&yop, &y, &ylen));
1070
 
    TRY (pl_PyArray_AsFloatArray(&zop, &z, &zlen));
1071
 
    if (n != ylen || n != zlen) {
1072
 
          PyErr_SetString(PyExc_ValueError, "args 1, 2, and 3 should have the same length");
1073
 
        Py_DECREF(xop);
1074
 
        Py_DECREF(yop);
1075
 
        Py_DECREF(zop);
1076
 
          return NULL;
1077
 
    }
1078
 
    plpoin3(n, x, y, z, code);
1079
 
    Py_DECREF(xop);
1080
 
    Py_DECREF(yop);
1081
 
    Py_DECREF(zop);
1082
 
    Py_INCREF(Py_None);
1083
 
    return Py_None;
1084
 
}
1085
 
 
1086
 
static char doc_plpoly3[]="Draws a polygon in 3 space";
1087
 
 
1088
 
static PyObject * pl_poly3(PyObject *self, PyObject *args)
1089
 
{
1090
 
    PLINT n, *draw, ylen, zlen, drawlen, ifcc;
1091
 
    PLFLT *x, *y, *z;
1092
 
    PyObject *xop, *yop, *zop, *drawop;
1093
 
    TRY (PyArg_ParseTuple(args, "OOOOi", &xop, &yop, &zop, &drawop, &ifcc));
1094
 
    TRY (pl_PyArray_AsFloatArray(&xop, &x, &n));
1095
 
    TRY (pl_PyArray_AsFloatArray(&yop, &y, &ylen));
1096
 
    TRY (pl_PyArray_AsFloatArray(&zop, &z, &zlen));
1097
 
    TRY (pl_PyArray_AsIntArray(&drawop, &draw, &drawlen));
1098
 
    if (n != ylen || n != zlen) {
1099
 
          PyErr_SetString(PyExc_ValueError, "args 1, 2, and 3 should have the same length");
1100
 
        Py_DECREF(xop);
1101
 
        Py_DECREF(yop);
1102
 
        Py_DECREF(zop);
1103
 
        Py_DECREF(drawop);
1104
 
          return NULL;
1105
 
    }
1106
 
    if (drawlen != n - 1) {
1107
 
          PyErr_SetString(PyExc_ValueError, 
1108
 
                                    "arg 4 should have a length one less than the other args");
1109
 
        Py_DECREF(xop);
1110
 
        Py_DECREF(yop);
1111
 
        Py_DECREF(zop);
1112
 
        Py_DECREF(drawop);
1113
 
          return NULL;
1114
 
    }
1115
 
    plpoly3(n, x, y, z, draw, ifcc);
1116
 
    Py_DECREF(xop);
1117
 
    Py_DECREF(yop);
1118
 
    Py_DECREF(zop);           
1119
 
    Py_INCREF(Py_None);
1120
 
    return Py_None;
1121
 
}
1122
 
 
1123
 
static char doc_plprec[]="Set the floating point precision (in number of places) in numeric labels";
1124
 
 
1125
 
static PyObject * pl_prec(PyObject *self, PyObject *args)
1126
 
{
1127
 
    PLINT setp, prec;
1128
 
    TRY (PyArg_ParseTuple(args, "ii", &setp, &prec));
1129
 
    plprec(setp, prec);
1130
 
    Py_INCREF(Py_None);
1131
 
    return Py_None;
1132
 
}
1133
 
 
1134
 
static char doc_plpsty[]="Set fill pattern, using one of the predefined patterns";
1135
 
 
1136
 
static PyObject * pl_psty(PyObject *self, PyObject *args)
1137
 
{
1138
 
    PLINT patt;
1139
 
    TRY (PyArg_ParseTuple(args, "i", &patt));
1140
 
    plpsty(patt);
1141
 
    Py_INCREF(Py_None);
1142
 
    return Py_None;
1143
 
}
1144
 
 
1145
 
static char doc_plptex[]="Prints out \"text\" at world cooordinate (x,y)";
1146
 
 
1147
 
static PyObject * pl_ptex(PyObject *self, PyObject *args)
1148
 
{
1149
 
    PLFLT x, y, dx, dy, just;
1150
 
    const char *text;
1151
 
    TRY (PyArg_ParseTuple(args, PL_ARGS("ddddds", "fffffs"), 
1152
 
                                              &x, &y, &dx, &dy, &just, &text));
1153
 
    plptex(x, y, dx, dy, just, text);
1154
 
    Py_INCREF(Py_None);
1155
 
    return Py_None;
1156
 
}
1157
 
 
1158
 
static char doc_plreplot[]="Replays contents of plot buffer to current device/file";
1159
 
 
1160
 
static PyObject * pl_replot(PyObject *self, PyObject *args)
1161
 
{
1162
 
    TRY (PyArg_ParseTuple(args, ""));
1163
 
    plreplot();
1164
 
    Py_INCREF(Py_None);
1165
 
    return Py_None;
1166
 
}
1167
 
 
1168
 
static char doc_plrgb[]="Set line color by red, green, blue from  0.0=0 to 1.0";
1169
 
 
1170
 
static PyObject * pl_rgb(PyObject *self, PyObject *args)
1171
 
{
1172
 
    PLFLT r, g, b;
1173
 
    TRY (PyArg_ParseTuple(args, PL_ARGS("ddd", "fff"), &r, &g, &b));
1174
 
    plrgb(r, g, b);
1175
 
    Py_INCREF(Py_None);
1176
 
    return Py_None;
1177
 
}
1178
 
 
1179
 
static char doc_plrgb1[]="Set line color by 8 bit RGB values";
1180
 
 
1181
 
static PyObject * pl_rgb1(PyObject *self, PyObject *args)
1182
 
{
1183
 
    PLINT r, g, b;
1184
 
    TRY (PyArg_ParseTuple(args, "iii", &r, &g, &b));
1185
 
    plrgb1(r, g, b);
1186
 
    Py_INCREF(Py_None);
1187
 
    return Py_None;
1188
 
}
1189
 
 
1190
 
static char doc_plschr[]="Set character height";
1191
 
 
1192
 
static PyObject * pl_schr(PyObject *self, PyObject *args)
1193
 
{
1194
 
    PLFLT def, scale;
1195
 
    TRY (PyArg_ParseTuple(args, PL_ARGS("dd", "ff"), &def, &scale));
1196
 
    plschr(def, scale);
1197
 
    Py_INCREF(Py_None);
1198
 
    return Py_None;
1199
 
}
1200
 
 
1201
 
static char doc_plscmap0n[]="Set number of colors in cmap 0";
1202
 
 
1203
 
static PyObject * pl_scmap0n(PyObject *self, PyObject *args)
1204
 
{
1205
 
    PLINT ncol0;
1206
 
    TRY (PyArg_ParseTuple(args, "i", &ncol0));
1207
 
    plscmap0n(ncol0);
1208
 
    Py_INCREF(Py_None);
1209
 
    return Py_None;
1210
 
}
1211
 
 
1212
 
static char doc_plscmap1n[]="Set number of colors in cmap 1";
1213
 
 
1214
 
static PyObject * pl_scmap1n(PyObject *self, PyObject *args)
1215
 
{
1216
 
    PLINT ncol1;
1217
 
    TRY (PyArg_ParseTuple(args, "i", &ncol1));
1218
 
    plscmap1n(ncol1);
1219
 
    Py_INCREF(Py_None);
1220
 
    return Py_None;
1221
 
}
1222
 
 
1223
 
static char doc_plscmap0[]="Set color map 0 colors by 8 bit RGB values";
1224
 
 
1225
 
static PyObject * pl_scmap0(PyObject *self, PyObject *args)
1226
 
{
1227
 
    PLINT *r, *g, *b;
1228
 
    PLINT ncol0, glen, blen;
1229
 
    PyObject *rop, *gop, *bop;
1230
 
    TRY (PyArg_ParseTuple(args, "OOO", &rop, &gop, &bop));
1231
 
    TRY (pl_PyArray_AsIntArray(&rop, &r, &ncol0));
1232
 
    TRY (pl_PyArray_AsIntArray(&gop, &g, &glen));
1233
 
    TRY (pl_PyArray_AsIntArray(&bop, &b, &blen));
1234
 
    if (ncol0 != glen || ncol0 != blen) {
1235
 
          PyErr_SetString(PyExc_ValueError, "args 1, 2, and 3 should have the same length");
1236
 
        Py_DECREF(rop);
1237
 
        Py_DECREF(gop);
1238
 
        Py_DECREF(bop);
1239
 
          return NULL;
1240
 
    }
1241
 
    plscmap0(r, g, b, ncol0);
1242
 
    Py_DECREF(rop);
1243
 
    Py_DECREF(gop);
1244
 
    Py_DECREF(bop);
1245
 
    Py_INCREF(Py_None);
1246
 
    return Py_None;
1247
 
}
1248
 
 
1249
 
static char doc_plscmap1[]="Set color map 1 colors by 8 bit RGB values";
1250
 
 
1251
 
static PyObject * pl_scmap1(PyObject *self, PyObject *args)
1252
 
{
1253
 
    PLINT *r, *g, *b;
1254
 
    PLINT ncol1, glen, blen;
1255
 
    PyObject *rop, *gop, *bop;
1256
 
    TRY (PyArg_ParseTuple(args, "OOO", &rop, &gop, &bop));
1257
 
    TRY (pl_PyArray_AsIntArray(&rop, &r, &ncol1));
1258
 
    TRY (pl_PyArray_AsIntArray(&gop, &g, &glen));
1259
 
    TRY (pl_PyArray_AsIntArray(&bop, &b, &blen));
1260
 
    if (ncol1 != glen || ncol1 != blen) {
1261
 
          PyErr_SetString(PyExc_ValueError, "args 1, 2, and 3 should have the same length");
1262
 
        Py_DECREF(rop);
1263
 
        Py_DECREF(gop);
1264
 
        Py_DECREF(bop);
1265
 
          return NULL;
1266
 
    }
1267
 
    plscmap1(r, g, b, ncol1);
1268
 
    Py_DECREF(rop);
1269
 
    Py_DECREF(gop);
1270
 
    Py_DECREF(bop);
1271
 
    Py_INCREF(Py_None);
1272
 
    return Py_None;
1273
 
}
1274
 
 
1275
 
static char doc_plscmap1l[]="Set color map 1 colors using a piece-wise linear relationship between intensity [0,1] (cmap 1 index) and position in HLS or RGB color space.";
1276
 
 
1277
 
static PyObject * pl_scmap1l(PyObject *self, PyObject *args)
1278
 
{
1279
 
    PLINT itype, npts, coord1len, coord2len, coord3len, revlen;
1280
 
    PLFLT *intensity, *coord1, *coord2, *coord3;
1281
 
    PLINT *rev;
1282
 
    PyObject *intensityop, *coord1op, *coord2op, *coord3op, *revop;
1283
 
    TRY (PyArg_ParseTuple(args, "iOOOOO", &itype, &intensityop, 
1284
 
                  &coord1op, &coord2op, &coord3op, &revop));
1285
 
    TRY (pl_PyArray_AsFloatArray(&intensityop, &intensity, &npts));
1286
 
    TRY (pl_PyArray_AsFloatArray(&coord1op, &coord1, &coord1len));
1287
 
    TRY (pl_PyArray_AsFloatArray(&coord2op, &coord2, &coord2len));
1288
 
    TRY (pl_PyArray_AsFloatArray(&coord3op, &coord3, &coord3len));
1289
 
    TRY (pl_PyArray_AsIntArray(&revop, &rev, &revlen));
1290
 
    
1291
 
    if (npts != coord1len || npts != coord2len || npts != coord3len || npts != revlen) {
1292
 
          PyErr_SetString(PyExc_ValueError, "args 2, 3, 4, 5, and 6 should have the same length");
1293
 
        Py_DECREF(intensityop);
1294
 
        Py_DECREF(coord1op);
1295
 
        Py_DECREF(coord2op);
1296
 
        Py_DECREF(coord3op);
1297
 
        Py_DECREF(revop);
1298
 
          return NULL;
1299
 
    }
1300
 
    plscmap1l(itype, npts, intensity, coord1, coord2, coord3, rev);
1301
 
    Py_DECREF(intensityop);
1302
 
    Py_DECREF(coord1op);
1303
 
    Py_DECREF(coord2op);
1304
 
    Py_DECREF(coord3op);
1305
 
    Py_DECREF(revop);
1306
 
    Py_INCREF(Py_None);
1307
 
    return Py_None;
1308
 
}
1309
 
 
1310
 
static char doc_plscol0[]="Set a given color from color map 0 by 8 bit RGB value";
1311
 
 
1312
 
static PyObject * pl_scol0(PyObject *self, PyObject *args)
1313
 
{
1314
 
    PLINT icol0, r, g, b;
1315
 
    TRY (PyArg_ParseTuple(args, "iiii", &icol0, &r, &g, &b));
1316
 
    plscol0(icol0, r, g, b);
1317
 
    Py_INCREF(Py_None);
1318
 
    return Py_None;
1319
 
}
1320
 
 
1321
 
static char doc_plscolbg[]="Set the background color by 8 bit RGB value";
1322
 
 
1323
 
static PyObject * pl_scolbg(PyObject *self, PyObject *args)
1324
 
{
1325
 
    PLINT r, g, b;
1326
 
    TRY (PyArg_ParseTuple(args, "iii", &r, &g, &b));
1327
 
    plscolbg(r, g, b);
1328
 
    Py_INCREF(Py_None);
1329
 
    return Py_None;
1330
 
}
1331
 
 
1332
 
static char doc_plscolor[]="Used to globally turn color output on/off";
1333
 
 
1334
 
static PyObject * pl_scolor(PyObject *self, PyObject *args)
1335
 
{
1336
 
    PLINT color;
1337
 
    TRY (PyArg_ParseTuple(args, "i", &color));
1338
 
    plscolor(color);
1339
 
    Py_INCREF(Py_None);
1340
 
    return Py_None;
1341
 
}
1342
 
 
1343
 
static char doc_plsdev[]="Set the device (keyword) name";
1344
 
 
1345
 
static PyObject * pl_sdev(PyObject *self, PyObject *args)
1346
 
{
1347
 
    const char *devname;
1348
 
    TRY (PyArg_ParseTuple(args, "s", &devname));
1349
 
    plsdev(devname);
1350
 
    Py_INCREF(Py_None);
1351
 
    return Py_None;
1352
 
}
1353
 
 
1354
 
static char doc_plsdidev[]="Set window into device space using margin, aspect ratio, and justification";
1355
 
 
1356
 
static PyObject * pl_sdidev(PyObject *self, PyObject *args)
1357
 
{
1358
 
    PLFLT mar, aspect, jx, jy;
1359
 
    TRY (PyArg_ParseTuple(args, PL_ARGS("dddd", "ffff"), &mar, &aspect, &jx, &jy));
1360
 
    plsdidev(mar, aspect, jx, jy);
1361
 
    Py_INCREF(Py_None);
1362
 
    return Py_None;
1363
 
}
1364
 
 
1365
 
static char doc_plsdimap[]="Set up transformation from metafile coordinates";
1366
 
 
1367
 
static PyObject * pl_sdimap(PyObject *self, PyObject *args)
1368
 
{
1369
 
    PLINT dimxmin, dimxmax, dimymin, dimymax, dimxpmm, dimypmm;
1370
 
    TRY (PyArg_ParseTuple(args, PL_ARGS("iiiidd", "iiiiff"),
1371
 
                                                  &dimxmin, &dimxmax, &dimymin, 
1372
 
                                              &dimymax, &dimxpmm, &dimypmm));
1373
 
    plsdimap(dimxmin, dimxmax, dimymin, dimymax, dimxpmm, dimypmm);
1374
 
    Py_INCREF(Py_None);
1375
 
    return Py_None;
1376
 
}
1377
 
 
1378
 
static char doc_plsdiori[]="Set plot orientation, specifying rotation in units of pi/2";
1379
 
 
1380
 
static PyObject * pl_sdiori(PyObject *self, PyObject *args)
1381
 
{
1382
 
    PLFLT rot;
1383
 
    TRY (PyArg_ParseTuple(args, PL_ARGS("d", "f"), &rot));
1384
 
    plsdiori(rot);
1385
 
    Py_INCREF(Py_None);
1386
 
    return Py_None;
1387
 
}
1388
 
 
1389
 
static char doc_plsdiplt[]="Set window into plot space";
1390
 
 
1391
 
static PyObject * pl_sdiplt(PyObject *self, PyObject *args)
1392
 
{
1393
 
    PLFLT xmin, ymin, xmax, ymax;
1394
 
    TRY (PyArg_ParseTuple(args, PL_ARGS("dddd", "ffff"), 
1395
 
                                              &xmin, &ymin, &xmax, &ymax));
1396
 
    plsdiplt(xmin, ymin, xmax, ymax);
1397
 
    Py_INCREF(Py_None);
1398
 
    return Py_None;
1399
 
}
1400
 
 
1401
 
static char doc_plsdiplz[]="Set window into plot space incrementally (zoom)";
1402
 
 
1403
 
static PyObject * pl_sdiplz(PyObject *self, PyObject *args)
1404
 
{
1405
 
    PLFLT xmin, ymin, xmax, ymax;
1406
 
    TRY (PyArg_ParseTuple(args, PL_ARGS("dddd", "ffff"), 
1407
 
                                              &xmin, &ymin, &xmax, &ymax));
1408
 
    plsdiplz(xmin, ymin, xmax, ymax);
1409
 
    Py_INCREF(Py_None);
1410
 
    return Py_None;
1411
 
}
1412
 
 
1413
 
static char doc_plsesc[]="Set the escape character for text strings";
1414
 
 
1415
 
static PyObject * pl_sesc(PyObject *self, PyObject *args)
1416
 
{
1417
 
    char esc;
1418
 
    TRY (PyArg_ParseTuple(args, "c", &esc));
1419
 
    plsesc(esc);
1420
 
    Py_INCREF(Py_None);
1421
 
    return Py_None;
1422
 
}
1423
 
 
1424
 
static char doc_pl_setcontlabelformat[]="Set contour label format";
1425
 
 
1426
 
static PyObject * pl__setcontlabelformat(PyObject *self, PyObject *args)
1427
 
{
1428
 
    PLINT lexp, sigdig;
1429
 
    TRY (PyArg_ParseTuple(args, "ii", &lexp, &sigdig));
1430
 
    pl_setcontlabelformat(lexp, sigdig);
1431
 
    Py_INCREF(Py_None);
1432
 
    return Py_None;
1433
 
}
1434
 
 
1435
 
static char doc_pl_setcontlabelparam[]="Set contour label parameters";
1436
 
 
1437
 
static PyObject * pl__setcontlabelparam(PyObject *self, PyObject *args)
1438
 
{
1439
 
    PLFLT offset, size, spacing;
1440
 
    PLINT active;
1441
 
    TRY (PyArg_ParseTuple(args, PL_ARGS("dddi", "fffi"),
1442
 
                          &offset, &size, &spacing, &active));
1443
 
    pl_setcontlabelparam(offset, size, spacing, active);
1444
 
    Py_INCREF(Py_None);
1445
 
    return Py_None;
1446
 
}
1447
 
 
1448
 
static char doc_plsfam[]="Set family file parameters";
1449
 
 
1450
 
static PyObject * pl_sfam(PyObject *self, PyObject *args)
1451
 
{
1452
 
    PLINT fam, num, bmax;
1453
 
    TRY (PyArg_ParseTuple(args, "iii", &fam, &num, &bmax));
1454
 
    plsfam(fam, num, bmax);
1455
 
    Py_INCREF(Py_None);
1456
 
    return Py_None;
1457
 
}
1458
 
 
1459
 
static char doc_plsfnam[]="Set the output file name";
1460
 
 
1461
 
static PyObject * pl_sfnam(PyObject *self, PyObject *args)
1462
 
{
1463
 
    const char *fnam;
1464
 
    TRY (PyArg_ParseTuple(args, "s", &fnam));
1465
 
    plsfnam(fnam);
1466
 
    Py_INCREF(Py_None);
1467
 
    return Py_None;
1468
 
}
1469
 
 
1470
 
#define PyAssert(c,m) if (!(c)) { PyErr_SetString( PyExc_RuntimeError, m ); \
1471
 
                                  return NULL; }
1472
 
 
1473
 
static char doc_plcont[] = "Draws a contour plot from data in z(x,y)";
1474
 
 
1475
 
/*
1476
 
  Allowable syntaxes:
1477
 
 
1478
 
  plcont( z, kx, lx, ky, ly, clev, pltr, xg, yg, wrap )
1479
 
  plcont( z, clev, pltr, xg, yg, wrap )
1480
 
 
1481
 
  where in both cases, parameters from pltr to the end are optional.
1482
 
 
1483
 
  First case, arg count = 6 +3? +1?
1484
 
  Second case, arg count = 2 +3? +1?
1485
 
 
1486
 
  The only way I see to disambiguate this is to either be able to
1487
 
  nondestructively hand parse the arg list, or to mandate fewer valid forms.
1488
 
  Since I cannot find info on how to do a nondestructive trial parse, we opt
1489
 
  for the second.  Thus, by fiat, I declare the following forms to be
1490
 
  admissible:
1491
 
 
1492
 
  plcont( z, kx, lx, ky, ly, clev, [pltr, xg, yg, wrap] )
1493
 
  plcont( z, clev, pltr, xg, yg, wrap )
1494
 
 */
1495
 
 
1496
 
/*static*/ PyObject *pl_cont( PyObject *self, PyObject *args )
1497
 
{
1498
 
    PyObject *zop, *xop, *yop;
1499
 
    PLFLT **z, **zwrapped, **zused, *clev;      
1500
 
    PLINT nx, ny, nlev;
1501
 
    char *pltrname = NULL;
1502
 
    void (*pltr) (PLFLT, PLFLT, PLFLT *, PLFLT *, PLPointer);
1503
 
    PLPointer pltr_data = NULL;
1504
 
    PLcGrid  cgrid1;
1505
 
    PLcGrid2 cgrid2;
1506
 
    PLINT wrap = 0;
1507
 
    int i=0, j;
1508
 
 
1509
 
    PLINT kx=0, lx=0, ky=0, ly=0;
1510
 
    int ifdefault=0;
1511
 
    int argc = PyTuple_Size( args );
1512
 
    PyObject *o;
1513
 
 
1514
 
    PyAssert( i < argc, "Invalid arg list for plcont" );
1515
 
    zop = PyTuple_GetItem( args, 0 ); i++;
1516
 
    TRY( pl_PyArray_AsFloatMatrix( &zop, &nx, &ny, &z ) );
1517
 
 
1518
 
    PyAssert( i < argc, "Invalid arg list for plcont" );
1519
 
 
1520
 
    o = PyTuple_GetItem( args, i );
1521
 
 
1522
 
/*   printf("printf debug, %d, %d\n", (o)->ob_type, &PyArray_Type);*/
1523
 
    if ( o && PyArray_Check(o) ) {
1524
 
    /* They skipped all the way to clev */
1525
 
        ifdefault = 1;
1526
 
    }
1527
 
    else {
1528
 
        PyAssert( i+3 < argc, "Invalid arg list for plcont" );
1529
 
/*      TRY( PyArg_GetLong( args, argc, i++, &kx ) ); */
1530
 
        kx = PyInt_AsLong( PyTuple_GetItem( args, i++ ) );
1531
 
/*      TRY( PyArg_GetLong( args, argc, i++, &lx ) ); */
1532
 
        lx = PyInt_AsLong( PyTuple_GetItem( args, i++ ) );
1533
 
/*      TRY( PyArg_GetLong( args, argc, i++, &ky ) ); */
1534
 
        ky = PyInt_AsLong( PyTuple_GetItem( args, i++ ) );
1535
 
/*      TRY( PyArg_GetLong( args, argc, i++, &ly ) ); */
1536
 
        ly = PyInt_AsLong( PyTuple_GetItem( args, i++ ) );
1537
 
        o = PyTuple_GetItem( args, i );
1538
 
    }
1539
 
 
1540
 
/*    printf( "plcont, kx=%d lx=%d ky=%d ly=%d\n", kx, lx, ky, ly );*/
1541
 
 
1542
 
/* Must now be positioned on clev, so pull it out and convert. */
1543
 
 
1544
 
    TRY( pl_PyArray_AsFloatArray( &o, &clev, &nlev ) );
1545
 
 
1546
 
/*    printf( "nlev=%d\n", nlev );*/
1547
 
 
1548
 
    i++;
1549
 
 
1550
 
/* Now parse the pltr stuff. */
1551
 
 
1552
 
/*    printf( "i=%d argc=%d\n", i, argc );*/
1553
 
    if ( i < argc ) {
1554
 
/*      pltrname = PyArg_GetString( PyTuple_GetItem( args, i++ ) ); */
1555
 
/*      TRY( PyArg_GetString( args, argc, i++, &pltrname ) ); */
1556
 
        pltrname = PyString_AsString( PyTuple_GetItem( args, i++ ) );
1557
 
/*      printf( "pltr=%s\n", pltrname );*/
1558
 
        if ( i < argc-1 ) {
1559
 
        /* Then there must be at least two args left, which means the xg, yg
1560
 
           stuff has been specified. */
1561
 
 
1562
 
            xop = PyTuple_GetItem( args, i++ );
1563
 
            yop = PyTuple_GetItem( args, i++ );
1564
 
        }
1565
 
 
1566
 
        if (i == argc-1) {
1567
 
/*          TRY( PyArg_GetLong( args, argc, i, &wrap ) ); */
1568
 
            wrap = PyInt_AsLong( PyTuple_GetItem( args, i ) ) ;
1569
 
        }
1570
 
    }
1571
 
 
1572
 
/*    printf( "wrap=%d\n", wrap ); */
1573
 
 
1574
 
/* Figure out which coordinate transformation model is being used, and setup
1575
 
   accordingly. */
1576
 
 
1577
 
    if (!pltrname || !strcmp( pltrname, "pltr0")) {
1578
 
        pltr = pltr0;
1579
 
        zused = z;
1580
 
 
1581
 
        if (wrap) {
1582
 
            PyErr_SetString( PyExc_RuntimeError,
1583
 
                             "Must not specify wrapping with pltr0." );
1584
 
            return NULL;
1585
 
        }
1586
 
    }
1587
 
    else if ( !strcmp( pltrname, "pltr1" ) ) {
1588
 
        pltr = pltr1;
1589
 
        pltr_data = &cgrid1;
1590
 
        zused = z;
1591
 
 
1592
 
    /* Check wrap. */
1593
 
        if (wrap) {
1594
 
            PyErr_SetString( PyExc_RuntimeError,
1595
 
                             "Must not specify wrapping with pltr1." );
1596
 
            return NULL;
1597
 
        }
1598
 
 
1599
 
    /* Check dimensionality of xg1 and xg2 */
1600
 
        TRY( pl_PyArray_AsFloatArray( &xop, &cgrid1.xg, &cgrid1.nx ) );
1601
 
        TRY( pl_PyArray_AsFloatArray( &yop, &cgrid1.yg, &cgrid1.ny ) );
1602
 
        if ( (cgrid1.nx != nx) || (cgrid1.ny != ny) ) {
1603
 
            PyErr_SetString( PyExc_RuntimeError,
1604
 
                             "Incompatible coord specifiers." );
1605
 
            return NULL;
1606
 
        }
1607
 
    }
1608
 
    else if ( !strcmp( pltrname, "pltr2" ) ) {
1609
 
    /* printf( "plcont, setting up for pltr2\n" ); */
1610
 
        if (!wrap) {
1611
 
        /* printf( "plcont, no wrapping is needed.\n" ); */
1612
 
            PLINT xnx, xny, ynx, yny;
1613
 
            PLFLT **xg, **yg;
1614
 
            TRY( pl_PyArray_AsFloatMatrix( &xop, &xnx, &xny, &xg ) );
1615
 
            TRY( pl_PyArray_AsFloatMatrix( &yop, &ynx, &yny, &yg ) );
1616
 
 
1617
 
            if ( (xnx != nx) || (ynx != nx) || (xny != ny) || (yny != ny) ) {
1618
 
                PyErr_SetString( PyExc_RuntimeError,
1619
 
                                 "Bogus transformation arrays." );
1620
 
                return NULL;
1621
 
            }
1622
 
 
1623
 
            plAlloc2dGrid( &cgrid2.xg, nx, ny );
1624
 
            plAlloc2dGrid( &cgrid2.yg, nx, ny );
1625
 
            cgrid2.nx = nx;
1626
 
            cgrid2.ny = ny;
1627
 
            zused = z;
1628
 
 
1629
 
            for( i=0; i < nx; i++ )
1630
 
                for( j=0; j < ny; j++ ) {
1631
 
                    cgrid2.xg[i][j] = xg[i][j];
1632
 
                    cgrid2.yg[i][j] = yg[i][j];
1633
 
                }
1634
 
        }
1635
 
        else if (wrap == 1) {
1636
 
            PLINT xnx, xny, ynx, yny;
1637
 
            PLFLT **xg, **yg;
1638
 
            TRY( pl_PyArray_AsFloatMatrix( &xop, &xnx, &xny, &xg ) );
1639
 
            TRY( pl_PyArray_AsFloatMatrix( &yop, &ynx, &yny, &yg ) );
1640
 
 
1641
 
            if ( (xnx != nx) || (ynx != nx) || (xny != ny) || (yny != ny) ) {
1642
 
                PyErr_SetString( PyExc_RuntimeError,
1643
 
                                 "Bogus transformation arrays." );
1644
 
                return NULL;
1645
 
            }
1646
 
 
1647
 
            plAlloc2dGrid( &cgrid2.xg, nx+1, ny );
1648
 
            plAlloc2dGrid( &cgrid2.yg, nx+1, ny );
1649
 
            plAlloc2dGrid( &zwrapped, nx+1, ny );
1650
 
            cgrid2.nx = nx+1;
1651
 
            cgrid2.ny = ny;
1652
 
            zused = zwrapped;
1653
 
 
1654
 
            for( i=0; i < nx; i++ )
1655
 
                for( j=0; j < ny; j++ ) {
1656
 
                    cgrid2.xg[i][j] = xg[i][j];
1657
 
                    cgrid2.yg[i][j] = yg[i][j];
1658
 
                    zwrapped[i][j] = z[i][j];
1659
 
                }
1660
 
 
1661
 
            for( j=0; j < ny; j++ ) {
1662
 
                cgrid2.xg[nx][j] = cgrid2.xg[0][j];
1663
 
                cgrid2.yg[nx][j] = cgrid2.yg[0][j];
1664
 
                zwrapped[nx][j] = zwrapped[0][j];
1665
 
            }
1666
 
 
1667
 
            nx++;
1668
 
        }
1669
 
        else if (wrap == 2) {
1670
 
            PLINT xnx, xny, ynx, yny;
1671
 
            PLFLT **xg, **yg;
1672
 
            TRY( pl_PyArray_AsFloatMatrix( &xop, &xnx, &xny, &xg ) );
1673
 
            TRY( pl_PyArray_AsFloatMatrix( &yop, &ynx, &yny, &yg ) );
1674
 
 
1675
 
            if ( (xnx != nx) || (ynx != nx) || (xny != ny) || (yny != ny) ) {
1676
 
                PyErr_SetString( PyExc_RuntimeError,
1677
 
                                 "Bogus transformation arrays." );
1678
 
                return NULL;
1679
 
            }
1680
 
 
1681
 
            plAlloc2dGrid( &cgrid2.xg, nx, ny+1 );
1682
 
            plAlloc2dGrid( &cgrid2.yg, nx, ny+1 );
1683
 
            plAlloc2dGrid( &zwrapped, nx, ny+1 );
1684
 
            cgrid2.nx = nx;
1685
 
            cgrid2.ny = ny+1;
1686
 
            zused = zwrapped;
1687
 
 
1688
 
            for( i=0; i < nx; i++ )
1689
 
                for( j=0; j < ny; j++ ) {
1690
 
                    cgrid2.xg[i][j] = xg[i][j];
1691
 
                    cgrid2.yg[i][j] = yg[i][j];
1692
 
                    zwrapped[i][j] = z[i][j];
1693
 
                }
1694
 
 
1695
 
            for( i=0; i < nx; i++ ) {
1696
 
                cgrid2.xg[i][ny] = cgrid2.xg[i][0];
1697
 
                cgrid2.yg[i][ny] = cgrid2.yg[i][0];
1698
 
                zwrapped[i][ny] = zwrapped[i][0];
1699
 
            }
1700
 
 
1701
 
            ny++;
1702
 
        }
1703
 
        else {
1704
 
            PyErr_SetString( PyExc_RuntimeError,
1705
 
                             "Invalid wrap specifier, must be 0, 1 or 2." );
1706
 
            return NULL;
1707
 
        }
1708
 
 
1709
 
        pltr = pltr2;
1710
 
        pltr_data = &cgrid2;
1711
 
    }
1712
 
    else {
1713
 
        PyErr_SetString( PyExc_RuntimeError,
1714
 
                         "Unrecognized coordinate transformation spec.  Must be pltr0, pltr1 or pltr2." );
1715
 
        return NULL;
1716
 
    }
1717
 
 
1718
 
    if (ifdefault) {
1719
 
        kx = 1; lx = nx;
1720
 
        ky = 1; ly = ny;
1721
 
    }
1722
 
/* Now go make the plot. */
1723
 
 
1724
 
    plcont( zused, nx, ny, kx, lx, ky, ly, clev, nlev, pltr, pltr_data );
1725
 
 
1726
 
/*
1727
 
    TRY (PyArg_ParseTuple(args, "OiiiiOO!", &op, &kx, &lx, &ky, &ly, &levelop, 
1728
 
                                                                                        &PyFunction_Type, &f));
1729
 
    TRY (pl_PyArray_AsFloatMatrix(&op, &nx, &ny, &z));
1730
 
    TRY (pl_PyArray_AsFloatArray(&levelop, &clevel, &nlevel));
1731
 
    plcont(z, nx, ny, kx, lx, ky, ly, clevel, nlevel, pypltr, f);
1732
 
    Py_DECREF(op);
1733
 
    Py_DECREF(levelop);
1734
 
    PyMem_DEL(z);
1735
 
    if (PyErr_Occurred()) {
1736
 
        PyErr_SetString(PyExc_RuntimeError, "Check your plotter function!");
1737
 
        return NULL;
1738
 
    }
1739
 
    */
1740
 
/* Now free up any space which got allocated for our coordinate trickery. */
1741
 
 
1742
 
    if (pltr == pltr1) {
1743
 
    /* Hmm, actually, nothing to do here currently, since we just used the
1744
 
        Python Matrix data directly, rather than allocating private space. */
1745
 
    }
1746
 
    else if (pltr == pltr2) {
1747
 
    /* printf( "plcont, freeing space for grids used in pltr2\n" ); */
1748
 
        plFree2dGrid( cgrid2.xg, nx, ny );
1749
 
        plFree2dGrid( cgrid2.yg, nx, ny );
1750
 
        if (wrap != 0)
1751
 
         plFree2dGrid( zwrapped, nx, ny );
1752
 
    }
1753
 
 
1754
 
    plflush();
1755
 
    Py_INCREF(Py_None);
1756
 
    return Py_None;
1757
 
}
1758
 
 
1759
 
/* AWI: plshades wrapper is modified version of Geoffrey's plshade wrapper.*/
1760
 
/*--------------------------------------------------------------------------*\
1761
 
 * plshadesCmd
1762
 
 *
1763
 
 * Processes plshades command.
1764
 
 * C version takes:
1765
 
 *    data, nx, ny, defined,
1766
 
 *    xmin, xmax, ymin, ymax,
1767
 
 *    clevel, nlevel, fill_width, cont_color, cont_width,
1768
 
 *    plfill, rect, pltr, pltr_data
1769
 
 *
1770
 
 * We will be getting data through a 2-d Matrix, which carries along
1771
 
 * nx and ny, so no need for those.  Toss defined since it's not supported
1772
 
 * anyway.  Toss nlevel since clevel carries it along.
1773
 
 * Toss plfill since it is the only valid choice.  Take an optional 
1774
 
 * pltr spec just as for plcont, and add a wrapping specifier, also just as
1775
 
 * in plcont.  So the new command looks like:
1776
 
 * 
1777
 
 * plshades(z, xmin, xmax, ymin, ymax,
1778
 
 * clevel, fill_width, cont_color, cont_width,
1779
 
 * rect, [pltr, x, y,] [wrap])
1780
 
\*--------------------------------------------------------------------------*/
1781
 
 
1782
 
static char doc_plshades[] = "Color fill plot";
1783
 
 
1784
 
static PyObject *pl_shades( PyObject *self, PyObject *args )
1785
 
{
1786
 
    PyObject *zop, *clevelop, *xop=NULL, *yop=NULL;
1787
 
    PLFLT **z, **zwrapped, **zused, *clevel;
1788
 
    PLINT nx, ny, nlevel;
1789
 
    char *pltrname = NULL;
1790
 
    void (*pltr) (PLFLT, PLFLT, PLFLT *, PLFLT *, PLPointer);
1791
 
    PLPointer pltr_data = NULL;
1792
 
    PLcGrid  cgrid1;
1793
 
    PLcGrid2 cgrid2;
1794
 
    PLINT wrap = 0;
1795
 
    int i, j;
1796
 
   
1797
 
    PLFLT xmin, xmax, ymin, ymax;
1798
 
    PLINT fill_width = 0, cont_color = 0, cont_width =0;
1799
 
    PLINT rect =1;
1800
 
 
1801
 
    TRY( PyArg_ParseTuple( args, PL_ARGS( "OddddOiiii|sOOi",
1802
 
                                          "OffffOiiii|sOOi" ),
1803
 
                           &zop, &xmin, &xmax, &ymin, &ymax, 
1804
 
                           &clevelop, &fill_width, &cont_color, &cont_width,
1805
 
                           &rect, &pltrname, &xop, &yop, &wrap ) );
1806
 
 
1807
 
    TRY( pl_PyArray_AsFloatMatrix( &zop, &nx, &ny, &z ) );
1808
 
    TRY( pl_PyArray_AsFloatArray( &clevelop, &clevel, &nlevel ) );
1809
 
 
1810
 
/* Figure out which coordinate transformation model is being used, and setup
1811
 
   accordingly. */
1812
 
 
1813
 
    if (!pltrname || !strcmp( pltrname, "pltr0")) {
1814
 
        pltr = pltr0;
1815
 
        zused = z;
1816
 
 
1817
 
        if (wrap) {
1818
 
            PyErr_SetString( PyExc_RuntimeError,
1819
 
                             "Must not specify wrapping with pltr0." );
1820
 
            return NULL;
1821
 
        }
1822
 
    }
1823
 
    else if (!strcmp( pltrname, "pltr1" ) ) {
1824
 
        pltr = pltr1;
1825
 
        zused = z;
1826
 
        pltr_data = &cgrid1;
1827
 
 
1828
 
    /* Check wrap. */
1829
 
        if (wrap) {
1830
 
            PyErr_SetString( PyExc_RuntimeError,
1831
 
                             "Must not specify wrapping with pltr1." );
1832
 
            return NULL;
1833
 
        }
1834
 
 
1835
 
    /* Check dimensionality of xg1 and xg2 */
1836
 
        TRY( pl_PyArray_AsFloatArray( &xop, &cgrid1.xg, &cgrid1.nx ) );
1837
 
        TRY( pl_PyArray_AsFloatArray( &yop, &cgrid1.yg, &cgrid1.ny ) );
1838
 
        if ( (cgrid1.nx != nx) || (cgrid1.ny != ny) ) {
1839
 
            PyErr_SetString( PyExc_RuntimeError,
1840
 
                             "Incompatible coord specifiers." );
1841
 
            return NULL;
1842
 
        }
1843
 
    }
1844
 
    else if ( !strcmp( pltrname, "pltr2" ) ) {
1845
 
    /* printf( "plshades, setting up for pltr2\n" ); */
1846
 
        if (!wrap) {
1847
 
        /* printf( "plshades, no wrapping is needed.\n" ); */
1848
 
            PLINT xnx, xny, ynx, yny;
1849
 
            PLFLT **xg, **yg;
1850
 
            TRY( pl_PyArray_AsFloatMatrix( &xop, &xnx, &xny, &xg ) );
1851
 
            TRY( pl_PyArray_AsFloatMatrix( &yop, &ynx, &yny, &yg ) );
1852
 
 
1853
 
            if ( (xnx != nx) || (ynx != nx) || (xny != ny) || (yny != ny) ) {
1854
 
                PyErr_SetString( PyExc_RuntimeError,
1855
 
                                 "Bogus transformation arrays." );
1856
 
                return NULL;
1857
 
            }
1858
 
 
1859
 
            plAlloc2dGrid( &cgrid2.xg, nx, ny );
1860
 
            plAlloc2dGrid( &cgrid2.yg, nx, ny );
1861
 
            cgrid2.nx = nx;
1862
 
            cgrid2.ny = ny;
1863
 
            zused = z;
1864
 
 
1865
 
            for( i=0; i < nx; i++ )
1866
 
                for( j=0; j < ny; j++ ) {
1867
 
                    cgrid2.xg[i][j] = xg[i][j];
1868
 
                    cgrid2.yg[i][j] = yg[i][j];
1869
 
                }
1870
 
        }
1871
 
        else if (wrap == 1) {
1872
 
            PLINT xnx, xny, ynx, yny;
1873
 
            PLFLT **xg, **yg;
1874
 
            TRY( pl_PyArray_AsFloatMatrix( &xop, &xnx, &xny, &xg ) );
1875
 
            TRY( pl_PyArray_AsFloatMatrix( &yop, &ynx, &yny, &yg ) );
1876
 
 
1877
 
            if ( (xnx != nx) || (ynx != nx) || (xny != ny) || (yny != ny) ) {
1878
 
                PyErr_SetString( PyExc_RuntimeError,
1879
 
                                 "Bogus transformation arrays." );
1880
 
                return NULL;
1881
 
            }
1882
 
 
1883
 
            plAlloc2dGrid( &cgrid2.xg, nx+1, ny );
1884
 
            plAlloc2dGrid( &cgrid2.yg, nx+1, ny );
1885
 
            plAlloc2dGrid( &zwrapped, nx+1, ny );
1886
 
            cgrid2.nx = nx+1;
1887
 
            cgrid2.ny = ny;
1888
 
            zused = zwrapped;
1889
 
 
1890
 
            for( i=0; i < nx; i++ )
1891
 
                for( j=0; j < ny; j++ ) {
1892
 
                    cgrid2.xg[i][j] = xg[i][j];
1893
 
                    cgrid2.yg[i][j] = yg[i][j];
1894
 
                    zwrapped[i][j] = z[i][j];
1895
 
                }
1896
 
 
1897
 
            for( j=0; j < ny; j++ ) {
1898
 
                cgrid2.xg[nx][j] = cgrid2.xg[0][j];
1899
 
                cgrid2.yg[nx][j] = cgrid2.yg[0][j];
1900
 
                zwrapped[nx][j] = zwrapped[0][j];
1901
 
            }
1902
 
 
1903
 
            nx++;
1904
 
        }
1905
 
        else if (wrap == 2) {
1906
 
            PLINT xnx, xny, ynx, yny;
1907
 
            PLFLT **xg, **yg;
1908
 
            TRY( pl_PyArray_AsFloatMatrix( &xop, &xnx, &xny, &xg ) );
1909
 
            TRY( pl_PyArray_AsFloatMatrix( &yop, &ynx, &yny, &yg ) );
1910
 
 
1911
 
            if ( (xnx != nx) || (ynx != nx) || (xny != ny) || (yny != ny) ) {
1912
 
                PyErr_SetString( PyExc_RuntimeError,
1913
 
                                 "Bogus transformation arrays." );
1914
 
                return NULL;
1915
 
            }
1916
 
 
1917
 
            plAlloc2dGrid( &cgrid2.xg, nx, ny+1 );
1918
 
            plAlloc2dGrid( &cgrid2.yg, nx, ny+1 );
1919
 
            plAlloc2dGrid( &zwrapped, nx, ny+1 );
1920
 
            cgrid2.nx = nx;
1921
 
            cgrid2.ny = ny+1;
1922
 
            zused = zwrapped;
1923
 
 
1924
 
            for( i=0; i < nx; i++ )
1925
 
                for( j=0; j < ny; j++ ) {
1926
 
                    cgrid2.xg[i][j] = xg[i][j];
1927
 
                    cgrid2.yg[i][j] = yg[i][j];
1928
 
                    zwrapped[i][j] = z[i][j];
1929
 
                }
1930
 
 
1931
 
            for( i=0; i < nx; i++ ) {
1932
 
                cgrid2.xg[i][ny] = cgrid2.xg[i][0];
1933
 
                cgrid2.yg[i][ny] = cgrid2.yg[i][0];
1934
 
                zwrapped[i][ny] = zwrapped[i][0];
1935
 
            }
1936
 
 
1937
 
            ny++;
1938
 
        }
1939
 
        else {
1940
 
            PyErr_SetString( PyExc_RuntimeError,
1941
 
                             "Invalid wrap specifier, must be 0, 1 or 2." );
1942
 
            return NULL;
1943
 
        }
1944
 
 
1945
 
        pltr = pltr2;
1946
 
        pltr_data = &cgrid2;
1947
 
    }
1948
 
    else {
1949
 
        PyErr_SetString( PyExc_RuntimeError,
1950
 
                         "Unrecognized coordinate transformation spec.  Must be pltr0, pltr1 or pltr2." );
1951
 
        return NULL;
1952
 
    }
1953
 
 
1954
 
/* Now go make the plot. */
1955
 
 
1956
 
    plshades( zused, nx, ny, NULL, xmin, xmax, ymin, ymax,
1957
 
              clevel, nlevel, fill_width, cont_color, cont_width,
1958
 
              plfill, rect, pltr, pltr_data );
1959
 
 
1960
 
/* Now free up any space which got allocated for our coordinate trickery. */
1961
 
 
1962
 
    if (pltr == pltr1) {
1963
 
    /* Hmm, actually, nothing to do here currently, since we just used the
1964
 
        Python Matrix data directly, rather than allocating private space. */
1965
 
    }
1966
 
    else if (pltr == pltr2) {
1967
 
    /* printf( "plshades, freeing space for grids used in pltr2\n" ); */
1968
 
        plFree2dGrid( cgrid2.xg, nx, ny );
1969
 
        plFree2dGrid( cgrid2.yg, nx, ny );
1970
 
        if (wrap != 0)
1971
 
         plFree2dGrid( zwrapped, nx, ny );
1972
 
    }
1973
 
 
1974
 
    plflush();
1975
 
    Py_INCREF( Py_None );
1976
 
    return Py_None;
1977
 
}
1978
 
 
1979
 
/* GMF 8/12/96, this implementation cobbled together from tclAPI.c 
1980
 
 * with wrap code subsequently fixed by AWI. */
1981
 
/*--------------------------------------------------------------------------*\
1982
 
 * plshadeCmd
1983
 
 *
1984
 
 * Processes plshade Tcl command.
1985
 
 * C version takes:
1986
 
 *    data, nx, ny, defined,
1987
 
 *    xmin, xmax, ymin, ymax,
1988
 
 *    sh_min, sh_max, sh_cmap, sh_color, sh_width,
1989
 
 *    min_col, min_wid, max_col, max_wid,
1990
 
 *    plfill, rect, pltr, pltr_data
1991
 
 *
1992
 
 * We will be getting data through a 2-d Matrix, which carries along
1993
 
 * nx and ny, so no need for those.  Toss defined since it's not supported
1994
 
 * anyway.  Toss plfill since it is the only valid choice.  Take an optional 
1995
 
 * pltr spec just as for plcont, and add a wrapping specifier, also just as
1996
 
 * in plcont.  So the new command looks like:
1997
 
 * 
1998
 
 *      plshade z xmin xmax ymin ymax \
1999
 
 *          sh_min sh_max sh_cmap sh_color sh_width \
2000
 
 *          min_col min_wid max_col max_wid \
2001
 
 *          rect [pltr x y] [wrap]
2002
 
\*--------------------------------------------------------------------------*/
2003
 
 
2004
 
static char doc_plshade[] = "Color fill plot";
2005
 
 
2006
 
static PyObject *pl_shade( PyObject *self, PyObject *args )
2007
 
{
2008
 
    PyObject *zop, *xop=NULL, *yop=NULL;
2009
 
    PLfGrid2 grid;
2010
 
    PLFLT **z, **zwrapped, **zused;
2011
 
    PLINT nx, ny;
2012
 
    char *pltrname = NULL;
2013
 
    void (*pltr) (PLFLT, PLFLT, PLFLT *, PLFLT *, PLPointer);
2014
 
    PLPointer pltr_data = NULL;
2015
 
    PLcGrid  cgrid1;
2016
 
    PLcGrid2 cgrid2;
2017
 
    PLINT wrap = 0;
2018
 
    int i, j;
2019
 
   
2020
 
    PLFLT xmin, xmax, ymin, ymax, sh_min, sh_max, sh_col;
2021
 
    PLINT sh_cmap =1, sh_wid =2;
2022
 
    PLINT min_col =1, min_wid =0, max_col =0, max_wid =0;
2023
 
    PLINT rect =1;
2024
 
 
2025
 
    TRY( PyArg_ParseTuple( args, PL_ARGS( "Oddddddidiiiiii|sOOi",
2026
 
                                          "Offffffifiiiiii|sOOi" ),
2027
 
                           &zop, &xmin, &xmax, &ymin, &ymax, &sh_min,
2028
 
                           &sh_max, &sh_cmap, &sh_col, &sh_wid,
2029
 
                           &min_col, &min_wid, &max_col, &max_wid, &rect,
2030
 
                           &pltrname, &xop, &yop, &wrap ) );
2031
 
 
2032
 
    TRY( pl_PyArray_AsFloatMatrix( &zop, &nx, &ny, &z ) );
2033
 
 
2034
 
/* Figure out which coordinate transformation model is being used, and setup
2035
 
   accordingly. */
2036
 
 
2037
 
    if (!pltrname || !strcmp( pltrname, "pltr0")) {
2038
 
        pltr = pltr0;
2039
 
        zused = z;
2040
 
 
2041
 
        if (wrap) {
2042
 
            PyErr_SetString( PyExc_RuntimeError,
2043
 
                             "Must not specify wrapping with pltr0." );
2044
 
            return NULL;
2045
 
        }
2046
 
    }
2047
 
    else if (!strcmp( pltrname, "pltr1" ) ) {
2048
 
        pltr = pltr1;
2049
 
        pltr_data = &cgrid1;
2050
 
        zused = z;
2051
 
 
2052
 
    /* Check wrap. */
2053
 
        if (wrap) {
2054
 
            PyErr_SetString( PyExc_RuntimeError,
2055
 
                             "Must not specify wrapping with pltr1." );
2056
 
            return NULL;
2057
 
        }
2058
 
 
2059
 
    /* Check dimensionality of xg1 and xg2 */
2060
 
        TRY( pl_PyArray_AsFloatArray( &xop, &cgrid1.xg, &cgrid1.nx ) );
2061
 
        TRY( pl_PyArray_AsFloatArray( &yop, &cgrid1.yg, &cgrid1.ny ) );
2062
 
        if ( (cgrid1.nx != nx) || (cgrid1.ny != ny) ) {
2063
 
            PyErr_SetString( PyExc_RuntimeError,
2064
 
                             "Incompatible coord specifiers." );
2065
 
            return NULL;
2066
 
        }
2067
 
    }
2068
 
    else if ( !strcmp( pltrname, "pltr2" ) ) {
2069
 
    /* printf( "plshade, setting up for pltr2\n" ); */
2070
 
        if (!wrap) {
2071
 
        /* printf( "plshade, no wrapping is needed.\n" ); */
2072
 
            PLINT xnx, xny, ynx, yny;
2073
 
            PLFLT **xg, **yg;
2074
 
            TRY( pl_PyArray_AsFloatMatrix( &xop, &xnx, &xny, &xg ) );
2075
 
            TRY( pl_PyArray_AsFloatMatrix( &yop, &ynx, &yny, &yg ) );
2076
 
 
2077
 
            if ( (xnx != nx) || (ynx != nx) || (xny != ny) || (yny != ny) ) {
2078
 
                PyErr_SetString( PyExc_RuntimeError,
2079
 
                                 "Bogus transformation arrays." );
2080
 
                return NULL;
2081
 
            }
2082
 
 
2083
 
            plAlloc2dGrid( &cgrid2.xg, nx, ny );
2084
 
            plAlloc2dGrid( &cgrid2.yg, nx, ny );
2085
 
            cgrid2.nx = nx;
2086
 
            cgrid2.ny = ny;
2087
 
            zused = z;
2088
 
 
2089
 
            for( i=0; i < nx; i++ )
2090
 
                for( j=0; j < ny; j++ ) {
2091
 
                    cgrid2.xg[i][j] = xg[i][j];
2092
 
                    cgrid2.yg[i][j] = yg[i][j];
2093
 
                }
2094
 
        }
2095
 
        else if (wrap == 1) {
2096
 
            PLINT xnx, xny, ynx, yny;
2097
 
            PLFLT **xg, **yg;
2098
 
            TRY( pl_PyArray_AsFloatMatrix( &xop, &xnx, &xny, &xg ) );
2099
 
            TRY( pl_PyArray_AsFloatMatrix( &yop, &ynx, &yny, &yg ) );
2100
 
 
2101
 
            if ( (xnx != nx) || (ynx != nx) || (xny != ny) || (yny != ny) ) {
2102
 
                PyErr_SetString( PyExc_RuntimeError,
2103
 
                                 "Bogus transformation arrays." );
2104
 
                return NULL;
2105
 
            }
2106
 
 
2107
 
            plAlloc2dGrid( &cgrid2.xg, nx+1, ny );
2108
 
            plAlloc2dGrid( &cgrid2.yg, nx+1, ny );
2109
 
            plAlloc2dGrid( &zwrapped, nx+1, ny );
2110
 
            cgrid2.nx = nx+1;
2111
 
            cgrid2.ny = ny;
2112
 
            zused = zwrapped;
2113
 
 
2114
 
            for( i=0; i < nx; i++ )
2115
 
                for( j=0; j < ny; j++ ) {
2116
 
                    cgrid2.xg[i][j] = xg[i][j];
2117
 
                    cgrid2.yg[i][j] = yg[i][j];
2118
 
                    zwrapped[i][j] = z[i][j];
2119
 
                }
2120
 
 
2121
 
            for( j=0; j < ny; j++ ) {
2122
 
                cgrid2.xg[nx][j] = cgrid2.xg[0][j];
2123
 
                cgrid2.yg[nx][j] = cgrid2.yg[0][j];
2124
 
                zwrapped[nx][j] = zwrapped[0][j];
2125
 
            }
2126
 
 
2127
 
            nx++;
2128
 
        }
2129
 
        else if (wrap == 2) {
2130
 
            PLINT xnx, xny, ynx, yny;
2131
 
            PLFLT **xg, **yg;
2132
 
            TRY( pl_PyArray_AsFloatMatrix( &xop, &xnx, &xny, &xg ) );
2133
 
            TRY( pl_PyArray_AsFloatMatrix( &yop, &ynx, &yny, &yg ) );
2134
 
 
2135
 
            if ( (xnx != nx) || (ynx != nx) || (xny != ny) || (yny != ny) ) {
2136
 
                PyErr_SetString( PyExc_RuntimeError,
2137
 
                                 "Bogus transformation arrays." );
2138
 
                return NULL;
2139
 
            }
2140
 
 
2141
 
            plAlloc2dGrid( &cgrid2.xg, nx, ny+1 );
2142
 
            plAlloc2dGrid( &cgrid2.yg, nx, ny+1 );
2143
 
            plAlloc2dGrid( &zwrapped, nx, ny+1 );
2144
 
            cgrid2.nx = nx;
2145
 
            cgrid2.ny = ny+1;
2146
 
            zused = zwrapped;
2147
 
 
2148
 
            for( i=0; i < nx; i++ )
2149
 
                for( j=0; j < ny; j++ ) {
2150
 
                    cgrid2.xg[i][j] = xg[i][j];
2151
 
                    cgrid2.yg[i][j] = yg[i][j];
2152
 
                    zwrapped[i][j] = z[i][j];
2153
 
                }
2154
 
 
2155
 
            for( i=0; i < nx; i++ ) {
2156
 
                cgrid2.xg[i][ny] = cgrid2.xg[i][0];
2157
 
                cgrid2.yg[i][ny] = cgrid2.yg[i][0];
2158
 
                zwrapped[i][ny] = zwrapped[i][0];
2159
 
            }
2160
 
 
2161
 
            ny++;
2162
 
        }
2163
 
        else {
2164
 
            PyErr_SetString( PyExc_RuntimeError,
2165
 
                             "Invalid wrap specifier, must be 0, 1 or 2." );
2166
 
            return NULL;
2167
 
        }
2168
 
 
2169
 
        pltr = pltr2;
2170
 
        pltr_data = &cgrid2;
2171
 
    }
2172
 
    else {
2173
 
        PyErr_SetString( PyExc_RuntimeError,
2174
 
                         "Unrecognized coordinate transformation spec.  Must be pltr0, pltr1 or pltr2." );
2175
 
        return NULL;
2176
 
    }
2177
 
 
2178
 
    grid.f = zused;
2179
 
    grid.nx = nx;
2180
 
    grid.ny = ny;
2181
 
 
2182
 
/* Now go make the plot. */
2183
 
 
2184
 
    plfshade( pyf2eval2, &grid, NULL, NULL, nx, ny,
2185
 
              xmin, xmax, ymin, ymax,
2186
 
              sh_min, sh_max, sh_cmap, sh_col, sh_wid,
2187
 
              min_col, min_wid, max_col, max_wid,
2188
 
              plfill, rect, pltr, pltr_data );
2189
 
 
2190
 
/* Now free up any space which got allocated for our coordinate trickery. */
2191
 
 
2192
 
    if (pltr == pltr1) {
2193
 
    /* Hmm, actually, nothing to do here currently, since we just used the
2194
 
        Python Matrix data directly, rather than allocating private space. */
2195
 
    }
2196
 
    else if (pltr == pltr2) {
2197
 
    /* printf( "plshade, freeing space for grids used in pltr2\n" ); */
2198
 
        plFree2dGrid( cgrid2.xg, nx, ny );
2199
 
        plFree2dGrid( cgrid2.yg, nx, ny );
2200
 
        if (wrap != 0)
2201
 
        plFree2dGrid( zwrapped, nx, ny );
2202
 
    }
2203
 
 
2204
 
    plflush();
2205
 
    Py_INCREF( Py_None );
2206
 
    return Py_None;
2207
 
}
2208
 
/* 
2209
 
Not done yet...
2210
 
 
2211
 
static char doc_plshade[]="Shade region";
2212
 
 
2213
 
void  c_plshade(PLFLT **a, PLINT nx, PLINT ny, const char **defined,
2214
 
                             PLFLT left, PLFLT right, PLFLT bottom, PLFLT top,
2215
 
                             PLFLT shade_min, PLFLT shade_max,
2216
 
                             PLINT sh_cmap, PLFLT sh_color, PLINT sh_width,
2217
 
                             PLINT min_color, PLINT min_width,
2218
 
                             PLINT max_color, PLINT max_width,
2219
 
                             void (*fill) (PLINT, PLFLT *, PLFLT *), PLINT rectangular,
2220
 
                             void (*pltr) (PLFLT, PLFLT, PLFLT *, PLFLT *, PLPointer),
2221
 
                             PLPointer pltr_data);
2222
 
 
2223
 
void plshade1(PLFLT *a, PLINT nx, PLINT ny, const char *defined,
2224
 
                          PLFLT left, PLFLT right, PLFLT bottom, PLFLT top,
2225
 
                          PLFLT shade_min, PLFLT shade_max,
2226
 
                          PLINT sh_cmap, PLFLT sh_color, PLINT sh_width,
2227
 
                          PLINT min_color, PLINT min_width,
2228
 
                          PLINT max_color, PLINT max_width,
2229
 
                          void (*fill) (PLINT, PLFLT *, PLFLT *), PLINT rectangular,
2230
 
                          void (*pltr) (PLFLT, PLFLT, PLFLT *, PLFLT *, PLPointer),
2231
 
                          PLPointer pltr_data);
2232
 
 
2233
 
void  plfshade(PLFLT (*f2eval) (PLINT, PLINT, PLPointer),
2234
 
                          PLPointer f2eval_data,
2235
 
                          PLFLT (*c2eval) (PLINT, PLINT, PLPointer),
2236
 
                          PLPointer c2eval_data,
2237
 
                          PLINT nx, PLINT ny, 
2238
 
                          PLFLT left, PLFLT right, PLFLT bottom, PLFLT top,
2239
 
                          PLFLT shade_min, PLFLT shade_max,
2240
 
                          PLINT sh_cmap, PLFLT sh_color, PLINT sh_width,
2241
 
                          PLINT min_color, PLINT min_width,
2242
 
                          PLINT max_color, PLINT max_width,
2243
 
                          void (*fill) (PLINT, PLFLT *, PLFLT *), PLINT rectangular,
2244
 
                          void (*pltr) (PLFLT, PLFLT, PLFLT *, PLFLT *, PLPointer),
2245
 
                          PLPointer pltr_data);
2246
 
*/
2247
 
 
2248
 
/* I've canned this for now */
2249
 
 
2250
 
/*
2251
 
void
2252
 
c_plslpb(PLFLT lpbxmi, PLFLT lpbxma, PLFLT lpbymi, PLFLT lpbyma);
2253
 
*/
2254
 
 
2255
 
static char doc_plsmaj[]="Set up lengths of major tick marks";
2256
 
 
2257
 
static PyObject * pl_smaj(PyObject *self, PyObject *args)
2258
 
{
2259
 
    PLFLT def, scale;
2260
 
    TRY (PyArg_ParseTuple(args, PL_ARGS("dd", "ff"), &def, &scale));
2261
 
    plsmaj(def, scale);
2262
 
    Py_INCREF(Py_None);
2263
 
    return Py_None;
2264
 
}
2265
 
 
2266
 
static char doc_plsmin[]="Set up lengths of minor tick marks";
2267
 
 
2268
 
static PyObject * pl_smin(PyObject *self, PyObject *args)
2269
 
{
2270
 
    PLFLT def, scale;
2271
 
    TRY (PyArg_ParseTuple(args, PL_ARGS("dd", "ff"), &def, &scale));
2272
 
    plsmin(def, scale);
2273
 
    Py_INCREF(Py_None);
2274
 
    return Py_None;
2275
 
}
2276
 
 
2277
 
static char doc_plsori[]="Set orientation.  Must be done before calling plinit.";
2278
 
 
2279
 
static PyObject *pl_sori(PyObject *self, PyObject *args)
2280
 
{
2281
 
    PLINT ori;
2282
 
    TRY (PyArg_ParseTuple(args, "i", &ori));
2283
 
    plsori(ori);
2284
 
    Py_INCREF(Py_None);
2285
 
    return Py_None;
2286
 
}
2287
 
 
2288
 
static char doc_plspage[]="Set output device parameters.  Usually ignored by the driver.";
2289
 
 
2290
 
static PyObject * pl_spage(PyObject *self, PyObject *args)
2291
 
{
2292
 
    PLFLT xp, yp;
2293
 
    PLINT xleng, yleng, xoff, yoff;
2294
 
    TRY (PyArg_ParseTuple(args, PL_ARGS("ddiiii", "ffiiii"), 
2295
 
                                              &xp, &yp, &xleng, &yleng, &xoff, &yoff));
2296
 
    plspage(xp, yp, xleng, yleng, xoff, yoff);
2297
 
    Py_INCREF(Py_None);
2298
 
    return Py_None;
2299
 
}
2300
 
 
2301
 
static char doc_plspause[]="Set the pause (on end-of-page) status";
2302
 
 
2303
 
static PyObject * pl_spause(PyObject *self, PyObject *args)
2304
 
{
2305
 
    PLINT pause;
2306
 
    TRY (PyArg_ParseTuple(args, "i", &pause));
2307
 
    plspause(pause);
2308
 
    Py_INCREF(Py_None);
2309
 
    return Py_None;
2310
 
}
2311
 
 
2312
 
static char doc_plsstrm[]="Set stream number";
2313
 
 
2314
 
static PyObject * pl_sstrm(PyObject *self, PyObject *args)
2315
 
{
2316
 
    PLINT strm;
2317
 
    TRY (PyArg_ParseTuple(args, "i", &strm));
2318
 
    plsstrm(strm);
2319
 
    Py_INCREF(Py_None);
2320
 
    return Py_None;
2321
 
}
2322
 
 
2323
 
static char doc_plssub[]="Set the number of subwindows in x and y";
2324
 
 
2325
 
static PyObject * pl_ssub(PyObject *self, PyObject *args)
2326
 
{
2327
 
    PLINT nx, ny;
2328
 
    TRY (PyArg_ParseTuple(args, "ii", &nx, &ny));
2329
 
    plssub(nx, ny);
2330
 
    Py_INCREF(Py_None);
2331
 
    return Py_None;
2332
 
}
2333
 
 
2334
 
static char doc_plssym[]="Set symbol height.";
2335
 
 
2336
 
static PyObject * pl_ssym(PyObject *self, PyObject *args)
2337
 
{
2338
 
    PLFLT def, scale;
2339
 
    TRY (PyArg_ParseTuple(args, PL_ARGS("dd", "ff"), &def, &scale));
2340
 
    plssym(def, scale);
2341
 
    Py_INCREF(Py_None);
2342
 
    return Py_None;
2343
 
}
2344
 
 
2345
 
static char doc_plstar[]="Initialize PLplot, passing in the windows/page settings";
2346
 
 
2347
 
static PyObject * pl_star(PyObject *self, PyObject *args)
2348
 
{
2349
 
    PLINT nx, ny;
2350
 
    TRY (PyArg_ParseTuple(args, "ii", &nx, &ny));
2351
 
    plstar(nx, ny);
2352
 
    Py_INCREF(Py_None);
2353
 
    return Py_None;
2354
 
}
2355
 
 
2356
 
static char doc_plstart[]="Initialize PLplot, passing the device name and windows/page settings";
2357
 
 
2358
 
static PyObject *pl_start(PyObject *self, PyObject *args)
2359
 
{
2360
 
    const char *devname;
2361
 
    PLINT nx, ny;
2362
 
    TRY (PyArg_ParseTuple(args, "sii", &devname, &nx, &ny));
2363
 
    plstart(devname, nx, ny);
2364
 
    Py_INCREF(Py_None);
2365
 
    return Py_None;
2366
 
}
2367
 
 
2368
 
static char doc_plstripa[]="Add a point to a stripchart";
2369
 
 
2370
 
static PyObject *pl_stripa(PyObject *self, PyObject *args)
2371
 
{
2372
 
    PLINT id, p;
2373
 
    PLFLT x, y;
2374
 
    TRY (PyArg_ParseTuple(args, PL_ARGS("iidd", "iiff"), &id, &p, &x, &y));
2375
 
    plstripa(id, p, x, y);
2376
 
    Py_INCREF(Py_None);
2377
 
    return Py_None;
2378
 
}
2379
 
 
2380
 
static char doc_plstripc[]="Create a 4-pen stripchart";
2381
 
 
2382
 
static PyObject *pl_stripc(PyObject *self, PyObject *args)
2383
 
{
2384
 
 
2385
 
    PyObject *collineop, *stylineop, *leglineop;
2386
 
    PLINT id;
2387
 
    char *xspec, *yspec;
2388
 
    PLFLT xmin, xmax, xjump, ymin, ymax, xlpos, ylpos;
2389
 
    PLINT y_ascl, acc, colbox,  collab;
2390
 
    PLINT *colline, *styline;
2391
 
    char **legline;
2392
 
    char *labx, *laby, *labtop ;
2393
 
    int ncolline, nstyline, nlegline;
2394
 
   
2395
 
    TRY (PyArg_ParseTuple(args, 
2396
 
                          PL_ARGS("ssdddddddiiiiOOOsss", "ssfffffffiiiiOOOsss"),
2397
 
                          &xspec, &yspec, 
2398
 
                          &xmin, &xmax, &xjump,
2399
 
                          &ymin, &ymax, &xlpos, &ylpos,
2400
 
                          &y_ascl, &acc, &colbox, &collab,
2401
 
                          &collineop, &stylineop, &leglineop, 
2402
 
                          &labx, &laby, &labtop));
2403
 
 
2404
 
    TRY (pl_PyArray_AsIntArray(&collineop, &colline, &ncolline));
2405
 
    TRY (pl_PyArray_AsIntArray(&stylineop, &styline, &nstyline));
2406
 
    TRY (pl_PyList_AsStringArray(leglineop, &legline, &nlegline));
2407
 
    if (ncolline != 4 || nstyline !=4 || nlegline !=4) {
2408
 
       PyErr_SetString( PyExc_RuntimeError,
2409
 
         "colline, nstyline, and nlegline must each have 4 components" );
2410
 
       Py_DECREF(collineop);
2411
 
       Py_DECREF(stylineop);
2412
 
       Py_DECREF(leglineop);
2413
 
       return NULL;
2414
 
    }
2415
 
   
2416
 
    plstripc(&id, xspec, yspec,
2417
 
             xmin, xmax, xjump, ymin, ymax,
2418
 
             xlpos, ylpos,
2419
 
             y_ascl, acc,
2420
 
             colbox, collab,
2421
 
             colline, styline, legline, 
2422
 
             labx, laby, labtop); 
2423
 
   
2424
 
    Py_DECREF(collineop);
2425
 
    Py_DECREF(stylineop);
2426
 
    Py_DECREF(leglineop);
2427
 
    return Py_BuildValue("i", id);
2428
 
}
2429
 
 
2430
 
static char doc_plstripd[]="Deletes and releases memory used by a stripchart";
2431
 
 
2432
 
static PyObject *pl_stripd(PyObject *self, PyObject *args)
2433
 
{
2434
 
    PLINT id;
2435
 
    TRY (PyArg_ParseTuple(args, "i", &id));
2436
 
    plstripd(id);
2437
 
    Py_INCREF(Py_None);
2438
 
    return Py_None;
2439
 
}
2440
 
 
2441
 
static char doc_plstyl[]="Set up a new line style";
2442
 
 
2443
 
static PyObject * pl_styl(PyObject *self, PyObject *args)
2444
 
{
2445
 
    PLINT n, a, b, nms, *mark, *space, spacelen;
2446
 
    PyObject *markop, *spaceop;
2447
 
    if (PyArg_ParseTuple(args, "iii", &n, &a, &b))
2448
 
        plstyl(n, &a, &b);
2449
 
    else {
2450
 
        PyErr_Clear();
2451
 
        TRY (PyArg_ParseTuple(args, "OO", &markop, &spaceop));
2452
 
        TRY (pl_PyArray_AsIntArray(&markop, &mark, &nms));
2453
 
        TRY (pl_PyArray_AsIntArray(&spaceop, &space, &spacelen));
2454
 
        if (nms != spacelen) {
2455
 
              PyErr_SetString(PyExc_ValueError, "args 1 and 2 should have the same length");
2456
 
            Py_DECREF(markop);
2457
 
            Py_DECREF(spaceop);
2458
 
              return NULL;
2459
 
        }
2460
 
        plstyl(nms, mark, space);
2461
 
        Py_DECREF(markop);
2462
 
        Py_DECREF(spaceop);
2463
 
    }
2464
 
    Py_INCREF(Py_None);
2465
 
    return Py_None;
2466
 
}
2467
 
 
2468
 
static char doc_plsvpa[]="Sets the edges of the viewport to the specified absolute coordinates";
2469
 
 
2470
 
static PyObject * pl_svpa(PyObject *self, PyObject *args)
2471
 
{
2472
 
    PLFLT xmin, xmax, ymin, ymax;
2473
 
    TRY (PyArg_ParseTuple(args, PL_ARGS("dddd", "ffff"), 
2474
 
                                              &xmin, &xmax, &ymin, &ymax));
2475
 
    plsvpa(xmin, xmax, ymin, ymax);
2476
 
    Py_INCREF(Py_None);
2477
 
    return Py_None;
2478
 
}
2479
 
 
2480
 
static char doc_plsxax[]="Set x axis labeling parameters";
2481
 
 
2482
 
static PyObject * pl_sxax(PyObject *self, PyObject *args)
2483
 
{
2484
 
    PLINT digmax, digits;
2485
 
    TRY (PyArg_ParseTuple(args, "ii", &digmax, &digits));
2486
 
    plsxax(digmax, digits);
2487
 
    Py_INCREF(Py_None);
2488
 
    return Py_None;
2489
 
}
2490
 
 
2491
 
static char doc_plsxwin[]="Set inferior X window";
2492
 
 
2493
 
static PyObject * pl_sxwin(PyObject *self, PyObject *args)
2494
 
{
2495
 
    PLINT window_id;
2496
 
    TRY (PyArg_ParseTuple(args, "i", &window_id));
2497
 
    plsxwin(window_id);
2498
 
    Py_INCREF(Py_None);
2499
 
    return Py_None;
2500
 
}
2501
 
 
2502
 
static char doc_plsyax[]="Set y axis labeling parameters";
2503
 
 
2504
 
static PyObject * pl_syax(PyObject *self, PyObject *args)
2505
 
{
2506
 
    PLINT digmax, digits;
2507
 
    TRY (PyArg_ParseTuple(args, "ii", &digmax, &digits));
2508
 
    plsyax(digmax, digits);
2509
 
    Py_INCREF(Py_None);
2510
 
    return Py_None;
2511
 
}
2512
 
 
2513
 
static char doc_plsym[]="Plots array y against x for n points using Hershey symbol \"code\"";
2514
 
 
2515
 
static PyObject * pl_sym(PyObject *self, PyObject *args)
2516
 
{
2517
 
    PLINT n, code, ylen;
2518
 
    PLFLT *x, *y;
2519
 
    PyObject *xop, *yop;
2520
 
    TRY (PyArg_ParseTuple(args, "OOi", &xop, &yop, &code));
2521
 
    TRY (pl_PyArray_AsFloatArray(&xop, &x, &n));
2522
 
    TRY (pl_PyArray_AsFloatArray(&yop, &y, &ylen));
2523
 
    if (n != ylen) {
2524
 
          PyErr_SetString(PyExc_ValueError, "args 1 and 2 should have the same length");
2525
 
        Py_DECREF(xop);
2526
 
        Py_DECREF(yop);
2527
 
          return NULL;
2528
 
    }
2529
 
    plsym(n, x, y, code);
2530
 
    Py_DECREF(xop);
2531
 
    Py_DECREF(yop);
2532
 
    Py_INCREF(Py_None);
2533
 
    return Py_None;
2534
 
}
2535
 
 
2536
 
static char doc_plszax[]="Set z axis labeling parameters";
2537
 
 
2538
 
static PyObject * pl_szax(PyObject *self, PyObject *args)
2539
 
{
2540
 
    PLINT digmax, digits;
2541
 
    TRY (PyArg_ParseTuple(args, "ii", &digmax, &digits));
2542
 
    plszax(digmax, digits);
2543
 
    Py_INCREF(Py_None);
2544
 
    return Py_None;
2545
 
}
2546
 
 
2547
 
static char doc_pltext[]="Switches to text screen";
2548
 
 
2549
 
static PyObject * pl_text(PyObject *self, PyObject *args)
2550
 
{
2551
 
    TRY (PyArg_ParseTuple(args, ""));
2552
 
    pltext();
2553
 
    Py_INCREF(Py_None);
2554
 
    return Py_None;
2555
 
}
2556
 
 
2557
 
static char doc_plvasp[]="Sets the edges of the viewport with the given aspect ratio, leaving room for labels";
2558
 
 
2559
 
static PyObject * pl_vasp(PyObject *self, PyObject *args)
2560
 
{
2561
 
    PLFLT aspect;
2562
 
    TRY (PyArg_ParseTuple(args, PL_ARGS("d", "f"), &aspect));
2563
 
    plvasp(aspect);
2564
 
    Py_INCREF(Py_None);
2565
 
    return Py_None;
2566
 
}
2567
 
 
2568
 
static char doc_plvpas[]="Creates the largest viewport of the specified aspect ratio that fits within the specified normalized subpage coordinates";
2569
 
 
2570
 
static PyObject * pl_vpas(PyObject *self, PyObject *args)
2571
 
{
2572
 
    PLFLT xmin, xmax, ymin, ymax, aspect;
2573
 
    TRY (PyArg_ParseTuple(args, PL_ARGS("ddddd", "fffff"), 
2574
 
                                              &xmin, &xmax, &ymin, &ymax, &aspect));
2575
 
    plvpas(xmin, xmax, ymin, ymax, aspect);
2576
 
    Py_INCREF(Py_None);
2577
 
    return Py_None;
2578
 
}
2579
 
 
2580
 
static char doc_plvpor[]="Creates a viewport with the specified normalized subpage coordinates";
2581
 
 
2582
 
static PyObject * pl_vpor(PyObject *self, PyObject *args)
2583
 
{
2584
 
    PLFLT xmin, xmax, ymin, ymax;
2585
 
    TRY (PyArg_ParseTuple(args, PL_ARGS("dddd", "ffff"), 
2586
 
                                              &xmin, &xmax, &ymin, &ymax));
2587
 
    plvpor(xmin, xmax, ymin, ymax);
2588
 
    Py_INCREF(Py_None);
2589
 
    return Py_None;
2590
 
}
2591
 
 
2592
 
static char doc_plvsta[]="Defines a \"standard\" viewport with seven character heights for the left margin and four character heights everywhere else";
2593
 
 
2594
 
static PyObject * pl_vsta(PyObject *self, PyObject *args)
2595
 
{
2596
 
    TRY (PyArg_ParseTuple(args, ""));
2597
 
    plvsta();
2598
 
    Py_INCREF(Py_None);
2599
 
    return Py_None;
2600
 
}
2601
 
 
2602
 
static char doc_plw3d[]="Set up a window for three-dimensional plotting";
2603
 
 
2604
 
static PyObject * pl_w3d(PyObject *self, PyObject *args)
2605
 
{
2606
 
    PLFLT basex, basey, height, xmin0, xmax0, ymin0, ymax0, zmin0, zmax0, alt, az;
2607
 
    TRY (PyArg_ParseTuple(args, PL_ARGS("ddddddddddd", "fffffffffff"),
2608
 
                                             &basex, &basey, &height, &xmin0, &xmax0, &ymin0, &ymax0,
2609
 
                                             &zmin0, &zmax0, &alt, &az));
2610
 
    plw3d(basex, basey, height, xmin0, xmax0, ymin0, ymax0, zmin0, zmax0, alt, az);
2611
 
    Py_INCREF(Py_None);
2612
 
    return Py_None;
2613
 
}
2614
 
 
2615
 
static char doc_plwid[]="Set pen width";
2616
 
 
2617
 
static PyObject * pl_wid(PyObject *self, PyObject *args)
2618
 
{
2619
 
    PLINT width;
2620
 
    TRY (PyArg_ParseTuple(args, "i", &width));
2621
 
    plwid(width);
2622
 
    Py_INCREF(Py_None);
2623
 
    return Py_None;
2624
 
}
2625
 
 
2626
 
static char doc_plwind[]="Set up world coordinates of the viewport boundaries (2d plots)";
2627
 
 
2628
 
static PyObject * pl_wind(PyObject *self, PyObject *args)
2629
 
{
2630
 
    PLFLT xmin, xmax, ymin, ymax;
2631
 
    TRY (PyArg_ParseTuple(args, PL_ARGS("dddd", "ffff"), 
2632
 
                                              &xmin, &xmax, &ymin, &ymax));
2633
 
    plwind(xmin, xmax, ymin, ymax);
2634
 
    Py_INCREF(Py_None);
2635
 
    return Py_None;
2636
 
}
2637
 
 
2638
 
static char doc_plParseOpts[]="Process PLplot internal options list";
2639
 
 
2640
 
static PyObject * pl_ParseOpts(PyObject *self, PyObject *args)
2641
 
{
2642
 
    int argc, status;
2643
 
    char **argv;
2644
 
    PLINT mode;
2645
 
    PyObject *argvlist;
2646
 
    TRY (PyArg_ParseTuple(args, "O!i", &PyList_Type, &argvlist, &mode));
2647
 
    TRY (pl_PyList_AsStringArray(argvlist, &argv, &argc));
2648
 
    status = plParseOpts(&argc, argv, mode);
2649
 
    TRY (pl_PyList_SetFromStringArray(argvlist, argv, argc));
2650
 
    PyMem_DEL(argv);
2651
 
    return Py_BuildValue("i", status);
2652
 
}
2653
 
 
2654
 
/* 
2655
 
Not done yet...
2656
 
 
2657
 
static char doc_plParseOpts[]="Process options list
2658
 
 
2659
 
int plParseOpts(int *p_argc, char **argv, PLINT mode, PLOptionTable *option_table,
2660
 
            void (*usage_handler) (char *));
2661
 
*/
2662
 
 
2663
 
static char doc_plsetopt[]="Process input strings, treating them as an option and argument pair";
2664
 
 
2665
 
static PyObject * pl_setopt(PyObject *self, PyObject *args)
2666
 
{
2667
 
    char *opt, *optarg;
2668
 
    int status;
2669
 
    TRY (PyArg_ParseTuple(args, "ss", &opt, &optarg));
2670
 
    status = plsetopt(opt, optarg);
2671
 
    return Py_BuildValue("i", status);
2672
 
}
2673
 
 
2674
 
static char doc_plGetCursor[]="Wait for right button mouse event and translate to world coordinates";
2675
 
 
2676
 
static PyObject * pl_GetCursor(PyObject *self, PyObject *args)
2677
 
{
2678
 
    PLGraphicsIn gin;
2679
 
    int translated;
2680
 
    PyObject *result;
2681
 
    TRY (PyArg_ParseTuple(args, ""));
2682
 
    translated = plGetCursor(&gin);
2683
 
    if (translated)
2684
 
          result = Py_BuildValue(PL_ARGS("(dddd)", "(ffff)"), gin.dX, gin.dY, gin.wX, gin.wY);
2685
 
    else
2686
 
          result = Py_BuildValue(PL_ARGS("(dd)", "(ff)"), gin.dX, gin.dY);
2687
 
    return result;
2688
 
}
2689
 
 
2690
 
 
2691
 
static char doc_xormod[]="enter/leave xor mode";
2692
 
 
2693
 
static PyObject * pl_xormod(PyObject *self, PyObject *args)
2694
 
{
2695
 
        PLINT mode,st;
2696
 
        TRY (PyArg_ParseTuple(args, "i", &mode));
2697
 
        plxormod(mode, &st);    
2698
 
        return Py_BuildValue("i", st);
2699
 
}
2700
 
 
2701
 
 
2702
 
static PyMethodDef pl_methods[] = {
2703
 
    {"pladv",                   pl_adv, METH_VARARGS, doc_pladv},
2704
 
    {"plarrows",                pl_arrows, METH_VARARGS, doc_plarrows},
2705
 
    {"plaxes",          pl_axes, METH_VARARGS, doc_plaxes},
2706
 
    {"plbin",                   pl_bin, METH_VARARGS, doc_plbin},
2707
 
    {"plbop",                   pl_bop, METH_VARARGS, doc_plbop},
2708
 
    {"plbox",                   pl_box, METH_VARARGS, doc_plbox},
2709
 
    {"plbox3",          pl_box3, METH_VARARGS, doc_plbox3},
2710
 
    {"plcalc_world",            pl_calc_world, METH_VARARGS, doc_plcalc_world},
2711
 
    {"plclr",                   pl_eop, METH_VARARGS, doc_pleop},               /* old name for backward compatibility */
2712
 
    {"plcol",                   pl_col0, METH_VARARGS, doc_plcol0},             /* old name for backward compatibility */
2713
 
    {"plcol0",          pl_col0, METH_VARARGS, doc_plcol0},
2714
 
    {"plcol1",          pl_col1, METH_VARARGS, doc_plcol1},
2715
 
    {"plcont",          pl_cont, METH_VARARGS, doc_plcont},
2716
 
    {"plcont2",         pl_cont2, METH_VARARGS, doc_plcont2},
2717
 
    {"plcpstrm",                pl_cpstrm, METH_VARARGS, doc_plcpstrm},
2718
 
    {"pldid2pc",                pl_did2pc, METH_VARARGS, doc_pldid2pc},
2719
 
    {"pldip2dc",                pl_dip2dc, METH_VARARGS, doc_pldip2dc},
2720
 
    {"plend",                   pl_end, METH_VARARGS, doc_plend},
2721
 
    {"plend1",          pl_end1, METH_VARARGS, doc_plend1},
2722
 
    {"plenv",                   pl_env, METH_VARARGS, doc_plenv},
2723
 
    {"pleop",                   pl_eop, METH_VARARGS, doc_pleop},
2724
 
    {"plerrx",                  pl_errx, METH_VARARGS, doc_plerrx},
2725
 
    {"plerry",                  pl_erry, METH_VARARGS, doc_plerry},
2726
 
    {"plfamadv",                pl_famadv, METH_VARARGS, doc_plfamadv},
2727
 
    {"plfill",                  pl_fill, METH_VARARGS, doc_plfill},
2728
 
    {"plflush",         pl_flush, METH_VARARGS, doc_plflush},
2729
 
    {"plfont",                  pl_font, METH_VARARGS, doc_plfont},
2730
 
    {"plfontld",                pl_fontld, METH_VARARGS, doc_plfontld},
2731
 
    {"plgchr",          pl_gchr, METH_VARARGS, doc_plgchr},
2732
 
    {"plgcol0",         pl_gcol0, METH_VARARGS, doc_plgcol0},
2733
 
    {"plgcolbg",                pl_gcolbg, METH_VARARGS, doc_plgcolbg},
2734
 
    {"plgdidev",                pl_gdidev, METH_VARARGS, doc_plgdidev},
2735
 
    {"plgdiori",                pl_gdiori, METH_VARARGS, doc_plgdiori},
2736
 
    {"plgdiplt",                pl_gdiplt, METH_VARARGS, doc_plgdiplt},
2737
 
    {"plgfam",          pl_gfam, METH_VARARGS, doc_plgfam},
2738
 
    {"plgfnam",         pl_gfnam, METH_VARARGS, doc_plgfnam},
2739
 
    {"plgpage",         pl_gpage, METH_VARARGS, doc_plgpage},
2740
 
    {"plgra",                   pl_gra, METH_VARARGS, doc_plgra},
2741
 
    {"plgspa",          pl_gspa, METH_VARARGS, doc_plgspa},
2742
 
    {"plgstrm",         pl_gstrm, METH_VARARGS, doc_plgstrm},
2743
 
    {"plgver",          pl_gver, METH_VARARGS, doc_plgver},
2744
 
    {"plgvpd",          pl_gvpd, METH_VARARGS, doc_plgvpd},
2745
 
    {"plgvpw",          pl_gvpw, METH_VARARGS, doc_plgvpw},
2746
 
    {"plPgvpw",         pl_gvpw, METH_VARARGS, doc_plgvpw},  /* old name */
2747
 
    {"plgxax",          pl_gxax, METH_VARARGS, doc_plgxax},
2748
 
    {"plgyax",          pl_gyax, METH_VARARGS, doc_plgyax},
2749
 
    {"plgzax",          pl_gzax, METH_VARARGS, doc_plgzax},
2750
 
    {"plhist",                  pl_hist, METH_VARARGS, doc_plhist},
2751
 
    {"plhls",                   pl_hls, METH_VARARGS, doc_plhls},
2752
 
    {"plinit",                  pl_init, METH_VARARGS, doc_plinit},
2753
 
    {"pljoin",                  pl_join, METH_VARARGS, doc_pljoin},
2754
 
    {"pllab",                   pl_lab, METH_VARARGS, doc_pllab},
2755
 
    {"pllightsource",           pl_lightsource, METH_VARARGS, doc_pllightsource},
2756
 
    {"plline",                  pl_line, METH_VARARGS, doc_plline},
2757
 
    {"plline3",         pl_line3, METH_VARARGS, doc_plline3},
2758
 
    {"pllsty",                  pl_lsty, METH_VARARGS, doc_pllsty},
2759
 
    {"plmesh",          pl_mesh, METH_VARARGS, doc_plmesh},
2760
 
    {"plmkstrm",                pl_mkstrm, METH_VARARGS, doc_plmkstrm},
2761
 
    {"plmtex",          pl_mtex, METH_VARARGS, doc_plmtex},
2762
 
    {"plot3d",          pl_ot3d, METH_VARARGS, doc_plot3d},
2763
 
    {"plotsh3d",        pl_otsh3d, METH_VARARGS, doc_plotsh3d},
2764
 
    {"plpage",          pl_bop, METH_VARARGS, doc_plbop},               /* old name for backward compatibility */
2765
 
    {"plpat",                   pl_pat, METH_VARARGS, doc_plpat},
2766
 
    {"plpoin",          pl_poin, METH_VARARGS, doc_plpoin},
2767
 
    {"plpoin3",         pl_poin3, METH_VARARGS, doc_plpoin3},
2768
 
    {"plpoly3",         pl_poly3, METH_VARARGS, doc_plpoly3},
2769
 
    {"plprec",          pl_prec, METH_VARARGS, doc_plprec},
2770
 
    {"plpsty",          pl_psty, METH_VARARGS, doc_plpsty},
2771
 
    {"plptex",          pl_ptex, METH_VARARGS, doc_plptex},
2772
 
    {"plreplot",                pl_replot, METH_VARARGS, doc_plreplot},
2773
 
    {"plrgb",                   pl_rgb, METH_VARARGS, doc_plrgb},
2774
 
    {"plrgb1",          pl_rgb1, METH_VARARGS, doc_plrgb1},
2775
 
    {"plschr",          pl_schr, METH_VARARGS, doc_plschr},
2776
 
    {"plscmap0n",       pl_scmap0n, METH_VARARGS, doc_plscmap0n},
2777
 
    {"plscmap1n",       pl_scmap1n, METH_VARARGS, doc_plscmap1n},
2778
 
    {"plscmap0",                pl_scmap0, METH_VARARGS, doc_plscmap0},
2779
 
    {"plscmap1",                pl_scmap1, METH_VARARGS, doc_plscmap1},
2780
 
    {"plscmap1l",       pl_scmap1l, METH_VARARGS, doc_plscmap1l},
2781
 
    {"plscol0",         pl_scol0, METH_VARARGS, doc_plscol0},
2782
 
    {"plscolbg",                pl_scolbg, METH_VARARGS, doc_plscolbg},
2783
 
    {"plscolor",                pl_scolor, METH_VARARGS, doc_plscolor},
2784
 
    {"plsdev",          pl_sdev, METH_VARARGS, doc_plsdev},
2785
 
    {"plsdidev",                pl_sdidev, METH_VARARGS, doc_plsdidev},
2786
 
    {"plsdimap",                pl_sdimap, METH_VARARGS, doc_plsdimap},
2787
 
    {"plsdiori",                pl_sdiori, METH_VARARGS, doc_plsdiori},
2788
 
    {"plsdiplt",                pl_sdiplt, METH_VARARGS, doc_plsdiplt},
2789
 
    {"plsdiplz",                pl_sdiplz, METH_VARARGS, doc_plsdiplz},
2790
 
    {"plsesc",          pl_sesc, METH_VARARGS, doc_plsesc},
2791
 
    {"pl_setcontlabelformat", pl__setcontlabelformat, METH_VARARGS, doc_pl_setcontlabelformat},
2792
 
    {"pl_setcontlabelparam", pl__setcontlabelparam, METH_VARARGS, doc_pl_setcontlabelparam},
2793
 
    {"plsfam",          pl_sfam, METH_VARARGS, doc_plsfam},
2794
 
    {"plsfnam",         pl_sfnam, METH_VARARGS, doc_plsfnam},
2795
 
    {"plshades",        pl_shades, METH_VARARGS, doc_plshades},
2796
 
    {"plshade",         pl_shade, METH_VARARGS, doc_plshade},
2797
 
    {"plsmaj",          pl_smaj, METH_VARARGS, doc_plsmaj},
2798
 
    {"plsmin",          pl_smin, METH_VARARGS, doc_plsmin},
2799
 
    {"plsori",                  pl_sori, METH_VARARGS, doc_plsori},
2800
 
    {"plspage",         pl_spage, METH_VARARGS, doc_plspage},
2801
 
    {"plspause",                pl_spause, METH_VARARGS, doc_plspause},
2802
 
    {"plsstrm",         pl_sstrm, METH_VARARGS, doc_plsstrm},
2803
 
    {"plssub",          pl_ssub, METH_VARARGS, doc_plssub},
2804
 
    {"plssym",          pl_ssym, METH_VARARGS, doc_plssym},
2805
 
    {"plstar",                  pl_star, METH_VARARGS, doc_plstar},
2806
 
    {"plstart",         pl_start, METH_VARARGS, doc_plstart},
2807
 
    {"plstripa",        pl_stripa, METH_VARARGS, doc_plstripa},
2808
 
    {"plstripc",        pl_stripc, METH_VARARGS, doc_plstripc},
2809
 
    {"plstripd",        pl_stripd, METH_VARARGS, doc_plstripd},
2810
 
    {"plstyl",                  pl_styl, METH_VARARGS, doc_plstyl},
2811
 
    {"plsvpa",          pl_svpa, METH_VARARGS, doc_plsvpa},
2812
 
    {"plsxax",          pl_sxax, METH_VARARGS, doc_plsxax},
2813
 
    {"plsxwin",         pl_sxwin, METH_VARARGS, doc_plsxwin},
2814
 
    {"plsyax",          pl_syax, METH_VARARGS, doc_plsyax},
2815
 
    {"plsym",                   pl_sym, METH_VARARGS, doc_plsym},
2816
 
    {"plszax",          pl_szax, METH_VARARGS, doc_plszax},
2817
 
    {"pltext",                  pl_text, METH_VARARGS, doc_pltext},
2818
 
    {"plvasp",          pl_vasp, METH_VARARGS, doc_plvasp},
2819
 
    {"plvpas",          pl_vpas, METH_VARARGS, doc_plvpas},
2820
 
    {"plvpor",          pl_vpor, METH_VARARGS, doc_plvpor},
2821
 
    {"plvsta",          pl_vsta, METH_VARARGS, doc_plvsta},
2822
 
    {"plw3d",           pl_w3d, METH_VARARGS, doc_plw3d},
2823
 
    {"plwid",                   pl_wid, METH_VARARGS, doc_plwid},
2824
 
    {"plwind",          pl_wind, METH_VARARGS, doc_plwind},
2825
 
    {"plxormod",        pl_xormod, METH_VARARGS, doc_xormod},
2826
 
    {"plParseOpts",     pl_ParseOpts, METH_VARARGS, doc_plParseOpts},
2827
 
    {"plsetopt",                pl_setopt, METH_VARARGS, doc_plsetopt},
2828
 
    {"plGetCursor",     pl_GetCursor, METH_VARARGS, doc_plGetCursor},
2829
 
    {NULL, NULL, 0, NULL}
2830
 
};
2831
 
 
2832
 
void initpl(void)
2833
 
{
2834
 
    PyObject *m;
2835
 
    PyObject *d;
2836
 
    PyObject *v;
2837
 
 
2838
 
    import_array();
2839
 
 
2840
 
    /* Create the module and add the functions */
2841
 
    m = Py_InitModule("pl", pl_methods);
2842
 
    d = PyModule_GetDict(m);
2843
 
 
2844
 
    /* Add some symbolic constants to the module */
2845
 
    v = PyInt_FromLong(PL_PARSE_PARTIAL);
2846
 
    PyDict_SetItemString(d, "PL_PARSE_PARTIAL", v);
2847
 
    Py_XDECREF(v);
2848
 
 
2849
 
    v = PyInt_FromLong(PL_PARSE_FULL);
2850
 
    PyDict_SetItemString(d, "PL_PARSE_FULL", v);
2851
 
    Py_XDECREF(v);
2852
 
 
2853
 
    v = PyInt_FromLong(PL_PARSE_QUIET);
2854
 
    PyDict_SetItemString(d, "PL_PARSE_QUIET", v);
2855
 
    Py_XDECREF(v);
2856
 
 
2857
 
    v = PyInt_FromLong(PL_PARSE_NODELETE);
2858
 
    PyDict_SetItemString(d, "PL_PARSE_NODELETE", v);
2859
 
    Py_XDECREF(v);
2860
 
 
2861
 
    v = PyInt_FromLong(PL_PARSE_SHOWALL);
2862
 
    PyDict_SetItemString(d, "PL_PARSE_SHOWALL", v);
2863
 
    Py_XDECREF(v);
2864
 
 
2865
 
    v = PyInt_FromLong(PL_PARSE_OVERRIDE);
2866
 
    PyDict_SetItemString(d, "PL_PARSE_OVERRIDE", v);
2867
 
    Py_XDECREF(v);
2868
 
 
2869
 
    v = PyInt_FromLong(PL_PARSE_NOPROGRAM);
2870
 
    PyDict_SetItemString(d, "PL_PARSE_NOPROGRAM", v);
2871
 
    Py_XDECREF(v);
2872
 
 
2873
 
    v = PyInt_FromLong(PL_PARSE_NODASH);
2874
 
    PyDict_SetItemString(d, "PL_PARSE_NODASH", v);
2875
 
    Py_XDECREF(v);
2876
 
 
2877
 
    /* Check for errors */
2878
 
    if (PyErr_Occurred())
2879
 
        Py_FatalError("pl module initialization failed");
2880
 
}