| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
#include "EXTERN.h" |
|
2
|
|
|
|
|
|
|
#include "perl.h" |
|
3
|
|
|
|
|
|
|
#include "pdl.h" |
|
4
|
|
|
|
|
|
|
#include "pdlcore.h" |
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
#define PDL PDL_Graphics_PLplot |
|
7
|
|
|
|
|
|
|
extern Core *PDL; |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
#include |
|
10
|
|
|
|
|
|
|
#include |
|
11
|
|
|
|
|
|
|
#include |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
#define MAKE_SETTABLE(label) \ |
|
14
|
|
|
|
|
|
|
static SV* label ## _subroutine; \ |
|
15
|
|
|
|
|
|
|
void label ## _callback_set(SV* sv, char *errmsg) { \ |
|
16
|
|
|
|
|
|
|
if (SvTRUE(sv) && (! SvROK(sv) || SvTYPE(SvRV(sv)) != SVt_PVCV)) \ |
|
17
|
|
|
|
|
|
|
croak("%s", errmsg); \ |
|
18
|
|
|
|
|
|
|
label ## _subroutine = sv; \ |
|
19
|
|
|
|
|
|
|
} |
|
20
|
|
|
|
|
|
|
|
|
21
|
38
|
100
|
|
|
|
|
MAKE_SETTABLE(pltr) |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
static IV pltr0_iv; |
|
24
|
|
|
|
|
|
|
static IV pltr1_iv; |
|
25
|
|
|
|
|
|
|
static IV pltr2_iv; |
|
26
|
32
|
|
|
|
|
|
void pltr_iv_set(IV iv0, IV iv1, IV iv2) { |
|
27
|
32
|
|
|
|
|
|
pltr0_iv = iv0; |
|
28
|
32
|
|
|
|
|
|
pltr1_iv = iv1; |
|
29
|
32
|
|
|
|
|
|
pltr2_iv = iv2; |
|
30
|
32
|
|
|
|
|
|
} |
|
31
|
|
|
|
|
|
|
|
|
32
|
269280
|
|
|
|
|
|
void pltr_callback(PLFLT x, PLFLT y, PLFLT* tx, PLFLT* ty, PLPointer pltr_data) |
|
33
|
|
|
|
|
|
|
{ |
|
34
|
|
|
|
|
|
|
I32 count; |
|
35
|
269280
|
|
|
|
|
|
dSP; |
|
36
|
|
|
|
|
|
|
|
|
37
|
269280
|
|
|
|
|
|
ENTER; |
|
38
|
269280
|
|
|
|
|
|
SAVETMPS; |
|
39
|
|
|
|
|
|
|
|
|
40
|
269280
|
50
|
|
|
|
|
PUSHMARK(SP); |
|
41
|
269280
|
50
|
|
|
|
|
XPUSHs(sv_2mortal(newSVnv((double) x))); |
|
42
|
269280
|
50
|
|
|
|
|
XPUSHs(sv_2mortal(newSVnv((double) y))); |
|
43
|
269280
|
50
|
|
|
|
|
XPUSHs((SV*) pltr_data); |
|
44
|
269280
|
|
|
|
|
|
PUTBACK; |
|
45
|
|
|
|
|
|
|
|
|
46
|
269280
|
|
|
|
|
|
count = call_sv(pltr_subroutine, G_ARRAY); |
|
47
|
|
|
|
|
|
|
|
|
48
|
269280
|
|
|
|
|
|
SPAGAIN; |
|
49
|
|
|
|
|
|
|
|
|
50
|
269280
|
50
|
|
|
|
|
if (count != 2) |
|
51
|
0
|
|
|
|
|
|
croak("pltr: must return two scalars"); |
|
52
|
|
|
|
|
|
|
|
|
53
|
269280
|
|
|
|
|
|
*ty = (PLFLT) POPn; |
|
54
|
269280
|
|
|
|
|
|
*tx = (PLFLT) POPn; |
|
55
|
|
|
|
|
|
|
|
|
56
|
269280
|
|
|
|
|
|
PUTBACK; |
|
57
|
269280
|
50
|
|
|
|
|
FREETMPS; |
|
58
|
269280
|
|
|
|
|
|
LEAVE; |
|
59
|
269280
|
|
|
|
|
|
} |
|
60
|
|
|
|
|
|
|
|
|
61
|
38
|
|
|
|
|
|
void* get_standard_pltrcb(SV* cb) |
|
62
|
|
|
|
|
|
|
{ |
|
63
|
38
|
100
|
|
|
|
|
if ( !SvROK(cb) ) return NULL; /* Added to prevent bug in plshades for 0 input. D. Hunt 12/18/2008 */ |
|
64
|
20
|
|
|
|
|
|
IV sub = (IV) SvRV (cb); |
|
65
|
|
|
|
|
|
|
|
|
66
|
20
|
50
|
|
|
|
|
if (sub == pltr0_iv) |
|
67
|
0
|
|
|
|
|
|
return (void*) pltr0; |
|
68
|
20
|
100
|
|
|
|
|
else if (sub == pltr1_iv) |
|
69
|
4
|
|
|
|
|
|
return (void*) pltr1; |
|
70
|
16
|
100
|
|
|
|
|
else if (sub == pltr2_iv) |
|
71
|
12
|
|
|
|
|
|
return (void*) pltr2; |
|
72
|
|
|
|
|
|
|
else |
|
73
|
4
|
50
|
|
|
|
|
return SvTRUE(cb) ? (void*) pltr_callback : NULL; |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
|
|
76
|
20
|
50
|
|
|
|
|
MAKE_SETTABLE(defined) |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
|
PLINT defined_callback(PLFLT x, PLFLT y) |
|
78
|
|
|
|
|
|
|
{ |
|
79
|
|
|
|
|
|
|
I32 count, retval; |
|
80
|
0
|
|
|
|
|
|
dSP; |
|
81
|
|
|
|
|
|
|
|
|
82
|
0
|
|
|
|
|
|
ENTER; |
|
83
|
0
|
|
|
|
|
|
SAVETMPS; |
|
84
|
|
|
|
|
|
|
|
|
85
|
0
|
0
|
|
|
|
|
PUSHMARK(SP); |
|
86
|
0
|
0
|
|
|
|
|
XPUSHs(sv_2mortal(newSVnv((double) x))); |
|
87
|
0
|
0
|
|
|
|
|
XPUSHs(sv_2mortal(newSVnv((double) y))); |
|
88
|
0
|
|
|
|
|
|
PUTBACK; |
|
89
|
|
|
|
|
|
|
|
|
90
|
0
|
|
|
|
|
|
count = call_sv(defined_subroutine, G_SCALAR); |
|
91
|
|
|
|
|
|
|
|
|
92
|
0
|
|
|
|
|
|
SPAGAIN; |
|
93
|
|
|
|
|
|
|
|
|
94
|
0
|
0
|
|
|
|
|
if (count != 1) |
|
95
|
0
|
|
|
|
|
|
croak("defined: must return one scalar"); |
|
96
|
|
|
|
|
|
|
|
|
97
|
0
|
|
|
|
|
|
retval = POPi; |
|
98
|
|
|
|
|
|
|
|
|
99
|
0
|
|
|
|
|
|
PUTBACK; |
|
100
|
0
|
0
|
|
|
|
|
FREETMPS; |
|
101
|
0
|
|
|
|
|
|
LEAVE; |
|
102
|
|
|
|
|
|
|
|
|
103
|
0
|
|
|
|
|
|
return retval; |
|
104
|
|
|
|
|
|
|
} |
|
105
|
|
|
|
|
|
|
|
|
106
|
6
|
100
|
|
|
|
|
MAKE_SETTABLE(mapform) |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
|
|
108
|
9400
|
|
|
|
|
|
void default_magic(pdl *p, size_t pa) { p->data = 0; } |
|
109
|
|
|
|
|
|
|
|
|
110
|
4700
|
|
|
|
|
|
void mapform_callback(PLINT n, PLFLT* x, PLFLT* y) |
|
111
|
|
|
|
|
|
|
{ |
|
112
|
|
|
|
|
|
|
pdl *x_pdl, *y_pdl; |
|
113
|
|
|
|
|
|
|
PLFLT *tx, *ty; |
|
114
|
|
|
|
|
|
|
SV *x_sv, *y_sv; |
|
115
|
|
|
|
|
|
|
#if defined(PDL_CORE_VERSION) && PDL_CORE_VERSION >= 10 |
|
116
|
|
|
|
|
|
|
PDL_Indx dims, i; |
|
117
|
|
|
|
|
|
|
#else |
|
118
|
|
|
|
|
|
|
int dims, i; |
|
119
|
|
|
|
|
|
|
#endif |
|
120
|
|
|
|
|
|
|
I32 count, ax; |
|
121
|
4700
|
|
|
|
|
|
dSP; |
|
122
|
|
|
|
|
|
|
|
|
123
|
4700
|
|
|
|
|
|
ENTER; |
|
124
|
4700
|
|
|
|
|
|
SAVETMPS; |
|
125
|
|
|
|
|
|
|
|
|
126
|
4700
|
|
|
|
|
|
dims = n; |
|
127
|
|
|
|
|
|
|
|
|
128
|
4700
|
|
|
|
|
|
x_pdl = PDL->pdlnew(); |
|
129
|
4700
|
|
|
|
|
|
PDL->add_deletedata_magic(x_pdl, default_magic, 0); |
|
130
|
4700
|
|
|
|
|
|
PDL->setdims(x_pdl, &dims, 1); |
|
131
|
4700
|
|
|
|
|
|
x_pdl->datatype = PDL_D; |
|
132
|
4700
|
|
|
|
|
|
x_pdl->data = x; |
|
133
|
4700
|
|
|
|
|
|
x_pdl->state |= PDL_DONTTOUCHDATA | PDL_ALLOCATED; |
|
134
|
4700
|
|
|
|
|
|
x_sv = sv_newmortal(); |
|
135
|
4700
|
|
|
|
|
|
PDL->SetSV_PDL(x_sv, x_pdl); |
|
136
|
|
|
|
|
|
|
|
|
137
|
4700
|
|
|
|
|
|
y_pdl = PDL->pdlnew(); |
|
138
|
4700
|
|
|
|
|
|
PDL->add_deletedata_magic(y_pdl, default_magic, 0); |
|
139
|
4700
|
|
|
|
|
|
PDL->setdims(y_pdl, &dims, 1); |
|
140
|
4700
|
|
|
|
|
|
y_pdl->datatype = PDL_D; |
|
141
|
4700
|
|
|
|
|
|
y_pdl->data = y; |
|
142
|
4700
|
|
|
|
|
|
y_pdl->state |= PDL_DONTTOUCHDATA | PDL_ALLOCATED; |
|
143
|
4700
|
|
|
|
|
|
y_sv = sv_newmortal(); |
|
144
|
4700
|
|
|
|
|
|
PDL->SetSV_PDL(y_sv, y_pdl); |
|
145
|
|
|
|
|
|
|
|
|
146
|
4700
|
50
|
|
|
|
|
PUSHMARK(SP); |
|
147
|
4700
|
50
|
|
|
|
|
XPUSHs(x_sv); |
|
148
|
4700
|
50
|
|
|
|
|
XPUSHs(y_sv); |
|
149
|
4700
|
|
|
|
|
|
PUTBACK; |
|
150
|
|
|
|
|
|
|
|
|
151
|
4700
|
|
|
|
|
|
count = call_sv(mapform_subroutine, G_ARRAY); |
|
152
|
|
|
|
|
|
|
|
|
153
|
4700
|
|
|
|
|
|
SPAGAIN; |
|
154
|
4700
|
|
|
|
|
|
SP -= count ; |
|
155
|
4700
|
|
|
|
|
|
ax = (SP - PL_stack_base) + 1; |
|
156
|
|
|
|
|
|
|
|
|
157
|
4700
|
50
|
|
|
|
|
if (count != 2) |
|
158
|
0
|
|
|
|
|
|
croak("mapform: must return two ndarrays"); |
|
159
|
|
|
|
|
|
|
|
|
160
|
4700
|
|
|
|
|
|
tx = (PLFLT*) ((PDL->SvPDLV(ST(0)))->data); |
|
161
|
4700
|
|
|
|
|
|
ty = (PLFLT*) ((PDL->SvPDLV(ST(1)))->data); |
|
162
|
|
|
|
|
|
|
|
|
163
|
14100
|
100
|
|
|
|
|
for (i = 0; i < n; i++) { |
|
164
|
9400
|
|
|
|
|
|
*(x + i) = *(tx + i); |
|
165
|
9400
|
|
|
|
|
|
*(y + i) = *(ty + i); |
|
166
|
|
|
|
|
|
|
} |
|
167
|
|
|
|
|
|
|
|
|
168
|
4700
|
|
|
|
|
|
PUTBACK; |
|
169
|
4700
|
50
|
|
|
|
|
FREETMPS; |
|
170
|
4700
|
|
|
|
|
|
LEAVE; |
|
171
|
4700
|
|
|
|
|
|
} |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
// Subroutines for adding transforms via plstransform |
|
174
|
|
|
|
|
|
|
|
|
175
|
2
|
50
|
|
|
|
|
MAKE_SETTABLE(xform) |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
void |
|
177
|
8715
|
|
|
|
|
|
xform_callback(PLFLT x, PLFLT y, PLFLT *xt, PLFLT *yt, PLPointer data) |
|
178
|
|
|
|
|
|
|
{ |
|
179
|
|
|
|
|
|
|
SV *x_sv, *y_sv; // Perl scalars for the input x and y |
|
180
|
|
|
|
|
|
|
I32 count, ax; |
|
181
|
8715
|
|
|
|
|
|
dSP; |
|
182
|
|
|
|
|
|
|
|
|
183
|
8715
|
|
|
|
|
|
ENTER; |
|
184
|
8715
|
|
|
|
|
|
SAVETMPS; |
|
185
|
|
|
|
|
|
|
|
|
186
|
8715
|
|
|
|
|
|
x_sv = newSVnv((double)x); |
|
187
|
8715
|
|
|
|
|
|
y_sv = newSVnv((double)y); |
|
188
|
|
|
|
|
|
|
|
|
189
|
8715
|
50
|
|
|
|
|
PUSHMARK(SP); |
|
190
|
8715
|
50
|
|
|
|
|
XPUSHs(x_sv); |
|
191
|
8715
|
50
|
|
|
|
|
XPUSHs(y_sv); |
|
192
|
8715
|
50
|
|
|
|
|
XPUSHs(data); |
|
193
|
8715
|
|
|
|
|
|
PUTBACK; |
|
194
|
|
|
|
|
|
|
|
|
195
|
8715
|
|
|
|
|
|
count = call_sv(xform_subroutine, G_ARRAY); |
|
196
|
|
|
|
|
|
|
|
|
197
|
8715
|
|
|
|
|
|
SPAGAIN; |
|
198
|
8715
|
|
|
|
|
|
SP -= count ; |
|
199
|
8715
|
|
|
|
|
|
ax = (SP - PL_stack_base) + 1; |
|
200
|
|
|
|
|
|
|
|
|
201
|
8715
|
50
|
|
|
|
|
if (count != 2) |
|
202
|
0
|
|
|
|
|
|
croak("xform: must return two perl scalars"); |
|
203
|
|
|
|
|
|
|
|
|
204
|
8715
|
|
|
|
|
|
*xt = (PLFLT) SvNV(ST(0)); |
|
205
|
8715
|
|
|
|
|
|
*yt = (PLFLT) SvNV(ST(1)); |
|
206
|
|
|
|
|
|
|
|
|
207
|
8715
|
|
|
|
|
|
PUTBACK; |
|
208
|
8715
|
50
|
|
|
|
|
FREETMPS; |
|
209
|
8715
|
|
|
|
|
|
LEAVE; |
|
210
|
8715
|
|
|
|
|
|
} |
|
211
|
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
// Subroutines for adding label formatting via plslabelfunc |
|
213
|
1
|
50
|
|
|
|
|
MAKE_SETTABLE(labelfunc) |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
214
|
12
|
|
|
|
|
|
void labelfunc_callback(PLINT axis, PLFLT value, char *label_text, PLINT length, void *data) |
|
215
|
|
|
|
|
|
|
{ |
|
216
|
|
|
|
|
|
|
SV *axis_sv, *value_sv, *length_sv; // Perl scalars for inputs |
|
217
|
|
|
|
|
|
|
I32 count, ax; |
|
218
|
12
|
|
|
|
|
|
dSP; |
|
219
|
|
|
|
|
|
|
|
|
220
|
12
|
|
|
|
|
|
ENTER; |
|
221
|
12
|
|
|
|
|
|
SAVETMPS; |
|
222
|
|
|
|
|
|
|
|
|
223
|
12
|
|
|
|
|
|
axis_sv = newSViv((IV)axis); |
|
224
|
12
|
|
|
|
|
|
value_sv = newSVnv((double)value); |
|
225
|
12
|
|
|
|
|
|
length_sv = newSViv((IV)length); |
|
226
|
|
|
|
|
|
|
|
|
227
|
12
|
50
|
|
|
|
|
PUSHMARK(SP); |
|
228
|
12
|
50
|
|
|
|
|
XPUSHs(axis_sv); |
|
229
|
12
|
50
|
|
|
|
|
XPUSHs(value_sv); |
|
230
|
12
|
50
|
|
|
|
|
XPUSHs(length_sv); |
|
231
|
12
|
|
|
|
|
|
PUTBACK; |
|
232
|
|
|
|
|
|
|
|
|
233
|
12
|
|
|
|
|
|
count = call_sv(labelfunc_subroutine, G_ARRAY); |
|
234
|
|
|
|
|
|
|
|
|
235
|
12
|
|
|
|
|
|
SPAGAIN; |
|
236
|
12
|
|
|
|
|
|
SP -= count ; |
|
237
|
12
|
|
|
|
|
|
ax = (SP - PL_stack_base) + 1; |
|
238
|
|
|
|
|
|
|
|
|
239
|
12
|
50
|
|
|
|
|
if (count != 1) |
|
240
|
0
|
|
|
|
|
|
croak("labelfunc: must return one perl scalar"); |
|
241
|
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
// Copy label into output string |
|
243
|
12
|
|
|
|
|
|
strncpy( label_text, (char *)SvPV_nolen(ST(0)), length-1 ); |
|
244
|
12
|
|
|
|
|
|
label_text[length-1] = '\0'; |
|
245
|
|
|
|
|
|
|
|
|
246
|
12
|
|
|
|
|
|
PUTBACK; |
|
247
|
12
|
50
|
|
|
|
|
FREETMPS; |
|
248
|
12
|
|
|
|
|
|
LEAVE; |
|
249
|
12
|
|
|
|
|
|
} |