Skip to content

Commit

Permalink
mavproxy_map: add returnpoint manipulation
Browse files Browse the repository at this point in the history
  • Loading branch information
peterbarker authored and tridge committed Aug 9, 2023
1 parent d2778bb commit 7e956c6
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions MAVProxy/modules/mavproxy_map/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,13 @@ def polyfence_remove_circle(self, id):
(seq, type) = id.split(":")
self.module('fence').removecircle(int(seq))

def polyfence_remove_returnpoint(self, id):
'''called when a returnpoint is right-clicked and remove is selected;
removes the return point
'''
(seq, type) = id.split(":")
self.module('fence').removereturnpoint(int(seq))

def polyfence_remove_polygon(self, id):
'''called when a fence is right-clicked and remove is selected;
removes the polygon
Expand Down Expand Up @@ -396,6 +403,32 @@ def display_polyfences_polygons(self, polygons, colour):
popup_menu=popup)
self.map.add_object(poly)

def display_polyfences_returnpoint(self):
returnpoint = self.module('fence').returnpoint()

if returnpoint is None:
return

lat = returnpoint.x
lng = returnpoint.y

if returnpoint.get_type() == 'MISSION_ITEM_INT':
lat *= 1e-7
lng *= 1e-7

popup = MPMenuSubMenu('Popup', [
MPMenuItem('Remove Return Point', returnkey='popupPolyFenceRemoveReturnPoint'),
])
self.map.add_object(mp_slipmap.SlipCircle(
str(returnpoint.seq) + ":returnpoint", # key
'PolyFence',
(lat, lng),
10,
(255,127,127),
2,
popup_menu=popup,
))

def display_polyfences_inclusion_polygons(self):
'''draws inclusion polygons in the PolyFence layer with colour colour'''
inclusions = self.module('fence').inclusion_polygons()
Expand All @@ -413,6 +446,7 @@ def display_polyfences(self):
self.display_polyfences_exclusion_circles()
self.display_polyfences_inclusion_polygons()
self.display_polyfences_exclusion_polygons()
self.display_polyfences_returnpoint()

def display_fence(self):
'''display the fence'''
Expand Down Expand Up @@ -543,6 +577,8 @@ def handle_menu_event(self, obj):
self.move_fencepoint(obj.selected[0].objkey, obj.selected[0].extra_info)
elif menuitem.returnkey == 'popupPolyFenceRemoveCircle':
self.polyfence_remove_circle(obj.selected[0].objkey)
elif menuitem.returnkey == 'popupPolyFenceRemoveReturnPoint':
self.polyfence_remove_returnpoint(obj.selected[0].objkey)
elif menuitem.returnkey == 'popupPolyFenceRemovePolygon':
self.polyfence_remove_polygon(obj.selected[0].objkey)
elif menuitem.returnkey == 'popupPolyFenceMovePolygonPoint':
Expand Down

0 comments on commit 7e956c6

Please sign in to comment.