diff --git a/src/Model/Geometry/Reach.py b/src/Model/Geometry/Reach.py index 1cacb2f64e22b1ee5ed01b097421a5cf10910532..ff05d1a7af816f9fcb9eda7bc29fb8fb2b4a0ce1 100644 --- a/src/Model/Geometry/Reach.py +++ b/src/Model/Geometry/Reach.py @@ -269,13 +269,37 @@ class Reach(SQLSubModel): self._status.modified() def get_x(self): - return [profile.x() for profile in self.profiles] + return list( + map( + lambda profile: profile.x(), + filter( + lambda profile: len(profile) > 0, + self.profiles + ) + ) + ) def get_y(self): - return [profile.y() for profile in self.profiles] + return list( + map( + lambda profile: profile.y(), + filter( + lambda profile: len(profile) > 0, + self.profiles + ) + ) + ) def get_z(self): - return [profile.z() for profile in self.profiles] + return list( + map( + lambda profile: profile.z(), + filter( + lambda profile: len(profile) > 0, + self.profiles + ) + ) + ) def get_z_min(self): """List of z min for each profile @@ -283,7 +307,15 @@ class Reach(SQLSubModel): Returns: List of z min for each profile """ - return [profile.z_min() for profile in self.profiles] + return list( + map( + lambda profile: profile.z_min(), + filter( + lambda profile: len(profile) > 0, + self.profiles + ) + ) + ) def get_z_max(self): """List of z max for each profile @@ -291,7 +323,15 @@ class Reach(SQLSubModel): Returns: List of z max for each profile """ - return [profile.z_max() for profile in self.profiles] + return list( + map( + lambda profile: profile.z_max(), + filter( + lambda profile: len(profile) > 0, + self.profiles + ) + ) + ) def get_kp(self): """List of profiles kp @@ -301,6 +341,18 @@ class Reach(SQLSubModel): """ return [profile.kp for profile in self.profiles] + def get_kp_complete_profiles(self): + return list( + map( + lambda profile: profile.kp, + filter( + lambda profile: len(profile) > 0, + self.profiles + ) + ) + ) + + def get_kp_min(self): if len(self.get_kp()) > 0: return min(self.get_kp()) diff --git a/src/View/Geometry/PlotAC.py b/src/View/Geometry/PlotAC.py index da0eb0bd1598d0bf389bc0d44032af269b630957..80b6270de7786518420de9c2e773b89cae4a766b 100644 --- a/src/View/Geometry/PlotAC.py +++ b/src/View/Geometry/PlotAC.py @@ -114,7 +114,7 @@ class PlotAC(PamhyrPlot): lcomplete = list(self.complete_gl) lincomplete = list(self.incomplete_gl) - line_2d = [line_2D for line_2D in self.plot_xy.line_gl] + line_2d = self.plot_xy.line_gl self.color_complete_gl = self.get_line_gl_colors(line_2d) self.color_incomplete_gl = 2 * ["#000000"] @@ -191,11 +191,11 @@ class PlotAC(PamhyrPlot): self.canvas.figure.tight_layout() label_before_plot_selected = _translate( - "MainWindow_reach", "Profil précédent") + "MainWindow_reach", "Previous cross-section") label_plot_selected = _translate( - "MainWindow_reach", "Profil sélectionné") + "MainWindow_reach", "Cross-section") label_after_plot_selected = _translate( - "MainWindow_reach", "Profil suivant") + "MainWindow_reach", "Next cross-section") color_before_plot_selected = "k" # 'grey' color_plot_selected = 'b' color_after_plot_selected = 'm' @@ -219,7 +219,7 @@ class PlotAC(PamhyrPlot): lcomplete = list(self.complete_gl) lincomplete = list(self.incomplete_gl) - line_2d = [line_2D for line_2D in self.plot_xy.line_gl] + line_2d = self.plot_xy.line_gl self.color_complete_gl = self.get_line_gl_colors(line_2d) self.color_incomplete_gl = 2 * ["#000000"] @@ -248,12 +248,15 @@ class PlotAC(PamhyrPlot): x_gl_complete.append(station[i]) y_gl_complete.append(elevation[i]) color_scat_complete_gl.append( - self.color_complete_gl[lcomplete.index(txt)]) + self.color_complete_gl[lcomplete.index(txt)] + ) elif txt.strip() in self.incomplete_gl: annotate = self.canvas.axes.annotate( - txt, (station[i], elevation[i] - ), horizontalalignment='left', - verticalalignment='top', annotation_clip=True, fontsize=11, + txt, + (station[i], elevation[i]), + horizontalalignment='left', + verticalalignment='top', + annotation_clip=True, fontsize=11, color=self.color_incomplete_gl[ lincomplete.index(txt) ], @@ -333,6 +336,10 @@ class PlotAC(PamhyrPlot): self.draw() return + line_2d = self.plot_xy.line_gl + self.color_complete_gl = self.get_line_gl_colors(line_2d) + self.color_incomplete_gl = 2 * ["#000000"] + if ind is not None: before = ind - 1 after = ind + 1 diff --git a/src/View/Geometry/PlotKPZ.py b/src/View/Geometry/PlotKPZ.py index 2b4fd6e361bcbc812c3cb8908a6eadd656c5a554..ee289a7d531a9d6e295c192c26c1a38a3797095c 100644 --- a/src/View/Geometry/PlotKPZ.py +++ b/src/View/Geometry/PlotKPZ.py @@ -59,12 +59,12 @@ class PlotKPZ(PamhyrPlot): if self.data is None: return - if self.data.number_profiles == 0: + if len(self.data.profiles) == 0: return profiles_defined = any( filter( - lambda profile: len(profile.x()) > 0, + lambda profile: len(profile) > 0, self.data.profiles ) ) @@ -82,7 +82,7 @@ class PlotKPZ(PamhyrPlot): color='black', fontsize=10 ) - kp = self.data.get_kp() + kp = self.data.get_kp_complete_profiles() z_min = self.data.get_z_min() z_max = self.data.get_z_max() @@ -153,7 +153,7 @@ class PlotKPZ(PamhyrPlot): ) self.after_plot_selected.set_visible(False) - kp = self.data.get_kp() + kp = self.data.get_kp_complete_profiles() self.line_kp_zgl = [] for z in self.data.get_guidelines_z(): # Is incomplete guideline? @@ -194,41 +194,47 @@ class PlotKPZ(PamhyrPlot): self.after_plot_selected.set_visible(False) if 0 <= before < self.data.number_profiles: - kp_i = self.data.profile(before).kp - z_min_i = self.data.profile(before).z_min() - z_max_i = self.data.profile(before).z_max() - - self.before_plot_selected.set_data( - (kp_i, kp_i), - (z_min_i, z_max_i) - ) - self.before_plot_selected.set_visible(True) + profile = self.data.profile(before) + if len(profile) > 0: + kp_i = profile.kp + z_min_i = profile.z_min() + z_max_i = profile.z_max() + + self.before_plot_selected.set_data( + (kp_i, kp_i), + (z_min_i, z_max_i) + ) + self.before_plot_selected.set_visible(True) if 0 <= ind < self.data.number_profiles: - kp_i = self.data.profile(ind).kp - z_min_i = self.data.profile(ind).z_min() - z_max_i = self.data.profile(ind).z_max() - - self.plot_selected.set_data( - (kp_i, kp_i), - (z_min_i, z_max_i) - ) - self.plot_selected.set_visible(True) + profile = self.data.profile(ind) + if len(profile) > 0: + kp_i = profile.kp + z_min_i = profile.z_min() + z_max_i = profile.z_max() + + self.plot_selected.set_data( + (kp_i, kp_i), + (z_min_i, z_max_i) + ) + self.plot_selected.set_visible(True) if 0 <= after < self.data.number_profiles: - kp_i = self.data.profile(after).kp - z_min_i = self.data.profile(after).z_min() - z_max_i = self.data.profile(after).z_max() - - self.after_plot_selected.set_data( - (kp_i, kp_i), - (z_min_i, z_max_i) - ) - self.after_plot_selected.set_visible(True) + profile = self.data.profile(after) + if len(profile) > 0: + kp_i = profile.kp + z_min_i = profile.z_min() + z_max_i = profile.z_max() + + self.after_plot_selected.set_data( + (kp_i, kp_i), + (z_min_i, z_max_i) + ) + self.after_plot_selected.set_visible(True) self.canvas.figure.canvas.draw_idle() else: - kp = self.data.get_kp() + kp = self.data.get_kp_complete_profiles() z_min = self.data.get_z_min() z_max = self.data.get_z_max() diff --git a/src/View/Geometry/PlotXY.py b/src/View/Geometry/PlotXY.py index f8cd23df768318f4336263215a1aaf72128bfa16..6941686d079e3c593fc22d84865dbc7ee9173d66 100644 --- a/src/View/Geometry/PlotXY.py +++ b/src/View/Geometry/PlotXY.py @@ -73,7 +73,7 @@ class PlotXY(PamhyrPlot): ) self.canvas.axes.axis("equal") - kp = self.data.get_kp() + kp = self.data.get_kp_complete_profiles() # self.canvas.axes.set_xlim( # left=min(kp), right=max(kp) # ) @@ -149,8 +149,15 @@ class PlotXY(PamhyrPlot): return self.data.compute_guidelines() - x_complete = self.data.get_guidelines_x() - y_complete = self.data.get_guidelines_y() + x_complete = list(self.data.get_guidelines_x()) + y_complete = list(self.data.get_guidelines_y()) + + self.line_gl = [ + self.canvas.axes.plot( + x, y, + ) + for x, y in zip(x_complete, y_complete) + ] for i in range(self.data.number_profiles): if i < len(self.line_xy): diff --git a/src/View/Geometry/Window.py b/src/View/Geometry/Window.py index b291d1c470683b7dfeb74fe523fb3f9d7b603944..17eb95cbf3e83a9b2c068ebef268fc3b8f4c47f6 100644 --- a/src/View/Geometry/Window.py +++ b/src/View/Geometry/Window.py @@ -200,9 +200,9 @@ class GeometryWindow(PamhyrWindow): def update(self): self.update_profile_windows() - self.plot_xy() - self.plot_kpc() - self.plot_ac() + # self.plot_xy() + # self.plot_kpc() + # self.plot_ac() self.select_current_profile() self.changed_slider_value() @@ -356,6 +356,7 @@ class GeometryWindow(PamhyrWindow): def select_plot_ac(self, ind: int): self.tableView.model().blockSignals(True) + logger.info(f"select_plot_ac(self, {ind})") self._plot_ac.update(ind=ind) self.tableView.model().blockSignals(False) @@ -515,26 +516,31 @@ class GeometryWindow(PamhyrWindow): if len(header) != 0: data = [header] + data - for row in data: - row.append(self._reach) - row.append(self._study.river._status) + try: + for row in data: + row.append(self._reach) + row.append(self._study.river._status) - row = self.index_selected_row() - # self._table.paste(row, header, data) - self._table.paste(row, [], data) - self.select_current_profile() + row = self.index_selected_row() + # self._table.paste(row, header, data) + self._table.paste(row, [], data) + self.select_current_profile() + except Exception as e: + logger_exception(e) def _undo(self): self._table.undo() self.select_current_profile() - self.update_plot_xy() - self.update_plot_kpc() + # self.update_plot_ac() + # self.update_plot_xy() + # self.update_plot_kpc() def _redo(self): self._table.redo() self.select_current_profile() - self.update_plot_xy() - self.update_plot_kpc() + # self.update_plot_ac() + # self.update_plot_xy() + # self.update_plot_kpc() def export_to_file(self): settings = QSettings(