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 75
19.8k
| code_tokens
list | docstring
stringlengths 3
17.3k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 87
242
|
|---|---|---|---|---|---|---|---|---|---|---|---|
235,600
|
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
|
235,601
|
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
|
235,602
|
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
|
235,603
|
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
|
235,604
|
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
|
235,605
|
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
|
235,606
|
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
|
235,607
|
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
|
235,608
|
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
|
235,609
|
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
|
235,610
|
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
|
235,611
|
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
|
235,612
|
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
|
235,613
|
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):
"""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
|
[
"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
|
235,614
|
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
|
235,615
|
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
|
235,616
|
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):
"""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
|
[
"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
|
235,617
|
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():
"""
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
|
[
"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
|
235,618
|
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():
"""
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()
|
[
"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
|
235,619
|
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):
"""
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
|
[
"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
|
235,620
|
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):
"""
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
|
[
"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
|
235,621
|
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):
"""
Select the current bitmap into this wxDC instance
"""
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
|
235,622
|
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):
"""
Select a Null bitmasp into this wxDC instance
"""
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
|
235,623
|
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):
"""
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()
|
[
"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
|
235,624
|
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):
"""
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()
|
[
"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
|
235,625
|
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):
"""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))
|
[
"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
|
235,626
|
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
|
235,627
|
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):
"""
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)
|
[
"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
|
235,628
|
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):
"""
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)
|
[
"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
|
235,629
|
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):
"""
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()
|
[
"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
|
235,630
|
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):
"""
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
|
[
"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
|
235,631
|
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
|
235,632
|
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):
"""
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
|
[
"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
|
235,633
|
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):
"""
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()
|
[
"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
|
235,634
|
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):
"""
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)
|
[
"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
|
235,635
|
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
|
235,636
|
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):
"""Capture key press."""
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
|
235,637
|
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):
"""Release key."""
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
|
235,638
|
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):
"""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)
|
[
"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
|
235,639
|
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):
"""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)
|
[
"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
|
235,640
|
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):
"""Mouse has left the window."""
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
|
235,641
|
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
|
235,642
|
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):
"""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()
|
[
"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
|
235,643
|
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):
"""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()
|
[
"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
|
235,644
|
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):
"""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()
|
[
"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
|
235,645
|
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):
"""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()
|
[
"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
|
235,646
|
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):
"""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
|
[
"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
|
235,647
|
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):
"""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])
|
[
"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
|
235,648
|
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):
"""
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()
|
[
"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
|
235,649
|
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):
"""
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)
|
[
"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
|
235,650
|
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):
"""
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)
|
[
"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
|
235,651
|
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
|
235,652
|
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
|
235,653
|
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
|
235,654
|
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
|
235,655
|
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
|
235,656
|
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
|
235,657
|
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
|
235,658
|
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
|
235,659
|
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
|
235,660
|
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
|
235,661
|
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
|
235,662
|
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
|
235,663
|
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
|
235,664
|
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
|
235,665
|
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
|
235,666
|
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
|
235,667
|
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
|
235,668
|
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
|
235,669
|
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
|
235,670
|
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
|
235,671
|
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
|
235,672
|
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
|
235,673
|
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
|
235,674
|
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
|
235,675
|
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
|
235,676
|
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
|
235,677
|
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
|
235,678
|
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
|
235,679
|
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
|
235,680
|
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
|
235,681
|
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
|
235,682
|
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
|
235,683
|
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
|
235,684
|
ArduPilot/MAVProxy
|
MAVProxy/modules/lib/wxhorizon_ui.py
|
HorizonFrame.on_idle
|
def on_idle(self, event):
'''To adjust text and positions on rescaling the window when resized.'''
# Check for resize
self.checkReszie()
if self.resized:
# Fix Window Scales
self.rescaleX()
self.calcFontScaling()
# Recalculate Horizon Polygons
self.calcHorizonPoints()
# Update Roll, Pitch, Yaw Text Locations
self.updateRPYLocations()
# Update Airpseed, Altitude, Climb Rate Locations
self.updateAARLocations()
# Update Pitch Markers
self.adjustPitchmarkers()
# Update Heading and North Pointer
self.adjustHeadingPointer()
self.adjustNorthPointer()
# Update Battery Bar
self.updateBatteryBar()
# Update Mode and State
self.updateStateText()
# Update Waypoint Text
self.updateWPText()
# Adjust Waypoint Pointer
self.adjustWPPointer()
# Update History Plot
self.updateAltHistory()
# Update Matplotlib Plot
self.canvas.draw()
self.canvas.Refresh()
self.resized = False
time.sleep(0.05)
|
python
|
def on_idle(self, event):
'''To adjust text and positions on rescaling the window when resized.'''
# Check for resize
self.checkReszie()
if self.resized:
# Fix Window Scales
self.rescaleX()
self.calcFontScaling()
# Recalculate Horizon Polygons
self.calcHorizonPoints()
# Update Roll, Pitch, Yaw Text Locations
self.updateRPYLocations()
# Update Airpseed, Altitude, Climb Rate Locations
self.updateAARLocations()
# Update Pitch Markers
self.adjustPitchmarkers()
# Update Heading and North Pointer
self.adjustHeadingPointer()
self.adjustNorthPointer()
# Update Battery Bar
self.updateBatteryBar()
# Update Mode and State
self.updateStateText()
# Update Waypoint Text
self.updateWPText()
# Adjust Waypoint Pointer
self.adjustWPPointer()
# Update History Plot
self.updateAltHistory()
# Update Matplotlib Plot
self.canvas.draw()
self.canvas.Refresh()
self.resized = False
time.sleep(0.05)
|
[
"def",
"on_idle",
"(",
"self",
",",
"event",
")",
":",
"# Check for resize",
"self",
".",
"checkReszie",
"(",
")",
"if",
"self",
".",
"resized",
":",
"# Fix Window Scales ",
"self",
".",
"rescaleX",
"(",
")",
"self",
".",
"calcFontScaling",
"(",
")",
"# Recalculate Horizon Polygons",
"self",
".",
"calcHorizonPoints",
"(",
")",
"# Update Roll, Pitch, Yaw Text Locations",
"self",
".",
"updateRPYLocations",
"(",
")",
"# Update Airpseed, Altitude, Climb Rate Locations",
"self",
".",
"updateAARLocations",
"(",
")",
"# Update Pitch Markers",
"self",
".",
"adjustPitchmarkers",
"(",
")",
"# Update Heading and North Pointer",
"self",
".",
"adjustHeadingPointer",
"(",
")",
"self",
".",
"adjustNorthPointer",
"(",
")",
"# Update Battery Bar",
"self",
".",
"updateBatteryBar",
"(",
")",
"# Update Mode and State",
"self",
".",
"updateStateText",
"(",
")",
"# Update Waypoint Text",
"self",
".",
"updateWPText",
"(",
")",
"# Adjust Waypoint Pointer",
"self",
".",
"adjustWPPointer",
"(",
")",
"# Update History Plot",
"self",
".",
"updateAltHistory",
"(",
")",
"# Update Matplotlib Plot",
"self",
".",
"canvas",
".",
"draw",
"(",
")",
"self",
".",
"canvas",
".",
"Refresh",
"(",
")",
"self",
".",
"resized",
"=",
"False",
"time",
".",
"sleep",
"(",
"0.05",
")"
] |
To adjust text and positions on rescaling the window when resized.
|
[
"To",
"adjust",
"text",
"and",
"positions",
"on",
"rescaling",
"the",
"window",
"when",
"resized",
"."
] |
f50bdeff33064876f7dc8dc4683d278ff47f75d5
|
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/wxhorizon_ui.py#L520-L567
|
235,685
|
ArduPilot/MAVProxy
|
MAVProxy/modules/lib/wxhorizon_ui.py
|
HorizonFrame.on_timer
|
def on_timer(self, event):
'''Main Loop.'''
state = self.state
self.loopStartTime = time.time()
if state.close_event.wait(0.001):
self.timer.Stop()
self.Destroy()
return
# Check for resizing
self.checkReszie()
if self.resized:
self.on_idle(0)
# Get attitude information
while state.child_pipe_recv.poll():
objList = state.child_pipe_recv.recv()
for obj in objList:
self.calcFontScaling()
if isinstance(obj,Attitude):
self.oldRoll = self.roll
self.pitch = obj.pitch*180/math.pi
self.roll = obj.roll*180/math.pi
self.yaw = obj.yaw*180/math.pi
# Update Roll, Pitch, Yaw Text Text
self.updateRPYText()
# Recalculate Horizon Polygons
self.calcHorizonPoints()
# Update Pitch Markers
self.adjustPitchmarkers()
elif isinstance(obj,VFR_HUD):
self.heading = obj.heading
self.airspeed = obj.airspeed
self.climbRate = obj.climbRate
# Update Airpseed, Altitude, Climb Rate Locations
self.updateAARText()
# Update Heading North Pointer
self.adjustHeadingPointer()
self.adjustNorthPointer()
elif isinstance(obj,Global_Position_INT):
self.relAlt = obj.relAlt
self.relAltTime = obj.curTime
# Update Airpseed, Altitude, Climb Rate Locations
self.updateAARText()
# Update Altitude History
self.updateAltHistory()
elif isinstance(obj,BatteryInfo):
self.voltage = obj.voltage
self.current = obj.current
self.batRemain = obj.batRemain
# Update Battery Bar
self.updateBatteryBar()
elif isinstance(obj,FlightState):
self.mode = obj.mode
self.armed = obj.armState
# Update Mode and Arm State Text
self.updateStateText()
elif isinstance(obj,WaypointInfo):
self.currentWP = obj.current
self.finalWP = obj.final
self.wpDist = obj.currentDist
self.nextWPTime = obj.nextWPTime
if obj.wpBearing < 0.0:
self.wpBearing = obj.wpBearing + 360
else:
self.wpBearing = obj.wpBearing
# Update waypoint text
self.updateWPText()
# Adjust Waypoint Pointer
self.adjustWPPointer()
elif isinstance(obj, FPS):
# Update fps target
self.fps = obj.fps
# Quit Drawing if too early
if (time.time() > self.nextTime):
# Update Matplotlib Plot
self.canvas.draw()
self.canvas.Refresh()
self.Refresh()
self.Update()
# Calculate next frame time
if (self.fps > 0):
fpsTime = 1/self.fps
self.nextTime = fpsTime + self.loopStartTime
else:
self.nextTime = time.time()
|
python
|
def on_timer(self, event):
'''Main Loop.'''
state = self.state
self.loopStartTime = time.time()
if state.close_event.wait(0.001):
self.timer.Stop()
self.Destroy()
return
# Check for resizing
self.checkReszie()
if self.resized:
self.on_idle(0)
# Get attitude information
while state.child_pipe_recv.poll():
objList = state.child_pipe_recv.recv()
for obj in objList:
self.calcFontScaling()
if isinstance(obj,Attitude):
self.oldRoll = self.roll
self.pitch = obj.pitch*180/math.pi
self.roll = obj.roll*180/math.pi
self.yaw = obj.yaw*180/math.pi
# Update Roll, Pitch, Yaw Text Text
self.updateRPYText()
# Recalculate Horizon Polygons
self.calcHorizonPoints()
# Update Pitch Markers
self.adjustPitchmarkers()
elif isinstance(obj,VFR_HUD):
self.heading = obj.heading
self.airspeed = obj.airspeed
self.climbRate = obj.climbRate
# Update Airpseed, Altitude, Climb Rate Locations
self.updateAARText()
# Update Heading North Pointer
self.adjustHeadingPointer()
self.adjustNorthPointer()
elif isinstance(obj,Global_Position_INT):
self.relAlt = obj.relAlt
self.relAltTime = obj.curTime
# Update Airpseed, Altitude, Climb Rate Locations
self.updateAARText()
# Update Altitude History
self.updateAltHistory()
elif isinstance(obj,BatteryInfo):
self.voltage = obj.voltage
self.current = obj.current
self.batRemain = obj.batRemain
# Update Battery Bar
self.updateBatteryBar()
elif isinstance(obj,FlightState):
self.mode = obj.mode
self.armed = obj.armState
# Update Mode and Arm State Text
self.updateStateText()
elif isinstance(obj,WaypointInfo):
self.currentWP = obj.current
self.finalWP = obj.final
self.wpDist = obj.currentDist
self.nextWPTime = obj.nextWPTime
if obj.wpBearing < 0.0:
self.wpBearing = obj.wpBearing + 360
else:
self.wpBearing = obj.wpBearing
# Update waypoint text
self.updateWPText()
# Adjust Waypoint Pointer
self.adjustWPPointer()
elif isinstance(obj, FPS):
# Update fps target
self.fps = obj.fps
# Quit Drawing if too early
if (time.time() > self.nextTime):
# Update Matplotlib Plot
self.canvas.draw()
self.canvas.Refresh()
self.Refresh()
self.Update()
# Calculate next frame time
if (self.fps > 0):
fpsTime = 1/self.fps
self.nextTime = fpsTime + self.loopStartTime
else:
self.nextTime = time.time()
|
[
"def",
"on_timer",
"(",
"self",
",",
"event",
")",
":",
"state",
"=",
"self",
".",
"state",
"self",
".",
"loopStartTime",
"=",
"time",
".",
"time",
"(",
")",
"if",
"state",
".",
"close_event",
".",
"wait",
"(",
"0.001",
")",
":",
"self",
".",
"timer",
".",
"Stop",
"(",
")",
"self",
".",
"Destroy",
"(",
")",
"return",
"# Check for resizing",
"self",
".",
"checkReszie",
"(",
")",
"if",
"self",
".",
"resized",
":",
"self",
".",
"on_idle",
"(",
"0",
")",
"# Get attitude information",
"while",
"state",
".",
"child_pipe_recv",
".",
"poll",
"(",
")",
":",
"objList",
"=",
"state",
".",
"child_pipe_recv",
".",
"recv",
"(",
")",
"for",
"obj",
"in",
"objList",
":",
"self",
".",
"calcFontScaling",
"(",
")",
"if",
"isinstance",
"(",
"obj",
",",
"Attitude",
")",
":",
"self",
".",
"oldRoll",
"=",
"self",
".",
"roll",
"self",
".",
"pitch",
"=",
"obj",
".",
"pitch",
"*",
"180",
"/",
"math",
".",
"pi",
"self",
".",
"roll",
"=",
"obj",
".",
"roll",
"*",
"180",
"/",
"math",
".",
"pi",
"self",
".",
"yaw",
"=",
"obj",
".",
"yaw",
"*",
"180",
"/",
"math",
".",
"pi",
"# Update Roll, Pitch, Yaw Text Text",
"self",
".",
"updateRPYText",
"(",
")",
"# Recalculate Horizon Polygons",
"self",
".",
"calcHorizonPoints",
"(",
")",
"# Update Pitch Markers",
"self",
".",
"adjustPitchmarkers",
"(",
")",
"elif",
"isinstance",
"(",
"obj",
",",
"VFR_HUD",
")",
":",
"self",
".",
"heading",
"=",
"obj",
".",
"heading",
"self",
".",
"airspeed",
"=",
"obj",
".",
"airspeed",
"self",
".",
"climbRate",
"=",
"obj",
".",
"climbRate",
"# Update Airpseed, Altitude, Climb Rate Locations",
"self",
".",
"updateAARText",
"(",
")",
"# Update Heading North Pointer",
"self",
".",
"adjustHeadingPointer",
"(",
")",
"self",
".",
"adjustNorthPointer",
"(",
")",
"elif",
"isinstance",
"(",
"obj",
",",
"Global_Position_INT",
")",
":",
"self",
".",
"relAlt",
"=",
"obj",
".",
"relAlt",
"self",
".",
"relAltTime",
"=",
"obj",
".",
"curTime",
"# Update Airpseed, Altitude, Climb Rate Locations",
"self",
".",
"updateAARText",
"(",
")",
"# Update Altitude History",
"self",
".",
"updateAltHistory",
"(",
")",
"elif",
"isinstance",
"(",
"obj",
",",
"BatteryInfo",
")",
":",
"self",
".",
"voltage",
"=",
"obj",
".",
"voltage",
"self",
".",
"current",
"=",
"obj",
".",
"current",
"self",
".",
"batRemain",
"=",
"obj",
".",
"batRemain",
"# Update Battery Bar",
"self",
".",
"updateBatteryBar",
"(",
")",
"elif",
"isinstance",
"(",
"obj",
",",
"FlightState",
")",
":",
"self",
".",
"mode",
"=",
"obj",
".",
"mode",
"self",
".",
"armed",
"=",
"obj",
".",
"armState",
"# Update Mode and Arm State Text",
"self",
".",
"updateStateText",
"(",
")",
"elif",
"isinstance",
"(",
"obj",
",",
"WaypointInfo",
")",
":",
"self",
".",
"currentWP",
"=",
"obj",
".",
"current",
"self",
".",
"finalWP",
"=",
"obj",
".",
"final",
"self",
".",
"wpDist",
"=",
"obj",
".",
"currentDist",
"self",
".",
"nextWPTime",
"=",
"obj",
".",
"nextWPTime",
"if",
"obj",
".",
"wpBearing",
"<",
"0.0",
":",
"self",
".",
"wpBearing",
"=",
"obj",
".",
"wpBearing",
"+",
"360",
"else",
":",
"self",
".",
"wpBearing",
"=",
"obj",
".",
"wpBearing",
"# Update waypoint text",
"self",
".",
"updateWPText",
"(",
")",
"# Adjust Waypoint Pointer",
"self",
".",
"adjustWPPointer",
"(",
")",
"elif",
"isinstance",
"(",
"obj",
",",
"FPS",
")",
":",
"# Update fps target",
"self",
".",
"fps",
"=",
"obj",
".",
"fps",
"# Quit Drawing if too early",
"if",
"(",
"time",
".",
"time",
"(",
")",
">",
"self",
".",
"nextTime",
")",
":",
"# Update Matplotlib Plot",
"self",
".",
"canvas",
".",
"draw",
"(",
")",
"self",
".",
"canvas",
".",
"Refresh",
"(",
")",
"self",
".",
"Refresh",
"(",
")",
"self",
".",
"Update",
"(",
")",
"# Calculate next frame time",
"if",
"(",
"self",
".",
"fps",
">",
"0",
")",
":",
"fpsTime",
"=",
"1",
"/",
"self",
".",
"fps",
"self",
".",
"nextTime",
"=",
"fpsTime",
"+",
"self",
".",
"loopStartTime",
"else",
":",
"self",
".",
"nextTime",
"=",
"time",
".",
"time",
"(",
")"
] |
Main Loop.
|
[
"Main",
"Loop",
"."
] |
f50bdeff33064876f7dc8dc4683d278ff47f75d5
|
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/wxhorizon_ui.py#L569-L675
|
235,686
|
ArduPilot/MAVProxy
|
MAVProxy/modules/lib/wxhorizon_ui.py
|
HorizonFrame.on_KeyPress
|
def on_KeyPress(self,event):
'''To adjust the distance between pitch markers.'''
if event.GetKeyCode() == wx.WXK_UP:
self.dist10deg += 0.1
print('Dist per 10 deg: %.1f' % self.dist10deg)
elif event.GetKeyCode() == wx.WXK_DOWN:
self.dist10deg -= 0.1
if self.dist10deg <= 0:
self.dist10deg = 0.1
print('Dist per 10 deg: %.1f' % self.dist10deg)
# Toggle Widgets
elif event.GetKeyCode() == 49: # 1
widgets = [self.modeText,self.wpText]
self.toggleWidgets(widgets)
elif event.GetKeyCode() == 50: # 2
widgets = [self.batOutRec,self.batInRec,self.voltsText,self.ampsText,self.batPerText]
self.toggleWidgets(widgets)
elif event.GetKeyCode() == 51: # 3
widgets = [self.rollText,self.pitchText,self.yawText]
self.toggleWidgets(widgets)
elif event.GetKeyCode() == 52: # 4
widgets = [self.airspeedText,self.altitudeText,self.climbRateText]
self.toggleWidgets(widgets)
elif event.GetKeyCode() == 53: # 5
widgets = [self.altHistRect,self.altPlot,self.altMarker,self.altText2]
self.toggleWidgets(widgets)
elif event.GetKeyCode() == 54: # 6
widgets = [self.headingTri,self.headingText,self.headingNorthTri,self.headingNorthText,self.headingWPTri,self.headingWPText]
self.toggleWidgets(widgets)
# Update Matplotlib Plot
self.canvas.draw()
self.canvas.Refresh()
self.Refresh()
self.Update()
|
python
|
def on_KeyPress(self,event):
'''To adjust the distance between pitch markers.'''
if event.GetKeyCode() == wx.WXK_UP:
self.dist10deg += 0.1
print('Dist per 10 deg: %.1f' % self.dist10deg)
elif event.GetKeyCode() == wx.WXK_DOWN:
self.dist10deg -= 0.1
if self.dist10deg <= 0:
self.dist10deg = 0.1
print('Dist per 10 deg: %.1f' % self.dist10deg)
# Toggle Widgets
elif event.GetKeyCode() == 49: # 1
widgets = [self.modeText,self.wpText]
self.toggleWidgets(widgets)
elif event.GetKeyCode() == 50: # 2
widgets = [self.batOutRec,self.batInRec,self.voltsText,self.ampsText,self.batPerText]
self.toggleWidgets(widgets)
elif event.GetKeyCode() == 51: # 3
widgets = [self.rollText,self.pitchText,self.yawText]
self.toggleWidgets(widgets)
elif event.GetKeyCode() == 52: # 4
widgets = [self.airspeedText,self.altitudeText,self.climbRateText]
self.toggleWidgets(widgets)
elif event.GetKeyCode() == 53: # 5
widgets = [self.altHistRect,self.altPlot,self.altMarker,self.altText2]
self.toggleWidgets(widgets)
elif event.GetKeyCode() == 54: # 6
widgets = [self.headingTri,self.headingText,self.headingNorthTri,self.headingNorthText,self.headingWPTri,self.headingWPText]
self.toggleWidgets(widgets)
# Update Matplotlib Plot
self.canvas.draw()
self.canvas.Refresh()
self.Refresh()
self.Update()
|
[
"def",
"on_KeyPress",
"(",
"self",
",",
"event",
")",
":",
"if",
"event",
".",
"GetKeyCode",
"(",
")",
"==",
"wx",
".",
"WXK_UP",
":",
"self",
".",
"dist10deg",
"+=",
"0.1",
"print",
"(",
"'Dist per 10 deg: %.1f'",
"%",
"self",
".",
"dist10deg",
")",
"elif",
"event",
".",
"GetKeyCode",
"(",
")",
"==",
"wx",
".",
"WXK_DOWN",
":",
"self",
".",
"dist10deg",
"-=",
"0.1",
"if",
"self",
".",
"dist10deg",
"<=",
"0",
":",
"self",
".",
"dist10deg",
"=",
"0.1",
"print",
"(",
"'Dist per 10 deg: %.1f'",
"%",
"self",
".",
"dist10deg",
")",
"# Toggle Widgets",
"elif",
"event",
".",
"GetKeyCode",
"(",
")",
"==",
"49",
":",
"# 1",
"widgets",
"=",
"[",
"self",
".",
"modeText",
",",
"self",
".",
"wpText",
"]",
"self",
".",
"toggleWidgets",
"(",
"widgets",
")",
"elif",
"event",
".",
"GetKeyCode",
"(",
")",
"==",
"50",
":",
"# 2",
"widgets",
"=",
"[",
"self",
".",
"batOutRec",
",",
"self",
".",
"batInRec",
",",
"self",
".",
"voltsText",
",",
"self",
".",
"ampsText",
",",
"self",
".",
"batPerText",
"]",
"self",
".",
"toggleWidgets",
"(",
"widgets",
")",
"elif",
"event",
".",
"GetKeyCode",
"(",
")",
"==",
"51",
":",
"# 3",
"widgets",
"=",
"[",
"self",
".",
"rollText",
",",
"self",
".",
"pitchText",
",",
"self",
".",
"yawText",
"]",
"self",
".",
"toggleWidgets",
"(",
"widgets",
")",
"elif",
"event",
".",
"GetKeyCode",
"(",
")",
"==",
"52",
":",
"# 4",
"widgets",
"=",
"[",
"self",
".",
"airspeedText",
",",
"self",
".",
"altitudeText",
",",
"self",
".",
"climbRateText",
"]",
"self",
".",
"toggleWidgets",
"(",
"widgets",
")",
"elif",
"event",
".",
"GetKeyCode",
"(",
")",
"==",
"53",
":",
"# 5",
"widgets",
"=",
"[",
"self",
".",
"altHistRect",
",",
"self",
".",
"altPlot",
",",
"self",
".",
"altMarker",
",",
"self",
".",
"altText2",
"]",
"self",
".",
"toggleWidgets",
"(",
"widgets",
")",
"elif",
"event",
".",
"GetKeyCode",
"(",
")",
"==",
"54",
":",
"# 6",
"widgets",
"=",
"[",
"self",
".",
"headingTri",
",",
"self",
".",
"headingText",
",",
"self",
".",
"headingNorthTri",
",",
"self",
".",
"headingNorthText",
",",
"self",
".",
"headingWPTri",
",",
"self",
".",
"headingWPText",
"]",
"self",
".",
"toggleWidgets",
"(",
"widgets",
")",
"# Update Matplotlib Plot",
"self",
".",
"canvas",
".",
"draw",
"(",
")",
"self",
".",
"canvas",
".",
"Refresh",
"(",
")",
"self",
".",
"Refresh",
"(",
")",
"self",
".",
"Update",
"(",
")"
] |
To adjust the distance between pitch markers.
|
[
"To",
"adjust",
"the",
"distance",
"between",
"pitch",
"markers",
"."
] |
f50bdeff33064876f7dc8dc4683d278ff47f75d5
|
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/wxhorizon_ui.py#L677-L712
|
235,687
|
ArduPilot/MAVProxy
|
MAVProxy/modules/mavproxy_fence.py
|
FenceModule.fenceloader
|
def fenceloader(self):
'''fence loader by sysid'''
if not self.target_system in self.fenceloader_by_sysid:
self.fenceloader_by_sysid[self.target_system] = mavwp.MAVFenceLoader()
return self.fenceloader_by_sysid[self.target_system]
|
python
|
def fenceloader(self):
'''fence loader by sysid'''
if not self.target_system in self.fenceloader_by_sysid:
self.fenceloader_by_sysid[self.target_system] = mavwp.MAVFenceLoader()
return self.fenceloader_by_sysid[self.target_system]
|
[
"def",
"fenceloader",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"target_system",
"in",
"self",
".",
"fenceloader_by_sysid",
":",
"self",
".",
"fenceloader_by_sysid",
"[",
"self",
".",
"target_system",
"]",
"=",
"mavwp",
".",
"MAVFenceLoader",
"(",
")",
"return",
"self",
".",
"fenceloader_by_sysid",
"[",
"self",
".",
"target_system",
"]"
] |
fence loader by sysid
|
[
"fence",
"loader",
"by",
"sysid"
] |
f50bdeff33064876f7dc8dc4683d278ff47f75d5
|
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_fence.py#L51-L55
|
235,688
|
ArduPilot/MAVProxy
|
MAVProxy/modules/mavproxy_fence.py
|
FenceModule.mavlink_packet
|
def mavlink_packet(self, m):
'''handle and incoming mavlink packet'''
if m.get_type() == "FENCE_STATUS":
self.last_fence_breach = m.breach_time
self.last_fence_status = m.breach_status
elif m.get_type() in ['SYS_STATUS']:
bits = mavutil.mavlink.MAV_SYS_STATUS_GEOFENCE
present = ((m.onboard_control_sensors_present & bits) == bits)
if self.present == False and present == True:
self.say("fence present")
elif self.present == True and present == False:
self.say("fence removed")
self.present = present
enabled = ((m.onboard_control_sensors_enabled & bits) == bits)
if self.enabled == False and enabled == True:
self.say("fence enabled")
elif self.enabled == True and enabled == False:
self.say("fence disabled")
self.enabled = enabled
healthy = ((m.onboard_control_sensors_health & bits) == bits)
if self.healthy == False and healthy == True:
self.say("fence OK")
elif self.healthy == True and healthy == False:
self.say("fence breach")
self.healthy = healthy
#console output for fence:
if not self.present:
self.console.set_status('Fence', 'FEN', row=0, fg='black')
elif self.enabled == False:
self.console.set_status('Fence', 'FEN', row=0, fg='grey')
elif self.enabled == True and self.healthy == True:
self.console.set_status('Fence', 'FEN', row=0, fg='green')
elif self.enabled == True and self.healthy == False:
self.console.set_status('Fence', 'FEN', row=0, fg='red')
|
python
|
def mavlink_packet(self, m):
'''handle and incoming mavlink packet'''
if m.get_type() == "FENCE_STATUS":
self.last_fence_breach = m.breach_time
self.last_fence_status = m.breach_status
elif m.get_type() in ['SYS_STATUS']:
bits = mavutil.mavlink.MAV_SYS_STATUS_GEOFENCE
present = ((m.onboard_control_sensors_present & bits) == bits)
if self.present == False and present == True:
self.say("fence present")
elif self.present == True and present == False:
self.say("fence removed")
self.present = present
enabled = ((m.onboard_control_sensors_enabled & bits) == bits)
if self.enabled == False and enabled == True:
self.say("fence enabled")
elif self.enabled == True and enabled == False:
self.say("fence disabled")
self.enabled = enabled
healthy = ((m.onboard_control_sensors_health & bits) == bits)
if self.healthy == False and healthy == True:
self.say("fence OK")
elif self.healthy == True and healthy == False:
self.say("fence breach")
self.healthy = healthy
#console output for fence:
if not self.present:
self.console.set_status('Fence', 'FEN', row=0, fg='black')
elif self.enabled == False:
self.console.set_status('Fence', 'FEN', row=0, fg='grey')
elif self.enabled == True and self.healthy == True:
self.console.set_status('Fence', 'FEN', row=0, fg='green')
elif self.enabled == True and self.healthy == False:
self.console.set_status('Fence', 'FEN', row=0, fg='red')
|
[
"def",
"mavlink_packet",
"(",
"self",
",",
"m",
")",
":",
"if",
"m",
".",
"get_type",
"(",
")",
"==",
"\"FENCE_STATUS\"",
":",
"self",
".",
"last_fence_breach",
"=",
"m",
".",
"breach_time",
"self",
".",
"last_fence_status",
"=",
"m",
".",
"breach_status",
"elif",
"m",
".",
"get_type",
"(",
")",
"in",
"[",
"'SYS_STATUS'",
"]",
":",
"bits",
"=",
"mavutil",
".",
"mavlink",
".",
"MAV_SYS_STATUS_GEOFENCE",
"present",
"=",
"(",
"(",
"m",
".",
"onboard_control_sensors_present",
"&",
"bits",
")",
"==",
"bits",
")",
"if",
"self",
".",
"present",
"==",
"False",
"and",
"present",
"==",
"True",
":",
"self",
".",
"say",
"(",
"\"fence present\"",
")",
"elif",
"self",
".",
"present",
"==",
"True",
"and",
"present",
"==",
"False",
":",
"self",
".",
"say",
"(",
"\"fence removed\"",
")",
"self",
".",
"present",
"=",
"present",
"enabled",
"=",
"(",
"(",
"m",
".",
"onboard_control_sensors_enabled",
"&",
"bits",
")",
"==",
"bits",
")",
"if",
"self",
".",
"enabled",
"==",
"False",
"and",
"enabled",
"==",
"True",
":",
"self",
".",
"say",
"(",
"\"fence enabled\"",
")",
"elif",
"self",
".",
"enabled",
"==",
"True",
"and",
"enabled",
"==",
"False",
":",
"self",
".",
"say",
"(",
"\"fence disabled\"",
")",
"self",
".",
"enabled",
"=",
"enabled",
"healthy",
"=",
"(",
"(",
"m",
".",
"onboard_control_sensors_health",
"&",
"bits",
")",
"==",
"bits",
")",
"if",
"self",
".",
"healthy",
"==",
"False",
"and",
"healthy",
"==",
"True",
":",
"self",
".",
"say",
"(",
"\"fence OK\"",
")",
"elif",
"self",
".",
"healthy",
"==",
"True",
"and",
"healthy",
"==",
"False",
":",
"self",
".",
"say",
"(",
"\"fence breach\"",
")",
"self",
".",
"healthy",
"=",
"healthy",
"#console output for fence:",
"if",
"not",
"self",
".",
"present",
":",
"self",
".",
"console",
".",
"set_status",
"(",
"'Fence'",
",",
"'FEN'",
",",
"row",
"=",
"0",
",",
"fg",
"=",
"'black'",
")",
"elif",
"self",
".",
"enabled",
"==",
"False",
":",
"self",
".",
"console",
".",
"set_status",
"(",
"'Fence'",
",",
"'FEN'",
",",
"row",
"=",
"0",
",",
"fg",
"=",
"'grey'",
")",
"elif",
"self",
".",
"enabled",
"==",
"True",
"and",
"self",
".",
"healthy",
"==",
"True",
":",
"self",
".",
"console",
".",
"set_status",
"(",
"'Fence'",
",",
"'FEN'",
",",
"row",
"=",
"0",
",",
"fg",
"=",
"'green'",
")",
"elif",
"self",
".",
"enabled",
"==",
"True",
"and",
"self",
".",
"healthy",
"==",
"False",
":",
"self",
".",
"console",
".",
"set_status",
"(",
"'Fence'",
",",
"'FEN'",
",",
"row",
"=",
"0",
",",
"fg",
"=",
"'red'",
")"
] |
handle and incoming mavlink packet
|
[
"handle",
"and",
"incoming",
"mavlink",
"packet"
] |
f50bdeff33064876f7dc8dc4683d278ff47f75d5
|
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_fence.py#L66-L103
|
235,689
|
ArduPilot/MAVProxy
|
MAVProxy/modules/mavproxy_fence.py
|
FenceModule.load_fence
|
def load_fence(self, filename):
'''load fence points from a file'''
try:
self.fenceloader.target_system = self.target_system
self.fenceloader.target_component = self.target_component
self.fenceloader.load(filename.strip('"'))
except Exception as msg:
print("Unable to load %s - %s" % (filename, msg))
return
print("Loaded %u geo-fence points from %s" % (self.fenceloader.count(), filename))
self.send_fence()
|
python
|
def load_fence(self, filename):
'''load fence points from a file'''
try:
self.fenceloader.target_system = self.target_system
self.fenceloader.target_component = self.target_component
self.fenceloader.load(filename.strip('"'))
except Exception as msg:
print("Unable to load %s - %s" % (filename, msg))
return
print("Loaded %u geo-fence points from %s" % (self.fenceloader.count(), filename))
self.send_fence()
|
[
"def",
"load_fence",
"(",
"self",
",",
"filename",
")",
":",
"try",
":",
"self",
".",
"fenceloader",
".",
"target_system",
"=",
"self",
".",
"target_system",
"self",
".",
"fenceloader",
".",
"target_component",
"=",
"self",
".",
"target_component",
"self",
".",
"fenceloader",
".",
"load",
"(",
"filename",
".",
"strip",
"(",
"'\"'",
")",
")",
"except",
"Exception",
"as",
"msg",
":",
"print",
"(",
"\"Unable to load %s - %s\"",
"%",
"(",
"filename",
",",
"msg",
")",
")",
"return",
"print",
"(",
"\"Loaded %u geo-fence points from %s\"",
"%",
"(",
"self",
".",
"fenceloader",
".",
"count",
"(",
")",
",",
"filename",
")",
")",
"self",
".",
"send_fence",
"(",
")"
] |
load fence points from a file
|
[
"load",
"fence",
"points",
"from",
"a",
"file"
] |
f50bdeff33064876f7dc8dc4683d278ff47f75d5
|
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_fence.py#L205-L215
|
235,690
|
ArduPilot/MAVProxy
|
MAVProxy/modules/mavproxy_fence.py
|
FenceModule.list_fence
|
def list_fence(self, filename):
'''list fence points, optionally saving to a file'''
self.fenceloader.clear()
count = self.get_mav_param('FENCE_TOTAL', 0)
if count == 0:
print("No geo-fence points")
return
for i in range(int(count)):
p = self.fetch_fence_point(i)
if p is None:
return
self.fenceloader.add(p)
if filename is not None:
try:
self.fenceloader.save(filename.strip('"'))
except Exception as msg:
print("Unable to save %s - %s" % (filename, msg))
return
print("Saved %u geo-fence points to %s" % (self.fenceloader.count(), filename))
else:
for i in range(self.fenceloader.count()):
p = self.fenceloader.point(i)
self.console.writeln("lat=%f lng=%f" % (p.lat, p.lng))
if self.status.logdir is not None:
fname = 'fence.txt'
if self.target_system > 1:
fname = 'fence_%u.txt' % self.target_system
fencetxt = os.path.join(self.status.logdir, fname)
self.fenceloader.save(fencetxt.strip('"'))
print("Saved fence to %s" % fencetxt)
self.have_list = True
|
python
|
def list_fence(self, filename):
'''list fence points, optionally saving to a file'''
self.fenceloader.clear()
count = self.get_mav_param('FENCE_TOTAL', 0)
if count == 0:
print("No geo-fence points")
return
for i in range(int(count)):
p = self.fetch_fence_point(i)
if p is None:
return
self.fenceloader.add(p)
if filename is not None:
try:
self.fenceloader.save(filename.strip('"'))
except Exception as msg:
print("Unable to save %s - %s" % (filename, msg))
return
print("Saved %u geo-fence points to %s" % (self.fenceloader.count(), filename))
else:
for i in range(self.fenceloader.count()):
p = self.fenceloader.point(i)
self.console.writeln("lat=%f lng=%f" % (p.lat, p.lng))
if self.status.logdir is not None:
fname = 'fence.txt'
if self.target_system > 1:
fname = 'fence_%u.txt' % self.target_system
fencetxt = os.path.join(self.status.logdir, fname)
self.fenceloader.save(fencetxt.strip('"'))
print("Saved fence to %s" % fencetxt)
self.have_list = True
|
[
"def",
"list_fence",
"(",
"self",
",",
"filename",
")",
":",
"self",
".",
"fenceloader",
".",
"clear",
"(",
")",
"count",
"=",
"self",
".",
"get_mav_param",
"(",
"'FENCE_TOTAL'",
",",
"0",
")",
"if",
"count",
"==",
"0",
":",
"print",
"(",
"\"No geo-fence points\"",
")",
"return",
"for",
"i",
"in",
"range",
"(",
"int",
"(",
"count",
")",
")",
":",
"p",
"=",
"self",
".",
"fetch_fence_point",
"(",
"i",
")",
"if",
"p",
"is",
"None",
":",
"return",
"self",
".",
"fenceloader",
".",
"add",
"(",
"p",
")",
"if",
"filename",
"is",
"not",
"None",
":",
"try",
":",
"self",
".",
"fenceloader",
".",
"save",
"(",
"filename",
".",
"strip",
"(",
"'\"'",
")",
")",
"except",
"Exception",
"as",
"msg",
":",
"print",
"(",
"\"Unable to save %s - %s\"",
"%",
"(",
"filename",
",",
"msg",
")",
")",
"return",
"print",
"(",
"\"Saved %u geo-fence points to %s\"",
"%",
"(",
"self",
".",
"fenceloader",
".",
"count",
"(",
")",
",",
"filename",
")",
")",
"else",
":",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"fenceloader",
".",
"count",
"(",
")",
")",
":",
"p",
"=",
"self",
".",
"fenceloader",
".",
"point",
"(",
"i",
")",
"self",
".",
"console",
".",
"writeln",
"(",
"\"lat=%f lng=%f\"",
"%",
"(",
"p",
".",
"lat",
",",
"p",
".",
"lng",
")",
")",
"if",
"self",
".",
"status",
".",
"logdir",
"is",
"not",
"None",
":",
"fname",
"=",
"'fence.txt'",
"if",
"self",
".",
"target_system",
">",
"1",
":",
"fname",
"=",
"'fence_%u.txt'",
"%",
"self",
".",
"target_system",
"fencetxt",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"status",
".",
"logdir",
",",
"fname",
")",
"self",
".",
"fenceloader",
".",
"save",
"(",
"fencetxt",
".",
"strip",
"(",
"'\"'",
")",
")",
"print",
"(",
"\"Saved fence to %s\"",
"%",
"fencetxt",
")",
"self",
".",
"have_list",
"=",
"True"
] |
list fence points, optionally saving to a file
|
[
"list",
"fence",
"points",
"optionally",
"saving",
"to",
"a",
"file"
] |
f50bdeff33064876f7dc8dc4683d278ff47f75d5
|
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_fence.py#L277-L308
|
235,691
|
ArduPilot/MAVProxy
|
MAVProxy/modules/lib/mp_image.py
|
MPImage.poll
|
def poll(self):
'''check for events, returning one event'''
if self.out_queue.qsize() <= 0:
return None
evt = self.out_queue.get()
while isinstance(evt, win_layout.WinLayout):
win_layout.set_layout(evt, self.set_layout)
if self.out_queue.qsize() == 0:
return None
evt = self.out_queue.get()
return evt
|
python
|
def poll(self):
'''check for events, returning one event'''
if self.out_queue.qsize() <= 0:
return None
evt = self.out_queue.get()
while isinstance(evt, win_layout.WinLayout):
win_layout.set_layout(evt, self.set_layout)
if self.out_queue.qsize() == 0:
return None
evt = self.out_queue.get()
return evt
|
[
"def",
"poll",
"(",
"self",
")",
":",
"if",
"self",
".",
"out_queue",
".",
"qsize",
"(",
")",
"<=",
"0",
":",
"return",
"None",
"evt",
"=",
"self",
".",
"out_queue",
".",
"get",
"(",
")",
"while",
"isinstance",
"(",
"evt",
",",
"win_layout",
".",
"WinLayout",
")",
":",
"win_layout",
".",
"set_layout",
"(",
"evt",
",",
"self",
".",
"set_layout",
")",
"if",
"self",
".",
"out_queue",
".",
"qsize",
"(",
")",
"==",
"0",
":",
"return",
"None",
"evt",
"=",
"self",
".",
"out_queue",
".",
"get",
"(",
")",
"return",
"evt"
] |
check for events, returning one event
|
[
"check",
"for",
"events",
"returning",
"one",
"event"
] |
f50bdeff33064876f7dc8dc4683d278ff47f75d5
|
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/mp_image.py#L172-L182
|
235,692
|
ArduPilot/MAVProxy
|
MAVProxy/modules/mavproxy_map/mp_slipmap_ui.py
|
MPSlipMapFrame.find_object
|
def find_object(self, key, layers):
'''find an object to be modified'''
state = self.state
if layers is None or layers == '':
layers = state.layers.keys()
for layer in layers:
if key in state.layers[layer]:
return state.layers[layer][key]
return None
|
python
|
def find_object(self, key, layers):
'''find an object to be modified'''
state = self.state
if layers is None or layers == '':
layers = state.layers.keys()
for layer in layers:
if key in state.layers[layer]:
return state.layers[layer][key]
return None
|
[
"def",
"find_object",
"(",
"self",
",",
"key",
",",
"layers",
")",
":",
"state",
"=",
"self",
".",
"state",
"if",
"layers",
"is",
"None",
"or",
"layers",
"==",
"''",
":",
"layers",
"=",
"state",
".",
"layers",
".",
"keys",
"(",
")",
"for",
"layer",
"in",
"layers",
":",
"if",
"key",
"in",
"state",
".",
"layers",
"[",
"layer",
"]",
":",
"return",
"state",
".",
"layers",
"[",
"layer",
"]",
"[",
"key",
"]",
"return",
"None"
] |
find an object to be modified
|
[
"find",
"an",
"object",
"to",
"be",
"modified"
] |
f50bdeff33064876f7dc8dc4683d278ff47f75d5
|
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_map/mp_slipmap_ui.py#L140-L149
|
235,693
|
ArduPilot/MAVProxy
|
MAVProxy/modules/mavproxy_map/mp_slipmap_ui.py
|
MPSlipMapFrame.add_object
|
def add_object(self, obj):
'''add an object to a layer'''
state = self.state
if not obj.layer in state.layers:
# its a new layer
state.layers[obj.layer] = {}
state.layers[obj.layer][obj.key] = obj
state.need_redraw = True
if (not self.legend_checkbox_menuitem_added and
isinstance(obj, SlipFlightModeLegend)):
self.add_legend_checkbox_menuitem()
self.legend_checkbox_menuitem_added = True
self.SetMenuBar(self.menu.wx_menu())
|
python
|
def add_object(self, obj):
'''add an object to a layer'''
state = self.state
if not obj.layer in state.layers:
# its a new layer
state.layers[obj.layer] = {}
state.layers[obj.layer][obj.key] = obj
state.need_redraw = True
if (not self.legend_checkbox_menuitem_added and
isinstance(obj, SlipFlightModeLegend)):
self.add_legend_checkbox_menuitem()
self.legend_checkbox_menuitem_added = True
self.SetMenuBar(self.menu.wx_menu())
|
[
"def",
"add_object",
"(",
"self",
",",
"obj",
")",
":",
"state",
"=",
"self",
".",
"state",
"if",
"not",
"obj",
".",
"layer",
"in",
"state",
".",
"layers",
":",
"# its a new layer",
"state",
".",
"layers",
"[",
"obj",
".",
"layer",
"]",
"=",
"{",
"}",
"state",
".",
"layers",
"[",
"obj",
".",
"layer",
"]",
"[",
"obj",
".",
"key",
"]",
"=",
"obj",
"state",
".",
"need_redraw",
"=",
"True",
"if",
"(",
"not",
"self",
".",
"legend_checkbox_menuitem_added",
"and",
"isinstance",
"(",
"obj",
",",
"SlipFlightModeLegend",
")",
")",
":",
"self",
".",
"add_legend_checkbox_menuitem",
"(",
")",
"self",
".",
"legend_checkbox_menuitem_added",
"=",
"True",
"self",
".",
"SetMenuBar",
"(",
"self",
".",
"menu",
".",
"wx_menu",
"(",
")",
")"
] |
add an object to a layer
|
[
"add",
"an",
"object",
"to",
"a",
"layer"
] |
f50bdeff33064876f7dc8dc4683d278ff47f75d5
|
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_map/mp_slipmap_ui.py#L177-L189
|
235,694
|
ArduPilot/MAVProxy
|
MAVProxy/modules/mavproxy_map/mp_slipmap_ui.py
|
MPSlipMapPanel.set_ground_width
|
def set_ground_width(self, ground_width):
'''set ground width of view'''
state = self.state
state.ground_width = ground_width
state.panel.re_center(state.width/2, state.height/2, state.lat, state.lon)
|
python
|
def set_ground_width(self, ground_width):
'''set ground width of view'''
state = self.state
state.ground_width = ground_width
state.panel.re_center(state.width/2, state.height/2, state.lat, state.lon)
|
[
"def",
"set_ground_width",
"(",
"self",
",",
"ground_width",
")",
":",
"state",
"=",
"self",
".",
"state",
"state",
".",
"ground_width",
"=",
"ground_width",
"state",
".",
"panel",
".",
"re_center",
"(",
"state",
".",
"width",
"/",
"2",
",",
"state",
".",
"height",
"/",
"2",
",",
"state",
".",
"lat",
",",
"state",
".",
"lon",
")"
] |
set ground width of view
|
[
"set",
"ground",
"width",
"of",
"view"
] |
f50bdeff33064876f7dc8dc4683d278ff47f75d5
|
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_map/mp_slipmap_ui.py#L387-L391
|
235,695
|
ArduPilot/MAVProxy
|
MAVProxy/modules/mavproxy_map/mp_slipmap_ui.py
|
MPSlipMapPanel.show_popup
|
def show_popup(self, selected, pos):
'''show popup menu for an object'''
state = self.state
if selected.popup_menu is not None:
import copy
popup_menu = selected.popup_menu
if state.default_popup is not None and state.default_popup.combine:
popup_menu = copy.deepcopy(popup_menu)
popup_menu.add(MPMenuSeparator())
popup_menu.combine(state.default_popup.popup)
wx_menu = popup_menu.wx_menu()
state.frame.PopupMenu(wx_menu, pos)
|
python
|
def show_popup(self, selected, pos):
'''show popup menu for an object'''
state = self.state
if selected.popup_menu is not None:
import copy
popup_menu = selected.popup_menu
if state.default_popup is not None and state.default_popup.combine:
popup_menu = copy.deepcopy(popup_menu)
popup_menu.add(MPMenuSeparator())
popup_menu.combine(state.default_popup.popup)
wx_menu = popup_menu.wx_menu()
state.frame.PopupMenu(wx_menu, pos)
|
[
"def",
"show_popup",
"(",
"self",
",",
"selected",
",",
"pos",
")",
":",
"state",
"=",
"self",
".",
"state",
"if",
"selected",
".",
"popup_menu",
"is",
"not",
"None",
":",
"import",
"copy",
"popup_menu",
"=",
"selected",
".",
"popup_menu",
"if",
"state",
".",
"default_popup",
"is",
"not",
"None",
"and",
"state",
".",
"default_popup",
".",
"combine",
":",
"popup_menu",
"=",
"copy",
".",
"deepcopy",
"(",
"popup_menu",
")",
"popup_menu",
".",
"add",
"(",
"MPMenuSeparator",
"(",
")",
")",
"popup_menu",
".",
"combine",
"(",
"state",
".",
"default_popup",
".",
"popup",
")",
"wx_menu",
"=",
"popup_menu",
".",
"wx_menu",
"(",
")",
"state",
".",
"frame",
".",
"PopupMenu",
"(",
"wx_menu",
",",
"pos",
")"
] |
show popup menu for an object
|
[
"show",
"popup",
"menu",
"for",
"an",
"object"
] |
f50bdeff33064876f7dc8dc4683d278ff47f75d5
|
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_map/mp_slipmap_ui.py#L568-L579
|
235,696
|
ArduPilot/MAVProxy
|
MAVProxy/mavproxy.py
|
cmd_watch
|
def cmd_watch(args):
'''watch a mavlink packet pattern'''
if len(args) == 0:
mpstate.status.watch = None
return
mpstate.status.watch = args
print("Watching %s" % mpstate.status.watch)
|
python
|
def cmd_watch(args):
'''watch a mavlink packet pattern'''
if len(args) == 0:
mpstate.status.watch = None
return
mpstate.status.watch = args
print("Watching %s" % mpstate.status.watch)
|
[
"def",
"cmd_watch",
"(",
"args",
")",
":",
"if",
"len",
"(",
"args",
")",
"==",
"0",
":",
"mpstate",
".",
"status",
".",
"watch",
"=",
"None",
"return",
"mpstate",
".",
"status",
".",
"watch",
"=",
"args",
"print",
"(",
"\"Watching %s\"",
"%",
"mpstate",
".",
"status",
".",
"watch",
")"
] |
watch a mavlink packet pattern
|
[
"watch",
"a",
"mavlink",
"packet",
"pattern"
] |
f50bdeff33064876f7dc8dc4683d278ff47f75d5
|
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/mavproxy.py#L315-L321
|
235,697
|
ArduPilot/MAVProxy
|
MAVProxy/mavproxy.py
|
load_module
|
def load_module(modname, quiet=False, **kwargs):
'''load a module'''
modpaths = ['MAVProxy.modules.mavproxy_%s' % modname, modname]
for (m,pm) in mpstate.modules:
if m.name == modname and not modname in mpstate.multi_instance:
if not quiet:
print("module %s already loaded" % modname)
# don't report an error
return True
ex = None
for modpath in modpaths:
try:
m = import_package(modpath)
reload(m)
module = m.init(mpstate, **kwargs)
if isinstance(module, mp_module.MPModule):
mpstate.modules.append((module, m))
if not quiet:
if kwargs:
print("Loaded module %s with kwargs = %s" % (modname, kwargs))
else:
print("Loaded module %s" % (modname,))
return True
else:
ex = "%s.init did not return a MPModule instance" % modname
break
except ImportError as msg:
ex = msg
if mpstate.settings.moddebug > 1:
import traceback
print(traceback.format_exc())
help_traceback = ""
if mpstate.settings.moddebug < 3:
help_traceback = " Use 'set moddebug 3' in the MAVProxy console to enable traceback"
print("Failed to load module: %s.%s" % (ex, help_traceback))
return False
|
python
|
def load_module(modname, quiet=False, **kwargs):
'''load a module'''
modpaths = ['MAVProxy.modules.mavproxy_%s' % modname, modname]
for (m,pm) in mpstate.modules:
if m.name == modname and not modname in mpstate.multi_instance:
if not quiet:
print("module %s already loaded" % modname)
# don't report an error
return True
ex = None
for modpath in modpaths:
try:
m = import_package(modpath)
reload(m)
module = m.init(mpstate, **kwargs)
if isinstance(module, mp_module.MPModule):
mpstate.modules.append((module, m))
if not quiet:
if kwargs:
print("Loaded module %s with kwargs = %s" % (modname, kwargs))
else:
print("Loaded module %s" % (modname,))
return True
else:
ex = "%s.init did not return a MPModule instance" % modname
break
except ImportError as msg:
ex = msg
if mpstate.settings.moddebug > 1:
import traceback
print(traceback.format_exc())
help_traceback = ""
if mpstate.settings.moddebug < 3:
help_traceback = " Use 'set moddebug 3' in the MAVProxy console to enable traceback"
print("Failed to load module: %s.%s" % (ex, help_traceback))
return False
|
[
"def",
"load_module",
"(",
"modname",
",",
"quiet",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"modpaths",
"=",
"[",
"'MAVProxy.modules.mavproxy_%s'",
"%",
"modname",
",",
"modname",
"]",
"for",
"(",
"m",
",",
"pm",
")",
"in",
"mpstate",
".",
"modules",
":",
"if",
"m",
".",
"name",
"==",
"modname",
"and",
"not",
"modname",
"in",
"mpstate",
".",
"multi_instance",
":",
"if",
"not",
"quiet",
":",
"print",
"(",
"\"module %s already loaded\"",
"%",
"modname",
")",
"# don't report an error",
"return",
"True",
"ex",
"=",
"None",
"for",
"modpath",
"in",
"modpaths",
":",
"try",
":",
"m",
"=",
"import_package",
"(",
"modpath",
")",
"reload",
"(",
"m",
")",
"module",
"=",
"m",
".",
"init",
"(",
"mpstate",
",",
"*",
"*",
"kwargs",
")",
"if",
"isinstance",
"(",
"module",
",",
"mp_module",
".",
"MPModule",
")",
":",
"mpstate",
".",
"modules",
".",
"append",
"(",
"(",
"module",
",",
"m",
")",
")",
"if",
"not",
"quiet",
":",
"if",
"kwargs",
":",
"print",
"(",
"\"Loaded module %s with kwargs = %s\"",
"%",
"(",
"modname",
",",
"kwargs",
")",
")",
"else",
":",
"print",
"(",
"\"Loaded module %s\"",
"%",
"(",
"modname",
",",
")",
")",
"return",
"True",
"else",
":",
"ex",
"=",
"\"%s.init did not return a MPModule instance\"",
"%",
"modname",
"break",
"except",
"ImportError",
"as",
"msg",
":",
"ex",
"=",
"msg",
"if",
"mpstate",
".",
"settings",
".",
"moddebug",
">",
"1",
":",
"import",
"traceback",
"print",
"(",
"traceback",
".",
"format_exc",
"(",
")",
")",
"help_traceback",
"=",
"\"\"",
"if",
"mpstate",
".",
"settings",
".",
"moddebug",
"<",
"3",
":",
"help_traceback",
"=",
"\" Use 'set moddebug 3' in the MAVProxy console to enable traceback\"",
"print",
"(",
"\"Failed to load module: %s.%s\"",
"%",
"(",
"ex",
",",
"help_traceback",
")",
")",
"return",
"False"
] |
load a module
|
[
"load",
"a",
"module"
] |
f50bdeff33064876f7dc8dc4683d278ff47f75d5
|
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/mavproxy.py#L337-L372
|
235,698
|
ArduPilot/MAVProxy
|
MAVProxy/mavproxy.py
|
process_mavlink
|
def process_mavlink(slave):
'''process packets from MAVLink slaves, forwarding to the master'''
try:
buf = slave.recv()
except socket.error:
return
try:
global mavversion
if slave.first_byte and mavversion is None:
slave.auto_mavlink_version(buf)
msgs = slave.mav.parse_buffer(buf)
except mavutil.mavlink.MAVError as e:
mpstate.console.error("Bad MAVLink slave message from %s: %s" % (slave.address, e.message))
return
if msgs is None:
return
if mpstate.settings.mavfwd and not mpstate.status.setup_mode:
for m in msgs:
mpstate.master().write(m.get_msgbuf())
if mpstate.status.watch:
for msg_type in mpstate.status.watch:
if fnmatch.fnmatch(m.get_type().upper(), msg_type.upper()):
mpstate.console.writeln('> '+ str(m))
break
mpstate.status.counters['Slave'] += 1
|
python
|
def process_mavlink(slave):
'''process packets from MAVLink slaves, forwarding to the master'''
try:
buf = slave.recv()
except socket.error:
return
try:
global mavversion
if slave.first_byte and mavversion is None:
slave.auto_mavlink_version(buf)
msgs = slave.mav.parse_buffer(buf)
except mavutil.mavlink.MAVError as e:
mpstate.console.error("Bad MAVLink slave message from %s: %s" % (slave.address, e.message))
return
if msgs is None:
return
if mpstate.settings.mavfwd and not mpstate.status.setup_mode:
for m in msgs:
mpstate.master().write(m.get_msgbuf())
if mpstate.status.watch:
for msg_type in mpstate.status.watch:
if fnmatch.fnmatch(m.get_type().upper(), msg_type.upper()):
mpstate.console.writeln('> '+ str(m))
break
mpstate.status.counters['Slave'] += 1
|
[
"def",
"process_mavlink",
"(",
"slave",
")",
":",
"try",
":",
"buf",
"=",
"slave",
".",
"recv",
"(",
")",
"except",
"socket",
".",
"error",
":",
"return",
"try",
":",
"global",
"mavversion",
"if",
"slave",
".",
"first_byte",
"and",
"mavversion",
"is",
"None",
":",
"slave",
".",
"auto_mavlink_version",
"(",
"buf",
")",
"msgs",
"=",
"slave",
".",
"mav",
".",
"parse_buffer",
"(",
"buf",
")",
"except",
"mavutil",
".",
"mavlink",
".",
"MAVError",
"as",
"e",
":",
"mpstate",
".",
"console",
".",
"error",
"(",
"\"Bad MAVLink slave message from %s: %s\"",
"%",
"(",
"slave",
".",
"address",
",",
"e",
".",
"message",
")",
")",
"return",
"if",
"msgs",
"is",
"None",
":",
"return",
"if",
"mpstate",
".",
"settings",
".",
"mavfwd",
"and",
"not",
"mpstate",
".",
"status",
".",
"setup_mode",
":",
"for",
"m",
"in",
"msgs",
":",
"mpstate",
".",
"master",
"(",
")",
".",
"write",
"(",
"m",
".",
"get_msgbuf",
"(",
")",
")",
"if",
"mpstate",
".",
"status",
".",
"watch",
":",
"for",
"msg_type",
"in",
"mpstate",
".",
"status",
".",
"watch",
":",
"if",
"fnmatch",
".",
"fnmatch",
"(",
"m",
".",
"get_type",
"(",
")",
".",
"upper",
"(",
")",
",",
"msg_type",
".",
"upper",
"(",
")",
")",
":",
"mpstate",
".",
"console",
".",
"writeln",
"(",
"'> '",
"+",
"str",
"(",
"m",
")",
")",
"break",
"mpstate",
".",
"status",
".",
"counters",
"[",
"'Slave'",
"]",
"+=",
"1"
] |
process packets from MAVLink slaves, forwarding to the master
|
[
"process",
"packets",
"from",
"MAVLink",
"slaves",
"forwarding",
"to",
"the",
"master"
] |
f50bdeff33064876f7dc8dc4683d278ff47f75d5
|
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/mavproxy.py#L638-L662
|
235,699
|
ArduPilot/MAVProxy
|
MAVProxy/mavproxy.py
|
log_writer
|
def log_writer():
'''log writing thread'''
while True:
mpstate.logfile_raw.write(bytearray(mpstate.logqueue_raw.get()))
timeout = time.time() + 10
while not mpstate.logqueue_raw.empty() and time.time() < timeout:
mpstate.logfile_raw.write(mpstate.logqueue_raw.get())
while not mpstate.logqueue.empty() and time.time() < timeout:
mpstate.logfile.write(mpstate.logqueue.get())
if mpstate.settings.flushlogs or time.time() >= timeout:
mpstate.logfile.flush()
mpstate.logfile_raw.flush()
|
python
|
def log_writer():
'''log writing thread'''
while True:
mpstate.logfile_raw.write(bytearray(mpstate.logqueue_raw.get()))
timeout = time.time() + 10
while not mpstate.logqueue_raw.empty() and time.time() < timeout:
mpstate.logfile_raw.write(mpstate.logqueue_raw.get())
while not mpstate.logqueue.empty() and time.time() < timeout:
mpstate.logfile.write(mpstate.logqueue.get())
if mpstate.settings.flushlogs or time.time() >= timeout:
mpstate.logfile.flush()
mpstate.logfile_raw.flush()
|
[
"def",
"log_writer",
"(",
")",
":",
"while",
"True",
":",
"mpstate",
".",
"logfile_raw",
".",
"write",
"(",
"bytearray",
"(",
"mpstate",
".",
"logqueue_raw",
".",
"get",
"(",
")",
")",
")",
"timeout",
"=",
"time",
".",
"time",
"(",
")",
"+",
"10",
"while",
"not",
"mpstate",
".",
"logqueue_raw",
".",
"empty",
"(",
")",
"and",
"time",
".",
"time",
"(",
")",
"<",
"timeout",
":",
"mpstate",
".",
"logfile_raw",
".",
"write",
"(",
"mpstate",
".",
"logqueue_raw",
".",
"get",
"(",
")",
")",
"while",
"not",
"mpstate",
".",
"logqueue",
".",
"empty",
"(",
")",
"and",
"time",
".",
"time",
"(",
")",
"<",
"timeout",
":",
"mpstate",
".",
"logfile",
".",
"write",
"(",
"mpstate",
".",
"logqueue",
".",
"get",
"(",
")",
")",
"if",
"mpstate",
".",
"settings",
".",
"flushlogs",
"or",
"time",
".",
"time",
"(",
")",
">=",
"timeout",
":",
"mpstate",
".",
"logfile",
".",
"flush",
"(",
")",
"mpstate",
".",
"logfile_raw",
".",
"flush",
"(",
")"
] |
log writing thread
|
[
"log",
"writing",
"thread"
] |
f50bdeff33064876f7dc8dc4683d278ff47f75d5
|
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/mavproxy.py#L677-L688
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.