Rev 7692 | 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 |
||
4162 | bpr | 4 | |
4351 | bpr | 5 | slib_author=Georges, Khaznadar |
4162 | bpr | 6 | |
20 | reyssat | 7 | slib_example= ,,,,,,,,,sin(x),[],0,0,1.2,1.5,2.4,3.2\ |
475 | georgesk | 8 | 12,8,0,0,1 max t (ms),1 max U (V),blue,red,[255,128,128],sin(x),[0,0,1.3,1.4,2.5,3],0,0,1.2,1.5,2.4,3.2 \ |
9 | ,,,,,,,,,[cos(6.28*t),sin(6.28*t)],[],0,0,1.2,1.5,2.4,3.2 |
||
20 | reyssat | 10 | |
11 | !exit |
||
12 | |||
13 | :proc |
||
14 | |||
15 | !reset slib_xd, slib_yd, slib_bg, slib_lc, slib_dc, slib_point, slib_xo, slib_yo, slib_xs, slib_ys, slib_correct slib_f, slib_labx, slib_laby, slib_maxx, slib_maxy |
||
16 | |||
17 | slib_parm=!item 1 to 11 of $wims_read_parm |
||
18 | !distribute item $slib_parm into slib_xd, slib_yd, slib_xo, slib_yo, slib_xs, slib_ys, slib_bg, slib_lc, slib_dc, slib_f, slib_correct |
||
19 | |||
20 | slib_point=!item 12 to -1 of $wims_read_parm |
||
21 | |||
22 | |||
23 | !default slib_xd=8 |
||
24 | !default slib_yd=8 |
||
25 | !default slib_xo=1 |
||
26 | !default slib_yo=1 |
||
27 | !default slib_xs=1 |
||
28 | !default slib_ys=1 |
||
29 | !default slib_correct=[] |
||
30 | |||
475 | georgesk | 31 | slib_f = !declosing $slib_f |
32 | |||
20 | reyssat | 33 | slib_labx=!word 2 to -1 of $slib_xs |
34 | slib_laby=!word 2 to -1 of $slib_ys |
||
35 | slib_xs=!word 1 of $slib_xs |
||
36 | slib_ys=!word 1 of $slib_ys |
||
37 | |||
38 | slib_maxx=!word 1 of $slib_labx |
||
39 | !if $slib_maxx = max |
||
40 | slib_labx = !word 2 to -1 of $slib_labx |
||
41 | !! we need to compute the X step slib_xs, given the values |
||
42 | !! of the total width slib_xd, abscissa of origin slib_xo |
||
43 | !! and knowing that slib_xs currently means a maximum value. |
||
44 | !! slib_xd-slib_xo must be be sufficient to display ticks greater |
||
45 | !! than the current value of slib_xs, the tick step being a multiple |
||
46 | !! of 1, 2 or 5. |
||
47 | slib_log=$[log10($slib_xs/($slib_xd-$slib_xo))] |
||
48 | slib_logint=$[floor($slib_log)] |
||
49 | slib_logmant=$[$slib_log-$slib_logint] |
||
50 | !if $slib_logmant > $[log10(5)] |
||
51 | slib_xs=1e$[$slib_logint+1] |
||
52 | !else |
||
53 | !if $slib_logmant > $[log10(2)] |
||
54 | slib_xs=5e$slib_logint |
||
55 | !else |
||
56 | slib_xs=2e$slib_logint |
||
57 | !endif |
||
58 | !endif |
||
59 | !else |
||
60 | slib_maxx=$empty |
||
61 | !endif |
||
62 | |||
63 | slib_maxy=!word 1 of $slib_laby |
||
64 | !if $slib_maxy = max |
||
65 | slib_laby = !word 2 to -1 of $slib_laby |
||
66 | !! we need to compute the Y step slib_ys, given the values |
||
67 | !! of the total height slib_yd, ordinate of origin slib_yo |
||
68 | !! and knowing that slib_ys currently means a maximum value. |
||
69 | !! slib_yd-slib_yo must be be sufficient to display ticks greater |
||
70 | !! than the current value of slib_ys, the tick step being a multiple |
||
71 | !! of 1, 2 or 5. |
||
72 | slib_log=$[log10($slib_ys/($slib_yd-$slib_yo))] |
||
73 | slib_logint=$[floor($slib_log)] |
||
74 | slib_logmant=$[$slib_log-$slib_logint] |
||
75 | !if $slib_logmant > $[log10(5)] |
||
76 | slib_ys=1e$[$slib_logint+1] |
||
77 | !else |
||
78 | !if $slib_logmant > $[log10(2)] |
||
79 | slib_ys=5e$slib_logint |
||
80 | !else |
||
81 | slib_ys=2e$slib_logint |
||
82 | !endif |
||
83 | !endif |
||
84 | !else |
||
85 | slib_maxy=$empty |
||
86 | !endif |
||
87 | |||
88 | slib_dc=!declosing $slib_dc |
||
89 | |||
90 | slib_correct=!declosing $slib_correct |
||
91 | slib_point=!declosing $slib_point |
||
92 | |||
93 | slib_bg=!declosing $slib_bg |
||
94 | !default slib_bg=240,233,255 |
||
95 | |||
96 | slib_lc=!declosing $slib_lc |
||
97 | !default slib_lc=255,220,180 |
||
98 | |||
99 | slib_dc=!declosing $slib_dc |
||
100 | !default slib_dc=10,10,10 |
||
101 | |||
102 | !!!!!!!!!!!!!!!!! begin grid !!!!!!!!!!!!!!!!!!!!!!!!! |
||
103 | |||
104 | slib_grey=128,128,128 |
||
105 | |||
106 | slib_dessin = new 60*$slib_xd,60*$slib_yd\ |
||
107 | xrange -0.5, 10*$slib_xd-0.5\ |
||
108 | yrange -0.5, 10*$slib_yd-0.5\ |
||
109 | fill 1,1,$slib_bg |
||
110 | |||
111 | !! traits fins tous les millimetres |
||
112 | slib_dessin=$slib_dessin\ |
||
113 | linewidth 1\ |
||
114 | parallel 0, 0, 0, 10*$slib_yd, 1, 0, 10*$slib_xd+1, $slib_lc\ |
||
115 | parallel 0, 0, 10*$slib_xd, 0, 0, 1, 10*$slib_yd+1, $slib_lc |
||
116 | |||
117 | !! traits gros tous les centimetres |
||
118 | slib_dessin=$slib_dessin\ |
||
119 | linewidth 3\ |
||
120 | parallel 0, 0, 0, 10*$slib_yd, 10, 0, $slib_xd+1, $slib_lc\ |
||
121 | parallel 0, 0, 10*$slib_xd, 0, 0, 10, $slib_yd+1, $slib_lc |
||
122 | |||
123 | !! axe_x |
||
124 | slib_dessin=$slib_dessin\ |
||
125 | linewidth 3\ |
||
126 | hline 0, $[10*$slib_yo], $slib_grey\ |
||
8584 | bpr | 127 | segment $[10*$slib_xd-3],$[10*$slib_yo-1],$[10*$slib_xd-1],$[10*$slib_yo], $slib_grey\ |
128 | segment $[10*$slib_xd-3],$[10*$slib_yo+1],$[10*$slib_xd-1],$[10*$slib_yo], $slib_grey\ |
||
20 | reyssat | 129 | parallel 0,$[10*$slib_yo+1],0,$[10*$slib_yo-1], 10, 0, $slib_xd+1, $slib_grey |
130 | |||
131 | slib_val=$[-$slib_xo*$slib_xs] |
||
132 | slib_dessin=$slib_dessin\ |
||
133 | linewidth 1 |
||
134 | !for slib_x from 0 to 10*$slib_xd step 10 |
||
135 | slib_dessin=$slib_dessin\ |
||
136 | text blue,$[$slib_x+1],$[10*$slib_yo-1],medium,$slib_val |
||
137 | slib_val=$[$slib_val+$slib_xs] |
||
138 | !next slib_x |
||
139 | !if $slib_labx != $empty |
||
140 | slib_dessin=$slib_dessin\ |
||
141 | text blue,$[$slib_x-20],$[10*$slib_yo-6],medium,$slib_labx |
||
142 | !endif |
||
143 | |||
144 | !! axe_y |
||
145 | slib_dessin=$slib_dessin\ |
||
146 | linewidth 3\ |
||
147 | vline $[10*$slib_xo],0, $slib_grey\ |
||
8584 | bpr | 148 | segment $[10*$slib_xo-1],$[10*$slib_yd-3],$[10*$slib_xo],$[10*$slib_yd-1], $slib_grey\ |
149 | segment $[10*$slib_xo+1],$[10*$slib_yd-3],$[10*$slib_xo],$[10*$slib_yd-1], $slib_grey\ |
||
20 | reyssat | 150 | parallel $[10*$slib_xo+1],0,$[10*$slib_xo-1], 0, 0, 10, $slib_yd+1, $slib_grey |
151 | |||
152 | slib_val=$[-$slib_yo*$slib_ys] |
||
153 | slib_dessin=$slib_dessin\ |
||
154 | linewidth 1 |
||
155 | !for slib_y from 0 to 10*$slib_yd step 10 |
||
156 | slib_dessin=$slib_dessin\ |
||
157 | text blue,$[10*$slib_xo+1],$[$slib_y-1],medium,$slib_val |
||
158 | slib_val=$[$slib_val+$slib_ys] |
||
159 | !next slib_y |
||
160 | !if $slib_laby != $empty |
||
161 | slib_dessin=$slib_dessin\ |
||
162 | text blue,$[10*$slib_xo-9],$[$slib_y-10],medium,$slib_laby |
||
163 | !endif |
||
164 | |||
165 | !!!!!!!!!!!!!!!!! end grid !!!!!!!!!!!!!!!!!!!!!!!!! |
||
166 | |||
167 | !! red dots : the correct list |
||
168 | n1=!itemcnt $slib_correct |
||
169 | !for i from 1 to $n1 step 2 |
||
170 | !if $i < $n1 |
||
171 | slib_x=!item $i of $slib_correct |
||
172 | slib_x=$[10*$slib_x/$slib_xs] |
||
173 | slib_y=!item $[$i+1] of $slib_correct |
||
174 | slib_y=$[10*$slib_y/$slib_ys] |
||
175 | slib_x1=$[10*$slib_xo+$slib_x-0.6] |
||
176 | slib_x2=$[10*$slib_xo+$slib_x+0.6] |
||
177 | slib_y1=$[10*$slib_yo+$slib_y-0.6] |
||
178 | slib_y2=$[10*$slib_yo+$slib_y+0.6] |
||
179 | !! add one red dot |
||
180 | slib_dessin=$slib_dessin\ |
||
181 | linewidth 2\ |
||
8584 | bpr | 182 | segment $slib_x1,$slib_y1,$slib_x2,$slib_y2,red\ |
183 | segment $slib_x2,$slib_y1,$slib_x1,$slib_y2,red |
||
20 | reyssat | 184 | !endif $i < $n1 |
185 | !next i |
||
186 | |||
187 | !! the function : blue thin curve |
||
475 | georgesk | 188 | slib_n = !itemcnt $slib_f |
189 | !if $slib_n = 1 |
||
190 | slib_f = !replace internal x by ($slib_xs/10*(x-10*$slib_xo)) in $slib_f |
||
191 | slib_f = 10*($slib_f)/$slib_ys+10*$slib_yo |
||
192 | !else |
||
193 | slib_x = !item 1 of $slib_f |
||
194 | slib_y = !item 2 of $slib_f |
||
195 | slib_x = 10*($slib_x/$slib_xs+$slib_xo) |
||
196 | slib_y = 10*($slib_y/$slib_ys+$slib_yo) |
||
197 | slib_f = $slib_x, $slib_y |
||
198 | !endif |
||
199 | |||
20 | reyssat | 200 | slib_dessin=$slib_dessin\ |
201 | plot blue, $slib_f |
||
202 | |||
203 | !! black dots |
||
204 | n2=!itemcnt $slib_point |
||
205 | !for i from 1 to $n2 step 2 |
||
206 | !if $i < $n2 |
||
207 | slib_x=!item $i of $slib_point |
||
208 | slib_x=$[10*$slib_x/$slib_xs] |
||
209 | slib_y=!item $[$i+1] of $slib_point |
||
210 | slib_y=$[10*$slib_y/$slib_ys] |
||
211 | slib_x1=$[10*$slib_xo+$slib_x-0.6] |
||
212 | slib_x2=$[10*$slib_xo+$slib_x+0.6] |
||
213 | slib_y1=$[10*$slib_yo+$slib_y-0.6] |
||
214 | slib_y2=$[10*$slib_yo+$slib_y+0.6] |
||
215 | !! add one '$slib_dc' dot |
||
216 | slib_dessin=$slib_dessin\ |
||
217 | linewidth 2\ |
||
8584 | bpr | 218 | segment $slib_x1,$slib_y1,$slib_x2,$slib_y2,$slib_dc\ |
219 | segment $slib_x2,$slib_y1,$slib_x1,$slib_y2,$slib_dc |
||
20 | reyssat | 220 | !endif $i < $n2 |
221 | !next i |
||
222 | |||
223 | slib_out= $slib_dessin |