1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234
|
//genesis
function expscale(factor, form)
float factor
str form
str field
float value
field = {getfield {form}/field value}
value = {getfield {form}/{field} value}
value = value*factor
setfield {form}/{field} value {value}
end
function linscale(factor, form)
float factor
str form
str field
float value
float v1, v2
float r
float l, t
int il, it
float corr
field = {getfield {form}/field value}
value = {getfield {form}/{field} value}
r = value
r = {abs {r}}
l = {log {r}}/{log 10}
if (l < 0)
il = l - 1
it = {pow 10 {-il}}
else
il = l
it = {pow 10 {il}}
end
t = il
t = {pow 10 {il}}
l = r/t
if (l > 9.999)
t = t*10.0
l = l/10.0
if (il < 0)
it = it/10
else
it = it*10
end
il = il + 1
end
// echo l = {l}, il = {il}, r = {r}, t = {t}
if ((l >= 0.999) && (l < 2))
r = t*0.1
end
if ((l >= 1.999) && (l < 5))
r = t*0.2
end
if (l >= 4.999)
r = t*0.5
end
if (value > 0)
corr = 0.5
else
corr = -0.5
end
t = it
if (il > 0)
value = {trunc {((value + r*factor)*10.0/t + corr)}}*t/10.0
else
value = {trunc {((value + r*factor)*t*10.0 + corr)}}/(t*10.0)
end
setfield {form}/{field} value {value}
end
function overscale(graph, widget)
str graph, widget
if ({getfield {widget} state} == 1)
setfield {graph} overlay 1
else
setfield {graph} overlay 0
end
end
function scalegraph(graph)
str graph
int x, y, w
str temp
//DHB temp = {getfield {graph} form}
//DHB x = {getfield {temp} x}
//DHB y = {getfield {temp} y}
x = {getfield {graph}/.. xgeom}
y = {getfield {graph}/.. ygeom}
create x1form {graph}_scale [{x},{y},200,280] -title Scale
create x1button {graph}/scale [0,0,50,] -script \
"xshowontop "{graph}_scale
create x1toggle {graph}/overlay [170,0,120,] -script \
"overscale "{graph}" "<widget>
setfield ^ label0 "do not overlay" label1 "overlay"
pushe {graph}_scale
create x1button "<<" [2%,35,20%,] -script \
"expscale 0.5 "{graph}_scale
create x1button "<" [24%,35,20%,] -script \
"linscale -1.0 "{graph}_scale
create x1button " >" [56%,35,20%,] -script \
"linscale 1.0 "{graph}_scale
create x1button " >>" [78%,35,20%,] -script \
"expscale 2.0 "{graph}_scale
create x1dialog field -value xmin -script "setwidgfield "<widget>
create x1dialog xmin -value {getfield {graph} xmin}
create x1dialog xmax -value {getfield {graph} xmax}
create x1dialog ymin -value {getfield {graph} ymin}
create x1dialog ymax -value {getfield {graph} ymax}
create x1button APPLY -script \
"applyscale "{graph}" "{graph}_scale" 0"
create x1button APPLY_AND_VANISH -script \
"applyscale "{graph}" "{graph}_scale" 1"
pope
end
function setwidgfield(widget)
str widget
str field
field = {getfield {widget} value}
if ({strcmp {field} xmin} == 0)
setfield {widget} value xmax
end
if ({strcmp {field} xmax} == 0)
setfield {widget} value ymin
end
if ({strcmp {field} ymin} == 0)
setfield {widget} value ymax
end
if ({strcmp {field} ymax} == 0)
setfield {widget} value xmin
end
end
function applyscale(graph, form, vanish)
str graph, form
int vanish
float xmin, ymin, xmax, ymax
xmin = {getfield {form}/xmin value}
xmax = {getfield {form}/xmax value}
ymin = {getfield {form}/ymin value}
ymax = {getfield {form}/ymax value}
if (xmin > xmax)
setfield {form}/xmin value {xmax}
setfield {form}/xmax value {xmin}
xmin = {getfield {form}/xmin value}
xmax = {getfield {form}/xmax value}
end
if (ymin > ymax)
setfield {form}/ymin value {ymax}
setfield {form}/ymax value {ymin}
ymin = {getfield {form}/ymin value}
ymax = {getfield {form}/ymax value}
end
if (xmin != {getfield {graph} xmin})
setfield {graph} xmin {xmin}
end
if (xmax != {getfield {graph} xmax})
setfield {graph} xmax {xmax}
end
if (ymin != {getfield {graph} ymin})
setfield {graph} ymin {ymin}
end
if (ymax != {getfield {graph} ymax})
setfield {graph} ymax {ymax}
end
/*
set {graph} xmin {xmin} ymin {ymin} xmax {xmax} ymax {ymax}
*/
if (vanish)
xhide {form}
end
end
function do_xgraph(num)
str num
int xoutwidth = (user_screenwidth - 380)/2
if ({strcmp {num} "1"} == 0)
if ((user_numxouts) == 1)
create x1form {cellpath}graph1 [380,540,600,350] \
-nolabel
else
create x1form {cellpath}graph1 [380,540,450,350] \
-nolabel
end
else
create x1form {cellpath}graph2 \
[{380 + xoutwidth},540,{xoutwidth},350] -nolabel
end
pushe {cellpath}graph{num}
disable .
create x1graph graph [1%,5%,98%,95%] -range [0,-0.1,0.1,0.4]
setfield ^ XUnits Sec
if ({strcmp {num} "1"} == 0)
setfield graph yoffset {user_yoffset1} xmax {user_xmax1} \
ymin {user_ymin1} ymax {user_ymax1}
else
setfield graph yoffset {user_yoffset2} xmax {user_xmax2} \
ymin {user_ymin2} ymax {user_ymax2}
end
useclock graph 9
scalegraph {cellpath}graph{num}/graph
create x1button {cellpath}graph{num}/graph/new_colors \
[70,0,80,] -script "color_plot "{num}
pope
end
|