Skip to content

Commit

Permalink
mavpicviewer: support clear all POI
Browse files Browse the repository at this point in the history
  • Loading branch information
rmackay9 committed Oct 10, 2024
1 parent 1f8e4f9 commit 65cb057
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 5 deletions.
17 changes: 17 additions & 0 deletions MAVProxy/tools/mavpicviewer/mavpicviewer_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,15 @@ def handle_comm_object(self, obj):
"""process an object received on the communication pipe"""
if isinstance(obj, mpv.SetFilelist):
self.filelist = obj.filelist
self.poi_clear_all()
self.update_image()
self.update_map()
elif isinstance(obj, mpv.SetFilenumber):
self.set_filenumber(obj.filenumber, False)
elif isinstance(obj, mpv.SetFOV):
self.set_fov(obj.fov)
elif isinstance(obj, mpv.ClearAllPOI):
self.poi_clear_all()
elif isinstance(obj, mpv.Close):
self.close(False)

Expand Down Expand Up @@ -255,6 +258,20 @@ def poi_capture_done(self, X, Y):
def poi_cancel(self):
self.poi_start_pos = None

# clear all POI points from dictionary and map and current image
def poi_clear_all(self):
self.poi_cancel()
update_image_required = False
for filenumber in self.poi_dict.keys():
filename = self.filelist[filenumber]
if filename is not None:
self.remove_rectangle_from_map(filename)
if self.filenumber == filenumber:
update_image_required = True
self.poi_dict.clear()
if update_image_required:
self.update_image()

# clear poi from current image
def cmd_clear_poi(self):
self.poi_cancel()
Expand Down
19 changes: 14 additions & 5 deletions MAVProxy/tools/mavpicviewer/mavpicviewer_mosaic.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,10 @@ def __init__(self, folderpath, comm_pipe=None):
self.frame.Bind(wx.EVT_MENU, self.menu_display_poi_images, id=3)
self.menu.Append(4, "Settings", "Settings")
self.frame.Bind(wx.EVT_MENU, self.mavpicviewer_settings.show_settings_window, id=4)
self.menu.Append(5, "Quit", "Quit")
self.frame.Bind(wx.EVT_MENU, self.menu_quit, id=5)
self.menu.Append(5, "Clear All POI", "Clear POI from all images")
self.frame.Bind(wx.EVT_MENU, self.menu_clear_all_poi, id=5)
self.menu.Append(6, "Quit", "Quit")
self.frame.Bind(wx.EVT_MENU, self.menu_quit, id=6)
self.menu_bar = wx.MenuBar()
self.menu_bar.Append(self.menu, "Menu")
self.frame.SetMenuBar(self.menu_bar)
Expand Down Expand Up @@ -175,6 +177,13 @@ def menu_display_poi_images(self, event):
"""display POI images only"""
wx.CallAfter(self.display_all_images, poi_only=True)

# clear all POI
def menu_clear_all_poi(self, event):
"""clear all POI"""
for filenumber in list(self.poi_dict.keys()):
self.clear_image_poi(filenumber)
self.send_comm_object(mpv.ClearAllPOI())

# process menu quit event
def menu_quit(self, event, notify_image_viewer=True):
"""process menu quit event"""
Expand Down Expand Up @@ -207,7 +216,6 @@ def handle_comm_object(self, obj):
self.update_status_text()
elif isinstance(obj, mpv.ClearPOI):
self.clear_image_poi(obj.filenumber)
self.update_status_text()
elif isinstance(obj, mpv.SetTempAndPos):
if obj.temp_max is not None:
self.image_temp_dict[obj.filenumber] = mpv.TempAndPos(obj.temp_max, obj.temp_pos_x, obj.temp_pos_y)
Expand Down Expand Up @@ -294,10 +302,11 @@ def set_image_poi(self, filenumber, poi):
# clear image poi
def clear_image_poi(self, filenumber):
"""set image poi"""
print(f"clear_image_poi: {filenumber}")
if filenumber in self.poi_dict:
del self.poi_dict[filenumber]
self.update_status_text()
if filenumber == self.filenumber:
self.update_status_text()
self.update_highlighting(filenumber)

# process key events
def on_key(self, event):
Expand Down
6 changes: 6 additions & 0 deletions MAVProxy/tools/mavpicviewer/mavpicviewer_shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ def __init__(self, filenumber, loc):


# set POI for the given filenumber
# if poi is None then the entire image should be used
class SetPOI:
def __init__(self, filenumber, poi):
self.filenumber = filenumber
Expand All @@ -108,6 +109,11 @@ def __init__(self, filenumber):
self.filenumber = filenumber


# clear ALL POIs for all images
class ClearAllPOI:
def __init__(self):
pass

# set Temp data for the given filenumber
class SetTempAndPos:
def __init__(self, filenumber, temp_max, temp_pos_x, temp_pos_y):
Expand Down

0 comments on commit 65cb057

Please sign in to comment.