mirror of https://gitlab.com/pamhyr/pamhyr2
Geometry: Fix some update error.
parent
fbf342f1ad
commit
e72d06bf6f
|
|
@ -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())
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
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)
|
||||
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()
|
||||
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)
|
||||
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()
|
||||
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.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()
|
||||
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
Loading…
Reference in New Issue