MainWindow: Checker: Minor change and fixes.

setup.py
Pierre-Antoine Rouby 2024-03-27 09:57:53 +01:00
parent 9d9a8a7ced
commit e7e1582836
5 changed files with 87 additions and 94 deletions

View File

@ -79,3 +79,17 @@ class Modules(Flag):
cls.RESERVOIR, cls.RESERVOIR,
cls.SEDIMENT_LAYER, cls.SEDIMENT_LAYER,
] ]
@classmethod
def modelling_display_name(cls):
return {
cls.NETWORK: "Network",
cls.GEOMETRY: "Geometry",
cls.BOUNDARY_CONDITION: "Boundary condition",
cls.LATERAL_CONTRIBUTION: "Lateral contribution",
cls.FRICTION: "Friction",
cls.INITIAL_CONDITION: "Initial condition",
cls.HYDRAULIC_STRUCTURES: "Hydraulic structures",
cls.RESERVOIR: "Reservoir",
cls.SEDIMENT_LAYER: "Sediment layer",
}

View File

@ -98,9 +98,9 @@ class Mage(CommandLineSolver):
@classmethod @classmethod
def checkers(cls): def checkers(cls):
lst = [ lst = [
MageNetworkGraphChecker(connectivity=True), MageNetworkGraphChecker(connectivity=True, version=cls._type),
MageNetworkGraphChecker(connectivity=False), MageNetworkGraphChecker(connectivity=False, version=cls._type),
MageGeometryGuideLineChecker(), MageGeometryGuideLineChecker(version=cls._type),
] ]
return lst return lst

View File

@ -79,6 +79,47 @@ class TabTableModel(PamhyrTableModel):
def _setup_lst(self): def _setup_lst(self):
self._lst = self._opt_data self._lst = self._opt_data
def data(self, index, role):
row = index.row()
column = index.column()
if role == Qt.ForegroundRole:
if self._headers[column] == "type":
return QVariant()
color = Qt.gray
status, _ = self.compute_status(row, column)
if status is STATUS.OK:
color = Qt.green
elif status is STATUS.WARNING:
color = QColor("orange")
elif status is STATUS.ERROR:
color = Qt.red
return QBrush(color)
if role == Qt.ItemDataRole.DisplayRole:
if self._headers[column] == "type":
return self.module_display_name(self._opt_data[row])
value = "UNKNOWN"
status, _ = self.compute_status(row, column)
if status is STATUS.OK:
value = "OK"
elif status is STATUS.WARNING:
value = "WARNING"
elif status is STATUS.ERROR:
value = "ERROR"
return value
return QVariant()
def module_display_name(self, module):
return Modules.modelling_display_name()[module]
def get_checkers(self, row, column): def get_checkers(self, row, column):
module = self._opt_data[row] module = self._opt_data[row]
solver = self._headers[column] solver = self._headers[column]
@ -121,41 +162,3 @@ class TabTableModel(PamhyrTableModel):
logger.debug(f"Checkers: {row}, {column}: {checkers_status} {status}") logger.debug(f"Checkers: {row}, {column}: {checkers_status} {status}")
return status, checkers_status return status, checkers_status
def data(self, index, role):
row = index.row()
column = index.column()
if role == Qt.ForegroundRole:
if self._headers[column] == "type":
return QVariant()
color = Qt.gray
status, _ = self.compute_status(row, column)
if status is STATUS.OK:
color = Qt.green
elif status is STATUS.WARNING:
color = QColor("orange")
elif status is STATUS.ERROR:
color = Qt.red
return QBrush(color)
if role == Qt.ItemDataRole.DisplayRole:
if self._headers[column] == "type":
return str(self._opt_data[row])
value = "UNKNOWN"
status, _ = self.compute_status(row, column)
if status is STATUS.OK:
value = "OK"
elif status is STATUS.WARNING:
value = "WARNING"
elif status is STATUS.ERROR:
value = "ERROR"
return value
return QVariant()

