Rev 1026 | Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1024 | bpr | 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 | */ |
||
17 | |||
18 | |||
19 | void vimg_init (void) |
||
20 | { |
||
21 | double x1,x2,y1,y2,t; |
||
22 | if(vimgfilename[0]==0) vimgf=stdout; |
||
23 | else vimgf=fopen(vimgfilename,"w"); |
||
24 | if(vimgf==NULL) {vimg_enable=0; return;} |
||
25 | x1=xstart; y1=ystart; |
||
26 | x2=sizex/xscale+xstart; |
||
27 | y2=sizey/yscale+ystart; |
||
28 | if(x2<x1) {t=x1;x1=x2;x2=t;} |
||
29 | if(y2<y1) {t=y1;y1=y2;y2=t;} |
||
30 | fprintf(vimgf," 0\nSECTION\n 2\nHEADER\n\ |
||
31 | 9\n$EXTMIN\n 10\n%f\n 20\n%f\n\ |
||
32 | 9\n$EXTMAX\n 10\n%f\n 20\n%f\n\ |
||
33 | 9\n$LIMMIN\n 10\n%f\n 20\n%f\n\ |
||
34 | 9\n$LIMMAX\n 10\n%f\n 20\n%f\n\ |
||
35 | 9\n$MEASUREMENT\n 70\n1\n 0\nENDSEC\n 0\nSECTION\n 2\nENTITIES\n", |
||
36 | x1,y1,x2,y2, x1,y1,x2,y2); |
||
37 | vimg_ready=1; |
||
38 | } |
||
39 | |||
40 | void vimg_close (void) |
||
41 | { |
||
42 | if(vimgf==NULL || vimg_ready==0) return; |
||
43 | fprintf(vimgf," 0\nENDSEC \n 0\nEOF\n"); |
||
44 | fclose(vimgf); vimg_ready=vimg_enable=0; vimgf=NULL; |
||
45 | } |
||
46 | |||
47 | void vimg_arc (double x0,double y0, double rx, double ry,double a1, double a2) |
||
48 | { |
||
49 | double mx,my,ratio; |
||
50 | if(rx==ry) { |
||
51 | fprintf(vimgf," 0\nARC\n 10\n%f\n 20\n%f\n 40\n%f\n\ |
||
52 | 50\n%f\n51\n%f\n",x0,y0,rx,a1,a2); |
||
53 | return; |
||
54 | } |
||
55 | if(rx>ry) {mx=rx;my=0;ratio=ry/rx;} |
||
56 | else {mx=0;my=ry;ratio=rx/ry;} |
||
57 | fprintf(vimgf," 0\nELLIPSE\n 10\n%f\n 20\n%f\n\ |
||
58 | 11\n%f\n 21\n%f\n 40\n%f\n 41\n%f\n 42\n%f\n", |
||
59 | x0,y0,mx,my,ratio, |
||
60 | a1*3.14159265/180,a2*3.14159265/180); |
||
61 | |||
62 | } |
||
63 | |||
64 | void vimg_ellipse (double x0, double y0, double rx, double ry) |
||
65 | { |
||
66 | if(rx==ry) { |
||
67 | fprintf(vimgf," 0\nCIRCLE\n 10\n%f\n 20\n%f\n\ |
||
68 | 40\n%f\n",x0,y0,rx); |
||
69 | return; |
||
70 | } |
||
71 | else vimg_arc (x0,y0,rx,ry,0,360); |
||
72 | } |
||
73 | |||
74 | void vimg_line (double x1,double y1,double x2,double y2) |
||
75 | { |
||
76 | fprintf(vimgf," 0\nLINE\n 10\n%f\n 20\n%f\n 11\n%f\n 21\n%f\n", |
||
77 | x1,y1,x2,y2); |
||
78 | } |
||
79 | |||
80 | void vimg_polyline (double xy[], int cnt, int closed) |
||
81 | { |
||
82 | int i; |
||
83 | fprintf(vimgf," 0\nPOLYLINE\n 70\n%d\n",closed); |
||
84 | for(i=0;i<2*cnt;i++,i++) { |
||
85 | fprintf(vimgf," 0\nVERTEX\n 10\n%f\n 20\n%f\n", |
||
86 | xy[i],xy[i+1]); |
||
87 | } |
||
88 | fprintf(vimgf," 0\nSEQEND\n"); |
||
89 | } |
||
90 | |||
91 | void vimg_rect (double x1, double y1, double x2, double y2) |
||
92 | { |
||
93 | double d[8]; |
||
94 | d[0]=x1; d[1]=y1; d[2]=x1; d[3]=y2; |
||
95 | d[4]=x2; d[5]=y2; d[6]=x2; d[7]=y1; |
||
96 | vimg_polyline (d,4,1); |
||
97 | } |
||
98 | |||
99 | void vimg_plotstart (void) |
||
100 | { |
||
101 | fprintf(vimgf," 0\nPOLYLINE\n 70\n0\n"); |
||
102 | } |
||
103 | |||
104 | void vimg_plot1 (double x, double y) |
||
105 | { |
||
106 | fprintf(vimgf," 0\nVERTEX\n 10\n%f\n 20\n%f\n", x,y); |
||
107 | } |
||
108 | |||
109 | void vimg_plotend (void) |
||
110 | { |
||
111 | fprintf(vimgf," 0\nSEQEND\n"); |
||
112 | } |
||
113 |