Skip to content

Commit

Permalink
fix: LinearView and SideView plot to display operation name (#2592)
Browse files Browse the repository at this point in the history
The model name is shown on TopView, SideView, LinearView on top right corner of the plot.
  • Loading branch information
TheMightyRaider authored Jan 13, 2025
1 parent 885c403 commit 22145d9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
10 changes: 4 additions & 6 deletions mslib/msui/mpl_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ def __init__(self, identifier=None, CRS=None, BBOX_UNITS=None, OPERATION_NAME=No
# Print project name and CRS identifier into figure.
if not hasattr(self, "_info_text"):
self._info_text = self.ax.figure.text(0, 0, "")
self._infos = [None] * 4
self.update_info_text(name=self.operation_name, crs=self.crs)
self._infos = [None] * 3
self.update_info_text(crs=self.crs)

if self.appearance["draw_graticule"]:
pass
Expand All @@ -170,15 +170,13 @@ def __init__(self, identifier=None, CRS=None, BBOX_UNITS=None, OPERATION_NAME=No
self.airspaces = None
self.airspacetext = None

def update_info_text(self, openaip=None, ourairports=None, name=None, crs=None):
def update_info_text(self, openaip=None, ourairports=None, crs=None):
if openaip is not None:
self._infos[0] = openaip
if ourairports is not None:
self._infos[1] = ourairports
if name is not None:
self._infos[2] = name
if crs is not None:
self._infos[3] = crs
self._infos[2] = crs
self._info_text.set_text(
"\n".join([_i for _i in self._infos if _i])) # both None and ""

Expand Down
3 changes: 3 additions & 0 deletions mslib/msui/mpl_qtwidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ def __init__(self, fig=None, ax=None, settings_tag=None, settings=None):

def draw_metadata(self, title="", init_time=None, valid_time=None,
level=None, style=None):

if style:
title += f" ({style})"
if level:
Expand Down Expand Up @@ -733,7 +734,9 @@ def draw_legend(self, img):
raise NotImplementedError

def draw_image(self, xmls, colors=None, scales=None):
title = self.fig._suptitle.get_text()
self.clear_figure()
self.fig.suptitle(title, x=0.95, ha='right')
offset = 40
self.ax.patch.set_visible(False)

Expand Down
7 changes: 5 additions & 2 deletions mslib/msui/viewwindows.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,10 +274,13 @@ def setFlightTrackModel(self, model):

# Update Top View flighttrack name
if hasattr(self.mpl.canvas, "map"):
self.mpl.canvas.map.operation_name = model.name
self.mpl.canvas.map.update_info_text(name=model.name)
self.mpl.canvas.map.ax.figure.suptitle(f"{model.name}", x=0.95, ha='right')
self.mpl.canvas.map.ax.figure.canvas.draw()

elif hasattr(self.mpl.canvas, 'plotter'):
self.mpl.canvas.plotter.fig.suptitle(f"{model.name}", x=0.95, ha='right')
self.mpl.canvas.plotter.fig.canvas.draw()

def getView(self):
"""
Return the MplCanvas instance of the window.
Expand Down

0 comments on commit 22145d9

Please sign in to comment.