AdisTT: user-friendly fixes on interface

monopk-ic-adistt
Dylan Jeannin 2026-07-17 09:31:03 +02:00
parent 965443a8f9
commit cac20d4f24
12 changed files with 91 additions and 38 deletions

View File

@ -76,7 +76,7 @@ class SpecificHumidity(WeatherParameters):
)
self._type = "SH"
self._header = ["time", "humidity percentage"]
self._header = ["time", "humidity"]
self._types = [SpecificHumidity.time_convert, float]

View File

@ -54,7 +54,7 @@ class Plot(PamhyrPlot):
self._isometric_axis = False
self._auto_relim_update = True
self._autoscale_update = False
self._autoscale_update = True
def custom_ticks(self):
if self.data.header[0] != "time":

View File

@ -124,7 +124,7 @@ class TableModel(PamhyrTableModel):
if self._headers[column] == "name":
n = self._lst[row].name
if n is None or n == "":
return self._trad["not_associated"]
return self._trad["default"]
return n
elif self._headers[column] == "node":
n = self._lst[row].node
@ -172,7 +172,13 @@ class TableModel(PamhyrTableModel):
logger.info(e)
logger.debug(traceback.format_exc())
self.dataChanged.emit(index, index)
if self._headers[column] == "node" and self.rowCount() > 0:
self.dataChanged.emit(
self.index(0, column),
self.index(self.rowCount() - 1, column)
)
else:
self.dataChanged.emit(index, index)
return True
def add(self, row, parent=QModelIndex()):

View File

@ -37,12 +37,23 @@ class SetNodeCommand(QUndoCommand):
self._index = index
self._old = self._bcs.get(self._index).node
self._new = node.id if node is not None else None
self._previous = next(
(
bc for i, bc in enumerate(self._bcs.lst)
if i != self._index and bc.node == self._new
),
None
)
def undo(self):
self._bcs.get(self._index).node = self._old
if self._previous is not None:
self._previous.node = self._new
def redo(self):
self._bcs.get(self._index).node = self._new
if self._previous is not None:
self._previous.node = None
class SetNameCommand(QUndoCommand):

View File

