diff --git a/src/View/OutputKpAdisTS/BasicHydraulicStructures/Table.py b/src/View/OutputKpAdisTS/BasicHydraulicStructures/Table.py
deleted file mode 100644
index f69a4099..00000000
--- a/src/View/OutputKpAdisTS/BasicHydraulicStructures/Table.py
+++ /dev/null
@@ -1,277 +0,0 @@
-# Table.py -- Pamhyr
-# Copyright (C) 2023-2024 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 .
-
-# -*- coding: utf-8 -*-
-
-import logging
-import traceback
-
-from tools import trace, timer
-
-from PyQt5.QtCore import (
- Qt, QVariant, QAbstractTableModel,
- QCoreApplication, QModelIndex, pyqtSlot,
- QRect,
-)
-
-from PyQt5.QtWidgets import (
- QDialogButtonBox, QPushButton, QLineEdit,
- QFileDialog, QTableView, QAbstractItemView,
- QUndoStack, QShortcut, QAction, QItemDelegate,
- QComboBox, QMessageBox,
-)
-
-from View.Tools.PamhyrTable import PamhyrTableModel
-
-from View.HydraulicStructures.BasicHydraulicStructures.UndoCommand import (
- SetNameCommand, SetTypeCommand,
- SetEnabledCommand, AddCommand, DelCommand,
- SetValueCommand,
-)
-from Model.HydraulicStructures.Basic.Types import BHS_types
-
-logger = logging.getLogger()
-
-_translate = QCoreApplication.translate
-
-
-class ComboBoxDelegate(QItemDelegate):
- def __init__(self, data=None, trad=None, parent=None):
- super(ComboBoxDelegate, self).__init__(parent)
-
- self._data = data
- self._trad = trad
-
- self._long_types = {}
- if self._trad is not None:
- self._long_types = self._trad.get_dict("long_types")
-
- def createEditor(self, parent, option, index):
- self.editor = QComboBox(parent)
-
- lst = list(
- map(
- lambda k: self._long_types[k],
- BHS_types.keys()
- )
- )
- self.editor.addItems(lst)
-
- self.editor.setCurrentText(index.data(Qt.DisplayRole))
- return self.editor
-
- def setEditorData(self, editor, index):
- value = index.data(Qt.DisplayRole)
- self.editor.currentTextChanged.connect(self.currentItemChanged)
-
- def setModelData(self, editor, model, index):
- text = str(editor.currentText())
- model.setData(index, text)
- editor.close()
- editor.deleteLater()
-
- def updateEditorGeometry(self, editor, option, index):
- r = QRect(option.rect)
- if self.editor.windowFlags() & Qt.Popup:
- if editor.parent() is not None:
- r.setTopLeft(self.editor.parent().mapToGlobal(r.topLeft()))
- editor.setGeometry(r)
-
- @pyqtSlot()
- def currentItemChanged(self):
- self.commitData.emit(self.sender())
-
-
-class TableModel(PamhyrTableModel):
- def __init__(self, trad=None, **kwargs):
- self._trad = trad
- self._long_types = {}
- if self._trad is not None:
- self._long_types = self._trad.get_dict("long_types")
-
- super(TableModel, self).__init__(trad=trad, **kwargs)
-
- def rowCount(self, parent):
- return len(self._lst)
-
- def data(self, index, role):
- if role != Qt.ItemDataRole.DisplayRole:
- return QVariant()
-
- row = index.row()
- column = index.column()
-
- if self._headers[column] == "name":
- return self._data.basic_structure(row).name
- elif self._headers[column] == "type":
- return self._long_types[self._data.basic_structure(row).type]
-
- return QVariant()
-
- def setData(self, index, value, role=Qt.EditRole):
- if not index.isValid() or role != Qt.EditRole:
- return False
-
- row = index.row()
- column = index.column()
-
- try:
- if self._headers[column] == "name":
- self._undo.push(
- SetNameCommand(
- self._data, row, value
- )
- )
- elif self._headers[column] == "type":
- old_type = self._data.basic_structure(row).type
-
- if old_type == "ND" or self._question_set_type():
- key = next(
- k for k, v in self._long_types.items()
- if v == value
- )
-
- self._undo.push(
- SetTypeCommand(
- self._data, row, BHS_types[key]
- )
- )
- except Exception as e:
- logger.error(e)
- logger.debug(traceback.format_exc())
-
- self.dataChanged.emit(index, index)
- return True
-
- def _question_set_type(self):
- question = QMessageBox(self._parent)
-
- question.setWindowTitle(self._trad['msg_type_change_title'])
- question.setText(self._trad['msg_type_change_text'])
- question.setStandardButtons(QMessageBox.Cancel | QMessageBox.Ok)
- question.setIcon(QMessageBox.Question)
-
- res = question.exec()
- return res == QMessageBox.Ok
-
- def add(self, row, parent=QModelIndex()):
- self.beginInsertRows(parent, row, row - 1)
-
- self._undo.push(
- AddCommand(
- self._data, row
- )
- )
-
- self.endInsertRows()
- self.layoutChanged.emit()
-
- def delete(self, rows, parent=QModelIndex()):
- self.beginRemoveRows(parent, rows[0], rows[-1])
-
- self._undo.push(
- DelCommand(
- self._data, rows
- )
- )
-
- self.endRemoveRows()
- self.layoutChanged.emit()
-
- def enabled(self, row, enabled, parent=QModelIndex()):
- self._undo.push(
- SetEnabledCommand(
- self._lst, row, enabled
- )
- )
- self.layoutChanged.emit()
-
- def undo(self):
- self._undo.undo()
- self.layoutChanged.emit()
-
- def redo(self):
- self._undo.redo()
- self.layoutChanged.emit()
-
-
-class ParametersTableModel(PamhyrTableModel):
- def __init__(self, trad=None, **kwargs):
- self._trad = trad
- self._long_types = {}
-
- if self._trad is not None:
- self._long_types = self._trad.get_dict("long_types")
-
- self._hs_index = None
-
- super(ParametersTableModel, self).__init__(trad=trad, **kwargs)
-
- def rowCount(self, parent):
- if self._hs_index is None:
- return 0
-
- return len(
- self._data.basic_structure(self._hs_index)
- )
-
- def data(self, index, role):
- if role != Qt.ItemDataRole.DisplayRole:
- return QVariant()
-
- if self._hs_index is None:
- return QVariant()
-
- row = index.row()
- column = index.column()
-
- hs = self._data.basic_structure(self._hs_index)
-
- if self._headers[column] == "name":
- return self._trad[hs.parameters[row].name]
- elif self._headers[column] == "value":
- return str(hs.parameters[row].value)
-
- return QVariant()
-
- def setData(self, index, value, role=Qt.EditRole):
- if not index.isValid() or role != Qt.EditRole:
- return False
-
- if self._hs_index is None:
- return QVariant()
-
- row = index.row()
- column = index.column()
-
- try:
- if self._headers[column] == "value":
- self._undo.push(
- SetValueCommand(
- self._data.basic_structure(self._hs_index),
- row, value
- )
- )
- except Exception as e:
- logger.error(e)
- logger.debug(traceback.format_exc())
-
- self.dataChanged.emit(index, index)
- return True
-
- def update_hs_index(self, index):
- self._hs_index = index
- self.layoutChanged.emit()
diff --git a/src/View/OutputKpAdisTS/BasicHydraulicStructures/Translate.py b/src/View/OutputKpAdisTS/BasicHydraulicStructures/Translate.py
deleted file mode 100644
index f55fb2d7..00000000
--- a/src/View/OutputKpAdisTS/BasicHydraulicStructures/Translate.py
+++ /dev/null
@@ -1,155 +0,0 @@
-# translate.py -- Pamhyr
-# Copyright (C) 2023-2024 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 .
-
-# -*- coding: utf-8 -*-
-
-from PyQt5.QtCore import QCoreApplication
-
-from View.Translate import MainTranslate
-
-_translate = QCoreApplication.translate
-
-
-class BasicHydraulicStructuresTranslate(MainTranslate):
- def __init__(self):
- super(BasicHydraulicStructuresTranslate, self).__init__()
-
- self._dict["Basic Hydraulic Structures"] = _translate(
- "BasicHydraulicStructures", "Basic Hydraulic Structures"
- )
-
- self._dict['msg_type_change_title'] = _translate(
- "BasicHydraulicStructures",
- "Change hydraulic structure type"
- )
-
- self._dict['msg_type_change_text'] = _translate(
- "BasicHydraulicStructures",
- "Do you want to change the hydraulic structure type and reset \
-hydraulic structure values?"
- )
-
- # BHSValues translation
-
- self._dict['width'] = self._dict["unit_width"]
- self._dict['height'] = self._dict["unit_thickness"]
- self._dict['elevation'] = self._dict["unit_elevation"]
- self._dict['diameter'] = self._dict["unit_diameter"]
- self._dict['discharge_coefficient'] = _translate(
- "BasicHydraulicStructures", "Discharge coefficient"
- )
- self._dict['loading_elevation'] = _translate(
- "BasicHydraulicStructures", "Upper elevation (m)"
- )
- self._dict['half-angle_tangent'] = _translate(
- "BasicHydraulicStructures", "Half-angle tangent"
- )
- self._dict['maximal_loading_elevation'] = _translate(
- "BasicHydraulicStructures", "Maximal loading elevation"
- )
- self._dict['siltation_height'] = _translate(
- "BasicHydraulicStructures", "Siltation height (m)"
- )
- self._dict['top_of_the_vault'] = _translate(
- "BasicHydraulicStructures", "Top of the vault (m)"
- )
- self._dict['bottom_of_the_vault'] = _translate(
- "BasicHydraulicStructures", "Bottom of the vault (m)"
- )
- self._dict['opening'] = _translate(
- "BasicHydraulicStructures", "Opening"
- )
- self._dict['maximal_opening'] = _translate(
- "BasicHydraulicStructures", "Maximal opening"
- )
- self._dict['step_space'] = _translate(
- "BasicHydraulicStructures", "Step space"
- )
- self._dict['weir'] = _translate(
- "BasicHydraulicStructures", "Weir"
- )
- self._dict['coefficient'] = _translate(
- "BasicHydraulicStructures", "Coefficient"
- )
-
- # Dummy parameters
-
- self._dict['parameter_1'] = _translate(
- "BasicHydraulicStructures", "Parameter 1"
- )
- self._dict['parameter_2'] = _translate(
- "BasicHydraulicStructures", "Parameter 2"
- )
- self._dict['parameter_3'] = _translate(
- "BasicHydraulicStructures", "Parameter 3"
- )
- self._dict['parameter_4'] = _translate(
- "BasicHydraulicStructures", "Parameter 4"
- )
- self._dict['parameter_5'] = _translate(
- "BasicHydraulicStructures", "Parameter 5"
- )
-
- # BHS types long names
-
- self._sub_dict["long_types"] = {
- "ND": self._dict["not_defined"],
- "S1": _translate(
- "BasicHydraulicStructures", "Discharge weir"
- ),
- "S2": _translate(
- "BasicHydraulicStructures", "Trapezoidal weir"
- ),
- "S3": _translate(
- "BasicHydraulicStructures", "Triangular weir"
- ),
- "OR": _translate(
- "BasicHydraulicStructures", "Rectangular orifice"
- ),
- "OC": _translate(
- "BasicHydraulicStructures", "Circular orifice"
- ),
- "OV": _translate(
- "BasicHydraulicStructures", "Vaulted orifice"
- ),
- "V1": _translate(
- "BasicHydraulicStructures", "Rectangular gate"
- ),
- "V2": _translate(
- "BasicHydraulicStructures", "Simplified rectangular gate"
- ),
- "BO": _translate(
- "BasicHydraulicStructures", "Borda-type head loss"
- ),
- "CV": _translate(
- "BasicHydraulicStructures", "Check valve"
- ),
- "UD": _translate(
- "BasicHydraulicStructures", "User defined"
- ),
- }
-
- # Tables
-
- self._sub_dict["table_headers"] = {
- "name": self._dict["name"],
- "type": self._dict["type"],
- }
-
- self._sub_dict["table_headers_parameters"] = {
- "name": self._dict["name"],
- "value": self._dict["value"],
- }
diff --git a/src/View/OutputKpAdisTS/BasicHydraulicStructures/UndoCommand.py b/src/View/OutputKpAdisTS/BasicHydraulicStructures/UndoCommand.py
deleted file mode 100644
index 78fa3d62..00000000
--- a/src/View/OutputKpAdisTS/BasicHydraulicStructures/UndoCommand.py
+++ /dev/null
@@ -1,153 +0,0 @@
-# UndoCommand.py -- Pamhyr
-# Copyright (C) 2023-2024 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 .
-
-# -*- coding: utf-8 -*-
-
-from copy import deepcopy
-from tools import trace, timer
-
-from PyQt5.QtWidgets import (
- QMessageBox, QUndoCommand, QUndoStack,
-)
-
-
-class SetNameCommand(QUndoCommand):
- def __init__(self, hs, index, new_value):
- QUndoCommand.__init__(self)
-
- self._hs = hs
- self._index = index
- self._old = self._hs.basic_structure(self._index).name
- self._new = str(new_value)
-
- def undo(self):
- self._hs.basic_structure(self._index).name = self._old
-
- def redo(self):
- self._hs.basic_structure(self._index).name = self._new
-
-
-class SetTypeCommand(QUndoCommand):
- def __init__(self, hs, index, new_type):
- QUndoCommand.__init__(self)
-
- self._hs = hs
- self._index = index
- self._type = new_type
- self._old = self._hs.basic_structure(self._index)
- self._new = self._hs.basic_structure(self._index)\
- .convert(self._type)
-
- def undo(self):
- self._hs.delete_i([self._index])
- self._hs.insert(self._index, self._old)
-
- def redo(self):
- self._hs.delete_i([self._index])
- self._hs.insert(self._index, self._new)
-
-
-class SetEnabledCommand(QUndoCommand):
- def __init__(self, hs, index, enabled):
- QUndoCommand.__init__(self)
-
- self._hs = hs
- self._index = index
- self._old = not enabled
- self._new = enabled
-
- def undo(self):
- self._hs.basic_structure(self._index).enabled = self._old
-
- def redo(self):
- self._hs.basic_structure(self._index).enabled = self._new
-
-
-class AddCommand(QUndoCommand):
- def __init__(self, hs, index):
- QUndoCommand.__init__(self)
-
- self._hs = hs
-
- self._index = index
- self._new = None
-
- def undo(self):
- self._hs.delete_i([self._index])
-
- def redo(self):
- if self._new is None:
- self._new = self._hs.add(self._index)
- else:
- self._hs.insert(self._index, self._new)
-
-
-class DelCommand(QUndoCommand):
- def __init__(self, hs, rows):
- QUndoCommand.__init__(self)
-
- self._hs = hs
-
- self._rows = rows
-
- self._bhs = []
- for row in rows:
- self._bhs.append((row, self._hs.basic_structure(row)))
-
- def undo(self):
- for row, el in self._bhs:
- self._hs.insert(row, el)
-
- def redo(self):
- self._hs.delete_i(self._rows)
-
-
-class PasteCommand(QUndoCommand):
- def __init__(self, hs, row, h_s):
- QUndoCommand.__init__(self)
-
- self._hs = hs
-
- self._row = row
- self._bhs = deepcopy(h_s)
- self._bhs.reverse()
-
- def undo(self):
- self._hs.delete_i(range(self._row, self._row + len(self._bhs)))
-
- def redo(self):
- for r in self._bhs:
- self._hs.insert(self._row, r)
-
-####################################
-# Basic hydraulic structure values #
-####################################
-
-
-class SetValueCommand(QUndoCommand):
- def __init__(self, bhs, index, value):
- QUndoCommand.__init__(self)
-
- self._bhs = bhs
- self._index = index
- self._old = self._bhs.parameters[self._index].value
- self._new = self._bhs.parameters[self._index].type(value)
-
- def undo(self):
- self._bhs.parameters[self._index].value = self._old
-
- def redo(self):
- self._bhs.parameters[self._index].value = self._new
diff --git a/src/View/OutputKpAdisTS/BasicHydraulicStructures/Window.py b/src/View/OutputKpAdisTS/BasicHydraulicStructures/Window.py
deleted file mode 100644
index 838d7bc0..00000000
--- a/src/View/OutputKpAdisTS/BasicHydraulicStructures/Window.py
+++ /dev/null
@@ -1,236 +0,0 @@
-# Window.py -- Pamhyr
-# Copyright (C) 2023-2024 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 .
-
-# -*- coding: utf-8 -*-
-
-import logging
-
-from tools import timer, trace
-
-from View.Tools.PamhyrWindow import PamhyrWindow
-
-from PyQt5 import QtCore
-from PyQt5.QtCore import (
- Qt, QVariant, QAbstractTableModel, QCoreApplication,
- pyqtSlot, pyqtSignal, QItemSelectionModel,
-)
-
-from PyQt5.QtWidgets import (
- QDialogButtonBox, QPushButton, QLineEdit,
- QFileDialog, QTableView, QAbstractItemView,
- QUndoStack, QShortcut, QAction, QItemDelegate,
- QHeaderView, QDoubleSpinBox, QVBoxLayout, QCheckBox
-)
-
-from View.Tools.Plot.PamhyrCanvas import MplCanvas
-from View.Tools.Plot.PamhyrToolbar import PamhyrPlotToolbar
-
-from View.HydraulicStructures.BasicHydraulicStructures.Table import (
- ComboBoxDelegate, TableModel, ParametersTableModel,
-)
-
-from View.Network.GraphWidget import GraphWidget
-from View.HydraulicStructures.BasicHydraulicStructures.Translate import (
- BasicHydraulicStructuresTranslate
-)
-
-_translate = QCoreApplication.translate
-
-logger = logging.getLogger()
-
-
-class BasicHydraulicStructuresWindow(PamhyrWindow):
- _pamhyr_ui = "BasicHydraulicStructures"
- _pamhyr_name = "Basic Hydraulic Structures"
-
- def __init__(self, data=None, study=None, config=None, parent=None):
- trad = BasicHydraulicStructuresTranslate()
- name = " - ".join([
- trad[self._pamhyr_name], data.name, study.name
- ])
-
- super(BasicHydraulicStructuresWindow, self).__init__(
- title=name,
- study=study,
- config=config,
- trad=trad,
- parent=parent
- )
-
- self._hash_data.append(data)
-
- self._hs = data
-
- self.setup_table()
- self.setup_checkbox()
- self.setup_connections()
-
- self.update()
-
- def setup_table(self):
- self.setup_table_bhs()
- self.setup_table_bhs_parameters()
-
- def setup_table_bhs(self):
- self._table = None
-
- self._delegate_type = ComboBoxDelegate(
- trad=self._trad,
- parent=self
- )
-
- table = self.find(QTableView, f"tableView")
- self._table = TableModel(
- table_view=table,
- table_headers=self._trad.get_dict("table_headers"),
- editable_headers=["name", "type"],
- delegates={
- "type": self._delegate_type,
- },
- trad=self._trad,
- data=self._hs,
- undo=self._undo_stack,
- parent=self,
- )
-
- selectionModel = table.selectionModel()
- index = table.model().index(0, 0)
-
- selectionModel.select(
- index,
- QItemSelectionModel.Rows |
- QItemSelectionModel.ClearAndSelect |
- QItemSelectionModel.Select
- )
- table.scrollTo(index)
-
- def setup_table_bhs_parameters(self):
- self._table_parameters = None
-
- table = self.find(QTableView, f"tableView_2")
- self._table_parameters = ParametersTableModel(
- table_view=table,
- table_headers=self._trad.get_dict("table_headers_parameters"),
- editable_headers=["value"],
- delegates={},
- trad=self._trad,
- data=self._hs,
- undo=self._undo_stack,
- parent=self,
- )
-
- def setup_checkbox(self):
- self._checkbox = self.find(QCheckBox, f"checkBox")
- self._set_checkbox_state()
-
- def setup_connections(self):
- self.find(QAction, "action_add").triggered.connect(self.add)
- self.find(QAction, "action_delete").triggered.connect(self.delete)
- self._checkbox.clicked.connect(self._set_basic_structure_state)
-
- table = self.find(QTableView, "tableView")
- table.selectionModel()\
- .selectionChanged\
- .connect(self.update)
-
- self._table.dataChanged.connect(self.update)
- self._table.layoutChanged.connect(self.update)
-
- def index_selected(self):
- table = self.find(QTableView, "tableView")
- r = table.selectionModel().selectedRows()
-
- if len(r) > 0:
- return r[0]
- else:
- return None
-
- def index_selected_row(self):
- table = self.find(QTableView, "tableView")
- r = table.selectionModel().selectedRows()
-
- if len(r) > 0:
- return r[0].row()
- else:
- return None
-
- def index_selected_rows(self):
- table = self.find(QTableView, "tableView")
- return list(
- # Delete duplicate
- set(
- map(
- lambda i: i.row(),
- table.selectedIndexes()
- )
- )
- )
-
- def add(self):
- rows = self.index_selected_rows()
-
- if len(self._hs) == 0 or len(rows) == 0:
- self._table.add(0)
- else:
- self._table.add(rows[0])
-
- def delete(self):
- rows = self.index_selected_rows()
-
- if len(rows) == 0:
- return
-
- self._table.delete(rows)
-
- def _copy(self):
- logger.info("TODO: copy")
-
- def _paste(self):
- logger.info("TODO: paste")
-
- def _undo(self):
- self._table.undo()
-
- def _redo(self):
- self._table.redo()
-
- def _set_checkbox_state(self):
- row = self.index_selected_row()
-
- if row is None:
- self._checkbox.setEnabled(False)
- self._checkbox.setChecked(True)
- else:
- self._checkbox.setEnabled(True)
- self._checkbox.setChecked(self._hs.basic_structure(row).enabled)
-
- def _set_basic_structure_state(self):
- rows = self.index_selected_rows()
- if len(rows) != 0:
- for row in rows:
- if row is not None:
- self._table.enabled(
- row,
- self._checkbox.isChecked()
- )
-
- def update(self):
- self._set_checkbox_state()
- self._update_parameters_table()
-
- def _update_parameters_table(self):
- row = self.index_selected_row()
- self._table_parameters.update_hs_index(row)
diff --git a/src/View/OutputKpAdisTS/Table.py b/src/View/OutputKpAdisTS/Table.py
index 73153ef6..1b7ab289 100644
--- a/src/View/OutputKpAdisTS/Table.py
+++ b/src/View/OutputKpAdisTS/Table.py
@@ -37,7 +37,7 @@ from PyQt5.QtWidgets import (
from View.Tools.PamhyrTable import PamhyrTableModel
from View.OutputKpAdisTS.UndoCommand import (
- SetNameCommand, SetReachCommand, SetKpCommand,
+ SetTitleCommand, SetReachCommand, SetKpCommand,
SetEnabledCommand, AddCommand, DelCommand,
)
@@ -145,7 +145,7 @@ class TableModel(PamhyrTableModel):
try:
if self._headers[column] == "title":
self._undo.push(
- SetNameCommand(
+ SetTitleCommand(
self._lst, row, value
)
)
diff --git a/src/View/OutputKpAdisTS/UndoCommand.py b/src/View/OutputKpAdisTS/UndoCommand.py
index 37f3dec0..76a06335 100644
--- a/src/View/OutputKpAdisTS/UndoCommand.py
+++ b/src/View/OutputKpAdisTS/UndoCommand.py
@@ -28,13 +28,13 @@ from PyQt5.QtWidgets import (
logger = logging.getLogger()
-class SetNameCommand(QUndoCommand):
+class SetTitleCommand(QUndoCommand):
def __init__(self, outputkp_lst, index, new_value):
QUndoCommand.__init__(self)
self._outputkp_lst = outputkp_lst
self._index = index
- self._old = self._outputkp_lst.get(self._index).name
+ self._old = self._outputkp_lst.get(self._index).title
self._new = str(new_value)
def undo(self):
@@ -50,20 +50,20 @@ class SetReachCommand(QUndoCommand):
self._outputkp_lst = outputkp_lst
self._index = index
- self._old = self._outputkp_lst.get(self._index).input_reach
+ self._old = self._outputkp_lst.get(self._index).reach
self._new = reach
- self._old_kp = self._outputkp_lst.get(self._index).input_kp
+ self._old_kp = self._outputkp_lst.get(self._index).kp
self._new_kp = None
def undo(self):
i = self._outputkp_lst.get(self._index)
- i.input_reach = self._old
- i.input_kp = self._old_kp
+ i.reach = self._old
+ i.kp = self._old_kp
def redo(self):
i = self._outputkp_lst.get(self._index)
- i.input_reach = self._new
- i.input_kp = self._new_kp
+ i.reach = self._new
+ i.kp = self._new_kp
class SetKpCommand(QUndoCommand):
@@ -72,14 +72,14 @@ class SetKpCommand(QUndoCommand):
self._outputkp_lst = outputkp_lst
self._index = index
- self._old = self._outputkp_lst.get(self._index).input_kp
+ self._old = self._outputkp_lst.get(self._index).kp
self._new = kp
def undo(self):
- self._outputkp_lst.get(self._index).input_kp = self._old
+ self._outputkp_lst.get(self._index).kp = self._old
def redo(self):
- self._outputkp_lst.get(self._index).input_kp = self._new
+ self._outputkp_lst.get(self._index).kp = self._new
class SetEnabledCommand(QUndoCommand):
diff --git a/src/View/OutputKpAdisTS/Window.py b/src/View/OutputKpAdisTS/Window.py
index 3ff4ec2f..04840d59 100644
--- a/src/View/OutputKpAdisTS/Window.py
+++ b/src/View/OutputKpAdisTS/Window.py
@@ -45,10 +45,6 @@ from View.OutputKpAdisTS.Table import (
from View.Network.GraphWidget import GraphWidget
from View.OutputKpAdisTS.Translate import OutputKpAdisTSTranslate
-from View.OutputKpAdisTS.BasicHydraulicStructures.Window import (
- BasicHydraulicStructuresWindow
-)
-
logger = logging.getLogger()
@@ -124,8 +120,7 @@ class OutputKpAdisTSWindow(PamhyrWindow):
def setup_connections(self):
self.find(QAction, "action_add").triggered.connect(self.add)
self.find(QAction, "action_delete").triggered.connect(self.delete)
- self.find(QAction, "action_edit").triggered.connect(self.edit)
- self._checkbox.clicked.connect(self._set_structure_state)
+ self._checkbox.clicked.connect(self._set_outputkp_state)
table = self.find(QTableView, "tableView")
table.selectionModel()\
@@ -191,24 +186,6 @@ class OutputKpAdisTSWindow(PamhyrWindow):
def _redo(self):
self._table.redo()
- def edit(self):
- rows = self.index_selected_rows()
- for row in rows:
- data = self._outputkp_lst.get(row)
-
- if self.sub_window_exists(
- BasicHydraulicStructuresWindow,
- data=[self._study, None, data]
- ):
- continue
-
- win = BasicHydraulicStructuresWindow(
- data=data,
- study=self._study,
- parent=self
- )
- win.show()
-
def _set_checkbox_state(self):
row = self.index_selected_row()
if row is None:
@@ -218,7 +195,7 @@ class OutputKpAdisTSWindow(PamhyrWindow):
self._checkbox.setEnabled(True)
self._checkbox.setChecked(self._outputkp_lst.get(row).enabled)
- def _set_structure_state(self):
+ def _set_outputkp_state(self):
rows = self.index_selected_rows()
if len(rows) != 0:
for row in rows:
diff --git a/src/View/ui/OutputKpAdisTS.ui b/src/View/ui/OutputKpAdisTS.ui
index fb911909..8c516d86 100644
--- a/src/View/ui/OutputKpAdisTS.ui
+++ b/src/View/ui/OutputKpAdisTS.ui
@@ -95,7 +95,6 @@
-
@@ -121,18 +120,6 @@
Delete points
-
-
-
- ressources/edit.pngressources/edit.png
-
-
- Edit
-
-
- Edit selected hydraulic structure
-
-
diff --git a/tests_cases/Ardeche/Ardeche.pamhyr b/tests_cases/Ardeche/Ardeche.pamhyr
index 1dc13ad2..874da2fc 100644
Binary files a/tests_cases/Ardeche/Ardeche.pamhyr and b/tests_cases/Ardeche/Ardeche.pamhyr differ