| 1 |
<?xml version="1.0"?> |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
<PropertyList> |
| 9 |
<name>marker-adjust</name> |
| 10 |
<layout>vbox</layout> |
| 11 |
<x>-20</x> |
| 12 |
<y>-20</y> |
| 13 |
|
| 14 |
<group> |
| 15 |
<layout>hbox</layout> |
| 16 |
|
| 17 |
<text> |
| 18 |
<label>Adjust marker</label> |
| 19 |
</text> |
| 20 |
|
| 21 |
<empty><stretch>1</stretch></empty> |
| 22 |
|
| 23 |
<button> |
| 24 |
<legend>X</legend> |
| 25 |
<key>Esc</key> |
| 26 |
<pref-width>20</pref-width> |
| 27 |
<pref-height>20</pref-height> |
| 28 |
<binding> |
| 29 |
<command>dialog-close</command> |
| 30 |
</binding> |
| 31 |
</button> |
| 32 |
</group> |
| 33 |
|
| 34 |
<hrule/> |
| 35 |
|
| 36 |
<nasal> |
| 37 |
<open> |
| 38 |
var self = cmdarg(); |
| 39 |
var dlgname = self.getNode("name").getValue(); |
| 40 |
var kbdctrl = props.globals.getNode("/devices/status/keyboard/ctrl", 1); |
| 41 |
var kbdshift = props.globals.getNode("/devices/status/keyboard/shift", 1); |
| 42 |
|
| 43 |
var Value = { |
| 44 |
new : func(name, factor, init = 0) { |
| 45 |
var m = { parents: [Value] }; |
| 46 |
m.name = name; |
| 47 |
m.factor = factor; |
| 48 |
m.init = init; |
| 49 |
var n = props.globals.getNode("/sim/model/marker/" ~ m.name, 1); |
| 50 |
m.sliderN = n.getNode("slider", 1); |
| 51 |
m.offsetN = n.getNode("offset", 1); |
| 52 |
m.valueN = n.getNode("value", 1); |
| 53 |
m.offsetN.setDoubleValue(0); |
| 54 |
m.sliderN.setDoubleValue(0); |
| 55 |
m.valueN.setDoubleValue(m.init); |
| 56 |
m.last_slider = 0; |
| 57 |
m.center(); |
| 58 |
m.sliderL = setlistener(m.sliderN, func { m.update() }); |
| 59 |
return m; |
| 60 |
}, |
| 61 |
del : func { |
| 62 |
removelistener(me.sliderL); |
| 63 |
}, |
| 64 |
reset : func { |
| 65 |
me.center(); |
| 66 |
me.valueN.setDoubleValue(me.init); |
| 67 |
}, |
| 68 |
update : func { |
| 69 |
var offs = me.sliderN.getValue(); |
| 70 |
var v = me.offsetN.getValue() + me.sliderN.getValue() - me.last_slider; |
| 71 |
var f = me.factor; |
| 72 |
if (kbdctrl.getValue()) { |
| 73 |
f *= 5; |
| 74 |
} elsif (kbdshift.getValue()) { |
| 75 |
f *= 0.1; |
| 76 |
} |
| 77 |
me.valueN.setValue(me.valueN.getValue() + v * f); |
| 78 |
me.offsetN.setDoubleValue(0); |
| 79 |
me.last_slider = offs; |
| 80 |
}, |
| 81 |
center : func { |
| 82 |
me.offsetN.setValue(me.offsetN.getValue() + me.sliderN.getValue()); |
| 83 |
me.sliderN.setDoubleValue(0); |
| 84 |
}, |
| 85 |
}; |
| 86 |
|
| 87 |
var values = [ |
| 88 |
Value.new("x", 0.1), # aft/fore |
| 89 |
Value.new("y", 0.1), # left/right |
| 90 |
Value.new("z", 0.1), # down/up |
| 91 |
Value.new("scale", 2, 1), |
| 92 |
]; |
| 93 |
|
| 94 |
var center = func { |
| 95 |
foreach (var v; values) { |
| 96 |
v.center(); |
| 97 |
} |
| 98 |
} |
| 99 |
|
| 100 |
var reset = func { |
| 101 |
foreach (var v; values) { |
| 102 |
v.reset(); |
| 103 |
} |
| 104 |
} |
| 105 |
|
| 106 |
var dump = func { |
| 107 |
var s = "marker("; |
| 108 |
var v = props.globals.getNode("/sim/current-view", 1); |
| 109 |
print("<view>"); |
| 110 |
foreach (var n; ["heading-offset-deg", "pitch-offset-deg", "roll-offset-deg", |
| 111 |
"x-offset-m", "y-offset-m", "z-offset-m", "field-of-view"]) { |
| 112 |
print(sprintf(" <%s>%.1f</%s>", n, v.getNode(n, 1).getValue(), n)); |
| 113 |
} |
| 114 |
print("</view>\n"); |
| 115 |
|
| 116 |
print("<marker>"); |
| 117 |
foreach (var v; values) { |
| 118 |
var tag = v.name == "scale" ? "scale" : v.name ~ "-m"; |
| 119 |
print(sprintf(" <%s>%.4f</%s>", tag, v.valueN.getValue(), tag)); |
| 120 |
s = s ~ sprintf("%.4f, ", v.valueN.getValue()); |
| 121 |
} |
| 122 |
print("</marker>"); |
| 123 |
s = substr(s, 0, size(s)-2); # Trim off last ", " |
| 124 |
s = s ~ ");\n"; |
| 125 |
print(s); |
| 126 |
} |
| 127 |
|
| 128 |
var update = func(w) { |
| 129 |
self.setValues({"dialog-name": dlgname, "object-name": w}); |
| 130 |
fgcommand("dialog-update", self); |
| 131 |
center(); |
| 132 |
} |
| 133 |
|
| 134 |
setprop("/sim/model/marker/arrow-enabled", 1); |
| 135 |
setprop("/sim/model/marker/cross-enabled", 1); |
| 136 |
</open> |
| 137 |
|
| 138 |
<close> |
| 139 |
setprop("/sim/model/marker/cross-enabled", 0); |
| 140 |
setprop("/sim/model/marker/arrow-enabled", 0); |
| 141 |
foreach (var v; values) { |
| 142 |
v.del(); |
| 143 |
} |
| 144 |
</close> |
| 145 |
</nasal> |
| 146 |
|
| 147 |
<group> |
| 148 |
<layout>hbox</layout> |
| 149 |
<default-padding>0</default-padding> |
| 150 |
|
| 151 |
<button> |
| 152 |
<legend><<</legend> |
| 153 |
<pref-width>22</pref-width> |
| 154 |
<pref-height>22</pref-height> |
| 155 |
|
| 156 |
<binding> |
| 157 |
<command>property-adjust</command> |
| 158 |
<property>/sim/model/marker/x/offset</property> |
| 159 |
<step>-10</step> |
| 160 |
</binding> |
| 161 |
<binding> |
| 162 |
<command>nasal</command> |
| 163 |
<script>update("x")</script> |
| 164 |
</binding> |
| 165 |
</button> |
| 166 |
|
| 167 |
<button> |
| 168 |
<legend><</legend> |
| 169 |
<pref-width>22</pref-width> |
| 170 |
<pref-height>22</pref-height> |
| 171 |
|
| 172 |
<binding> |
| 173 |
<command>property-adjust</command> |
| 174 |
<property>/sim/model/marker/x/offset</property> |
| 175 |
<step>-1</step> |
| 176 |
</binding> |
| 177 |
<binding> |
| 178 |
<command>nasal</command> |
| 179 |
<script>update("x")</script> |
| 180 |
</binding> |
| 181 |
</button> |
| 182 |
|
| 183 |
<slider> |
| 184 |
<name>x</name> |
| 185 |
<property>/sim/model/marker/x/slider</property> |
| 186 |
<legend>fore/aft</legend> |
| 187 |
<pref-width>250</pref-width> |
| 188 |
<live>1</live> |
| 189 |
<min>-1</min> |
| 190 |
<max>1</max> |
| 191 |
|
| 192 |
<color> |
| 193 |
<red>1.0</red> |
| 194 |
<green>0.6</green> |
| 195 |
<blue>0.6</blue> |
| 196 |
<alpha>1</alpha> |
| 197 |
</color> |
| 198 |
|
| 199 |
<binding> |
| 200 |
<command>dialog-apply</command> |
| 201 |
<object-name>x</object-name> |
| 202 |
</binding> |
| 203 |
</slider> |
| 204 |
|
| 205 |
<button> |
| 206 |
<legend>></legend> |
| 207 |
<pref-width>22</pref-width> |
| 208 |
<pref-height>22</pref-height> |
| 209 |
|
| 210 |
<binding> |
| 211 |
<command>property-adjust</command> |
| 212 |
<property>/sim/model/marker/x/offset</property> |
| 213 |
<step>1</step> |
| 214 |
</binding> |
| 215 |
<binding> |
| 216 |
<command>nasal</command> |
| 217 |
<script>update("x")</script> |
| 218 |
</binding> |
| 219 |
</button> |
| 220 |
|
| 221 |
<button> |
| 222 |
<legend>>></legend> |
| 223 |
<pref-width>22</pref-width> |
| 224 |
<pref-height>22</pref-height> |
| 225 |
|
| 226 |
<binding> |
| 227 |
<command>property-adjust</command> |
| 228 |
<property>/sim/model/marker/x/offset</property> |
| 229 |
<step>10</step> |
| 230 |
</binding> |
| 231 |
<binding> |
| 232 |
<command>nasal</command> |
| 233 |
<script>update("x")</script> |
| 234 |
</binding> |
| 235 |
</button> |
| 236 |
</group> |
| 237 |
|
| 238 |
<group> |
| 239 |
<layout>hbox</layout> |
| 240 |
<default-padding>0</default-padding> |
| 241 |
|
| 242 |
<button> |
| 243 |
<legend><<</legend> |
| 244 |
<pref-width>22</pref-width> |
| 245 |
<pref-height>22</pref-height> |
| 246 |
|
| 247 |
<binding> |
| 248 |
<command>property-adjust</command> |
| 249 |
<property>/sim/model/marker/y/offset</property> |
| 250 |
<step>-10</step> |
| 251 |
</binding> |
| 252 |
<binding> |
| 253 |
<command>nasal</command> |
| 254 |
<script>update("y")</script> |
| 255 |
</binding> |
| 256 |
</button> |
| 257 |
|
| 258 |
<button> |
| 259 |
<legend><</legend> |
| 260 |
<pref-width>22</pref-width> |
| 261 |
<pref-height>22</pref-height> |
| 262 |
|
| 263 |
<binding> |
| 264 |
<command>property-adjust</command> |
| 265 |
<property>/sim/model/marker/y/offset</property> |
| 266 |
<step>-1</step> |
| 267 |
</binding> |
| 268 |
<binding> |
| 269 |
<command>nasal</command> |
| 270 |
<script>update("y")</script> |
| 271 |
</binding> |
| 272 |
</button> |
| 273 |
|
| 274 |
<slider> |
| 275 |
<name>y</name> |
| 276 |
<property>/sim/model/marker/y/slider</property> |
| 277 |
<legend>left/right</legend> |
| 278 |
<pref-width>250</pref-width> |
| 279 |
<live>1</live> |
| 280 |
<min>-1</min> |
| 281 |
<max>1</max> |
| 282 |
|
| 283 |
<color> |
| 284 |
<red>0.6</red> |
| 285 |
<green>1.0</green> |
| 286 |
<blue>0.6</blue> |
| 287 |
<alpha>1.0</alpha> |
| 288 |
</color> |
| 289 |
|
| 290 |
<binding> |
| 291 |
<command>dialog-apply</command> |
| 292 |
<object-name>y</object-name> |
| 293 |
</binding> |
| 294 |
</slider> |
| 295 |
|
| 296 |
<button> |
| 297 |
<legend>></legend> |
| 298 |
<pref-width>22</pref-width> |
| 299 |
<pref-height>22</pref-height> |
| 300 |
|
| 301 |
<binding> |
| 302 |
<command>property-adjust</command> |
| 303 |
<property>/sim/model/marker/y/offset</property> |
| 304 |
<step>1</step> |
| 305 |
</binding> |
| 306 |
<binding> |
| 307 |
<command>nasal</command> |
| 308 |
<script>update("y")</script> |
| 309 |
</binding> |
| 310 |
</button> |
| 311 |
|
| 312 |
<button> |
| 313 |
<legend>>></legend> |
| 314 |
<pref-width>22</pref-width> |
| 315 |
<pref-height>22</pref-height> |
| 316 |
|
| 317 |
<binding> |
| 318 |
<command>property-adjust</command> |
| 319 |
<property>/sim/model/marker/y/offset</property> |
| 320 |
<step>10</step> |
| 321 |
</binding> |
| 322 |
<binding> |
| 323 |
<command>nasal</command> |
| 324 |
<script>update("y")</script> |
| 325 |
</binding> |
| 326 |
</button> |
| 327 |
</group> |
| 328 |
|
| 329 |
<group> |
| 330 |
<layout>hbox</layout> |
| 331 |
<default-padding>0</default-padding> |
| 332 |
|
| 333 |
<button> |
| 334 |
<legend><<</legend> |
| 335 |
<pref-width>22</pref-width> |
| 336 |
<pref-height>22</pref-height> |
| 337 |
|
| 338 |
<binding> |
| 339 |
<command>property-adjust</command> |
| 340 |
<property>/sim//model/marker/z/offset</property> |
| 341 |
<step>-10</step> |
| 342 |
</binding> |
| 343 |
<binding> |
| 344 |
<command>nasal</command> |
| 345 |
<script>update("z")</script> |
| 346 |
</binding> |
| 347 |
</button> |
| 348 |
|
| 349 |
<button> |
| 350 |
<legend><</legend> |
| 351 |
<pref-width>22</pref-width> |
| 352 |
<pref-height>22</pref-height> |
| 353 |
|
| 354 |
<binding> |
| 355 |
<command>property-adjust</command> |
| 356 |
<property>/sim/model/marker/z/offset</property> |
| 357 |
<step>-1</step> |
| 358 |
</binding> |
| 359 |
<binding> |
| 360 |
<command>nasal</command> |
| 361 |
<script>update("z")</script> |
| 362 |
</binding> |
| 363 |
</button> |
| 364 |
|
| 365 |
<slider> |
| 366 |
<name>z</name> |
| 367 |
<property>/sim/model/marker/z/slider</property> |
| 368 |
<legend>down/up</legend> |
| 369 |
<pref-width>250</pref-width> |
| 370 |
<live>1</live> |
| 371 |
<min>-1</min> |
| 372 |
<max>1</max> |
| 373 |
|
| 374 |
<color> |
| 375 |
<red>0.6</red> |
| 376 |
<green>0.6</green> |
| 377 |
<blue>1.0</blue> |
| 378 |
<alpha>1.0</alpha> |
| 379 |
</color> |
| 380 |
|
| 381 |
<binding> |
| 382 |
<command>dialog-apply</command> |
| 383 |
<object-name>z</object-name> |
| 384 |
</binding> |
| 385 |
</slider> |
| 386 |
|
| 387 |
<button> |
| 388 |
<legend>></legend> |
| 389 |
<pref-width>22</pref-width> |
| 390 |
<pref-height>22</pref-height> |
| 391 |
|
| 392 |
<binding> |
| 393 |
<command>property-adjust</command> |
| 394 |
<property>/sim/model/marker/z/offset</property> |
| 395 |
<step>1</step> |
| 396 |
</binding> |
| 397 |
<binding> |
| 398 |
<command>nasal</command> |
| 399 |
<script>update("z")</script> |
| 400 |
</binding> |
| 401 |
</button> |
| 402 |
|
| 403 |
<button> |
| 404 |
<legend>>></legend> |
| 405 |
<pref-width>22</pref-width> |
| 406 |
<pref-height>22</pref-height> |
| 407 |
|
| 408 |
<binding> |
| 409 |
<command>property-adjust</command> |
| 410 |
<property>/sim/model/marker/z/offset</property> |
| 411 |
<step>10</step> |
| 412 |
</binding> |
| 413 |
<binding> |
| 414 |
<command>nasal</command> |
| 415 |
<script>update("z")</script> |
| 416 |
</binding> |
| 417 |
</button> |
| 418 |
</group> |
| 419 |
|
| 420 |
<group> |
| 421 |
<layout>hbox</layout> |
| 422 |
<default-padding>0</default-padding> |
| 423 |
|
| 424 |
<button> |
| 425 |
<legend><<</legend> |
| 426 |
<pref-width>22</pref-width> |
| 427 |
<pref-height>22</pref-height> |
| 428 |
|
| 429 |
<binding> |
| 430 |
<command>property-adjust</command> |
| 431 |
<property>/sim//model/marker/scale/offset</property> |
| 432 |
<step>-10</step> |
| 433 |
</binding> |
| 434 |
<binding> |
| 435 |
<command>nasal</command> |
| 436 |
<script>update("scale")</script> |
| 437 |
</binding> |
| 438 |
</button> |
| 439 |
|
| 440 |
<button> |
| 441 |
<legend><</legend> |
| 442 |
<pref-width>22</pref-width> |
| 443 |
<pref-height>22</pref-height> |
| 444 |
|
| 445 |
<binding> |
| 446 |
<command>property-adjust</command> |
| 447 |
<property>/sim/model/marker/scale/offset</property> |
| 448 |
<step>-1</step> |
| 449 |
</binding> |
| 450 |
<binding> |
| 451 |
<command>nasal</command> |
| 452 |
<script>update("scale")</script> |
| 453 |
</binding> |
| 454 |
</button> |
| 455 |
|
| 456 |
<slider> |
| 457 |
<name>scale</name> |
| 458 |
<property>/sim/model/marker/scale/slider</property> |
| 459 |
<legend>size</legend> |
| 460 |
<pref-width>250</pref-width> |
| 461 |
<live>1</live> |
| 462 |
<min>-1</min> |
| 463 |
<max>1</max> |
| 464 |
|
| 465 |
<color> |
| 466 |
<red>1.0</red> |
| 467 |
<green>0.6</green> |
| 468 |
<blue>1.0</blue> |
| 469 |
<alpha>1.0</alpha> |
| 470 |
</color> |
| 471 |
|
| 472 |
<binding> |
| 473 |
<command>dialog-apply</command> |
| 474 |
<object-name>scale</object-name> |
| 475 |
</binding> |
| 476 |
</slider> |
| 477 |
|
| 478 |
<button> |
| 479 |
<legend>></legend> |
| 480 |
<pref-width>22</pref-width> |
| 481 |
<pref-height>22</pref-height> |
| 482 |
|
| 483 |
<binding> |
| 484 |
<command>property-adjust</command> |
| 485 |
<property>/sim/model/marker/scale/offset</property> |
| 486 |
<step>1</step> |
| 487 |
</binding> |
| 488 |
<binding> |
| 489 |
<command>nasal</command> |
| 490 |
<script>update("scale")</script> |
| 491 |
</binding> |
| 492 |
</button> |
| 493 |
|
| 494 |
<button> |
| 495 |
<legend>>></legend> |
| 496 |
<pref-width>22</pref-width> |
| 497 |
<pref-height>22</pref-height> |
| 498 |
|
| 499 |
<binding> |
| 500 |
<command>property-adjust</command> |
| 501 |
<property>/sim/model/marker/scale/offset</property> |
| 502 |
<step>10</step> |
| 503 |
</binding> |
| 504 |
<binding> |
| 505 |
<command>nasal</command> |
| 506 |
<script>update("scale")</script> |
| 507 |
</binding> |
| 508 |
</button> |
| 509 |
</group> |
| 510 |
|
| 511 |
<group> |
| 512 |
<layout>hbox</layout> |
| 513 |
<default-padding>2</default-padding> |
| 514 |
|
| 515 |
<button> |
| 516 |
<halign>left</halign> |
| 517 |
<legend>Reset</legend> |
| 518 |
<pref-height>22</pref-height> |
| 519 |
<pref-width>60</pref-width> |
| 520 |
<binding> |
| 521 |
<command>nasal</command> |
| 522 |
<script>reset()</script> |
| 523 |
</binding> |
| 524 |
</button> |
| 525 |
|
| 526 |
<empty><stretch>1</stretch></empty> |
| 527 |
|
| 528 |
<button> |
| 529 |
<halign>center</halign> |
| 530 |
<legend>Center</legend> |
| 531 |
<pref-height>22</pref-height> |
| 532 |
<pref-width>60</pref-width> |
| 533 |
<binding> |
| 534 |
<command>nasal</command> |
| 535 |
<script>center()</script> |
| 536 |
</binding> |
| 537 |
</button> |
| 538 |
|
| 539 |
<empty><stretch>1</stretch></empty> |
| 540 |
|
| 541 |
<button> |
| 542 |
<halign>right</halign> |
| 543 |
<legend>Dump</legend> |
| 544 |
<pref-height>22</pref-height> |
| 545 |
<pref-width>60</pref-width> |
| 546 |
<binding> |
| 547 |
<command>nasal</command> |
| 548 |
<script>dump()</script> |
| 549 |
</binding> |
| 550 |
</button> |
| 551 |
</group> |
| 552 |
</PropertyList> |