Rev 20 | Rev 4162 | Go to most recent revision | Details | Compare with Previous | 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 \ |
||
2100 | georgesk | 15 | void, <ol><li>optional list of style specifications. The syntax of style specifications is : <ul><li><span style="color:green;">style:grad={xy, no, x_only, y_only}</span> for graduations [defaults to xy], to draw respectively both graduations, no graduations, graduations only on x axis, graduations only on y axis ;<li><span style="color:green;">style:dot={+,x,o}</span> for dots [defaults to +], to make dots like straight crosses, oblique crosses, circles. </ul><li>Then optional list of dots (an even count of coordinates : x1,y1,x2,y2,etc.)</ul> |
20 | reyssat | 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, \ |
||
2100 | georgesk | 19 | put them in brackets ; there may be no dots.<br><br> \ |
20 | The syntax for <b>x_step</b> and <b>y_step</b> is the following : \ |
||
20 | reyssat | 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\ |
||
2100 | georgesk | 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 | 12,8,0,0,1 max t (ms),1 max U (V),blue,red,[255,128,128],style.grad=x_only, style.dot=o,0,0,1.2,1.5,2.4,3.2 |
||
20 | reyssat | 27 | |
28 | |||
29 | !exit |
||
30 | |||
31 | :proc |
||
32 | |||
2100 | georgesk | 33 | !reset slib_formdot,slib_grad,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, slib_style, slib_empty, slib_key, slib_val, slib_pos |
20 | reyssat | 34 | |
35 | slib_parm=!item 1 to 9 of $wims_read_parm |
||
36 | !distribute item $slib_parm into slib_xd, slib_yd, slib_xo, slib_yo, slib_xs, slib_ys, slib_bg, slib_lc, slib_dc |
||
37 | |||
38 | slib_point=!item 10 to -1 of $wims_read_parm |
||
39 | |||
2100 | georgesk | 40 | slib_empty= |
41 | slib_style=!item 1 of $slib_point |
||
42 | slib_pos=!positionof style: in $slib_style |
||
43 | !while $slib_pos=0 |
||
44 | slib_point=!item 2 to -1 of $slib_point |
||
45 | slib_style= !replace style: by $slib_empty in $slib_style |
||
46 | slib_style= !replace = by , in $slib_style |
||
47 | !distribute item $slib_style into slib_key, slib_val |
||
48 | !if $slib_key=grad |
||
49 | !if $slib_val=no |
||
50 | slib_grad=0 |
||
51 | !endif |
||
52 | !if $slib_val=x_only |
||
53 | slib_grad=2 |
||
54 | !endif |
||
55 | !if $slib_val=y_only |
||
56 | slib_grad=3 |
||
57 | !endif |
||
58 | !endif |
||
59 | !if $slib_key=dot |
||
60 | !if $slib_val=x |
||
61 | slib_formdot=0 |
||
62 | !endif |
||
63 | !if $slib_val=o |
||
64 | slib_formdot=2 |
||
65 | !endif |
||
66 | !endif |
||
67 | slib_style=!item 1 of $slib_point |
||
68 | slib_pos=!positionof style: in $slib_style |
||
69 | !endwhile |
||
70 | |||
20 | reyssat | 71 | !default slib_xd=8 |
72 | !default slib_yd=8 |
||
73 | !default slib_xo=1 |
||
74 | !default slib_yo=1 |
||
75 | !default slib_xs=1 |
||
76 | !default slib_ys=1 |
||
2100 | georgesk | 77 | !default slib_grad=1 |
78 | !default slib_formdot=1 |
||
20 | reyssat | 79 | |
80 | slib_labx=!word 2 to -1 of $slib_xs |
||
81 | slib_laby=!word 2 to -1 of $slib_ys |
||
82 | slib_xs=!word 1 of $slib_xs |
||
83 | slib_ys=!word 1 of $slib_ys |
||
84 | |||
85 | slib_maxx=!word 1 of $slib_labx |
||
86 | !if $slib_maxx = max |
||
87 | slib_labx = !word 2 to -1 of $slib_labx |
||
88 | !! we need to compute the X step slib_xs, given the values |
||
89 | !! of the total width slib_xd, abscissa of origin slib_xo |
||
90 | !! and knowing that slib_xs currently means a maximum value. |
||
91 | !! slib_xd-slib_xo must be be sufficient to display ticks greater |
||
92 | !! than the current value of slib_xs, the tick step being a multiple |
||
93 | !! of 1, 2 or 5. |
||
94 | slib_log=$[log10($slib_xs/($slib_xd-$slib_xo))] |
||
95 | slib_logint=$[floor($slib_log)] |
||
96 | slib_logmant=$[$slib_log-$slib_logint] |
||
97 | !if $slib_logmant > $[log10(5)] |
||
98 | slib_xs=1e$[$slib_logint+1] |
||
99 | !else |
||
100 | !if $slib_logmant > $[log10(2)] |
||
101 | slib_xs=5e$slib_logint |
||
102 | !else |
||
103 | slib_xs=2e$slib_logint |
||
104 | !endif |
||
105 | !endif |
||
106 | !else |
||
107 | slib_maxx=$empty |
||
108 | !endif |
||
109 | |||
110 | slib_maxy=!word 1 of $slib_laby |
||
111 | !if $slib_maxy = max |
||
112 | slib_laby = !word 2 to -1 of $slib_laby |
||
113 | !! we need to compute the Y step slib_ys, given the values |
||
114 | !! of the total height slib_yd, ordinate of origin slib_yo |
||
115 | !! and knowing that slib_ys currently means a maximum value. |
||
116 | !! slib_yd-slib_yo must be be sufficient to display ticks greater |
||
117 | !! than the current value of slib_ys, the tick step being a multiple |
||
118 | !! of 1, 2 or 5. |
||
119 | slib_log=$[log10($slib_ys/($slib_yd-$slib_yo))] |
||
120 | slib_logint=$[floor($slib_log)] |
||
121 | slib_logmant=$[$slib_log-$slib_logint] |
||
122 | !if $slib_logmant > $[log10(5)] |
||
123 | slib_ys=1e$[$slib_logint+1] |
||
124 | !else |
||
125 | !if $slib_logmant > $[log10(2)] |
||
126 | slib_ys=5e$slib_logint |
||
127 | !else |
||
128 | slib_ys=2e$slib_logint |
||
129 | !endif |
||
130 | !endif |
||
131 | !else |
||
132 | slib_maxy=$empty |
||
133 | !endif |
||
134 | |||
135 | slib_dc=!declosing $slib_dc |
||
136 | |||
137 | slib_point=!declosing $slib_point |
||
138 | |||
139 | slib_bg=!declosing $slib_bg |
||
140 | !default slib_bg=240,233,255 |
||
141 | |||
142 | slib_lc=!declosing $slib_lc |
||
143 | !default slib_lc=255,220,180 |
||
144 | |||
145 | slib_dc=!declosing $slib_dc |
||
146 | !default slib_dc=10,10,10 |
||
147 | |||
148 | !!!!!!!!!!!!!!!!! begin grid !!!!!!!!!!!!!!!!!!!!!!!!! |
||
149 | |||
150 | slib_grey=128,128,128 |
||
151 | |||
152 | slib_dessin = new 60*$slib_xd,60*$slib_yd\ |
||
153 | xrange -0.5, 10*$slib_xd-0.5\ |
||
154 | yrange -0.5, 10*$slib_yd-0.5\ |
||
155 | fill 1,1,$slib_bg |
||
156 | |||
157 | !! traits fins tous les millimetres |
||
158 | slib_dessin=$slib_dessin\ |
||
159 | linewidth 1\ |
||
160 | parallel 0, 0, 0, 10*$slib_yd, 1, 0, 10*$slib_xd+1, $slib_lc\ |
||
161 | parallel 0, 0, 10*$slib_xd, 0, 0, 1, 10*$slib_yd+1, $slib_lc |
||
162 | |||
163 | !! traits gros tous les centimetres |
||
164 | slib_dessin=$slib_dessin\ |
||
165 | linewidth 3\ |
||
166 | parallel 0, 0, 0, 10*$slib_yd, 10, 0, $slib_xd+1, $slib_lc\ |
||
167 | parallel 0, 0, 10*$slib_xd, 0, 0, 10, $slib_yd+1, $slib_lc |
||
168 | |||
169 | !! axe_x |
||
170 | slib_dessin=$slib_dessin\ |
||
171 | linewidth 3\ |
||
172 | hline 0, $[10*$slib_yo], $slib_grey\ |
||
173 | line $[10*$slib_xd-3],$[10*$slib_yo-1],$[10*$slib_xd-1],$[10*$slib_yo], $slib_grey\ |
||
174 | line $[10*$slib_xd-3],$[10*$slib_yo+1],$[10*$slib_xd-1],$[10*$slib_yo], $slib_grey\ |
||
175 | parallel 0,$[10*$slib_yo+1],0,$[10*$slib_yo-1], 10, 0, $slib_xd+1, $slib_grey |
||
176 | |||
177 | slib_val=$[-$slib_xo*$slib_xs] |
||
178 | slib_dessin=$slib_dessin\ |
||
179 | linewidth 1 |
||
2100 | georgesk | 180 | !if ($slib_grad=2 or $slib_grad=1) |
20 | reyssat | 181 | !for slib_x from 0 to 10*$slib_xd step 10 |
182 | slib_dessin=$slib_dessin\ |
||
183 | text blue,$[$slib_x+1],$[10*$slib_yo-1],medium,$slib_val |
||
184 | slib_val=$[$slib_val+$slib_xs] |
||
185 | !next slib_x |
||
186 | !if $slib_labx != $empty |
||
187 | slib_dessin=$slib_dessin\ |
||
188 | text blue,$[$slib_x-20],$[10*$slib_yo-6],medium,$slib_labx |
||
189 | !endif |
||
2100 | georgesk | 190 | !endif |
20 | reyssat | 191 | |
192 | !! axe_y |
||
193 | slib_dessin=$slib_dessin\ |
||
194 | linewidth 3\ |
||
195 | vline $[10*$slib_xo],0, $slib_grey\ |
||
196 | line $[10*$slib_xo-1],$[10*$slib_yd-3],$[10*$slib_xo],$[10*$slib_yd-1], $slib_grey\ |
||
197 | line $[10*$slib_xo+1],$[10*$slib_yd-3],$[10*$slib_xo],$[10*$slib_yd-1], $slib_grey\ |
||
198 | parallel $[10*$slib_xo+1],0,$[10*$slib_xo-1], 0, 0, 10, $slib_yd+1, $slib_grey |
||
199 | |||
200 | slib_val=$[-$slib_yo*$slib_ys] |
||
201 | slib_dessin=$slib_dessin\ |
||
202 | linewidth 1 |
||
2100 | georgesk | 203 | !if ($slib_grad=3 or $slib_grad=1) |
20 | reyssat | 204 | !for slib_y from 0 to 10*$slib_yd step 10 |
205 | slib_dessin=$slib_dessin\ |
||
206 | text blue,$[10*$slib_xo+1],$[$slib_y-1],medium,$slib_val |
||
207 | slib_val=$[$slib_val+$slib_ys] |
||
208 | !next slib_y |
||
209 | !if $slib_laby != $empty |
||
210 | slib_dessin=$slib_dessin\ |
||
211 | text blue,$[10*$slib_xo-9],$[$slib_y-10],medium,$slib_laby |
||
212 | !endif |
||
2100 | georgesk | 213 | !endif |
20 | reyssat | 214 | |
215 | !!!!!!!!!!!!!!!!! end grid !!!!!!!!!!!!!!!!!!!!!!!!! |
||
216 | |||
217 | slib_i=0 |
||
218 | !for slib_xy in $slib_point |
||
219 | !if $slib_i=0 |
||
220 | slib_i=1 |
||
221 | slib_x=$[10*$slib_xy/$slib_xs] |
||
222 | !goto continue |
||
223 | !endif |
||
224 | !if $slib_i=1 |
||
225 | slib_i=0 |
||
226 | slib_y=$[10*$slib_xy/$slib_ys] |
||
2100 | georgesk | 227 | !if $slib_formdot=0 |
20 | reyssat | 228 | slib_x1=$[10*$slib_xo+$slib_x-0.6] |
229 | slib_x2=$[10*$slib_xo+$slib_x+0.6] |
||
230 | slib_y1=$[10*$slib_yo+$slib_y-0.6] |
||
231 | slib_y2=$[10*$slib_yo+$slib_y+0.6] |
||
232 | slib_dessin=$slib_dessin\ |
||
233 | linewidth 2\ |
||
234 | line $slib_x1,$slib_y1,$slib_x2,$slib_y2,$slib_dc\ |
||
235 | line $slib_x2,$slib_y1,$slib_x1,$slib_y2,$slib_dc |
||
236 | !endif |
||
2100 | georgesk | 237 | !if $slib_formdot=1 |
238 | slib_x1=$[10*$slib_xo+$slib_x-1] |
||
239 | slib_x2=$[10*$slib_xo+$slib_x+1] |
||
240 | slib_x3=$[10*$slib_xo+$slib_x] |
||
241 | slib_y1=$[10*$slib_yo+$slib_y] |
||
242 | slib_y2=$[10*$slib_yo+$slib_y+1] |
||
243 | slib_y3=$[10*$slib_yo+$slib_y-1] |
||
244 | slib_dessin=$slib_dessin\ |
||
245 | linewidth 2\ |
||
246 | line $slib_x1,$slib_y1,$slib_x2,$slib_y1,$slib_dc\ |
||
247 | line $slib_x3,$slib_y2,$slib_x3,$slib_y3,$slib_dc |
||
248 | !endif |
||
249 | !if $slib_formdot=2 |
||
250 | slib_dessin=$slib_dessin\ |
||
251 | linewidth 1\ |
||
252 | circle $slib_xo+$slib_x,$slib_yo+$slib_y,6,$slib_dc |
||
253 | !endif |
||
254 | !endif |
||
20 | reyssat | 255 | :continue |
256 | !next slib_xy |
||
257 | |||
258 | slib_out= $slib_dessin |