mirror of https://gitlab.com/pamhyr/pamhyr2
add reach selection in geometry
parent
24d92b2ac0
commit
f35048b89f
|
|
@ -83,8 +83,8 @@ class TriangularWeir(BasicHS):
|
|||
self._data = [
|
||||
BHSValue("elevation", float, 1.0, status=status),
|
||||
BHSValue("loading_elevation", float, 9999.999, status=status),
|
||||
BHSValue("discharge_coefficient", float, 0.4, status=status),
|
||||
BHSValue("half-angle_tangent", float, 0.0, status=status),
|
||||
BHSValue("discharge_coefficient", float, 0.31, status=status),
|
||||
BHSValue("half-angle_tangent", float, 1.0, status=status),
|
||||
]
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -51,6 +51,11 @@ class PlotAC(PamhyrPlot):
|
|||
self.plot_selected = None
|
||||
self.next_plot_selected = None
|
||||
|
||||
@timer
|
||||
def redraw(self, data):
|
||||
self._data = data
|
||||
self.draw()
|
||||
|
||||
@timer
|
||||
def draw(self):
|
||||
self.init_axes()
|
||||
|
|
|
|||
|
|
@ -163,6 +163,11 @@ class PlotRKZ(PamhyrPlot):
|
|||
)
|
||||
self._table.scrollTo(self._table.model().index(ind2, 0))
|
||||
|
||||
@timer
|
||||
def redraw(self, data):
|
||||
self._data = data
|
||||
self.draw()
|
||||
|
||||
@timer
|
||||
def draw(self):
|
||||
self.init_axes()
|
||||
|
|
|
|||
|
|
@ -162,6 +162,11 @@ class PlotXY(PamhyrPlot):
|
|||
)
|
||||
self._table.scrollTo(self._table.model().index(ind2, 0))
|
||||
|
||||
@timer
|
||||
def redraw(self, data):
|
||||
self._data = data
|
||||
self.draw()
|
||||
|
||||
@timer
|
||||
def draw(self):
|
||||
self.init_axes()
|
||||
|
|
|
|||
|
|
@ -47,6 +47,8 @@ from View.Tools.PamhyrWindow import PamhyrWindow
|
|||
from View.Tools.Plot.PamhyrToolbar import PamhyrPlotToolbar
|
||||
from View.Tools.Plot.PamhyrCanvas import MplCanvas
|
||||
|
||||
from View.SelectReach.Window import SelectReachWindow
|
||||
|
||||
from Meshing.Mage import (
|
||||
MeshingWithMage, MeshingWithMageMailleurTT
|
||||
)
|
||||
|
|
@ -196,6 +198,7 @@ class GeometryWindow(PamhyrWindow):
|
|||
"action_update_rk": self.update_rk,
|
||||
"action_purge": self.purge,
|
||||
"action_shift": self.shift,
|
||||
"action_select_reach": self.select_reach,
|
||||
}
|
||||
|
||||
for action in actions:
|
||||
|
|
@ -217,9 +220,9 @@ class GeometryWindow(PamhyrWindow):
|
|||
|
||||
def _update(self, redraw=False, propagate=True):
|
||||
if redraw:
|
||||
self._plot_xy.draw()
|
||||
self._plot_rkc.draw()
|
||||
self._plot_ac.draw()
|
||||
self._plot_xy.redraw(data=self._reach)
|
||||
self._plot_rkc.redraw(data=self._reach)
|
||||
self._plot_ac.redraw(data=self._reach)
|
||||
|
||||
self.select_current_profile()
|
||||
|
||||
|
|
@ -535,6 +538,25 @@ class GeometryWindow(PamhyrWindow):
|
|||
logger_exception(e)
|
||||
return
|
||||
|
||||
def select_reach(self):
|
||||
try:
|
||||
dlg = SelectReachWindow(
|
||||
study=self._study,
|
||||
trad=self._trad,
|
||||
parent=self
|
||||
)
|
||||
if dlg.exec():
|
||||
self._reach = self._study.river.current_reach().reach
|
||||
self.setup_table()
|
||||
self.update_redraw() # Profile selection when line change in table
|
||||
self.find(QTableView, "tableView").selectionModel()\
|
||||
.selectionChanged\
|
||||
.connect(self.select_current_profile)
|
||||
except Exception as e:
|
||||
logger_exception(e)
|
||||
return
|
||||
|
||||
|
||||
def duplicate(self):
|
||||
rows = [
|
||||
row.row() for row in
|
||||
|
|
|
|||
|
|
@ -0,0 +1,68 @@
|
|||
# Window.py -- Pamhyr
|
||||
# Copyright (C) 2023-2025 INRAE
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from View.Tools.PamhyrWindow import PamhyrDialog
|
||||
|
||||
|
||||
class SelectReachWindow(PamhyrDialog):
|
||||
_pamhyr_ui = "SelectReach"
|
||||
_pamhyr_name = "Select reach"
|
||||
|
||||
def __init__(self, study=None, config=None, trad=None, parent=None):
|
||||
|
||||
super(SelectReachWindow, self).__init__(
|
||||
title=trad[self._pamhyr_name],
|
||||
study=study,
|
||||
config=config,
|
||||
options=[],
|
||||
parent=parent
|
||||
)
|
||||
|
||||
self.setup_combobox()
|
||||
self.select_current_reach()
|
||||
|
||||
def setup_combobox(self):
|
||||
reaches = list(self._study.river.enable_edges())
|
||||
reaches_name = [r.name for r in reaches]
|
||||
|
||||
self.combobox_add_items("comboBox", reaches_name)
|
||||
|
||||
def select_current_reach(self):
|
||||
if self._study.river.has_current_reach():
|
||||
reach = self._study.river.current_reach()
|
||||
self.set_combobox_text(
|
||||
"comboBox",
|
||||
reach.name
|
||||
)
|
||||
|
||||
def accept(self):
|
||||
reach_name = self.get_combobox_text("comboBox")
|
||||
|
||||
reach = next(
|
||||
filter(
|
||||
lambda s: s.name == reach_name,
|
||||
self._study.river.enable_edges()
|
||||
)
|
||||
)
|
||||
|
||||
self._study.river.set_current_reach(reach)
|
||||
|
||||
super().accept()
|
||||
|
||||
def reject(self):
|
||||
self.close()
|
||||
|
|
@ -39,6 +39,7 @@ class CommonWordTranslate(PamhyrTranslate):
|
|||
|
||||
self._dict["reach"] = _translate("CommonWord", "Reach")
|
||||
self._dict["reaches"] = _translate("CommonWord", "Reaches")
|
||||
self._dict["Select reach"] = _translate("CommonWord", "Select reach")
|
||||
self._dict["cross_section"] = _translate("CommonWord", "Cross-section")
|
||||
self._dict["main_channel"] = _translate("CommonWord", "Main channel")
|
||||
self._dict["floodway"] = _translate("CommonWord", "Floodway")
|
||||
|
|
|
|||
|
|
@ -93,6 +93,7 @@
|
|||
<addaction name="action_update_rk"/>
|
||||
<addaction name="action_purge"/>
|
||||
<addaction name="action_shift"/>
|
||||
<addaction name="action_select_reach"/>
|
||||
</widget>
|
||||
<action name="action_import">
|
||||
<property name="icon">
|
||||
|
|
@ -235,6 +236,14 @@
|
|||
<string>Shift selected sections coordinates</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="action_select_reach">
|
||||
<property name="text">
|
||||
<string>Select reach</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Change current reach</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,67 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Dialog</class>
|
||||
<widget class="QDialog" name="Dialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>76</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="1" column="0">
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QComboBox" name="comboBox"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>Dialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>Dialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
Loading…
Reference in New Issue