id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
51
19.8k
code_tokens
sequence
docstring
stringlengths
3
17.3k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
87
242
249,400
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_map/__init__.py
MapModule.cmd_follow
def cmd_follow(self, args): '''control following of vehicle''' if len(args) < 2: print("map follow 0|1") return follow = int(args[1]) self.map.set_follow(follow)
python
def cmd_follow(self, args): '''control following of vehicle''' if len(args) < 2: print("map follow 0|1") return follow = int(args[1]) self.map.set_follow(follow)
[ "def", "cmd_follow", "(", "self", ",", "args", ")", ":", "if", "len", "(", "args", ")", "<", "2", ":", "print", "(", "\"map follow 0|1\"", ")", "return", "follow", "=", "int", "(", "args", "[", "1", "]", ")", "self", ".", "map", ".", "set_follow", "(", "follow", ")" ]
control following of vehicle
[ "control", "following", "of", "vehicle" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_map/__init__.py#L607-L613
249,401
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_map/__init__.py
MapModule.set_secondary_vehicle_position
def set_secondary_vehicle_position(self, m): '''show 2nd vehicle on map''' if m.get_type() != 'GLOBAL_POSITION_INT': return (lat, lon, heading) = (m.lat*1.0e-7, m.lon*1.0e-7, m.hdg*0.01) if abs(lat) < 1.0e-3 and abs(lon) > 1.0e-3: return # hack for OBC2016 alt = self.ElevationMap.GetElevation(lat, lon) agl = m.alt * 0.001 - alt agl_s = str(int(agl)) + 'm' self.create_vehicle_icon('VehiclePos2', 'blue', follow=False, vehicle_type='plane') self.map.set_position('VehiclePos2', (lat, lon), rotation=heading, label=agl_s, colour=(0,255,255))
python
def set_secondary_vehicle_position(self, m): '''show 2nd vehicle on map''' if m.get_type() != 'GLOBAL_POSITION_INT': return (lat, lon, heading) = (m.lat*1.0e-7, m.lon*1.0e-7, m.hdg*0.01) if abs(lat) < 1.0e-3 and abs(lon) > 1.0e-3: return # hack for OBC2016 alt = self.ElevationMap.GetElevation(lat, lon) agl = m.alt * 0.001 - alt agl_s = str(int(agl)) + 'm' self.create_vehicle_icon('VehiclePos2', 'blue', follow=False, vehicle_type='plane') self.map.set_position('VehiclePos2', (lat, lon), rotation=heading, label=agl_s, colour=(0,255,255))
[ "def", "set_secondary_vehicle_position", "(", "self", ",", "m", ")", ":", "if", "m", ".", "get_type", "(", ")", "!=", "'GLOBAL_POSITION_INT'", ":", "return", "(", "lat", ",", "lon", ",", "heading", ")", "=", "(", "m", ".", "lat", "*", "1.0e-7", ",", "m", ".", "lon", "*", "1.0e-7", ",", "m", ".", "hdg", "*", "0.01", ")", "if", "abs", "(", "lat", ")", "<", "1.0e-3", "and", "abs", "(", "lon", ")", ">", "1.0e-3", ":", "return", "# hack for OBC2016", "alt", "=", "self", ".", "ElevationMap", ".", "GetElevation", "(", "lat", ",", "lon", ")", "agl", "=", "m", ".", "alt", "*", "0.001", "-", "alt", "agl_s", "=", "str", "(", "int", "(", "agl", ")", ")", "+", "'m'", "self", ".", "create_vehicle_icon", "(", "'VehiclePos2'", ",", "'blue'", ",", "follow", "=", "False", ",", "vehicle_type", "=", "'plane'", ")", "self", ".", "map", ".", "set_position", "(", "'VehiclePos2'", ",", "(", "lat", ",", "lon", ")", ",", "rotation", "=", "heading", ",", "label", "=", "agl_s", ",", "colour", "=", "(", "0", ",", "255", ",", "255", ")", ")" ]
show 2nd vehicle on map
[ "show", "2nd", "vehicle", "on", "map" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_map/__init__.py#L615-L627
249,402
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_kmlread.py
KmlReadModule.cmd_param
def cmd_param(self, args): '''control kml reading''' usage = "Usage: kml <clear | load (filename) | layers | toggle (layername) | fence (layername)>" if len(args) < 1: print(usage) return elif args[0] == "clear": self.clearkml() elif args[0] == "snapwp": self.cmd_snap_wp(args[1:]) elif args[0] == "snapfence": self.cmd_snap_fence(args[1:]) elif args[0] == "load": if len(args) != 2: print("usage: kml load <filename>") return self.loadkml(args[1]) elif args[0] == "layers": for layer in self.curlayers: print("Found layer: " + layer) elif args[0] == "toggle": self.togglekml(args[1]) elif args[0] == "fence": self.fencekml(args[1]) else: print(usage) return
python
def cmd_param(self, args): '''control kml reading''' usage = "Usage: kml <clear | load (filename) | layers | toggle (layername) | fence (layername)>" if len(args) < 1: print(usage) return elif args[0] == "clear": self.clearkml() elif args[0] == "snapwp": self.cmd_snap_wp(args[1:]) elif args[0] == "snapfence": self.cmd_snap_fence(args[1:]) elif args[0] == "load": if len(args) != 2: print("usage: kml load <filename>") return self.loadkml(args[1]) elif args[0] == "layers": for layer in self.curlayers: print("Found layer: " + layer) elif args[0] == "toggle": self.togglekml(args[1]) elif args[0] == "fence": self.fencekml(args[1]) else: print(usage) return
[ "def", "cmd_param", "(", "self", ",", "args", ")", ":", "usage", "=", "\"Usage: kml <clear | load (filename) | layers | toggle (layername) | fence (layername)>\"", "if", "len", "(", "args", ")", "<", "1", ":", "print", "(", "usage", ")", "return", "elif", "args", "[", "0", "]", "==", "\"clear\"", ":", "self", ".", "clearkml", "(", ")", "elif", "args", "[", "0", "]", "==", "\"snapwp\"", ":", "self", ".", "cmd_snap_wp", "(", "args", "[", "1", ":", "]", ")", "elif", "args", "[", "0", "]", "==", "\"snapfence\"", ":", "self", ".", "cmd_snap_fence", "(", "args", "[", "1", ":", "]", ")", "elif", "args", "[", "0", "]", "==", "\"load\"", ":", "if", "len", "(", "args", ")", "!=", "2", ":", "print", "(", "\"usage: kml load <filename>\"", ")", "return", "self", ".", "loadkml", "(", "args", "[", "1", "]", ")", "elif", "args", "[", "0", "]", "==", "\"layers\"", ":", "for", "layer", "in", "self", ".", "curlayers", ":", "print", "(", "\"Found layer: \"", "+", "layer", ")", "elif", "args", "[", "0", "]", "==", "\"toggle\"", ":", "self", ".", "togglekml", "(", "args", "[", "1", "]", ")", "elif", "args", "[", "0", "]", "==", "\"fence\"", ":", "self", ".", "fencekml", "(", "args", "[", "1", "]", ")", "else", ":", "print", "(", "usage", ")", "return" ]
control kml reading
[ "control", "kml", "reading" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_kmlread.py#L48-L74
249,403
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_kmlread.py
KmlReadModule.cmd_snap_wp
def cmd_snap_wp(self, args): '''snap waypoints to KML''' threshold = 10.0 if len(args) > 0: threshold = float(args[0]) wpmod = self.module('wp') wploader = wpmod.wploader changed = False for i in range(1,wploader.count()): w = wploader.wp(i) if not wploader.is_location_command(w.command): continue lat = w.x lon = w.y best = None best_dist = (threshold+1)*3 for (snap_lat,snap_lon) in self.snap_points: dist = mp_util.gps_distance(lat, lon, snap_lat, snap_lon) if dist < best_dist: best_dist = dist best = (snap_lat, snap_lon) if best is not None and best_dist <= threshold: if w.x != best[0] or w.y != best[1]: w.x = best[0] w.y = best[1] print("Snapping WP %u to %f %f" % (i, w.x, w.y)) wploader.set(w, i) changed = True elif best is not None: if best_dist <= (threshold+1)*3: print("Not snapping wp %u dist %.1f" % (i, best_dist)) if changed: wpmod.send_all_waypoints()
python
def cmd_snap_wp(self, args): '''snap waypoints to KML''' threshold = 10.0 if len(args) > 0: threshold = float(args[0]) wpmod = self.module('wp') wploader = wpmod.wploader changed = False for i in range(1,wploader.count()): w = wploader.wp(i) if not wploader.is_location_command(w.command): continue lat = w.x lon = w.y best = None best_dist = (threshold+1)*3 for (snap_lat,snap_lon) in self.snap_points: dist = mp_util.gps_distance(lat, lon, snap_lat, snap_lon) if dist < best_dist: best_dist = dist best = (snap_lat, snap_lon) if best is not None and best_dist <= threshold: if w.x != best[0] or w.y != best[1]: w.x = best[0] w.y = best[1] print("Snapping WP %u to %f %f" % (i, w.x, w.y)) wploader.set(w, i) changed = True elif best is not None: if best_dist <= (threshold+1)*3: print("Not snapping wp %u dist %.1f" % (i, best_dist)) if changed: wpmod.send_all_waypoints()
[ "def", "cmd_snap_wp", "(", "self", ",", "args", ")", ":", "threshold", "=", "10.0", "if", "len", "(", "args", ")", ">", "0", ":", "threshold", "=", "float", "(", "args", "[", "0", "]", ")", "wpmod", "=", "self", ".", "module", "(", "'wp'", ")", "wploader", "=", "wpmod", ".", "wploader", "changed", "=", "False", "for", "i", "in", "range", "(", "1", ",", "wploader", ".", "count", "(", ")", ")", ":", "w", "=", "wploader", ".", "wp", "(", "i", ")", "if", "not", "wploader", ".", "is_location_command", "(", "w", ".", "command", ")", ":", "continue", "lat", "=", "w", ".", "x", "lon", "=", "w", ".", "y", "best", "=", "None", "best_dist", "=", "(", "threshold", "+", "1", ")", "*", "3", "for", "(", "snap_lat", ",", "snap_lon", ")", "in", "self", ".", "snap_points", ":", "dist", "=", "mp_util", ".", "gps_distance", "(", "lat", ",", "lon", ",", "snap_lat", ",", "snap_lon", ")", "if", "dist", "<", "best_dist", ":", "best_dist", "=", "dist", "best", "=", "(", "snap_lat", ",", "snap_lon", ")", "if", "best", "is", "not", "None", "and", "best_dist", "<=", "threshold", ":", "if", "w", ".", "x", "!=", "best", "[", "0", "]", "or", "w", ".", "y", "!=", "best", "[", "1", "]", ":", "w", ".", "x", "=", "best", "[", "0", "]", "w", ".", "y", "=", "best", "[", "1", "]", "print", "(", "\"Snapping WP %u to %f %f\"", "%", "(", "i", ",", "w", ".", "x", ",", "w", ".", "y", ")", ")", "wploader", ".", "set", "(", "w", ",", "i", ")", "changed", "=", "True", "elif", "best", "is", "not", "None", ":", "if", "best_dist", "<=", "(", "threshold", "+", "1", ")", "*", "3", ":", "print", "(", "\"Not snapping wp %u dist %.1f\"", "%", "(", "i", ",", "best_dist", ")", ")", "if", "changed", ":", "wpmod", ".", "send_all_waypoints", "(", ")" ]
snap waypoints to KML
[ "snap", "waypoints", "to", "KML" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_kmlread.py#L76-L108
249,404
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_kmlread.py
KmlReadModule.cmd_snap_fence
def cmd_snap_fence(self, args): '''snap fence to KML''' threshold = 10.0 if len(args) > 0: threshold = float(args[0]) fencemod = self.module('fence') loader = fencemod.fenceloader changed = False for i in range(0,loader.count()): fp = loader.point(i) lat = fp.lat lon = fp.lng best = None best_dist = (threshold+1)*3 for (snap_lat,snap_lon) in self.snap_points: dist = mp_util.gps_distance(lat, lon, snap_lat, snap_lon) if dist < best_dist: best_dist = dist best = (snap_lat, snap_lon) if best is not None and best_dist <= threshold: if best[0] != lat or best[1] != lon: loader.move(i, best[0], best[1]) print("Snapping fence point %u to %f %f" % (i, best[0], best[1])) changed = True elif best is not None: if best_dist <= (threshold+1)*3: print("Not snapping fence point %u dist %.1f" % (i, best_dist)) if changed: fencemod.send_fence()
python
def cmd_snap_fence(self, args): '''snap fence to KML''' threshold = 10.0 if len(args) > 0: threshold = float(args[0]) fencemod = self.module('fence') loader = fencemod.fenceloader changed = False for i in range(0,loader.count()): fp = loader.point(i) lat = fp.lat lon = fp.lng best = None best_dist = (threshold+1)*3 for (snap_lat,snap_lon) in self.snap_points: dist = mp_util.gps_distance(lat, lon, snap_lat, snap_lon) if dist < best_dist: best_dist = dist best = (snap_lat, snap_lon) if best is not None and best_dist <= threshold: if best[0] != lat or best[1] != lon: loader.move(i, best[0], best[1]) print("Snapping fence point %u to %f %f" % (i, best[0], best[1])) changed = True elif best is not None: if best_dist <= (threshold+1)*3: print("Not snapping fence point %u dist %.1f" % (i, best_dist)) if changed: fencemod.send_fence()
[ "def", "cmd_snap_fence", "(", "self", ",", "args", ")", ":", "threshold", "=", "10.0", "if", "len", "(", "args", ")", ">", "0", ":", "threshold", "=", "float", "(", "args", "[", "0", "]", ")", "fencemod", "=", "self", ".", "module", "(", "'fence'", ")", "loader", "=", "fencemod", ".", "fenceloader", "changed", "=", "False", "for", "i", "in", "range", "(", "0", ",", "loader", ".", "count", "(", ")", ")", ":", "fp", "=", "loader", ".", "point", "(", "i", ")", "lat", "=", "fp", ".", "lat", "lon", "=", "fp", ".", "lng", "best", "=", "None", "best_dist", "=", "(", "threshold", "+", "1", ")", "*", "3", "for", "(", "snap_lat", ",", "snap_lon", ")", "in", "self", ".", "snap_points", ":", "dist", "=", "mp_util", ".", "gps_distance", "(", "lat", ",", "lon", ",", "snap_lat", ",", "snap_lon", ")", "if", "dist", "<", "best_dist", ":", "best_dist", "=", "dist", "best", "=", "(", "snap_lat", ",", "snap_lon", ")", "if", "best", "is", "not", "None", "and", "best_dist", "<=", "threshold", ":", "if", "best", "[", "0", "]", "!=", "lat", "or", "best", "[", "1", "]", "!=", "lon", ":", "loader", ".", "move", "(", "i", ",", "best", "[", "0", "]", ",", "best", "[", "1", "]", ")", "print", "(", "\"Snapping fence point %u to %f %f\"", "%", "(", "i", ",", "best", "[", "0", "]", ",", "best", "[", "1", "]", ")", ")", "changed", "=", "True", "elif", "best", "is", "not", "None", ":", "if", "best_dist", "<=", "(", "threshold", "+", "1", ")", "*", "3", ":", "print", "(", "\"Not snapping fence point %u dist %.1f\"", "%", "(", "i", ",", "best_dist", ")", ")", "if", "changed", ":", "fencemod", ".", "send_fence", "(", ")" ]
snap fence to KML
[ "snap", "fence", "to", "KML" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_kmlread.py#L110-L139
249,405
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_kmlread.py
KmlReadModule.fencekml
def fencekml(self, layername): '''set a layer as the geofence''' #Strip quotation marks if neccessary if layername.startswith('"') and layername.endswith('"'): layername = layername[1:-1] #for each point in the layer, add it in for layer in self.allayers: if layer.key == layername: #clear the current fence self.fenceloader.clear() if len(layer.points) < 3: return self.fenceloader.target_system = self.target_system self.fenceloader.target_component = self.target_component #send centrepoint to fence[0] as the return point bounds = mp_util.polygon_bounds(layer.points) (lat, lon, width, height) = bounds center = (lat+width/2, lon+height/2) self.fenceloader.add_latlon(center[0], center[1]) for lat, lon in layer.points: #add point self.fenceloader.add_latlon(lat, lon) #and send self.send_fence()
python
def fencekml(self, layername): '''set a layer as the geofence''' #Strip quotation marks if neccessary if layername.startswith('"') and layername.endswith('"'): layername = layername[1:-1] #for each point in the layer, add it in for layer in self.allayers: if layer.key == layername: #clear the current fence self.fenceloader.clear() if len(layer.points) < 3: return self.fenceloader.target_system = self.target_system self.fenceloader.target_component = self.target_component #send centrepoint to fence[0] as the return point bounds = mp_util.polygon_bounds(layer.points) (lat, lon, width, height) = bounds center = (lat+width/2, lon+height/2) self.fenceloader.add_latlon(center[0], center[1]) for lat, lon in layer.points: #add point self.fenceloader.add_latlon(lat, lon) #and send self.send_fence()
[ "def", "fencekml", "(", "self", ",", "layername", ")", ":", "#Strip quotation marks if neccessary", "if", "layername", ".", "startswith", "(", "'\"'", ")", "and", "layername", ".", "endswith", "(", "'\"'", ")", ":", "layername", "=", "layername", "[", "1", ":", "-", "1", "]", "#for each point in the layer, add it in", "for", "layer", "in", "self", ".", "allayers", ":", "if", "layer", ".", "key", "==", "layername", ":", "#clear the current fence", "self", ".", "fenceloader", ".", "clear", "(", ")", "if", "len", "(", "layer", ".", "points", ")", "<", "3", ":", "return", "self", ".", "fenceloader", ".", "target_system", "=", "self", ".", "target_system", "self", ".", "fenceloader", ".", "target_component", "=", "self", ".", "target_component", "#send centrepoint to fence[0] as the return point", "bounds", "=", "mp_util", ".", "polygon_bounds", "(", "layer", ".", "points", ")", "(", "lat", ",", "lon", ",", "width", ",", "height", ")", "=", "bounds", "center", "=", "(", "lat", "+", "width", "/", "2", ",", "lon", "+", "height", "/", "2", ")", "self", ".", "fenceloader", ".", "add_latlon", "(", "center", "[", "0", "]", ",", "center", "[", "1", "]", ")", "for", "lat", ",", "lon", "in", "layer", ".", "points", ":", "#add point", "self", ".", "fenceloader", ".", "add_latlon", "(", "lat", ",", "lon", ")", "#and send", "self", ".", "send_fence", "(", ")" ]
set a layer as the geofence
[ "set", "a", "layer", "as", "the", "geofence" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_kmlread.py#L141-L165
249,406
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_kmlread.py
KmlReadModule.togglekml
def togglekml(self, layername): '''toggle the display of a kml''' #Strip quotation marks if neccessary if layername.startswith('"') and layername.endswith('"'): layername = layername[1:-1] #toggle layer off (plus associated text element) if layername in self.curlayers: for layer in self.curlayers: if layer == layername: self.mpstate.map.remove_object(layer) self.curlayers.remove(layername) if layername in self.curtextlayers: for clayer in self.curtextlayers: if clayer == layername: self.mpstate.map.remove_object(clayer) self.curtextlayers.remove(clayer) #toggle layer on (plus associated text element) else: for layer in self.allayers: if layer.key == layername: self.mpstate.map.add_object(layer) self.curlayers.append(layername) for alayer in self.alltextlayers: if alayer.key == layername: self.mpstate.map.add_object(alayer) self.curtextlayers.append(layername) self.menu_needs_refreshing = True
python
def togglekml(self, layername): '''toggle the display of a kml''' #Strip quotation marks if neccessary if layername.startswith('"') and layername.endswith('"'): layername = layername[1:-1] #toggle layer off (plus associated text element) if layername in self.curlayers: for layer in self.curlayers: if layer == layername: self.mpstate.map.remove_object(layer) self.curlayers.remove(layername) if layername in self.curtextlayers: for clayer in self.curtextlayers: if clayer == layername: self.mpstate.map.remove_object(clayer) self.curtextlayers.remove(clayer) #toggle layer on (plus associated text element) else: for layer in self.allayers: if layer.key == layername: self.mpstate.map.add_object(layer) self.curlayers.append(layername) for alayer in self.alltextlayers: if alayer.key == layername: self.mpstate.map.add_object(alayer) self.curtextlayers.append(layername) self.menu_needs_refreshing = True
[ "def", "togglekml", "(", "self", ",", "layername", ")", ":", "#Strip quotation marks if neccessary", "if", "layername", ".", "startswith", "(", "'\"'", ")", "and", "layername", ".", "endswith", "(", "'\"'", ")", ":", "layername", "=", "layername", "[", "1", ":", "-", "1", "]", "#toggle layer off (plus associated text element)", "if", "layername", "in", "self", ".", "curlayers", ":", "for", "layer", "in", "self", ".", "curlayers", ":", "if", "layer", "==", "layername", ":", "self", ".", "mpstate", ".", "map", ".", "remove_object", "(", "layer", ")", "self", ".", "curlayers", ".", "remove", "(", "layername", ")", "if", "layername", "in", "self", ".", "curtextlayers", ":", "for", "clayer", "in", "self", ".", "curtextlayers", ":", "if", "clayer", "==", "layername", ":", "self", ".", "mpstate", ".", "map", ".", "remove_object", "(", "clayer", ")", "self", ".", "curtextlayers", ".", "remove", "(", "clayer", ")", "#toggle layer on (plus associated text element)", "else", ":", "for", "layer", "in", "self", ".", "allayers", ":", "if", "layer", ".", "key", "==", "layername", ":", "self", ".", "mpstate", ".", "map", ".", "add_object", "(", "layer", ")", "self", ".", "curlayers", ".", "append", "(", "layername", ")", "for", "alayer", "in", "self", ".", "alltextlayers", ":", "if", "alayer", ".", "key", "==", "layername", ":", "self", ".", "mpstate", ".", "map", ".", "add_object", "(", "alayer", ")", "self", ".", "curtextlayers", ".", "append", "(", "layername", ")", "self", ".", "menu_needs_refreshing", "=", "True" ]
toggle the display of a kml
[ "toggle", "the", "display", "of", "a", "kml" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_kmlread.py#L209-L235
249,407
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_kmlread.py
KmlReadModule.clearkml
def clearkml(self): '''Clear the kmls from the map''' #go through all the current layers and remove them for layer in self.curlayers: self.mpstate.map.remove_object(layer) for layer in self.curtextlayers: self.mpstate.map.remove_object(layer) self.allayers = [] self.curlayers = [] self.alltextlayers = [] self.curtextlayers = [] self.menu_needs_refreshing = True
python
def clearkml(self): '''Clear the kmls from the map''' #go through all the current layers and remove them for layer in self.curlayers: self.mpstate.map.remove_object(layer) for layer in self.curtextlayers: self.mpstate.map.remove_object(layer) self.allayers = [] self.curlayers = [] self.alltextlayers = [] self.curtextlayers = [] self.menu_needs_refreshing = True
[ "def", "clearkml", "(", "self", ")", ":", "#go through all the current layers and remove them", "for", "layer", "in", "self", ".", "curlayers", ":", "self", ".", "mpstate", ".", "map", ".", "remove_object", "(", "layer", ")", "for", "layer", "in", "self", ".", "curtextlayers", ":", "self", ".", "mpstate", ".", "map", ".", "remove_object", "(", "layer", ")", "self", ".", "allayers", "=", "[", "]", "self", ".", "curlayers", "=", "[", "]", "self", ".", "alltextlayers", "=", "[", "]", "self", ".", "curtextlayers", "=", "[", "]", "self", ".", "menu_needs_refreshing", "=", "True" ]
Clear the kmls from the map
[ "Clear", "the", "kmls", "from", "the", "map" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_kmlread.py#L237-L248
249,408
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_kmlread.py
KmlReadModule.loadkml
def loadkml(self, filename): '''Load a kml from file and put it on the map''' #Open the zip file nodes = self.readkmz(filename) self.snap_points = [] #go through each object in the kml... for n in nodes: point = self.readObject(n) #and place any polygons on the map if self.mpstate.map is not None and point[0] == 'Polygon': self.snap_points.extend(point[2]) #print("Adding " + point[1]) newcolour = (random.randint(0, 255), 0, random.randint(0, 255)) curpoly = mp_slipmap.SlipPolygon(point[1], point[2], layer=2, linewidth=2, colour=newcolour) self.mpstate.map.add_object(curpoly) self.allayers.append(curpoly) self.curlayers.append(point[1]) #and points - barrell image and text if self.mpstate.map is not None and point[0] == 'Point': #print("Adding " + point[1]) icon = self.mpstate.map.icon('barrell.png') curpoint = mp_slipmap.SlipIcon(point[1], latlon = (point[2][0][0], point[2][0][1]), layer=3, img=icon, rotation=0, follow=False) curtext = mp_slipmap.SlipLabel(point[1], point = (point[2][0][0], point[2][0][1]), layer=4, label=point[1], colour=(0,255,255)) self.mpstate.map.add_object(curpoint) self.mpstate.map.add_object(curtext) self.allayers.append(curpoint) self.alltextlayers.append(curtext) self.curlayers.append(point[1]) self.curtextlayers.append(point[1]) self.menu_needs_refreshing = True
python
def loadkml(self, filename): '''Load a kml from file and put it on the map''' #Open the zip file nodes = self.readkmz(filename) self.snap_points = [] #go through each object in the kml... for n in nodes: point = self.readObject(n) #and place any polygons on the map if self.mpstate.map is not None and point[0] == 'Polygon': self.snap_points.extend(point[2]) #print("Adding " + point[1]) newcolour = (random.randint(0, 255), 0, random.randint(0, 255)) curpoly = mp_slipmap.SlipPolygon(point[1], point[2], layer=2, linewidth=2, colour=newcolour) self.mpstate.map.add_object(curpoly) self.allayers.append(curpoly) self.curlayers.append(point[1]) #and points - barrell image and text if self.mpstate.map is not None and point[0] == 'Point': #print("Adding " + point[1]) icon = self.mpstate.map.icon('barrell.png') curpoint = mp_slipmap.SlipIcon(point[1], latlon = (point[2][0][0], point[2][0][1]), layer=3, img=icon, rotation=0, follow=False) curtext = mp_slipmap.SlipLabel(point[1], point = (point[2][0][0], point[2][0][1]), layer=4, label=point[1], colour=(0,255,255)) self.mpstate.map.add_object(curpoint) self.mpstate.map.add_object(curtext) self.allayers.append(curpoint) self.alltextlayers.append(curtext) self.curlayers.append(point[1]) self.curtextlayers.append(point[1]) self.menu_needs_refreshing = True
[ "def", "loadkml", "(", "self", ",", "filename", ")", ":", "#Open the zip file", "nodes", "=", "self", ".", "readkmz", "(", "filename", ")", "self", ".", "snap_points", "=", "[", "]", "#go through each object in the kml...", "for", "n", "in", "nodes", ":", "point", "=", "self", ".", "readObject", "(", "n", ")", "#and place any polygons on the map", "if", "self", ".", "mpstate", ".", "map", "is", "not", "None", "and", "point", "[", "0", "]", "==", "'Polygon'", ":", "self", ".", "snap_points", ".", "extend", "(", "point", "[", "2", "]", ")", "#print(\"Adding \" + point[1])", "newcolour", "=", "(", "random", ".", "randint", "(", "0", ",", "255", ")", ",", "0", ",", "random", ".", "randint", "(", "0", ",", "255", ")", ")", "curpoly", "=", "mp_slipmap", ".", "SlipPolygon", "(", "point", "[", "1", "]", ",", "point", "[", "2", "]", ",", "layer", "=", "2", ",", "linewidth", "=", "2", ",", "colour", "=", "newcolour", ")", "self", ".", "mpstate", ".", "map", ".", "add_object", "(", "curpoly", ")", "self", ".", "allayers", ".", "append", "(", "curpoly", ")", "self", ".", "curlayers", ".", "append", "(", "point", "[", "1", "]", ")", "#and points - barrell image and text", "if", "self", ".", "mpstate", ".", "map", "is", "not", "None", "and", "point", "[", "0", "]", "==", "'Point'", ":", "#print(\"Adding \" + point[1])", "icon", "=", "self", ".", "mpstate", ".", "map", ".", "icon", "(", "'barrell.png'", ")", "curpoint", "=", "mp_slipmap", ".", "SlipIcon", "(", "point", "[", "1", "]", ",", "latlon", "=", "(", "point", "[", "2", "]", "[", "0", "]", "[", "0", "]", ",", "point", "[", "2", "]", "[", "0", "]", "[", "1", "]", ")", ",", "layer", "=", "3", ",", "img", "=", "icon", ",", "rotation", "=", "0", ",", "follow", "=", "False", ")", "curtext", "=", "mp_slipmap", ".", "SlipLabel", "(", "point", "[", "1", "]", ",", "point", "=", "(", "point", "[", "2", "]", "[", "0", "]", "[", "0", "]", ",", "point", "[", "2", "]", "[", "0", "]", "[", "1", "]", ")", ",", "layer", "=", "4", ",", "label", "=", "point", "[", "1", "]", ",", "colour", "=", "(", "0", ",", "255", ",", "255", ")", ")", "self", ".", "mpstate", ".", "map", ".", "add_object", "(", "curpoint", ")", "self", ".", "mpstate", ".", "map", ".", "add_object", "(", "curtext", ")", "self", ".", "allayers", ".", "append", "(", "curpoint", ")", "self", ".", "alltextlayers", ".", "append", "(", "curtext", ")", "self", ".", "curlayers", ".", "append", "(", "point", "[", "1", "]", ")", "self", ".", "curtextlayers", ".", "append", "(", "point", "[", "1", "]", ")", "self", ".", "menu_needs_refreshing", "=", "True" ]
Load a kml from file and put it on the map
[ "Load", "a", "kml", "from", "file", "and", "put", "it", "on", "the", "map" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_kmlread.py#L250-L286
249,409
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_kmlread.py
KmlReadModule.idle_task
def idle_task(self): '''handle GUI elements''' if not self.menu_needs_refreshing: return if self.module('map') is not None and not self.menu_added_map: self.menu_added_map = True self.module('map').add_menu(self.menu) #(re)create the menu if mp_util.has_wxpython and self.menu_added_map: # we don't dynamically update these yet due to a wx bug self.menu.items = [ MPMenuItem('Clear', 'Clear', '# kml clear'), MPMenuItem('Load', 'Load', '# kml load ', handler=MPMenuCallFileDialog(flags=('open',), title='KML Load', wildcard='*.kml;*.kmz')), self.menu_fence, MPMenuSeparator() ] self.menu_fence.items = [] for layer in self.allayers: #if it's a polygon, add it to the "set Geofence" list if isinstance(layer, mp_slipmap.SlipPolygon): self.menu_fence.items.append(MPMenuItem(layer.key, layer.key, '# kml fence \"' + layer.key + '\"')) #then add all the layers to the menu, ensuring to check the active layers #text elements aren't included on the menu if layer.key in self.curlayers and layer.key[-5:] != "-text": self.menu.items.append(MPMenuCheckbox(layer.key, layer.key, '# kml toggle \"' + layer.key + '\"', checked=True)) elif layer.key[-5:] != "-text": self.menu.items.append(MPMenuCheckbox(layer.key, layer.key, '# kml toggle \"' + layer.key + '\"', checked=False)) #and add the menu to the map popu menu self.module('map').add_menu(self.menu) self.menu_needs_refreshing = False
python
def idle_task(self): '''handle GUI elements''' if not self.menu_needs_refreshing: return if self.module('map') is not None and not self.menu_added_map: self.menu_added_map = True self.module('map').add_menu(self.menu) #(re)create the menu if mp_util.has_wxpython and self.menu_added_map: # we don't dynamically update these yet due to a wx bug self.menu.items = [ MPMenuItem('Clear', 'Clear', '# kml clear'), MPMenuItem('Load', 'Load', '# kml load ', handler=MPMenuCallFileDialog(flags=('open',), title='KML Load', wildcard='*.kml;*.kmz')), self.menu_fence, MPMenuSeparator() ] self.menu_fence.items = [] for layer in self.allayers: #if it's a polygon, add it to the "set Geofence" list if isinstance(layer, mp_slipmap.SlipPolygon): self.menu_fence.items.append(MPMenuItem(layer.key, layer.key, '# kml fence \"' + layer.key + '\"')) #then add all the layers to the menu, ensuring to check the active layers #text elements aren't included on the menu if layer.key in self.curlayers and layer.key[-5:] != "-text": self.menu.items.append(MPMenuCheckbox(layer.key, layer.key, '# kml toggle \"' + layer.key + '\"', checked=True)) elif layer.key[-5:] != "-text": self.menu.items.append(MPMenuCheckbox(layer.key, layer.key, '# kml toggle \"' + layer.key + '\"', checked=False)) #and add the menu to the map popu menu self.module('map').add_menu(self.menu) self.menu_needs_refreshing = False
[ "def", "idle_task", "(", "self", ")", ":", "if", "not", "self", ".", "menu_needs_refreshing", ":", "return", "if", "self", ".", "module", "(", "'map'", ")", "is", "not", "None", "and", "not", "self", ".", "menu_added_map", ":", "self", ".", "menu_added_map", "=", "True", "self", ".", "module", "(", "'map'", ")", ".", "add_menu", "(", "self", ".", "menu", ")", "#(re)create the menu", "if", "mp_util", ".", "has_wxpython", "and", "self", ".", "menu_added_map", ":", "# we don't dynamically update these yet due to a wx bug", "self", ".", "menu", ".", "items", "=", "[", "MPMenuItem", "(", "'Clear'", ",", "'Clear'", ",", "'# kml clear'", ")", ",", "MPMenuItem", "(", "'Load'", ",", "'Load'", ",", "'# kml load '", ",", "handler", "=", "MPMenuCallFileDialog", "(", "flags", "=", "(", "'open'", ",", ")", ",", "title", "=", "'KML Load'", ",", "wildcard", "=", "'*.kml;*.kmz'", ")", ")", ",", "self", ".", "menu_fence", ",", "MPMenuSeparator", "(", ")", "]", "self", ".", "menu_fence", ".", "items", "=", "[", "]", "for", "layer", "in", "self", ".", "allayers", ":", "#if it's a polygon, add it to the \"set Geofence\" list", "if", "isinstance", "(", "layer", ",", "mp_slipmap", ".", "SlipPolygon", ")", ":", "self", ".", "menu_fence", ".", "items", ".", "append", "(", "MPMenuItem", "(", "layer", ".", "key", ",", "layer", ".", "key", ",", "'# kml fence \\\"'", "+", "layer", ".", "key", "+", "'\\\"'", ")", ")", "#then add all the layers to the menu, ensuring to check the active layers", "#text elements aren't included on the menu", "if", "layer", ".", "key", "in", "self", ".", "curlayers", "and", "layer", ".", "key", "[", "-", "5", ":", "]", "!=", "\"-text\"", ":", "self", ".", "menu", ".", "items", ".", "append", "(", "MPMenuCheckbox", "(", "layer", ".", "key", ",", "layer", ".", "key", ",", "'# kml toggle \\\"'", "+", "layer", ".", "key", "+", "'\\\"'", ",", "checked", "=", "True", ")", ")", "elif", "layer", ".", "key", "[", "-", "5", ":", "]", "!=", "\"-text\"", ":", "self", ".", "menu", ".", "items", ".", "append", "(", "MPMenuCheckbox", "(", "layer", ".", "key", ",", "layer", ".", "key", ",", "'# kml toggle \\\"'", "+", "layer", ".", "key", "+", "'\\\"'", ",", "checked", "=", "False", ")", ")", "#and add the menu to the map popu menu", "self", ".", "module", "(", "'map'", ")", ".", "add_menu", "(", "self", ".", "menu", ")", "self", ".", "menu_needs_refreshing", "=", "False" ]
handle GUI elements
[ "handle", "GUI", "elements" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_kmlread.py#L289-L313
249,410
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_kmlread.py
KmlReadModule.readkmz
def readkmz(self, filename): '''reads in a kmz file and returns xml nodes''' #Strip quotation marks if neccessary filename.strip('"') #Open the zip file (as applicable) if filename[-4:] == '.kml': fo = open(filename, "r") fstring = fo.read() fo.close() elif filename[-4:] == '.kmz': zip=ZipFile(filename) for z in zip.filelist: if z.filename[-4:] == '.kml': fstring=zip.read(z) break else: raise Exception("Could not find kml file in %s" % filename) else: raise Exception("Is not a valid kml or kmz file in %s" % filename) #send into the xml parser kmlstring = parseString(fstring) #get all the placenames nodes=kmlstring.getElementsByTagName('Placemark') return nodes
python
def readkmz(self, filename): '''reads in a kmz file and returns xml nodes''' #Strip quotation marks if neccessary filename.strip('"') #Open the zip file (as applicable) if filename[-4:] == '.kml': fo = open(filename, "r") fstring = fo.read() fo.close() elif filename[-4:] == '.kmz': zip=ZipFile(filename) for z in zip.filelist: if z.filename[-4:] == '.kml': fstring=zip.read(z) break else: raise Exception("Could not find kml file in %s" % filename) else: raise Exception("Is not a valid kml or kmz file in %s" % filename) #send into the xml parser kmlstring = parseString(fstring) #get all the placenames nodes=kmlstring.getElementsByTagName('Placemark') return nodes
[ "def", "readkmz", "(", "self", ",", "filename", ")", ":", "#Strip quotation marks if neccessary", "filename", ".", "strip", "(", "'\"'", ")", "#Open the zip file (as applicable) ", "if", "filename", "[", "-", "4", ":", "]", "==", "'.kml'", ":", "fo", "=", "open", "(", "filename", ",", "\"r\"", ")", "fstring", "=", "fo", ".", "read", "(", ")", "fo", ".", "close", "(", ")", "elif", "filename", "[", "-", "4", ":", "]", "==", "'.kmz'", ":", "zip", "=", "ZipFile", "(", "filename", ")", "for", "z", "in", "zip", ".", "filelist", ":", "if", "z", ".", "filename", "[", "-", "4", ":", "]", "==", "'.kml'", ":", "fstring", "=", "zip", ".", "read", "(", "z", ")", "break", "else", ":", "raise", "Exception", "(", "\"Could not find kml file in %s\"", "%", "filename", ")", "else", ":", "raise", "Exception", "(", "\"Is not a valid kml or kmz file in %s\"", "%", "filename", ")", "#send into the xml parser", "kmlstring", "=", "parseString", "(", "fstring", ")", "#get all the placenames", "nodes", "=", "kmlstring", ".", "getElementsByTagName", "(", "'Placemark'", ")", "return", "nodes" ]
reads in a kmz file and returns xml nodes
[ "reads", "in", "a", "kmz", "file", "and", "returns", "xml", "nodes" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_kmlread.py#L318-L344
249,411
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_asterix.py
AsterixModule.cmd_asterix
def cmd_asterix(self, args): '''asterix command parser''' usage = "usage: asterix <set|start|stop|restart|status>" if len(args) == 0: print(usage) return if args[0] == "set": self.asterix_settings.command(args[1:]) elif args[0] == "start": self.start_listener() elif args[0] == "stop": self.stop_listener() elif args[0] == "restart": self.stop_listener() self.start_listener() elif args[0] == "status": self.print_status() else: print(usage)
python
def cmd_asterix(self, args): '''asterix command parser''' usage = "usage: asterix <set|start|stop|restart|status>" if len(args) == 0: print(usage) return if args[0] == "set": self.asterix_settings.command(args[1:]) elif args[0] == "start": self.start_listener() elif args[0] == "stop": self.stop_listener() elif args[0] == "restart": self.stop_listener() self.start_listener() elif args[0] == "status": self.print_status() else: print(usage)
[ "def", "cmd_asterix", "(", "self", ",", "args", ")", ":", "usage", "=", "\"usage: asterix <set|start|stop|restart|status>\"", "if", "len", "(", "args", ")", "==", "0", ":", "print", "(", "usage", ")", "return", "if", "args", "[", "0", "]", "==", "\"set\"", ":", "self", ".", "asterix_settings", ".", "command", "(", "args", "[", "1", ":", "]", ")", "elif", "args", "[", "0", "]", "==", "\"start\"", ":", "self", ".", "start_listener", "(", ")", "elif", "args", "[", "0", "]", "==", "\"stop\"", ":", "self", ".", "stop_listener", "(", ")", "elif", "args", "[", "0", "]", "==", "\"restart\"", ":", "self", ".", "stop_listener", "(", ")", "self", ".", "start_listener", "(", ")", "elif", "args", "[", "0", "]", "==", "\"status\"", ":", "self", ".", "print_status", "(", ")", "else", ":", "print", "(", "usage", ")" ]
asterix command parser
[ "asterix", "command", "parser" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_asterix.py#L99-L117
249,412
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_asterix.py
AsterixModule.start_listener
def start_listener(self): '''start listening for packets''' if self.sock is not None: self.sock.close() self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP) self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) self.sock.bind(('', self.asterix_settings.port)) self.sock.setblocking(False) print("Started on port %u" % self.asterix_settings.port)
python
def start_listener(self): '''start listening for packets''' if self.sock is not None: self.sock.close() self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP) self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) self.sock.bind(('', self.asterix_settings.port)) self.sock.setblocking(False) print("Started on port %u" % self.asterix_settings.port)
[ "def", "start_listener", "(", "self", ")", ":", "if", "self", ".", "sock", "is", "not", "None", ":", "self", ".", "sock", ".", "close", "(", ")", "self", ".", "sock", "=", "socket", ".", "socket", "(", "socket", ".", "AF_INET", ",", "socket", ".", "SOCK_DGRAM", ",", "socket", ".", "IPPROTO_UDP", ")", "self", ".", "sock", ".", "setsockopt", "(", "socket", ".", "SOL_SOCKET", ",", "socket", ".", "SO_REUSEADDR", ",", "1", ")", "self", ".", "sock", ".", "bind", "(", "(", "''", ",", "self", ".", "asterix_settings", ".", "port", ")", ")", "self", ".", "sock", ".", "setblocking", "(", "False", ")", "print", "(", "\"Started on port %u\"", "%", "self", ".", "asterix_settings", ".", "port", ")" ]
start listening for packets
[ "start", "listening", "for", "packets" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_asterix.py#L119-L127
249,413
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_asterix.py
AsterixModule.stop_listener
def stop_listener(self): '''stop listening for packets''' if self.sock is not None: self.sock.close() self.sock = None self.tracks = {}
python
def stop_listener(self): '''stop listening for packets''' if self.sock is not None: self.sock.close() self.sock = None self.tracks = {}
[ "def", "stop_listener", "(", "self", ")", ":", "if", "self", ".", "sock", "is", "not", "None", ":", "self", ".", "sock", ".", "close", "(", ")", "self", ".", "sock", "=", "None", "self", ".", "tracks", "=", "{", "}" ]
stop listening for packets
[ "stop", "listening", "for", "packets" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_asterix.py#L129-L134
249,414
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_asterix.py
AsterixModule.set_secondary_vehicle_position
def set_secondary_vehicle_position(self, m): '''store second vehicle position for filtering purposes''' if m.get_type() != 'GLOBAL_POSITION_INT': return (lat, lon, heading) = (m.lat*1.0e-7, m.lon*1.0e-7, m.hdg*0.01) if abs(lat) < 1.0e-3 and abs(lon) < 1.0e-3: return self.vehicle2_pos = VehiclePos(m)
python
def set_secondary_vehicle_position(self, m): '''store second vehicle position for filtering purposes''' if m.get_type() != 'GLOBAL_POSITION_INT': return (lat, lon, heading) = (m.lat*1.0e-7, m.lon*1.0e-7, m.hdg*0.01) if abs(lat) < 1.0e-3 and abs(lon) < 1.0e-3: return self.vehicle2_pos = VehiclePos(m)
[ "def", "set_secondary_vehicle_position", "(", "self", ",", "m", ")", ":", "if", "m", ".", "get_type", "(", ")", "!=", "'GLOBAL_POSITION_INT'", ":", "return", "(", "lat", ",", "lon", ",", "heading", ")", "=", "(", "m", ".", "lat", "*", "1.0e-7", ",", "m", ".", "lon", "*", "1.0e-7", ",", "m", ".", "hdg", "*", "0.01", ")", "if", "abs", "(", "lat", ")", "<", "1.0e-3", "and", "abs", "(", "lon", ")", "<", "1.0e-3", ":", "return", "self", ".", "vehicle2_pos", "=", "VehiclePos", "(", "m", ")" ]
store second vehicle position for filtering purposes
[ "store", "second", "vehicle", "position", "for", "filtering", "purposes" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_asterix.py#L136-L143
249,415
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_asterix.py
AsterixModule.could_collide_hor
def could_collide_hor(self, vpos, adsb_pkt): '''return true if vehicle could come within filter_dist_xy meters of adsb vehicle in timeout seconds''' margin = self.asterix_settings.filter_dist_xy timeout = self.asterix_settings.filter_time alat = adsb_pkt.lat * 1.0e-7 alon = adsb_pkt.lon * 1.0e-7 avel = adsb_pkt.hor_velocity * 0.01 vvel = sqrt(vpos.vx**2 + vpos.vy**2) dist = mp_util.gps_distance(vpos.lat, vpos.lon, alat, alon) dist -= avel * timeout dist -= vvel * timeout if dist <= margin: return True return False
python
def could_collide_hor(self, vpos, adsb_pkt): '''return true if vehicle could come within filter_dist_xy meters of adsb vehicle in timeout seconds''' margin = self.asterix_settings.filter_dist_xy timeout = self.asterix_settings.filter_time alat = adsb_pkt.lat * 1.0e-7 alon = adsb_pkt.lon * 1.0e-7 avel = adsb_pkt.hor_velocity * 0.01 vvel = sqrt(vpos.vx**2 + vpos.vy**2) dist = mp_util.gps_distance(vpos.lat, vpos.lon, alat, alon) dist -= avel * timeout dist -= vvel * timeout if dist <= margin: return True return False
[ "def", "could_collide_hor", "(", "self", ",", "vpos", ",", "adsb_pkt", ")", ":", "margin", "=", "self", ".", "asterix_settings", ".", "filter_dist_xy", "timeout", "=", "self", ".", "asterix_settings", ".", "filter_time", "alat", "=", "adsb_pkt", ".", "lat", "*", "1.0e-7", "alon", "=", "adsb_pkt", ".", "lon", "*", "1.0e-7", "avel", "=", "adsb_pkt", ".", "hor_velocity", "*", "0.01", "vvel", "=", "sqrt", "(", "vpos", ".", "vx", "**", "2", "+", "vpos", ".", "vy", "**", "2", ")", "dist", "=", "mp_util", ".", "gps_distance", "(", "vpos", ".", "lat", ",", "vpos", ".", "lon", ",", "alat", ",", "alon", ")", "dist", "-=", "avel", "*", "timeout", "dist", "-=", "vvel", "*", "timeout", "if", "dist", "<=", "margin", ":", "return", "True", "return", "False" ]
return true if vehicle could come within filter_dist_xy meters of adsb vehicle in timeout seconds
[ "return", "true", "if", "vehicle", "could", "come", "within", "filter_dist_xy", "meters", "of", "adsb", "vehicle", "in", "timeout", "seconds" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_asterix.py#L145-L158
249,416
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_asterix.py
AsterixModule.could_collide_ver
def could_collide_ver(self, vpos, adsb_pkt): '''return true if vehicle could come within filter_dist_z meters of adsb vehicle in timeout seconds''' if adsb_pkt.emitter_type < 100 or adsb_pkt.emitter_type > 104: return True margin = self.asterix_settings.filter_dist_z vtype = adsb_pkt.emitter_type - 100 valt = vpos.alt aalt1 = adsb_pkt.altitude * 0.001 if vtype == 2: # weather, always yes return True if vtype == 4: # bird of prey, always true return True # planes and migrating birds have 150m margin aalt2 = aalt1 + adsb_pkt.ver_velocity * 0.01 * self.asterix_settings.filter_time altsep1 = abs(valt - aalt1) altsep2 = abs(valt - aalt2) if altsep1 > 150 + margin and altsep2 > 150 + margin: return False return True
python
def could_collide_ver(self, vpos, adsb_pkt): '''return true if vehicle could come within filter_dist_z meters of adsb vehicle in timeout seconds''' if adsb_pkt.emitter_type < 100 or adsb_pkt.emitter_type > 104: return True margin = self.asterix_settings.filter_dist_z vtype = adsb_pkt.emitter_type - 100 valt = vpos.alt aalt1 = adsb_pkt.altitude * 0.001 if vtype == 2: # weather, always yes return True if vtype == 4: # bird of prey, always true return True # planes and migrating birds have 150m margin aalt2 = aalt1 + adsb_pkt.ver_velocity * 0.01 * self.asterix_settings.filter_time altsep1 = abs(valt - aalt1) altsep2 = abs(valt - aalt2) if altsep1 > 150 + margin and altsep2 > 150 + margin: return False return True
[ "def", "could_collide_ver", "(", "self", ",", "vpos", ",", "adsb_pkt", ")", ":", "if", "adsb_pkt", ".", "emitter_type", "<", "100", "or", "adsb_pkt", ".", "emitter_type", ">", "104", ":", "return", "True", "margin", "=", "self", ".", "asterix_settings", ".", "filter_dist_z", "vtype", "=", "adsb_pkt", ".", "emitter_type", "-", "100", "valt", "=", "vpos", ".", "alt", "aalt1", "=", "adsb_pkt", ".", "altitude", "*", "0.001", "if", "vtype", "==", "2", ":", "# weather, always yes", "return", "True", "if", "vtype", "==", "4", ":", "# bird of prey, always true", "return", "True", "# planes and migrating birds have 150m margin", "aalt2", "=", "aalt1", "+", "adsb_pkt", ".", "ver_velocity", "*", "0.01", "*", "self", ".", "asterix_settings", ".", "filter_time", "altsep1", "=", "abs", "(", "valt", "-", "aalt1", ")", "altsep2", "=", "abs", "(", "valt", "-", "aalt2", ")", "if", "altsep1", ">", "150", "+", "margin", "and", "altsep2", ">", "150", "+", "margin", ":", "return", "False", "return", "True" ]
return true if vehicle could come within filter_dist_z meters of adsb vehicle in timeout seconds
[ "return", "true", "if", "vehicle", "could", "come", "within", "filter_dist_z", "meters", "of", "adsb", "vehicle", "in", "timeout", "seconds" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_asterix.py#L160-L180
249,417
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_asterix.py
AsterixModule.mavlink_packet
def mavlink_packet(self, m): '''get time from mavlink ATTITUDE''' if m.get_type() == 'GLOBAL_POSITION_INT': if abs(m.lat) < 1000 and abs(m.lon) < 1000: return self.vehicle_pos = VehiclePos(m)
python
def mavlink_packet(self, m): '''get time from mavlink ATTITUDE''' if m.get_type() == 'GLOBAL_POSITION_INT': if abs(m.lat) < 1000 and abs(m.lon) < 1000: return self.vehicle_pos = VehiclePos(m)
[ "def", "mavlink_packet", "(", "self", ",", "m", ")", ":", "if", "m", ".", "get_type", "(", ")", "==", "'GLOBAL_POSITION_INT'", ":", "if", "abs", "(", "m", ".", "lat", ")", "<", "1000", "and", "abs", "(", "m", ".", "lon", ")", "<", "1000", ":", "return", "self", ".", "vehicle_pos", "=", "VehiclePos", "(", "m", ")" ]
get time from mavlink ATTITUDE
[ "get", "time", "from", "mavlink", "ATTITUDE" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_asterix.py#L300-L305
249,418
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_link.py
LinkModule.complete_serial_ports
def complete_serial_ports(self, text): '''return list of serial ports''' ports = mavutil.auto_detect_serial(preferred_list=preferred_ports) return [ p.device for p in ports ]
python
def complete_serial_ports(self, text): '''return list of serial ports''' ports = mavutil.auto_detect_serial(preferred_list=preferred_ports) return [ p.device for p in ports ]
[ "def", "complete_serial_ports", "(", "self", ",", "text", ")", ":", "ports", "=", "mavutil", ".", "auto_detect_serial", "(", "preferred_list", "=", "preferred_ports", ")", "return", "[", "p", ".", "device", "for", "p", "in", "ports", "]" ]
return list of serial ports
[ "return", "list", "of", "serial", "ports" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_link.py#L77-L80
249,419
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_link.py
LinkModule.complete_links
def complete_links(self, text): '''return list of links''' try: ret = [ m.address for m in self.mpstate.mav_master ] for m in self.mpstate.mav_master: ret.append(m.address) if hasattr(m, 'label'): ret.append(m.label) return ret except Exception as e: print("Caught exception: %s" % str(e))
python
def complete_links(self, text): '''return list of links''' try: ret = [ m.address for m in self.mpstate.mav_master ] for m in self.mpstate.mav_master: ret.append(m.address) if hasattr(m, 'label'): ret.append(m.label) return ret except Exception as e: print("Caught exception: %s" % str(e))
[ "def", "complete_links", "(", "self", ",", "text", ")", ":", "try", ":", "ret", "=", "[", "m", ".", "address", "for", "m", "in", "self", ".", "mpstate", ".", "mav_master", "]", "for", "m", "in", "self", ".", "mpstate", ".", "mav_master", ":", "ret", ".", "append", "(", "m", ".", "address", ")", "if", "hasattr", "(", "m", ",", "'label'", ")", ":", "ret", ".", "append", "(", "m", ".", "label", ")", "return", "ret", "except", "Exception", "as", "e", ":", "print", "(", "\"Caught exception: %s\"", "%", "str", "(", "e", ")", ")" ]
return list of links
[ "return", "list", "of", "links" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_link.py#L82-L92
249,420
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_link.py
LinkModule.cmd_link_attributes
def cmd_link_attributes(self, args): '''change optional link attributes''' link = args[0] attributes = args[1] print("Setting link %s attributes (%s)" % (link, attributes)) self.link_attributes(link, attributes)
python
def cmd_link_attributes(self, args): '''change optional link attributes''' link = args[0] attributes = args[1] print("Setting link %s attributes (%s)" % (link, attributes)) self.link_attributes(link, attributes)
[ "def", "cmd_link_attributes", "(", "self", ",", "args", ")", ":", "link", "=", "args", "[", "0", "]", "attributes", "=", "args", "[", "1", "]", "print", "(", "\"Setting link %s attributes (%s)\"", "%", "(", "link", ",", "attributes", ")", ")", "self", ".", "link_attributes", "(", "link", ",", "attributes", ")" ]
change optional link attributes
[ "change", "optional", "link", "attributes" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_link.py#L242-L247
249,421
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_link.py
LinkModule.find_link
def find_link(self, device): '''find a device based on number, name or label''' for i in range(len(self.mpstate.mav_master)): conn = self.mpstate.mav_master[i] if (str(i) == device or conn.address == device or getattr(conn, 'label', None) == device): return i return None
python
def find_link(self, device): '''find a device based on number, name or label''' for i in range(len(self.mpstate.mav_master)): conn = self.mpstate.mav_master[i] if (str(i) == device or conn.address == device or getattr(conn, 'label', None) == device): return i return None
[ "def", "find_link", "(", "self", ",", "device", ")", ":", "for", "i", "in", "range", "(", "len", "(", "self", ".", "mpstate", ".", "mav_master", ")", ")", ":", "conn", "=", "self", ".", "mpstate", ".", "mav_master", "[", "i", "]", "if", "(", "str", "(", "i", ")", "==", "device", "or", "conn", ".", "address", "==", "device", "or", "getattr", "(", "conn", ",", "'label'", ",", "None", ")", "==", "device", ")", ":", "return", "i", "return", "None" ]
find a device based on number, name or label
[ "find", "a", "device", "based", "on", "number", "name", "or", "label" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_link.py#L255-L263
249,422
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_link.py
LinkModule.cmd_link_remove
def cmd_link_remove(self, args): '''remove an link''' device = args[0] if len(self.mpstate.mav_master) <= 1: print("Not removing last link") return i = self.find_link(device) if i is None: return conn = self.mpstate.mav_master[i] print("Removing link %s" % conn.address) try: try: mp_util.child_fd_list_remove(conn.port.fileno()) except Exception: pass self.mpstate.mav_master[i].close() except Exception as msg: print(msg) pass self.mpstate.mav_master.pop(i) self.status.counters['MasterIn'].pop(i) # renumber the links for j in range(len(self.mpstate.mav_master)): conn = self.mpstate.mav_master[j] conn.linknum = j
python
def cmd_link_remove(self, args): '''remove an link''' device = args[0] if len(self.mpstate.mav_master) <= 1: print("Not removing last link") return i = self.find_link(device) if i is None: return conn = self.mpstate.mav_master[i] print("Removing link %s" % conn.address) try: try: mp_util.child_fd_list_remove(conn.port.fileno()) except Exception: pass self.mpstate.mav_master[i].close() except Exception as msg: print(msg) pass self.mpstate.mav_master.pop(i) self.status.counters['MasterIn'].pop(i) # renumber the links for j in range(len(self.mpstate.mav_master)): conn = self.mpstate.mav_master[j] conn.linknum = j
[ "def", "cmd_link_remove", "(", "self", ",", "args", ")", ":", "device", "=", "args", "[", "0", "]", "if", "len", "(", "self", ".", "mpstate", ".", "mav_master", ")", "<=", "1", ":", "print", "(", "\"Not removing last link\"", ")", "return", "i", "=", "self", ".", "find_link", "(", "device", ")", "if", "i", "is", "None", ":", "return", "conn", "=", "self", ".", "mpstate", ".", "mav_master", "[", "i", "]", "print", "(", "\"Removing link %s\"", "%", "conn", ".", "address", ")", "try", ":", "try", ":", "mp_util", ".", "child_fd_list_remove", "(", "conn", ".", "port", ".", "fileno", "(", ")", ")", "except", "Exception", ":", "pass", "self", ".", "mpstate", ".", "mav_master", "[", "i", "]", ".", "close", "(", ")", "except", "Exception", "as", "msg", ":", "print", "(", "msg", ")", "pass", "self", ".", "mpstate", ".", "mav_master", ".", "pop", "(", "i", ")", "self", ".", "status", ".", "counters", "[", "'MasterIn'", "]", ".", "pop", "(", "i", ")", "# renumber the links", "for", "j", "in", "range", "(", "len", "(", "self", ".", "mpstate", ".", "mav_master", ")", ")", ":", "conn", "=", "self", ".", "mpstate", ".", "mav_master", "[", "j", "]", "conn", ".", "linknum", "=", "j" ]
remove an link
[ "remove", "an", "link" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_link.py#L265-L290
249,423
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_link.py
LinkModule.master_send_callback
def master_send_callback(self, m, master): '''called on sending a message''' if self.status.watch is not None: for msg_type in self.status.watch: if fnmatch.fnmatch(m.get_type().upper(), msg_type.upper()): self.mpstate.console.writeln('> '+ str(m)) break mtype = m.get_type() if mtype != 'BAD_DATA' and self.mpstate.logqueue: usec = self.get_usec() usec = (usec & ~3) | 3 # linknum 3 self.mpstate.logqueue.put(bytearray(struct.pack('>Q', usec) + m.get_msgbuf()))
python
def master_send_callback(self, m, master): '''called on sending a message''' if self.status.watch is not None: for msg_type in self.status.watch: if fnmatch.fnmatch(m.get_type().upper(), msg_type.upper()): self.mpstate.console.writeln('> '+ str(m)) break mtype = m.get_type() if mtype != 'BAD_DATA' and self.mpstate.logqueue: usec = self.get_usec() usec = (usec & ~3) | 3 # linknum 3 self.mpstate.logqueue.put(bytearray(struct.pack('>Q', usec) + m.get_msgbuf()))
[ "def", "master_send_callback", "(", "self", ",", "m", ",", "master", ")", ":", "if", "self", ".", "status", ".", "watch", "is", "not", "None", ":", "for", "msg_type", "in", "self", ".", "status", ".", "watch", ":", "if", "fnmatch", ".", "fnmatch", "(", "m", ".", "get_type", "(", ")", ".", "upper", "(", ")", ",", "msg_type", ".", "upper", "(", ")", ")", ":", "self", ".", "mpstate", ".", "console", ".", "writeln", "(", "'> '", "+", "str", "(", "m", ")", ")", "break", "mtype", "=", "m", ".", "get_type", "(", ")", "if", "mtype", "!=", "'BAD_DATA'", "and", "self", ".", "mpstate", ".", "logqueue", ":", "usec", "=", "self", ".", "get_usec", "(", ")", "usec", "=", "(", "usec", "&", "~", "3", ")", "|", "3", "# linknum 3", "self", ".", "mpstate", ".", "logqueue", ".", "put", "(", "bytearray", "(", "struct", ".", "pack", "(", "'>Q'", ",", "usec", ")", "+", "m", ".", "get_msgbuf", "(", ")", ")", ")" ]
called on sending a message
[ "called", "on", "sending", "a", "message" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_link.py#L296-L308
249,424
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_link.py
LinkModule.handle_msec_timestamp
def handle_msec_timestamp(self, m, master): '''special handling for MAVLink packets with a time_boot_ms field''' if m.get_type() == 'GLOBAL_POSITION_INT': # this is fix time, not boot time return msec = m.time_boot_ms if msec + 30000 < master.highest_msec: self.say('Time has wrapped') print('Time has wrapped', msec, master.highest_msec) self.status.highest_msec = msec for mm in self.mpstate.mav_master: mm.link_delayed = False mm.highest_msec = msec return # we want to detect when a link is delayed master.highest_msec = msec if msec > self.status.highest_msec: self.status.highest_msec = msec if msec < self.status.highest_msec and len(self.mpstate.mav_master) > 1 and self.mpstate.settings.checkdelay: master.link_delayed = True else: master.link_delayed = False
python
def handle_msec_timestamp(self, m, master): '''special handling for MAVLink packets with a time_boot_ms field''' if m.get_type() == 'GLOBAL_POSITION_INT': # this is fix time, not boot time return msec = m.time_boot_ms if msec + 30000 < master.highest_msec: self.say('Time has wrapped') print('Time has wrapped', msec, master.highest_msec) self.status.highest_msec = msec for mm in self.mpstate.mav_master: mm.link_delayed = False mm.highest_msec = msec return # we want to detect when a link is delayed master.highest_msec = msec if msec > self.status.highest_msec: self.status.highest_msec = msec if msec < self.status.highest_msec and len(self.mpstate.mav_master) > 1 and self.mpstate.settings.checkdelay: master.link_delayed = True else: master.link_delayed = False
[ "def", "handle_msec_timestamp", "(", "self", ",", "m", ",", "master", ")", ":", "if", "m", ".", "get_type", "(", ")", "==", "'GLOBAL_POSITION_INT'", ":", "# this is fix time, not boot time", "return", "msec", "=", "m", ".", "time_boot_ms", "if", "msec", "+", "30000", "<", "master", ".", "highest_msec", ":", "self", ".", "say", "(", "'Time has wrapped'", ")", "print", "(", "'Time has wrapped'", ",", "msec", ",", "master", ".", "highest_msec", ")", "self", ".", "status", ".", "highest_msec", "=", "msec", "for", "mm", "in", "self", ".", "mpstate", ".", "mav_master", ":", "mm", ".", "link_delayed", "=", "False", "mm", ".", "highest_msec", "=", "msec", "return", "# we want to detect when a link is delayed", "master", ".", "highest_msec", "=", "msec", "if", "msec", ">", "self", ".", "status", ".", "highest_msec", ":", "self", ".", "status", ".", "highest_msec", "=", "msec", "if", "msec", "<", "self", ".", "status", ".", "highest_msec", "and", "len", "(", "self", ".", "mpstate", ".", "mav_master", ")", ">", "1", "and", "self", ".", "mpstate", ".", "settings", ".", "checkdelay", ":", "master", ".", "link_delayed", "=", "True", "else", ":", "master", ".", "link_delayed", "=", "False" ]
special handling for MAVLink packets with a time_boot_ms field
[ "special", "handling", "for", "MAVLink", "packets", "with", "a", "time_boot_ms", "field" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_link.py#L310-L334
249,425
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_link.py
LinkModule.report_altitude
def report_altitude(self, altitude): '''possibly report a new altitude''' master = self.master if getattr(self.console, 'ElevationMap', None) is not None and self.mpstate.settings.basealt != 0: lat = master.field('GLOBAL_POSITION_INT', 'lat', 0)*1.0e-7 lon = master.field('GLOBAL_POSITION_INT', 'lon', 0)*1.0e-7 alt1 = self.console.ElevationMap.GetElevation(lat, lon) if alt1 is not None: alt2 = self.mpstate.settings.basealt altitude += alt2 - alt1 self.status.altitude = altitude altitude_converted = self.height_convert_units(altitude) if (int(self.mpstate.settings.altreadout) > 0 and math.fabs(altitude_converted - self.last_altitude_announce) >= int(self.settings.altreadout)): self.last_altitude_announce = altitude_converted rounded_alt = int(self.settings.altreadout) * ((self.settings.altreadout/2 + int(altitude_converted)) / int(self.settings.altreadout)) self.say("height %u" % rounded_alt, priority='notification')
python
def report_altitude(self, altitude): '''possibly report a new altitude''' master = self.master if getattr(self.console, 'ElevationMap', None) is not None and self.mpstate.settings.basealt != 0: lat = master.field('GLOBAL_POSITION_INT', 'lat', 0)*1.0e-7 lon = master.field('GLOBAL_POSITION_INT', 'lon', 0)*1.0e-7 alt1 = self.console.ElevationMap.GetElevation(lat, lon) if alt1 is not None: alt2 = self.mpstate.settings.basealt altitude += alt2 - alt1 self.status.altitude = altitude altitude_converted = self.height_convert_units(altitude) if (int(self.mpstate.settings.altreadout) > 0 and math.fabs(altitude_converted - self.last_altitude_announce) >= int(self.settings.altreadout)): self.last_altitude_announce = altitude_converted rounded_alt = int(self.settings.altreadout) * ((self.settings.altreadout/2 + int(altitude_converted)) / int(self.settings.altreadout)) self.say("height %u" % rounded_alt, priority='notification')
[ "def", "report_altitude", "(", "self", ",", "altitude", ")", ":", "master", "=", "self", ".", "master", "if", "getattr", "(", "self", ".", "console", ",", "'ElevationMap'", ",", "None", ")", "is", "not", "None", "and", "self", ".", "mpstate", ".", "settings", ".", "basealt", "!=", "0", ":", "lat", "=", "master", ".", "field", "(", "'GLOBAL_POSITION_INT'", ",", "'lat'", ",", "0", ")", "*", "1.0e-7", "lon", "=", "master", ".", "field", "(", "'GLOBAL_POSITION_INT'", ",", "'lon'", ",", "0", ")", "*", "1.0e-7", "alt1", "=", "self", ".", "console", ".", "ElevationMap", ".", "GetElevation", "(", "lat", ",", "lon", ")", "if", "alt1", "is", "not", "None", ":", "alt2", "=", "self", ".", "mpstate", ".", "settings", ".", "basealt", "altitude", "+=", "alt2", "-", "alt1", "self", ".", "status", ".", "altitude", "=", "altitude", "altitude_converted", "=", "self", ".", "height_convert_units", "(", "altitude", ")", "if", "(", "int", "(", "self", ".", "mpstate", ".", "settings", ".", "altreadout", ")", ">", "0", "and", "math", ".", "fabs", "(", "altitude_converted", "-", "self", ".", "last_altitude_announce", ")", ">=", "int", "(", "self", ".", "settings", ".", "altreadout", ")", ")", ":", "self", ".", "last_altitude_announce", "=", "altitude_converted", "rounded_alt", "=", "int", "(", "self", ".", "settings", ".", "altreadout", ")", "*", "(", "(", "self", ".", "settings", ".", "altreadout", "/", "2", "+", "int", "(", "altitude_converted", ")", ")", "/", "int", "(", "self", ".", "settings", ".", "altreadout", ")", ")", "self", ".", "say", "(", "\"height %u\"", "%", "rounded_alt", ",", "priority", "=", "'notification'", ")" ]
possibly report a new altitude
[ "possibly", "report", "a", "new", "altitude" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_link.py#L354-L371
249,426
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_link.py
LinkModule.cmd_vehicle
def cmd_vehicle(self, args): '''handle vehicle commands''' if len(args) < 1: print("Usage: vehicle SYSID[:COMPID]") return a = args[0].split(':') self.mpstate.settings.target_system = int(a[0]) if len(a) > 1: self.mpstate.settings.target_component = int(a[1]) # change default link based on most recent HEARTBEAT best_link = 0 best_timestamp = 0 for i in range(len(self.mpstate.mav_master)): m = self.mpstate.mav_master[i] m.target_system = self.mpstate.settings.target_system m.target_component = self.mpstate.settings.target_component if 'HEARTBEAT' in m.messages: stamp = m.messages['HEARTBEAT']._timestamp src_system = m.messages['HEARTBEAT'].get_srcSystem() if stamp > best_timestamp: best_link = i best_timestamp = stamp self.mpstate.settings.link = best_link + 1 print("Set vehicle %s (link %u)" % (args[0], best_link+1))
python
def cmd_vehicle(self, args): '''handle vehicle commands''' if len(args) < 1: print("Usage: vehicle SYSID[:COMPID]") return a = args[0].split(':') self.mpstate.settings.target_system = int(a[0]) if len(a) > 1: self.mpstate.settings.target_component = int(a[1]) # change default link based on most recent HEARTBEAT best_link = 0 best_timestamp = 0 for i in range(len(self.mpstate.mav_master)): m = self.mpstate.mav_master[i] m.target_system = self.mpstate.settings.target_system m.target_component = self.mpstate.settings.target_component if 'HEARTBEAT' in m.messages: stamp = m.messages['HEARTBEAT']._timestamp src_system = m.messages['HEARTBEAT'].get_srcSystem() if stamp > best_timestamp: best_link = i best_timestamp = stamp self.mpstate.settings.link = best_link + 1 print("Set vehicle %s (link %u)" % (args[0], best_link+1))
[ "def", "cmd_vehicle", "(", "self", ",", "args", ")", ":", "if", "len", "(", "args", ")", "<", "1", ":", "print", "(", "\"Usage: vehicle SYSID[:COMPID]\"", ")", "return", "a", "=", "args", "[", "0", "]", ".", "split", "(", "':'", ")", "self", ".", "mpstate", ".", "settings", ".", "target_system", "=", "int", "(", "a", "[", "0", "]", ")", "if", "len", "(", "a", ")", ">", "1", ":", "self", ".", "mpstate", ".", "settings", ".", "target_component", "=", "int", "(", "a", "[", "1", "]", ")", "# change default link based on most recent HEARTBEAT", "best_link", "=", "0", "best_timestamp", "=", "0", "for", "i", "in", "range", "(", "len", "(", "self", ".", "mpstate", ".", "mav_master", ")", ")", ":", "m", "=", "self", ".", "mpstate", ".", "mav_master", "[", "i", "]", "m", ".", "target_system", "=", "self", ".", "mpstate", ".", "settings", ".", "target_system", "m", ".", "target_component", "=", "self", ".", "mpstate", ".", "settings", ".", "target_component", "if", "'HEARTBEAT'", "in", "m", ".", "messages", ":", "stamp", "=", "m", ".", "messages", "[", "'HEARTBEAT'", "]", ".", "_timestamp", "src_system", "=", "m", ".", "messages", "[", "'HEARTBEAT'", "]", ".", "get_srcSystem", "(", ")", "if", "stamp", ">", "best_timestamp", ":", "best_link", "=", "i", "best_timestamp", "=", "stamp", "self", ".", "mpstate", ".", "settings", ".", "link", "=", "best_link", "+", "1", "print", "(", "\"Set vehicle %s (link %u)\"", "%", "(", "args", "[", "0", "]", ",", "best_link", "+", "1", ")", ")" ]
handle vehicle commands
[ "handle", "vehicle", "commands" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_link.py#L635-L659
249,427
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_devop.py
DeviceOpModule.devop_read
def devop_read(self, args, bustype): '''read from device''' if len(args) < 5: print("Usage: devop read <spi|i2c> name bus address regstart count") return name = args[0] bus = int(args[1],base=0) address = int(args[2],base=0) reg = int(args[3],base=0) count = int(args[4],base=0) self.master.mav.device_op_read_send(self.target_system, self.target_component, self.request_id, bustype, bus, address, name, reg, count) self.request_id += 1
python
def devop_read(self, args, bustype): '''read from device''' if len(args) < 5: print("Usage: devop read <spi|i2c> name bus address regstart count") return name = args[0] bus = int(args[1],base=0) address = int(args[2],base=0) reg = int(args[3],base=0) count = int(args[4],base=0) self.master.mav.device_op_read_send(self.target_system, self.target_component, self.request_id, bustype, bus, address, name, reg, count) self.request_id += 1
[ "def", "devop_read", "(", "self", ",", "args", ",", "bustype", ")", ":", "if", "len", "(", "args", ")", "<", "5", ":", "print", "(", "\"Usage: devop read <spi|i2c> name bus address regstart count\"", ")", "return", "name", "=", "args", "[", "0", "]", "bus", "=", "int", "(", "args", "[", "1", "]", ",", "base", "=", "0", ")", "address", "=", "int", "(", "args", "[", "2", "]", ",", "base", "=", "0", ")", "reg", "=", "int", "(", "args", "[", "3", "]", ",", "base", "=", "0", ")", "count", "=", "int", "(", "args", "[", "4", "]", ",", "base", "=", "0", ")", "self", ".", "master", ".", "mav", ".", "device_op_read_send", "(", "self", ".", "target_system", ",", "self", ".", "target_component", ",", "self", ".", "request_id", ",", "bustype", ",", "bus", ",", "address", ",", "name", ",", "reg", ",", "count", ")", "self", ".", "request_id", "+=", "1" ]
read from device
[ "read", "from", "device" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_devop.py#L37-L56
249,428
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_devop.py
DeviceOpModule.devop_write
def devop_write(self, args, bustype): '''write to a device''' usage = "Usage: devop write <spi|i2c> name bus address regstart count <bytes>" if len(args) < 5: print(usage) return name = args[0] bus = int(args[1],base=0) address = int(args[2],base=0) reg = int(args[3],base=0) count = int(args[4],base=0) args = args[5:] if len(args) < count: print(usage) return bytes = [0]*128 for i in range(count): bytes[i] = int(args[i],base=0) self.master.mav.device_op_write_send(self.target_system, self.target_component, self.request_id, bustype, bus, address, name, reg, count, bytes) self.request_id += 1
python
def devop_write(self, args, bustype): '''write to a device''' usage = "Usage: devop write <spi|i2c> name bus address regstart count <bytes>" if len(args) < 5: print(usage) return name = args[0] bus = int(args[1],base=0) address = int(args[2],base=0) reg = int(args[3],base=0) count = int(args[4],base=0) args = args[5:] if len(args) < count: print(usage) return bytes = [0]*128 for i in range(count): bytes[i] = int(args[i],base=0) self.master.mav.device_op_write_send(self.target_system, self.target_component, self.request_id, bustype, bus, address, name, reg, count, bytes) self.request_id += 1
[ "def", "devop_write", "(", "self", ",", "args", ",", "bustype", ")", ":", "usage", "=", "\"Usage: devop write <spi|i2c> name bus address regstart count <bytes>\"", "if", "len", "(", "args", ")", "<", "5", ":", "print", "(", "usage", ")", "return", "name", "=", "args", "[", "0", "]", "bus", "=", "int", "(", "args", "[", "1", "]", ",", "base", "=", "0", ")", "address", "=", "int", "(", "args", "[", "2", "]", ",", "base", "=", "0", ")", "reg", "=", "int", "(", "args", "[", "3", "]", ",", "base", "=", "0", ")", "count", "=", "int", "(", "args", "[", "4", "]", ",", "base", "=", "0", ")", "args", "=", "args", "[", "5", ":", "]", "if", "len", "(", "args", ")", "<", "count", ":", "print", "(", "usage", ")", "return", "bytes", "=", "[", "0", "]", "*", "128", "for", "i", "in", "range", "(", "count", ")", ":", "bytes", "[", "i", "]", "=", "int", "(", "args", "[", "i", "]", ",", "base", "=", "0", ")", "self", ".", "master", ".", "mav", ".", "device_op_write_send", "(", "self", ".", "target_system", ",", "self", ".", "target_component", ",", "self", ".", "request_id", ",", "bustype", ",", "bus", ",", "address", ",", "name", ",", "reg", ",", "count", ",", "bytes", ")", "self", ".", "request_id", "+=", "1" ]
write to a device
[ "write", "to", "a", "device" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_devop.py#L58-L86
249,429
ArduPilot/MAVProxy
MAVProxy/modules/lib/ANUGA/geo_reference.py
Geo_reference.get_absolute
def get_absolute(self, points): """Given a set of points geo referenced to this instance, return the points as absolute values. """ # remember if we got a list is_list = isinstance(points, list) points = ensure_numeric(points, num.float) if len(points.shape) == 1: # One point has been passed msg = 'Single point must have two elements' if not len(points) == 2: raise ValueError(msg) msg = 'Input must be an N x 2 array or list of (x,y) values. ' msg += 'I got an %d x %d array' %points.shape if not points.shape[1] == 2: raise ValueError(msg) # Add geo ref to points if not self.is_absolute(): points = copy.copy(points) # Don't destroy input points[:,0] += self.xllcorner points[:,1] += self.yllcorner if is_list: points = points.tolist() return points
python
def get_absolute(self, points): # remember if we got a list is_list = isinstance(points, list) points = ensure_numeric(points, num.float) if len(points.shape) == 1: # One point has been passed msg = 'Single point must have two elements' if not len(points) == 2: raise ValueError(msg) msg = 'Input must be an N x 2 array or list of (x,y) values. ' msg += 'I got an %d x %d array' %points.shape if not points.shape[1] == 2: raise ValueError(msg) # Add geo ref to points if not self.is_absolute(): points = copy.copy(points) # Don't destroy input points[:,0] += self.xllcorner points[:,1] += self.yllcorner if is_list: points = points.tolist() return points
[ "def", "get_absolute", "(", "self", ",", "points", ")", ":", "# remember if we got a list", "is_list", "=", "isinstance", "(", "points", ",", "list", ")", "points", "=", "ensure_numeric", "(", "points", ",", "num", ".", "float", ")", "if", "len", "(", "points", ".", "shape", ")", "==", "1", ":", "# One point has been passed", "msg", "=", "'Single point must have two elements'", "if", "not", "len", "(", "points", ")", "==", "2", ":", "raise", "ValueError", "(", "msg", ")", "msg", "=", "'Input must be an N x 2 array or list of (x,y) values. '", "msg", "+=", "'I got an %d x %d array'", "%", "points", ".", "shape", "if", "not", "points", ".", "shape", "[", "1", "]", "==", "2", ":", "raise", "ValueError", "(", "msg", ")", "# Add geo ref to points", "if", "not", "self", ".", "is_absolute", "(", ")", ":", "points", "=", "copy", ".", "copy", "(", "points", ")", "# Don't destroy input", "points", "[", ":", ",", "0", "]", "+=", "self", ".", "xllcorner", "points", "[", ":", ",", "1", "]", "+=", "self", ".", "yllcorner", "if", "is_list", ":", "points", "=", "points", ".", "tolist", "(", ")", "return", "points" ]
Given a set of points geo referenced to this instance, return the points as absolute values.
[ "Given", "a", "set", "of", "points", "geo", "referenced", "to", "this", "instance", "return", "the", "points", "as", "absolute", "values", "." ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/ANUGA/geo_reference.py#L295-L327
249,430
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_cameraview.py
CameraViewModule.cmd_cameraview
def cmd_cameraview(self, args): '''camera view commands''' state = self if args and args[0] == 'set': if len(args) < 3: state.view_settings.show_all() else: state.view_settings.set(args[1], args[2]) state.update_col() else: print('usage: cameraview set')
python
def cmd_cameraview(self, args): '''camera view commands''' state = self if args and args[0] == 'set': if len(args) < 3: state.view_settings.show_all() else: state.view_settings.set(args[1], args[2]) state.update_col() else: print('usage: cameraview set')
[ "def", "cmd_cameraview", "(", "self", ",", "args", ")", ":", "state", "=", "self", "if", "args", "and", "args", "[", "0", "]", "==", "'set'", ":", "if", "len", "(", "args", ")", "<", "3", ":", "state", ".", "view_settings", ".", "show_all", "(", ")", "else", ":", "state", ".", "view_settings", ".", "set", "(", "args", "[", "1", "]", ",", "args", "[", "2", "]", ")", "state", ".", "update_col", "(", ")", "else", ":", "print", "(", "'usage: cameraview set'", ")" ]
camera view commands
[ "camera", "view", "commands" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_cameraview.py#L50-L60
249,431
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_cameraview.py
CameraViewModule.scale_rc
def scale_rc(self, servo, min, max, param): '''scale a PWM value''' # default to servo range of 1000 to 2000 min_pwm = self.get_mav_param('%s_MIN' % param, 0) max_pwm = self.get_mav_param('%s_MAX' % param, 0) if min_pwm == 0 or max_pwm == 0: return 0 if max_pwm == min_pwm: p = 0.0 else: p = (servo-min_pwm) / float(max_pwm-min_pwm) v = min + p*(max-min) if v < min: v = min if v > max: v = max return v
python
def scale_rc(self, servo, min, max, param): '''scale a PWM value''' # default to servo range of 1000 to 2000 min_pwm = self.get_mav_param('%s_MIN' % param, 0) max_pwm = self.get_mav_param('%s_MAX' % param, 0) if min_pwm == 0 or max_pwm == 0: return 0 if max_pwm == min_pwm: p = 0.0 else: p = (servo-min_pwm) / float(max_pwm-min_pwm) v = min + p*(max-min) if v < min: v = min if v > max: v = max return v
[ "def", "scale_rc", "(", "self", ",", "servo", ",", "min", ",", "max", ",", "param", ")", ":", "# default to servo range of 1000 to 2000", "min_pwm", "=", "self", ".", "get_mav_param", "(", "'%s_MIN'", "%", "param", ",", "0", ")", "max_pwm", "=", "self", ".", "get_mav_param", "(", "'%s_MAX'", "%", "param", ",", "0", ")", "if", "min_pwm", "==", "0", "or", "max_pwm", "==", "0", ":", "return", "0", "if", "max_pwm", "==", "min_pwm", ":", "p", "=", "0.0", "else", ":", "p", "=", "(", "servo", "-", "min_pwm", ")", "/", "float", "(", "max_pwm", "-", "min_pwm", ")", "v", "=", "min", "+", "p", "*", "(", "max", "-", "min", ")", "if", "v", "<", "min", ":", "v", "=", "min", "if", "v", ">", "max", ":", "v", "=", "max", "return", "v" ]
scale a PWM value
[ "scale", "a", "PWM", "value" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_cameraview.py#L66-L82
249,432
ArduPilot/MAVProxy
MAVProxy/modules/lib/MacOS/backend_wx.py
raise_msg_to_str
def raise_msg_to_str(msg): """msg is a return arg from a raise. Join with new lines""" if not is_string_like(msg): msg = '\n'.join(map(str, msg)) return msg
python
def raise_msg_to_str(msg): if not is_string_like(msg): msg = '\n'.join(map(str, msg)) return msg
[ "def", "raise_msg_to_str", "(", "msg", ")", ":", "if", "not", "is_string_like", "(", "msg", ")", ":", "msg", "=", "'\\n'", ".", "join", "(", "map", "(", "str", ",", "msg", ")", ")", "return", "msg" ]
msg is a return arg from a raise. Join with new lines
[ "msg", "is", "a", "return", "arg", "from", "a", "raise", ".", "Join", "with", "new", "lines" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/MacOS/backend_wx.py#L162-L166
249,433
ArduPilot/MAVProxy
MAVProxy/modules/lib/MacOS/backend_wx.py
_create_wx_app
def _create_wx_app(): """ Creates a wx.App instance if it has not been created sofar. """ wxapp = wx.GetApp() if wxapp is None: wxapp = wx.App(False) wxapp.SetExitOnFrameDelete(True) # retain a reference to the app object so it does not get garbage # collected and cause segmentation faults _create_wx_app.theWxApp = wxapp
python
def _create_wx_app(): wxapp = wx.GetApp() if wxapp is None: wxapp = wx.App(False) wxapp.SetExitOnFrameDelete(True) # retain a reference to the app object so it does not get garbage # collected and cause segmentation faults _create_wx_app.theWxApp = wxapp
[ "def", "_create_wx_app", "(", ")", ":", "wxapp", "=", "wx", ".", "GetApp", "(", ")", "if", "wxapp", "is", "None", ":", "wxapp", "=", "wx", ".", "App", "(", "False", ")", "wxapp", ".", "SetExitOnFrameDelete", "(", "True", ")", "# retain a reference to the app object so it does not get garbage", "# collected and cause segmentation faults", "_create_wx_app", ".", "theWxApp", "=", "wxapp" ]
Creates a wx.App instance if it has not been created sofar.
[ "Creates", "a", "wx", ".", "App", "instance", "if", "it", "has", "not", "been", "created", "sofar", "." ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/MacOS/backend_wx.py#L1241-L1251
249,434
ArduPilot/MAVProxy
MAVProxy/modules/lib/MacOS/backend_wx.py
draw_if_interactive
def draw_if_interactive(): """ This should be overriden in a windowing environment if drawing should be done in interactive python mode """ DEBUG_MSG("draw_if_interactive()", 1, None) if matplotlib.is_interactive(): figManager = Gcf.get_active() if figManager is not None: figManager.canvas.draw_idle()
python
def draw_if_interactive(): DEBUG_MSG("draw_if_interactive()", 1, None) if matplotlib.is_interactive(): figManager = Gcf.get_active() if figManager is not None: figManager.canvas.draw_idle()
[ "def", "draw_if_interactive", "(", ")", ":", "DEBUG_MSG", "(", "\"draw_if_interactive()\"", ",", "1", ",", "None", ")", "if", "matplotlib", ".", "is_interactive", "(", ")", ":", "figManager", "=", "Gcf", ".", "get_active", "(", ")", "if", "figManager", "is", "not", "None", ":", "figManager", ".", "canvas", ".", "draw_idle", "(", ")" ]
This should be overriden in a windowing environment if drawing should be done in interactive python mode
[ "This", "should", "be", "overriden", "in", "a", "windowing", "environment", "if", "drawing", "should", "be", "done", "in", "interactive", "python", "mode" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/MacOS/backend_wx.py#L1254-L1265
249,435
ArduPilot/MAVProxy
MAVProxy/modules/lib/MacOS/backend_wx.py
RendererWx.new_gc
def new_gc(self): """ Return an instance of a GraphicsContextWx, and sets the current gc copy """ DEBUG_MSG('new_gc()', 2, self) self.gc = GraphicsContextWx(self.bitmap, self) self.gc.select() self.gc.unselect() return self.gc
python
def new_gc(self): DEBUG_MSG('new_gc()', 2, self) self.gc = GraphicsContextWx(self.bitmap, self) self.gc.select() self.gc.unselect() return self.gc
[ "def", "new_gc", "(", "self", ")", ":", "DEBUG_MSG", "(", "'new_gc()'", ",", "2", ",", "self", ")", "self", ".", "gc", "=", "GraphicsContextWx", "(", "self", ".", "bitmap", ",", "self", ")", "self", ".", "gc", ".", "select", "(", ")", "self", ".", "gc", ".", "unselect", "(", ")", "return", "self", ".", "gc" ]
Return an instance of a GraphicsContextWx, and sets the current gc copy
[ "Return", "an", "instance", "of", "a", "GraphicsContextWx", "and", "sets", "the", "current", "gc", "copy" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/MacOS/backend_wx.py#L392-L400
249,436
ArduPilot/MAVProxy
MAVProxy/modules/lib/MacOS/backend_wx.py
RendererWx.get_wx_font
def get_wx_font(self, s, prop): """ Return a wx font. Cache instances in a font dictionary for efficiency """ DEBUG_MSG("get_wx_font()", 1, self) key = hash(prop) fontprop = prop fontname = fontprop.get_name() font = self.fontd.get(key) if font is not None: return font # Allow use of platform independent and dependent font names wxFontname = self.fontnames.get(fontname, wx.ROMAN) wxFacename = '' # Empty => wxPython chooses based on wx_fontname # Font colour is determined by the active wx.Pen # TODO: It may be wise to cache font information size = self.points_to_pixels(fontprop.get_size_in_points()) font =wx.Font(int(size+0.5), # Size wxFontname, # 'Generic' name self.fontangles[fontprop.get_style()], # Angle self.fontweights[fontprop.get_weight()], # Weight False, # Underline wxFacename) # Platform font name # cache the font and gc and return it self.fontd[key] = font return font
python
def get_wx_font(self, s, prop): DEBUG_MSG("get_wx_font()", 1, self) key = hash(prop) fontprop = prop fontname = fontprop.get_name() font = self.fontd.get(key) if font is not None: return font # Allow use of platform independent and dependent font names wxFontname = self.fontnames.get(fontname, wx.ROMAN) wxFacename = '' # Empty => wxPython chooses based on wx_fontname # Font colour is determined by the active wx.Pen # TODO: It may be wise to cache font information size = self.points_to_pixels(fontprop.get_size_in_points()) font =wx.Font(int(size+0.5), # Size wxFontname, # 'Generic' name self.fontangles[fontprop.get_style()], # Angle self.fontweights[fontprop.get_weight()], # Weight False, # Underline wxFacename) # Platform font name # cache the font and gc and return it self.fontd[key] = font return font
[ "def", "get_wx_font", "(", "self", ",", "s", ",", "prop", ")", ":", "DEBUG_MSG", "(", "\"get_wx_font()\"", ",", "1", ",", "self", ")", "key", "=", "hash", "(", "prop", ")", "fontprop", "=", "prop", "fontname", "=", "fontprop", ".", "get_name", "(", ")", "font", "=", "self", ".", "fontd", ".", "get", "(", "key", ")", "if", "font", "is", "not", "None", ":", "return", "font", "# Allow use of platform independent and dependent font names", "wxFontname", "=", "self", ".", "fontnames", ".", "get", "(", "fontname", ",", "wx", ".", "ROMAN", ")", "wxFacename", "=", "''", "# Empty => wxPython chooses based on wx_fontname", "# Font colour is determined by the active wx.Pen", "# TODO: It may be wise to cache font information", "size", "=", "self", ".", "points_to_pixels", "(", "fontprop", ".", "get_size_in_points", "(", ")", ")", "font", "=", "wx", ".", "Font", "(", "int", "(", "size", "+", "0.5", ")", ",", "# Size", "wxFontname", ",", "# 'Generic' name", "self", ".", "fontangles", "[", "fontprop", ".", "get_style", "(", ")", "]", ",", "# Angle", "self", ".", "fontweights", "[", "fontprop", ".", "get_weight", "(", ")", "]", ",", "# Weight", "False", ",", "# Underline", "wxFacename", ")", "# Platform font name", "# cache the font and gc and return it", "self", ".", "fontd", "[", "key", "]", "=", "font", "return", "font" ]
Return a wx font. Cache instances in a font dictionary for efficiency
[ "Return", "a", "wx", "font", ".", "Cache", "instances", "in", "a", "font", "dictionary", "for", "efficiency" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/MacOS/backend_wx.py#L411-L446
249,437
ArduPilot/MAVProxy
MAVProxy/modules/lib/MacOS/backend_wx.py
GraphicsContextWx.select
def select(self): """ Select the current bitmap into this wxDC instance """ if sys.platform=='win32': self.dc.SelectObject(self.bitmap) self.IsSelected = True
python
def select(self): if sys.platform=='win32': self.dc.SelectObject(self.bitmap) self.IsSelected = True
[ "def", "select", "(", "self", ")", ":", "if", "sys", ".", "platform", "==", "'win32'", ":", "self", ".", "dc", ".", "SelectObject", "(", "self", ".", "bitmap", ")", "self", ".", "IsSelected", "=", "True" ]
Select the current bitmap into this wxDC instance
[ "Select", "the", "current", "bitmap", "into", "this", "wxDC", "instance" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/MacOS/backend_wx.py#L505-L512
249,438
ArduPilot/MAVProxy
MAVProxy/modules/lib/MacOS/backend_wx.py
GraphicsContextWx.unselect
def unselect(self): """ Select a Null bitmasp into this wxDC instance """ if sys.platform=='win32': self.dc.SelectObject(wx.NullBitmap) self.IsSelected = False
python
def unselect(self): if sys.platform=='win32': self.dc.SelectObject(wx.NullBitmap) self.IsSelected = False
[ "def", "unselect", "(", "self", ")", ":", "if", "sys", ".", "platform", "==", "'win32'", ":", "self", ".", "dc", ".", "SelectObject", "(", "wx", ".", "NullBitmap", ")", "self", ".", "IsSelected", "=", "False" ]
Select a Null bitmasp into this wxDC instance
[ "Select", "a", "Null", "bitmasp", "into", "this", "wxDC", "instance" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/MacOS/backend_wx.py#L514-L520
249,439
ArduPilot/MAVProxy
MAVProxy/modules/lib/MacOS/backend_wx.py
GraphicsContextWx.set_linewidth
def set_linewidth(self, w): """ Set the line width. """ DEBUG_MSG("set_linewidth()", 1, self) self.select() if w>0 and w<1: w = 1 GraphicsContextBase.set_linewidth(self, w) lw = int(self.renderer.points_to_pixels(self._linewidth)) if lw==0: lw = 1 self._pen.SetWidth(lw) self.gfx_ctx.SetPen(self._pen) self.unselect()
python
def set_linewidth(self, w): DEBUG_MSG("set_linewidth()", 1, self) self.select() if w>0 and w<1: w = 1 GraphicsContextBase.set_linewidth(self, w) lw = int(self.renderer.points_to_pixels(self._linewidth)) if lw==0: lw = 1 self._pen.SetWidth(lw) self.gfx_ctx.SetPen(self._pen) self.unselect()
[ "def", "set_linewidth", "(", "self", ",", "w", ")", ":", "DEBUG_MSG", "(", "\"set_linewidth()\"", ",", "1", ",", "self", ")", "self", ".", "select", "(", ")", "if", "w", ">", "0", "and", "w", "<", "1", ":", "w", "=", "1", "GraphicsContextBase", ".", "set_linewidth", "(", "self", ",", "w", ")", "lw", "=", "int", "(", "self", ".", "renderer", ".", "points_to_pixels", "(", "self", ".", "_linewidth", ")", ")", "if", "lw", "==", "0", ":", "lw", "=", "1", "self", ".", "_pen", ".", "SetWidth", "(", "lw", ")", "self", ".", "gfx_ctx", ".", "SetPen", "(", "self", ".", "_pen", ")", "self", ".", "unselect", "(", ")" ]
Set the line width.
[ "Set", "the", "line", "width", "." ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/MacOS/backend_wx.py#L554-L566
249,440
ArduPilot/MAVProxy
MAVProxy/modules/lib/MacOS/backend_wx.py
GraphicsContextWx.set_linestyle
def set_linestyle(self, ls): """ Set the line style to be one of """ DEBUG_MSG("set_linestyle()", 1, self) self.select() GraphicsContextBase.set_linestyle(self, ls) try: self._style = GraphicsContextWx._dashd_wx[ls] except KeyError: self._style = wx.LONG_DASH# Style not used elsewhere... # On MS Windows platform, only line width of 1 allowed for dash lines if wx.Platform == '__WXMSW__': self.set_linewidth(1) self._pen.SetStyle(self._style) self.gfx_ctx.SetPen(self._pen) self.unselect()
python
def set_linestyle(self, ls): DEBUG_MSG("set_linestyle()", 1, self) self.select() GraphicsContextBase.set_linestyle(self, ls) try: self._style = GraphicsContextWx._dashd_wx[ls] except KeyError: self._style = wx.LONG_DASH# Style not used elsewhere... # On MS Windows platform, only line width of 1 allowed for dash lines if wx.Platform == '__WXMSW__': self.set_linewidth(1) self._pen.SetStyle(self._style) self.gfx_ctx.SetPen(self._pen) self.unselect()
[ "def", "set_linestyle", "(", "self", ",", "ls", ")", ":", "DEBUG_MSG", "(", "\"set_linestyle()\"", ",", "1", ",", "self", ")", "self", ".", "select", "(", ")", "GraphicsContextBase", ".", "set_linestyle", "(", "self", ",", "ls", ")", "try", ":", "self", ".", "_style", "=", "GraphicsContextWx", ".", "_dashd_wx", "[", "ls", "]", "except", "KeyError", ":", "self", ".", "_style", "=", "wx", ".", "LONG_DASH", "# Style not used elsewhere...", "# On MS Windows platform, only line width of 1 allowed for dash lines", "if", "wx", ".", "Platform", "==", "'__WXMSW__'", ":", "self", ".", "set_linewidth", "(", "1", ")", "self", ".", "_pen", ".", "SetStyle", "(", "self", ".", "_style", ")", "self", ".", "gfx_ctx", ".", "SetPen", "(", "self", ".", "_pen", ")", "self", ".", "unselect", "(", ")" ]
Set the line style to be one of
[ "Set", "the", "line", "style", "to", "be", "one", "of" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/MacOS/backend_wx.py#L590-L608
249,441
ArduPilot/MAVProxy
MAVProxy/modules/lib/MacOS/backend_wx.py
GraphicsContextWx.get_wxcolour
def get_wxcolour(self, color): """return a wx.Colour from RGB format""" DEBUG_MSG("get_wx_color()", 1, self) if len(color) == 3: r, g, b = color r *= 255 g *= 255 b *= 255 return wx.Colour(red=int(r), green=int(g), blue=int(b)) else: r, g, b, a = color r *= 255 g *= 255 b *= 255 a *= 255 return wx.Colour(red=int(r), green=int(g), blue=int(b), alpha=int(a))
python
def get_wxcolour(self, color): DEBUG_MSG("get_wx_color()", 1, self) if len(color) == 3: r, g, b = color r *= 255 g *= 255 b *= 255 return wx.Colour(red=int(r), green=int(g), blue=int(b)) else: r, g, b, a = color r *= 255 g *= 255 b *= 255 a *= 255 return wx.Colour(red=int(r), green=int(g), blue=int(b), alpha=int(a))
[ "def", "get_wxcolour", "(", "self", ",", "color", ")", ":", "DEBUG_MSG", "(", "\"get_wx_color()\"", ",", "1", ",", "self", ")", "if", "len", "(", "color", ")", "==", "3", ":", "r", ",", "g", ",", "b", "=", "color", "r", "*=", "255", "g", "*=", "255", "b", "*=", "255", "return", "wx", ".", "Colour", "(", "red", "=", "int", "(", "r", ")", ",", "green", "=", "int", "(", "g", ")", ",", "blue", "=", "int", "(", "b", ")", ")", "else", ":", "r", ",", "g", ",", "b", ",", "a", "=", "color", "r", "*=", "255", "g", "*=", "255", "b", "*=", "255", "a", "*=", "255", "return", "wx", ".", "Colour", "(", "red", "=", "int", "(", "r", ")", ",", "green", "=", "int", "(", "g", ")", ",", "blue", "=", "int", "(", "b", ")", ",", "alpha", "=", "int", "(", "a", ")", ")" ]
return a wx.Colour from RGB format
[ "return", "a", "wx", ".", "Colour", "from", "RGB", "format" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/MacOS/backend_wx.py#L610-L625
249,442
ArduPilot/MAVProxy
MAVProxy/modules/lib/MacOS/backend_wx.py
FigureCanvasWx.Copy_to_Clipboard
def Copy_to_Clipboard(self, event=None): "copy bitmap of canvas to system clipboard" bmp_obj = wx.BitmapDataObject() bmp_obj.SetBitmap(self.bitmap) if not wx.TheClipboard.IsOpened(): open_success = wx.TheClipboard.Open() if open_success: wx.TheClipboard.SetData(bmp_obj) wx.TheClipboard.Close() wx.TheClipboard.Flush()
python
def Copy_to_Clipboard(self, event=None): "copy bitmap of canvas to system clipboard" bmp_obj = wx.BitmapDataObject() bmp_obj.SetBitmap(self.bitmap) if not wx.TheClipboard.IsOpened(): open_success = wx.TheClipboard.Open() if open_success: wx.TheClipboard.SetData(bmp_obj) wx.TheClipboard.Close() wx.TheClipboard.Flush()
[ "def", "Copy_to_Clipboard", "(", "self", ",", "event", "=", "None", ")", ":", "bmp_obj", "=", "wx", ".", "BitmapDataObject", "(", ")", "bmp_obj", ".", "SetBitmap", "(", "self", ".", "bitmap", ")", "if", "not", "wx", ".", "TheClipboard", ".", "IsOpened", "(", ")", ":", "open_success", "=", "wx", ".", "TheClipboard", ".", "Open", "(", ")", "if", "open_success", ":", "wx", ".", "TheClipboard", ".", "SetData", "(", "bmp_obj", ")", "wx", ".", "TheClipboard", ".", "Close", "(", ")", "wx", ".", "TheClipboard", ".", "Flush", "(", ")" ]
copy bitmap of canvas to system clipboard
[ "copy", "bitmap", "of", "canvas", "to", "system", "clipboard" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/MacOS/backend_wx.py#L776-L786
249,443
ArduPilot/MAVProxy
MAVProxy/modules/lib/MacOS/backend_wx.py
FigureCanvasWx.draw_idle
def draw_idle(self): """ Delay rendering until the GUI is idle. """ DEBUG_MSG("draw_idle()", 1, self) self._isDrawn = False # Force redraw # Create a timer for handling draw_idle requests # If there are events pending when the timer is # complete, reset the timer and continue. The # alternative approach, binding to wx.EVT_IDLE, # doesn't behave as nicely. if hasattr(self,'_idletimer'): self._idletimer.Restart(IDLE_DELAY) else: self._idletimer = wx.FutureCall(IDLE_DELAY,self._onDrawIdle)
python
def draw_idle(self): DEBUG_MSG("draw_idle()", 1, self) self._isDrawn = False # Force redraw # Create a timer for handling draw_idle requests # If there are events pending when the timer is # complete, reset the timer and continue. The # alternative approach, binding to wx.EVT_IDLE, # doesn't behave as nicely. if hasattr(self,'_idletimer'): self._idletimer.Restart(IDLE_DELAY) else: self._idletimer = wx.FutureCall(IDLE_DELAY,self._onDrawIdle)
[ "def", "draw_idle", "(", "self", ")", ":", "DEBUG_MSG", "(", "\"draw_idle()\"", ",", "1", ",", "self", ")", "self", ".", "_isDrawn", "=", "False", "# Force redraw", "# Create a timer for handling draw_idle requests", "# If there are events pending when the timer is", "# complete, reset the timer and continue. The", "# alternative approach, binding to wx.EVT_IDLE,", "# doesn't behave as nicely.", "if", "hasattr", "(", "self", ",", "'_idletimer'", ")", ":", "self", ".", "_idletimer", ".", "Restart", "(", "IDLE_DELAY", ")", "else", ":", "self", ".", "_idletimer", "=", "wx", ".", "FutureCall", "(", "IDLE_DELAY", ",", "self", ".", "_onDrawIdle", ")" ]
Delay rendering until the GUI is idle.
[ "Delay", "rendering", "until", "the", "GUI", "is", "idle", "." ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/MacOS/backend_wx.py#L788-L802
249,444
ArduPilot/MAVProxy
MAVProxy/modules/lib/MacOS/backend_wx.py
FigureCanvasWx.draw
def draw(self, drawDC=None): """ Render the figure using RendererWx instance renderer, or using a previously defined renderer if none is specified. """ DEBUG_MSG("draw()", 1, self) self.renderer = RendererWx(self.bitmap, self.figure.dpi) self.figure.draw(self.renderer) self._isDrawn = True self.gui_repaint(drawDC=drawDC)
python
def draw(self, drawDC=None): DEBUG_MSG("draw()", 1, self) self.renderer = RendererWx(self.bitmap, self.figure.dpi) self.figure.draw(self.renderer) self._isDrawn = True self.gui_repaint(drawDC=drawDC)
[ "def", "draw", "(", "self", ",", "drawDC", "=", "None", ")", ":", "DEBUG_MSG", "(", "\"draw()\"", ",", "1", ",", "self", ")", "self", ".", "renderer", "=", "RendererWx", "(", "self", ".", "bitmap", ",", "self", ".", "figure", ".", "dpi", ")", "self", ".", "figure", ".", "draw", "(", "self", ".", "renderer", ")", "self", ".", "_isDrawn", "=", "True", "self", ".", "gui_repaint", "(", "drawDC", "=", "drawDC", ")" ]
Render the figure using RendererWx instance renderer, or using a previously defined renderer if none is specified.
[ "Render", "the", "figure", "using", "RendererWx", "instance", "renderer", "or", "using", "a", "previously", "defined", "renderer", "if", "none", "is", "specified", "." ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/MacOS/backend_wx.py#L816-L825
249,445
ArduPilot/MAVProxy
MAVProxy/modules/lib/MacOS/backend_wx.py
FigureCanvasWx.start_event_loop
def start_event_loop(self, timeout=0): """ Start an event loop. This is used to start a blocking event loop so that interactive functions, such as ginput and waitforbuttonpress, can wait for events. This should not be confused with the main GUI event loop, which is always running and has nothing to do with this. Call signature:: start_event_loop(self,timeout=0) This call blocks until a callback function triggers stop_event_loop() or *timeout* is reached. If *timeout* is <=0, never timeout. Raises RuntimeError if event loop is already running. """ if hasattr(self, '_event_loop'): raise RuntimeError("Event loop already running") id = wx.NewId() timer = wx.Timer(self, id=id) if timeout > 0: timer.Start(timeout*1000, oneShot=True) bind(self, wx.EVT_TIMER, self.stop_event_loop, id=id) # Event loop handler for start/stop event loop self._event_loop = wx.EventLoop() self._event_loop.Run() timer.Stop()
python
def start_event_loop(self, timeout=0): if hasattr(self, '_event_loop'): raise RuntimeError("Event loop already running") id = wx.NewId() timer = wx.Timer(self, id=id) if timeout > 0: timer.Start(timeout*1000, oneShot=True) bind(self, wx.EVT_TIMER, self.stop_event_loop, id=id) # Event loop handler for start/stop event loop self._event_loop = wx.EventLoop() self._event_loop.Run() timer.Stop()
[ "def", "start_event_loop", "(", "self", ",", "timeout", "=", "0", ")", ":", "if", "hasattr", "(", "self", ",", "'_event_loop'", ")", ":", "raise", "RuntimeError", "(", "\"Event loop already running\"", ")", "id", "=", "wx", ".", "NewId", "(", ")", "timer", "=", "wx", ".", "Timer", "(", "self", ",", "id", "=", "id", ")", "if", "timeout", ">", "0", ":", "timer", ".", "Start", "(", "timeout", "*", "1000", ",", "oneShot", "=", "True", ")", "bind", "(", "self", ",", "wx", ".", "EVT_TIMER", ",", "self", ".", "stop_event_loop", ",", "id", "=", "id", ")", "# Event loop handler for start/stop event loop", "self", ".", "_event_loop", "=", "wx", ".", "EventLoop", "(", ")", "self", ".", "_event_loop", ".", "Run", "(", ")", "timer", ".", "Stop", "(", ")" ]
Start an event loop. This is used to start a blocking event loop so that interactive functions, such as ginput and waitforbuttonpress, can wait for events. This should not be confused with the main GUI event loop, which is always running and has nothing to do with this. Call signature:: start_event_loop(self,timeout=0) This call blocks until a callback function triggers stop_event_loop() or *timeout* is reached. If *timeout* is <=0, never timeout. Raises RuntimeError if event loop is already running.
[ "Start", "an", "event", "loop", ".", "This", "is", "used", "to", "start", "a", "blocking", "event", "loop", "so", "that", "interactive", "functions", "such", "as", "ginput", "and", "waitforbuttonpress", "can", "wait", "for", "events", ".", "This", "should", "not", "be", "confused", "with", "the", "main", "GUI", "event", "loop", "which", "is", "always", "running", "and", "has", "nothing", "to", "do", "with", "this", "." ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/MacOS/backend_wx.py#L846-L875
249,446
ArduPilot/MAVProxy
MAVProxy/modules/lib/MacOS/backend_wx.py
FigureCanvasWx.stop_event_loop
def stop_event_loop(self, event=None): """ Stop an event loop. This is used to stop a blocking event loop so that interactive functions, such as ginput and waitforbuttonpress, can wait for events. Call signature:: stop_event_loop_default(self) """ if hasattr(self,'_event_loop'): if self._event_loop.IsRunning(): self._event_loop.Exit() del self._event_loop
python
def stop_event_loop(self, event=None): if hasattr(self,'_event_loop'): if self._event_loop.IsRunning(): self._event_loop.Exit() del self._event_loop
[ "def", "stop_event_loop", "(", "self", ",", "event", "=", "None", ")", ":", "if", "hasattr", "(", "self", ",", "'_event_loop'", ")", ":", "if", "self", ".", "_event_loop", ".", "IsRunning", "(", ")", ":", "self", ".", "_event_loop", ".", "Exit", "(", ")", "del", "self", ".", "_event_loop" ]
Stop an event loop. This is used to stop a blocking event loop so that interactive functions, such as ginput and waitforbuttonpress, can wait for events. Call signature:: stop_event_loop_default(self)
[ "Stop", "an", "event", "loop", ".", "This", "is", "used", "to", "stop", "a", "blocking", "event", "loop", "so", "that", "interactive", "functions", "such", "as", "ginput", "and", "waitforbuttonpress", "can", "wait", "for", "events", "." ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/MacOS/backend_wx.py#L877-L890
249,447
ArduPilot/MAVProxy
MAVProxy/modules/lib/MacOS/backend_wx.py
FigureCanvasWx._get_imagesave_wildcards
def _get_imagesave_wildcards(self): 'return the wildcard string for the filesave dialog' default_filetype = self.get_default_filetype() filetypes = self.get_supported_filetypes_grouped() sorted_filetypes = filetypes.items() sorted_filetypes.sort() wildcards = [] extensions = [] filter_index = 0 for i, (name, exts) in enumerate(sorted_filetypes): ext_list = ';'.join(['*.%s' % ext for ext in exts]) extensions.append(exts[0]) wildcard = '%s (%s)|%s' % (name, ext_list, ext_list) if default_filetype in exts: filter_index = i wildcards.append(wildcard) wildcards = '|'.join(wildcards) return wildcards, extensions, filter_index
python
def _get_imagesave_wildcards(self): 'return the wildcard string for the filesave dialog' default_filetype = self.get_default_filetype() filetypes = self.get_supported_filetypes_grouped() sorted_filetypes = filetypes.items() sorted_filetypes.sort() wildcards = [] extensions = [] filter_index = 0 for i, (name, exts) in enumerate(sorted_filetypes): ext_list = ';'.join(['*.%s' % ext for ext in exts]) extensions.append(exts[0]) wildcard = '%s (%s)|%s' % (name, ext_list, ext_list) if default_filetype in exts: filter_index = i wildcards.append(wildcard) wildcards = '|'.join(wildcards) return wildcards, extensions, filter_index
[ "def", "_get_imagesave_wildcards", "(", "self", ")", ":", "default_filetype", "=", "self", ".", "get_default_filetype", "(", ")", "filetypes", "=", "self", ".", "get_supported_filetypes_grouped", "(", ")", "sorted_filetypes", "=", "filetypes", ".", "items", "(", ")", "sorted_filetypes", ".", "sort", "(", ")", "wildcards", "=", "[", "]", "extensions", "=", "[", "]", "filter_index", "=", "0", "for", "i", ",", "(", "name", ",", "exts", ")", "in", "enumerate", "(", "sorted_filetypes", ")", ":", "ext_list", "=", "';'", ".", "join", "(", "[", "'*.%s'", "%", "ext", "for", "ext", "in", "exts", "]", ")", "extensions", ".", "append", "(", "exts", "[", "0", "]", ")", "wildcard", "=", "'%s (%s)|%s'", "%", "(", "name", ",", "ext_list", ",", "ext_list", ")", "if", "default_filetype", "in", "exts", ":", "filter_index", "=", "i", "wildcards", ".", "append", "(", "wildcard", ")", "wildcards", "=", "'|'", ".", "join", "(", "wildcards", ")", "return", "wildcards", ",", "extensions", ",", "filter_index" ]
return the wildcard string for the filesave dialog
[ "return", "the", "wildcard", "string", "for", "the", "filesave", "dialog" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/MacOS/backend_wx.py#L893-L910
249,448
ArduPilot/MAVProxy
MAVProxy/modules/lib/MacOS/backend_wx.py
FigureCanvasWx.gui_repaint
def gui_repaint(self, drawDC=None): """ Performs update of the displayed image on the GUI canvas, using the supplied device context. If drawDC is None, a ClientDC will be used to redraw the image. """ DEBUG_MSG("gui_repaint()", 1, self) if self.IsShownOnScreen(): if drawDC is None: drawDC=wx.ClientDC(self) #drawDC.BeginDrawing() drawDC.DrawBitmap(self.bitmap, 0, 0) #drawDC.EndDrawing() #wx.GetApp().Yield() else: pass
python
def gui_repaint(self, drawDC=None): DEBUG_MSG("gui_repaint()", 1, self) if self.IsShownOnScreen(): if drawDC is None: drawDC=wx.ClientDC(self) #drawDC.BeginDrawing() drawDC.DrawBitmap(self.bitmap, 0, 0) #drawDC.EndDrawing() #wx.GetApp().Yield() else: pass
[ "def", "gui_repaint", "(", "self", ",", "drawDC", "=", "None", ")", ":", "DEBUG_MSG", "(", "\"gui_repaint()\"", ",", "1", ",", "self", ")", "if", "self", ".", "IsShownOnScreen", "(", ")", ":", "if", "drawDC", "is", "None", ":", "drawDC", "=", "wx", ".", "ClientDC", "(", "self", ")", "#drawDC.BeginDrawing()", "drawDC", ".", "DrawBitmap", "(", "self", ".", "bitmap", ",", "0", ",", "0", ")", "#drawDC.EndDrawing()", "#wx.GetApp().Yield()", "else", ":", "pass" ]
Performs update of the displayed image on the GUI canvas, using the supplied device context. If drawDC is None, a ClientDC will be used to redraw the image.
[ "Performs", "update", "of", "the", "displayed", "image", "on", "the", "GUI", "canvas", "using", "the", "supplied", "device", "context", ".", "If", "drawDC", "is", "None", "a", "ClientDC", "will", "be", "used", "to", "redraw", "the", "image", "." ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/MacOS/backend_wx.py#L912-L928
249,449
ArduPilot/MAVProxy
MAVProxy/modules/lib/MacOS/backend_wx.py
FigureCanvasWx._onPaint
def _onPaint(self, evt): """ Called when wxPaintEvt is generated """ DEBUG_MSG("_onPaint()", 1, self) drawDC = wx.PaintDC(self) if not self._isDrawn: self.draw(drawDC=drawDC) else: self.gui_repaint(drawDC=drawDC) evt.Skip()
python
def _onPaint(self, evt): DEBUG_MSG("_onPaint()", 1, self) drawDC = wx.PaintDC(self) if not self._isDrawn: self.draw(drawDC=drawDC) else: self.gui_repaint(drawDC=drawDC) evt.Skip()
[ "def", "_onPaint", "(", "self", ",", "evt", ")", ":", "DEBUG_MSG", "(", "\"_onPaint()\"", ",", "1", ",", "self", ")", "drawDC", "=", "wx", ".", "PaintDC", "(", "self", ")", "if", "not", "self", ".", "_isDrawn", ":", "self", ".", "draw", "(", "drawDC", "=", "drawDC", ")", "else", ":", "self", ".", "gui_repaint", "(", "drawDC", "=", "drawDC", ")", "evt", ".", "Skip", "(", ")" ]
Called when wxPaintEvt is generated
[ "Called", "when", "wxPaintEvt", "is", "generated" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/MacOS/backend_wx.py#L1021-L1032
249,450
ArduPilot/MAVProxy
MAVProxy/modules/lib/MacOS/backend_wx.py
FigureCanvasWx._onSize
def _onSize(self, evt): """ Called when wxEventSize is generated. In this application we attempt to resize to fit the window, so it is better to take the performance hit and redraw the whole window. """ DEBUG_MSG("_onSize()", 2, self) # Create a new, correctly sized bitmap self._width, self._height = self.GetClientSize() self.bitmap =wx.EmptyBitmap(self._width, self._height) self._isDrawn = False if self._width <= 1 or self._height <= 1: return # Empty figure dpival = self.figure.dpi winch = self._width/dpival hinch = self._height/dpival self.figure.set_size_inches(winch, hinch) # Rendering will happen on the associated paint event # so no need to do anything here except to make sure # the whole background is repainted. self.Refresh(eraseBackground=False) FigureCanvasBase.resize_event(self)
python
def _onSize(self, evt): DEBUG_MSG("_onSize()", 2, self) # Create a new, correctly sized bitmap self._width, self._height = self.GetClientSize() self.bitmap =wx.EmptyBitmap(self._width, self._height) self._isDrawn = False if self._width <= 1 or self._height <= 1: return # Empty figure dpival = self.figure.dpi winch = self._width/dpival hinch = self._height/dpival self.figure.set_size_inches(winch, hinch) # Rendering will happen on the associated paint event # so no need to do anything here except to make sure # the whole background is repainted. self.Refresh(eraseBackground=False) FigureCanvasBase.resize_event(self)
[ "def", "_onSize", "(", "self", ",", "evt", ")", ":", "DEBUG_MSG", "(", "\"_onSize()\"", ",", "2", ",", "self", ")", "# Create a new, correctly sized bitmap", "self", ".", "_width", ",", "self", ".", "_height", "=", "self", ".", "GetClientSize", "(", ")", "self", ".", "bitmap", "=", "wx", ".", "EmptyBitmap", "(", "self", ".", "_width", ",", "self", ".", "_height", ")", "self", ".", "_isDrawn", "=", "False", "if", "self", ".", "_width", "<=", "1", "or", "self", ".", "_height", "<=", "1", ":", "return", "# Empty figure", "dpival", "=", "self", ".", "figure", ".", "dpi", "winch", "=", "self", ".", "_width", "/", "dpival", "hinch", "=", "self", ".", "_height", "/", "dpival", "self", ".", "figure", ".", "set_size_inches", "(", "winch", ",", "hinch", ")", "# Rendering will happen on the associated paint event", "# so no need to do anything here except to make sure", "# the whole background is repainted.", "self", ".", "Refresh", "(", "eraseBackground", "=", "False", ")", "FigureCanvasBase", ".", "resize_event", "(", "self", ")" ]
Called when wxEventSize is generated. In this application we attempt to resize to fit the window, so it is better to take the performance hit and redraw the whole window.
[ "Called", "when", "wxEventSize", "is", "generated", "." ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/MacOS/backend_wx.py#L1041-L1066
249,451
ArduPilot/MAVProxy
MAVProxy/modules/lib/MacOS/backend_wx.py
FigureCanvasWx._onIdle
def _onIdle(self, evt): 'a GUI idle event' evt.Skip() FigureCanvasBase.idle_event(self, guiEvent=evt)
python
def _onIdle(self, evt): 'a GUI idle event' evt.Skip() FigureCanvasBase.idle_event(self, guiEvent=evt)
[ "def", "_onIdle", "(", "self", ",", "evt", ")", ":", "evt", ".", "Skip", "(", ")", "FigureCanvasBase", ".", "idle_event", "(", "self", ",", "guiEvent", "=", "evt", ")" ]
a GUI idle event
[ "a", "GUI", "idle", "event" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/MacOS/backend_wx.py#L1090-L1093
249,452
ArduPilot/MAVProxy
MAVProxy/modules/lib/MacOS/backend_wx.py
FigureCanvasWx._onKeyDown
def _onKeyDown(self, evt): """Capture key press.""" key = self._get_key(evt) evt.Skip() FigureCanvasBase.key_press_event(self, key, guiEvent=evt)
python
def _onKeyDown(self, evt): key = self._get_key(evt) evt.Skip() FigureCanvasBase.key_press_event(self, key, guiEvent=evt)
[ "def", "_onKeyDown", "(", "self", ",", "evt", ")", ":", "key", "=", "self", ".", "_get_key", "(", "evt", ")", "evt", ".", "Skip", "(", ")", "FigureCanvasBase", ".", "key_press_event", "(", "self", ",", "key", ",", "guiEvent", "=", "evt", ")" ]
Capture key press.
[ "Capture", "key", "press", "." ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/MacOS/backend_wx.py#L1095-L1099
249,453
ArduPilot/MAVProxy
MAVProxy/modules/lib/MacOS/backend_wx.py
FigureCanvasWx._onKeyUp
def _onKeyUp(self, evt): """Release key.""" key = self._get_key(evt) #print 'release key', key evt.Skip() FigureCanvasBase.key_release_event(self, key, guiEvent=evt)
python
def _onKeyUp(self, evt): key = self._get_key(evt) #print 'release key', key evt.Skip() FigureCanvasBase.key_release_event(self, key, guiEvent=evt)
[ "def", "_onKeyUp", "(", "self", ",", "evt", ")", ":", "key", "=", "self", ".", "_get_key", "(", "evt", ")", "#print 'release key', key", "evt", ".", "Skip", "(", ")", "FigureCanvasBase", ".", "key_release_event", "(", "self", ",", "key", ",", "guiEvent", "=", "evt", ")" ]
Release key.
[ "Release", "key", "." ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/MacOS/backend_wx.py#L1101-L1106
249,454
ArduPilot/MAVProxy
MAVProxy/modules/lib/MacOS/backend_wx.py
FigureCanvasWx._onLeftButtonUp
def _onLeftButtonUp(self, evt): """End measuring on an axis.""" x = evt.GetX() y = self.figure.bbox.height - evt.GetY() #print 'release button', 1 evt.Skip() if self.HasCapture(): self.ReleaseMouse() FigureCanvasBase.button_release_event(self, x, y, 1, guiEvent=evt)
python
def _onLeftButtonUp(self, evt): x = evt.GetX() y = self.figure.bbox.height - evt.GetY() #print 'release button', 1 evt.Skip() if self.HasCapture(): self.ReleaseMouse() FigureCanvasBase.button_release_event(self, x, y, 1, guiEvent=evt)
[ "def", "_onLeftButtonUp", "(", "self", ",", "evt", ")", ":", "x", "=", "evt", ".", "GetX", "(", ")", "y", "=", "self", ".", "figure", ".", "bbox", ".", "height", "-", "evt", ".", "GetY", "(", ")", "#print 'release button', 1", "evt", ".", "Skip", "(", ")", "if", "self", ".", "HasCapture", "(", ")", ":", "self", ".", "ReleaseMouse", "(", ")", "FigureCanvasBase", ".", "button_release_event", "(", "self", ",", "x", ",", "y", ",", "1", ",", "guiEvent", "=", "evt", ")" ]
End measuring on an axis.
[ "End", "measuring", "on", "an", "axis", "." ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/MacOS/backend_wx.py#L1148-L1155
249,455
ArduPilot/MAVProxy
MAVProxy/modules/lib/MacOS/backend_wx.py
FigureCanvasWx._onMouseWheel
def _onMouseWheel(self, evt): """Translate mouse wheel events into matplotlib events""" # Determine mouse location x = evt.GetX() y = self.figure.bbox.height - evt.GetY() # Convert delta/rotation/rate into a floating point step size delta = evt.GetWheelDelta() rotation = evt.GetWheelRotation() rate = evt.GetLinesPerAction() #print "delta,rotation,rate",delta,rotation,rate step = rate*float(rotation)/delta # Done handling event evt.Skip() # Mac is giving two events for every wheel event # Need to skip every second one if wx.Platform == '__WXMAC__': if not hasattr(self,'_skipwheelevent'): self._skipwheelevent = True elif self._skipwheelevent: self._skipwheelevent = False return # Return without processing event else: self._skipwheelevent = True # Convert to mpl event FigureCanvasBase.scroll_event(self, x, y, step, guiEvent=evt)
python
def _onMouseWheel(self, evt): # Determine mouse location x = evt.GetX() y = self.figure.bbox.height - evt.GetY() # Convert delta/rotation/rate into a floating point step size delta = evt.GetWheelDelta() rotation = evt.GetWheelRotation() rate = evt.GetLinesPerAction() #print "delta,rotation,rate",delta,rotation,rate step = rate*float(rotation)/delta # Done handling event evt.Skip() # Mac is giving two events for every wheel event # Need to skip every second one if wx.Platform == '__WXMAC__': if not hasattr(self,'_skipwheelevent'): self._skipwheelevent = True elif self._skipwheelevent: self._skipwheelevent = False return # Return without processing event else: self._skipwheelevent = True # Convert to mpl event FigureCanvasBase.scroll_event(self, x, y, step, guiEvent=evt)
[ "def", "_onMouseWheel", "(", "self", ",", "evt", ")", ":", "# Determine mouse location", "x", "=", "evt", ".", "GetX", "(", ")", "y", "=", "self", ".", "figure", ".", "bbox", ".", "height", "-", "evt", ".", "GetY", "(", ")", "# Convert delta/rotation/rate into a floating point step size", "delta", "=", "evt", ".", "GetWheelDelta", "(", ")", "rotation", "=", "evt", ".", "GetWheelRotation", "(", ")", "rate", "=", "evt", ".", "GetLinesPerAction", "(", ")", "#print \"delta,rotation,rate\",delta,rotation,rate", "step", "=", "rate", "*", "float", "(", "rotation", ")", "/", "delta", "# Done handling event", "evt", ".", "Skip", "(", ")", "# Mac is giving two events for every wheel event", "# Need to skip every second one", "if", "wx", ".", "Platform", "==", "'__WXMAC__'", ":", "if", "not", "hasattr", "(", "self", ",", "'_skipwheelevent'", ")", ":", "self", ".", "_skipwheelevent", "=", "True", "elif", "self", ".", "_skipwheelevent", ":", "self", ".", "_skipwheelevent", "=", "False", "return", "# Return without processing event", "else", ":", "self", ".", "_skipwheelevent", "=", "True", "# Convert to mpl event", "FigureCanvasBase", ".", "scroll_event", "(", "self", ",", "x", ",", "y", ",", "step", ",", "guiEvent", "=", "evt", ")" ]
Translate mouse wheel events into matplotlib events
[ "Translate", "mouse", "wheel", "events", "into", "matplotlib", "events" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/MacOS/backend_wx.py#L1183-L1212
249,456
ArduPilot/MAVProxy
MAVProxy/modules/lib/MacOS/backend_wx.py
FigureCanvasWx._onLeave
def _onLeave(self, evt): """Mouse has left the window.""" evt.Skip() FigureCanvasBase.leave_notify_event(self, guiEvent = evt)
python
def _onLeave(self, evt): evt.Skip() FigureCanvasBase.leave_notify_event(self, guiEvent = evt)
[ "def", "_onLeave", "(", "self", ",", "evt", ")", ":", "evt", ".", "Skip", "(", ")", "FigureCanvasBase", ".", "leave_notify_event", "(", "self", ",", "guiEvent", "=", "evt", ")" ]
Mouse has left the window.
[ "Mouse", "has", "left", "the", "window", "." ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/MacOS/backend_wx.py#L1222-L1226
249,457
ArduPilot/MAVProxy
MAVProxy/modules/lib/MacOS/backend_wx.py
FigureManagerWx.resize
def resize(self, width, height): 'Set the canvas size in pixels' self.canvas.SetInitialSize(wx.Size(width, height)) self.window.GetSizer().Fit(self.window)
python
def resize(self, width, height): 'Set the canvas size in pixels' self.canvas.SetInitialSize(wx.Size(width, height)) self.window.GetSizer().Fit(self.window)
[ "def", "resize", "(", "self", ",", "width", ",", "height", ")", ":", "self", ".", "canvas", ".", "SetInitialSize", "(", "wx", ".", "Size", "(", "width", ",", "height", ")", ")", "self", ".", "window", ".", "GetSizer", "(", ")", ".", "Fit", "(", "self", ".", "window", ")" ]
Set the canvas size in pixels
[ "Set", "the", "canvas", "size", "in", "pixels" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/MacOS/backend_wx.py#L1443-L1446
249,458
ArduPilot/MAVProxy
MAVProxy/modules/lib/MacOS/backend_wx.py
MenuButtonWx._onMenuButton
def _onMenuButton(self, evt): """Handle menu button pressed.""" x, y = self.GetPositionTuple() w, h = self.GetSizeTuple() self.PopupMenuXY(self._menu, x, y+h-4) # When menu returned, indicate selection in button evt.Skip()
python
def _onMenuButton(self, evt): x, y = self.GetPositionTuple() w, h = self.GetSizeTuple() self.PopupMenuXY(self._menu, x, y+h-4) # When menu returned, indicate selection in button evt.Skip()
[ "def", "_onMenuButton", "(", "self", ",", "evt", ")", ":", "x", ",", "y", "=", "self", ".", "GetPositionTuple", "(", ")", "w", ",", "h", "=", "self", ".", "GetSizeTuple", "(", ")", "self", ".", "PopupMenuXY", "(", "self", ".", "_menu", ",", "x", ",", "y", "+", "h", "-", "4", ")", "# When menu returned, indicate selection in button", "evt", ".", "Skip", "(", ")" ]
Handle menu button pressed.
[ "Handle", "menu", "button", "pressed", "." ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/MacOS/backend_wx.py#L1513-L1519
249,459
ArduPilot/MAVProxy
MAVProxy/modules/lib/MacOS/backend_wx.py
MenuButtonWx._handleSelectAllAxes
def _handleSelectAllAxes(self, evt): """Called when the 'select all axes' menu item is selected.""" if len(self._axisId) == 0: return for i in range(len(self._axisId)): self._menu.Check(self._axisId[i], True) self._toolbar.set_active(self.getActiveAxes()) evt.Skip()
python
def _handleSelectAllAxes(self, evt): if len(self._axisId) == 0: return for i in range(len(self._axisId)): self._menu.Check(self._axisId[i], True) self._toolbar.set_active(self.getActiveAxes()) evt.Skip()
[ "def", "_handleSelectAllAxes", "(", "self", ",", "evt", ")", ":", "if", "len", "(", "self", ".", "_axisId", ")", "==", "0", ":", "return", "for", "i", "in", "range", "(", "len", "(", "self", ".", "_axisId", ")", ")", ":", "self", ".", "_menu", ".", "Check", "(", "self", ".", "_axisId", "[", "i", "]", ",", "True", ")", "self", ".", "_toolbar", ".", "set_active", "(", "self", ".", "getActiveAxes", "(", ")", ")", "evt", ".", "Skip", "(", ")" ]
Called when the 'select all axes' menu item is selected.
[ "Called", "when", "the", "select", "all", "axes", "menu", "item", "is", "selected", "." ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/MacOS/backend_wx.py#L1521-L1528
249,460
ArduPilot/MAVProxy
MAVProxy/modules/lib/MacOS/backend_wx.py
MenuButtonWx._handleInvertAxesSelected
def _handleInvertAxesSelected(self, evt): """Called when the invert all menu item is selected""" if len(self._axisId) == 0: return for i in range(len(self._axisId)): if self._menu.IsChecked(self._axisId[i]): self._menu.Check(self._axisId[i], False) else: self._menu.Check(self._axisId[i], True) self._toolbar.set_active(self.getActiveAxes()) evt.Skip()
python
def _handleInvertAxesSelected(self, evt): if len(self._axisId) == 0: return for i in range(len(self._axisId)): if self._menu.IsChecked(self._axisId[i]): self._menu.Check(self._axisId[i], False) else: self._menu.Check(self._axisId[i], True) self._toolbar.set_active(self.getActiveAxes()) evt.Skip()
[ "def", "_handleInvertAxesSelected", "(", "self", ",", "evt", ")", ":", "if", "len", "(", "self", ".", "_axisId", ")", "==", "0", ":", "return", "for", "i", "in", "range", "(", "len", "(", "self", ".", "_axisId", ")", ")", ":", "if", "self", ".", "_menu", ".", "IsChecked", "(", "self", ".", "_axisId", "[", "i", "]", ")", ":", "self", ".", "_menu", ".", "Check", "(", "self", ".", "_axisId", "[", "i", "]", ",", "False", ")", "else", ":", "self", ".", "_menu", ".", "Check", "(", "self", ".", "_axisId", "[", "i", "]", ",", "True", ")", "self", ".", "_toolbar", ".", "set_active", "(", "self", ".", "getActiveAxes", "(", ")", ")", "evt", ".", "Skip", "(", ")" ]
Called when the invert all menu item is selected
[ "Called", "when", "the", "invert", "all", "menu", "item", "is", "selected" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/MacOS/backend_wx.py#L1530-L1539
249,461
ArduPilot/MAVProxy
MAVProxy/modules/lib/MacOS/backend_wx.py
MenuButtonWx._onMenuItemSelected
def _onMenuItemSelected(self, evt): """Called whenever one of the specific axis menu items is selected""" current = self._menu.IsChecked(evt.GetId()) if current: new = False else: new = True self._menu.Check(evt.GetId(), new) # Lines above would be deleted based on svn tracker ID 2841525; # not clear whether this matters or not. self._toolbar.set_active(self.getActiveAxes()) evt.Skip()
python
def _onMenuItemSelected(self, evt): current = self._menu.IsChecked(evt.GetId()) if current: new = False else: new = True self._menu.Check(evt.GetId(), new) # Lines above would be deleted based on svn tracker ID 2841525; # not clear whether this matters or not. self._toolbar.set_active(self.getActiveAxes()) evt.Skip()
[ "def", "_onMenuItemSelected", "(", "self", ",", "evt", ")", ":", "current", "=", "self", ".", "_menu", ".", "IsChecked", "(", "evt", ".", "GetId", "(", ")", ")", "if", "current", ":", "new", "=", "False", "else", ":", "new", "=", "True", "self", ".", "_menu", ".", "Check", "(", "evt", ".", "GetId", "(", ")", ",", "new", ")", "# Lines above would be deleted based on svn tracker ID 2841525;", "# not clear whether this matters or not.", "self", ".", "_toolbar", ".", "set_active", "(", "self", ".", "getActiveAxes", "(", ")", ")", "evt", ".", "Skip", "(", ")" ]
Called whenever one of the specific axis menu items is selected
[ "Called", "whenever", "one", "of", "the", "specific", "axis", "menu", "items", "is", "selected" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/MacOS/backend_wx.py#L1541-L1552
249,462
ArduPilot/MAVProxy
MAVProxy/modules/lib/MacOS/backend_wx.py
MenuButtonWx.getActiveAxes
def getActiveAxes(self): """Return a list of the selected axes.""" active = [] for i in range(len(self._axisId)): if self._menu.IsChecked(self._axisId[i]): active.append(i) return active
python
def getActiveAxes(self): active = [] for i in range(len(self._axisId)): if self._menu.IsChecked(self._axisId[i]): active.append(i) return active
[ "def", "getActiveAxes", "(", "self", ")", ":", "active", "=", "[", "]", "for", "i", "in", "range", "(", "len", "(", "self", ".", "_axisId", ")", ")", ":", "if", "self", ".", "_menu", ".", "IsChecked", "(", "self", ".", "_axisId", "[", "i", "]", ")", ":", "active", ".", "append", "(", "i", ")", "return", "active" ]
Return a list of the selected axes.
[ "Return", "a", "list", "of", "the", "selected", "axes", "." ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/MacOS/backend_wx.py#L1570-L1576
249,463
ArduPilot/MAVProxy
MAVProxy/modules/lib/MacOS/backend_wx.py
MenuButtonWx.updateButtonText
def updateButtonText(self, lst): """Update the list of selected axes in the menu button""" axis_txt = '' for e in lst: axis_txt += '%d,' % (e+1) # remove trailing ',' and add to button string self.SetLabel("Axes: %s" % axis_txt[:-1])
python
def updateButtonText(self, lst): axis_txt = '' for e in lst: axis_txt += '%d,' % (e+1) # remove trailing ',' and add to button string self.SetLabel("Axes: %s" % axis_txt[:-1])
[ "def", "updateButtonText", "(", "self", ",", "lst", ")", ":", "axis_txt", "=", "''", "for", "e", "in", "lst", ":", "axis_txt", "+=", "'%d,'", "%", "(", "e", "+", "1", ")", "# remove trailing ',' and add to button string", "self", ".", "SetLabel", "(", "\"Axes: %s\"", "%", "axis_txt", "[", ":", "-", "1", "]", ")" ]
Update the list of selected axes in the menu button
[ "Update", "the", "list", "of", "selected", "axes", "in", "the", "menu", "button" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/MacOS/backend_wx.py#L1578-L1584
249,464
ArduPilot/MAVProxy
MAVProxy/modules/lib/MacOS/backend_wx.py
NavigationToolbarWx._create_menu
def _create_menu(self): """ Creates the 'menu' - implemented as a button which opens a pop-up menu since wxPython does not allow a menu as a control """ DEBUG_MSG("_create_menu()", 1, self) self._menu = MenuButtonWx(self) self.AddControl(self._menu) self.AddSeparator()
python
def _create_menu(self): DEBUG_MSG("_create_menu()", 1, self) self._menu = MenuButtonWx(self) self.AddControl(self._menu) self.AddSeparator()
[ "def", "_create_menu", "(", "self", ")", ":", "DEBUG_MSG", "(", "\"_create_menu()\"", ",", "1", ",", "self", ")", "self", ".", "_menu", "=", "MenuButtonWx", "(", "self", ")", "self", ".", "AddControl", "(", "self", ".", "_menu", ")", "self", ".", "AddSeparator", "(", ")" ]
Creates the 'menu' - implemented as a button which opens a pop-up menu since wxPython does not allow a menu as a control
[ "Creates", "the", "menu", "-", "implemented", "as", "a", "button", "which", "opens", "a", "pop", "-", "up", "menu", "since", "wxPython", "does", "not", "allow", "a", "menu", "as", "a", "control" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/MacOS/backend_wx.py#L1795-L1803
249,465
ArduPilot/MAVProxy
MAVProxy/modules/lib/MacOS/backend_wx.py
NavigationToolbarWx._create_controls
def _create_controls(self, can_kill): """ Creates the button controls, and links them to event handlers """ DEBUG_MSG("_create_controls()", 1, self) # Need the following line as Windows toolbars default to 15x16 self.SetToolBitmapSize(wx.Size(16,16)) self.AddSimpleTool(_NTB_X_PAN_LEFT, _load_bitmap('stock_left.xpm'), 'Left', 'Scroll left') self.AddSimpleTool(_NTB_X_PAN_RIGHT, _load_bitmap('stock_right.xpm'), 'Right', 'Scroll right') self.AddSimpleTool(_NTB_X_ZOOMIN, _load_bitmap('stock_zoom-in.xpm'), 'Zoom in', 'Increase X axis magnification') self.AddSimpleTool(_NTB_X_ZOOMOUT, _load_bitmap('stock_zoom-out.xpm'), 'Zoom out', 'Decrease X axis magnification') self.AddSeparator() self.AddSimpleTool(_NTB_Y_PAN_UP,_load_bitmap('stock_up.xpm'), 'Up', 'Scroll up') self.AddSimpleTool(_NTB_Y_PAN_DOWN, _load_bitmap('stock_down.xpm'), 'Down', 'Scroll down') self.AddSimpleTool(_NTB_Y_ZOOMIN, _load_bitmap('stock_zoom-in.xpm'), 'Zoom in', 'Increase Y axis magnification') self.AddSimpleTool(_NTB_Y_ZOOMOUT, _load_bitmap('stock_zoom-out.xpm'), 'Zoom out', 'Decrease Y axis magnification') self.AddSeparator() self.AddSimpleTool(_NTB_SAVE, _load_bitmap('stock_save_as.xpm'), 'Save', 'Save plot contents as images') self.AddSeparator() bind(self, wx.EVT_TOOL, self._onLeftScroll, id=_NTB_X_PAN_LEFT) bind(self, wx.EVT_TOOL, self._onRightScroll, id=_NTB_X_PAN_RIGHT) bind(self, wx.EVT_TOOL, self._onXZoomIn, id=_NTB_X_ZOOMIN) bind(self, wx.EVT_TOOL, self._onXZoomOut, id=_NTB_X_ZOOMOUT) bind(self, wx.EVT_TOOL, self._onUpScroll, id=_NTB_Y_PAN_UP) bind(self, wx.EVT_TOOL, self._onDownScroll, id=_NTB_Y_PAN_DOWN) bind(self, wx.EVT_TOOL, self._onYZoomIn, id=_NTB_Y_ZOOMIN) bind(self, wx.EVT_TOOL, self._onYZoomOut, id=_NTB_Y_ZOOMOUT) bind(self, wx.EVT_TOOL, self._onSave, id=_NTB_SAVE) bind(self, wx.EVT_TOOL_ENTER, self._onEnterTool, id=self.GetId()) if can_kill: bind(self, wx.EVT_TOOL, self._onClose, id=_NTB_CLOSE) bind(self, wx.EVT_MOUSEWHEEL, self._onMouseWheel)
python
def _create_controls(self, can_kill): DEBUG_MSG("_create_controls()", 1, self) # Need the following line as Windows toolbars default to 15x16 self.SetToolBitmapSize(wx.Size(16,16)) self.AddSimpleTool(_NTB_X_PAN_LEFT, _load_bitmap('stock_left.xpm'), 'Left', 'Scroll left') self.AddSimpleTool(_NTB_X_PAN_RIGHT, _load_bitmap('stock_right.xpm'), 'Right', 'Scroll right') self.AddSimpleTool(_NTB_X_ZOOMIN, _load_bitmap('stock_zoom-in.xpm'), 'Zoom in', 'Increase X axis magnification') self.AddSimpleTool(_NTB_X_ZOOMOUT, _load_bitmap('stock_zoom-out.xpm'), 'Zoom out', 'Decrease X axis magnification') self.AddSeparator() self.AddSimpleTool(_NTB_Y_PAN_UP,_load_bitmap('stock_up.xpm'), 'Up', 'Scroll up') self.AddSimpleTool(_NTB_Y_PAN_DOWN, _load_bitmap('stock_down.xpm'), 'Down', 'Scroll down') self.AddSimpleTool(_NTB_Y_ZOOMIN, _load_bitmap('stock_zoom-in.xpm'), 'Zoom in', 'Increase Y axis magnification') self.AddSimpleTool(_NTB_Y_ZOOMOUT, _load_bitmap('stock_zoom-out.xpm'), 'Zoom out', 'Decrease Y axis magnification') self.AddSeparator() self.AddSimpleTool(_NTB_SAVE, _load_bitmap('stock_save_as.xpm'), 'Save', 'Save plot contents as images') self.AddSeparator() bind(self, wx.EVT_TOOL, self._onLeftScroll, id=_NTB_X_PAN_LEFT) bind(self, wx.EVT_TOOL, self._onRightScroll, id=_NTB_X_PAN_RIGHT) bind(self, wx.EVT_TOOL, self._onXZoomIn, id=_NTB_X_ZOOMIN) bind(self, wx.EVT_TOOL, self._onXZoomOut, id=_NTB_X_ZOOMOUT) bind(self, wx.EVT_TOOL, self._onUpScroll, id=_NTB_Y_PAN_UP) bind(self, wx.EVT_TOOL, self._onDownScroll, id=_NTB_Y_PAN_DOWN) bind(self, wx.EVT_TOOL, self._onYZoomIn, id=_NTB_Y_ZOOMIN) bind(self, wx.EVT_TOOL, self._onYZoomOut, id=_NTB_Y_ZOOMOUT) bind(self, wx.EVT_TOOL, self._onSave, id=_NTB_SAVE) bind(self, wx.EVT_TOOL_ENTER, self._onEnterTool, id=self.GetId()) if can_kill: bind(self, wx.EVT_TOOL, self._onClose, id=_NTB_CLOSE) bind(self, wx.EVT_MOUSEWHEEL, self._onMouseWheel)
[ "def", "_create_controls", "(", "self", ",", "can_kill", ")", ":", "DEBUG_MSG", "(", "\"_create_controls()\"", ",", "1", ",", "self", ")", "# Need the following line as Windows toolbars default to 15x16", "self", ".", "SetToolBitmapSize", "(", "wx", ".", "Size", "(", "16", ",", "16", ")", ")", "self", ".", "AddSimpleTool", "(", "_NTB_X_PAN_LEFT", ",", "_load_bitmap", "(", "'stock_left.xpm'", ")", ",", "'Left'", ",", "'Scroll left'", ")", "self", ".", "AddSimpleTool", "(", "_NTB_X_PAN_RIGHT", ",", "_load_bitmap", "(", "'stock_right.xpm'", ")", ",", "'Right'", ",", "'Scroll right'", ")", "self", ".", "AddSimpleTool", "(", "_NTB_X_ZOOMIN", ",", "_load_bitmap", "(", "'stock_zoom-in.xpm'", ")", ",", "'Zoom in'", ",", "'Increase X axis magnification'", ")", "self", ".", "AddSimpleTool", "(", "_NTB_X_ZOOMOUT", ",", "_load_bitmap", "(", "'stock_zoom-out.xpm'", ")", ",", "'Zoom out'", ",", "'Decrease X axis magnification'", ")", "self", ".", "AddSeparator", "(", ")", "self", ".", "AddSimpleTool", "(", "_NTB_Y_PAN_UP", ",", "_load_bitmap", "(", "'stock_up.xpm'", ")", ",", "'Up'", ",", "'Scroll up'", ")", "self", ".", "AddSimpleTool", "(", "_NTB_Y_PAN_DOWN", ",", "_load_bitmap", "(", "'stock_down.xpm'", ")", ",", "'Down'", ",", "'Scroll down'", ")", "self", ".", "AddSimpleTool", "(", "_NTB_Y_ZOOMIN", ",", "_load_bitmap", "(", "'stock_zoom-in.xpm'", ")", ",", "'Zoom in'", ",", "'Increase Y axis magnification'", ")", "self", ".", "AddSimpleTool", "(", "_NTB_Y_ZOOMOUT", ",", "_load_bitmap", "(", "'stock_zoom-out.xpm'", ")", ",", "'Zoom out'", ",", "'Decrease Y axis magnification'", ")", "self", ".", "AddSeparator", "(", ")", "self", ".", "AddSimpleTool", "(", "_NTB_SAVE", ",", "_load_bitmap", "(", "'stock_save_as.xpm'", ")", ",", "'Save'", ",", "'Save plot contents as images'", ")", "self", ".", "AddSeparator", "(", ")", "bind", "(", "self", ",", "wx", ".", "EVT_TOOL", ",", "self", ".", "_onLeftScroll", ",", "id", "=", "_NTB_X_PAN_LEFT", ")", "bind", "(", "self", ",", "wx", ".", "EVT_TOOL", ",", "self", ".", "_onRightScroll", ",", "id", "=", "_NTB_X_PAN_RIGHT", ")", "bind", "(", "self", ",", "wx", ".", "EVT_TOOL", ",", "self", ".", "_onXZoomIn", ",", "id", "=", "_NTB_X_ZOOMIN", ")", "bind", "(", "self", ",", "wx", ".", "EVT_TOOL", ",", "self", ".", "_onXZoomOut", ",", "id", "=", "_NTB_X_ZOOMOUT", ")", "bind", "(", "self", ",", "wx", ".", "EVT_TOOL", ",", "self", ".", "_onUpScroll", ",", "id", "=", "_NTB_Y_PAN_UP", ")", "bind", "(", "self", ",", "wx", ".", "EVT_TOOL", ",", "self", ".", "_onDownScroll", ",", "id", "=", "_NTB_Y_PAN_DOWN", ")", "bind", "(", "self", ",", "wx", ".", "EVT_TOOL", ",", "self", ".", "_onYZoomIn", ",", "id", "=", "_NTB_Y_ZOOMIN", ")", "bind", "(", "self", ",", "wx", ".", "EVT_TOOL", ",", "self", ".", "_onYZoomOut", ",", "id", "=", "_NTB_Y_ZOOMOUT", ")", "bind", "(", "self", ",", "wx", ".", "EVT_TOOL", ",", "self", ".", "_onSave", ",", "id", "=", "_NTB_SAVE", ")", "bind", "(", "self", ",", "wx", ".", "EVT_TOOL_ENTER", ",", "self", ".", "_onEnterTool", ",", "id", "=", "self", ".", "GetId", "(", ")", ")", "if", "can_kill", ":", "bind", "(", "self", ",", "wx", ".", "EVT_TOOL", ",", "self", ".", "_onClose", ",", "id", "=", "_NTB_CLOSE", ")", "bind", "(", "self", ",", "wx", ".", "EVT_MOUSEWHEEL", ",", "self", ".", "_onMouseWheel", ")" ]
Creates the button controls, and links them to event handlers
[ "Creates", "the", "button", "controls", "and", "links", "them", "to", "event", "handlers" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/MacOS/backend_wx.py#L1805-L1847
249,466
ArduPilot/MAVProxy
MAVProxy/modules/lib/MacOS/backend_wx.py
NavigationToolbarWx.set_active
def set_active(self, ind): """ ind is a list of index numbers for the axes which are to be made active """ DEBUG_MSG("set_active()", 1, self) self._ind = ind if ind != None: self._active = [ self._axes[i] for i in self._ind ] else: self._active = [] # Now update button text wit active axes self._menu.updateButtonText(ind)
python
def set_active(self, ind): DEBUG_MSG("set_active()", 1, self) self._ind = ind if ind != None: self._active = [ self._axes[i] for i in self._ind ] else: self._active = [] # Now update button text wit active axes self._menu.updateButtonText(ind)
[ "def", "set_active", "(", "self", ",", "ind", ")", ":", "DEBUG_MSG", "(", "\"set_active()\"", ",", "1", ",", "self", ")", "self", ".", "_ind", "=", "ind", "if", "ind", "!=", "None", ":", "self", ".", "_active", "=", "[", "self", ".", "_axes", "[", "i", "]", "for", "i", "in", "self", ".", "_ind", "]", "else", ":", "self", ".", "_active", "=", "[", "]", "# Now update button text wit active axes", "self", ".", "_menu", ".", "updateButtonText", "(", "ind", ")" ]
ind is a list of index numbers for the axes which are to be made active
[ "ind", "is", "a", "list", "of", "index", "numbers", "for", "the", "axes", "which", "are", "to", "be", "made", "active" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/MacOS/backend_wx.py#L1849-L1860
249,467
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_map/srtm.py
SRTMDownloader.getURIWithRedirect
def getURIWithRedirect(self, url): '''fetch a URL with redirect handling''' tries = 0 while tries < 5: conn = httplib.HTTPConnection(self.server) conn.request("GET", url) r1 = conn.getresponse() if r1.status in [301, 302, 303, 307]: location = r1.getheader('Location') if self.debug: print("redirect from %s to %s" % (url, location)) url = location conn.close() tries += 1 continue data = r1.read() conn.close() if sys.version_info.major < 3: return data else: encoding = r1.headers.get_content_charset(default) return data.decode(encoding) return None
python
def getURIWithRedirect(self, url): '''fetch a URL with redirect handling''' tries = 0 while tries < 5: conn = httplib.HTTPConnection(self.server) conn.request("GET", url) r1 = conn.getresponse() if r1.status in [301, 302, 303, 307]: location = r1.getheader('Location') if self.debug: print("redirect from %s to %s" % (url, location)) url = location conn.close() tries += 1 continue data = r1.read() conn.close() if sys.version_info.major < 3: return data else: encoding = r1.headers.get_content_charset(default) return data.decode(encoding) return None
[ "def", "getURIWithRedirect", "(", "self", ",", "url", ")", ":", "tries", "=", "0", "while", "tries", "<", "5", ":", "conn", "=", "httplib", ".", "HTTPConnection", "(", "self", ".", "server", ")", "conn", ".", "request", "(", "\"GET\"", ",", "url", ")", "r1", "=", "conn", ".", "getresponse", "(", ")", "if", "r1", ".", "status", "in", "[", "301", ",", "302", ",", "303", ",", "307", "]", ":", "location", "=", "r1", ".", "getheader", "(", "'Location'", ")", "if", "self", ".", "debug", ":", "print", "(", "\"redirect from %s to %s\"", "%", "(", "url", ",", "location", ")", ")", "url", "=", "location", "conn", ".", "close", "(", ")", "tries", "+=", "1", "continue", "data", "=", "r1", ".", "read", "(", ")", "conn", ".", "close", "(", ")", "if", "sys", ".", "version_info", ".", "major", "<", "3", ":", "return", "data", "else", ":", "encoding", "=", "r1", ".", "headers", ".", "get_content_charset", "(", "default", ")", "return", "data", ".", "decode", "(", "encoding", ")", "return", "None" ]
fetch a URL with redirect handling
[ "fetch", "a", "URL", "with", "redirect", "handling" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_map/srtm.py#L133-L155
249,468
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_rc.py
RCModule.cmd_rc
def cmd_rc(self, args): '''handle RC value override''' if len(args) != 2: print("Usage: rc <channel|all> <pwmvalue>") return value = int(args[1]) if value > 65535 or value < -1: raise ValueError("PWM value must be a positive integer between 0 and 65535") if value == -1: value = 65535 channels = self.override if args[0] == 'all': for i in range(16): channels[i] = value else: channel = int(args[0]) if channel < 1 or channel > 16: print("Channel must be between 1 and 8 or 'all'") return channels[channel - 1] = value self.set_override(channels)
python
def cmd_rc(self, args): '''handle RC value override''' if len(args) != 2: print("Usage: rc <channel|all> <pwmvalue>") return value = int(args[1]) if value > 65535 or value < -1: raise ValueError("PWM value must be a positive integer between 0 and 65535") if value == -1: value = 65535 channels = self.override if args[0] == 'all': for i in range(16): channels[i] = value else: channel = int(args[0]) if channel < 1 or channel > 16: print("Channel must be between 1 and 8 or 'all'") return channels[channel - 1] = value self.set_override(channels)
[ "def", "cmd_rc", "(", "self", ",", "args", ")", ":", "if", "len", "(", "args", ")", "!=", "2", ":", "print", "(", "\"Usage: rc <channel|all> <pwmvalue>\"", ")", "return", "value", "=", "int", "(", "args", "[", "1", "]", ")", "if", "value", ">", "65535", "or", "value", "<", "-", "1", ":", "raise", "ValueError", "(", "\"PWM value must be a positive integer between 0 and 65535\"", ")", "if", "value", "==", "-", "1", ":", "value", "=", "65535", "channels", "=", "self", ".", "override", "if", "args", "[", "0", "]", "==", "'all'", ":", "for", "i", "in", "range", "(", "16", ")", ":", "channels", "[", "i", "]", "=", "value", "else", ":", "channel", "=", "int", "(", "args", "[", "0", "]", ")", "if", "channel", "<", "1", "or", "channel", ">", "16", ":", "print", "(", "\"Channel must be between 1 and 8 or 'all'\"", ")", "return", "channels", "[", "channel", "-", "1", "]", "=", "value", "self", ".", "set_override", "(", "channels", ")" ]
handle RC value override
[ "handle", "RC", "value", "override" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_rc.py#L86-L106
249,469
ArduPilot/MAVProxy
MAVProxy/modules/lib/rline.py
complete_variable
def complete_variable(text): '''complete a MAVLink variable or expression''' if text == '': return list(rline_mpstate.status.msgs.keys()) if text.endswith(":2"): suffix = ":2" text = text[:-2] else: suffix = '' try: if mavutil.evaluate_expression(text, rline_mpstate.status.msgs) is not None: return [text+suffix] except Exception as ex: pass try: m1 = re.match("^(.*?)([A-Z0-9][A-Z0-9_]*)[.]([A-Za-z0-9_]*)$", text) except Exception as ex: return [] if m1 is not None: prefix = m1.group(1) mtype = m1.group(2) fname = m1.group(3) if mtype in rline_mpstate.status.msgs: ret = [] for f in rline_mpstate.status.msgs[mtype].get_fieldnames(): if f.startswith(fname): ret.append(prefix + mtype + '.' + f + suffix) return ret return [] try: m2 = re.match("^(.*?)([A-Z0-9][A-Z0-9_]*)$", text) except Exception as ex: return [] prefix = m2.group(1) mtype = m2.group(2) ret = [] for k in list(rline_mpstate.status.msgs.keys()): if k.startswith(mtype): ret.append(prefix + k + suffix) return ret
python
def complete_variable(text): '''complete a MAVLink variable or expression''' if text == '': return list(rline_mpstate.status.msgs.keys()) if text.endswith(":2"): suffix = ":2" text = text[:-2] else: suffix = '' try: if mavutil.evaluate_expression(text, rline_mpstate.status.msgs) is not None: return [text+suffix] except Exception as ex: pass try: m1 = re.match("^(.*?)([A-Z0-9][A-Z0-9_]*)[.]([A-Za-z0-9_]*)$", text) except Exception as ex: return [] if m1 is not None: prefix = m1.group(1) mtype = m1.group(2) fname = m1.group(3) if mtype in rline_mpstate.status.msgs: ret = [] for f in rline_mpstate.status.msgs[mtype].get_fieldnames(): if f.startswith(fname): ret.append(prefix + mtype + '.' + f + suffix) return ret return [] try: m2 = re.match("^(.*?)([A-Z0-9][A-Z0-9_]*)$", text) except Exception as ex: return [] prefix = m2.group(1) mtype = m2.group(2) ret = [] for k in list(rline_mpstate.status.msgs.keys()): if k.startswith(mtype): ret.append(prefix + k + suffix) return ret
[ "def", "complete_variable", "(", "text", ")", ":", "if", "text", "==", "''", ":", "return", "list", "(", "rline_mpstate", ".", "status", ".", "msgs", ".", "keys", "(", ")", ")", "if", "text", ".", "endswith", "(", "\":2\"", ")", ":", "suffix", "=", "\":2\"", "text", "=", "text", "[", ":", "-", "2", "]", "else", ":", "suffix", "=", "''", "try", ":", "if", "mavutil", ".", "evaluate_expression", "(", "text", ",", "rline_mpstate", ".", "status", ".", "msgs", ")", "is", "not", "None", ":", "return", "[", "text", "+", "suffix", "]", "except", "Exception", "as", "ex", ":", "pass", "try", ":", "m1", "=", "re", ".", "match", "(", "\"^(.*?)([A-Z0-9][A-Z0-9_]*)[.]([A-Za-z0-9_]*)$\"", ",", "text", ")", "except", "Exception", "as", "ex", ":", "return", "[", "]", "if", "m1", "is", "not", "None", ":", "prefix", "=", "m1", ".", "group", "(", "1", ")", "mtype", "=", "m1", ".", "group", "(", "2", ")", "fname", "=", "m1", ".", "group", "(", "3", ")", "if", "mtype", "in", "rline_mpstate", ".", "status", ".", "msgs", ":", "ret", "=", "[", "]", "for", "f", "in", "rline_mpstate", ".", "status", ".", "msgs", "[", "mtype", "]", ".", "get_fieldnames", "(", ")", ":", "if", "f", ".", "startswith", "(", "fname", ")", ":", "ret", ".", "append", "(", "prefix", "+", "mtype", "+", "'.'", "+", "f", "+", "suffix", ")", "return", "ret", "return", "[", "]", "try", ":", "m2", "=", "re", ".", "match", "(", "\"^(.*?)([A-Z0-9][A-Z0-9_]*)$\"", ",", "text", ")", "except", "Exception", "as", "ex", ":", "return", "[", "]", "prefix", "=", "m2", ".", "group", "(", "1", ")", "mtype", "=", "m2", ".", "group", "(", "2", ")", "ret", "=", "[", "]", "for", "k", "in", "list", "(", "rline_mpstate", ".", "status", ".", "msgs", ".", "keys", "(", ")", ")", ":", "if", "k", ".", "startswith", "(", "mtype", ")", ":", "ret", ".", "append", "(", "prefix", "+", "k", "+", "suffix", ")", "return", "ret" ]
complete a MAVLink variable or expression
[ "complete", "a", "MAVLink", "variable", "or", "expression" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/rline.py#L94-L136
249,470
ArduPilot/MAVProxy
MAVProxy/modules/lib/rline.py
complete_rule
def complete_rule(rule, cmd): '''complete using one rule''' global rline_mpstate rule_components = rule.split(' ') # complete the empty string (e.g "graph <TAB><TAB>") if len(cmd) == 0: return rule_expand(rule_components[0], "") # check it matches so far for i in range(len(cmd)-1): if not rule_match(rule_components[i], cmd[i]): return [] # expand the next rule component expanded = rule_expand(rule_components[len(cmd)-1], cmd[-1]) return expanded
python
def complete_rule(rule, cmd): '''complete using one rule''' global rline_mpstate rule_components = rule.split(' ') # complete the empty string (e.g "graph <TAB><TAB>") if len(cmd) == 0: return rule_expand(rule_components[0], "") # check it matches so far for i in range(len(cmd)-1): if not rule_match(rule_components[i], cmd[i]): return [] # expand the next rule component expanded = rule_expand(rule_components[len(cmd)-1], cmd[-1]) return expanded
[ "def", "complete_rule", "(", "rule", ",", "cmd", ")", ":", "global", "rline_mpstate", "rule_components", "=", "rule", ".", "split", "(", "' '", ")", "# complete the empty string (e.g \"graph <TAB><TAB>\")", "if", "len", "(", "cmd", ")", "==", "0", ":", "return", "rule_expand", "(", "rule_components", "[", "0", "]", ",", "\"\"", ")", "# check it matches so far", "for", "i", "in", "range", "(", "len", "(", "cmd", ")", "-", "1", ")", ":", "if", "not", "rule_match", "(", "rule_components", "[", "i", "]", ",", "cmd", "[", "i", "]", ")", ":", "return", "[", "]", "# expand the next rule component", "expanded", "=", "rule_expand", "(", "rule_components", "[", "len", "(", "cmd", ")", "-", "1", "]", ",", "cmd", "[", "-", "1", "]", ")", "return", "expanded" ]
complete using one rule
[ "complete", "using", "one", "rule" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/rline.py#L156-L172
249,471
ArduPilot/MAVProxy
MAVProxy/modules/lib/wxhorizon_ui.py
HorizonFrame.createPlotPanel
def createPlotPanel(self): '''Creates the figure and axes for the plotting panel.''' self.figure = Figure() self.axes = self.figure.add_subplot(111) self.canvas = FigureCanvas(self,-1,self.figure) self.canvas.SetSize(wx.Size(300,300)) self.axes.axis('off') self.figure.subplots_adjust(left=0,right=1,top=1,bottom=0) self.sizer = wx.BoxSizer(wx.VERTICAL) self.sizer.Add(self.canvas,1,wx.EXPAND,wx.ALL) self.SetSizerAndFit(self.sizer) self.Fit()
python
def createPlotPanel(self): '''Creates the figure and axes for the plotting panel.''' self.figure = Figure() self.axes = self.figure.add_subplot(111) self.canvas = FigureCanvas(self,-1,self.figure) self.canvas.SetSize(wx.Size(300,300)) self.axes.axis('off') self.figure.subplots_adjust(left=0,right=1,top=1,bottom=0) self.sizer = wx.BoxSizer(wx.VERTICAL) self.sizer.Add(self.canvas,1,wx.EXPAND,wx.ALL) self.SetSizerAndFit(self.sizer) self.Fit()
[ "def", "createPlotPanel", "(", "self", ")", ":", "self", ".", "figure", "=", "Figure", "(", ")", "self", ".", "axes", "=", "self", ".", "figure", ".", "add_subplot", "(", "111", ")", "self", ".", "canvas", "=", "FigureCanvas", "(", "self", ",", "-", "1", ",", "self", ".", "figure", ")", "self", ".", "canvas", ".", "SetSize", "(", "wx", ".", "Size", "(", "300", ",", "300", ")", ")", "self", ".", "axes", ".", "axis", "(", "'off'", ")", "self", ".", "figure", ".", "subplots_adjust", "(", "left", "=", "0", ",", "right", "=", "1", ",", "top", "=", "1", ",", "bottom", "=", "0", ")", "self", ".", "sizer", "=", "wx", ".", "BoxSizer", "(", "wx", ".", "VERTICAL", ")", "self", ".", "sizer", ".", "Add", "(", "self", ".", "canvas", ",", "1", ",", "wx", ".", "EXPAND", ",", "wx", ".", "ALL", ")", "self", ".", "SetSizerAndFit", "(", "self", ".", "sizer", ")", "self", ".", "Fit", "(", ")" ]
Creates the figure and axes for the plotting panel.
[ "Creates", "the", "figure", "and", "axes", "for", "the", "plotting", "panel", "." ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/wxhorizon_ui.py#L135-L146
249,472
ArduPilot/MAVProxy
MAVProxy/modules/lib/wxhorizon_ui.py
HorizonFrame.rescaleX
def rescaleX(self): '''Rescales the horizontal axes to make the lengthscales equal.''' self.ratio = self.figure.get_size_inches()[0]/float(self.figure.get_size_inches()[1]) self.axes.set_xlim(-self.ratio,self.ratio) self.axes.set_ylim(-1,1)
python
def rescaleX(self): '''Rescales the horizontal axes to make the lengthscales equal.''' self.ratio = self.figure.get_size_inches()[0]/float(self.figure.get_size_inches()[1]) self.axes.set_xlim(-self.ratio,self.ratio) self.axes.set_ylim(-1,1)
[ "def", "rescaleX", "(", "self", ")", ":", "self", ".", "ratio", "=", "self", ".", "figure", ".", "get_size_inches", "(", ")", "[", "0", "]", "/", "float", "(", "self", ".", "figure", ".", "get_size_inches", "(", ")", "[", "1", "]", ")", "self", ".", "axes", ".", "set_xlim", "(", "-", "self", ".", "ratio", ",", "self", ".", "ratio", ")", "self", ".", "axes", ".", "set_ylim", "(", "-", "1", ",", "1", ")" ]
Rescales the horizontal axes to make the lengthscales equal.
[ "Rescales", "the", "horizontal", "axes", "to", "make", "the", "lengthscales", "equal", "." ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/wxhorizon_ui.py#L148-L152
249,473
ArduPilot/MAVProxy
MAVProxy/modules/lib/wxhorizon_ui.py
HorizonFrame.calcFontScaling
def calcFontScaling(self): '''Calculates the current font size and left position for the current window.''' self.ypx = self.figure.get_size_inches()[1]*self.figure.dpi self.xpx = self.figure.get_size_inches()[0]*self.figure.dpi self.fontSize = self.vertSize*(self.ypx/2.0) self.leftPos = self.axes.get_xlim()[0] self.rightPos = self.axes.get_xlim()[1]
python
def calcFontScaling(self): '''Calculates the current font size and left position for the current window.''' self.ypx = self.figure.get_size_inches()[1]*self.figure.dpi self.xpx = self.figure.get_size_inches()[0]*self.figure.dpi self.fontSize = self.vertSize*(self.ypx/2.0) self.leftPos = self.axes.get_xlim()[0] self.rightPos = self.axes.get_xlim()[1]
[ "def", "calcFontScaling", "(", "self", ")", ":", "self", ".", "ypx", "=", "self", ".", "figure", ".", "get_size_inches", "(", ")", "[", "1", "]", "*", "self", ".", "figure", ".", "dpi", "self", ".", "xpx", "=", "self", ".", "figure", ".", "get_size_inches", "(", ")", "[", "0", "]", "*", "self", ".", "figure", ".", "dpi", "self", ".", "fontSize", "=", "self", ".", "vertSize", "*", "(", "self", ".", "ypx", "/", "2.0", ")", "self", ".", "leftPos", "=", "self", ".", "axes", ".", "get_xlim", "(", ")", "[", "0", "]", "self", ".", "rightPos", "=", "self", ".", "axes", ".", "get_xlim", "(", ")", "[", "1", "]" ]
Calculates the current font size and left position for the current window.
[ "Calculates", "the", "current", "font", "size", "and", "left", "position", "for", "the", "current", "window", "." ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/wxhorizon_ui.py#L154-L160
249,474
ArduPilot/MAVProxy
MAVProxy/modules/lib/wxhorizon_ui.py
HorizonFrame.checkReszie
def checkReszie(self): '''Checks if the window was resized.''' if not self.resized: oldypx = self.ypx oldxpx = self.xpx self.ypx = self.figure.get_size_inches()[1]*self.figure.dpi self.xpx = self.figure.get_size_inches()[0]*self.figure.dpi if (oldypx != self.ypx) or (oldxpx != self.xpx): self.resized = True else: self.resized = False
python
def checkReszie(self): '''Checks if the window was resized.''' if not self.resized: oldypx = self.ypx oldxpx = self.xpx self.ypx = self.figure.get_size_inches()[1]*self.figure.dpi self.xpx = self.figure.get_size_inches()[0]*self.figure.dpi if (oldypx != self.ypx) or (oldxpx != self.xpx): self.resized = True else: self.resized = False
[ "def", "checkReszie", "(", "self", ")", ":", "if", "not", "self", ".", "resized", ":", "oldypx", "=", "self", ".", "ypx", "oldxpx", "=", "self", ".", "xpx", "self", ".", "ypx", "=", "self", ".", "figure", ".", "get_size_inches", "(", ")", "[", "1", "]", "*", "self", ".", "figure", ".", "dpi", "self", ".", "xpx", "=", "self", ".", "figure", ".", "get_size_inches", "(", ")", "[", "0", "]", "*", "self", ".", "figure", ".", "dpi", "if", "(", "oldypx", "!=", "self", ".", "ypx", ")", "or", "(", "oldxpx", "!=", "self", ".", "xpx", ")", ":", "self", ".", "resized", "=", "True", "else", ":", "self", ".", "resized", "=", "False" ]
Checks if the window was resized.
[ "Checks", "if", "the", "window", "was", "resized", "." ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/wxhorizon_ui.py#L162-L172
249,475
ArduPilot/MAVProxy
MAVProxy/modules/lib/wxhorizon_ui.py
HorizonFrame.createHeadingPointer
def createHeadingPointer(self): '''Creates the pointer for the current heading.''' self.headingTri = patches.RegularPolygon((0.0,0.80),3,0.05,color='k',zorder=4) self.axes.add_patch(self.headingTri) self.headingText = self.axes.text(0.0,0.675,'0',color='k',size=self.fontSize,horizontalalignment='center',verticalalignment='center',zorder=4)
python
def createHeadingPointer(self): '''Creates the pointer for the current heading.''' self.headingTri = patches.RegularPolygon((0.0,0.80),3,0.05,color='k',zorder=4) self.axes.add_patch(self.headingTri) self.headingText = self.axes.text(0.0,0.675,'0',color='k',size=self.fontSize,horizontalalignment='center',verticalalignment='center',zorder=4)
[ "def", "createHeadingPointer", "(", "self", ")", ":", "self", ".", "headingTri", "=", "patches", ".", "RegularPolygon", "(", "(", "0.0", ",", "0.80", ")", ",", "3", ",", "0.05", ",", "color", "=", "'k'", ",", "zorder", "=", "4", ")", "self", ".", "axes", ".", "add_patch", "(", "self", ".", "headingTri", ")", "self", ".", "headingText", "=", "self", ".", "axes", ".", "text", "(", "0.0", ",", "0.675", ",", "'0'", ",", "color", "=", "'k'", ",", "size", "=", "self", ".", "fontSize", ",", "horizontalalignment", "=", "'center'", ",", "verticalalignment", "=", "'center'", ",", "zorder", "=", "4", ")" ]
Creates the pointer for the current heading.
[ "Creates", "the", "pointer", "for", "the", "current", "heading", "." ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/wxhorizon_ui.py#L174-L178
249,476
ArduPilot/MAVProxy
MAVProxy/modules/lib/wxhorizon_ui.py
HorizonFrame.adjustHeadingPointer
def adjustHeadingPointer(self): '''Adjust the value of the heading pointer.''' self.headingText.set_text(str(self.heading)) self.headingText.set_size(self.fontSize)
python
def adjustHeadingPointer(self): '''Adjust the value of the heading pointer.''' self.headingText.set_text(str(self.heading)) self.headingText.set_size(self.fontSize)
[ "def", "adjustHeadingPointer", "(", "self", ")", ":", "self", ".", "headingText", ".", "set_text", "(", "str", "(", "self", ".", "heading", ")", ")", "self", ".", "headingText", ".", "set_size", "(", "self", ".", "fontSize", ")" ]
Adjust the value of the heading pointer.
[ "Adjust", "the", "value", "of", "the", "heading", "pointer", "." ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/wxhorizon_ui.py#L180-L183
249,477
ArduPilot/MAVProxy
MAVProxy/modules/lib/wxhorizon_ui.py
HorizonFrame.createNorthPointer
def createNorthPointer(self): '''Creates the north pointer relative to current heading.''' self.headingNorthTri = patches.RegularPolygon((0.0,0.80),3,0.05,color='k',zorder=4) self.axes.add_patch(self.headingNorthTri) self.headingNorthText = self.axes.text(0.0,0.675,'N',color='k',size=self.fontSize,horizontalalignment='center',verticalalignment='center',zorder=4)
python
def createNorthPointer(self): '''Creates the north pointer relative to current heading.''' self.headingNorthTri = patches.RegularPolygon((0.0,0.80),3,0.05,color='k',zorder=4) self.axes.add_patch(self.headingNorthTri) self.headingNorthText = self.axes.text(0.0,0.675,'N',color='k',size=self.fontSize,horizontalalignment='center',verticalalignment='center',zorder=4)
[ "def", "createNorthPointer", "(", "self", ")", ":", "self", ".", "headingNorthTri", "=", "patches", ".", "RegularPolygon", "(", "(", "0.0", ",", "0.80", ")", ",", "3", ",", "0.05", ",", "color", "=", "'k'", ",", "zorder", "=", "4", ")", "self", ".", "axes", ".", "add_patch", "(", "self", ".", "headingNorthTri", ")", "self", ".", "headingNorthText", "=", "self", ".", "axes", ".", "text", "(", "0.0", ",", "0.675", ",", "'N'", ",", "color", "=", "'k'", ",", "size", "=", "self", ".", "fontSize", ",", "horizontalalignment", "=", "'center'", ",", "verticalalignment", "=", "'center'", ",", "zorder", "=", "4", ")" ]
Creates the north pointer relative to current heading.
[ "Creates", "the", "north", "pointer", "relative", "to", "current", "heading", "." ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/wxhorizon_ui.py#L185-L189
249,478
ArduPilot/MAVProxy
MAVProxy/modules/lib/wxhorizon_ui.py
HorizonFrame.adjustNorthPointer
def adjustNorthPointer(self): '''Adjust the position and orientation of the north pointer.''' self.headingNorthText.set_size(self.fontSize) headingRotate = mpl.transforms.Affine2D().rotate_deg_around(0.0,0.0,self.heading)+self.axes.transData self.headingNorthText.set_transform(headingRotate) if (self.heading > 90) and (self.heading < 270): headRot = self.heading-180 else: headRot = self.heading self.headingNorthText.set_rotation(headRot) self.headingNorthTri.set_transform(headingRotate) # Adjust if overlapping with heading pointer if (self.heading <= 10.0) or (self.heading >= 350.0): self.headingNorthText.set_text('') else: self.headingNorthText.set_text('N')
python
def adjustNorthPointer(self): '''Adjust the position and orientation of the north pointer.''' self.headingNorthText.set_size(self.fontSize) headingRotate = mpl.transforms.Affine2D().rotate_deg_around(0.0,0.0,self.heading)+self.axes.transData self.headingNorthText.set_transform(headingRotate) if (self.heading > 90) and (self.heading < 270): headRot = self.heading-180 else: headRot = self.heading self.headingNorthText.set_rotation(headRot) self.headingNorthTri.set_transform(headingRotate) # Adjust if overlapping with heading pointer if (self.heading <= 10.0) or (self.heading >= 350.0): self.headingNorthText.set_text('') else: self.headingNorthText.set_text('N')
[ "def", "adjustNorthPointer", "(", "self", ")", ":", "self", ".", "headingNorthText", ".", "set_size", "(", "self", ".", "fontSize", ")", "headingRotate", "=", "mpl", ".", "transforms", ".", "Affine2D", "(", ")", ".", "rotate_deg_around", "(", "0.0", ",", "0.0", ",", "self", ".", "heading", ")", "+", "self", ".", "axes", ".", "transData", "self", ".", "headingNorthText", ".", "set_transform", "(", "headingRotate", ")", "if", "(", "self", ".", "heading", ">", "90", ")", "and", "(", "self", ".", "heading", "<", "270", ")", ":", "headRot", "=", "self", ".", "heading", "-", "180", "else", ":", "headRot", "=", "self", ".", "heading", "self", ".", "headingNorthText", ".", "set_rotation", "(", "headRot", ")", "self", ".", "headingNorthTri", ".", "set_transform", "(", "headingRotate", ")", "# Adjust if overlapping with heading pointer", "if", "(", "self", ".", "heading", "<=", "10.0", ")", "or", "(", "self", ".", "heading", ">=", "350.0", ")", ":", "self", ".", "headingNorthText", ".", "set_text", "(", "''", ")", "else", ":", "self", ".", "headingNorthText", ".", "set_text", "(", "'N'", ")" ]
Adjust the position and orientation of the north pointer.
[ "Adjust", "the", "position", "and", "orientation", "of", "the", "north", "pointer", "." ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/wxhorizon_ui.py#L191-L207
249,479
ArduPilot/MAVProxy
MAVProxy/modules/lib/wxhorizon_ui.py
HorizonFrame.createRPYText
def createRPYText(self): '''Creates the text for roll, pitch and yaw.''' self.rollText = self.axes.text(self.leftPos+(self.vertSize/10.0),-0.97+(2*self.vertSize)-(self.vertSize/10.0),'Roll: %.2f' % self.roll,color='w',size=self.fontSize) self.pitchText = self.axes.text(self.leftPos+(self.vertSize/10.0),-0.97+self.vertSize-(0.5*self.vertSize/10.0),'Pitch: %.2f' % self.pitch,color='w',size=self.fontSize) self.yawText = self.axes.text(self.leftPos+(self.vertSize/10.0),-0.97,'Yaw: %.2f' % self.yaw,color='w',size=self.fontSize) self.rollText.set_path_effects([PathEffects.withStroke(linewidth=1,foreground='k')]) self.pitchText.set_path_effects([PathEffects.withStroke(linewidth=1,foreground='k')]) self.yawText.set_path_effects([PathEffects.withStroke(linewidth=1,foreground='k')])
python
def createRPYText(self): '''Creates the text for roll, pitch and yaw.''' self.rollText = self.axes.text(self.leftPos+(self.vertSize/10.0),-0.97+(2*self.vertSize)-(self.vertSize/10.0),'Roll: %.2f' % self.roll,color='w',size=self.fontSize) self.pitchText = self.axes.text(self.leftPos+(self.vertSize/10.0),-0.97+self.vertSize-(0.5*self.vertSize/10.0),'Pitch: %.2f' % self.pitch,color='w',size=self.fontSize) self.yawText = self.axes.text(self.leftPos+(self.vertSize/10.0),-0.97,'Yaw: %.2f' % self.yaw,color='w',size=self.fontSize) self.rollText.set_path_effects([PathEffects.withStroke(linewidth=1,foreground='k')]) self.pitchText.set_path_effects([PathEffects.withStroke(linewidth=1,foreground='k')]) self.yawText.set_path_effects([PathEffects.withStroke(linewidth=1,foreground='k')])
[ "def", "createRPYText", "(", "self", ")", ":", "self", ".", "rollText", "=", "self", ".", "axes", ".", "text", "(", "self", ".", "leftPos", "+", "(", "self", ".", "vertSize", "/", "10.0", ")", ",", "-", "0.97", "+", "(", "2", "*", "self", ".", "vertSize", ")", "-", "(", "self", ".", "vertSize", "/", "10.0", ")", ",", "'Roll: %.2f'", "%", "self", ".", "roll", ",", "color", "=", "'w'", ",", "size", "=", "self", ".", "fontSize", ")", "self", ".", "pitchText", "=", "self", ".", "axes", ".", "text", "(", "self", ".", "leftPos", "+", "(", "self", ".", "vertSize", "/", "10.0", ")", ",", "-", "0.97", "+", "self", ".", "vertSize", "-", "(", "0.5", "*", "self", ".", "vertSize", "/", "10.0", ")", ",", "'Pitch: %.2f'", "%", "self", ".", "pitch", ",", "color", "=", "'w'", ",", "size", "=", "self", ".", "fontSize", ")", "self", ".", "yawText", "=", "self", ".", "axes", ".", "text", "(", "self", ".", "leftPos", "+", "(", "self", ".", "vertSize", "/", "10.0", ")", ",", "-", "0.97", ",", "'Yaw: %.2f'", "%", "self", ".", "yaw", ",", "color", "=", "'w'", ",", "size", "=", "self", ".", "fontSize", ")", "self", ".", "rollText", ".", "set_path_effects", "(", "[", "PathEffects", ".", "withStroke", "(", "linewidth", "=", "1", ",", "foreground", "=", "'k'", ")", "]", ")", "self", ".", "pitchText", ".", "set_path_effects", "(", "[", "PathEffects", ".", "withStroke", "(", "linewidth", "=", "1", ",", "foreground", "=", "'k'", ")", "]", ")", "self", ".", "yawText", ".", "set_path_effects", "(", "[", "PathEffects", ".", "withStroke", "(", "linewidth", "=", "1", ",", "foreground", "=", "'k'", ")", "]", ")" ]
Creates the text for roll, pitch and yaw.
[ "Creates", "the", "text", "for", "roll", "pitch", "and", "yaw", "." ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/wxhorizon_ui.py#L217-L224
249,480
ArduPilot/MAVProxy
MAVProxy/modules/lib/wxhorizon_ui.py
HorizonFrame.updateRPYLocations
def updateRPYLocations(self): '''Update the locations of roll, pitch, yaw text.''' # Locations self.rollText.set_position((self.leftPos+(self.vertSize/10.0),-0.97+(2*self.vertSize)-(self.vertSize/10.0))) self.pitchText.set_position((self.leftPos+(self.vertSize/10.0),-0.97+self.vertSize-(0.5*self.vertSize/10.0))) self.yawText.set_position((self.leftPos+(self.vertSize/10.0),-0.97)) # Font Size self.rollText.set_size(self.fontSize) self.pitchText.set_size(self.fontSize) self.yawText.set_size(self.fontSize)
python
def updateRPYLocations(self): '''Update the locations of roll, pitch, yaw text.''' # Locations self.rollText.set_position((self.leftPos+(self.vertSize/10.0),-0.97+(2*self.vertSize)-(self.vertSize/10.0))) self.pitchText.set_position((self.leftPos+(self.vertSize/10.0),-0.97+self.vertSize-(0.5*self.vertSize/10.0))) self.yawText.set_position((self.leftPos+(self.vertSize/10.0),-0.97)) # Font Size self.rollText.set_size(self.fontSize) self.pitchText.set_size(self.fontSize) self.yawText.set_size(self.fontSize)
[ "def", "updateRPYLocations", "(", "self", ")", ":", "# Locations", "self", ".", "rollText", ".", "set_position", "(", "(", "self", ".", "leftPos", "+", "(", "self", ".", "vertSize", "/", "10.0", ")", ",", "-", "0.97", "+", "(", "2", "*", "self", ".", "vertSize", ")", "-", "(", "self", ".", "vertSize", "/", "10.0", ")", ")", ")", "self", ".", "pitchText", ".", "set_position", "(", "(", "self", ".", "leftPos", "+", "(", "self", ".", "vertSize", "/", "10.0", ")", ",", "-", "0.97", "+", "self", ".", "vertSize", "-", "(", "0.5", "*", "self", ".", "vertSize", "/", "10.0", ")", ")", ")", "self", ".", "yawText", ".", "set_position", "(", "(", "self", ".", "leftPos", "+", "(", "self", ".", "vertSize", "/", "10.0", ")", ",", "-", "0.97", ")", ")", "# Font Size", "self", ".", "rollText", ".", "set_size", "(", "self", ".", "fontSize", ")", "self", ".", "pitchText", ".", "set_size", "(", "self", ".", "fontSize", ")", "self", ".", "yawText", ".", "set_size", "(", "self", ".", "fontSize", ")" ]
Update the locations of roll, pitch, yaw text.
[ "Update", "the", "locations", "of", "roll", "pitch", "yaw", "text", "." ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/wxhorizon_ui.py#L226-L235
249,481
ArduPilot/MAVProxy
MAVProxy/modules/lib/wxhorizon_ui.py
HorizonFrame.updateRPYText
def updateRPYText(self): 'Updates the displayed Roll, Pitch, Yaw Text' self.rollText.set_text('Roll: %.2f' % self.roll) self.pitchText.set_text('Pitch: %.2f' % self.pitch) self.yawText.set_text('Yaw: %.2f' % self.yaw)
python
def updateRPYText(self): 'Updates the displayed Roll, Pitch, Yaw Text' self.rollText.set_text('Roll: %.2f' % self.roll) self.pitchText.set_text('Pitch: %.2f' % self.pitch) self.yawText.set_text('Yaw: %.2f' % self.yaw)
[ "def", "updateRPYText", "(", "self", ")", ":", "self", ".", "rollText", ".", "set_text", "(", "'Roll: %.2f'", "%", "self", ".", "roll", ")", "self", ".", "pitchText", ".", "set_text", "(", "'Pitch: %.2f'", "%", "self", ".", "pitch", ")", "self", ".", "yawText", ".", "set_text", "(", "'Yaw: %.2f'", "%", "self", ".", "yaw", ")" ]
Updates the displayed Roll, Pitch, Yaw Text
[ "Updates", "the", "displayed", "Roll", "Pitch", "Yaw", "Text" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/wxhorizon_ui.py#L237-L241
249,482
ArduPilot/MAVProxy
MAVProxy/modules/lib/wxhorizon_ui.py
HorizonFrame.createCenterPointMarker
def createCenterPointMarker(self): '''Creates the center pointer in the middle of the screen.''' self.axes.add_patch(patches.Rectangle((-0.75,-self.thick),0.5,2.0*self.thick,facecolor='orange',zorder=3)) self.axes.add_patch(patches.Rectangle((0.25,-self.thick),0.5,2.0*self.thick,facecolor='orange',zorder=3)) self.axes.add_patch(patches.Circle((0,0),radius=self.thick,facecolor='orange',edgecolor='none',zorder=3))
python
def createCenterPointMarker(self): '''Creates the center pointer in the middle of the screen.''' self.axes.add_patch(patches.Rectangle((-0.75,-self.thick),0.5,2.0*self.thick,facecolor='orange',zorder=3)) self.axes.add_patch(patches.Rectangle((0.25,-self.thick),0.5,2.0*self.thick,facecolor='orange',zorder=3)) self.axes.add_patch(patches.Circle((0,0),radius=self.thick,facecolor='orange',edgecolor='none',zorder=3))
[ "def", "createCenterPointMarker", "(", "self", ")", ":", "self", ".", "axes", ".", "add_patch", "(", "patches", ".", "Rectangle", "(", "(", "-", "0.75", ",", "-", "self", ".", "thick", ")", ",", "0.5", ",", "2.0", "*", "self", ".", "thick", ",", "facecolor", "=", "'orange'", ",", "zorder", "=", "3", ")", ")", "self", ".", "axes", ".", "add_patch", "(", "patches", ".", "Rectangle", "(", "(", "0.25", ",", "-", "self", ".", "thick", ")", ",", "0.5", ",", "2.0", "*", "self", ".", "thick", ",", "facecolor", "=", "'orange'", ",", "zorder", "=", "3", ")", ")", "self", ".", "axes", ".", "add_patch", "(", "patches", ".", "Circle", "(", "(", "0", ",", "0", ")", ",", "radius", "=", "self", ".", "thick", ",", "facecolor", "=", "'orange'", ",", "edgecolor", "=", "'none'", ",", "zorder", "=", "3", ")", ")" ]
Creates the center pointer in the middle of the screen.
[ "Creates", "the", "center", "pointer", "in", "the", "middle", "of", "the", "screen", "." ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/wxhorizon_ui.py#L243-L247
249,483
ArduPilot/MAVProxy
MAVProxy/modules/lib/wxhorizon_ui.py
HorizonFrame.createHorizonPolygons
def createHorizonPolygons(self): '''Creates the two polygons to show the sky and ground.''' # Sky Polygon vertsTop = [[-1,0],[-1,1],[1,1],[1,0],[-1,0]] self.topPolygon = Polygon(vertsTop,facecolor='dodgerblue',edgecolor='none') self.axes.add_patch(self.topPolygon) # Ground Polygon vertsBot = [[-1,0],[-1,-1],[1,-1],[1,0],[-1,0]] self.botPolygon = Polygon(vertsBot,facecolor='brown',edgecolor='none') self.axes.add_patch(self.botPolygon)
python
def createHorizonPolygons(self): '''Creates the two polygons to show the sky and ground.''' # Sky Polygon vertsTop = [[-1,0],[-1,1],[1,1],[1,0],[-1,0]] self.topPolygon = Polygon(vertsTop,facecolor='dodgerblue',edgecolor='none') self.axes.add_patch(self.topPolygon) # Ground Polygon vertsBot = [[-1,0],[-1,-1],[1,-1],[1,0],[-1,0]] self.botPolygon = Polygon(vertsBot,facecolor='brown',edgecolor='none') self.axes.add_patch(self.botPolygon)
[ "def", "createHorizonPolygons", "(", "self", ")", ":", "# Sky Polygon", "vertsTop", "=", "[", "[", "-", "1", ",", "0", "]", ",", "[", "-", "1", ",", "1", "]", ",", "[", "1", ",", "1", "]", ",", "[", "1", ",", "0", "]", ",", "[", "-", "1", ",", "0", "]", "]", "self", ".", "topPolygon", "=", "Polygon", "(", "vertsTop", ",", "facecolor", "=", "'dodgerblue'", ",", "edgecolor", "=", "'none'", ")", "self", ".", "axes", ".", "add_patch", "(", "self", ".", "topPolygon", ")", "# Ground Polygon", "vertsBot", "=", "[", "[", "-", "1", ",", "0", "]", ",", "[", "-", "1", ",", "-", "1", "]", ",", "[", "1", ",", "-", "1", "]", ",", "[", "1", ",", "0", "]", ",", "[", "-", "1", ",", "0", "]", "]", "self", ".", "botPolygon", "=", "Polygon", "(", "vertsBot", ",", "facecolor", "=", "'brown'", ",", "edgecolor", "=", "'none'", ")", "self", ".", "axes", ".", "add_patch", "(", "self", ".", "botPolygon", ")" ]
Creates the two polygons to show the sky and ground.
[ "Creates", "the", "two", "polygons", "to", "show", "the", "sky", "and", "ground", "." ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/wxhorizon_ui.py#L249-L258
249,484
ArduPilot/MAVProxy
MAVProxy/modules/lib/wxhorizon_ui.py
HorizonFrame.calcHorizonPoints
def calcHorizonPoints(self): '''Updates the verticies of the patches for the ground and sky.''' ydiff = math.tan(math.radians(-self.roll))*float(self.ratio) pitchdiff = self.dist10deg*(self.pitch/10.0) # Sky Polygon vertsTop = [(-self.ratio,ydiff-pitchdiff),(-self.ratio,1),(self.ratio,1),(self.ratio,-ydiff-pitchdiff),(-self.ratio,ydiff-pitchdiff)] self.topPolygon.set_xy(vertsTop) # Ground Polygon vertsBot = [(-self.ratio,ydiff-pitchdiff),(-self.ratio,-1),(self.ratio,-1),(self.ratio,-ydiff-pitchdiff),(-self.ratio,ydiff-pitchdiff)] self.botPolygon.set_xy(vertsBot)
python
def calcHorizonPoints(self): '''Updates the verticies of the patches for the ground and sky.''' ydiff = math.tan(math.radians(-self.roll))*float(self.ratio) pitchdiff = self.dist10deg*(self.pitch/10.0) # Sky Polygon vertsTop = [(-self.ratio,ydiff-pitchdiff),(-self.ratio,1),(self.ratio,1),(self.ratio,-ydiff-pitchdiff),(-self.ratio,ydiff-pitchdiff)] self.topPolygon.set_xy(vertsTop) # Ground Polygon vertsBot = [(-self.ratio,ydiff-pitchdiff),(-self.ratio,-1),(self.ratio,-1),(self.ratio,-ydiff-pitchdiff),(-self.ratio,ydiff-pitchdiff)] self.botPolygon.set_xy(vertsBot)
[ "def", "calcHorizonPoints", "(", "self", ")", ":", "ydiff", "=", "math", ".", "tan", "(", "math", ".", "radians", "(", "-", "self", ".", "roll", ")", ")", "*", "float", "(", "self", ".", "ratio", ")", "pitchdiff", "=", "self", ".", "dist10deg", "*", "(", "self", ".", "pitch", "/", "10.0", ")", "# Sky Polygon", "vertsTop", "=", "[", "(", "-", "self", ".", "ratio", ",", "ydiff", "-", "pitchdiff", ")", ",", "(", "-", "self", ".", "ratio", ",", "1", ")", ",", "(", "self", ".", "ratio", ",", "1", ")", ",", "(", "self", ".", "ratio", ",", "-", "ydiff", "-", "pitchdiff", ")", ",", "(", "-", "self", ".", "ratio", ",", "ydiff", "-", "pitchdiff", ")", "]", "self", ".", "topPolygon", ".", "set_xy", "(", "vertsTop", ")", "# Ground Polygon", "vertsBot", "=", "[", "(", "-", "self", ".", "ratio", ",", "ydiff", "-", "pitchdiff", ")", ",", "(", "-", "self", ".", "ratio", ",", "-", "1", ")", ",", "(", "self", ".", "ratio", ",", "-", "1", ")", ",", "(", "self", ".", "ratio", ",", "-", "ydiff", "-", "pitchdiff", ")", ",", "(", "-", "self", ".", "ratio", ",", "ydiff", "-", "pitchdiff", ")", "]", "self", ".", "botPolygon", ".", "set_xy", "(", "vertsBot", ")" ]
Updates the verticies of the patches for the ground and sky.
[ "Updates", "the", "verticies", "of", "the", "patches", "for", "the", "ground", "and", "sky", "." ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/wxhorizon_ui.py#L260-L269
249,485
ArduPilot/MAVProxy
MAVProxy/modules/lib/wxhorizon_ui.py
HorizonFrame.createPitchMarkers
def createPitchMarkers(self): '''Creates the rectangle patches for the pitch indicators.''' self.pitchPatches = [] # Major Lines (multiple of 10 deg) for i in [-9,-8,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7,8,9]: width = self.calcPitchMarkerWidth(i) currPatch = patches.Rectangle((-width/2.0,self.dist10deg*i-(self.thick/2.0)),width,self.thick,facecolor='w',edgecolor='none') self.axes.add_patch(currPatch) self.pitchPatches.append(currPatch) # Add Label for +-30 deg self.vertSize = 0.09 self.pitchLabelsLeft = [] self.pitchLabelsRight = [] i=0 for j in [-90,-60,-30,30,60,90]: self.pitchLabelsLeft.append(self.axes.text(-0.55,(j/10.0)*self.dist10deg,str(j),color='w',size=self.fontSize,horizontalalignment='center',verticalalignment='center')) self.pitchLabelsLeft[i].set_path_effects([PathEffects.withStroke(linewidth=1,foreground='k')]) self.pitchLabelsRight.append(self.axes.text(0.55,(j/10.0)*self.dist10deg,str(j),color='w',size=self.fontSize,horizontalalignment='center',verticalalignment='center')) self.pitchLabelsRight[i].set_path_effects([PathEffects.withStroke(linewidth=1,foreground='k')]) i += 1
python
def createPitchMarkers(self): '''Creates the rectangle patches for the pitch indicators.''' self.pitchPatches = [] # Major Lines (multiple of 10 deg) for i in [-9,-8,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7,8,9]: width = self.calcPitchMarkerWidth(i) currPatch = patches.Rectangle((-width/2.0,self.dist10deg*i-(self.thick/2.0)),width,self.thick,facecolor='w',edgecolor='none') self.axes.add_patch(currPatch) self.pitchPatches.append(currPatch) # Add Label for +-30 deg self.vertSize = 0.09 self.pitchLabelsLeft = [] self.pitchLabelsRight = [] i=0 for j in [-90,-60,-30,30,60,90]: self.pitchLabelsLeft.append(self.axes.text(-0.55,(j/10.0)*self.dist10deg,str(j),color='w',size=self.fontSize,horizontalalignment='center',verticalalignment='center')) self.pitchLabelsLeft[i].set_path_effects([PathEffects.withStroke(linewidth=1,foreground='k')]) self.pitchLabelsRight.append(self.axes.text(0.55,(j/10.0)*self.dist10deg,str(j),color='w',size=self.fontSize,horizontalalignment='center',verticalalignment='center')) self.pitchLabelsRight[i].set_path_effects([PathEffects.withStroke(linewidth=1,foreground='k')]) i += 1
[ "def", "createPitchMarkers", "(", "self", ")", ":", "self", ".", "pitchPatches", "=", "[", "]", "# Major Lines (multiple of 10 deg)", "for", "i", "in", "[", "-", "9", ",", "-", "8", ",", "-", "7", ",", "-", "6", ",", "-", "5", ",", "-", "4", ",", "-", "3", ",", "-", "2", ",", "-", "1", ",", "0", ",", "1", ",", "2", ",", "3", ",", "4", ",", "5", ",", "6", ",", "7", ",", "8", ",", "9", "]", ":", "width", "=", "self", ".", "calcPitchMarkerWidth", "(", "i", ")", "currPatch", "=", "patches", ".", "Rectangle", "(", "(", "-", "width", "/", "2.0", ",", "self", ".", "dist10deg", "*", "i", "-", "(", "self", ".", "thick", "/", "2.0", ")", ")", ",", "width", ",", "self", ".", "thick", ",", "facecolor", "=", "'w'", ",", "edgecolor", "=", "'none'", ")", "self", ".", "axes", ".", "add_patch", "(", "currPatch", ")", "self", ".", "pitchPatches", ".", "append", "(", "currPatch", ")", "# Add Label for +-30 deg", "self", ".", "vertSize", "=", "0.09", "self", ".", "pitchLabelsLeft", "=", "[", "]", "self", ".", "pitchLabelsRight", "=", "[", "]", "i", "=", "0", "for", "j", "in", "[", "-", "90", ",", "-", "60", ",", "-", "30", ",", "30", ",", "60", ",", "90", "]", ":", "self", ".", "pitchLabelsLeft", ".", "append", "(", "self", ".", "axes", ".", "text", "(", "-", "0.55", ",", "(", "j", "/", "10.0", ")", "*", "self", ".", "dist10deg", ",", "str", "(", "j", ")", ",", "color", "=", "'w'", ",", "size", "=", "self", ".", "fontSize", ",", "horizontalalignment", "=", "'center'", ",", "verticalalignment", "=", "'center'", ")", ")", "self", ".", "pitchLabelsLeft", "[", "i", "]", ".", "set_path_effects", "(", "[", "PathEffects", ".", "withStroke", "(", "linewidth", "=", "1", ",", "foreground", "=", "'k'", ")", "]", ")", "self", ".", "pitchLabelsRight", ".", "append", "(", "self", ".", "axes", ".", "text", "(", "0.55", ",", "(", "j", "/", "10.0", ")", "*", "self", ".", "dist10deg", ",", "str", "(", "j", ")", ",", "color", "=", "'w'", ",", "size", "=", "self", ".", "fontSize", ",", "horizontalalignment", "=", "'center'", ",", "verticalalignment", "=", "'center'", ")", ")", "self", ".", "pitchLabelsRight", "[", "i", "]", ".", "set_path_effects", "(", "[", "PathEffects", ".", "withStroke", "(", "linewidth", "=", "1", ",", "foreground", "=", "'k'", ")", "]", ")", "i", "+=", "1" ]
Creates the rectangle patches for the pitch indicators.
[ "Creates", "the", "rectangle", "patches", "for", "the", "pitch", "indicators", "." ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/wxhorizon_ui.py#L271-L290
249,486
ArduPilot/MAVProxy
MAVProxy/modules/lib/wxhorizon_ui.py
HorizonFrame.adjustPitchmarkers
def adjustPitchmarkers(self): '''Adjusts the location and orientation of pitch markers.''' pitchdiff = self.dist10deg*(self.pitch/10.0) rollRotate = mpl.transforms.Affine2D().rotate_deg_around(0.0,-pitchdiff,self.roll)+self.axes.transData j=0 for i in [-9,-8,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7,8,9]: width = self.calcPitchMarkerWidth(i) self.pitchPatches[j].set_xy((-width/2.0,self.dist10deg*i-(self.thick/2.0)-pitchdiff)) self.pitchPatches[j].set_transform(rollRotate) j+=1 # Adjust Text Size and rotation i=0 for j in [-9,-6,-3,3,6,9]: self.pitchLabelsLeft[i].set_y(j*self.dist10deg-pitchdiff) self.pitchLabelsRight[i].set_y(j*self.dist10deg-pitchdiff) self.pitchLabelsLeft[i].set_size(self.fontSize) self.pitchLabelsRight[i].set_size(self.fontSize) self.pitchLabelsLeft[i].set_rotation(self.roll) self.pitchLabelsRight[i].set_rotation(self.roll) self.pitchLabelsLeft[i].set_transform(rollRotate) self.pitchLabelsRight[i].set_transform(rollRotate) i += 1
python
def adjustPitchmarkers(self): '''Adjusts the location and orientation of pitch markers.''' pitchdiff = self.dist10deg*(self.pitch/10.0) rollRotate = mpl.transforms.Affine2D().rotate_deg_around(0.0,-pitchdiff,self.roll)+self.axes.transData j=0 for i in [-9,-8,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7,8,9]: width = self.calcPitchMarkerWidth(i) self.pitchPatches[j].set_xy((-width/2.0,self.dist10deg*i-(self.thick/2.0)-pitchdiff)) self.pitchPatches[j].set_transform(rollRotate) j+=1 # Adjust Text Size and rotation i=0 for j in [-9,-6,-3,3,6,9]: self.pitchLabelsLeft[i].set_y(j*self.dist10deg-pitchdiff) self.pitchLabelsRight[i].set_y(j*self.dist10deg-pitchdiff) self.pitchLabelsLeft[i].set_size(self.fontSize) self.pitchLabelsRight[i].set_size(self.fontSize) self.pitchLabelsLeft[i].set_rotation(self.roll) self.pitchLabelsRight[i].set_rotation(self.roll) self.pitchLabelsLeft[i].set_transform(rollRotate) self.pitchLabelsRight[i].set_transform(rollRotate) i += 1
[ "def", "adjustPitchmarkers", "(", "self", ")", ":", "pitchdiff", "=", "self", ".", "dist10deg", "*", "(", "self", ".", "pitch", "/", "10.0", ")", "rollRotate", "=", "mpl", ".", "transforms", ".", "Affine2D", "(", ")", ".", "rotate_deg_around", "(", "0.0", ",", "-", "pitchdiff", ",", "self", ".", "roll", ")", "+", "self", ".", "axes", ".", "transData", "j", "=", "0", "for", "i", "in", "[", "-", "9", ",", "-", "8", ",", "-", "7", ",", "-", "6", ",", "-", "5", ",", "-", "4", ",", "-", "3", ",", "-", "2", ",", "-", "1", ",", "0", ",", "1", ",", "2", ",", "3", ",", "4", ",", "5", ",", "6", ",", "7", ",", "8", ",", "9", "]", ":", "width", "=", "self", ".", "calcPitchMarkerWidth", "(", "i", ")", "self", ".", "pitchPatches", "[", "j", "]", ".", "set_xy", "(", "(", "-", "width", "/", "2.0", ",", "self", ".", "dist10deg", "*", "i", "-", "(", "self", ".", "thick", "/", "2.0", ")", "-", "pitchdiff", ")", ")", "self", ".", "pitchPatches", "[", "j", "]", ".", "set_transform", "(", "rollRotate", ")", "j", "+=", "1", "# Adjust Text Size and rotation", "i", "=", "0", "for", "j", "in", "[", "-", "9", ",", "-", "6", ",", "-", "3", ",", "3", ",", "6", ",", "9", "]", ":", "self", ".", "pitchLabelsLeft", "[", "i", "]", ".", "set_y", "(", "j", "*", "self", ".", "dist10deg", "-", "pitchdiff", ")", "self", ".", "pitchLabelsRight", "[", "i", "]", ".", "set_y", "(", "j", "*", "self", ".", "dist10deg", "-", "pitchdiff", ")", "self", ".", "pitchLabelsLeft", "[", "i", "]", ".", "set_size", "(", "self", ".", "fontSize", ")", "self", ".", "pitchLabelsRight", "[", "i", "]", ".", "set_size", "(", "self", ".", "fontSize", ")", "self", ".", "pitchLabelsLeft", "[", "i", "]", ".", "set_rotation", "(", "self", ".", "roll", ")", "self", ".", "pitchLabelsRight", "[", "i", "]", ".", "set_rotation", "(", "self", ".", "roll", ")", "self", ".", "pitchLabelsLeft", "[", "i", "]", ".", "set_transform", "(", "rollRotate", ")", "self", ".", "pitchLabelsRight", "[", "i", "]", ".", "set_transform", "(", "rollRotate", ")", "i", "+=", "1" ]
Adjusts the location and orientation of pitch markers.
[ "Adjusts", "the", "location", "and", "orientation", "of", "pitch", "markers", "." ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/wxhorizon_ui.py#L304-L325
249,487
ArduPilot/MAVProxy
MAVProxy/modules/lib/wxhorizon_ui.py
HorizonFrame.createAARText
def createAARText(self): '''Creates the text for airspeed, altitude and climb rate.''' self.airspeedText = self.axes.text(self.rightPos-(self.vertSize/10.0),-0.97+(2*self.vertSize)-(self.vertSize/10.0),'AS: %.1f m/s' % self.airspeed,color='w',size=self.fontSize,ha='right') self.altitudeText = self.axes.text(self.rightPos-(self.vertSize/10.0),-0.97+self.vertSize-(0.5*self.vertSize/10.0),'ALT: %.1f m ' % self.relAlt,color='w',size=self.fontSize,ha='right') self.climbRateText = self.axes.text(self.rightPos-(self.vertSize/10.0),-0.97,'CR: %.1f m/s' % self.climbRate,color='w',size=self.fontSize,ha='right') self.airspeedText.set_path_effects([PathEffects.withStroke(linewidth=1,foreground='k')]) self.altitudeText.set_path_effects([PathEffects.withStroke(linewidth=1,foreground='k')]) self.climbRateText.set_path_effects([PathEffects.withStroke(linewidth=1,foreground='k')])
python
def createAARText(self): '''Creates the text for airspeed, altitude and climb rate.''' self.airspeedText = self.axes.text(self.rightPos-(self.vertSize/10.0),-0.97+(2*self.vertSize)-(self.vertSize/10.0),'AS: %.1f m/s' % self.airspeed,color='w',size=self.fontSize,ha='right') self.altitudeText = self.axes.text(self.rightPos-(self.vertSize/10.0),-0.97+self.vertSize-(0.5*self.vertSize/10.0),'ALT: %.1f m ' % self.relAlt,color='w',size=self.fontSize,ha='right') self.climbRateText = self.axes.text(self.rightPos-(self.vertSize/10.0),-0.97,'CR: %.1f m/s' % self.climbRate,color='w',size=self.fontSize,ha='right') self.airspeedText.set_path_effects([PathEffects.withStroke(linewidth=1,foreground='k')]) self.altitudeText.set_path_effects([PathEffects.withStroke(linewidth=1,foreground='k')]) self.climbRateText.set_path_effects([PathEffects.withStroke(linewidth=1,foreground='k')])
[ "def", "createAARText", "(", "self", ")", ":", "self", ".", "airspeedText", "=", "self", ".", "axes", ".", "text", "(", "self", ".", "rightPos", "-", "(", "self", ".", "vertSize", "/", "10.0", ")", ",", "-", "0.97", "+", "(", "2", "*", "self", ".", "vertSize", ")", "-", "(", "self", ".", "vertSize", "/", "10.0", ")", ",", "'AS: %.1f m/s'", "%", "self", ".", "airspeed", ",", "color", "=", "'w'", ",", "size", "=", "self", ".", "fontSize", ",", "ha", "=", "'right'", ")", "self", ".", "altitudeText", "=", "self", ".", "axes", ".", "text", "(", "self", ".", "rightPos", "-", "(", "self", ".", "vertSize", "/", "10.0", ")", ",", "-", "0.97", "+", "self", ".", "vertSize", "-", "(", "0.5", "*", "self", ".", "vertSize", "/", "10.0", ")", ",", "'ALT: %.1f m '", "%", "self", ".", "relAlt", ",", "color", "=", "'w'", ",", "size", "=", "self", ".", "fontSize", ",", "ha", "=", "'right'", ")", "self", ".", "climbRateText", "=", "self", ".", "axes", ".", "text", "(", "self", ".", "rightPos", "-", "(", "self", ".", "vertSize", "/", "10.0", ")", ",", "-", "0.97", ",", "'CR: %.1f m/s'", "%", "self", ".", "climbRate", ",", "color", "=", "'w'", ",", "size", "=", "self", ".", "fontSize", ",", "ha", "=", "'right'", ")", "self", ".", "airspeedText", ".", "set_path_effects", "(", "[", "PathEffects", ".", "withStroke", "(", "linewidth", "=", "1", ",", "foreground", "=", "'k'", ")", "]", ")", "self", ".", "altitudeText", ".", "set_path_effects", "(", "[", "PathEffects", ".", "withStroke", "(", "linewidth", "=", "1", ",", "foreground", "=", "'k'", ")", "]", ")", "self", ".", "climbRateText", ".", "set_path_effects", "(", "[", "PathEffects", ".", "withStroke", "(", "linewidth", "=", "1", ",", "foreground", "=", "'k'", ")", "]", ")" ]
Creates the text for airspeed, altitude and climb rate.
[ "Creates", "the", "text", "for", "airspeed", "altitude", "and", "climb", "rate", "." ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/wxhorizon_ui.py#L327-L334
249,488
ArduPilot/MAVProxy
MAVProxy/modules/lib/wxhorizon_ui.py
HorizonFrame.updateAARLocations
def updateAARLocations(self): '''Update the locations of airspeed, altitude and Climb rate.''' # Locations self.airspeedText.set_position((self.rightPos-(self.vertSize/10.0),-0.97+(2*self.vertSize)-(self.vertSize/10.0))) self.altitudeText.set_position((self.rightPos-(self.vertSize/10.0),-0.97+self.vertSize-(0.5*self.vertSize/10.0))) self.climbRateText.set_position((self.rightPos-(self.vertSize/10.0),-0.97)) # Font Size self.airspeedText.set_size(self.fontSize) self.altitudeText.set_size(self.fontSize) self.climbRateText.set_size(self.fontSize)
python
def updateAARLocations(self): '''Update the locations of airspeed, altitude and Climb rate.''' # Locations self.airspeedText.set_position((self.rightPos-(self.vertSize/10.0),-0.97+(2*self.vertSize)-(self.vertSize/10.0))) self.altitudeText.set_position((self.rightPos-(self.vertSize/10.0),-0.97+self.vertSize-(0.5*self.vertSize/10.0))) self.climbRateText.set_position((self.rightPos-(self.vertSize/10.0),-0.97)) # Font Size self.airspeedText.set_size(self.fontSize) self.altitudeText.set_size(self.fontSize) self.climbRateText.set_size(self.fontSize)
[ "def", "updateAARLocations", "(", "self", ")", ":", "# Locations", "self", ".", "airspeedText", ".", "set_position", "(", "(", "self", ".", "rightPos", "-", "(", "self", ".", "vertSize", "/", "10.0", ")", ",", "-", "0.97", "+", "(", "2", "*", "self", ".", "vertSize", ")", "-", "(", "self", ".", "vertSize", "/", "10.0", ")", ")", ")", "self", ".", "altitudeText", ".", "set_position", "(", "(", "self", ".", "rightPos", "-", "(", "self", ".", "vertSize", "/", "10.0", ")", ",", "-", "0.97", "+", "self", ".", "vertSize", "-", "(", "0.5", "*", "self", ".", "vertSize", "/", "10.0", ")", ")", ")", "self", ".", "climbRateText", ".", "set_position", "(", "(", "self", ".", "rightPos", "-", "(", "self", ".", "vertSize", "/", "10.0", ")", ",", "-", "0.97", ")", ")", "# Font Size", "self", ".", "airspeedText", ".", "set_size", "(", "self", ".", "fontSize", ")", "self", ".", "altitudeText", ".", "set_size", "(", "self", ".", "fontSize", ")", "self", ".", "climbRateText", ".", "set_size", "(", "self", ".", "fontSize", ")" ]
Update the locations of airspeed, altitude and Climb rate.
[ "Update", "the", "locations", "of", "airspeed", "altitude", "and", "Climb", "rate", "." ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/wxhorizon_ui.py#L336-L345
249,489
ArduPilot/MAVProxy
MAVProxy/modules/lib/wxhorizon_ui.py
HorizonFrame.updateAARText
def updateAARText(self): 'Updates the displayed airspeed, altitude, climb rate Text' self.airspeedText.set_text('AR: %.1f m/s' % self.airspeed) self.altitudeText.set_text('ALT: %.1f m ' % self.relAlt) self.climbRateText.set_text('CR: %.1f m/s' % self.climbRate)
python
def updateAARText(self): 'Updates the displayed airspeed, altitude, climb rate Text' self.airspeedText.set_text('AR: %.1f m/s' % self.airspeed) self.altitudeText.set_text('ALT: %.1f m ' % self.relAlt) self.climbRateText.set_text('CR: %.1f m/s' % self.climbRate)
[ "def", "updateAARText", "(", "self", ")", ":", "self", ".", "airspeedText", ".", "set_text", "(", "'AR: %.1f m/s'", "%", "self", ".", "airspeed", ")", "self", ".", "altitudeText", ".", "set_text", "(", "'ALT: %.1f m '", "%", "self", ".", "relAlt", ")", "self", ".", "climbRateText", ".", "set_text", "(", "'CR: %.1f m/s'", "%", "self", ".", "climbRate", ")" ]
Updates the displayed airspeed, altitude, climb rate Text
[ "Updates", "the", "displayed", "airspeed", "altitude", "climb", "rate", "Text" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/wxhorizon_ui.py#L347-L351
249,490
ArduPilot/MAVProxy
MAVProxy/modules/lib/wxhorizon_ui.py
HorizonFrame.createBatteryBar
def createBatteryBar(self): '''Creates the bar to display current battery percentage.''' self.batOutRec = patches.Rectangle((self.rightPos-(1.3+self.rOffset)*self.batWidth,1.0-(0.1+1.0+(2*0.075))*self.batHeight),self.batWidth*1.3,self.batHeight*1.15,facecolor='darkgrey',edgecolor='none') self.batInRec = patches.Rectangle((self.rightPos-(self.rOffset+1+0.15)*self.batWidth,1.0-(0.1+1+0.075)*self.batHeight),self.batWidth,self.batHeight,facecolor='lawngreen',edgecolor='none') self.batPerText = self.axes.text(self.rightPos - (self.rOffset+0.65)*self.batWidth,1-(0.1+1+(0.075+0.15))*self.batHeight,'%.f' % self.batRemain,color='w',size=self.fontSize,ha='center',va='top') self.batPerText.set_path_effects([PathEffects.withStroke(linewidth=1,foreground='k')]) self.voltsText = self.axes.text(self.rightPos-(self.rOffset+1.3+0.2)*self.batWidth,1-(0.1+0.05+0.075)*self.batHeight,'%.1f V' % self.voltage,color='w',size=self.fontSize,ha='right',va='top') self.ampsText = self.axes.text(self.rightPos-(self.rOffset+1.3+0.2)*self.batWidth,1-self.vertSize-(0.1+0.05+0.1+0.075)*self.batHeight,'%.1f A' % self.current,color='w',size=self.fontSize,ha='right',va='top') self.voltsText.set_path_effects([PathEffects.withStroke(linewidth=1,foreground='k')]) self.ampsText.set_path_effects([PathEffects.withStroke(linewidth=1,foreground='k')]) self.axes.add_patch(self.batOutRec) self.axes.add_patch(self.batInRec)
python
def createBatteryBar(self): '''Creates the bar to display current battery percentage.''' self.batOutRec = patches.Rectangle((self.rightPos-(1.3+self.rOffset)*self.batWidth,1.0-(0.1+1.0+(2*0.075))*self.batHeight),self.batWidth*1.3,self.batHeight*1.15,facecolor='darkgrey',edgecolor='none') self.batInRec = patches.Rectangle((self.rightPos-(self.rOffset+1+0.15)*self.batWidth,1.0-(0.1+1+0.075)*self.batHeight),self.batWidth,self.batHeight,facecolor='lawngreen',edgecolor='none') self.batPerText = self.axes.text(self.rightPos - (self.rOffset+0.65)*self.batWidth,1-(0.1+1+(0.075+0.15))*self.batHeight,'%.f' % self.batRemain,color='w',size=self.fontSize,ha='center',va='top') self.batPerText.set_path_effects([PathEffects.withStroke(linewidth=1,foreground='k')]) self.voltsText = self.axes.text(self.rightPos-(self.rOffset+1.3+0.2)*self.batWidth,1-(0.1+0.05+0.075)*self.batHeight,'%.1f V' % self.voltage,color='w',size=self.fontSize,ha='right',va='top') self.ampsText = self.axes.text(self.rightPos-(self.rOffset+1.3+0.2)*self.batWidth,1-self.vertSize-(0.1+0.05+0.1+0.075)*self.batHeight,'%.1f A' % self.current,color='w',size=self.fontSize,ha='right',va='top') self.voltsText.set_path_effects([PathEffects.withStroke(linewidth=1,foreground='k')]) self.ampsText.set_path_effects([PathEffects.withStroke(linewidth=1,foreground='k')]) self.axes.add_patch(self.batOutRec) self.axes.add_patch(self.batInRec)
[ "def", "createBatteryBar", "(", "self", ")", ":", "self", ".", "batOutRec", "=", "patches", ".", "Rectangle", "(", "(", "self", ".", "rightPos", "-", "(", "1.3", "+", "self", ".", "rOffset", ")", "*", "self", ".", "batWidth", ",", "1.0", "-", "(", "0.1", "+", "1.0", "+", "(", "2", "*", "0.075", ")", ")", "*", "self", ".", "batHeight", ")", ",", "self", ".", "batWidth", "*", "1.3", ",", "self", ".", "batHeight", "*", "1.15", ",", "facecolor", "=", "'darkgrey'", ",", "edgecolor", "=", "'none'", ")", "self", ".", "batInRec", "=", "patches", ".", "Rectangle", "(", "(", "self", ".", "rightPos", "-", "(", "self", ".", "rOffset", "+", "1", "+", "0.15", ")", "*", "self", ".", "batWidth", ",", "1.0", "-", "(", "0.1", "+", "1", "+", "0.075", ")", "*", "self", ".", "batHeight", ")", ",", "self", ".", "batWidth", ",", "self", ".", "batHeight", ",", "facecolor", "=", "'lawngreen'", ",", "edgecolor", "=", "'none'", ")", "self", ".", "batPerText", "=", "self", ".", "axes", ".", "text", "(", "self", ".", "rightPos", "-", "(", "self", ".", "rOffset", "+", "0.65", ")", "*", "self", ".", "batWidth", ",", "1", "-", "(", "0.1", "+", "1", "+", "(", "0.075", "+", "0.15", ")", ")", "*", "self", ".", "batHeight", ",", "'%.f'", "%", "self", ".", "batRemain", ",", "color", "=", "'w'", ",", "size", "=", "self", ".", "fontSize", ",", "ha", "=", "'center'", ",", "va", "=", "'top'", ")", "self", ".", "batPerText", ".", "set_path_effects", "(", "[", "PathEffects", ".", "withStroke", "(", "linewidth", "=", "1", ",", "foreground", "=", "'k'", ")", "]", ")", "self", ".", "voltsText", "=", "self", ".", "axes", ".", "text", "(", "self", ".", "rightPos", "-", "(", "self", ".", "rOffset", "+", "1.3", "+", "0.2", ")", "*", "self", ".", "batWidth", ",", "1", "-", "(", "0.1", "+", "0.05", "+", "0.075", ")", "*", "self", ".", "batHeight", ",", "'%.1f V'", "%", "self", ".", "voltage", ",", "color", "=", "'w'", ",", "size", "=", "self", ".", "fontSize", ",", "ha", "=", "'right'", ",", "va", "=", "'top'", ")", "self", ".", "ampsText", "=", "self", ".", "axes", ".", "text", "(", "self", ".", "rightPos", "-", "(", "self", ".", "rOffset", "+", "1.3", "+", "0.2", ")", "*", "self", ".", "batWidth", ",", "1", "-", "self", ".", "vertSize", "-", "(", "0.1", "+", "0.05", "+", "0.1", "+", "0.075", ")", "*", "self", ".", "batHeight", ",", "'%.1f A'", "%", "self", ".", "current", ",", "color", "=", "'w'", ",", "size", "=", "self", ".", "fontSize", ",", "ha", "=", "'right'", ",", "va", "=", "'top'", ")", "self", ".", "voltsText", ".", "set_path_effects", "(", "[", "PathEffects", ".", "withStroke", "(", "linewidth", "=", "1", ",", "foreground", "=", "'k'", ")", "]", ")", "self", ".", "ampsText", ".", "set_path_effects", "(", "[", "PathEffects", ".", "withStroke", "(", "linewidth", "=", "1", ",", "foreground", "=", "'k'", ")", "]", ")", "self", ".", "axes", ".", "add_patch", "(", "self", ".", "batOutRec", ")", "self", ".", "axes", ".", "add_patch", "(", "self", ".", "batInRec", ")" ]
Creates the bar to display current battery percentage.
[ "Creates", "the", "bar", "to", "display", "current", "battery", "percentage", "." ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/wxhorizon_ui.py#L353-L365
249,491
ArduPilot/MAVProxy
MAVProxy/modules/lib/wxhorizon_ui.py
HorizonFrame.updateBatteryBar
def updateBatteryBar(self): '''Updates the position and values of the battery bar.''' # Bar self.batOutRec.set_xy((self.rightPos-(1.3+self.rOffset)*self.batWidth,1.0-(0.1+1.0+(2*0.075))*self.batHeight)) self.batInRec.set_xy((self.rightPos-(self.rOffset+1+0.15)*self.batWidth,1.0-(0.1+1+0.075)*self.batHeight)) self.batPerText.set_position((self.rightPos - (self.rOffset+0.65)*self.batWidth,1-(0.1+1+(0.075+0.15))*self.batHeight)) self.batPerText.set_fontsize(self.fontSize) self.voltsText.set_text('%.1f V' % self.voltage) self.ampsText.set_text('%.1f A' % self.current) self.voltsText.set_position((self.rightPos-(self.rOffset+1.3+0.2)*self.batWidth,1-(0.1+0.05)*self.batHeight)) self.ampsText.set_position((self.rightPos-(self.rOffset+1.3+0.2)*self.batWidth,1-self.vertSize-(0.1+0.05+0.1)*self.batHeight)) self.voltsText.set_fontsize(self.fontSize) self.ampsText.set_fontsize(self.fontSize) if self.batRemain >= 0: self.batPerText.set_text(int(self.batRemain)) self.batInRec.set_height(self.batRemain*self.batHeight/100.0) if self.batRemain/100.0 > 0.5: self.batInRec.set_facecolor('lawngreen') elif self.batRemain/100.0 <= 0.5 and self.batRemain/100.0 > 0.2: self.batInRec.set_facecolor('yellow') elif self.batRemain/100.0 <= 0.2 and self.batRemain >= 0.0: self.batInRec.set_facecolor('r') elif self.batRemain == -1: self.batInRec.set_height(self.batHeight) self.batInRec.set_facecolor('k')
python
def updateBatteryBar(self): '''Updates the position and values of the battery bar.''' # Bar self.batOutRec.set_xy((self.rightPos-(1.3+self.rOffset)*self.batWidth,1.0-(0.1+1.0+(2*0.075))*self.batHeight)) self.batInRec.set_xy((self.rightPos-(self.rOffset+1+0.15)*self.batWidth,1.0-(0.1+1+0.075)*self.batHeight)) self.batPerText.set_position((self.rightPos - (self.rOffset+0.65)*self.batWidth,1-(0.1+1+(0.075+0.15))*self.batHeight)) self.batPerText.set_fontsize(self.fontSize) self.voltsText.set_text('%.1f V' % self.voltage) self.ampsText.set_text('%.1f A' % self.current) self.voltsText.set_position((self.rightPos-(self.rOffset+1.3+0.2)*self.batWidth,1-(0.1+0.05)*self.batHeight)) self.ampsText.set_position((self.rightPos-(self.rOffset+1.3+0.2)*self.batWidth,1-self.vertSize-(0.1+0.05+0.1)*self.batHeight)) self.voltsText.set_fontsize(self.fontSize) self.ampsText.set_fontsize(self.fontSize) if self.batRemain >= 0: self.batPerText.set_text(int(self.batRemain)) self.batInRec.set_height(self.batRemain*self.batHeight/100.0) if self.batRemain/100.0 > 0.5: self.batInRec.set_facecolor('lawngreen') elif self.batRemain/100.0 <= 0.5 and self.batRemain/100.0 > 0.2: self.batInRec.set_facecolor('yellow') elif self.batRemain/100.0 <= 0.2 and self.batRemain >= 0.0: self.batInRec.set_facecolor('r') elif self.batRemain == -1: self.batInRec.set_height(self.batHeight) self.batInRec.set_facecolor('k')
[ "def", "updateBatteryBar", "(", "self", ")", ":", "# Bar", "self", ".", "batOutRec", ".", "set_xy", "(", "(", "self", ".", "rightPos", "-", "(", "1.3", "+", "self", ".", "rOffset", ")", "*", "self", ".", "batWidth", ",", "1.0", "-", "(", "0.1", "+", "1.0", "+", "(", "2", "*", "0.075", ")", ")", "*", "self", ".", "batHeight", ")", ")", "self", ".", "batInRec", ".", "set_xy", "(", "(", "self", ".", "rightPos", "-", "(", "self", ".", "rOffset", "+", "1", "+", "0.15", ")", "*", "self", ".", "batWidth", ",", "1.0", "-", "(", "0.1", "+", "1", "+", "0.075", ")", "*", "self", ".", "batHeight", ")", ")", "self", ".", "batPerText", ".", "set_position", "(", "(", "self", ".", "rightPos", "-", "(", "self", ".", "rOffset", "+", "0.65", ")", "*", "self", ".", "batWidth", ",", "1", "-", "(", "0.1", "+", "1", "+", "(", "0.075", "+", "0.15", ")", ")", "*", "self", ".", "batHeight", ")", ")", "self", ".", "batPerText", ".", "set_fontsize", "(", "self", ".", "fontSize", ")", "self", ".", "voltsText", ".", "set_text", "(", "'%.1f V'", "%", "self", ".", "voltage", ")", "self", ".", "ampsText", ".", "set_text", "(", "'%.1f A'", "%", "self", ".", "current", ")", "self", ".", "voltsText", ".", "set_position", "(", "(", "self", ".", "rightPos", "-", "(", "self", ".", "rOffset", "+", "1.3", "+", "0.2", ")", "*", "self", ".", "batWidth", ",", "1", "-", "(", "0.1", "+", "0.05", ")", "*", "self", ".", "batHeight", ")", ")", "self", ".", "ampsText", ".", "set_position", "(", "(", "self", ".", "rightPos", "-", "(", "self", ".", "rOffset", "+", "1.3", "+", "0.2", ")", "*", "self", ".", "batWidth", ",", "1", "-", "self", ".", "vertSize", "-", "(", "0.1", "+", "0.05", "+", "0.1", ")", "*", "self", ".", "batHeight", ")", ")", "self", ".", "voltsText", ".", "set_fontsize", "(", "self", ".", "fontSize", ")", "self", ".", "ampsText", ".", "set_fontsize", "(", "self", ".", "fontSize", ")", "if", "self", ".", "batRemain", ">=", "0", ":", "self", ".", "batPerText", ".", "set_text", "(", "int", "(", "self", ".", "batRemain", ")", ")", "self", ".", "batInRec", ".", "set_height", "(", "self", ".", "batRemain", "*", "self", ".", "batHeight", "/", "100.0", ")", "if", "self", ".", "batRemain", "/", "100.0", ">", "0.5", ":", "self", ".", "batInRec", ".", "set_facecolor", "(", "'lawngreen'", ")", "elif", "self", ".", "batRemain", "/", "100.0", "<=", "0.5", "and", "self", ".", "batRemain", "/", "100.0", ">", "0.2", ":", "self", ".", "batInRec", ".", "set_facecolor", "(", "'yellow'", ")", "elif", "self", ".", "batRemain", "/", "100.0", "<=", "0.2", "and", "self", ".", "batRemain", ">=", "0.0", ":", "self", ".", "batInRec", ".", "set_facecolor", "(", "'r'", ")", "elif", "self", ".", "batRemain", "==", "-", "1", ":", "self", ".", "batInRec", ".", "set_height", "(", "self", ".", "batHeight", ")", "self", ".", "batInRec", ".", "set_facecolor", "(", "'k'", ")" ]
Updates the position and values of the battery bar.
[ "Updates", "the", "position", "and", "values", "of", "the", "battery", "bar", "." ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/wxhorizon_ui.py#L367-L391
249,492
ArduPilot/MAVProxy
MAVProxy/modules/lib/wxhorizon_ui.py
HorizonFrame.createStateText
def createStateText(self): '''Creates the mode and arm state text.''' self.modeText = self.axes.text(self.leftPos+(self.vertSize/10.0),0.97,'UNKNOWN',color='grey',size=1.5*self.fontSize,ha='left',va='top') self.modeText.set_path_effects([PathEffects.withStroke(linewidth=self.fontSize/10.0,foreground='black')])
python
def createStateText(self): '''Creates the mode and arm state text.''' self.modeText = self.axes.text(self.leftPos+(self.vertSize/10.0),0.97,'UNKNOWN',color='grey',size=1.5*self.fontSize,ha='left',va='top') self.modeText.set_path_effects([PathEffects.withStroke(linewidth=self.fontSize/10.0,foreground='black')])
[ "def", "createStateText", "(", "self", ")", ":", "self", ".", "modeText", "=", "self", ".", "axes", ".", "text", "(", "self", ".", "leftPos", "+", "(", "self", ".", "vertSize", "/", "10.0", ")", ",", "0.97", ",", "'UNKNOWN'", ",", "color", "=", "'grey'", ",", "size", "=", "1.5", "*", "self", ".", "fontSize", ",", "ha", "=", "'left'", ",", "va", "=", "'top'", ")", "self", ".", "modeText", ".", "set_path_effects", "(", "[", "PathEffects", ".", "withStroke", "(", "linewidth", "=", "self", ".", "fontSize", "/", "10.0", ",", "foreground", "=", "'black'", ")", "]", ")" ]
Creates the mode and arm state text.
[ "Creates", "the", "mode", "and", "arm", "state", "text", "." ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/wxhorizon_ui.py#L393-L396
249,493
ArduPilot/MAVProxy
MAVProxy/modules/lib/wxhorizon_ui.py
HorizonFrame.updateStateText
def updateStateText(self): '''Updates the mode and colours red or green depending on arm state.''' self.modeText.set_position((self.leftPos+(self.vertSize/10.0),0.97)) self.modeText.set_text(self.mode) self.modeText.set_size(1.5*self.fontSize) if self.armed: self.modeText.set_color('red') self.modeText.set_path_effects([PathEffects.withStroke(linewidth=self.fontSize/10.0,foreground='yellow')]) elif (self.armed == False): self.modeText.set_color('lightgreen') self.modeText.set_bbox(None) self.modeText.set_path_effects([PathEffects.withStroke(linewidth=1,foreground='black')]) else: # Fall back if unknown self.modeText.set_color('grey') self.modeText.set_bbox(None) self.modeText.set_path_effects([PathEffects.withStroke(linewidth=self.fontSize/10.0,foreground='black')])
python
def updateStateText(self): '''Updates the mode and colours red or green depending on arm state.''' self.modeText.set_position((self.leftPos+(self.vertSize/10.0),0.97)) self.modeText.set_text(self.mode) self.modeText.set_size(1.5*self.fontSize) if self.armed: self.modeText.set_color('red') self.modeText.set_path_effects([PathEffects.withStroke(linewidth=self.fontSize/10.0,foreground='yellow')]) elif (self.armed == False): self.modeText.set_color('lightgreen') self.modeText.set_bbox(None) self.modeText.set_path_effects([PathEffects.withStroke(linewidth=1,foreground='black')]) else: # Fall back if unknown self.modeText.set_color('grey') self.modeText.set_bbox(None) self.modeText.set_path_effects([PathEffects.withStroke(linewidth=self.fontSize/10.0,foreground='black')])
[ "def", "updateStateText", "(", "self", ")", ":", "self", ".", "modeText", ".", "set_position", "(", "(", "self", ".", "leftPos", "+", "(", "self", ".", "vertSize", "/", "10.0", ")", ",", "0.97", ")", ")", "self", ".", "modeText", ".", "set_text", "(", "self", ".", "mode", ")", "self", ".", "modeText", ".", "set_size", "(", "1.5", "*", "self", ".", "fontSize", ")", "if", "self", ".", "armed", ":", "self", ".", "modeText", ".", "set_color", "(", "'red'", ")", "self", ".", "modeText", ".", "set_path_effects", "(", "[", "PathEffects", ".", "withStroke", "(", "linewidth", "=", "self", ".", "fontSize", "/", "10.0", ",", "foreground", "=", "'yellow'", ")", "]", ")", "elif", "(", "self", ".", "armed", "==", "False", ")", ":", "self", ".", "modeText", ".", "set_color", "(", "'lightgreen'", ")", "self", ".", "modeText", ".", "set_bbox", "(", "None", ")", "self", ".", "modeText", ".", "set_path_effects", "(", "[", "PathEffects", ".", "withStroke", "(", "linewidth", "=", "1", ",", "foreground", "=", "'black'", ")", "]", ")", "else", ":", "# Fall back if unknown", "self", ".", "modeText", ".", "set_color", "(", "'grey'", ")", "self", ".", "modeText", ".", "set_bbox", "(", "None", ")", "self", ".", "modeText", ".", "set_path_effects", "(", "[", "PathEffects", ".", "withStroke", "(", "linewidth", "=", "self", ".", "fontSize", "/", "10.0", ",", "foreground", "=", "'black'", ")", "]", ")" ]
Updates the mode and colours red or green depending on arm state.
[ "Updates", "the", "mode", "and", "colours", "red", "or", "green", "depending", "on", "arm", "state", "." ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/wxhorizon_ui.py#L398-L414
249,494
ArduPilot/MAVProxy
MAVProxy/modules/lib/wxhorizon_ui.py
HorizonFrame.createWPText
def createWPText(self): '''Creates the text for the current and final waypoint, and the distance to the new waypoint.''' self.wpText = self.axes.text(self.leftPos+(1.5*self.vertSize/10.0),0.97-(1.5*self.vertSize)+(0.5*self.vertSize/10.0),'0/0\n(0 m, 0 s)',color='w',size=self.fontSize,ha='left',va='top') self.wpText.set_path_effects([PathEffects.withStroke(linewidth=1,foreground='black')])
python
def createWPText(self): '''Creates the text for the current and final waypoint, and the distance to the new waypoint.''' self.wpText = self.axes.text(self.leftPos+(1.5*self.vertSize/10.0),0.97-(1.5*self.vertSize)+(0.5*self.vertSize/10.0),'0/0\n(0 m, 0 s)',color='w',size=self.fontSize,ha='left',va='top') self.wpText.set_path_effects([PathEffects.withStroke(linewidth=1,foreground='black')])
[ "def", "createWPText", "(", "self", ")", ":", "self", ".", "wpText", "=", "self", ".", "axes", ".", "text", "(", "self", ".", "leftPos", "+", "(", "1.5", "*", "self", ".", "vertSize", "/", "10.0", ")", ",", "0.97", "-", "(", "1.5", "*", "self", ".", "vertSize", ")", "+", "(", "0.5", "*", "self", ".", "vertSize", "/", "10.0", ")", ",", "'0/0\\n(0 m, 0 s)'", ",", "color", "=", "'w'", ",", "size", "=", "self", ".", "fontSize", ",", "ha", "=", "'left'", ",", "va", "=", "'top'", ")", "self", ".", "wpText", ".", "set_path_effects", "(", "[", "PathEffects", ".", "withStroke", "(", "linewidth", "=", "1", ",", "foreground", "=", "'black'", ")", "]", ")" ]
Creates the text for the current and final waypoint, and the distance to the new waypoint.
[ "Creates", "the", "text", "for", "the", "current", "and", "final", "waypoint", "and", "the", "distance", "to", "the", "new", "waypoint", "." ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/wxhorizon_ui.py#L416-L420
249,495
ArduPilot/MAVProxy
MAVProxy/modules/lib/wxhorizon_ui.py
HorizonFrame.updateWPText
def updateWPText(self): '''Updates the current waypoint and distance to it.''' self.wpText.set_position((self.leftPos+(1.5*self.vertSize/10.0),0.97-(1.5*self.vertSize)+(0.5*self.vertSize/10.0))) self.wpText.set_size(self.fontSize) if type(self.nextWPTime) is str: self.wpText.set_text('%.f/%.f\n(%.f m, ~ s)' % (self.currentWP,self.finalWP,self.wpDist)) else: self.wpText.set_text('%.f/%.f\n(%.f m, %.f s)' % (self.currentWP,self.finalWP,self.wpDist,self.nextWPTime))
python
def updateWPText(self): '''Updates the current waypoint and distance to it.''' self.wpText.set_position((self.leftPos+(1.5*self.vertSize/10.0),0.97-(1.5*self.vertSize)+(0.5*self.vertSize/10.0))) self.wpText.set_size(self.fontSize) if type(self.nextWPTime) is str: self.wpText.set_text('%.f/%.f\n(%.f m, ~ s)' % (self.currentWP,self.finalWP,self.wpDist)) else: self.wpText.set_text('%.f/%.f\n(%.f m, %.f s)' % (self.currentWP,self.finalWP,self.wpDist,self.nextWPTime))
[ "def", "updateWPText", "(", "self", ")", ":", "self", ".", "wpText", ".", "set_position", "(", "(", "self", ".", "leftPos", "+", "(", "1.5", "*", "self", ".", "vertSize", "/", "10.0", ")", ",", "0.97", "-", "(", "1.5", "*", "self", ".", "vertSize", ")", "+", "(", "0.5", "*", "self", ".", "vertSize", "/", "10.0", ")", ")", ")", "self", ".", "wpText", ".", "set_size", "(", "self", ".", "fontSize", ")", "if", "type", "(", "self", ".", "nextWPTime", ")", "is", "str", ":", "self", ".", "wpText", ".", "set_text", "(", "'%.f/%.f\\n(%.f m, ~ s)'", "%", "(", "self", ".", "currentWP", ",", "self", ".", "finalWP", ",", "self", ".", "wpDist", ")", ")", "else", ":", "self", ".", "wpText", ".", "set_text", "(", "'%.f/%.f\\n(%.f m, %.f s)'", "%", "(", "self", ".", "currentWP", ",", "self", ".", "finalWP", ",", "self", ".", "wpDist", ",", "self", ".", "nextWPTime", ")", ")" ]
Updates the current waypoint and distance to it.
[ "Updates", "the", "current", "waypoint", "and", "distance", "to", "it", "." ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/wxhorizon_ui.py#L422-L429
249,496
ArduPilot/MAVProxy
MAVProxy/modules/lib/wxhorizon_ui.py
HorizonFrame.createWPPointer
def createWPPointer(self): '''Creates the waypoint pointer relative to current heading.''' self.headingWPTri = patches.RegularPolygon((0.0,0.55),3,0.05,facecolor='lime',zorder=4,ec='k') self.axes.add_patch(self.headingWPTri) self.headingWPText = self.axes.text(0.0,0.45,'1',color='lime',size=self.fontSize,horizontalalignment='center',verticalalignment='center',zorder=4) self.headingWPText.set_path_effects([PathEffects.withStroke(linewidth=1,foreground='k')])
python
def createWPPointer(self): '''Creates the waypoint pointer relative to current heading.''' self.headingWPTri = patches.RegularPolygon((0.0,0.55),3,0.05,facecolor='lime',zorder=4,ec='k') self.axes.add_patch(self.headingWPTri) self.headingWPText = self.axes.text(0.0,0.45,'1',color='lime',size=self.fontSize,horizontalalignment='center',verticalalignment='center',zorder=4) self.headingWPText.set_path_effects([PathEffects.withStroke(linewidth=1,foreground='k')])
[ "def", "createWPPointer", "(", "self", ")", ":", "self", ".", "headingWPTri", "=", "patches", ".", "RegularPolygon", "(", "(", "0.0", ",", "0.55", ")", ",", "3", ",", "0.05", ",", "facecolor", "=", "'lime'", ",", "zorder", "=", "4", ",", "ec", "=", "'k'", ")", "self", ".", "axes", ".", "add_patch", "(", "self", ".", "headingWPTri", ")", "self", ".", "headingWPText", "=", "self", ".", "axes", ".", "text", "(", "0.0", ",", "0.45", ",", "'1'", ",", "color", "=", "'lime'", ",", "size", "=", "self", ".", "fontSize", ",", "horizontalalignment", "=", "'center'", ",", "verticalalignment", "=", "'center'", ",", "zorder", "=", "4", ")", "self", ".", "headingWPText", ".", "set_path_effects", "(", "[", "PathEffects", ".", "withStroke", "(", "linewidth", "=", "1", ",", "foreground", "=", "'k'", ")", "]", ")" ]
Creates the waypoint pointer relative to current heading.
[ "Creates", "the", "waypoint", "pointer", "relative", "to", "current", "heading", "." ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/wxhorizon_ui.py#L431-L436
249,497
ArduPilot/MAVProxy
MAVProxy/modules/lib/wxhorizon_ui.py
HorizonFrame.adjustWPPointer
def adjustWPPointer(self): '''Adjust the position and orientation of the waypoint pointer.''' self.headingWPText.set_size(self.fontSize) headingRotate = mpl.transforms.Affine2D().rotate_deg_around(0.0,0.0,-self.wpBearing+self.heading)+self.axes.transData self.headingWPText.set_transform(headingRotate) angle = self.wpBearing - self.heading if angle < 0: angle += 360 if (angle > 90) and (angle < 270): headRot = angle-180 else: headRot = angle self.headingWPText.set_rotation(-headRot) self.headingWPTri.set_transform(headingRotate) self.headingWPText.set_text('%.f' % (angle))
python
def adjustWPPointer(self): '''Adjust the position and orientation of the waypoint pointer.''' self.headingWPText.set_size(self.fontSize) headingRotate = mpl.transforms.Affine2D().rotate_deg_around(0.0,0.0,-self.wpBearing+self.heading)+self.axes.transData self.headingWPText.set_transform(headingRotate) angle = self.wpBearing - self.heading if angle < 0: angle += 360 if (angle > 90) and (angle < 270): headRot = angle-180 else: headRot = angle self.headingWPText.set_rotation(-headRot) self.headingWPTri.set_transform(headingRotate) self.headingWPText.set_text('%.f' % (angle))
[ "def", "adjustWPPointer", "(", "self", ")", ":", "self", ".", "headingWPText", ".", "set_size", "(", "self", ".", "fontSize", ")", "headingRotate", "=", "mpl", ".", "transforms", ".", "Affine2D", "(", ")", ".", "rotate_deg_around", "(", "0.0", ",", "0.0", ",", "-", "self", ".", "wpBearing", "+", "self", ".", "heading", ")", "+", "self", ".", "axes", ".", "transData", "self", ".", "headingWPText", ".", "set_transform", "(", "headingRotate", ")", "angle", "=", "self", ".", "wpBearing", "-", "self", ".", "heading", "if", "angle", "<", "0", ":", "angle", "+=", "360", "if", "(", "angle", ">", "90", ")", "and", "(", "angle", "<", "270", ")", ":", "headRot", "=", "angle", "-", "180", "else", ":", "headRot", "=", "angle", "self", ".", "headingWPText", ".", "set_rotation", "(", "-", "headRot", ")", "self", ".", "headingWPTri", ".", "set_transform", "(", "headingRotate", ")", "self", ".", "headingWPText", ".", "set_text", "(", "'%.f'", "%", "(", "angle", ")", ")" ]
Adjust the position and orientation of the waypoint pointer.
[ "Adjust", "the", "position", "and", "orientation", "of", "the", "waypoint", "pointer", "." ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/wxhorizon_ui.py#L438-L453
249,498
ArduPilot/MAVProxy
MAVProxy/modules/lib/wxhorizon_ui.py
HorizonFrame.createAltHistoryPlot
def createAltHistoryPlot(self): '''Creates the altitude history plot.''' self.altHistRect = patches.Rectangle((self.leftPos+(self.vertSize/10.0),-0.25),0.5,0.5,facecolor='grey',edgecolor='none',alpha=0.4,zorder=4) self.axes.add_patch(self.altHistRect) self.altPlot, = self.axes.plot([self.leftPos+(self.vertSize/10.0),self.leftPos+(self.vertSize/10.0)+0.5],[0.0,0.0],color='k',marker=None,zorder=4) self.altMarker, = self.axes.plot(self.leftPos+(self.vertSize/10.0)+0.5,0.0,marker='o',color='k',zorder=4) self.altText2 = self.axes.text(self.leftPos+(4*self.vertSize/10.0)+0.5,0.0,'%.f m' % self.relAlt,color='k',size=self.fontSize,ha='left',va='center',zorder=4)
python
def createAltHistoryPlot(self): '''Creates the altitude history plot.''' self.altHistRect = patches.Rectangle((self.leftPos+(self.vertSize/10.0),-0.25),0.5,0.5,facecolor='grey',edgecolor='none',alpha=0.4,zorder=4) self.axes.add_patch(self.altHistRect) self.altPlot, = self.axes.plot([self.leftPos+(self.vertSize/10.0),self.leftPos+(self.vertSize/10.0)+0.5],[0.0,0.0],color='k',marker=None,zorder=4) self.altMarker, = self.axes.plot(self.leftPos+(self.vertSize/10.0)+0.5,0.0,marker='o',color='k',zorder=4) self.altText2 = self.axes.text(self.leftPos+(4*self.vertSize/10.0)+0.5,0.0,'%.f m' % self.relAlt,color='k',size=self.fontSize,ha='left',va='center',zorder=4)
[ "def", "createAltHistoryPlot", "(", "self", ")", ":", "self", ".", "altHistRect", "=", "patches", ".", "Rectangle", "(", "(", "self", ".", "leftPos", "+", "(", "self", ".", "vertSize", "/", "10.0", ")", ",", "-", "0.25", ")", ",", "0.5", ",", "0.5", ",", "facecolor", "=", "'grey'", ",", "edgecolor", "=", "'none'", ",", "alpha", "=", "0.4", ",", "zorder", "=", "4", ")", "self", ".", "axes", ".", "add_patch", "(", "self", ".", "altHistRect", ")", "self", ".", "altPlot", ",", "=", "self", ".", "axes", ".", "plot", "(", "[", "self", ".", "leftPos", "+", "(", "self", ".", "vertSize", "/", "10.0", ")", ",", "self", ".", "leftPos", "+", "(", "self", ".", "vertSize", "/", "10.0", ")", "+", "0.5", "]", ",", "[", "0.0", ",", "0.0", "]", ",", "color", "=", "'k'", ",", "marker", "=", "None", ",", "zorder", "=", "4", ")", "self", ".", "altMarker", ",", "=", "self", ".", "axes", ".", "plot", "(", "self", ".", "leftPos", "+", "(", "self", ".", "vertSize", "/", "10.0", ")", "+", "0.5", ",", "0.0", ",", "marker", "=", "'o'", ",", "color", "=", "'k'", ",", "zorder", "=", "4", ")", "self", ".", "altText2", "=", "self", ".", "axes", ".", "text", "(", "self", ".", "leftPos", "+", "(", "4", "*", "self", ".", "vertSize", "/", "10.0", ")", "+", "0.5", ",", "0.0", ",", "'%.f m'", "%", "self", ".", "relAlt", ",", "color", "=", "'k'", ",", "size", "=", "self", ".", "fontSize", ",", "ha", "=", "'left'", ",", "va", "=", "'center'", ",", "zorder", "=", "4", ")" ]
Creates the altitude history plot.
[ "Creates", "the", "altitude", "history", "plot", "." ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/wxhorizon_ui.py#L455-L461
249,499
ArduPilot/MAVProxy
MAVProxy/modules/lib/wxhorizon_ui.py
HorizonFrame.updateAltHistory
def updateAltHistory(self): '''Updates the altitude history plot.''' self.altHist.append(self.relAlt) self.timeHist.append(self.relAltTime) # Delete entries older than x seconds histLim = 10 currentTime = time.time() point = 0 for i in range(0,len(self.timeHist)): if (self.timeHist[i] > (currentTime - 10.0)): break # Remove old entries self.altHist = self.altHist[i:] self.timeHist = self.timeHist[i:] # Transform Data x = [] y = [] tmin = min(self.timeHist) tmax = max(self.timeHist) x1 = self.leftPos+(self.vertSize/10.0) y1 = -0.25 altMin = 0 altMax = max(self.altHist) # Keep alt max for whole mission if altMax > self.altMax: self.altMax = altMax else: altMax = self.altMax if tmax != tmin: mx = 0.5/(tmax-tmin) else: mx = 0.0 if altMax != altMin: my = 0.5/(altMax-altMin) else: my = 0.0 for t in self.timeHist: x.append(mx*(t-tmin)+x1) for alt in self.altHist: val = my*(alt-altMin)+y1 # Crop extreme noise if val < -0.25: val = -0.25 elif val > 0.25: val = 0.25 y.append(val) # Display Plot self.altHistRect.set_x(self.leftPos+(self.vertSize/10.0)) self.altPlot.set_data(x,y) self.altMarker.set_data(self.leftPos+(self.vertSize/10.0)+0.5,val) self.altText2.set_position((self.leftPos+(4*self.vertSize/10.0)+0.5,val)) self.altText2.set_size(self.fontSize) self.altText2.set_text('%.f m' % self.relAlt)
python
def updateAltHistory(self): '''Updates the altitude history plot.''' self.altHist.append(self.relAlt) self.timeHist.append(self.relAltTime) # Delete entries older than x seconds histLim = 10 currentTime = time.time() point = 0 for i in range(0,len(self.timeHist)): if (self.timeHist[i] > (currentTime - 10.0)): break # Remove old entries self.altHist = self.altHist[i:] self.timeHist = self.timeHist[i:] # Transform Data x = [] y = [] tmin = min(self.timeHist) tmax = max(self.timeHist) x1 = self.leftPos+(self.vertSize/10.0) y1 = -0.25 altMin = 0 altMax = max(self.altHist) # Keep alt max for whole mission if altMax > self.altMax: self.altMax = altMax else: altMax = self.altMax if tmax != tmin: mx = 0.5/(tmax-tmin) else: mx = 0.0 if altMax != altMin: my = 0.5/(altMax-altMin) else: my = 0.0 for t in self.timeHist: x.append(mx*(t-tmin)+x1) for alt in self.altHist: val = my*(alt-altMin)+y1 # Crop extreme noise if val < -0.25: val = -0.25 elif val > 0.25: val = 0.25 y.append(val) # Display Plot self.altHistRect.set_x(self.leftPos+(self.vertSize/10.0)) self.altPlot.set_data(x,y) self.altMarker.set_data(self.leftPos+(self.vertSize/10.0)+0.5,val) self.altText2.set_position((self.leftPos+(4*self.vertSize/10.0)+0.5,val)) self.altText2.set_size(self.fontSize) self.altText2.set_text('%.f m' % self.relAlt)
[ "def", "updateAltHistory", "(", "self", ")", ":", "self", ".", "altHist", ".", "append", "(", "self", ".", "relAlt", ")", "self", ".", "timeHist", ".", "append", "(", "self", ".", "relAltTime", ")", "# Delete entries older than x seconds", "histLim", "=", "10", "currentTime", "=", "time", ".", "time", "(", ")", "point", "=", "0", "for", "i", "in", "range", "(", "0", ",", "len", "(", "self", ".", "timeHist", ")", ")", ":", "if", "(", "self", ".", "timeHist", "[", "i", "]", ">", "(", "currentTime", "-", "10.0", ")", ")", ":", "break", "# Remove old entries", "self", ".", "altHist", "=", "self", ".", "altHist", "[", "i", ":", "]", "self", ".", "timeHist", "=", "self", ".", "timeHist", "[", "i", ":", "]", "# Transform Data", "x", "=", "[", "]", "y", "=", "[", "]", "tmin", "=", "min", "(", "self", ".", "timeHist", ")", "tmax", "=", "max", "(", "self", ".", "timeHist", ")", "x1", "=", "self", ".", "leftPos", "+", "(", "self", ".", "vertSize", "/", "10.0", ")", "y1", "=", "-", "0.25", "altMin", "=", "0", "altMax", "=", "max", "(", "self", ".", "altHist", ")", "# Keep alt max for whole mission", "if", "altMax", ">", "self", ".", "altMax", ":", "self", ".", "altMax", "=", "altMax", "else", ":", "altMax", "=", "self", ".", "altMax", "if", "tmax", "!=", "tmin", ":", "mx", "=", "0.5", "/", "(", "tmax", "-", "tmin", ")", "else", ":", "mx", "=", "0.0", "if", "altMax", "!=", "altMin", ":", "my", "=", "0.5", "/", "(", "altMax", "-", "altMin", ")", "else", ":", "my", "=", "0.0", "for", "t", "in", "self", ".", "timeHist", ":", "x", ".", "append", "(", "mx", "*", "(", "t", "-", "tmin", ")", "+", "x1", ")", "for", "alt", "in", "self", ".", "altHist", ":", "val", "=", "my", "*", "(", "alt", "-", "altMin", ")", "+", "y1", "# Crop extreme noise", "if", "val", "<", "-", "0.25", ":", "val", "=", "-", "0.25", "elif", "val", ">", "0.25", ":", "val", "=", "0.25", "y", ".", "append", "(", "val", ")", "# Display Plot", "self", ".", "altHistRect", ".", "set_x", "(", "self", ".", "leftPos", "+", "(", "self", ".", "vertSize", "/", "10.0", ")", ")", "self", ".", "altPlot", ".", "set_data", "(", "x", ",", "y", ")", "self", ".", "altMarker", ".", "set_data", "(", "self", ".", "leftPos", "+", "(", "self", ".", "vertSize", "/", "10.0", ")", "+", "0.5", ",", "val", ")", "self", ".", "altText2", ".", "set_position", "(", "(", "self", ".", "leftPos", "+", "(", "4", "*", "self", ".", "vertSize", "/", "10.0", ")", "+", "0.5", ",", "val", ")", ")", "self", ".", "altText2", ".", "set_size", "(", "self", ".", "fontSize", ")", "self", ".", "altText2", ".", "set_text", "(", "'%.f m'", "%", "self", ".", "relAlt", ")" ]
Updates the altitude history plot.
[ "Updates", "the", "altitude", "history", "plot", "." ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/wxhorizon_ui.py#L463-L517