add make increasing button in boundary condition rating curve

compare_results
Theophile Terraz 2024-09-19 11:39:06 +02:00
parent 0b78522ca5
commit f755b7ce74
3 changed files with 35 additions and 3 deletions

View File

@ -204,12 +204,17 @@ class EditBoundaryConditionWindow(PamhyrWindow):
self.find(QAction, "action_generate_critical").triggered.connect(
self.generate_critical
)
self.find(QAction, "action_increasing").triggered.connect(
self.make_increasing
)
if self._data.bctype != "ZD" or not self._data.has_node:
self.find(QAction, "action_generate_uniform").setVisible(False)
self.find(QAction, "action_generate_critical").setVisible(False)
self.find(QAction, "action_increasing").setVisible(False)
else:
self.find(QAction, "action_generate_uniform").setVisible(True)
self.find(QAction, "action_generate_critical").setVisible(True)
self.find(QAction, "action_increasing").setVisible(True)
self._table.dataChanged.connect(self.update)
self._table.layoutChanged.connect(self.update)
@ -382,3 +387,21 @@ class EditBoundaryConditionWindow(PamhyrWindow):
height[i] += z_min
self._table.replace_data(height, q)
return
def make_increasing(self):
if self._data.has_node:
node = self._data.node
if node is None:
return
if len(self._table._data) < 2:
return
h = [self._data.get_i(0)[0]]
q = [self._data.get_i(0)[1]]
for i in range(len(self._table._data)):
if i == 0:
continue
row = self._data.get_i(i)
if row[1] > q[-1]:
h.append(row[0])
q.append(row[1])
self._table.replace_data(h, q)

View File

@ -75,6 +75,7 @@
<addaction name="action_sort"/>
<addaction name="action_generate_uniform"/>
<addaction name="action_generate_critical"/>
<addaction name="action_increasing"/>
</widget>
<action name="action_add">
<property name="checkable">
@ -140,6 +141,14 @@
<string>Generate rating curve as Q(z) = Sqrt(g*S(z)^3/L(z))</string>
</property>
</action>
<action name="action_increasing">
<property name="text">
<string>Make increasing</string>
</property>
<property name="toolTip">
<string>Remove points to make the curve increasing</string>
</property>
</action>
</widget>
<resources/>
<connections/>

View File

@ -22,7 +22,7 @@
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Upstream Height (m)</string>
<string>Upstream height (m)</string>
</property>
</widget>
</item>
@ -64,7 +64,7 @@
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Downstream Height (m)</string>
<string>Downstream height (m)</string>
</property>
</widget>
</item>
@ -95,7 +95,7 @@
<item>
<widget class="QCheckBox" name="checkBox">
<property name="text">
<string>Generate Constant Discharge</string>
<string>Generate constant discharge</string>
</property>
</widget>
</item>