Subversion Repositories wimsdev

Rev

Rev 8584 | Details | Compare with Previous | Last modification | View Log | RSS feed

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