marker-adjust
vbox
-20
-20
hbox
1
1
var self = cmdarg();
var dlgname = self.getNode("name").getValue();
var kbdctrl = props.globals.getNode("/devices/status/keyboard/ctrl", 1);
var kbdshift = props.globals.getNode("/devices/status/keyboard/shift", 1);
var Value = {
new : func(name, factor, init = 0) {
var m = { parents: [Value] };
m.name = name;
m.factor = factor;
m.init = init;
var n = props.globals.getNode("/sim/model/marker/" ~ m.name, 1);
m.sliderN = n.getNode("slider", 1);
m.offsetN = n.getNode("offset", 1);
m.valueN = n.getNode("value", 1);
m.offsetN.setDoubleValue(0);
m.sliderN.setDoubleValue(0);
m.valueN.setDoubleValue(m.init);
m.last_slider = 0;
m.center();
m.sliderL = setlistener(m.sliderN, func { m.update() });
return m;
},
del : func {
removelistener(me.sliderL);
},
reset : func {
me.center();
me.valueN.setDoubleValue(me.init);
},
update : func {
var offs = me.sliderN.getValue();
var v = me.offsetN.getValue() + me.sliderN.getValue() - me.last_slider;
var f = me.factor;
if (kbdctrl.getValue()) {
f *= 5;
} elsif (kbdshift.getValue()) {
f *= 0.1;
}
me.valueN.setValue(me.valueN.getValue() + v * f);
me.offsetN.setDoubleValue(0);
me.last_slider = offs;
},
center : func {
me.offsetN.setValue(me.offsetN.getValue() + me.sliderN.getValue());
me.sliderN.setDoubleValue(0);
},
};
var values = [
Value.new("x", 0.1), # aft/fore
Value.new("y", 0.1), # left/right
Value.new("z", 0.1), # down/up
Value.new("scale", 2, 1),
];
var center = func {
foreach (var v; values) {
v.center();
}
}
var reset = func {
foreach (var v; values) {
v.reset();
}
}
var dump = func {
var v = props.globals.getNode("/sim/current-view", 1);
print("<view>");
foreach (var n; ["heading-offset-deg", "pitch-offset-deg", "roll-offset-deg",
"x-offset-m", "y-offset-m", "z-offset-m", "field-of-view"]) {
print(sprintf(" <%s>%.1f</%s>", n, v.getNode(n, 1).getValue(), n));
}
print("</view>\n");
print("<marker>");
foreach (var v; values) {
var tag = v.name == "scale" ? "scale" : v.name ~ "-m";
print(sprintf(" <%s>%.4f</%s>", tag, v.valueN.getValue(), tag));
}
print("</marker>\n");
}
var update = func(w) {
self.setValues({"dialog-name": dlgname, "object-name": w});
fgcommand("dialog-update", self);
center();
}
setprop("/sim/model/marker/arrow-enabled", 1);
setprop("/sim/model/marker/cross-enabled", 1);
setprop("/sim/model/marker/cross-enabled", 0);
setprop("/sim/model/marker/arrow-enabled", 0);
foreach (var v; values) {
v.del();
}
hbox
0
x
/sim/model/marker/x/slider
250
1
-1
1
1.0
0.6
0.6
1
dialog-apply
x
hbox
0
y
/sim/model/marker/y/slider
250
1
-1
1
0.6
1.0
0.6
1.0
dialog-apply
y
hbox
0
z
/sim/model/marker/z/slider
250
1
-1
1
0.6
0.6
1.0
1.0
dialog-apply
z
hbox
0
scale
/sim/model/marker/scale/slider
250
1
-1
1
1.0
0.6
1.0
1.0
dialog-apply
scale
hbox
2
1
1