Rev 8156 | Rev 8162 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
10 | reyssat | 1 | /* Copyright (C) 1998-2003 XIAO, Gang of Universite de Nice - Sophia Antipolis |
2 | * |
||
3 | * This program is free software; you can redistribute it and/or modify |
||
4 | * it under the terms of the GNU General Public License as published by |
||
5 | * the Free Software Foundation; either version 2 of the License, or |
||
6 | * (at your option) any later version. |
||
7 | * |
||
8 | * This program is distributed in the hope that it will be useful, |
||
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
11 | * GNU General Public License for more details. |
||
12 | * |
||
13 | * You should have received a copy of the GNU General Public License |
||
14 | * along with this program; if not, write to the Free Software |
||
15 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
||
16 | */ |
||
8102 | bpr | 17 | #include "flydraw.h" |
10 | reyssat | 18 | #include <errno.h> |
8010 | bpr | 19 | /* bug in gdImageFillToBorder */ |
20 | void gdImageFillToBorder1 (gdImagePtr im, int x, int y, int border, int color) |
||
21 | { |
||
8156 | bpr | 22 | if(x>=im->sx) x=im->sx-1; if(x<0) x=0; |
23 | if(y>=im->sy) y=im->sy-1; if(y<0) y=0; |
||
8076 | bpr | 24 | gdImageFillToBorder(im,x,y,border,color); |
8010 | bpr | 25 | } |
10 | reyssat | 26 | |
8076 | bpr | 27 | void gdImageFillToBorder2 (gdImagePtr im, int x, int y, int border, int color) |
28 | { |
||
8156 | bpr | 29 | if(x>=im->sx || x<0 || y>=im->sy || y<0) return; |
8076 | bpr | 30 | gdImageFillToBorder(im,x,y,border,color); |
31 | } |
||
32 | |||
8156 | bpr | 33 | void gdImageFill2 (gdImagePtr im, int x, int y, int color) |
34 | { |
||
35 | if(x>=im->sx || x<0 || y>=im->sy || y<0) return; |
||
36 | gdImageFill(im,x,y,color); |
||
37 | } |
||
8076 | bpr | 38 | |
8156 | bpr | 39 | |
7675 | bpr | 40 | /* File opening: with security */ |
10 | reyssat | 41 | FILE *open4read(char *n) |
42 | { |
||
43 | char *p, *p1, *p2, namebuf[2048]; |
||
44 | int t; |
||
45 | FILE *f; |
||
46 | n=find_word_start(n); |
||
47 | if(*n==0) return NULL; |
||
48 | p=getenv("flydraw_filebase"); |
||
49 | p1=n+strlen(n)-4;if(p1<n || strcasecmp(p1,".gif")!=0) t=1; else t=0; |
||
50 | if(p!=NULL && *p!=0) { |
||
7675 | bpr | 51 | char pbuf[MAX_LINELEN+1]; |
52 | snprintf(pbuf,sizeof(pbuf),"%s",p); |
||
53 | p=find_word_start(pbuf); if(strstr(p,"..")!=NULL) return NULL; |
||
54 | if(*n=='/' || strstr(n,"..")!=NULL) return NULL; |
||
55 | /* prohibit unusual file/dir names */ |
||
56 | for(p1=p;*p1;p1++) |
||
57 | if(!isalnum(*p1) && !isspace(*p1) && strchr("~_-/.",*p1)==NULL) |
||
58 | return NULL; |
||
59 | for(p1=n;*p1;p1++) |
||
60 | if(!isalnum(*p1) && !isspace(*p1) && strchr("~_-/.",*p1)==NULL) |
||
61 | return NULL; |
||
62 | f=NULL; |
||
63 | for(p1=p; *p1; p1=find_word_start(p2)) { |
||
64 | p2=find_word_end(p1); |
||
65 | if(*p2) *p2++=0; |
||
66 | snprintf(namebuf,sizeof(namebuf),"%s/%s",p1,n); |
||
67 | f=fopen(namebuf,"r"); if(f!=NULL) goto imgtype; |
||
68 | } |
||
69 | p1=getenv("w_wims_session"); |
||
70 | if(p1!=NULL && strncmp(n,"insert",6)==0) { |
||
71 | snprintf(namebuf,sizeof(namebuf),"../s2/%s/%s",p1,n); |
||
72 | f=fopen(namebuf,"r"); |
||
73 | } |
||
10 | reyssat | 74 | } |
75 | else { |
||
7675 | bpr | 76 | snprintf(namebuf,sizeof(namebuf),"%s",n); |
77 | f=fopen(namebuf,"r"); |
||
10 | reyssat | 78 | } |
79 | imgtype: |
||
80 | if(t && f!=NULL) { |
||
7675 | bpr | 81 | char tbuf[1024],sbuf[4096]; |
82 | fclose(f); f=NULL; |
||
83 | p1=getenv("TMPDIR"); if(p1==NULL || *p1==0) p1="."; |
||
84 | snprintf(tbuf,sizeof(tbuf),"%s/drawfile_.gif",p1); |
||
85 | snprintf(sbuf,sizeof(sbuf),"convert %s %s",namebuf,tbuf); |
||
86 | if (system(sbuf)) error("system_failed"); |
||
7615 | bpr | 87 | f=fopen(tbuf,"r"); |
10 | reyssat | 88 | } |
89 | return f; |
||
90 | } |
||
91 | |||
7675 | bpr | 92 | /* Does nothing; just a comment. */ |
10 | reyssat | 93 | void obj_comment(objparm *pm) |
94 | { |
||
95 | return; |
||
96 | } |
||
97 | |||
7675 | bpr | 98 | /* define image size */ |
10 | reyssat | 99 | void obj_size(objparm *pm) |
100 | { |
||
101 | sizex=rint(pm->pd[0]); sizey=rint(pm->pd[1]); |
||
102 | if(sizex<0 || sizey<0 || sizex>MAX_SIZE || sizey>MAX_SIZE) { |
||
7675 | bpr | 103 | error("bad_size"); return; |
10 | reyssat | 104 | } |
105 | if(image!=NULL) { |
||
7675 | bpr | 106 | error("size_already_defined"); return; |
10 | reyssat | 107 | } |
108 | image=gdImageCreate(sizex,sizey); |
||
109 | if(image==NULL) error("image_creation_failure"); |
||
110 | else { |
||
7675 | bpr | 111 | color_white=gdImageColorAllocate(image,255,255,255); |
112 | color_black=gdImageColorAllocate(image,0,0,0); |
||
113 | color_bounder=gdImageColorAllocate(image,1,2,3); |
||
8158 | bpr | 114 | color_frame=gdImageColorAllocate(image,254,254,254); |
10 | reyssat | 115 | } |
116 | } |
||
117 | |||
7675 | bpr | 118 | /* new image */ |
10 | reyssat | 119 | void obj_new(objparm *pm) |
120 | { |
||
121 | if(image) { |
||
7675 | bpr | 122 | gdImageDestroy(image);image=NULL; |
10 | reyssat | 123 | } |
8158 | bpr | 124 | if(pm->pcnt>=2) { obj_size(pm); gdImageRectangle(image,0,0,sizex-1,sizey-1,color_frame);} |
10 | reyssat | 125 | else sizex=sizey=0; |
126 | saved=0; |
||
127 | } |
||
128 | |||
7675 | bpr | 129 | /* new image */ |
10 | reyssat | 130 | void obj_existing(objparm *pm) |
131 | { |
||
132 | FILE *inf; |
||
133 | char *pp; |
||
7615 | bpr | 134 | |
10 | reyssat | 135 | if(image) { |
7675 | bpr | 136 | gdImageDestroy(image);image=NULL; |
10 | reyssat | 137 | } |
138 | pp=find_word_start(pm->str);*find_word_end(pp)=0; |
||
139 | inf=open4read(pp); |
||
140 | if(inf==NULL) { |
||
7675 | bpr | 141 | error("file_not_exist"); return; |
10 | reyssat | 142 | } |
143 | image=gdImageCreateFromGif(inf); fclose(inf); |
||
144 | if(image==NULL) { |
||
7675 | bpr | 145 | error("bad_gif"); return; |
10 | reyssat | 146 | } |
147 | sizex=image->sx; sizey=image->sy; |
||
148 | saved=0; |
||
149 | } |
||
150 | |||
7675 | bpr | 151 | /* solid line */ |
10 | reyssat | 152 | void obj_line(objparm *pm) |
153 | { |
||
154 | scale(pm->pd,pm->p,2); |
||
155 | gdImageLine(image,pm->p[0],pm->p[1],pm->p[2],pm->p[3],pm->color[0]); |
||
1024 | bpr | 156 | if(vimg_enable) vimg_line(scale_buf[0],scale_buf[1],scale_buf[2],scale_buf[3]); |
10 | reyssat | 157 | } |
158 | |||
1024 | bpr | 159 | void _obj_arrow(objparm *pm, int twoside) |
10 | reyssat | 160 | { |
161 | int l,ii[6],xx,yy; |
||
162 | double dx,dy,length,dd[6]; |
||
7615 | bpr | 163 | scale(pm->pd,pm->p,2); |
10 | reyssat | 164 | xx=ii[0]=pm->p[2];yy=ii[1]=pm->p[3]; |
165 | l=pm->pd[4];if(l<0) l=0; if(l>200) l=200; |
||
166 | scale2(pm->pd[0]-pm->pd[2],pm->pd[1]-pm->pd[3],&dx,&dy); |
||
167 | length=sqrt(dx*dx+dy*dy); |
||
168 | if(length<3 || l<5) goto stem; |
||
169 | dd[0]=l*dx/length; dd[1]=l*dy/length; |
||
170 | #define fat 0.27 |
||
171 | dd[2]=dd[0]+dd[1]*fat; dd[3]=dd[1]-dd[0]*fat; |
||
172 | dd[4]=dd[0]-dd[1]*fat; dd[5]=dd[1]+dd[0]*fat; |
||
173 | ii[2]=rint(dd[2])+ii[0]; ii[3]=rint(dd[3])+ii[1]; |
||
174 | ii[4]=rint(dd[4])+ii[0]; ii[5]=rint(dd[5])+ii[1]; |
||
175 | gdImageFilledPolygon(image,(gdPointPtr) ii,3,pm->color[0]); |
||
176 | xx=rint(dd[0])+ii[0];yy=rint(dd[1])+ii[1]; |
||
1024 | bpr | 177 | if(twoside) { |
7675 | bpr | 178 | ii[0]=pm->p[0]; ii[1]=pm->p[1]; |
179 | ii[2]=-rint(dd[2])+ii[0]; ii[3]=-rint(dd[3])+ii[1]; |
||
180 | ii[4]=-rint(dd[4])+ii[0]; ii[5]=-rint(dd[5])+ii[1]; |
||
181 | gdImageFilledPolygon(image,(gdPointPtr) ii,3,pm->color[0]); |
||
1024 | bpr | 182 | } |
10 | reyssat | 183 | stem: if(pm->fill) |
184 | gdImageDashedLine(image,pm->p[0],pm->p[1],xx,yy,pm->color[0]); |
||
185 | else |
||
186 | gdImageLine(image,pm->p[0],pm->p[1],xx,yy,pm->color[0]); |
||
1024 | bpr | 187 | if(vimg_enable) vimg_line(scale_buf[0],scale_buf[1],scale_buf[2],scale_buf[3]); |
10 | reyssat | 188 | } |
189 | |||
7675 | bpr | 190 | /* Arrow */ |
1024 | bpr | 191 | void obj_arrow(objparm *pm) |
192 | { |
||
193 | _obj_arrow(pm,0); |
||
194 | } |
||
195 | |||
7675 | bpr | 196 | /* 2-sided arrow */ |
1024 | bpr | 197 | void obj_arrow2(objparm *pm) |
198 | { |
||
199 | _obj_arrow(pm,1); |
||
200 | } |
||
201 | |||
7675 | bpr | 202 | /* horizontal line */ |
10 | reyssat | 203 | void obj_hline(objparm *pm) |
204 | { |
||
205 | scale(pm->pd,pm->p,1); |
||
206 | if(pm->fill) |
||
207 | gdImageDashedLine(image,0,pm->p[1],sizex,pm->p[1],pm->color[0]); |
||
208 | else |
||
209 | gdImageLine(image,0,pm->p[1],sizex,pm->p[1],pm->color[0]); |
||
210 | } |
||
211 | |||
7675 | bpr | 212 | /* vertical line */ |
10 | reyssat | 213 | void obj_vline(objparm *pm) |
214 | { |
||
215 | scale(pm->pd,pm->p,1); |
||
216 | if(pm->fill) |
||
217 | gdImageDashedLine(image,pm->p[0],0,pm->p[0],sizey,pm->color[0]); |
||
218 | else |
||
219 | gdImageLine(image,pm->p[0],0,pm->p[0],sizey,pm->color[0]); |
||
220 | } |
||
221 | |||
7675 | bpr | 222 | /* dashed line */ |
10 | reyssat | 223 | void obj_dline(objparm *pm) |
224 | { |
||
225 | scale(pm->pd,pm->p,2); |
||
226 | gdImageDashedLine(image,pm->p[0],pm->p[1],pm->p[2],pm->p[3], |
||
7675 | bpr | 227 | pm->color[0]); |
10 | reyssat | 228 | } |
229 | |||
7675 | bpr | 230 | /* parallel lines. |
231 | * x1,y1,x2,y2,xv,yv,n,color */ |
||
10 | reyssat | 232 | void obj_parallel(objparm *pm) |
233 | { |
||
234 | int i, n, xi,yi; |
||
235 | double xv,yv; |
||
236 | n=pm->pd[6]; if(n<0) return; if(n>256) n=256; |
||
1122 | bpr | 237 | scale(pm->pd,pm->p,3); |
10 | reyssat | 238 | scale2(pm->pd[4],pm->pd[5],&xv,&yv); |
239 | for(i=0;i<n;i++) { |
||
7675 | bpr | 240 | xi=rint(i*xv); yi=rint(i*yv); |
241 | gdImageLine(image,pm->p[0]+xi,pm->p[1]+yi,pm->p[2]+xi,pm->p[3]+yi, |
||
242 | pm->color[0]); |
||
243 | if(vimg_enable) vimg_line(scale_buf[0]+i*(scale_buf[4]-transx), |
||
244 | scale_buf[1]+i*(scale_buf[5]-transy), |
||
245 | scale_buf[2]+i*(scale_buf[4]-transx), |
||
246 | scale_buf[3]+i*(scale_buf[5]-transy)); |
||
10 | reyssat | 247 | } |
248 | } |
||
249 | |||
7675 | bpr | 250 | /* rectangle */ |
10 | reyssat | 251 | void obj_rect(objparm *pm) |
252 | { |
||
253 | int x1,y1,x2,y2; |
||
254 | scale(pm->pd,pm->p,2); |
||
255 | x1=min(pm->p[0],pm->p[2]); x2=max(pm->p[0],pm->p[2]); |
||
256 | y1=min(pm->p[1],pm->p[3]); y2=max(pm->p[1],pm->p[3]); |
||
257 | if(pm->fill) |
||
258 | gdImageFilledRectangle(image,x1,y1,x2,y2,pm->color[0]); |
||
259 | else |
||
260 | gdImageRectangle(image,x1,y1,x2,y2,pm->color[0]); |
||
1024 | bpr | 261 | if(vimg_enable) vimg_rect(scale_buf[0],scale_buf[1],scale_buf[2],scale_buf[3]); |
10 | reyssat | 262 | } |
263 | |||
7675 | bpr | 264 | /* square */ |
10 | reyssat | 265 | void obj_square(objparm *pm) |
266 | { |
||
267 | int w,h; |
||
268 | scale(pm->pd,pm->p,1); |
||
269 | w=rint(pm->pd[2]); h=rint(pm->pd[2]); |
||
270 | if(pm->fill) |
||
271 | gdImageFilledRectangle(image,pm->p[0],pm->p[1], |
||
7675 | bpr | 272 | pm->p[0]+w,pm->p[1]+h,pm->color[0]); |
10 | reyssat | 273 | else |
274 | gdImageRectangle(image,pm->p[0],pm->p[1], |
||
7675 | bpr | 275 | pm->p[0]+w,pm->p[1]+h,pm->color[0]); |
1024 | bpr | 276 | if(vimg_enable) vimg_rect(scale_buf[0],scale_buf[1], |
7675 | bpr | 277 | scale_buf[0]+pm->pd[2],scale_buf[1]+pm->pd[2]); |
10 | reyssat | 278 | } |
279 | |||
7675 | bpr | 280 | /* triangle */ |
10 | reyssat | 281 | void obj_triangle(objparm *pm) |
282 | { |
||
283 | scale(pm->pd,pm->p,3); |
||
284 | if(pm->fill) |
||
285 | gdImageFilledPolygon(image,(gdPointPtr) pm->p,3,pm->color[0]); |
||
286 | else |
||
287 | gdImagePolygon(image,(gdPointPtr) pm->p,3,pm->color[0]); |
||
1024 | bpr | 288 | if(vimg_enable) vimg_polyline(scale_buf,3,1); |
10 | reyssat | 289 | } |
290 | |||
7675 | bpr | 291 | /* polygon */ |
10 | reyssat | 292 | void obj_poly(objparm *pm) |
293 | { |
||
294 | int cnt; |
||
295 | cnt=(pm->pcnt)/2; |
||
296 | scale(pm->pd,pm->p,cnt); |
||
297 | if(pm->fill) |
||
298 | gdImageFilledPolygon(image,(gdPointPtr) pm->p,cnt,pm->color[0]); |
||
299 | else |
||
300 | gdImagePolygon(image,(gdPointPtr) pm->p,cnt,pm->color[0]); |
||
1024 | bpr | 301 | if(vimg_enable) vimg_polyline(scale_buf,cnt,1); |
10 | reyssat | 302 | } |
303 | |||
7675 | bpr | 304 | /* rays */ |
10 | reyssat | 305 | void obj_rays(objparm *pm) |
306 | { |
||
307 | int i, n; |
||
308 | n=(pm->pcnt)/2; |
||
309 | scale(pm->pd,pm->p,n); |
||
1024 | bpr | 310 | for(i=2;i<2*n;i+=2) { |
7675 | bpr | 311 | gdImageLine(image,pm->p[0],pm->p[1],pm->p[i],pm->p[i+1],pm->color[0]); |
312 | if(vimg_enable) vimg_line(scale_buf[0],scale_buf[1], |
||
313 | scale_buf[i],scale_buf[i+1]); |
||
1024 | bpr | 314 | } |
10 | reyssat | 315 | } |
316 | |||
7675 | bpr | 317 | /* segments */ |
10 | reyssat | 318 | void obj_lines(objparm *pm) |
319 | { |
||
320 | int i, n; |
||
321 | n=(pm->pcnt)/2; |
||
322 | scale(pm->pd,pm->p,n); |
||
7615 | bpr | 323 | for(i=2;i<2*n;i+=2) |
10 | reyssat | 324 | gdImageLine(image,pm->p[i-2],pm->p[i-1],pm->p[i],pm->p[i+1],pm->color[0]); |
1024 | bpr | 325 | if(vimg_enable) vimg_polyline(scale_buf,n,0); |
10 | reyssat | 326 | } |
327 | |||
7675 | bpr | 328 | /* segments */ |
10 | reyssat | 329 | void obj_dlines(objparm *pm) |
330 | { |
||
331 | int i, n; |
||
332 | n=(pm->pcnt)/2; |
||
333 | scale(pm->pd,pm->p,n); |
||
334 | for(i=2;i<2*n;i+=2) |
||
335 | gdImageDashedLine(image,pm->p[i-2],pm->p[i-1],pm->p[i],pm->p[i+1],pm->color[0]); |
||
1024 | bpr | 336 | if(vimg_enable) vimg_polyline(scale_buf,n,0); |
10 | reyssat | 337 | } |
338 | |||
7675 | bpr | 339 | /* points */ |
10 | reyssat | 340 | void obj_points(objparm *pm) |
341 | { |
||
342 | int i, n; |
||
343 | n=(pm->pcnt)/2; |
||
344 | scale(pm->pd,pm->p,n); |
||
345 | for(i=0;i<2*n;i+=2) |
||
346 | gdImageSetPixel(image,pm->p[i],pm->p[i+1],pm->color[0]); |
||
347 | } |
||
348 | |||
7675 | bpr | 349 | /* lattice. |
350 | * x0,y0,xv1,yv1,xv2,yv2,n1,n2,color */ |
||
10 | reyssat | 351 | void obj_lattice(objparm *pm) |
352 | { |
||
353 | int n1,n2,i1,i2,xi1,yi1,xi2,yi2; |
||
354 | double xv1,xv2,yv1,yv2; |
||
355 | n1=pm->pd[6];n2=pm->pd[7]; if(n1<0 || n2<0) return; |
||
356 | if(n1>256) n1=256; if(n2>256) n2=256; |
||
357 | scale(pm->pd,pm->p,1); |
||
358 | scale2(pm->pd[2],pm->pd[3],&xv1,&yv1); |
||
359 | scale2(pm->pd[4],pm->pd[5],&xv2,&yv2); |
||
360 | for(i1=0;i1<n1;i1++) { |
||
7675 | bpr | 361 | xi1=rint(i1*xv1)+pm->p[0]; yi1=rint(i1*yv1)+pm->p[1]; |
362 | for(i2=0;i2<n2;i2++) { |
||
363 | xi2=i2*xv2+xi1;yi2=i2*yv2+yi1; |
||
364 | gdImageSetPixel(image,xi2,yi2,pm->color[0]); |
||
365 | } |
||
10 | reyssat | 366 | } |
367 | } |
||
368 | |||
7675 | bpr | 369 | /* arc */ |
10 | reyssat | 370 | void obj_arc(objparm *pm) |
371 | { |
||
372 | scale(pm->pd,pm->p,1); |
||
373 | pm->p[2]=rint(pm->pd[2]*xscale); pm->p[3]=rint(pm->pd[3]*yscale); |
||
374 | gdImageArc(image,pm->p[0],pm->p[1],pm->p[2],pm->p[3], |
||
7675 | bpr | 375 | pm->pd[4],pm->pd[5],pm->color[0]); |
1024 | bpr | 376 | if(vimg_enable) vimg_arc(scale_buf[0],scale_buf[1], |
7675 | bpr | 377 | 0.5*pm->pd[2],0.5*pm->pd[3],pm->pd[4],pm->pd[5]); |
10 | reyssat | 378 | } |
379 | |||
7675 | bpr | 380 | /* Ellipse: centre 0,1, width 2, hight 3, color 4,5,6 */ |
10 | reyssat | 381 | void obj_ellipse(objparm *pm) |
382 | { |
||
383 | scale(pm->pd,pm->p,1); |
||
384 | pm->p[2]=rint(pm->pd[2]*xscale); pm->p[3]=rint(pm->pd[3]*yscale); |
||
385 | if(pm->fill) { |
||
7675 | bpr | 386 | gdImageArc(image,pm->p[0],pm->p[1],pm->p[2],pm->p[3],0,360, |
387 | color_bounder); |
||
8076 | bpr | 388 | gdImageFillToBorder2(image,pm->p[0],pm->p[1], |
7675 | bpr | 389 | color_bounder,pm->color[0]); |
10 | reyssat | 390 | } |
391 | gdImageArc(image,pm->p[0],pm->p[1],pm->p[2],pm->p[3],0,360,pm->color[0]); |
||
1024 | bpr | 392 | if(vimg_enable) vimg_ellipse(scale_buf[0],scale_buf[1],0.5*pm->pd[2],0.5*pm->pd[3]); |
10 | reyssat | 393 | } |
394 | |||
7675 | bpr | 395 | /* Circle */ |
10 | reyssat | 396 | void obj_circle(objparm *pm) |
397 | { |
||
398 | scale(pm->pd,pm->p,1); |
||
399 | pm->p[2]=rint(pm->pd[2]); pm->p[3]=rint(pm->pd[2]); |
||
400 | if(pm->fill) { |
||
7675 | bpr | 401 | gdImageArc(image,pm->p[0],pm->p[1],pm->p[2],pm->p[3],0,360, |
402 | color_bounder); |
||
8076 | bpr | 403 | gdImageFillToBorder2(image,pm->p[0],pm->p[1], |
7675 | bpr | 404 | color_bounder,pm->color[0]); |
10 | reyssat | 405 | } |
406 | gdImageArc(image,pm->p[0],pm->p[1],pm->p[2],pm->p[3],0,360,pm->color[0]); |
||
407 | } |
||
408 | |||
7675 | bpr | 409 | /* flood fill */ |
10 | reyssat | 410 | void obj_fill(objparm *pm) |
411 | { |
||
412 | scale(pm->pd,pm->p,1); |
||
8156 | bpr | 413 | gdImageFill2(image,pm->p[0],pm->p[1],pm->color[0]); |
10 | reyssat | 414 | } |
415 | |||
7675 | bpr | 416 | /* flood fill to border*/ |
10 | reyssat | 417 | void obj_fillb(objparm *pm) |
418 | { |
||
419 | scale(pm->pd,pm->p,1); |
||
8010 | bpr | 420 | gdImageFillToBorder1(image,pm->p[0],pm->p[1],pm->color[0],pm->color[1]); |
10 | reyssat | 421 | } |
422 | |||
423 | gdImagePtr himg; |
||
424 | |||
425 | int makehatchimage(int x, int y, int px, int py, int col) |
||
426 | { |
||
427 | int c1,c2,r,g,b; |
||
428 | gdImagePtr saveimg; |
||
429 | himg=gdImageCreate(x,y); |
||
430 | c1=gdImageGetPixel(image,px,py); |
||
431 | r=gdImageRed(image,c1); g=gdImageGreen(image,c1); b=gdImageBlue(image,c1); |
||
432 | if(r>=255) r--; else r++; if(g>=255) g--; else g++; if(b>=255) b--; else b++; |
||
433 | c1=gdImageColorAllocate(himg,r,g,b); |
||
434 | r=gdImageRed(image,col); g=gdImageGreen(image,col); b=gdImageBlue(image,col); |
||
435 | c2=gdImageColorAllocate(himg,r,g,b); |
||
436 | if(width>1) { |
||
7675 | bpr | 437 | savew=-1; saveimg=image; |
438 | image=himg; c2=widthcolor(width,c2); image=saveimg; |
||
439 | c2=gdBrushed; savew=-1; |
||
10 | reyssat | 440 | } |
441 | return c2; |
||
442 | } |
||
443 | |||
7675 | bpr | 444 | /* flood fill with hatching */ |
10 | reyssat | 445 | void obj_hatchfill(objparm *pm) |
446 | { |
||
447 | int nx,ny,ax,ay, dir, c; |
||
448 | scale(pm->pd,pm->p,1); |
||
449 | nx=pm->pd[2]; ny=pm->pd[3]; ax=abs(nx); ay=abs(ny); |
||
450 | if(nx==0 && ny==0) {error("bad displacement vector"); return;} |
||
451 | if((nx>0 && ny>0) || (nx<0 && ny<0)) dir=1; else dir=-1; |
||
452 | if(ax==0) {ax=100; dir=2;} |
||
453 | if(ay==0) {ay=100; dir=3;} |
||
454 | c=makehatchimage(ax,ay,pm->p[0],pm->p[1],pm->color[0]); |
||
455 | switch(dir) { |
||
7675 | bpr | 456 | case -1: { |
457 | gdImageLine(himg,0,ay-1,ax-1,0,c); |
||
458 | if(width>1) { |
||
459 | gdImageLine(himg,-ax,ay-1,-1,0,c); |
||
460 | gdImageLine(himg,ax,ay-1,2*ax-1,0,c); |
||
461 | gdImageLine(himg,0,-1,ax-1,-ay,c); |
||
462 | gdImageLine(himg,0,2*ay-1,ax-1,ay,c); |
||
463 | } |
||
464 | break; |
||
465 | } |
||
466 | case 1: { |
||
467 | gdImageLine(himg,0,0,ax-1,ay-1,c); |
||
468 | if(width>1) { |
||
469 | gdImageLine(himg,-ax,0,-1,ay-1,c); |
||
470 | gdImageLine(himg,ax,0,2*ax-1,ay-1,c); |
||
471 | gdImageLine(himg,0,-ay,ax-1,-1,c); |
||
472 | gdImageLine(himg,0,ay,ax-1,2*ay-1,c); |
||
473 | } |
||
474 | break; |
||
475 | } |
||
476 | case 2: gdImageLine(himg,0,ay/2,ax-1,ay/2,c); break; |
||
477 | case 3: gdImageLine(himg,ax/2,0,ax/2,ay-1,c); break; |
||
10 | reyssat | 478 | } |
479 | gdImageSetTile(image,himg); |
||
8156 | bpr | 480 | gdImageFill2(image,pm->p[0],pm->p[1],gdTiled); |
10 | reyssat | 481 | gdImageDestroy(himg); |
482 | if(tiled) gdImageSetTile(image,tileimg); |
||
483 | } |
||
484 | |||
7675 | bpr | 485 | /* flood fill with grid */ |
10 | reyssat | 486 | void obj_gridfill(objparm *pm) |
487 | { |
||
488 | int nx,ny, c; |
||
489 | scale(pm->pd,pm->p,1); |
||
490 | nx=pm->pd[2]; ny=pm->pd[3]; nx=abs(nx); ny=abs(ny); |
||
491 | if(nx==0 && ny==0) {error("bad grid size"); return;} |
||
492 | c=makehatchimage(nx,ny,pm->p[0],pm->p[1],pm->color[0]); |
||
493 | gdImageLine(himg,0,ny/2,nx-1,ny/2,c); gdImageLine(himg,nx/2,0,nx/2,ny-1,c); |
||
494 | gdImageSetTile(image,himg); |
||
8156 | bpr | 495 | gdImageFill2(image,pm->p[0],pm->p[1],gdTiled); |
10 | reyssat | 496 | gdImageDestroy(himg); |
497 | if(tiled) gdImageSetTile(image,tileimg); |
||
498 | } |
||
499 | |||
7675 | bpr | 500 | /* flood fill with double hatching */ |
10 | reyssat | 501 | void obj_diafill(objparm *pm) |
502 | { |
||
503 | int nx,ny, c; |
||
504 | scale(pm->pd,pm->p,1); |
||
505 | nx=pm->pd[2]; ny=pm->pd[3]; nx=abs(nx); ny=abs(ny); |
||
506 | if(nx==0 && ny==0) {error("bad grid size"); return;} |
||
507 | c=makehatchimage(nx,ny,pm->p[0],pm->p[1],pm->color[0]); |
||
508 | gdImageLine(himg,0,0,nx-1,ny-1,c); gdImageLine(himg,0,ny-1,nx-1,0,c); |
||
509 | gdImageSetTile(image,himg); |
||
8156 | bpr | 510 | gdImageFill2(image,pm->p[0],pm->p[1],gdTiled); |
10 | reyssat | 511 | gdImageDestroy(himg); |
512 | if(tiled) gdImageSetTile(image,tileimg); |
||
513 | } |
||
514 | |||
7675 | bpr | 515 | /* flood fill with double hatching */ |
10 | reyssat | 516 | void obj_dotfill(objparm *pm) |
517 | { |
||
518 | int nx,ny, c; |
||
519 | scale(pm->pd,pm->p,1); |
||
520 | nx=pm->pd[2]; ny=pm->pd[3]; nx=abs(nx); ny=abs(ny); |
||
521 | if(nx==0 && ny==0) {error("bad grid size"); return;} |
||
522 | c=makehatchimage(nx,ny,pm->p[0],pm->p[1],pm->color[0]); |
||
523 | gdImageSetPixel(himg,nx/2,ny/2,c); |
||
524 | gdImageSetTile(image,himg); |
||
8156 | bpr | 525 | gdImageFill2(image,pm->p[0],pm->p[1],gdTiled); |
10 | reyssat | 526 | gdImageDestroy(himg); |
527 | if(tiled) gdImageSetTile(image,tileimg); |
||
528 | } |
||
529 | |||
530 | struct { |
||
531 | char *name; |
||
532 | gdFontPtr *fpt; |
||
533 | } fonttab[]={ |
||
7675 | bpr | 534 | {"tiny", &gdFontTiny}, |
535 | {"small", &gdFontSmall}, |
||
10 | reyssat | 536 | {"medium",&gdFontMediumBold}, |
7675 | bpr | 537 | {"large", &gdFontLarge}, |
538 | {"giant", &gdFontGiant}, |
||
539 | {"huge", &gdFontGiant} |
||
10 | reyssat | 540 | }; |
541 | |||
542 | #define fonttab_no (sizeof(fonttab)/sizeof(fonttab[0])) |
||
543 | |||
7675 | bpr | 544 | /* string */ |
10 | reyssat | 545 | void obj_string(objparm *pm) |
546 | { |
||
547 | char *pp, *pe, *p2; |
||
548 | int i; |
||
549 | pp=pm->str; pe=strchr(pp,','); if(pe==NULL) { |
||
7675 | bpr | 550 | error("too_few_parms"); return; |
10 | reyssat | 551 | } |
552 | *pe++=0; pp=find_word_start(pp); *find_word_end(pp)=0; |
||
553 | pe=find_word_start(pe); strip_trailing_spaces(pe); |
||
554 | if(*pp) { |
||
7675 | bpr | 555 | for(i=0;i<fonttab_no && strcmp(pp,fonttab[i].name)!=0; i++); |
556 | if(i>=fonttab_no) i=1; |
||
10 | reyssat | 557 | } |
558 | else i=1; |
||
559 | scale(pm->pd,pm->p,1); |
||
560 | if(*pe=='"') { |
||
7675 | bpr | 561 | p2=strchr(pe+1,'"'); |
562 | if(p2 && *(p2+1)==0) {*p2=0; pe++;} |
||
10 | reyssat | 563 | } |
564 | if(pm->fill) |
||
7615 | bpr | 565 | gdImageStringUp(image,*(fonttab[i].fpt),pm->p[0],pm->p[1], (unsigned char*) pe, |
7675 | bpr | 566 | pm->color[0]); |
10 | reyssat | 567 | else |
7615 | bpr | 568 | gdImageString(image,*(fonttab[i].fpt),pm->p[0],pm->p[1], (unsigned char*) pe, |
7675 | bpr | 569 | pm->color[0]); |
10 | reyssat | 570 | } |
571 | |||
7675 | bpr | 572 | /* point */ |
10 | reyssat | 573 | void obj_point(objparm *pm) |
574 | { |
||
575 | scale(pm->pd,pm->p,1); |
||
576 | gdImageSetPixel(image,pm->p[0],pm->p[1],pm->color[0]); |
||
577 | } |
||
578 | |||
7675 | bpr | 579 | /* copy an image file */ |
10 | reyssat | 580 | void obj_copy(objparm *pm) |
581 | { |
||
582 | char *pp; |
||
583 | FILE *inf; |
||
7675 | bpr | 584 | gdImagePtr insimg; |
7615 | bpr | 585 | |
10 | reyssat | 586 | pp=find_word_start(pm->str);*find_word_end(pp)=0; |
587 | inf=open4read(pp); |
||
588 | if(inf==NULL) { |
||
7675 | bpr | 589 | error("file_not_exist"); return; |
10 | reyssat | 590 | } |
591 | insimg=gdImageCreateFromGif(inf); fclose(inf); |
||
592 | if(insimg==NULL) { |
||
7675 | bpr | 593 | error("bad_gif"); return; |
10 | reyssat | 594 | } |
595 | scale(pm->pd,pm->p,1); |
||
7615 | bpr | 596 | if(pm->pd[2]<0 && pm->pd[3]<0 && pm->pd[4]<0 && pm->pd[5]<0) |
10 | reyssat | 597 | gdImageCopy(image,insimg,pm->p[0],pm->p[1],0,0, |
7675 | bpr | 598 | insimg->sx,insimg->sy); |
10 | reyssat | 599 | else |
600 | gdImageCopy(image,insimg,pm->p[0],pm->p[1],pm->pd[2],pm->pd[3], |
||
7675 | bpr | 601 | pm->pd[4]-pm->pd[2],pm->pd[5]-pm->pd[3]); |
10 | reyssat | 602 | gdImageDestroy(insimg); |
603 | } |
||
604 | |||
7675 | bpr | 605 | /* copy an image file, with resizing */ |
10 | reyssat | 606 | void obj_copyresize(objparm *pm) |
607 | { |
||
608 | char *pp; |
||
609 | FILE *inf; |
||
7675 | bpr | 610 | gdImagePtr insimg; |
7615 | bpr | 611 | |
10 | reyssat | 612 | pp=find_word_start(pm->str);*find_word_end(pp)=0; |
613 | inf=open4read(pp); |
||
614 | if(inf==NULL) { |
||
7675 | bpr | 615 | error("file_not_found"); return; |
10 | reyssat | 616 | } |
617 | insimg=gdImageCreateFromGif(inf); fclose(inf); |
||
618 | if(insimg==NULL) { |
||
7675 | bpr | 619 | error("bad_gif"); return; |
10 | reyssat | 620 | } |
621 | scale(pm->pd+4,pm->p+4,2); |
||
7615 | bpr | 622 | if(pm->pd[0]<0 && pm->pd[1]<0 && pm->pd[2]<0 && pm->pd[3]<0) |
10 | reyssat | 623 | gdImageCopyResized(image,insimg,pm->p[4],pm->p[5],0,0, |
7675 | bpr | 624 | pm->p[6]-pm->p[4]+1,pm->p[7]-pm->p[5]+1, |
625 | insimg->sx,insimg->sy); |
||
10 | reyssat | 626 | else |
627 | gdImageCopyResized(image,insimg,pm->p[4],pm->p[5],pm->pd[0],pm->pd[1], |
||
7675 | bpr | 628 | pm->p[6]-pm->p[4]+1,pm->p[7]-pm->p[5]+1, |
629 | pm->pd[2]-pm->pd[0]+1,pm->pd[3]-pm->pd[1]+1); |
||
10 | reyssat | 630 | gdImageDestroy(insimg); |
631 | } |
||
632 | |||
7675 | bpr | 633 | /* set brush or tile */ |
10 | reyssat | 634 | void obj_setbrush(objparm *pm) |
635 | { |
||
636 | char *pp; |
||
637 | FILE *inf; |
||
638 | gdImagePtr insimg; |
||
639 | |||
640 | pp=find_word_start(pm->str); *find_word_end(pp)=0; |
||
641 | inf=open4read(pp); if(inf==NULL) { |
||
7675 | bpr | 642 | error("file_not_found"); return; |
10 | reyssat | 643 | } |
644 | insimg=gdImageCreateFromGif(inf); fclose(inf); |
||
645 | if(insimg==NULL) { |
||
7675 | bpr | 646 | error("bad_gif"); return; |
10 | reyssat | 647 | } |
648 | if(pm->fill) { |
||
7675 | bpr | 649 | gdImageSetTile(image,insimg); tiled=1; tileimg=insimg; |
10 | reyssat | 650 | } |
651 | else { |
||
7675 | bpr | 652 | gdImageSetBrush(image,insimg);brushed=1; brushimg=insimg; |
10 | reyssat | 653 | } |
654 | } |
||
655 | |||
7675 | bpr | 656 | /* kill brush */ |
10 | reyssat | 657 | void obj_killbrush(objparm *pm) |
658 | { |
||
659 | if(brushimg) gdImageDestroy(brushimg); |
||
660 | brushed=0; brushimg=NULL; |
||
661 | } |
||
662 | |||
7675 | bpr | 663 | /* kill tile */ |
10 | reyssat | 664 | void obj_killtile(objparm *pm) |
665 | { |
||
666 | if(tileimg) gdImageDestroy(tileimg); |
||
667 | tiled=0; tileimg=NULL; |
||
668 | } |
||
669 | |||
7675 | bpr | 670 | /* set style */ |
10 | reyssat | 671 | void obj_setstyle(objparm *pm) |
672 | { |
||
673 | int i,t; |
||
674 | t=pm->pcnt/3; if(t<=0) { |
||
7675 | bpr | 675 | error("too_few_parms"); return; |
10 | reyssat | 676 | } |
677 | for(i=0;i<t;i++) { |
||
7675 | bpr | 678 | if(pm->pd[3*i]<0 || pm->pd[3*i+1]<0 || pm->pd[3*i+2]<0) |
679 | pm->p[i]=gdTransparent; |
||
680 | else |
||
681 | pm->p[i]=getcolor(pm->pd[3*i],pm->pd[3*i+1],pm->pd[3*i+2]); |
||
10 | reyssat | 682 | } |
683 | gdImageSetStyle(image,pm->p,t); styled=1; |
||
684 | } |
||
685 | |||
7675 | bpr | 686 | /* kill style */ |
10 | reyssat | 687 | void obj_killstyle(objparm *pm) |
688 | { |
||
689 | styled=0; |
||
690 | } |
||
691 | |||
7675 | bpr | 692 | /* set transparent */ |
10 | reyssat | 693 | void obj_transp(objparm *pm) |
694 | { |
||
695 | gdImageColorTransparent(image,pm->color[0]); |
||
696 | } |
||
697 | |||
7675 | bpr | 698 | /* set interlace */ |
10 | reyssat | 699 | void obj_interlace(objparm *pm) |
700 | { |
||
701 | gdImageInterlace(image,1); |
||
702 | } |
||
703 | |||
7675 | bpr | 704 | /* set linewidth */ |
10 | reyssat | 705 | void obj_linewidth(objparm *pm) |
706 | { |
||
707 | if(pm->pd[0]<1 || pm->pd[0]>255) error("bad_parms"); |
||
708 | else width=pm->pd[0]; |
||
709 | } |
||
710 | |||
7675 | bpr | 711 | /* set x range */ |
10 | reyssat | 712 | void obj_xrange(objparm *pm) |
713 | { |
||
714 | double dd; |
||
715 | dd=pm->pd[1]-pm->pd[0]; |
||
716 | xstart=pm->pd[0]; xscale=sizex/dd; |
||
717 | } |
||
718 | |||
7675 | bpr | 719 | /* set y range */ |
10 | reyssat | 720 | void obj_yrange(objparm *pm) |
721 | { |
||
722 | double dd; |
||
723 | dd=pm->pd[1]-pm->pd[0]; |
||
724 | ystart=pm->pd[1]; yscale=-sizey/dd; |
||
725 | } |
||
726 | |||
7675 | bpr | 727 | /* set x et y range */ |
10 | reyssat | 728 | void obj_range(objparm *pm) |
729 | { |
||
730 | double d1,d2; |
||
731 | d1=pm->pd[1]-pm->pd[0]; d2=pm->pd[3]-pm->pd[2]; |
||
732 | xstart=pm->pd[0]; xscale=(sizex-1)/d1; |
||
733 | ystart=pm->pd[3]; yscale=-(sizey-1)/d2; |
||
734 | } |
||
735 | |||
7675 | bpr | 736 | /* set t range */ |
10 | reyssat | 737 | void obj_trange(objparm *pm) |
738 | { |
||
6790 | bpr | 739 | /*double dd; |
740 | dd=pm->pd[1]-pm->pd[0];*/ |
||
10 | reyssat | 741 | tstart=pm->pd[0]; tend=pm->pd[1]; |
742 | tranged=1; |
||
743 | } |
||
744 | |||
7675 | bpr | 745 | /* set tstep (plotting step) */ |
10 | reyssat | 746 | void obj_tstep(objparm *pm) |
747 | { |
||
748 | int dd; |
||
749 | dd=pm->pd[0]; |
||
750 | if(dd<3) { |
||
7675 | bpr | 751 | error("bad_step"); return; |
10 | reyssat | 752 | } |
753 | if(dd>2000) dd=2000; |
||
754 | tstep=dd; |
||
755 | } |
||
756 | |||
7675 | bpr | 757 | /* set plotjump (plot jump break threashold) */ |
10 | reyssat | 758 | void obj_plotjump(objparm *pm) |
759 | { |
||
760 | int dd; |
||
761 | dd=pm->pd[0]; |
||
762 | if(dd<3) dd=3; if(dd>MAX_SIZE) dd=MAX_SIZE; |
||
763 | plotjump=dd; |
||
764 | } |
||
765 | |||
7675 | bpr | 766 | /* plot a curve, either parametric or explicit */ |
6578 | bpr | 767 | void _obj_plot(objparm *pm,int dash) |
10 | reyssat | 768 | { |
769 | int i,j,n,dist,xx,yy,varpos; |
||
770 | char p1[MAX_LINELEN+1], p2[MAX_LINELEN+1]; |
||
771 | char *varn, *pp; |
||
772 | double dc[2],t,v; |
||
773 | int ic[2],oc[2]; |
||
774 | |||
775 | n=itemnum(pm->str); |
||
776 | if(n<1) { |
||
7675 | bpr | 777 | error("bad_parms"); return; |
10 | reyssat | 778 | } |
779 | fnd_item(pm->str,1,p1); fnd_item(pm->str,2,p2); |
||
780 | if(n==1 && !tranged) v=sizex/xscale/tstep; |
||
781 | else v=(tend-tstart)/tstep; |
||
782 | if(n==1) varn="x"; else varn="t"; |
||
783 | for(pp=varchr(p1,varn); pp; pp=varchr(pp,varn)) { |
||
7675 | bpr | 784 | string_modify(p1,pp,pp+strlen(varn),EV_T); |
785 | pp+=strlen(EV_T); |
||
10 | reyssat | 786 | } |
787 | for(pp=varchr(p2,varn); pp; pp=varchr(pp,varn)) { |
||
7675 | bpr | 788 | string_modify(p2,pp,pp+strlen(varn),EV_T); |
789 | pp+=strlen(EV_T); |
||
10 | reyssat | 790 | } |
791 | varpos=eval_getpos(EV_T); |
||
792 | if(varpos<0) return; /* unknown error */ |
||
793 | evalue_compile(p1); evalue_compile(p2); |
||
1024 | bpr | 794 | if(vimg_enable) vimg_plotstart(); |
10 | reyssat | 795 | for(i=j=0;i<=tstep;i++) { |
7675 | bpr | 796 | if(n==1) { |
797 | if(tranged) t=tstart+i*v; else t=xstart+i*v; |
||
8076 | bpr | 798 | eval_setval(varpos,t); dc[0]=t; dc[1]=strevalue(p1); |
7675 | bpr | 799 | } |
800 | else { |
||
801 | t=tstart+i*v; eval_setval(varpos,t); |
||
8076 | bpr | 802 | dc[0]=strevalue(p1); dc[1]=strevalue(p2); |
7675 | bpr | 803 | } |
804 | if(!finite(dc[0]) || !finite(dc[1])) ic[0]=ic[1]=-BOUND; |
||
805 | else scale(dc,ic,1); |
||
806 | if(vimg_enable) vimg_plot1 (scale_buf[0],scale_buf[1]); |
||
807 | if(j==0) { |
||
808 | gdImageSetPixel(image,ic[0],ic[1],pm->color[0]); j++; |
||
809 | } |
||
810 | else { |
||
811 | xx=ic[0]-oc[0]; yy=ic[1]-oc[1]; |
||
812 | dist=sqrt(xx*xx+yy*yy); |
||
813 | if(dist>0) { |
||
814 | if(dist>plotjump || dist==1) |
||
815 | gdImageSetPixel(image,ic[0],ic[1],pm->color[0]); |
||
816 | else |
||
817 | if ( dash==1) { |
||
818 | gdImageDashedLine(image,oc[0],oc[1],ic[0],ic[1],pm->color[0]); |
||
819 | } else |
||
820 | {gdImageLine(image,oc[0],oc[1],ic[0],ic[1],pm->color[0]); } |
||
7615 | bpr | 821 | |
7675 | bpr | 822 | } |
823 | } |
||
824 | memmove(oc,ic,sizeof(oc)); |
||
10 | reyssat | 825 | } |
1024 | bpr | 826 | if(vimg_enable) vimg_plotend(); |
10 | reyssat | 827 | } |
828 | |||
6578 | bpr | 829 | void obj_plot(objparm *pm) { _obj_plot( pm,0) ;} |
830 | void obj_dplot(objparm *pm) { _obj_plot( pm,1) ; } |
||
831 | |||
7675 | bpr | 832 | /* set levelcurve granularity */ |
10 | reyssat | 833 | void obj_levelstep(objparm *pm) |
834 | { |
||
835 | int dd; |
||
836 | dd=pm->pd[0]; |
||
837 | if(dd<1) return; if(dd>16) dd=16; |
||
838 | lstep=dd; |
||
839 | } |
||
840 | |||
7675 | bpr | 841 | /* level curve */ |
10 | reyssat | 842 | void obj_levelcurve(objparm *pm) |
843 | { |
||
844 | char fn[MAX_LINELEN+1],tc[MAX_LINELEN+1]; |
||
845 | int n,i; |
||
846 | double d; |
||
847 | leveldata *ld; |
||
7615 | bpr | 848 | |
10 | reyssat | 849 | ld=xmalloc(sizeof(leveldata)+16); |
850 | ld->xname="x"; ld->yname="y"; |
||
851 | ld->xsize=sizex; ld->ysize=sizey; ld->datacnt=0; |
||
852 | ld->xrange[0]=xstart; ld->xrange[1]=sizex/xscale+xstart; |
||
853 | ld->yrange[0]=sizey/yscale+ystart; ld->yrange[1]=ystart; |
||
854 | ld->grain=lstep; |
||
855 | fnd_item(pm->str,1,fn); ld->fn=fn; |
||
856 | n=itemnum(pm->str); |
||
857 | if(n<=1) {ld->levelcnt=1; ld->levels[0]=0;} |
||
858 | else { |
||
7675 | bpr | 859 | if(n>LEVEL_LIM+1) n=LEVEL_LIM+1; |
860 | for(i=0;i<n-1;i++) { |
||
861 | fnd_item(pm->str,i+2,tc); |
||
8076 | bpr | 862 | d=strevalue(tc); |
7675 | bpr | 863 | if(finite(d)) ld->levels[i]=d; else ld->levels[i]=0; |
864 | } |
||
865 | ld->levelcnt=n-1; |
||
10 | reyssat | 866 | } |
867 | levelcurve(ld); |
||
868 | for(i=0;i<ld->datacnt;i++) { |
||
7675 | bpr | 869 | gdImageSetPixel(image,ld->xdata[i],ld->ydata[i],pm->color[0]); |
10 | reyssat | 870 | } |
871 | free(ld); |
||
872 | } |
||
873 | |||
7675 | bpr | 874 | /* set animation step */ |
10 | reyssat | 875 | void obj_animstep(objparm *pm) |
876 | { |
||
877 | animstep=pm->pd[0]; |
||
878 | setvar("animstep",pm->pd[0]); |
||
879 | } |
||
880 | |||
7675 | bpr | 881 | /* Starts a line counting */ |
10 | reyssat | 882 | void obj_linecount(objparm *pm) |
883 | { |
||
884 | linecnt=pm->pd[0]; |
||
885 | } |
||
886 | |||
7675 | bpr | 887 | /* marks end of execution */ |
10 | reyssat | 888 | void obj_end(objparm *pm) |
889 | { |
||
890 | error("successful_end_of_execution"); |
||
891 | } |
||
892 | |||
7675 | bpr | 893 | /* output */ |
10 | reyssat | 894 | void obj_output(objparm *pm) |
895 | { |
||
896 | char *p, namebuf[1024]; |
||
897 | p=find_word_start(pm->str); *find_word_end(p)=0; |
||
898 | snprintf(namebuf,sizeof(namebuf),"%s",imagefilename); |
||
899 | snprintf(imagefilename,sizeof(imagefilename),"%s",p); |
||
900 | output(); |
||
901 | snprintf(imagefilename,sizeof(imagefilename),"%s",namebuf); |
||
902 | } |
||
903 | |||
7675 | bpr | 904 | /* vimgfile */ |
1024 | bpr | 905 | void obj_vimgfile(objparm *pm) |
906 | { |
||
907 | char *p; |
||
908 | p=find_word_start(pm->str); *find_word_end(p)=0; |
||
909 | snprintf(vimgfilename,sizeof(vimgfilename),"%s",p); |
||
910 | if(vimg_ready) vimg_close(); |
||
911 | } |
||
912 | |||
7675 | bpr | 913 | /* vimg enable/disable */ |
1024 | bpr | 914 | void obj_vimg(objparm *pm) |
915 | { |
||
916 | vimg_enable=pm->pd[0]; |
||
917 | if(vimg_enable>0 && vimg_ready==0) { |
||
7675 | bpr | 918 | vimg_init(); |
1024 | bpr | 919 | } |
920 | } |
||
921 | |||
7675 | bpr | 922 | /* Set affine transformation */ |
10 | reyssat | 923 | void obj_affine(objparm *pm) |
924 | { |
||
925 | int i; |
||
926 | for(i=0;i<4;i++) matrix[i]=pm->pd[i]; |
||
927 | transx=pm->pd[4]; transy=pm->pd[5]; |
||
928 | transform=1; |
||
929 | } |
||
930 | |||
7675 | bpr | 931 | /* Set affine transformation */ |
10 | reyssat | 932 | void obj_rotation(objparm *pm) |
933 | { |
||
934 | double r; |
||
935 | r=M_PI*pm->pd[0]/180; |
||
936 | matrix[0]=matrix[3]=cos(r); |
||
937 | matrix[1]=-sin(r); matrix[2]=sin(r); |
||
938 | transform=1; |
||
939 | } |
||
940 | |||
7675 | bpr | 941 | /* Set affine transformation */ |
10 | reyssat | 942 | void obj_linear(objparm *pm) |
943 | { |
||
944 | int i; |
||
945 | for(i=0;i<4;i++) matrix[i]=pm->pd[i]; |
||
946 | transform=1; |
||
947 | } |
||
948 | |||
7675 | bpr | 949 | /* Set affine transformation */ |
10 | reyssat | 950 | void obj_translation(objparm *pm) |
951 | { |
||
952 | transx=pm->pd[0]; transy=pm->pd[1]; |
||
953 | } |
||
954 | |||
7675 | bpr | 955 | /* Set affine transformation */ |
10 | reyssat | 956 | void obj_killaffine(objparm *pm) |
957 | { |
||
958 | matrix[0]=matrix[3]=1; |
||
959 | matrix[1]=matrix[2]=transx=transy=0; |
||
960 | transform=0; |
||
961 | } |
||
962 | |||
7675 | bpr | 963 | /* Set affine transformation */ |
10 | reyssat | 964 | void obj_killlinear(objparm *pm) |
965 | { |
||
966 | matrix[0]=matrix[3]=1; |
||
967 | matrix[1]=matrix[2]=0; |
||
968 | transform=0; |
||
969 | } |
||
970 | |||
7675 | bpr | 971 | /* Set affine transformation */ |
10 | reyssat | 972 | void obj_killtranslation(objparm *pm) |
973 | { |
||
974 | transx=transy=0; |
||
975 | } |
||
976 | |||
977 | /***** Les modifs de Jean-Christophe Leger Fev 2006 *****/ |
||
978 | |||
7615 | bpr | 979 | /* arguments: un numero de matrice entre 1 et JC_NB_MATRICES, une liste de 4 nombres reels pour la matrice */ |
10 | reyssat | 980 | void obj_setmatrix(objparm *pm) |
981 | { |
||
982 | int nummatrix = (int) (pm->pd[0]); |
||
983 | if((nummatrix < 1) ||(nummatrix>JC_NB_MATRICES)) { |
||
984 | error("bad_matrix_number"); |
||
985 | return; |
||
986 | } |
||
987 | matrices_pavage[nummatrix][0] = pm->pd[1]; |
||
988 | matrices_pavage[nummatrix][1] = pm->pd[2]; |
||
989 | matrices_pavage[nummatrix][2] = pm->pd[3]; |
||
990 | matrices_pavage[nummatrix][3] = pm->pd[4]; |
||
991 | } |
||
992 | |||
7615 | bpr | 993 | /* arguments: un numero de matrice entre 1 et JC_NB_MATRICES */ |
10 | reyssat | 994 | void obj_resetmatrix(objparm *pm) |
995 | { |
||
996 | int nummatrix = (int) (pm->pd[0]); |
||
997 | if((nummatrix < 1) ||(nummatrix>JC_NB_MATRICES)) { |
||
998 | error("bad_matrix_number"); |
||
999 | return; |
||
1000 | } |
||
1001 | matrices_pavage[nummatrix][0] = 1; |
||
1002 | matrices_pavage[nummatrix][1] = 0; |
||
1003 | matrices_pavage[nummatrix][2] = 0; |
||
1004 | matrices_pavage[nummatrix][3] = 1; |
||
1005 | |||
1006 | } |
||
7615 | bpr | 1007 | /* arguments: un numero de vecteur entre 1 et JC_NB_MATRICES, une liste de 2 nombres reels pour le vecteur */ |
10 | reyssat | 1008 | void obj_setvector(objparm *pm) |
1009 | { |
||
1010 | int nummatrix = (int) (pm->pd[0]); |
||
1011 | if((nummatrix < 1) ||(nummatrix>JC_NB_MATRICES)) { |
||
1012 | error("bad_vector_number"); |
||
1013 | return; |
||
1014 | } |
||
1015 | vecteurs_pavage[nummatrix][0] = pm->pd[1]; |
||
1016 | vecteurs_pavage[nummatrix][1] = pm->pd[2]; |
||
1017 | } |
||
1018 | |||
7615 | bpr | 1019 | /* arguments: un numero de matrice entre 1 et JC_NB_MATRICES */ |
10 | reyssat | 1020 | void obj_resetvector(objparm *pm) |
1021 | { |
||
1022 | int nummatrix = (int) (pm->pd[0]); |
||
1023 | if((nummatrix < 1) ||(nummatrix>JC_NB_MATRICES)) { |
||
1024 | error("bad_vector_number"); |
||
1025 | return; |
||
1026 | } |
||
1027 | vecteurs_pavage[nummatrix][0] = 0; |
||
1028 | vecteurs_pavage[nummatrix][1] = 0; |
||
1029 | } |
||
1030 | |||
7615 | bpr | 1031 | /* arguments: un numero de vecteur entre 1 et JC_NB_MATRICES, une liste de 6 nombres reels pour la matrice et le vecteur */ |
10 | reyssat | 1032 | void obj_settransform(objparm *pm) |
1033 | { |
||
1034 | int nummatrix = (int) (pm->pd[0]); |
||
1035 | if((nummatrix < 1) ||(nummatrix>JC_NB_MATRICES)) { |
||
1036 | error("bad_vector_number"); |
||
1037 | return; |
||
1038 | } |
||
1039 | matrices_pavage[nummatrix][0] = pm->pd[1]; |
||
1040 | matrices_pavage[nummatrix][1] = pm->pd[2]; |
||
1041 | matrices_pavage[nummatrix][2] = pm->pd[3]; |
||
1042 | matrices_pavage[nummatrix][3] = pm->pd[4]; |
||
1043 | vecteurs_pavage[nummatrix][0] = pm->pd[5]; |
||
1044 | vecteurs_pavage[nummatrix][1] = pm->pd[6]; |
||
1045 | } |
||
1046 | |||
1047 | |||
7615 | bpr | 1048 | /* arguments: un numero de matrice entre 1 et JC_NB_MATRICES */ |
10 | reyssat | 1049 | void obj_resettransform(objparm *pm) |
1050 | { |
||
1051 | int nummatrix = (int) (pm->pd[0]); |
||
1052 | if((nummatrix < 1) ||(nummatrix>JC_NB_MATRICES)) { |
||
1053 | error("bad_vector_number"); |
||
1054 | return; |
||
1055 | } |
||
1056 | vecteurs_pavage[nummatrix][0] = 0; |
||
1057 | vecteurs_pavage[nummatrix][1] = 0; |
||
1058 | matrices_pavage[nummatrix][0] = 1; |
||
1059 | matrices_pavage[nummatrix][1] = 0; |
||
1060 | matrices_pavage[nummatrix][2] = 0; |
||
1061 | matrices_pavage[nummatrix][3] = 1; |
||
1062 | } |
||
1063 | |||
7615 | bpr | 1064 | /* arguments: une liste de 6 nombres reels pour les coordonnees de l'origine et des vecteurs de base */ |
10 | reyssat | 1065 | void obj_setparallelogram(objparm *pm) |
1066 | { |
||
1067 | int i; |
||
1068 | for(i=0;i<6;i++) parallogram_fonda[i]=pm->pd[i]; |
||
1069 | } |
||
1070 | |||
1071 | /* arguments :aucun */ |
||
1072 | void obj_resetparallelogram(objparm *pm) |
||
1073 | { |
||
1074 | parallogram_fonda[0]=0; |
||
1075 | parallogram_fonda[1]=0; |
||
1076 | parallogram_fonda[2]=100; |
||
1077 | parallogram_fonda[3]=0; |
||
1078 | parallogram_fonda[4]=0; |
||
1079 | parallogram_fonda[5]=100; |
||
1080 | } |
||
1081 | |||
1082 | /* argument : la liste des numeros des matrices a faire agir, le nom du fichier de l'image a inclure */ |
||
1083 | void obj_multicopy(objparm *pm) |
||
1084 | { |
||
1085 | char *pp,*pe,*cptr; |
||
1086 | FILE *inf; |
||
7675 | bpr | 1087 | gdImagePtr insimg; |
10 | reyssat | 1088 | int i,j; |
1089 | int imax,jmax; |
||
1090 | int c; /* la couleur reperee */ |
||
1091 | int mat; |
||
1092 | int nummatrices[JC_NB_MATRICES]; |
||
1093 | double pt[2]; /* les coordonnees math. du point repere dans le parallelogramme */ |
||
1094 | double ptr[2]; /* les coordonnees math. du point transforme */ |
||
1095 | int pti[2]; /* les coordonnees img du point a placer sur le canevas */ |
||
1096 | int t; |
||
1097 | /* gestion palette de couleur de l'image a inserer */ |
||
1098 | int colorMap[gdMaxColors]; |
||
1099 | int comptmat=0; /* combien de matrices en tout ? */ |
||
7615 | bpr | 1100 | |
10 | reyssat | 1101 | for (i=0; (i<gdMaxColors); i++) { |
1102 | colorMap[i] = (-1); |
||
1103 | } |
||
1104 | |||
1105 | /* Gestion des parametres la liste est censee finir avec le nom du fichier */ |
||
7615 | bpr | 1106 | t=pm->pcnt-1; /* il faut enlever le nom de fichier ! c'est le nombre de parametres en plus */ |
10 | reyssat | 1107 | pp=find_word_start(pm->str); |
1108 | /* visiblement find_word_start n'arrive pas a trouver le dernier mot dans un contexte ou le nombre de parameters est variable |
||
1109 | * on cherche donc l'emplacement de la derniere virgule: |
||
1110 | * il y en a une car t>0, on retrouve ensuite le debut de mot |
||
1111 | */ |
||
1112 | for(pe=pp;*pe!=0;pe++);/* trouve la fin de la chaine */ |
||
1113 | if(t>0){ |
||
1114 | for(cptr = pe; cptr > pp && *cptr != ','; cptr--); |
||
1115 | pp=find_word_start(cptr+1); |
||
1116 | } |
||
1117 | pe=find_word_end(pp);*pe=0; /* strip junk final */ |
||
1118 | // printf("pp contient %s\n",pp); |
||
1119 | |||
1120 | |||
1121 | inf=open4read(pp); |
||
1122 | if(inf==NULL) { |
||
7675 | bpr | 1123 | error("file_not_exist"); return; |
10 | reyssat | 1124 | } |
1125 | insimg=gdImageCreateFromGif(inf); fclose(inf); |
||
1126 | if(insimg==NULL) { |
||
7675 | bpr | 1127 | error("bad_gif"); return; |
10 | reyssat | 1128 | } |
1129 | |||
7675 | bpr | 1130 | /* On recupere les numeros des matrices/vecteurs a faire agir, |
1131 | * s'il n'y en a pas, on les fait toutes agir |
||
1132 | */ |
||
10 | reyssat | 1133 | for(i=0;i<t && i< JC_NB_MATRICES;i++) { |
1134 | if(pm->pd[i]>=1 && pm->pd[i]<=JC_NB_MATRICES){ |
||
7675 | bpr | 1135 | nummatrices[comptmat] = pm->pd[i]; |
1136 | comptmat++; |
||
10 | reyssat | 1137 | } |
1138 | } |
||
1139 | if(t<=0){ |
||
1140 | for(i=0;i<JC_NB_MATRICES;i++) { |
||
7675 | bpr | 1141 | nummatrices[i] = i+1; |
10 | reyssat | 1142 | } |
1143 | comptmat=JC_NB_MATRICES; |
||
1144 | } |
||
1145 | |||
7615 | bpr | 1146 | |
10 | reyssat | 1147 | imax = gdImageSX(insimg); |
1148 | jmax = gdImageSY(insimg); |
||
1149 | |||
1150 | for(i=0;i<imax;i++){ |
||
1151 | for(j=0;j<jmax;j++){ |
||
7675 | bpr | 1152 | int nc; |
1153 | c=gdImageGetPixel(insimg,i,j); |
||
1154 | /* Le code suivant est une copie du code dans gdImageCopy Added 7/24/95: support transparent copies */ |
||
1155 | if (gdImageGetTransparent(insimg) != c) { |
||
1156 | /* Have we established a mapping for this color? */ |
||
1157 | if (colorMap[c] == (-1)) { |
||
1158 | /* If it's the same image, mapping is trivial, dans notre cas ca n'arrive jamais... */ |
||
1159 | if (image == insimg) { |
||
1160 | nc = c; |
||
1161 | } else { |
||
1162 | /* First look for an exact match */ |
||
1163 | nc = gdImageColorExact(image, |
||
1164 | insimg->red[c], insimg->green[c], |
||
1165 | insimg->blue[c]); |
||
1166 | } |
||
1167 | if (nc == (-1)) { |
||
1168 | /* No, so try to allocate it */ |
||
1169 | nc = gdImageColorAllocate(image, |
||
1170 | insimg->red[c], insimg->green[c], |
||
1171 | insimg->blue[c]); |
||
1172 | /* If we're out of colors, go for the closest color */ |
||
1173 | if (nc == (-1)) { |
||
1174 | nc = gdImageColorClosest(image, |
||
1175 | insimg->red[c], insimg->green[c], |
||
1176 | insimg->blue[c]); |
||
1177 | } |
||
1178 | } |
||
1179 | colorMap[c] = nc; |
||
1180 | } |
||
10 | reyssat | 1181 | |
7675 | bpr | 1182 | pt[0]= i*(parallogram_fonda[2])/(imax-1)+(jmax-j)*(parallogram_fonda[4])/(jmax-1)+parallogram_fonda[0]; |
1183 | pt[1]= i*(parallogram_fonda[3])/(imax-1)+(jmax-j)*(parallogram_fonda[5])/(jmax-1)+parallogram_fonda[1]; |
||
1184 | for(mat=0;mat<comptmat;mat++){ |
||
1185 | double *matricecourante = matrices_pavage[nummatrices[mat]]; |
||
1186 | double *vecteurcourant = vecteurs_pavage[nummatrices[mat]]; |
||
1187 | ptr[0] = matricecourante[0]*pt[0]+matricecourante[1]*pt[1]+vecteurcourant[0]; |
||
1188 | ptr[1] = matricecourante[2]*pt[0]+matricecourante[3]*pt[1]+vecteurcourant[1]; |
||
1189 | scale(ptr,pti,1); |
||
1190 | gdImageSetPixel(image,pti[0],pti[1],colorMap[c]); |
||
1191 | } |
||
1192 | } |
||
10 | reyssat | 1193 | } |
1194 | } |
||
1195 | gdImageDestroy(insimg); |
||
1196 | } |
||
1197 | |||
1198 | /**** Fin modifs JC Fev 06 ******/ |
||
1199 | |||
7675 | bpr | 1200 | /* get color from value */ |
10 | reyssat | 1201 | int calc_color(char *p, struct objtab *o) |
1202 | { |
||
1203 | int k, cc[3]; |
||
1204 | char buf[MAX_LINELEN+1]; |
||
1205 | for(k=0;k<3;k++) { |
||
7675 | bpr | 1206 | fnd_item(p,k+1,buf); |
8076 | bpr | 1207 | cc[k]=strevalue(buf); |
10 | reyssat | 1208 | } |
1209 | collapse_item(p,3); |
||
1210 | if(cc[0]==-1 && cc[1]==-1 && cc[2]==-255) { |
||
1211 | |||
7675 | bpr | 1212 | if(brushed && o->subst&1) return gdBrushed; |
1213 | else return color_black; |
||
10 | reyssat | 1214 | } |
1215 | if(cc[0]==-1 && cc[1]==-255 && cc[2]==-1) { |
||
7675 | bpr | 1216 | if(styled && o->subst&2) return gdStyled; |
1217 | else return color_black; |
||
10 | reyssat | 1218 | } |
1219 | if(cc[0]==-255 && cc[1]==-1 && cc[2]==-1) { |
||
7675 | bpr | 1220 | if(tiled && o->fill_tag==1) return gdTiled; |
1221 | else return color_black; |
||
10 | reyssat | 1222 | } |
1223 | return getcolor(cc[0],cc[1],cc[2]); |
||
1224 | } |
||
1225 | |||
7675 | bpr | 1226 | /* Routine to parse parameters */ |
10 | reyssat | 1227 | int parse_parms(char *p,objparm *pm,struct objtab *o) |
1228 | { |
||
1229 | char buf[MAX_LINELEN+1]; |
||
1230 | char *p1, *p2; |
||
1231 | int j,t,c,c1,c2; |
||
7615 | bpr | 1232 | |
10 | reyssat | 1233 | c=o->color_pos;c1=c2=0; |
1234 | pm->color[0]=pm->color[1]=0; |
||
1235 | if(c>0) c1=c; if(c<0) c2=-c; c=c1+c2; |
||
1236 | t=itemnum(p);if(t<o->required_parms+3*c) return -1; |
||
1237 | if(c1>0 && t>o->required_parms+3*c) t=o->required_parms+3*c; |
||
1238 | pm->pcnt=t-3*c; |
||
1239 | if(pm->pcnt>MAX_PARMS) pm->pcnt=MAX_PARMS; |
||
1240 | if(c2>0) { |
||
7675 | bpr | 1241 | for(j=0;j<2 && j<c2; j++) pm->color[j]=calc_color(p,o); |
10 | reyssat | 1242 | } |
1243 | snprintf(buf,sizeof(buf),"%s",p); |
||
1244 | for(j=0, p1=buf; j<pm->pcnt; j++, p1=p2) { |
||
7675 | bpr | 1245 | p2=find_item_end(p1); if(*p2) *p2++=0; |
1246 | p1=find_word_start(p1); |
||
8076 | bpr | 1247 | if(*p1) pm->pd[j]=strevalue(p1); else pm->pd[j]=0; |
7675 | bpr | 1248 | if(!finite(pm->pd[j])) { |
1249 | if(j<o->required_parms) return -1; |
||
1250 | else {pm->pd[j]=0;break;} |
||
1251 | } |
||
10 | reyssat | 1252 | } |
1253 | collapse_item(p,o->required_parms); |
||
1254 | if(c1>0) { |
||
7675 | bpr | 1255 | for(j=0;j<c1 && j<2; j++) pm->color[j]=calc_color(p,o); |
10 | reyssat | 1256 | } |
1257 | if(width>1 && o->subst&1 && pm->color[0]!=gdBrushed |
||
1258 | && pm->color[0]!=gdStyled && pm->color[0]!=gdTiled) { |
||
7675 | bpr | 1259 | pm->color[1]=pm->color[0]; |
1260 | pm->color[0]=widthcolor(width,pm->color[0]); |
||
10 | reyssat | 1261 | } |
1262 | pm->fill=o->fill_tag; |
||
3718 | reyssat | 1263 | ovlstrcpy(pm->str,p); return 0; |
10 | reyssat | 1264 | } |
1265 | |||
8068 | bpr | 1266 | /* Create the struct objparm pm corresponding to the objparm p |
1267 | * Execute a command. Returns 0 if OK. |
||
1268 | */ |
||
10 | reyssat | 1269 | int obj_main(char *p) |
1270 | { |
||
1271 | int i; |
||
1272 | char *pp,*name,*pt; |
||
1273 | char tbuf2[MAX_LINELEN+1]; |
||
1274 | struct objparm pm; |
||
1275 | |||
1276 | p=find_word_start(p); |
||
1277 | if(*p==exec_prefix_char || *p==0) return 0; /* comment */ |
||
1278 | name=p; |
||
1279 | pp=find_name_end(p); |
||
1280 | pt=find_word_start(pp); if(*pt=='=') *pt=' '; |
||
1281 | if(*pt==':' && *(pt+1)=='=') *pt=*(pt+1)=' '; |
||
1282 | pp=find_word_end(p); |
||
1283 | if(*pp!=0) { |
||
7675 | bpr | 1284 | *(pp++)=0; pp=find_word_start(pp); |
10 | reyssat | 1285 | } |
1286 | if(strlen(p)==1 || (strlen(p)==2 && isdigit(*(p+1)))) { |
||
8076 | bpr | 1287 | setvar(p,strevalue(pp)); return 0; |
10 | reyssat | 1288 | } |
8068 | bpr | 1289 | /* search the number of the object */ |
10 | reyssat | 1290 | i=search_list(objtab,obj_no,sizeof(objtab[0]),name); |
1291 | if(i<0) { |
||
7675 | bpr | 1292 | error("bad_cmd"); return 1; |
10 | reyssat | 1293 | } |
1294 | if(image==NULL && (objtab[i].color_pos || objtab[i].required_parms>2)) { |
||
7675 | bpr | 1295 | error("image_not_defined"); return 1; |
10 | reyssat | 1296 | } |
3718 | reyssat | 1297 | ovlstrcpy(tbuf2,pp); |
10 | reyssat | 1298 | if(objtab[i].color_pos || objtab[i].routine==obj_setstyle) { |
7675 | bpr | 1299 | substit(tbuf2); |
10 | reyssat | 1300 | } |
1301 | if(parse_parms(tbuf2,&pm,objtab+i)!=0) error("bad_parms"); |
||
1302 | else objtab[i].routine(&pm); |
||
1303 | return 0; |
||
1304 | } |
||
1305 |