mirror of https://gitlab.com/pamhyr/pamhyr2
Geometry:toggle interpolated profiles visibility in geometry table and plots
parent
a0d8b9ea43
commit
081e6e7322
|
|
@ -112,7 +112,7 @@ class PlotAC(PamhyrPlot):
|
|||
profile_id = 0
|
||||
|
||||
profile = self.data.profile(profile_id)
|
||||
if profile is None:
|
||||
if profile is None or self._parent.tableView.isRowHidden(profile_id):
|
||||
return
|
||||
|
||||
station = profile.get_station()
|
||||
|
|
@ -192,21 +192,24 @@ class PlotAC(PamhyrPlot):
|
|||
self.plot_selected.set_data([], [])
|
||||
self.next_plot_selected.set_data([], [])
|
||||
|
||||
if 0 <= previous_id < self.data.number_profiles:
|
||||
if (0 <= previous_id < self.data.number_profiles
|
||||
and not self._parent.tableView.isRowHidden(previous_id)):
|
||||
self.previous_plot_selected.set_data(
|
||||
self.data.profile(previous_id).get_station(),
|
||||
self.data.profile(previous_id).z()
|
||||
)
|
||||
self.previous_plot_selected.set_visible(True)
|
||||
|
||||
if 0 <= profile_id < self.data.number_profiles:
|
||||
if (0 <= profile_id < self.data.number_profiles
|
||||
and not self._parent.tableView.isRowHidden(profile_id)):
|
||||
self.plot_selected.set_data(
|
||||
self.data.profile(profile_id).get_station(),
|
||||
self.data.profile(profile_id).z()
|
||||
)
|
||||
self.plot_selected.set_visible(True)
|
||||
|
||||
if 0 <= next_id < self.data.number_profiles:
|
||||
if (0 <= next_id < self.data.number_profiles
|
||||
and not self._parent.tableView.isRowHidden(next_id)):
|
||||
self.next_plot_selected.set_data(
|
||||
self.data.profile(next_id).get_station(),
|
||||
self.data.profile(next_id).z()
|
||||
|
|
|
|||
|
|
@ -110,9 +110,9 @@ class PlotRKZ(PamhyrPlot):
|
|||
def _closest_rk(self, event):
|
||||
|
||||
s = event.artist.get_segments()
|
||||
x = [i[0, 0] for i in s]
|
||||
mx = event.mouseevent.xdata
|
||||
points = enumerate(x)
|
||||
points = [(i, segment[0, 0]) for i, segment in enumerate(s)
|
||||
if len(segment)]
|
||||
|
||||
def dist_mouse(point):
|
||||
x = point[1]
|
||||
|
|
@ -136,6 +136,7 @@ class PlotRKZ(PamhyrPlot):
|
|||
if len(ind) == 0:
|
||||
return
|
||||
|
||||
ind = [i for i in ind if not self._table.isRowHidden(i)]
|
||||
for i in ind:
|
||||
index.append(QItemSelectionRange(self._table.model().index(i, 0)))
|
||||
|
||||
|
|
@ -150,18 +151,7 @@ class PlotRKZ(PamhyrPlot):
|
|||
self._table.scrollTo(self._table.model().index(ind[-1], 0))
|
||||
|
||||
def _select_range_in_table(self, ind1, ind2):
|
||||
if self._table is not None:
|
||||
self._table.setFocus()
|
||||
selection = self._table.selectionModel()
|
||||
index = QItemSelection(self._table.model().index(ind1, 0),
|
||||
self._table.model().index(ind2, 0))
|
||||
selection.select(
|
||||
index,
|
||||
QItemSelectionModel.Rows |
|
||||
QItemSelectionModel.ClearAndSelect |
|
||||
QItemSelectionModel.Select
|
||||
)
|
||||
self._table.scrollTo(self._table.model().index(ind2, 0))
|
||||
self._select_in_table(list(range(ind1, ind2 + 1)))
|
||||
|
||||
@timer
|
||||
def redraw(self, data):
|
||||
|
|
@ -213,6 +203,13 @@ class PlotRKZ(PamhyrPlot):
|
|||
picker=10,
|
||||
)
|
||||
|
||||
if self._table is not None:
|
||||
segments = self.line_rk_zmin_zmax.get_segments()
|
||||
self.line_rk_zmin_zmax.set_segments([
|
||||
segment[:0] if self._table.isRowHidden(row) else segment
|
||||
for row, segment in enumerate(segments)
|
||||
])
|
||||
|
||||
def color_highlight(self):
|
||||
rows = sorted(list(
|
||||
set(
|
||||
|
|
|
|||
|
|
@ -136,6 +136,7 @@ class PlotXY(PamhyrPlot):
|
|||
index = QItemSelection()
|
||||
if len(ind) == 0:
|
||||
return
|
||||
ind = [i for i in ind if not self._table.isRowHidden(i)]
|
||||
for i in ind:
|
||||
index.append(QItemSelectionRange(self._table.model().index(i, 0)))
|
||||
selection.select(
|
||||
|
|
@ -149,18 +150,7 @@ class PlotXY(PamhyrPlot):
|
|||
self._table.scrollTo(self._table.model().index(ind[-1], 0))
|
||||
|
||||
def _select_range_in_table(self, ind1, ind2):
|
||||
if self._table is not None:
|
||||
self._table.setFocus()
|
||||
selection = self._table.selectionModel()
|
||||
index = QItemSelection(self._table.model().index(ind1, 0),
|
||||
self._table.model().index(ind2, 0))
|
||||
selection.select(
|
||||
index,
|
||||
QItemSelectionModel.Rows |
|
||||
QItemSelectionModel.ClearAndSelect |
|
||||
QItemSelectionModel.Select
|
||||
)
|
||||
self._table.scrollTo(self._table.model().index(ind2, 0))
|
||||
self._select_in_table(list(range(ind1, ind2 + 1)))
|
||||
|
||||
@timer
|
||||
def redraw(self, data):
|
||||
|
|
@ -189,8 +179,12 @@ class PlotXY(PamhyrPlot):
|
|||
|
||||
def draw_xy(self):
|
||||
self.line_xy = []
|
||||
for xy in zip(self.data.get_x(), self.data.get_y()):
|
||||
self.line_xy.append(np.column_stack(xy))
|
||||
for row, profile in enumerate(self.data.profiles):
|
||||
hidden = self._table is not None and self._table.isRowHidden(row)
|
||||
self.line_xy.append(
|
||||
np.empty((0, 2)) if hidden or len(profile) == 0
|
||||
else np.column_stack((profile.x(), profile.y()))
|
||||
)
|
||||
|
||||
self._colors, self._style = self.color_highlight()
|
||||
self.line_xy_collection = collections.LineCollection(
|
||||
|
|
|
|||
|
|
@ -45,6 +45,9 @@ class GeometryTranslate(MainTranslate):
|
|||
self._dict["cross_sections"] = _translate("Geometry", "cross-sections")
|
||||
self._dict["profile"] = _translate("Geometry", "cross-section")
|
||||
self._dict["profiles"] = _translate("Geometry", "cross-sections")
|
||||
self._dict["show_interpolated_profiles"] = _translate(
|
||||
"Geometry", "Show interpolated profiles"
|
||||
)
|
||||
self._dict["cross_section_enabled_count"] = _translate(
|
||||
"Geometry", "Cross-section enabled ({count} disabled)"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -127,6 +127,9 @@ class GeometryWindow(PamhyrWindow):
|
|||
table.setAlternatingRowColors(True)
|
||||
|
||||
def setup_checkbox(self):
|
||||
self.find(QCheckBox, "checkBox_show_interpolated").setText(
|
||||
self._trad["show_interpolated_profiles"]
|
||||
)
|
||||
self._checkbox = self.find(QCheckBox, "checkBox_enabled")
|
||||
self._set_checkbox_state()
|
||||
|
||||
|
|
@ -197,6 +200,15 @@ class GeometryWindow(PamhyrWindow):
|
|||
self._status_label.setText(txt)
|
||||
|
||||
def setup_connections(self):
|
||||
self.find(QCheckBox, "checkBox_show_interpolated").toggled.connect(
|
||||
self.update_interpolated_profiles_visibility
|
||||
)
|
||||
self.find(QCheckBox, "checkBox_show_interpolated").toggled.connect(
|
||||
self.update_redraw
|
||||
)
|
||||
self._table.modelReset.connect(self.update_interpolated_profiles_visibility)
|
||||
self._table.rowsInserted.connect(self.update_interpolated_profiles_visibility)
|
||||
self._table.rowsRemoved.connect(self.update_interpolated_profiles_visibility)
|
||||
if self._study.is_read_only():
|
||||
actions = {
|
||||
"action_export": self.export_to_file,
|
||||
|
|
@ -237,6 +249,22 @@ class GeometryWindow(PamhyrWindow):
|
|||
def update(self):
|
||||
self._update()
|
||||
|
||||
def update_interpolated_profiles_visibility(self):
|
||||
show_interpolated = self.find(
|
||||
QCheckBox, "checkBox_show_interpolated"
|
||||
).isChecked()
|
||||
selection = self.tableView.selectionModel()
|
||||
for row in range(self._table.rowCount()):
|
||||
hidden = not show_interpolated and self._reach.profile(row).interpolated
|
||||
self.tableView.setRowHidden(row, hidden)
|
||||
if hidden:
|
||||
selection.select(
|
||||
self._table.index(row, 0),
|
||||
QItemSelectionModel.Deselect | QItemSelectionModel.Rows
|
||||
)
|
||||
if selection.currentIndex().row() == row:
|
||||
selection.setCurrentIndex(QModelIndex(), QItemSelectionModel.NoUpdate)
|
||||
|
||||
def update_redraw(self):
|
||||
self._update(redraw=True)
|
||||
|
||||
|
|
@ -248,6 +276,7 @@ class GeometryWindow(PamhyrWindow):
|
|||
self.find(QAction, "action_meshing").setEnabled(enabled)
|
||||
|
||||
def _update(self, redraw=False, propagate=True):
|
||||
self.update_interpolated_profiles_visibility()
|
||||
self.update_meshing_action()
|
||||
|
||||
if redraw:
|
||||
|
|
@ -498,6 +527,7 @@ class GeometryWindow(PamhyrWindow):
|
|||
data=self._reach,
|
||||
trad=self._trad,
|
||||
toolbar=self._toolbar_ac,
|
||||
parent=self,
|
||||
)
|
||||
self._plot_ac.draw()
|
||||
|
||||
|
|
|
|||
|
|
@ -25,6 +25,16 @@
|
|||
</property>
|
||||
<widget class="QWidget" name="horizontalLayoutWidget">
|
||||
<layout class="QVBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_show_interpolated">
|
||||
<property name="text">
|
||||
<string notr="true">Show interpolated profiles</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTableView" name="tableView"/>
|
||||
</item>
|
||||
|
|
|
|||
Loading…
Reference in New Issue