@ -30,6 +30,9 @@ class BCTemperatureTranslate(MainTranslate):
self._dict["Boundary conditions temperature"] = _translate(
"BoundaryConditionsTemperature", "Boundary conditions temperature"
)
self._dict["default"] = _translate(
"BoundaryConditionsTemperature", "default"
)
self._sub_dict["table_headers"] = {
"name": self._dict["name"],

View File

@ -137,7 +137,7 @@ class InitialConditionTableModel(PamhyrTableModel):
if self._headers[column] == "name":
n = self._lst[row].name
if n is None or n == "":
return self._trad['not_associated']
return self._trad['not_defined']
return n
elif self._headers[column] == "reach":
n = self._lst[row].reach
@ -159,27 +159,27 @@ class InitialConditionTableModel(PamhyrTableModel):
elif self._headers[column] == "concentration":
n = self._lst[row].concentration
if n is None:
return self._trad['not_associated']
return self._trad['not_defined']
return n
elif self._headers[column] == "eg":
n = self._lst[row].eg
if n is None:
return self._trad['not_associated']
return self._trad['not_defined']
return n
elif self._headers[column] == "em":
n = self._lst[row].em
if n is None:
return self._trad['not_associated']
return self._trad['not_defined']
return n
elif self._headers[column] == "ed":
n = self._lst[row].ed
if n is None:
return self._trad['not_associated']
return self._trad['not_defined']
return n
elif self._headers[column] == "rate":
n = self._lst[row].rate
if n is None:
return self._trad['not_associated']
return self._trad['not_defined']
return n
return QVariant()

View File

@ -65,10 +65,11 @@ class ComboBoxDelegate(QItemDelegate):
reach = next(filter(lambda edge: edge.id == reach_id,
self._data.edges()), None)
if reach_id is not None:
if reach is not None:
val = list(
map(
lambda rk: str(rk), reach.reach.get_rk()
lambda profile: profile.display_name(),
reach.reach.profiles
)
)
else:
@ -92,7 +93,29 @@ class ComboBoxDelegate(QItemDelegate):
def setModelData(self, editor, model, index):
text = str(editor.currentText())
model.setData(index, text)
value = text
if self._mode == "rk":
reach_id = self._ic_spec_lst[index.row()].reach
reach = next(
(
edge for edge in self._data.edges()
if edge.id == reach_id
),
None
)
if reach is not None:
profile = next(
(
profile for profile in reach.reach.profiles
if profile.display_name() == text
),
None
)
if profile is not None:
value = profile.rk
model.setData(index, value)
editor.close()
editor.deleteLater()
@ -137,7 +160,7 @@ class InitialConditionTableModel(PamhyrTableModel):
if self._headers[column] == "name":
n = self._lst[row].name
if n is None or n == "":
return self._trad['not_associated']
return self._trad['not_defined']
return n
elif self._headers[column] == "reach":
n = self._lst[row].reach
@ -150,20 +173,41 @@ class InitialConditionTableModel(PamhyrTableModel):
n = self._lst[row].start_rk
if n is None:
return self._trad['not_associated']
return n
return self._rk_display_name(row, n)
elif self._headers[column] == "end_rk":
n = self._lst[row].end_rk
if n is None:
return self._trad['not_associated']
return n
return self._rk_display_name(row, n)
elif self._headers[column] == "temperature":
n = self._lst[row].temperature
if n is None:
return self._trad['not_associated']
return self._trad['not_defined']
return n
return QVariant()
def _rk_display_name(self, row, rk):
reach_id = self._lst[row].reach
reach = next(
(
edge for edge in self._river.edges()
if edge.id == reach_id
),
None
)
if reach is None:
return str(rk)
profile = next(
(
profile for profile in reach.reach.profiles
if profile.rk == rk
),
None
)
return profile.display_name() if profile is not None else str(rk)
def setData(self, index, value, role=Qt.EditRole):
if not index.isValid() or role != Qt.EditRole:
return False

View File

@ -97,8 +97,8 @@ class PamhyrPlot(APlot):
self._auto_relim = True #: Auto relim axes at plot creation
self._autoscale = True #: Auto scale at plot creation
self._auto_relim_update = False #: Auto relim axes at plot update
self._autoscale_update = False #: Auto scale at plot creation
self._auto_relim_update = True #: Auto relim axes at plot update
self._autoscale_update = True #: Auto scale at plot creation
self._highlight_data = None #: Data identifier to highlight
self._highlight_data_update = False

View File

@ -40,13 +40,16 @@ class PamhyrPlotToolbar(NavigationToolbar2QT):
isometric_signal = pyqtSignal(str)
def __init__(self, canvas, parent,
items=["home", "move", "zoom", "save"]):
items=[
"home", "back/forward", "move",
"zoom", "iso", "save"
]):
"""PamhyrPlotToolbar
Args:
canvas: MatPlotLib canvas
parent: parent Qt object
items: Enables items (default: "home", "move", "zoom", "save")
items: Enables toolbar items
"""
self._canvas = canvas
self._items = items

View File

@ -36,8 +36,8 @@ class WPETranslate(WeatherParametersTranslate):
"date": self._dict["date"],
"discharge": self._dict["unit_discharge"],
"temperature": _translate("WeatherParameters", "Temperature (°C)"),
"humidity percentage": _translate("WeatherParameters",
"Humidity Percentage"),
"humidity": _translate("WeatherParameters",
"Humidity"),
"radiation": _translate("WeatherParameters", "Radiation (W/m²)"),
"wind speed": _translate("WeatherParameters", "Wind Speed (m/s)"),
"albedo": _translate("WeatherParameters", "Albedo"),

View File

@ -47,7 +47,7 @@ class WeatherParametersTranslate(MainTranslate):
"air_temperature": _translate("WeatherParameters",
"Air Temperature (°C)"),
"specific_humidity": _translate("WeatherParameters",
"Specific Humidity (%)"),
"Specific Humidity"),
"global_radiation": _translate("WeatherParameters",
"Global Radiation (W/m²)"),
"reference_wind_speed": _translate("WeatherParameters",

View File

@ -50,20 +50,6 @@
</property>
</widget>
<widget class="QStatusBar" name="statusbar"/>
<widget class="QToolBar" name="toolBar">
<property name="windowTitle">
<string>toolBar</string>
</property>
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
<addaction name="action_add"/>
<addaction name="action_del"/>
<addaction name="action_sort"/>
</widget>
<action name="action_add">
<property name="icon">
<iconset>