2014-01-10 03:04:36 +00:00
|
|
|
# Class things:
|
|
|
|
var name = 'VOR';
|
|
|
|
var parents = [DotSym];
|
|
|
|
var __self__ = caller(0)[0];
|
|
|
|
DotSym.makeinstance( name, __self__ );
|
2013-12-01 12:29:22 +00:00
|
|
|
|
|
|
|
var element_type = "group"; # we want a group, becomes "me.element"
|
2014-01-10 03:04:36 +00:00
|
|
|
var icon_vor = nil;
|
2013-12-01 12:29:22 +00:00
|
|
|
var range_vor = nil; # two elements that get drawn when needed
|
|
|
|
var radial_vor = nil; # if one is nil, the other has to be nil
|
|
|
|
|
|
|
|
var draw = func {
|
2014-01-10 03:04:36 +00:00
|
|
|
# Init
|
|
|
|
if (me.icon_vor == nil) {
|
|
|
|
me.icon_vor = me.element.createChild("path")
|
|
|
|
.moveTo(-15,0)
|
|
|
|
.lineTo(-7.5,12.5)
|
|
|
|
.lineTo(7.5,12.5)
|
|
|
|
.lineTo(15,0)
|
|
|
|
.lineTo(7.5,-12.5)
|
|
|
|
.lineTo(-7.5,-12.5)
|
|
|
|
.close()
|
|
|
|
.setStrokeLineWidth(3)
|
|
|
|
.setColor(0,0.6,0.85);
|
|
|
|
}
|
|
|
|
# Update
|
|
|
|
if (me.controller.isActive(me.model)) {
|
|
|
|
if (me.range_vor == nil) {
|
|
|
|
var rangeNm = me.controller.query_range();
|
|
|
|
# print("VOR is tuned:", me.model.id);
|
|
|
|
var radius = (me.model.range_nm/rangeNm)*345;
|
|
|
|
me.range_vor = me.element.createChild("path")
|
|
|
|
.moveTo(-radius,0)
|
|
|
|
.arcSmallCW(radius,radius,0,2*radius,0)
|
|
|
|
.arcSmallCW(radius,radius,0,-2*radius,0)
|
|
|
|
.setStrokeLineWidth(3)
|
|
|
|
.setStrokeDashArray([5, 15, 5, 15, 5])
|
|
|
|
.setColor(0,1,0);
|
2013-12-01 12:29:22 +00:00
|
|
|
|
2014-01-10 03:04:36 +00:00
|
|
|
var course = me.controller.get_tuned_course(me.model.frequency/100);
|
|
|
|
me.radial_vor = me.element.createChild("path")
|
|
|
|
.moveTo(0,-radius)
|
|
|
|
.vert(2*radius)
|
|
|
|
.setStrokeLineWidth(3)
|
|
|
|
.setStrokeDashArray([15, 5, 15, 5, 15])
|
|
|
|
.setColor(0,1,0)
|
|
|
|
.setRotation(course*D2R);
|
|
|
|
me.icon_vor.setColor(0,1,0);
|
2013-12-01 12:29:22 +00:00
|
|
|
}
|
2014-01-10 03:04:36 +00:00
|
|
|
me.range_vor.show();
|
|
|
|
me.radial_vor.show();
|
|
|
|
} elsif (me.range_vor != nil) {
|
|
|
|
me.range_vor.hide();
|
|
|
|
me.radial_vor.hide();
|
|
|
|
}
|
2013-12-01 12:29:22 +00:00
|
|
|
};
|
|
|
|
|