| 1 |
#!/usr/bin/env yorick -i |
| 2 |
/* |
| 3 |
Copyright 2007 F. Rigaut |
| 4 |
Copyright 2011-2015 Thibaut Paumard |
| 5 |
|
| 6 |
This file is part of Gyoto. |
| 7 |
|
| 8 |
Gyoto is free software: you can redistribute it and/or modify |
| 9 |
it under the terms of the GNU General Public License as published by |
| 10 |
the Free Software Foundation, either version 3 of the License, or |
| 11 |
(at your option) any later version. |
| 12 |
|
| 13 |
Gyoto is distributed in the hope that it will be useful, |
| 14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 |
GNU General Public License for more details. |
| 17 |
|
| 18 |
You should have received a copy of the GNU General Public License |
| 19 |
along with Gyoto. If not, see <http://www.gnu.org/licenses/>. |
| 20 |
*/ |
| 21 |
|
| 22 |
/* |
| 23 |
gyotoy.i |
| 24 |
main function to call the pygtk GUI to gyotoy. |
| 25 |
syntax: yorick -i gyotoy.i |
| 26 |
*/ |
| 27 |
|
| 28 |
require, "gyoto.i"; |
| 29 |
require, "gyoto_std.i"; |
| 30 |
require, "pl3d.i"; |
| 31 |
// gy_gtk needs to be included after defining gy_gtk_before_init |
| 32 |
// require, "gy_gtk.i"; |
| 33 |
|
| 34 |
func __gyotoy_before_init |
| 35 |
{ |
| 36 |
noop, gy.GLib.set_prgname("Gyotoy"); |
| 37 |
noop, gy.GLib.set_application_name("Gyotoy"); |
| 38 |
noop, gy.Gdk.set_allowed_backends("x11,*"); |
| 39 |
} |
| 40 |
|
| 41 |
GYOTOY_VERSION = "0.2"; |
| 42 |
|
| 43 |
extern _gyotoy_running; |
| 44 |
extern _gyotoy_reticle; |
| 45 |
extern _gyotoy_wstyle; |
| 46 |
extern _gyotoy_stand_alone; |
| 47 |
extern _gyotoy_particle_is_massless; |
| 48 |
extern _gyotoy_metric; |
| 49 |
extern _gyotoy_particle; |
| 50 |
extern _gyotoy_t1; |
| 51 |
extern _gyotoy_delta; |
| 52 |
extern _gyotoy_adaptive; |
| 53 |
extern _gyotoy_initcoord; |
| 54 |
extern _gyotoy_mass; |
| 55 |
extern _gyotoy_distance; |
| 56 |
extern _gyotoy_unit; |
| 57 |
extern _gyotoy_txyz; |
| 58 |
extern _gyotoy_particle_to_load; |
| 59 |
extern _gyotoy_inhibit_redraw; |
| 60 |
extern _gyotoy_metric_file; |
| 61 |
extern _gyotoy_nsteps; |
| 62 |
/* DOCUMENT extern _gyotoy_*; |
| 63 |
Some variable holding state information for use inside gyotoy. |
| 64 |
_running: true if GTK interface is running; |
| 65 |
_reticle: true if reticle should be displayed; |
| 66 |
.yid: Yorick window ID of the Gyotoy plot area; |
| 67 |
_wstyle: window style (normally "nobox.gs"); |
| 68 |
_gyotoy.filename: name of the last file read (careful: can be |
| 69 |
the py file itself) |
| 70 |
_gyotoy_stand_alone: true if the user is not supposed to ever see |
| 71 |
the Yorick prompt. |
| 72 |
_gyotoy_particle_is_massless: true for a photon. |
| 73 |
_gyoto_metric: the actual metric object. |
| 74 |
SEE ALSO: gyotoy |
| 75 |
*/ |
| 76 |
if (is_void(_gyotoy_nsteps)) _gyotoy_nsteps=100 ; |
| 77 |
|
| 78 |
func gyotoy_adaptive(mode, void) { |
| 79 |
extern _gyotoy_adaptive; |
| 80 |
if (!is_numerical(mode)) mode = !mode.get_active(); |
| 81 |
_gyotoy_adaptive=mode; |
| 82 |
if (mode) _gyotoy_particle, setparameter="Adaptive"; |
| 83 |
else _gyotoy_particle, setparameter="NonAdaptive"; |
| 84 |
} |
| 85 |
|
| 86 |
func gyotoy_reset(void){ |
| 87 |
extern _gyotoy_running; |
| 88 |
extern _gyotoy_reticle; |
| 89 |
extern _gyotoy_wstyle; |
| 90 |
extern _gyotoy_stand_alone; |
| 91 |
extern _gyotoy_particle_is_massless; |
| 92 |
extern _gyotoy_metric; |
| 93 |
extern _gyotoy_particle; |
| 94 |
extern _gyotoy_t0; |
| 95 |
extern _gyotoy_t1; |
| 96 |
extern _gyotoy_initcoord; |
| 97 |
extern _gyotoy_mass; |
| 98 |
extern _gyotoy_distance; |
| 99 |
extern _gyotoy_unit; |
| 100 |
extern _gyotoy_txyz; |
| 101 |
extern _gyotoy_particle_to_load; |
| 102 |
|
| 103 |
_gyotoy_particle_is_massless=0; |
| 104 |
_gyotoy_metric=gyoto_KerrBL(spin=0.995); |
| 105 |
_gyotoy_initcoord=[0.,10.791,pi/2,0.,0.,0.,0.016664]; |
| 106 |
_gyotoy_t1=3000.; |
| 107 |
_gyotoy_t0=0.; |
| 108 |
_gyotoy_delta=0.01; |
| 109 |
_gyotoy_particle=gyoto_Star(metric=_gyotoy_metric, |
| 110 |
initcoord=_gyotoy_initcoord(1:4), |
| 111 |
_gyotoy_initcoord(5:7), |
| 112 |
delta=_gyotoy_delta); |
| 113 |
gyotoy_adaptive,1; |
| 114 |
_gyotoy_particle, xfill=_gyotoy_t1; |
| 115 |
_gyotoy_txyz=_gyotoy_particle(get_txyz=1); |
| 116 |
_gyotoy_mass=4e6; |
| 117 |
_gyotoy_distance=8.; |
| 118 |
_gyotoy_unit="geometrical"; |
| 119 |
} |
| 120 |
gyotoy_reset; |
| 121 |
|
| 122 |
func gyotoy_set_unit(unit, data) { |
| 123 |
extern _gyotoy_unit; |
| 124 |
if (!is_string(unit)) { |
| 125 |
if (!unit.get_active()) return; |
| 126 |
unit=gy.Gtk.Buildable(unit).get_name(); |
| 127 |
} |
| 128 |
_gyotoy_unit=unit; |
| 129 |
gyotoy_redraw; |
| 130 |
} |
| 131 |
|
| 132 |
func gyotoy_set_t1(t1, void) |
| 133 |
{ |
| 134 |
extern _gyotoy_txyz, _gyotoy_t1; |
| 135 |
if (!is_numerical(t1)) t1 = t1.get_value(); |
| 136 |
/* if ( (_gyotoy_t1 > _gyotoy_t0 && t1<_gyotoy_t1) || |
| 137 |
(_gyotoy_t1 < _gyotoy_t0 && t1>_gyotoy_t1) ) |
| 138 |
_gyotoy_particle, reset=;*/ |
| 139 |
_gyotoy_t1=t1; |
| 140 |
if (catch(0x08)) return; // avoid breaking in case of v>c |
| 141 |
// _gyotoy_txyz=_gyotoy_particle(xfill=t1, get_txyz=1); |
| 142 |
gyotoy_compute_and_draw; |
| 143 |
} |
| 144 |
|
| 145 |
func gyotoy_set_distance(dist, void) { |
| 146 |
extern _gyotoy_distance; |
| 147 |
if (!is_numerical(dist)) dist = dist.get_value(); |
| 148 |
_gyotoy_distance=dist; |
| 149 |
gyotoy_redraw; |
| 150 |
} |
| 151 |
|
| 152 |
func gyotoy_set_KerrBL_metric(spin, void) |
| 153 |
{ |
| 154 |
extern _gyotoy_metric, _gyotoy_particle, _gyotoy_txyz; |
| 155 |
if (!is_numerical(spin)) spin = spin.get_value(); |
| 156 |
|
| 157 |
_gyotoy_metric = gyoto_KerrBL ( spin = spin ); |
| 158 |
if (_gyotoy_inhibit_redraw) return; |
| 159 |
//if (catch(0x08)) return; // avoid breaking in case of v>c |
| 160 |
_gyotoy_particle,metric=_gyotoy_metric, |
| 161 |
initcoord=_gyotoy_initcoord(1:4), _gyotoy_initcoord(5:7); |
| 162 |
gyotoy_compute_and_draw; |
| 163 |
} |
| 164 |
|
| 165 |
func gyotoy_set_KerrKS_metric(spin, void) |
| 166 |
{ |
| 167 |
extern _gyotoy_metric, _gyotoy_particle, _gyotoy_txyz; |
| 168 |
if (!is_numerical(spin)) spin = spin.get_value(); |
| 169 |
|
| 170 |
_gyotoy_metric = gyoto_KerrKS ( spin = spin ); |
| 171 |
if (_gyotoy_inhibit_redraw) return; |
| 172 |
//if (catch(0x08)) return; // avoid breaking in case of v>c |
| 173 |
_gyotoy_particle,metric=_gyotoy_metric, |
| 174 |
initcoord=_gyotoy_initcoord(1:4), _gyotoy_initcoord(5:7); |
| 175 |
gyotoy_compute_and_draw; |
| 176 |
} |
| 177 |
|
| 178 |
func gyotoy_set_metric(fname, void) |
| 179 |
{ |
| 180 |
extern _gyotoy_metric, _gyotoy_particle, _gyotoy_txyz, _gyotoy_metric_file; |
| 181 |
|
| 182 |
if (catch(0x08)) { |
| 183 |
// avoid breaking in case bad file |
| 184 |
gyotoy_warning, "Unable to load metric. Is this a GYOTO XML description file?"; |
| 185 |
return; |
| 186 |
} |
| 187 |
if (is_void(structof(fname))) |
| 188 |
fname = gy.Gtk.FileChooser(fname).get_filename(); |
| 189 |
if (is_string(fname)) metric=gyoto_Metric(fname); |
| 190 |
if (typeof(metric)!="gyoto_Metric") gyotoy_warning, "Failed to set metric"; |
| 191 |
prev_metric=_gyotoy_metric; |
| 192 |
_gyotoy_metric=metric; |
| 193 |
_gyotoy_metric_file=fname; |
| 194 |
if (catch(0x08)) { |
| 195 |
// avoid breaking in case of v>c or other problem |
| 196 |
gyotoy_warning, "metric loaded but orbit computation failed"; |
| 197 |
_gyotoy_metric=prev_metric; |
| 198 |
_gyotoy_particle,metric=_gyotoy_metric, |
| 199 |
initcoord=_gyotoy_initcoord(1:4), _gyotoy_initcoord(5:7); |
| 200 |
return; |
| 201 |
} |
| 202 |
_gyotoy_particle,metric=_gyotoy_metric, |
| 203 |
initcoord=_gyotoy_initcoord(1:4), _gyotoy_initcoord(5:7); |
| 204 |
gyotoy_compute_and_draw; |
| 205 |
} |
| 206 |
|
| 207 |
func gyotoy_set_initcoord(t0, r0, theta0, phi0, |
| 208 |
rprime0, thetaprime0, phiprime0) { |
| 209 |
extern _gyotoy_initcoord, _gyotoy_txyz, _gyotoy_inhibit_redraw; |
| 210 |
if (!is_numerical(t0)) { |
| 211 |
r0 = _gyotoy.builder.get_object("r0").get_value(); |
| 212 |
theta0 = _gyotoy.builder.get_object("theta0").get_value(); |
| 213 |
phi0 = _gyotoy.builder.get_object("phi0").get_value(); |
| 214 |
t0 = _gyotoy.builder.get_object("t0").get_value(); |
| 215 |
rprime0 = _gyotoy.builder.get_object("rprime0").get_value(); |
| 216 |
thetaprime0 = _gyotoy.builder.get_object("thetaprime0").get_value(); |
| 217 |
phiprime0 = _gyotoy.builder.get_object("phiprime0").get_value(); |
| 218 |
} |
| 219 |
_gyotoy_initcoord=[t0, r0, theta0, phi0, |
| 220 |
rprime0, thetaprime0, phiprime0]; |
| 221 |
_gyotoy_t0=t0; |
| 222 |
if (catch(0x08)) return; // avoid breaking in case of v>c |
| 223 |
_gyotoy_particle, initcoord=_gyotoy_initcoord(1:4),_gyotoy_initcoord(5:7); |
| 224 |
if (_gyotoy_inhibit_redraw) return; |
| 225 |
gyotoy_compute_and_draw; |
| 226 |
} |
| 227 |
|
| 228 |
func gyotoy_redraw(void){ |
| 229 |
/* DOCUMENT gyotoy_redraw |
| 230 |
|
| 231 |
Redraws the Gyotoy plot: |
| 232 |
- convert to UNIT; |
| 233 |
- erase the plot; |
| 234 |
- if requested, draws the reticle; |
| 235 |
- plot the orbit (which triggers drawing the 3d cage). |
| 236 |
|
| 237 |
SEE ALSO: gyoto_Kerr_orbit, gyoto_convert, gyoto_reticle, |
| 238 |
gyoto_plg3 |
| 239 |
*/ |
| 240 |
// [a, e, l, q]; |
| 241 |
// delta; long(niter); |
| 242 |
// Purpose of the "if": gyoto_Kerr_orbit will return 0 if v>c |
| 243 |
|
| 244 |
extern _gyotoy_txyz, _gyotoy_inhibit_redraw; |
| 245 |
if (_gyotoy_inhibit_redraw) return; |
| 246 |
if (numberof(_gyotoy_txyz)>1) { |
| 247 |
t=_gyotoy_txyz(,1); |
| 248 |
n0=abs(t-_gyotoy_t0)(mnx); |
| 249 |
n1=abs(t-_gyotoy_t1)(mnx); |
| 250 |
if (n1>n0) ++n1; else --n1; |
| 251 |
if (n1<1) n1=1; |
| 252 |
if (n1>numberof(t)) n1=numberof(t); |
| 253 |
if (n1<n0) { |
| 254 |
n2=n0; |
| 255 |
n0=n1; |
| 256 |
n1=n2; |
| 257 |
} |
| 258 |
x=_gyotoy_txyz(n0:n1,2); |
| 259 |
y=_gyotoy_txyz(n0:n1,3); |
| 260 |
z=_gyotoy_txyz(n0:n1,4); |
| 261 |
gyoto_convert, x, _gyotoy_mass, _gyotoy_distance, _gyotoy_unit; |
| 262 |
gyoto_convert, y, _gyotoy_mass, _gyotoy_distance, _gyotoy_unit; |
| 263 |
gyoto_convert, z, _gyotoy_mass, _gyotoy_distance, _gyotoy_unit; |
| 264 |
rmax=sqrt(max(x^2+y^2+z^2)); |
| 265 |
|
| 266 |
window, _gyotoy.yid; |
| 267 |
clear3; |
| 268 |
if (_gyotoy_reticle) gyoto_reticle, rmax*1.41421; |
| 269 |
if (gyotoy_origin) gyoto_plmksky,0,0; |
| 270 |
gyoto_plg3, x, y, z; |
| 271 |
limit3,-rmax,rmax,-rmax,rmax,-rmax,rmax; |
| 272 |
//if (is_void(set_idler())) draw3,1; |
| 273 |
//gy_gtk_idleonce; |
| 274 |
} |
| 275 |
|
| 276 |
} |
| 277 |
|
| 278 |
func gyotoy_toggle_reticle(wdg, data) { |
| 279 |
/* DOCUMENT gyotoy_toggle_reticle |
| 280 |
Toggles sky reticle on/off |
| 281 |
SEE ALSO: gyoto_reticle |
| 282 |
*/ |
| 283 |
extern _gyotoy_reticle; |
| 284 |
if (is_void(_gyotoy_reticle)) _gyotoy_reticle=1; |
| 285 |
else _gyotoy_reticle=1-_gyotoy_reticle; |
| 286 |
gyotoy_redraw; |
| 287 |
} |
| 288 |
|
| 289 |
func gyotoy_window_init |
| 290 |
// initialize window in GTK frontend |
| 291 |
{ |
| 292 |
extern _gyotoy_wstyle, _gyotoy_particle, _gyotoy_inhibit_redraw; |
| 293 |
|
| 294 |
iconf = find_in_path("gyotoy.png", takefirst=1, |
| 295 |
path=pathform(_(get_cwd(), |
| 296 |
_(Y_SITES, |
| 297 |
Y_SITE)+"data/"))); |
| 298 |
|
| 299 |
if (iconf) { |
| 300 |
icon = gy.GdkPixbuf.Pixbuf.new_from_file(iconf); |
| 301 |
noop, _gyotoy.toplevel.set_icon(icon); |
| 302 |
} |
| 303 |
|
| 304 |
limits, square=1; |
| 305 |
gnomon,1; |
| 306 |
cage3,1; |
| 307 |
//orient3,pi,-pi/2; |
| 308 |
pldefault, marks=0; |
| 309 |
if (!is_void(_gyotoy_particle_to_load)) gyotoy_set_particle,_gyotoy_particle_to_load; |
| 310 |
else if (_gyotoy.filename) gyotoy_import,_gyotoy.filename; |
| 311 |
//else pyk,"compute_orbit('rien')"; |
| 312 |
_gyotoy_orient3; |
| 313 |
noop, _gyotoy.builder.get_object("metric_type").set_active(0); |
| 314 |
_gyotoy_inhibit_redraw=0; |
| 315 |
gyotoy_compute_and_draw; |
| 316 |
} |
| 317 |
|
| 318 |
func gyotoy_quit(wdg, void1, void2) { |
| 319 |
// called when GTK window is closed |
| 320 |
extern _gyotoy_running; |
| 321 |
if (_gyotoy_stand_alone) quit; |
| 322 |
noop, _gyotoy.toplevel.hide(); |
| 323 |
_gyotoy_running=0; |
| 324 |
gy_gtk_idler_maybe_stop; |
| 325 |
} |
| 326 |
|
| 327 |
func gyotoy_checkvers_cb(msg) { |
| 328 |
extern _gyotoy_pyvers; |
| 329 |
_gyotoy_pyvers=msg; |
| 330 |
} |
| 331 |
|
| 332 |
if (is_void(_gyotoy)) _gyotoy = save(); |
| 333 |
|
| 334 |
func gyotoy(filename) { |
| 335 |
/* DOCUMENT gyotoy [,filename] |
| 336 |
or gyotoy, star |
| 337 |
or gyotoy, photon |
| 338 |
Launch Gyotoy GTK interface |
| 339 |
SEE ALSO: |
| 340 |
*/ |
| 341 |
require, "gy_gtk.i"; |
| 342 |
extern _gyotoy, _gyotoy_running, _gyotoy_particle; |
| 343 |
extern _gyotoy_particle_to_load, _gyotoy_inhibit_redraw; |
| 344 |
local yid; |
| 345 |
yid=[]; |
| 346 |
|
| 347 |
_gyotoy=save(); |
| 348 |
_gyotoy_running=1; |
| 349 |
_gyotoy, filename=[]; |
| 350 |
_gyotoy_particle_to_load=[]; |
| 351 |
_gyotoy_inhibit_redraw=1; |
| 352 |
|
| 353 |
_gyotoy, builder = gy_gtk_builder("gyotoy.xml"); |
| 354 |
|
| 355 |
if (is_string(filename)) _gyotoy, filename=filename; |
| 356 |
else if ((is_gyoto_Astrobj(filename) && filename(kind=)=="Star") |
| 357 |
||typeof(filename)=="gyoto_Photon") |
| 358 |
_gyotoy_particle_to_load=filename; |
| 359 |
else _gyotoy_particle_to_load=_gyotoy_particle; |
| 360 |
|
| 361 |
_gyotoy, toplevel = _gyotoy.builder.get_object("main_window"); |
| 362 |
noop, _gyotoy.builder.get_object("plot_slot"). |
| 363 |
add(gy_gtk_ywindow(yid, style="nobox.gs",on_realize=gyotoy_window_init)); |
| 364 |
_gyotoy, yid = yid; |
| 365 |
noop, _gyotoy.builder.get_object("main_vbox"). |
| 366 |
pack_start(gy_gtk_ycmd(), 0, 0, 0); |
| 367 |
gy_signal_connect, _gyotoy.builder; |
| 368 |
gy_signal_connect, _gyotoy.toplevel, "delete-event", gyotoy_quit; |
| 369 |
|
| 370 |
// git has gy_gtk_main, but it's not yet in the stable release |
| 371 |
if (is_func(gy_gtk_main)) gy_gtk_main, _gyotoy.toplevel; |
| 372 |
else noop, _gyotoy.toplevel.show_all(); |
| 373 |
|
| 374 |
/* |
| 375 |
if (_gyotoy.filename && |
| 376 |
(strglob("*.dat",_gyotoy.filename,case=0) || |
| 377 |
strglob("*.txt",_gyotoy.filename,case=0) || |
| 378 |
strglob("*.xml",_gyotoy.filename,case=0) )) |
| 379 |
pyk,"set_filename('"+_gyotoy.filename+"')"; |
| 380 |
*/ |
| 381 |
} |
| 382 |
|
| 383 |
func _gyotoy_on_realize |
| 384 |
{ |
| 385 |
extern _gyotoy_inhibit_redraw; |
| 386 |
_gyotoy_inhibit_redraw=0; |
| 387 |
gyotoy_redraw; |
| 388 |
} |
| 389 |
|
| 390 |
func gyotoy_set_particle(part) { |
| 391 |
tp = typeof(part); |
| 392 |
if (!((tp == "gyoto_Astrobj" && part(kind=) == "Star") || |
| 393 |
(tp == "gyoto_Photon"))) { |
| 394 |
error, "Particle must be Star or Photon"; |
| 395 |
return; |
| 396 |
} |
| 397 |
|
| 398 |
extern _gyotoy_particle, _gyotoy_metric, _gyotoy_initcoord, _gyotoy_txyz, |
| 399 |
_gyotoy_metric_file, _gyotoy_inhibit_redraw, |
| 400 |
_gyotoy_delta, _gyotoy_adaptive; |
| 401 |
rdr=_gyotoy_inhibit_redraw; |
| 402 |
_gyotoy_inhibit_redraw=1; |
| 403 |
|
| 404 |
omtype=_gyotoy_metric(kind=); |
| 405 |
oldmass=_gyotoy_particle_is_massless; |
| 406 |
|
| 407 |
_gyotoy_particle=part; |
| 408 |
_gyotoy_metric = part(metric=); |
| 409 |
_gyotoy_initcoord=part(initcoord=); |
| 410 |
_gyotoy_delta=part(delta=); |
| 411 |
_gyotoy_adaptive=part(adaptive=); |
| 412 |
|
| 413 |
if (is_gyoto_Astrobj(part)) { |
| 414 |
part_type="star"; |
| 415 |
_gyotoy_particle_is_massless=0; |
| 416 |
} |
| 417 |
else { |
| 418 |
part_type="photon"; |
| 419 |
_gyotoy_particle_is_massless=1; |
| 420 |
} |
| 421 |
if (oldmass != _gyotoy_particle_is_massless) |
| 422 |
_noop, gyotoy.builder.get_object(part_type).set_active(1); |
| 423 |
|
| 424 |
noop, _gyotoy.builder.get_object("delta").set_value(_gyotoy_delta); |
| 425 |
noop, _gyotoy.builder.get_object("adaptive_button"). |
| 426 |
set_active(1-_gyotoy_adaptive); |
| 427 |
|
| 428 |
// Metric & projection |
| 429 |
if ((mtype=_gyotoy_metric(kind=))=="KerrBL") { |
| 430 |
if (omtype != "KerrBL") |
| 431 |
noop, _gyotoy.builder.get_object("metric_type").set_active(0); |
| 432 |
noop, _gyotoy.builder.get_object("spin").set_value(_gyotoy_metric(spin=)); |
| 433 |
} else { |
| 434 |
if (otype == "KerrBL") |
| 435 |
noop, _gyotoy.builder.get_object("metric_type").set_active(1); |
| 436 |
if (_gyotoy.filename) |
| 437 |
noop, gy.Gtk.FileChooser(_gyotoy.builder.get_object("metric_file")). |
| 438 |
set_filename(_gyotoy.filename); |
| 439 |
_gyotoy_metric_file=_gyotoy.filename; |
| 440 |
} |
| 441 |
|
| 442 |
//ok=pyk("set_parameter('incl',"+swrite(format="%.12f",metric(get_inclination=1)*rad2deg)+")"); |
| 443 |
//ok=pyk("set_parameter('paln',"+swrite(format="%.12f",metric(get_paln=1)*rad2deg)+")"); |
| 444 |
//ok=pyk("set_parameter('phase',"+swrite(format="%.12f",metric(get_argument=1)*rad2deg)+")"); |
| 445 |
//ok=pyk("set_parameter('distance',"+swrite(format="%.12f",metric(get_distance=1))+")"); |
| 446 |
// m_sun = 1.98843e30; // kg |
| 447 |
// ok=pyk("set_parameter('mass',"+swrite(format="%.12f",_gyotoy_metric(mass=)/m_sun)+")"); |
| 448 |
|
| 449 |
// Initial condition |
| 450 |
coord = part(initcoord=); |
| 451 |
noop, _gyotoy.builder.get_object("t0").set_value(coord(1)); |
| 452 |
noop, _gyotoy.builder.get_object("r0").set_value(coord(2)); |
| 453 |
noop, _gyotoy.builder.get_object("theta0").set_value(coord(3)); |
| 454 |
noop, _gyotoy.builder.get_object("phi0").set_value(coord(4)); |
| 455 |
|
| 456 |
if (part_type=="star") fact=1./coord(5); |
| 457 |
else fact=1.; |
| 458 |
noop, _gyotoy.builder.get_object("rprime0").set_value(coord(6)*fact); |
| 459 |
noop, _gyotoy.builder.get_object("thetaprime0").set_value(coord(7)*fact); |
| 460 |
noop, _gyotoy.builder.get_object("phiprime0").set_value(coord(8)*fact); |
| 461 |
|
| 462 |
// Wait for parameters to have reached glade |
| 463 |
// pyk,"compute_orbit('rien')"; |
| 464 |
|
| 465 |
// bug ? |
| 466 |
if (mtype != "KerrBL") |
| 467 |
noop, _gyotoy.builder.get_object("metric_type").set_active(1); |
| 468 |
|
| 469 |
|
| 470 |
_gyotoy_inhibit_redraw=rdr; |
| 471 |
gyotoy_compute_and_draw; |
| 472 |
|
| 473 |
} |
| 474 |
|
| 475 |
func gyotoy_set_nsteps(nsteps, void) { |
| 476 |
extern _gyotoy_nsteps; |
| 477 |
if (is_numerical(nsteps)) nsteps=long(nsteps); |
| 478 |
else nsteps = nsteps.get_value(); |
| 479 |
if (nsteps <=0) nsteps=1; |
| 480 |
_gyotoy_nsteps=nsteps; |
| 481 |
} |
| 482 |
|
| 483 |
func gyotoy_compute_and_draw(rien) { |
| 484 |
|
| 485 |
extern _gyotoy_particle, _gyotoy_redrawing, _gyotoy_cancel, _gyotoy_nsteps; |
| 486 |
extern _gyotoy_t1, _gyotoy_inhibit_redraw, _gyotoy_txyz; |
| 487 |
if (_gyotoy_inhibit_redraw) return; |
| 488 |
|
| 489 |
if (_gyotoy_redrawing) { |
| 490 |
_gyotoy_cancel=1; |
| 491 |
return; |
| 492 |
} |
| 493 |
_gyotoy_cancel=0; |
| 494 |
|
| 495 |
if (is_void(_gyotoy_redrawing)) _gyotoy_redrawing=0; |
| 496 |
++_gyotoy_redrawing; |
| 497 |
|
| 498 |
t0 = _gyotoy_particle(initcoord=)(1); |
| 499 |
_gyotoy_txyz=_gyotoy_particle(get_txyz=1); |
| 500 |
if (_gyotoy_t1>=t0) |
| 501 |
t = _gyotoy_txyz(0,1); |
| 502 |
else |
| 503 |
t = _gyotoy_txyz(1,1); |
| 504 |
dt = (_gyotoy_t1-t0)/_gyotoy_nsteps; |
| 505 |
if (dt==0) { |
| 506 |
gyotoy_warning, "t0 and t1 too close."; |
| 507 |
--_gyotoy_redrawing; |
| 508 |
return; |
| 509 |
} |
| 510 |
|
| 511 |
if ( ((t-t0)/(_gyotoy_t1-t0)) >=1 ){ |
| 512 |
gyotoy_set_play_image, "gtk-media-play"; |
| 513 |
gyotoy_set_fraction, (t-t0)/(_gyotoy_t1-t0); |
| 514 |
gyotoy_redraw; |
| 515 |
--_gyotoy_redrawing; |
| 516 |
return; |
| 517 |
} |
| 518 |
|
| 519 |
gyotoy_set_fraction, (t-t0)/(_gyotoy_t1-t0); |
| 520 |
gyotoy_set_play_image, "gtk-media-pause"; |
| 521 |
|
| 522 |
dir = sign(_gyotoy_t1-t0); |
| 523 |
|
| 524 |
for ( ; |
| 525 |
((dir == 1 && t<=_gyotoy_t1+dt) || |
| 526 |
(dir ==-1 && t>=_gyotoy_t1+dt) ) |
| 527 |
&& !_gyotoy_cancel; |
| 528 |
t+=dt) { |
| 529 |
_gyotoy_txyz=_gyotoy_particle(xfill=t, get_txyz=1); |
| 530 |
if ( ( (dir== 1) && _gyotoy_txyz(0,1) < t) || |
| 531 |
( (dir==-1) && _gyotoy_txyz(1,1) > t) ) |
| 532 |
t = _gyotoy_t1+2*dt; |
| 533 |
gyotoy_redraw; |
| 534 |
//gy_gtk_step_once; |
| 535 |
frac=(t-t0)/(_gyotoy_t1-t0); |
| 536 |
if (frac>1.) frac=1; |
| 537 |
gyotoy_set_fraction, frac; |
| 538 |
while (gy.Gtk.events_pending ()) noop, gy.Gtk.main_iteration (); |
| 539 |
} |
| 540 |
|
| 541 |
gyotoy_set_play_image, "gtk-media-play"; |
| 542 |
frac=(t-t0)/(_gyotoy_t1-t0); |
| 543 |
if (frac>1.) frac=1; |
| 544 |
gyotoy_set_fraction, frac; |
| 545 |
|
| 546 |
gyotoy_redraw; |
| 547 |
--_gyotoy_redrawing; |
| 548 |
if (_gyotoy_cancel==2) gyotoy_rewind; |
| 549 |
} |
| 550 |
|
| 551 |
func gyotoy_set_play_image(name) |
| 552 |
{ |
| 553 |
noop, _gyotoy.builder.get_object("play_image"). |
| 554 |
set_from_stock(name, gy.Gtk.IconSize.button); |
| 555 |
} |
| 556 |
|
| 557 |
func gyotoy_rewind(wdg, data) |
| 558 |
{ |
| 559 |
extern _gyotoy_cancel; |
| 560 |
if (_gyotoy_redrawing) { |
| 561 |
_gyotoy_cancel=2; |
| 562 |
return; |
| 563 |
} |
| 564 |
_gyotoy_particle, reset=; |
| 565 |
gyotoy_set_fraction, 0; |
| 566 |
} |
| 567 |
|
| 568 |
func gyotoy_set_fraction(frac) |
| 569 |
{ |
| 570 |
noop, _gyotoy.builder.get_object("progressbar").set_fraction(frac); |
| 571 |
} |
| 572 |
|
| 573 |
func gyotoy_set_delta(delta, void) { |
| 574 |
extern _gyotoy_delta; |
| 575 |
if (!is_numerical(delta)) delta = delta.get_value(); |
| 576 |
_gyotoy_delta=delta; |
| 577 |
_gyotoy_particle, delta=delta; |
| 578 |
} |
| 579 |
|
| 580 |
func gyotoy_inhibit_redraw(mode, data) { |
| 581 |
extern _gyotoy_inhibit_redraw, _gyotoy_cancel; |
| 582 |
if (!structof(mode)) mode=mode.get_active(); |
| 583 |
_gyotoy_inhibit_redraw=mode; |
| 584 |
if (mode &&_gyotoy_redrawing) _gyotoy_cancel=1; |
| 585 |
} |
| 586 |
|
| 587 |
func gyotoy_play_pause(wdg, data) |
| 588 |
{ |
| 589 |
noop, _gyotoy.builder.get_object("inhibit_button").set_active(0); |
| 590 |
gyotoy_compute_and_draw; |
| 591 |
} |
| 592 |
|
| 593 |
func gyotoy_export(filename, data) |
| 594 |
{ |
| 595 |
/* DOCUMENT gyotoy_export, filename |
| 596 |
|
| 597 |
Save current plot or Gyotoy data to file. |
| 598 |
|
| 599 |
The plot is exported using the standard Yorick functions if |
| 600 |
filename ends in ".pdf", ".png", ".eps", ".ps", ".jpeg", ".jpg", |
| 601 |
or ".jfif". |
| 602 |
|
| 603 |
The data are exported to an ASCII file if filename ends in ".dat" |
| 604 |
or ".txt". The GTK interface needs to be running for this to |
| 605 |
happen. Use gyotoy_save_data for the same result if the interface |
| 606 |
is not running. |
| 607 |
|
| 608 |
SEE ALSO: gyotoy_import, gyotoy_save_data |
| 609 |
*/ |
| 610 |
|
| 611 |
// If filename is not a string, assume open button has been clicked |
| 612 |
if (!is_string(filename)) { |
| 613 |
Gtk = gy.require("Gtk", "3.0"); |
| 614 |
|
| 615 |
chooser = Gtk.FileChooserDialog(); |
| 616 |
noop, chooser.add_button(Gtk.STOCK_CANCEL, Gtk.ResponseType.cancel); |
| 617 |
noop, chooser.add_button(Gtk.STOCK_SAVE, Gtk.ResponseType.ok); |
| 618 |
fcfc = Gtk.FileChooser(chooser); |
| 619 |
noop, fcfc.set_action(Gtk.FileChooserAction.save); |
| 620 |
noop, fcfc.set_do_overwrite_confirmation(1); |
| 621 |
|
| 622 |
filter = Gtk.FileFilter(); |
| 623 |
noop, filter.add_pattern("*"); |
| 624 |
noop, filter.set_name("All Files"); |
| 625 |
noop, fcfc.add_filter(filter); |
| 626 |
|
| 627 |
filter = Gtk.FileFilter(); |
| 628 |
noop, filter.add_pattern("*.[tT][xX][tT]"); |
| 629 |
noop, filter.add_pattern("*.[dD][aA][tT]"); |
| 630 |
noop, filter.add_pattern("*.[pP][dD][fF]"); |
| 631 |
noop, filter.add_pattern("*.[eE][pP][sS]"); |
| 632 |
noop, filter.add_pattern("*.[jJ][pP][eE][gG]"); |
| 633 |
noop, filter.add_pattern("*.[jJ][pP][gG]"); |
| 634 |
noop, filter.add_pattern("*.[jJ][fF][iI][fF]"); |
| 635 |
noop, filter.add_pattern("*.[pP][nN][gG]"); |
| 636 |
noop, filter.set_name("All supported files"); |
| 637 |
noop, fcfc.add_filter(filter); |
| 638 |
|
| 639 |
filter = Gtk.FileFilter(); |
| 640 |
noop, filter.add_pattern("*.[dD][aA][tT]"); |
| 641 |
noop, filter.add_pattern("*.[tT][xX][tT]"); |
| 642 |
noop, filter.set_name("Data Files"); |
| 643 |
noop, fcfc.add_filter(filter); |
| 644 |
|
| 645 |
filter = Gtk.FileFilter(); |
| 646 |
noop, filter.add_pattern("*.[xX][mM][lL]"); |
| 647 |
noop, filter.set_name("XML description files"); |
| 648 |
noop, fcfc.add_filter(filter); |
| 649 |
|
| 650 |
filter = Gtk.FileFilter(); |
| 651 |
noop, filter.add_pattern("*.[pP][dD][fF]"); |
| 652 |
noop, filter.set_name("PDF documents"); |
| 653 |
noop, fcfc.add_filter(filter); |
| 654 |
|
| 655 |
filter = Gtk.FileFilter(); |
| 656 |
noop, filter.add_pattern("*.[eE][pP][sS]"); |
| 657 |
noop, filter.set_name("EPS documents"); |
| 658 |
noop, fcfc.add_filter(filter); |
| 659 |
|
| 660 |
filter = Gtk.FileFilter(); |
| 661 |
noop, filter.add_pattern("*.[jJ][pP][eE][gG]"); |
| 662 |
noop, filter.add_pattern("*.[jJ][pP][gG]"); |
| 663 |
noop, filter.add_pattern("*.[jJ][fF][iI][fF]"); |
| 664 |
noop, filter.set_name("JPEG images"); |
| 665 |
noop, fcfc.add_filter(filter); |
| 666 |
|
| 667 |
filter = Gtk.FileFilter(); |
| 668 |
noop, filter.add_pattern("*.[pP][nN][gG]"); |
| 669 |
noop, filter.set_name("PNG images"); |
| 670 |
noop, fcfc.add_filter(filter); |
| 671 |
|
| 672 |
res = chooser.run(); |
| 673 |
noop, chooser.hide(); |
| 674 |
if (res == Gtk.ResponseType.OK) { |
| 675 |
filename=fcfc.get_filename(); |
| 676 |
noop, chooser.destroy(); |
| 677 |
} else { |
| 678 |
noop, chooser.destroy(); |
| 679 |
return; |
| 680 |
} |
| 681 |
} |
| 682 |
|
| 683 |
window, _gyotoy.yid; |
| 684 |
require,"pathfun.i"; |
| 685 |
ext=pathsplit(filename,delim=".")(0); |
| 686 |
if (strglob("*.pdf", filename, case=0)) pdf, filename; |
| 687 |
else if (strglob("*.png", filename, case=0)) png, filename; |
| 688 |
else if (strglob("*.eps", filename, case=0)) eps, filename; |
| 689 |
else if (strglob("*.ps", filename, case=0)) ps, filename; |
| 690 |
else if (strglob("*.jpeg",filename, case=0)) jpeg,filename; |
| 691 |
else if (strglob("*.jpg", filename, case=0)) jpeg,filename; |
| 692 |
else if (strglob("*.jfif",filename, case=0)) jpeg,filename; |
| 693 |
else if (strglob("*.dat", filename, case=0)) gyotoy_save_data(filename); |
| 694 |
else if (strglob("*.txt", filename, case=0)) gyotoy_save_data(filename); |
| 695 |
else if (strglob("*.xml", filename, case=0)) _gyotoy_particle, |
| 696 |
xmlwrite=filename; |
| 697 |
else pyk,"warning('Unknown file type for "+filename+"')"; |
| 698 |
} |
| 699 |
|
| 700 |
func gyotoy_import(filename, data) { |
| 701 |
extern _gyotoy, _gyotoy_inhibit_redraw; |
| 702 |
|
| 703 |
// If filename is not a string, assume open button has been clicked |
| 704 |
if (!is_string(filename)) { |
| 705 |
Gtk = gy.require("Gtk", "3.0"); |
| 706 |
|
| 707 |
chooser = Gtk.FileChooserDialog(); |
| 708 |
noop, chooser.add_button(Gtk.STOCK_CANCEL, Gtk.ResponseType.cancel); |
| 709 |
noop, chooser.add_button(Gtk.STOCK_OPEN, Gtk.ResponseType.ok); |
| 710 |
fcfc = Gtk.FileChooser(chooser); |
| 711 |
noop, fcfc.set_action(Gtk.FileChooserAction.open); |
| 712 |
noop, fcfc.set_do_overwrite_confirmation(1); |
| 713 |
/* |
| 714 |
buttons=(Gtk.STOCK_CANCEL, |
| 715 |
Gtk.ResponseType.CANCEL, |
| 716 |
Gtk.STOCK_OPEN, |
| 717 |
Gtk.ResponseType.OK)); |
| 718 |
*/ |
| 719 |
filter = Gtk.FileFilter(); |
| 720 |
noop, filter.add_pattern("*"); |
| 721 |
noop, filter.set_name("All Files"); |
| 722 |
noop, fcfc.add_filter(filter); |
| 723 |
|
| 724 |
filter = Gtk.FileFilter(); |
| 725 |
noop, filter.add_pattern("*.[dD][aA][tT]"); |
| 726 |
noop, filter.add_pattern("*.[tT][xX][tT]"); |
| 727 |
noop, filter.set_name("Data Files"); |
| 728 |
noop, fcfc.add_filter(filter); |
| 729 |
|
| 730 |
filter = Gtk.FileFilter(); |
| 731 |
noop, filter.add_pattern("*.[xX][mM][lL]"); |
| 732 |
noop, filter.set_name("XML description files"); |
| 733 |
noop, fcfc.add_filter(filter); |
| 734 |
|
| 735 |
res = chooser.run(); |
| 736 |
noop, chooser.hide(); |
| 737 |
if (res == Gtk.ResponseType.OK) { |
| 738 |
filename=fcfc.get_filename(); |
| 739 |
noop, chooser.destroy(); |
| 740 |
} else { |
| 741 |
noop, chooser.destroy(); |
| 742 |
return; |
| 743 |
} |
| 744 |
} |
| 745 |
|
| 746 |
// XML file: |
| 747 |
if (strpart(filename,-3:0)==".xml") { |
| 748 |
local rad2deg; |
| 749 |
rad2deg=180./pi; |
| 750 |
_gyotoy, filename=filename; |
| 751 |
gyotoy_set_particle, gyoto_Astrobj(filename); |
| 752 |
return; |
| 753 |
} |
| 754 |
|
| 755 |
// Non-xml file |
| 756 |
if(! (file = open(filename,"r",1))) { |
| 757 |
gyotoy_warning, "Could not open file "+filename+" for reading"; |
| 758 |
return; |
| 759 |
} |
| 760 |
/* if (!strmatch(rdline(file),"# Gyotoy save file")) { |
| 761 |
gyotoy_warning, filename+" is not a Gyotoy save file"; |
| 762 |
return; |
| 763 |
}*/ |
| 764 |
rdr=_gyotoy_inhibit_redraw; |
| 765 |
_gyotoy_inhibit_redraw=1; |
| 766 |
|
| 767 |
while ((line=rdline(file)) && !strmatch(line,"# Start Gyoto parameters")) {} |
| 768 |
if (!line) { |
| 769 |
gyotoy_warning, filename+" is not a Gyoto save file"; |
| 770 |
return; |
| 771 |
} |
| 772 |
while (!strmatch((line=rdline(file)),"# End Gyoto parameters")) { |
| 773 |
key=""; |
| 774 |
value=""; |
| 775 |
sread,line, format="# %s = %s", key, value; |
| 776 |
if (key=="metric_file") gyotoy_set_metric, strpart(value, 2:-1); |
| 777 |
ok=pyk("set_parameter('"+key+"',"+value+")"); |
| 778 |
} |
| 779 |
_gyotoy_inhibit_redraw=rdr; |
| 780 |
gyotoy_compute_and_draw; |
| 781 |
//pyk,"compute_orbit('rien')"; |
| 782 |
} |
| 783 |
|
| 784 |
func gyotoy_print(truc) {print,truc;} |
| 785 |
|
| 786 |
func gyotoy_set_mass(mass, void) |
| 787 |
{ |
| 788 |
extern _gyotoy_mass; |
| 789 |
if (!is_numerical(mass)) mass = mass.get_value(); |
| 790 |
_gyotoy_mass=mass; |
| 791 |
gyotoy_redraw; |
| 792 |
} |
| 793 |
|
| 794 |
func gyotoy_set_particle_type(type, void) |
| 795 |
{ |
| 796 |
extern _gyotoy_particle_is_massless, _gyotoy_particle, _gyotoy_metric; |
| 797 |
extern _gyotoy_txyz; |
| 798 |
if (!is_string(type)) { |
| 799 |
if (!type.get_active()) return; |
| 800 |
type = gy.Gtk.Buildable(type).get_name(); |
| 801 |
} |
| 802 |
_gyotoy_particle_is_massless = (type=="photon"); |
| 803 |
if (type=="photon") { |
| 804 |
_gyotoy_particle_is_massless = 1; |
| 805 |
_gyotoy_particle = gyoto_Photon(); |
| 806 |
} else { |
| 807 |
_gyotoy_particle_is_massless = 0; |
| 808 |
_gyotoy_particle = gyoto_Star(); |
| 809 |
} |
| 810 |
if (catch(0x08)) return; // avoid breaking in case of v>c |
| 811 |
_gyotoy_particle,metric=_gyotoy_metric, |
| 812 |
initcoord=_gyotoy_initcoord(1:4),_gyotoy_initcoord(5:7); |
| 813 |
_gyotoy_particle, delta=_gyotoy_delta; |
| 814 |
gyotoy_adaptive, _gyotoy_adaptive; |
| 815 |
gyotoy_compute_and_draw; |
| 816 |
} |
| 817 |
|
| 818 |
func gyotoy_save_data(filename) { |
| 819 |
/* DOCUMENT gyotoy_save_data,filename |
| 820 |
|
| 821 |
Save parameters and orbit to text file. |
| 822 |
|
| 823 |
SEE ALSO: |
| 824 |
*/ |
| 825 |
extern _gyotoy_metric; |
| 826 |
t=_gyotoy_txyz(,1); |
| 827 |
x=_gyotoy_txyz(,2); |
| 828 |
y=_gyotoy_txyz(,3); |
| 829 |
z=_gyotoy_txyz(,4); |
| 830 |
|
| 831 |
gyoto_convert, x, _gyotoy_mass, _gyotoy_distance, _gyotoy_unit; |
| 832 |
gyoto_convert, y, _gyotoy_mass, _gyotoy_distance, _gyotoy_unit; |
| 833 |
gyoto_convert, z, _gyotoy_mass, _gyotoy_distance, _gyotoy_unit; |
| 834 |
ptype = (_gyotoy_particle_is_massless?"photon":"star"); |
| 835 |
mtype = (_gyotoy_metric(kind=)=="KerrBL")?"kerrbl":"file"; |
| 836 |
spin=(_gyotoy_metric(kind=)=="KerrBL")?_gyotoy_metric(spin=):2; |
| 837 |
if (f=open(filename,"w",1)) { |
| 838 |
write, f, format="# %s\n", "Gyoto save file"; |
| 839 |
write, f, format="# %s\n", "Start Gyoto parameters"; |
| 840 |
write, f, format="# %13s = \"%s\"\n", "particle_type", ptype; |
| 841 |
write, f, format="# %13s = \"%s\"\n", "metric_type", mtype; |
| 842 |
if (mtype=="kerrbl") |
| 843 |
write, f, format="# %13s = %14.12f\n", "spin", spin; |
| 844 |
else |
| 845 |
write, f, format="# %13s = \"%s\"\n", "metric_file", _gyotoy_metric_file; |
| 846 |
write, f, format="# %13s = %14.12f\n", |
| 847 |
["mass", |
| 848 |
"t0", "r0", "theta0", "phi0", |
| 849 |
"rprime0", "thetaprime0", "phiprime0", |
| 850 |
"t1", "delta"], |
| 851 |
_([_gyotoy_mass], |
| 852 |
_gyotoy_initcoord, |
| 853 |
_gyotoy_t1, _gyotoy_delta); |
| 854 |
write, f, format="# %13s = %d\n", |
| 855 |
["adaptive", "nsteps"], [_gyotoy_adaptive, _gyotoy_nsteps]; |
| 856 |
write, f, format="# %13s = \"%s\"\n", "length_unit", _gyotoy_unit; |
| 857 |
write, f, format="# %s\n", "End Gyoto parameters"; |
| 858 |
write, f, format= "# %s\n", "Columns are t, x, y, z"; |
| 859 |
write, f, format="%14.12f %14.12f %14.12f %14.12f\n", t, x, y, z; |
| 860 |
close,f; |
| 861 |
} else error, "Could not create file "+filename; |
| 862 |
} |
| 863 |
|
| 864 |
|
| 865 |
/************** CALLBACKS ****************/ |
| 866 |
func gyotoy_about(wdg, udata) |
| 867 |
{ |
| 868 |
Gtk=gy.require("Gtk", "3.0"); |
| 869 |
dialog = Gtk.AboutDialog(); |
| 870 |
noop, dialog.set_program_name("Gyotoy"); |
| 871 |
noop, dialog.set_version(GYOTOY_VERSION); |
| 872 |
noop, dialog.set_logo(icon); |
| 873 |
noop, dialog.set_copyright("Copyright © 20011-2013 Frédéric Vincent & Thibaut Paumard"); |
| 874 |
noop, dialog.set_license_type(Gtk.License.gpl_3_0); |
| 875 |
noop, dialog.run(); |
| 876 |
noop, dialog.destroy(); |
| 877 |
} |
| 878 |
|
| 879 |
func _gyotoy_orient3(wdg, data) |
| 880 |
{ |
| 881 |
incl = _gyotoy.builder.get_object("incl").get_value(); |
| 882 |
paln = _gyotoy.builder.get_object("paln").get_value(); |
| 883 |
phase = _gyotoy.builder.get_object("phase").get_value(); |
| 884 |
gyoto_orient3, incl, paln, phase; |
| 885 |
//draw3,1; |
| 886 |
} |
| 887 |
|
| 888 |
func _gyotoy_metric_type(wdg, data) |
| 889 |
{ |
| 890 |
type_id = wdg.get_active(); |
| 891 |
if (type_id == 0) type = "kerrbl"; |
| 892 |
else if (type_id == 1) type = "kerrks"; |
| 893 |
else if (type_id == 2) type = "file"; |
| 894 |
|
| 895 |
if (type=="file") { |
| 896 |
noop, _gyotoy.builder.get_object("spin").set_sensitive(0); |
| 897 |
noop, _gyotoy.builder.get_object("spin").set_visible(0); |
| 898 |
noop, _gyotoy.builder.get_object("spin_label").set_visible(0); |
| 899 |
noop, _gyotoy.builder.get_object("metric_file").set_sensitive(1); |
| 900 |
noop, _gyotoy.builder.get_object("metric_file_label").set_visible(1); |
| 901 |
noop, _gyotoy.builder.get_object("metric_file").set_visible(1); |
| 902 |
// TO PORT |
| 903 |
//_gyotoy.metric_file_set_cb(_gyotoy.builder.get_object("metric_file")); |
| 904 |
} else if (type=="kerrbl") { |
| 905 |
noop, _gyotoy.builder.get_object("spin").set_visible(1); |
| 906 |
noop, _gyotoy.builder.get_object("spin").set_sensitive(1); |
| 907 |
noop, _gyotoy.builder.get_object("spin_label").set_visible(1); |
| 908 |
noop, _gyotoy.builder.get_object("metric_file").set_sensitive(0); |
| 909 |
noop, _gyotoy.builder.get_object("metric_file_label").set_visible(0); |
| 910 |
noop, _gyotoy.builder.get_object("metric_file").set_visible(0); |
| 911 |
gyotoy_set_KerrBL_metric, _gyotoy.builder.get_object("spin"); |
| 912 |
} else if (type=="kerrks") { |
| 913 |
noop, _gyotoy.builder.get_object("spin").set_visible(1); |
| 914 |
noop, _gyotoy.builder.get_object("spin").set_sensitive(1); |
| 915 |
noop, _gyotoy.builder.get_object("spin_label").set_visible(1); |
| 916 |
noop, _gyotoy.builder.get_object("metric_file").set_sensitive(0); |
| 917 |
noop, _gyotoy.builder.get_object("metric_file_label").set_visible(0); |
| 918 |
noop, _gyotoy.builder.get_object("metric_file").set_visible(0); |
| 919 |
gyotoy_set_KerrKS_metric, _gyotoy.builder.get_object("spin"); |
| 920 |
} else { |
| 921 |
error, "Unknown metric type"; |
| 922 |
} |
| 923 |
} |
| 924 |
|
| 925 |
func _gyotoy_gnomon(wdg, data) |
| 926 |
{ |
| 927 |
gnomon; |
| 928 |
} |
| 929 |
|
| 930 |
func _gyotoy_cage(wdg, data) |
| 931 |
{ |
| 932 |
cage3; |
| 933 |
} |
| 934 |
|
| 935 |
func _gyotoy_unlimit(wdg, data) |
| 936 |
{ |
| 937 |
limits; |
| 938 |
} |
| 939 |
|
| 940 |
|
| 941 |
extern gyotoy_warning; |
| 942 |
gyotoy_warning=error; |
| 943 |
|
| 944 |
extern _pyk_proc, _gyotoy_stand_alone; |
| 945 |
if (is_void(_gyotoy.yid)) _gyotoy,yid=0; |
| 946 |
gyotoy_args=get_argv(); |
| 947 |
if (is_void(GYOTOY_NO_AUTO) & numberof(gyotoy_args)>=3 && anyof(basename(gyotoy_args(3))==["gyotoy.i","gyotoy"])) { |
| 948 |
_gyotoy_stand_alone=1; |
| 949 |
if (numberof(gyotoy_args)>3) { |
| 950 |
gyotoy_args=gyotoy_args(4:); |
| 951 |
ind=where(strgrep("^-",gyotoy_args)(2,)==-1); |
| 952 |
if (numberof(ind)) _gyotoy, filename=gyotoy_args(ind(1)); |
| 953 |
if (numberof(ind)<numberof(gyotoy_args)) { |
| 954 |
ind=where(strgrep("^--",gyotoy_args)(2,)!=-1); |
| 955 |
gyotoy_options=gyotoy_args(ind); |
| 956 |
for (o=1;o<=numberof(gyotoy_options);o++) { |
| 957 |
option=gyotoy_options(o); |
| 958 |
pos=strfind("=",option); |
| 959 |
key=strpart(option,3:pos(1)); |
| 960 |
if (pos(2)==-1) value= "true"; else value=strpart(option,pos(2)+1:); |
| 961 |
if (key == "stand-alone") { |
| 962 |
if (anyof(value==["true","1","TRUE","T","yes","t"])) _gyotoy_stand_alone=1; |
| 963 |
else _gyotoy_stand_alone=0; |
| 964 |
} |
| 965 |
else if (key == "ui") gyotoy_ui=value; |
| 966 |
} |
| 967 |
} |
| 968 |
} |
| 969 |
|
| 970 |
if (_gyotoy_stand_alone) { |
| 971 |
batch,1; |
| 972 |
gy_gtk_before_init = __gyotoy_before_init; |
| 973 |
} |
| 974 |
|
| 975 |
if (!is_void(_gyotoy.filename)) gyotoy,_gyotoy.filename; |
| 976 |
else gyotoy; |
| 977 |
} |