View File

@ -15,30 +15,6 @@
</property> </property>
<layout class="QGridLayout" name="gridLayout_3"> <layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0"> <item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="pushButton_restart">
<property name="text">
<string>Restart</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QSplitter" name="splitter_2"> <widget class="QSplitter" name="splitter_2">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>

View File

@ -871,130 +871,130 @@
<message> <message>
<location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="54"/> <location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="54"/>
<source>Description:</source> <source>Description:</source>
<translation>Description :</translation> <translation type="obsolete">Description :</translation>
</message> </message>
<message> <message>
<location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="68"/> <location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="68"/>
<source>Name:</source> <source>Name:</source>
<translation>Nom :</translation> <translation type="obsolete">Nom :</translation>
</message> </message>
<message> <message>
<location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="78"/> <location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="64"/>
<source>@study_name</source> <source>@study_name</source>
<translation>@study_name</translation> <translation>@study_name</translation>
</message> </message>
<message> <message>
<location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="88"/> <location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="74"/>
<source>River network</source> <source>River network</source>
<translation>Réseau de la rivière</translation> <translation>Réseau de la rivière</translation>
</message> </message>
<message> <message>
<location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="104"/> <location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="90"/>
<source>Reach:</source> <source>Reach:</source>
<translation>Bief :</translation> <translation>Bief :</translation>
</message> </message>
<message> <message>
<location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="131"/> <location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="117"/>
<source>Node:</source> <source>Node:</source>
<translation>Nœud :</translation> <translation>Nœud :</translation>
</message> </message>
<message> <message>
<location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="141"/> <location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="127"/>
<source>@nb_nodes</source> <source>@nb_nodes</source>
<translation>@nb_nodes</translation> <translation>@nb_nodes</translation>
</message> </message>
<message> <message>
<location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="158"/> <location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="144"/>
<source>@nb_edges</source> <source>@nb_edges</source>
<translation>@nb_edges</translation> <translation>@nb_edges</translation>
</message> </message>
<message> <message>
<location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="124"/> <location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="110"/>
<source>Current reach:</source> <source>Current reach:</source>
<translation>Bief actuel :</translation> <translation>Bief actuel :</translation>
</message> </message>
<message> <message>
<location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="97"/> <location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="83"/>
<source>@current_reach</source> <source>@current_reach</source>
<translation>@current_reach</translation> <translation>@current_reach</translation>
</message> </message>
<message> <message>
<location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="216"/> <location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="202"/>
<source>Geometry</source> <source>Geometry</source>
<translation>Géometrie</translation> <translation>Géometrie</translation>
</message> </message>
<message> <message>
<location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="258"/> <location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="244"/>
<source>@nb_points</source> <source>@nb_points</source>
<translation>@nb_points</translation> <translation>@nb_points</translation>
</message> </message>
<message> <message>
<location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="265"/> <location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="251"/>
<source>Cross-sections:</source> <source>Cross-sections:</source>
<translation>Section en travers :</translation> <translation>Section en travers :</translation>
</message> </message>
<message> <message>
<location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="272"/> <location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="258"/>
<source>Points:</source> <source>Points:</source>
<translation>Points :</translation> <translation>Points :</translation>
</message> </message>
<message> <message>
<location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="282"/> <location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="268"/>
<source>@nb_cs</source> <source>@nb_cs</source>
<translation>@nb_cs</translation> <translation>@nb_cs</translation>
</message> </message>
<message> <message>
<location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="148"/> <location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="134"/>
<source>@nb_res</source> <source>@nb_res</source>
<translation>@nb_res</translation> <translation>@nb_res</translation>
</message> </message>
<message> <message>
<location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="165"/> <location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="151"/>
<source>Boundary conditions:</source> <source>Boundary conditions:</source>
<translation>Conditions aux limites :</translation> <translation>Conditions aux limites :</translation>
</message> </message>
<message> <message>
<location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="172"/> <location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="158"/>
<source>Reservoir:</source> <source>Reservoir:</source>
<translation>Casier :</translation> <translation>Casier :</translation>
</message> </message>
<message> <message>
<location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="179"/> <location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="165"/>
<source>@nb_bc</source> <source>@nb_bc</source>
<translation>@nb_bc</translation> <translation>@nb_bc</translation>
</message> </message>
<message> <message>
<location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="199"/> <location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="185"/>
<source>Lateral contributions:</source> <source>Lateral contributions:</source>
<translation>Contributions latérales :</translation> <translation>Contributions latérales :</translation>
</message> </message>
<message> <message>
<location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="206"/> <location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="192"/>
<source>@nb_lc</source> <source>@nb_lc</source>
<translation>@nb_lc</translation> <translation>@nb_lc</translation>
</message> </message>
<message> <message>
<location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="248"/> <location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="234"/>
<source>Hydraulic stuctures:</source> <source>Hydraulic stuctures:</source>
<translation>Ouvrages hydrauliques :</translation> <translation>Ouvrages hydrauliques :</translation>
</message> </message>
<message> <message>
<location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="289"/> <location filename="../View/ui/Widgets/MainWindowTabInfo.ui" line="275"/>
<source>@nb_hs</source> <source>@nb_hs</source>
<translation>@nb_hs</translation> <translation>@nb_hs</translation>
</message> </message>
<message> <message>
<location filename="../View/ui/Widgets/MainWindowTabCheckers.ui" line="22"/> <location filename="../View/ui/Widgets/MainWindowTabCheckers.ui" line="22"/>
<source>Restart</source> <source>Restart</source>
<translation>Relancer</translation> <translation type="obsolete">Relancer</translation>
</message> </message>
<message> <message>
<location filename="../View/ui/Widgets/MainWindowTabCheckers.ui" line="53"/> <location filename="../View/ui/Widgets/MainWindowTabCheckers.ui" line="29"/>
<source>Checkers list</source> <source>Checkers list</source>
<translation>Liste des vérificateurs</translation> <translation>Liste des vérificateurs</translation>
</message> </message>
<message> <message>
<location filename="../View/ui/Widgets/MainWindowTabCheckers.ui" line="63"/> <location filename="../View/ui/Widgets/MainWindowTabCheckers.ui" line="39"/>
<source>Errors summary</source> <source>Errors summary</source>
<translation>Résumer des erreurs</translation> <translation>Résumer des erreurs</translation>
</message> </message>
@ -1874,7 +1874,7 @@
<message> <message>
<location filename="../View/ui/CheckList.ui" line="88"/> <location filename="../View/ui/CheckList.ui" line="88"/>
<source>Retry check</source> <source>Retry check</source>
<translation>Réessayer les verifications</translation> <translation>Réessayer les vérifications</translation>
</message> </message>
<message> <message>
<location filename="../View/ui/BasicHydraulicStructures.ui" line="14"/> <location filename="../View/ui/BasicHydraulicStructures.ui" line="14"/>
@ -2149,7 +2149,7 @@
<message> <message>
<location filename="../View/Translate.py" line="81"/> <location filename="../View/Translate.py" line="81"/>
<source>Checks</source> <source>Checks</source>
<translation>Verifications</translation> <translation>Vérifications</translation>
</message> </message>
<message> <message>
<location filename="../View/ui/MainWindow.ui" line="200"/> <location filename="../View/ui/MainWindow.ui" line="200"/>
@ -2239,7 +2239,7 @@
<message> <message>
<location filename="../View/ui/MainWindow.ui" line="568"/> <location filename="../View/ui/MainWindow.ui" line="568"/>
<source>Edit the study information</source> <source>Edit the study information</source>
<translation type="unfinished"></translation> <translation>Éditer les information de l&apos;étude</translation>
</message> </message>
</context> </context>
<context> <context>