diff --git a/src/Model/Geometry/ProfileXYZ.py b/src/Model/Geometry/ProfileXYZ.py index 9ee0f298f0e94d17af933b8b36e1350a37de0576..6b3449946450c2f58b1c18284809c75397f3a47c 100644 --- a/src/Model/Geometry/ProfileXYZ.py +++ b/src/Model/Geometry/ProfileXYZ.py @@ -519,10 +519,10 @@ class ProfileXYZ(Profile, SQLSubModel): station = [] constant = 0.0 - if (first_named_point is not None and - last_named_point is not None): - if (first_named_point != last_named_point and - first_named_point.x != last_named_point.x): + if (first_named_point is not None + and last_named_point is not None): + if (first_named_point != last_named_point + and first_named_point.x != last_named_point.x): vector = Vector1d(first_named_point, last_named_point) norm_dir_vec = vector.normalized_direction_vector() else: diff --git a/src/Solver/RubarBE.py b/src/Solver/RubarBE.py index bdef669135668b827ddb2e3736bb51dbb08fb804..43addf3cffe20aba581ebf306fb214ba5499a403 100644 --- a/src/Solver/RubarBE.py +++ b/src/Solver/RubarBE.py @@ -135,7 +135,6 @@ class RubarBE(CommandLineSolver): name = self._study.name return f"{name}.TRA" - def export(self, study, repertory, qlog=None): self._study = study name = study.name.replace(" ", "_") @@ -384,7 +383,9 @@ class RubarBE(CommandLineSolver): last = profiles[-1] if first.kp not in data or last.kp not in data: - logger.error("Study initial condition is not fully defined") + logger.error( + "Study initial condition is not fully defined" + ) return f_h_s = self._export_tps_profile_height_speed(first, data) @@ -419,7 +420,6 @@ class RubarBE(CommandLineSolver): # Last mail f.write(f"{ind:>5} {f_h_s[0]} {f_h_s[1]}") - def _export_tps_init_data(self, ics): data = {} diff --git a/src/View/Geometry/Profile/Plot.py b/src/View/Geometry/Profile/Plot.py index b5d16734c116c120295badaad6a3ebb3800924d7..357bb5b824e08415695a7919bbc81588c3b3fee6 100644 --- a/src/View/Geometry/Profile/Plot.py +++ b/src/View/Geometry/Profile/Plot.py @@ -47,6 +47,9 @@ class Plot(PamhyrPlot): ) self._table = table + self._z_note = None + self._z_line = None + self._z_fill_between = None self.line_xy = [] self.line_gl = [] @@ -63,7 +66,8 @@ class Plot(PamhyrPlot): self.hl_points = [] self.highlight = ( [], # Points list to highlight - None # Water level (z) + None # Hydrolic values (z, wet_area, + # wet_preimeter, water_width) ) def onpick(self, event): @@ -74,11 +78,11 @@ class Plot(PamhyrPlot): if modifiers != Qt.ControlModifier: return - points, z = self.highlight + _, hyd = self.highlight ind, point = self._closer_point(event) - self.highlight = ([point], z) + self.highlight = ([point], hyd) self._select_in_table(ind) self.update() @@ -92,18 +96,24 @@ class Plot(PamhyrPlot): if modifiers != Qt.ShiftModifier: return - points, z = self.highlight + points, _ = self.highlight - # Compute largeur au miroir + z = self._get_z_from_click(event) + if z < self.data.z_min(): + return + + a, p, w = self._compute_hydrolics(z) - self.highlight = (points, z) + logger.debug(f"{z, a, p, w}") + + self.highlight = (points, (z, a, p, w)) self.update() return def select_points_from_indexes(self, indexes): data = self.data - _, z = self.highlight + _, hyd = self.highlight points = list( map( @@ -117,7 +127,7 @@ class Plot(PamhyrPlot): ) ) - self.highlight = (points, z) + self.highlight = (points, hyd) self.update() def _select_in_table(self, ind): @@ -157,11 +167,9 @@ class Plot(PamhyrPlot): def dist_mouse(point): x, y = point[1] - d = ( - sqrt( + d = sqrt( (((mx - x) / ratio) ** 2) + ((my - y) ** 2) - ) ) return d @@ -171,6 +179,22 @@ class Plot(PamhyrPlot): return closer + def _get_z_from_click(self, event): + return event.ydata + + def _compute_hydrolics(self, z): + profile = self.data + + points = profile.wet_points(z) + station = profile._get_station(points) + width = abs(station[0] - station[-1]) + + poly = profile.wet_polygon(z) + area = poly.area + perimeter = poly.length + + return area, perimeter, width + @timer def draw(self): self.init_axes() @@ -180,9 +204,7 @@ class Plot(PamhyrPlot): x_carto = self.data.x() y_carto = self.data.y() - if (len(x_carto) < 3 - or len(y_carto) < 3 - or len(x) < 3): + if (len(x_carto) < 3 or len(y_carto) < 3 or len(x) < 3): # Noting to do in this case return @@ -193,7 +215,7 @@ class Plot(PamhyrPlot): ) self.draw_annotation(x, y) - self.draw_hightligth() + self.draw_highligth() self.idle() @@ -235,8 +257,8 @@ class Plot(PamhyrPlot): self.canvas.axes.set_facecolor('#F9F9F9') self.canvas.figure.patch.set_facecolor('white') - def draw_hightligth(self): - points, z = self.highlight + def draw_highligth(self): + points, hyd = self.highlight for p in self.hl_points: p[0].set_data([], []) @@ -252,8 +274,63 @@ class Plot(PamhyrPlot): ) ) + if hyd is not None: + self.draw_highligth_z_line(*hyd) + + def draw_highligth_z_line(self, z, a, p, w): + text = ( + f"Z = {z:.3f} m, " + + f"{self._trad['width']} = {w:.3f} m,\n" + + f"{self._trad['area']} = {a:.3f} m², " + + f"{self._trad['perimeter']} = {p:.3f} m" + ) + + x = self.data.get_station() + xlim = (x[0], x[-1]) + pos = ( + xlim[0] + (abs(xlim[0] - xlim[1]) * 0.05), + z + 0.8 + ) + y = self.data.z() + + if self._z_note is None: + self.draw_highligth_z_line_fill(x, y, z) + + self._z_line = self.canvas.axes.plot( + xlim, [z, z], + color=self.color_plot_river_water + ) + + self._z_note = self.canvas.axes.annotate( + text, pos, + horizontalalignment='left', + verticalalignment='top', + annotation_clip=True, + color=self.color_plot_river_water, + fontsize=9, + fontweight='bold', + alpha=0.7 + ) + else: + self.draw_highligth_z_line_fill(x, y, z) + + self._z_line[0].set_data(xlim, [z, z]) + self._z_note.set_position(pos) + self._z_note.set_text(text) + + def draw_highligth_z_line_fill(self, x, y, z): + if self._z_fill_between is not None: + self._z_fill_between.remove() + + self._z_fill_between = self.canvas.axes.fill_between( + x, y, z, + where=y <= z, + facecolor=self.color_plot_river_water_zone, + interpolate=True, alpha=0.7 + ) + @timer def update(self): - self.draw_hightligth() + self.draw_highligth() self.update_idle() diff --git a/src/View/Geometry/Profile/Translate.py b/src/View/Geometry/Profile/Translate.py index 249d17c7af08a77aa2b17d3d46e64632076d0cb9..43532bb1077c3b2e4f648f4937387419a2a80672 100644 --- a/src/View/Geometry/Profile/Translate.py +++ b/src/View/Geometry/Profile/Translate.py @@ -32,6 +32,10 @@ class GeometryProfileTranslate(GeometryTranslate): "Geometry", "Geometry cross-section" ) + self._dict["width"] = _translate("Geometry", "Width") + self._dict["area"] = _translate("Geometry", "Area") + self._dict["perimeter"] = _translate("Geometry", "Perimeter") + self._sub_dict["table_headers"] = { "x": self._dict["x"], "y": self._dict["y"],