From cf53985feda74e686b5e554343da5c6f06879b93 Mon Sep 17 00:00:00 2001 From: Pierre-Antoine Rouby <pierre-antoine.rouby@inrae.fr> Date: Tue, 16 Jan 2024 09:05:27 +0100 Subject: [PATCH] Geometry: Remove some warning when profile not fully defined. --- src/View/Geometry/PlotAC.py | 10 ++++++++-- src/View/Geometry/PlotKPZ.py | 17 ++++++++++++++--- src/View/Geometry/PlotXY.py | 6 +++--- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/src/View/Geometry/PlotAC.py b/src/View/Geometry/PlotAC.py index 968f16eb..da0eb0bd 100644 --- a/src/View/Geometry/PlotAC.py +++ b/src/View/Geometry/PlotAC.py @@ -63,13 +63,19 @@ class PlotAC(PamhyrPlot): if self.data.number_profiles == 0: return + np = len(self.data.profiles) + if np < 2: + return + selected_profile = 0 + station = self.data.profile(selected_profile).get_station() - station_plus_1 = self.data.profile(selected_profile + 1).get_station() elevation = self.data.profile(selected_profile).z() - elevation_i_plus_1 = self.data.profile(selected_profile + 1).z() gl = self.data.profile(selected_profile).names() + station_plus_1 = self.data.profile(selected_profile + 1).get_station() + elevation_i_plus_1 = self.data.profile(selected_profile + 1).z() + self.canvas.axes.set_xlabel( _translate("MainWindow_reach", "Transverse abscissa (m)"), color='black', fontsize=10 diff --git a/src/View/Geometry/PlotKPZ.py b/src/View/Geometry/PlotKPZ.py index 6825abfa..2b4fd6e3 100644 --- a/src/View/Geometry/PlotKPZ.py +++ b/src/View/Geometry/PlotKPZ.py @@ -62,6 +62,17 @@ class PlotKPZ(PamhyrPlot): if self.data.number_profiles == 0: return + profiles_defined = any( + filter( + lambda profile: len(profile.x()) > 0, + self.data.profiles + ) + ) + + if not profiles_defined: + self._init = False + return + self.canvas.axes.set_xlabel( _translate("MainWindow_reach", "Kp (m)"), color='black', fontsize=10 @@ -75,9 +86,9 @@ class PlotKPZ(PamhyrPlot): z_min = self.data.get_z_min() z_max = self.data.get_z_max() - self.canvas.axes.set_xlim( - left=min(kp), right=max(kp) - ) + # self.canvas.axes.set_xlim( + # left=min(kp), right=max(kp) + # ) self.line_kp_zmin_zmax = self.canvas.axes.vlines( x=kp, diff --git a/src/View/Geometry/PlotXY.py b/src/View/Geometry/PlotXY.py index 9aba4652..f8cd23df 100644 --- a/src/View/Geometry/PlotXY.py +++ b/src/View/Geometry/PlotXY.py @@ -74,9 +74,9 @@ class PlotXY(PamhyrPlot): self.canvas.axes.axis("equal") kp = self.data.get_kp() - self.canvas.axes.set_xlim( - left=min(kp), right=max(kp) - ) + # self.canvas.axes.set_xlim( + # left=min(kp), right=max(kp) + # ) # Draw line for each profile self.line_xy = [ -- GitLab