Rev 2100 | Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
20 | reyssat | 1 | !if $wims_read_parm!=slib_header |
2 | !goto proc |
||
3 | !endif |
||
4 | slib_title=Graphic paper sheet |
||
5 | slib_parms=10\ |
||
6 | 8,x_dimension (cm) \ |
||
7 | 8,y_dimension (cm) \ |
||
8 | 1,x_orig (cm) \ |
||
9 | 1,y_orig (cm) \ |
||
10 | 1,x_step (delta x for 1 cm on the paper or max value for x and optional label ) \ |
||
11 | 1,y_step (delta y for 1 cm on the paper or max value for y and optional label) \ |
||
12 | [240,233,255],background color \ |
||
13 | [255,220,180],lines color \ |
||
14 | [10,10,10],dots color \ |
||
15 | void,list of dots (an even count of coordinates : x1,y1,x2,y2,etc.) |
||
16 | slib_author=Georges KHAZNADAR |
||
17 | slib_out=Source for insdraw-ing a graph paper with the dots on it |
||
18 | slib_comment=if color are three numbers, \ |
||
19 | put them in brackets ; there may be no dots.<br> \ |
||
20 | The syntax for x_step and y_step is the following : |
||
21 | a bare number is for deltaX or deltaY, a number followed by the \ |
||
22 | word "max" means a maximum value, any other words are interpreted \ |
||
23 | like a label for the axis. |
||
24 | slib_example= ,,,,,,,,,0,0,1.2,1.5,2.4,3.2\ |
||
25 | 12,8,0,0,1 max t (ms),1 max U (V),blue,red,[255,128,128],0,0,1.2,1.5,2.4,3.2 |
||
26 | |||
27 | |||
28 | !exit |
||
29 | |||
30 | :proc |
||
31 | |||
32 | !reset slib_xd, slib_yd, slib_bg, slib_lc, slib_dc, slib_point, slib_xo, slib_yo, slib_xs, slib_ys, slib_labx, slib_laby, slib_maxx, slib_maxy |
||
33 | |||
34 | slib_parm=!item 1 to 9 of $wims_read_parm |
||
35 | !distribute item $slib_parm into slib_xd, slib_yd, slib_xo, slib_yo, slib_xs, slib_ys, slib_bg, slib_lc, slib_dc |
||
36 | |||
37 | slib_point=!item 10 to -1 of $wims_read_parm |
||
38 | |||
39 | !default slib_xd=8 |
||
40 | !default slib_yd=8 |
||
41 | !default slib_xo=1 |
||
42 | !default slib_yo=1 |
||
43 | !default slib_xs=1 |
||
44 | !default slib_ys=1 |
||
45 | |||
46 | slib_labx=!word 2 to -1 of $slib_xs |
||
47 | slib_laby=!word 2 to -1 of $slib_ys |
||
48 | slib_xs=!word 1 of $slib_xs |
||
49 | slib_ys=!word 1 of $slib_ys |
||
50 | |||
51 | slib_maxx=!word 1 of $slib_labx |
||
52 | !if $slib_maxx = max |
||
53 | slib_labx = !word 2 to -1 of $slib_labx |
||
54 | !! we need to compute the X step slib_xs, given the values |
||
55 | !! of the total width slib_xd, abscissa of origin slib_xo |
||
56 | !! and knowing that slib_xs currently means a maximum value. |
||
57 | !! slib_xd-slib_xo must be be sufficient to display ticks greater |
||
58 | !! than the current value of slib_xs, the tick step being a multiple |
||
59 | !! of 1, 2 or 5. |
||
60 | slib_log=$[log10($slib_xs/($slib_xd-$slib_xo))] |
||
61 | slib_logint=$[floor($slib_log)] |
||
62 | slib_logmant=$[$slib_log-$slib_logint] |
||
63 | !if $slib_logmant > $[log10(5)] |
||
64 | slib_xs=1e$[$slib_logint+1] |
||
65 | !else |
||
66 | !if $slib_logmant > $[log10(2)] |
||
67 | slib_xs=5e$slib_logint |
||
68 | !else |
||
69 | slib_xs=2e$slib_logint |
||
70 | !endif |
||
71 | !endif |
||
72 | !else |
||
73 | slib_maxx=$empty |
||
74 | !endif |
||
75 | |||
76 | slib_maxy=!word 1 of $slib_laby |
||
77 | !if $slib_maxy = max |
||
78 | slib_laby = !word 2 to -1 of $slib_laby |
||
79 | !! we need to compute the Y step slib_ys, given the values |
||
80 | !! of the total height slib_yd, ordinate of origin slib_yo |
||
81 | !! and knowing that slib_ys currently means a maximum value. |
||
82 | !! slib_yd-slib_yo must be be sufficient to display ticks greater |
||
83 | !! than the current value of slib_ys, the tick step being a multiple |
||
84 | !! of 1, 2 or 5. |
||
85 | slib_log=$[log10($slib_ys/($slib_yd-$slib_yo))] |
||
86 | slib_logint=$[floor($slib_log)] |
||
87 | slib_logmant=$[$slib_log-$slib_logint] |
||
88 | !if $slib_logmant > $[log10(5)] |
||
89 | slib_ys=1e$[$slib_logint+1] |
||
90 | !else |
||
91 | !if $slib_logmant > $[log10(2)] |
||
92 | slib_ys=5e$slib_logint |
||
93 | !else |
||
94 | slib_ys=2e$slib_logint |
||
95 | !endif |
||
96 | !endif |
||
97 | !else |
||
98 | slib_maxy=$empty |
||
99 | !endif |
||
100 | |||
101 | slib_dc=!declosing $slib_dc |
||
102 | |||
103 | slib_point=!declosing $slib_point |
||
104 | |||
105 | slib_bg=!declosing $slib_bg |
||
106 | !default slib_bg=240,233,255 |
||
107 | |||
108 | slib_lc=!declosing $slib_lc |
||
109 | !default slib_lc=255,220,180 |
||
110 | |||
111 | slib_dc=!declosing $slib_dc |
||
112 | !default slib_dc=10,10,10 |
||
113 | |||
114 | !!!!!!!!!!!!!!!!! begin grid !!!!!!!!!!!!!!!!!!!!!!!!! |
||
115 | |||
116 | slib_grey=128,128,128 |
||
117 | |||
118 | slib_dessin = new 60*$slib_xd,60*$slib_yd\ |
||
119 | xrange -0.5, 10*$slib_xd-0.5\ |
||
120 | yrange -0.5, 10*$slib_yd-0.5\ |
||
121 | fill 1,1,$slib_bg |
||
122 | |||
123 | !! traits fins tous les millimetres |
||
124 | slib_dessin=$slib_dessin\ |
||
125 | linewidth 1\ |
||
126 | parallel 0, 0, 0, 10*$slib_yd, 1, 0, 10*$slib_xd+1, $slib_lc\ |
||
127 | parallel 0, 0, 10*$slib_xd, 0, 0, 1, 10*$slib_yd+1, $slib_lc |
||
128 | |||
129 | !! traits gros tous les centimetres |
||
130 | slib_dessin=$slib_dessin\ |
||
131 | linewidth 3\ |
||
132 | parallel 0, 0, 0, 10*$slib_yd, 10, 0, $slib_xd+1, $slib_lc\ |
||
133 | parallel 0, 0, 10*$slib_xd, 0, 0, 10, $slib_yd+1, $slib_lc |
||
134 | |||
135 | !! axe_x |
||
136 | slib_dessin=$slib_dessin\ |
||
137 | linewidth 3\ |
||
138 | hline 0, $[10*$slib_yo], $slib_grey\ |
||
139 | line $[10*$slib_xd-3],$[10*$slib_yo-1],$[10*$slib_xd-1],$[10*$slib_yo], $slib_grey\ |
||
140 | line $[10*$slib_xd-3],$[10*$slib_yo+1],$[10*$slib_xd-1],$[10*$slib_yo], $slib_grey\ |
||
141 | parallel 0,$[10*$slib_yo+1],0,$[10*$slib_yo-1], 10, 0, $slib_xd+1, $slib_grey |
||
142 | |||
143 | slib_val=$[-$slib_xo*$slib_xs] |
||
144 | slib_dessin=$slib_dessin\ |
||
145 | linewidth 1 |
||
146 | !for slib_x from 0 to 10*$slib_xd step 10 |
||
147 | slib_dessin=$slib_dessin\ |
||
148 | text blue,$[$slib_x+1],$[10*$slib_yo-1],medium,$slib_val |
||
149 | slib_val=$[$slib_val+$slib_xs] |
||
150 | !next slib_x |
||
151 | !if $slib_labx != $empty |
||
152 | slib_dessin=$slib_dessin\ |
||
153 | text blue,$[$slib_x-20],$[10*$slib_yo-6],medium,$slib_labx |
||
154 | !endif |
||
155 | |||
156 | |||
157 | !! axe_y |
||
158 | slib_dessin=$slib_dessin\ |
||
159 | linewidth 3\ |
||
160 | vline $[10*$slib_xo],0, $slib_grey\ |
||
161 | line $[10*$slib_xo-1],$[10*$slib_yd-3],$[10*$slib_xo],$[10*$slib_yd-1], $slib_grey\ |
||
162 | line $[10*$slib_xo+1],$[10*$slib_yd-3],$[10*$slib_xo],$[10*$slib_yd-1], $slib_grey\ |
||
163 | parallel $[10*$slib_xo+1],0,$[10*$slib_xo-1], 0, 0, 10, $slib_yd+1, $slib_grey |
||
164 | |||
165 | slib_val=$[-$slib_yo*$slib_ys] |
||
166 | slib_dessin=$slib_dessin\ |
||
167 | linewidth 1 |
||
168 | !for slib_y from 0 to 10*$slib_yd step 10 |
||
169 | slib_dessin=$slib_dessin\ |
||
170 | text blue,$[10*$slib_xo+1],$[$slib_y-1],medium,$slib_val |
||
171 | slib_val=$[$slib_val+$slib_ys] |
||
172 | !next slib_y |
||
173 | !if $slib_laby != $empty |
||
174 | slib_dessin=$slib_dessin\ |
||
175 | text blue,$[10*$slib_xo-9],$[$slib_y-10],medium,$slib_laby |
||
176 | !endif |
||
177 | |||
178 | !!!!!!!!!!!!!!!!! end grid !!!!!!!!!!!!!!!!!!!!!!!!! |
||
179 | |||
180 | slib_i=0 |
||
181 | !for slib_xy in $slib_point |
||
182 | !if $slib_i=0 |
||
183 | slib_i=1 |
||
184 | slib_x=$[10*$slib_xy/$slib_xs] |
||
185 | !goto continue |
||
186 | !endif |
||
187 | !if $slib_i=1 |
||
188 | slib_i=0 |
||
189 | slib_y=$[10*$slib_xy/$slib_ys] |
||
190 | slib_x1=$[10*$slib_xo+$slib_x-0.6] |
||
191 | slib_x2=$[10*$slib_xo+$slib_x+0.6] |
||
192 | slib_y1=$[10*$slib_yo+$slib_y-0.6] |
||
193 | slib_y2=$[10*$slib_yo+$slib_y+0.6] |
||
194 | slib_dessin=$slib_dessin\ |
||
195 | linewidth 2\ |
||
196 | line $slib_x1,$slib_y1,$slib_x2,$slib_y2,$slib_dc\ |
||
197 | line $slib_x2,$slib_y1,$slib_x1,$slib_y2,$slib_dc |
||
198 | !endif |
||
199 | :continue |
||
200 | !next slib_xy |
||
201 | |||
202 | slib_out= $slib_dessin |