From 65cb057322e5f032fe9ddb2df9b8b283e64ac343 Mon Sep 17 00:00:00 2001 From: Randy Mackay Date: Thu, 10 Oct 2024 16:32:35 +0900 Subject: [PATCH] mavpicviewer: support clear all POI --- .../tools/mavpicviewer/mavpicviewer_image.py | 17 +++++++++++++++++ .../tools/mavpicviewer/mavpicviewer_mosaic.py | 19 ++++++++++++++----- .../tools/mavpicviewer/mavpicviewer_shared.py | 6 ++++++ 3 files changed, 37 insertions(+), 5 deletions(-) diff --git a/MAVProxy/tools/mavpicviewer/mavpicviewer_image.py b/MAVProxy/tools/mavpicviewer/mavpicviewer_image.py index 9729e836ff..4b0993e7d0 100644 --- a/MAVProxy/tools/mavpicviewer/mavpicviewer_image.py +++ b/MAVProxy/tools/mavpicviewer/mavpicviewer_image.py @@ -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) @@ -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() diff --git a/MAVProxy/tools/mavpicviewer/mavpicviewer_mosaic.py b/MAVProxy/tools/mavpicviewer/mavpicviewer_mosaic.py index 42d70151b9..96a006f2a4 100644 --- a/MAVProxy/tools/mavpicviewer/mavpicviewer_mosaic.py +++ b/MAVProxy/tools/mavpicviewer/mavpicviewer_mosaic.py @@ -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) @@ -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""" @@ -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) @@ -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): diff --git a/MAVProxy/tools/mavpicviewer/mavpicviewer_shared.py b/MAVProxy/tools/mavpicviewer/mavpicviewer_shared.py index 292ea56d2d..1654cb5c37 100644 --- a/MAVProxy/tools/mavpicviewer/mavpicviewer_shared.py +++ b/MAVProxy/tools/mavpicviewer/mavpicviewer_shared.py @@ -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 @@ -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):