mirror of
https://gitlab.com/pamhyr/pamhyr2.git
synced 2026-10-30 03:20:41 +01:00
pep8: Some modifications to respect pep8 standard code.
This commit is contained in:
1 parent
8544dd1144
commit
fa2454d079
152 files changed
+1626
-1277
No files matched your search
@@ -26,6 +26,7 @@ from PyQt5.QtCore import QCoreApplication
|
||||
_translate = QCoreApplication.translate
|
||||
logger = logging.getLogger()
|
||||
|
||||
|
||||
class AboutWindow(PamhyrDialog):
|
||||
_pamhyr_ui = "about"
|
||||
_pamhyr_name = "About"
|
||||
@@ -38,13 +39,13 @@ class AboutWindow(PamhyrDialog):
|
||||
)
|
||||
)
|
||||
|
||||
def __init__(self, study = None, config = None, parent=None):
|
||||
def __init__(self, study=None, config=None, parent=None):
|
||||
super(AboutWindow, self).__init__(
|
||||
title = _translate("About", "About"),
|
||||
study = study,
|
||||
config = config,
|
||||
options = [],
|
||||
parent = parent
|
||||
title=_translate("About", "About"),
|
||||
study=study,
|
||||
config=config,
|
||||
options=[],
|
||||
parent=parent
|
||||
)
|
||||
|
||||
# Version
|
||||
|
||||
@@ -33,16 +33,17 @@ _translate = QCoreApplication.translate
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
|
||||
class Plot(PamhyrPlot):
|
||||
def __init__(self, mode = "time", data=None,
|
||||
def __init__(self, mode="time", data=None,
|
||||
trad=None, canvas=None, toolbar=None,
|
||||
parent=None):
|
||||
super(Plot, self).__init__(
|
||||
canvas = canvas,
|
||||
trad = trad,
|
||||
data = data,
|
||||
toolbar = toolbar,
|
||||
parent = parent
|
||||
canvas=canvas,
|
||||
trad=trad,
|
||||
data=data,
|
||||
toolbar=toolbar,
|
||||
parent=parent
|
||||
)
|
||||
|
||||
self._table_headers = self._trad.get_dict("table_headers")
|
||||
@@ -72,8 +73,8 @@ class Plot(PamhyrPlot):
|
||||
map(
|
||||
lambda v: str(
|
||||
datetime.fromtimestamp(v[0]) - t0
|
||||
).split(",")[0]\
|
||||
.replace("days", _translate("BoundaryCondition", "days"))\
|
||||
).split(",")[0]
|
||||
.replace("days", _translate("BoundaryCondition", "days"))
|
||||
.replace("day", _translate("BoundaryCondition", "day")),
|
||||
fx
|
||||
)
|
||||
@@ -88,7 +89,6 @@ class Plot(PamhyrPlot):
|
||||
|
||||
self.canvas.axes.set_xticks(ticks=xx, labels=xt, rotation=45)
|
||||
|
||||
|
||||
@timer
|
||||
def draw(self):
|
||||
self.canvas.axes.cla()
|
||||
@@ -122,7 +122,7 @@ class Plot(PamhyrPlot):
|
||||
self.canvas.axes.autoscale_view(True, True, True)
|
||||
self.canvas.figure.tight_layout()
|
||||
self.canvas.figure.canvas.draw_idle()
|
||||
#self.toolbar.update()
|
||||
# self.toolbar.update()
|
||||
|
||||
self._init = True
|
||||
|
||||
|
||||
@@ -51,6 +51,7 @@ _translate = QCoreApplication.translate
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
|
||||
class TableModel(PamhyrTableModel):
|
||||
def data(self, index, role):
|
||||
if role == Qt.TextAlignmentRole:
|
||||
|
||||
@@ -29,6 +29,7 @@ from Model.BoundaryCondition.BoundaryCondition import BoundaryCondition
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
|
||||
class SetDataCommand(QUndoCommand):
|
||||
def __init__(self, data, index, column, new_value):
|
||||
QUndoCommand.__init__(self)
|
||||
@@ -46,6 +47,7 @@ class SetDataCommand(QUndoCommand):
|
||||
def redo(self):
|
||||
self._data._set_i_c_v(self._index, self._column, self._new)
|
||||
|
||||
|
||||
class SetMetaDataCommand(QUndoCommand):
|
||||
def __init__(self, data, column, new_value):
|
||||
QUndoCommand.__init__(self)
|
||||
@@ -89,6 +91,7 @@ class AddCommand(QUndoCommand):
|
||||
else:
|
||||
self._data.insert(self._index, self._new)
|
||||
|
||||
|
||||
class DelCommand(QUndoCommand):
|
||||
def __init__(self, data, rows):
|
||||
QUndoCommand.__init__(self)
|
||||
@@ -108,6 +111,7 @@ class DelCommand(QUndoCommand):
|
||||
def redo(self):
|
||||
self._data.delete_i(self._rows)
|
||||
|
||||
|
||||
class SortCommand(QUndoCommand):
|
||||
def __init__(self, data, _reverse):
|
||||
QUndoCommand.__init__(self)
|
||||
|
||||
@@ -53,6 +53,7 @@ _translate = QCoreApplication.translate
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
|
||||
class WD50Sigma(PamhyrWidget):
|
||||
_pamhyr_ui = "d50sigma"
|
||||
|
||||
@@ -94,6 +95,7 @@ class WD50Sigma(PamhyrWidget):
|
||||
def valueChangedSigma(self, value):
|
||||
self.sigmaChanged.emit(value)
|
||||
|
||||
|
||||
class EditBoundaryConditionWindow(PamhyrWindow):
|
||||
_pamhyr_ui = "EditBoundaryConditions"
|
||||
_pamhyr_name = "Edit Boundary Conditions"
|
||||
@@ -115,11 +117,11 @@ class EditBoundaryConditionWindow(PamhyrWindow):
|
||||
)
|
||||
|
||||
super(EditBoundaryConditionWindow, self).__init__(
|
||||
title = name,
|
||||
study = study,
|
||||
config = config,
|
||||
trad = trad,
|
||||
parent = parent
|
||||
title=name,
|
||||
study=study,
|
||||
config=config,
|
||||
trad=trad,
|
||||
parent=parent
|
||||
)
|
||||
|
||||
self.setup_table()
|
||||
@@ -132,7 +134,7 @@ class EditBoundaryConditionWindow(PamhyrWindow):
|
||||
|
||||
if self._is_solid:
|
||||
layout = self.find(QVBoxLayout, "verticalLayout_table")
|
||||
self._d50sigma = WD50Sigma(parent = self)
|
||||
self._d50sigma = WD50Sigma(parent=self)
|
||||
layout.addWidget(self._d50sigma)
|
||||
|
||||
self._d50sigma.set_d50(self._data.d50)
|
||||
@@ -145,22 +147,22 @@ class EditBoundaryConditionWindow(PamhyrWindow):
|
||||
headers[h] = table_headers[h]
|
||||
|
||||
self._delegate_time = PamhyrExTimeDelegate(
|
||||
data = self._data,
|
||||
mode = self._study.time_system,
|
||||
parent = self
|
||||
data=self._data,
|
||||
mode=self._study.time_system,
|
||||
parent=self
|
||||
)
|
||||
|
||||
table = self.find(QTableView, "tableView")
|
||||
self._table = TableModel(
|
||||
table_view = table,
|
||||
table_headers = headers,
|
||||
editable_headers = self._data.header,
|
||||
delegates = {
|
||||
table_view=table,
|
||||
table_headers=headers,
|
||||
editable_headers=self._data.header,
|
||||
delegates={
|
||||
"time": self._delegate_time,
|
||||
},
|
||||
data = self._data,
|
||||
undo = self._undo_stack,
|
||||
opt_data = self._study.time_system
|
||||
data=self._data,
|
||||
undo=self._undo_stack,
|
||||
opt_data=self._study.time_system
|
||||
)
|
||||
|
||||
table.setModel(self._table)
|
||||
@@ -178,11 +180,11 @@ class EditBoundaryConditionWindow(PamhyrWindow):
|
||||
self.verticalLayout.addWidget(self.canvas)
|
||||
|
||||
self.plot = Plot(
|
||||
canvas = self.canvas,
|
||||
data = self._data,
|
||||
mode = self._study.time_system,
|
||||
trad = self._trad,
|
||||
toolbar = self.toolbar,
|
||||
canvas=self.canvas,
|
||||
data=self._data,
|
||||
mode=self._study.time_system,
|
||||
trad=self._trad,
|
||||
toolbar=self.toolbar,
|
||||
)
|
||||
self.plot.draw()
|
||||
|
||||
@@ -270,7 +272,6 @@ class EditBoundaryConditionWindow(PamhyrWindow):
|
||||
self._table.move_down(row)
|
||||
self.plot.update()
|
||||
|
||||
|
||||
def _copy(self):
|
||||
rows = self.index_selected_rows()
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ from View.BoundaryCondition.translate import BCTranslate
|
||||
|
||||
_translate = QCoreApplication.translate
|
||||
|
||||
|
||||
class BCETranslate(BCTranslate):
|
||||
def __init__(self):
|
||||
super(BCETranslate, self).__init__()
|
||||
|
||||
@@ -52,6 +52,7 @@ logger = logging.getLogger()
|
||||
|
||||
_translate = QCoreApplication.translate
|
||||
|
||||
|
||||
class ComboBoxDelegate(QItemDelegate):
|
||||
def __init__(self, data=None, mode="type", tab="", trad=None, parent=None):
|
||||
super(ComboBoxDelegate, self).__init__(parent)
|
||||
@@ -157,20 +158,21 @@ class TableModel(PamhyrTableModel):
|
||||
if self._headers[column] == "name":
|
||||
self._undo.push(
|
||||
SetNameCommand(
|
||||
self._lst, self._tab,row, value
|
||||
self._lst, self._tab, row, value
|
||||
)
|
||||
)
|
||||
elif self._headers[column] == "type":
|
||||
key = next(k for k, v in self._long_types.items() if v == value)
|
||||
key = next(k for k, v in self._long_types.items()
|
||||
if v == value)
|
||||
self._undo.push(
|
||||
SetTypeCommand(
|
||||
self._lst, self._tab,row, BC_types[key]
|
||||
self._lst, self._tab, row, BC_types[key]
|
||||
)
|
||||
)
|
||||
elif self._headers[column] == "node":
|
||||
self._undo.push(
|
||||
SetNodeCommand(
|
||||
self._lst, self._tab,row, self._data.node(value)
|
||||
self._lst, self._tab, row, self._data.node(value)
|
||||
)
|
||||
)
|
||||
except Exception as e:
|
||||
@@ -185,7 +187,7 @@ class TableModel(PamhyrTableModel):
|
||||
|
||||
self._undo.push(
|
||||
AddCommand(
|
||||
self._lst, self._tab,row
|
||||
self._lst, self._tab, row
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ from PyQt5.QtWidgets import (
|
||||
from Model.BoundaryCondition.BoundaryCondition import BoundaryCondition
|
||||
from Model.BoundaryCondition.BoundaryConditionList import BoundaryConditionList
|
||||
|
||||
|
||||
class SetNameCommand(QUndoCommand):
|
||||
def __init__(self, bcs, tab, index, new_value):
|
||||
QUndoCommand.__init__(self)
|
||||
@@ -42,6 +43,7 @@ class SetNameCommand(QUndoCommand):
|
||||
def redo(self):
|
||||
self._bcs.get(self._tab, self._index).name = self._new
|
||||
|
||||
|
||||
class SetNodeCommand(QUndoCommand):
|
||||
def __init__(self, bcs, tab, index, node):
|
||||
QUndoCommand.__init__(self)
|
||||
@@ -58,6 +60,7 @@ class SetNodeCommand(QUndoCommand):
|
||||
def redo(self):
|
||||
self._bcs.get(self._tab, self._index).node = self._new
|
||||
|
||||
|
||||
class SetTypeCommand(QUndoCommand):
|
||||
def __init__(self, bcs, tab, index, _type):
|
||||
QUndoCommand.__init__(self)
|
||||
@@ -76,6 +79,7 @@ class SetTypeCommand(QUndoCommand):
|
||||
def redo(self):
|
||||
self._bcs.set(self._tab, self._index, self._new)
|
||||
|
||||
|
||||
class AddCommand(QUndoCommand):
|
||||
def __init__(self, bcs, tab, index):
|
||||
QUndoCommand.__init__(self)
|
||||
@@ -94,6 +98,7 @@ class AddCommand(QUndoCommand):
|
||||
else:
|
||||
self._bcs.insert(self._tab, self._index, self._new)
|
||||
|
||||
|
||||
class DelCommand(QUndoCommand):
|
||||
def __init__(self, bcs, tab, rows):
|
||||
QUndoCommand.__init__(self)
|
||||
@@ -114,6 +119,7 @@ class DelCommand(QUndoCommand):
|
||||
def redo(self):
|
||||
self._bcs.delete_i(self._tab, self._rows)
|
||||
|
||||
|
||||
class SortCommand(QUndoCommand):
|
||||
def __init__(self, bcs, tab, _reverse):
|
||||
QUndoCommand.__init__(self)
|
||||
|
||||
@@ -62,6 +62,7 @@ _translate = QCoreApplication.translate
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
|
||||
class BoundaryConditionWindow(PamhyrWindow):
|
||||
_pamhyr_ui = "BoundaryConditions"
|
||||
_pamhyr_name = "Boundary conditions"
|
||||
@@ -70,10 +71,10 @@ class BoundaryConditionWindow(PamhyrWindow):
|
||||
name = self._pamhyr_name + " - " + study.name
|
||||
|
||||
super(BoundaryConditionWindow, self).__init__(
|
||||
title = name,
|
||||
study = study,
|
||||
config = config,
|
||||
trad = BCTranslate(),
|
||||
title=name,
|
||||
study=study,
|
||||
config=config,
|
||||
trad=BCTranslate(),
|
||||
parent=parent
|
||||
)
|
||||
|
||||
@@ -90,33 +91,33 @@ class BoundaryConditionWindow(PamhyrWindow):
|
||||
|
||||
for t in ["liquid", "solid", "suspenssion"]:
|
||||
self._delegate_type = ComboBoxDelegate(
|
||||
trad = self._trad,
|
||||
data = self._study.river,
|
||||
mode = "type",
|
||||
tab = t,
|
||||
trad=self._trad,
|
||||
data=self._study.river,
|
||||
mode="type",
|
||||
tab=t,
|
||||
parent=self
|
||||
)
|
||||
self._delegate_node = ComboBoxDelegate(
|
||||
trad = self._trad,
|
||||
data = self._study.river,
|
||||
mode = "node",
|
||||
tab = t,
|
||||
trad=self._trad,
|
||||
data=self._study.river,
|
||||
mode="node",
|
||||
tab=t,
|
||||
parent=self
|
||||
)
|
||||
|
||||
table = self.find(QTableView, f"tableView_{t}")
|
||||
self._table[t] = TableModel(
|
||||
table_view = table,
|
||||
table_headers = self._trad.get_dict("table_headers"),
|
||||
editable_headers = ["name", "type", "node"],
|
||||
delegates = {
|
||||
table_view=table,
|
||||
table_headers=self._trad.get_dict("table_headers"),
|
||||
editable_headers=["name", "type", "node"],
|
||||
delegates={
|
||||
"type": self._delegate_type,
|
||||
"node": self._delegate_node,
|
||||
},
|
||||
trad = self._trad,
|
||||
data = self._study.river,
|
||||
undo = self._undo_stack,
|
||||
opt_data = t,
|
||||
trad=self._trad,
|
||||
data=self._study.river,
|
||||
undo=self._undo_stack,
|
||||
opt_data=t,
|
||||
)
|
||||
table.setModel(self._table[t])
|
||||
table.setSelectionBehavior(QAbstractItemView.SelectRows)
|
||||
@@ -126,7 +127,7 @@ class BoundaryConditionWindow(PamhyrWindow):
|
||||
def setup_graph(self):
|
||||
self.graph_widget = GraphWidget(
|
||||
self._study.river,
|
||||
min_size=None, size=(200,200),
|
||||
min_size=None, size=(200, 200),
|
||||
only_display=True,
|
||||
parent=self
|
||||
)
|
||||
@@ -215,7 +216,7 @@ class BoundaryConditionWindow(PamhyrWindow):
|
||||
for row in rows:
|
||||
win = self.sub_win_filter_first(
|
||||
"Edit boundary condition",
|
||||
contain = [f"({self._bcs.get(tab, row).id})"]
|
||||
contain=[f"({self._bcs.get(tab, row).id})"]
|
||||
)
|
||||
|
||||
if win is None:
|
||||
|
||||
@@ -37,6 +37,7 @@ BC_types = {
|
||||
"SL": Solid,
|
||||
}
|
||||
|
||||
|
||||
class BCTranslate(PamhyrTranslate):
|
||||
def __init__(self):
|
||||
super(BCTranslate, self).__init__()
|
||||
|
||||
@@ -22,6 +22,7 @@ from View.Tools.PamhyrTranslate import PamhyrTranslate
|
||||
|
||||
_translate = QCoreApplication.translate
|
||||
|
||||
|
||||
class CheckListTranslate(PamhyrTranslate):
|
||||
def __init__(self):
|
||||
super(CheckListTranslate, self).__init__()
|
||||
|
||||
@@ -44,13 +44,14 @@ from View.CheckList.Translate import CheckListTranslate
|
||||
|
||||
_translate = QCoreApplication.translate
|
||||
|
||||
|
||||
class CheckListWindow(PamhyrWindow):
|
||||
_pamhyr_ui = "CheckList"
|
||||
_pamhyr_name = "Check list"
|
||||
|
||||
signalStatus = pyqtSignal(str)
|
||||
|
||||
def __init__(self, autorun:bool=True,
|
||||
def __init__(self, autorun: bool = True,
|
||||
study=None, config=None,
|
||||
solver=None, parent=None):
|
||||
self._autorun = autorun
|
||||
@@ -59,12 +60,12 @@ class CheckListWindow(PamhyrWindow):
|
||||
name = self._pamhyr_name + " - " + study.name
|
||||
|
||||
super(CheckListWindow, self).__init__(
|
||||
title = name,
|
||||
study = study,
|
||||
config = config,
|
||||
trad = CheckListTranslate(),
|
||||
options = [],
|
||||
parent = parent
|
||||
title=name,
|
||||
study=study,
|
||||
config=config,
|
||||
trad=CheckListTranslate(),
|
||||
options=[],
|
||||
parent=parent
|
||||
)
|
||||
|
||||
self._checker_list = (
|
||||
@@ -81,9 +82,9 @@ class CheckListWindow(PamhyrWindow):
|
||||
def setup_table(self):
|
||||
table = self.find(QTableView, f"tableView")
|
||||
self._table = TableModel(
|
||||
table_view = table,
|
||||
table_headers = self._trad.get_dict("table_headers"),
|
||||
data = self._checker_list,
|
||||
table_view=table,
|
||||
table_headers=self._trad.get_dict("table_headers"),
|
||||
data=self._checker_list,
|
||||
)
|
||||
|
||||
def setup_progress_bar(self):
|
||||
@@ -120,7 +121,8 @@ class CheckListWindow(PamhyrWindow):
|
||||
|
||||
def _compute_status(self):
|
||||
ok = len(list(filter(lambda c: c.is_ok(), self._checker_list)))
|
||||
warning = len(list(filter(lambda c: c.is_warning(), self._checker_list)))
|
||||
warning = len(
|
||||
list(filter(lambda c: c.is_warning(), self._checker_list)))
|
||||
error = len(list(filter(lambda c: c.is_error(), self._checker_list)))
|
||||
|
||||
return ok, warning, error
|
||||
@@ -164,7 +166,7 @@ class CheckListWindow(PamhyrWindow):
|
||||
|
||||
self.update_statusbar()
|
||||
|
||||
def update(self, key:str):
|
||||
def update(self, key: str):
|
||||
if key == "start":
|
||||
self.start_compute()
|
||||
self.info_compute("Starting ...")
|
||||
@@ -187,4 +189,4 @@ class CheckListWindow(PamhyrWindow):
|
||||
|
||||
def accept(self):
|
||||
self._parent.solver_log(self._solver)
|
||||
#self.end()
|
||||
# self.end()
|
||||
@@ -22,6 +22,7 @@ from PyQt5.QtCore import (
|
||||
Qt, QObject, pyqtSlot, pyqtSignal
|
||||
)
|
||||
|
||||
|
||||
class Worker(QObject):
|
||||
signalStatus = pyqtSignal(str)
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ from PyQt5.QtWidgets import (
|
||||
QPushButton,
|
||||
)
|
||||
|
||||
|
||||
class ConfigureSolverWindow(PamhyrDialog):
|
||||
_pamhyr_ui = "ConfigureAddSolverDialog"
|
||||
_pamhyr_name = "Add/Edit Solver"
|
||||
@@ -35,9 +36,9 @@ class ConfigureSolverWindow(PamhyrDialog):
|
||||
name = "Add a new Solver"
|
||||
|
||||
super(ConfigureSolverWindow, self).__init__(
|
||||
title = name,
|
||||
config = config,
|
||||
options = [],
|
||||
title=name,
|
||||
config=config,
|
||||
options=[],
|
||||
parent=parent
|
||||
)
|
||||
|
||||
@@ -67,16 +68,19 @@ class ConfigureSolverWindow(PamhyrDialog):
|
||||
# File button
|
||||
buttons = {
|
||||
"pushButton_input": (lambda: self.file_dialog(
|
||||
select_file = True,
|
||||
callback = lambda f: self.set_line_edit_text("lineEdit_input", f[0])
|
||||
select_file=True,
|
||||
callback=lambda f: self.set_line_edit_text(
|
||||
"lineEdit_input", f[0])
|
||||
)),
|
||||
"pushButton_solver": (lambda: self.file_dialog(
|
||||
select_file = True,
|
||||
callback = lambda f: self.set_line_edit_text("lineEdit_solver", f[0])
|
||||
select_file=True,
|
||||
callback=lambda f: self.set_line_edit_text(
|
||||
"lineEdit_solver", f[0])
|
||||
)),
|
||||
"pushButton_output": (lambda: self.file_dialog(
|
||||
select_file = True,
|
||||
callback = lambda f: self.set_line_edit_text("lineEdit_output", f[0])
|
||||
select_file=True,
|
||||
callback=lambda f: self.set_line_edit_text(
|
||||
"lineEdit_output", f[0])
|
||||
)),
|
||||
}
|
||||
|
||||
@@ -92,9 +96,11 @@ class ConfigureSolverWindow(PamhyrDialog):
|
||||
else:
|
||||
# Build new solver from selected type
|
||||
stype = self.get_combobox_text("comboBox_solver")
|
||||
self.data = solver_type_list[stype](self.get_line_edit_text("lineEdit_name"))
|
||||
self.data = solver_type_list[stype](
|
||||
self.get_line_edit_text("lineEdit_name"))
|
||||
|
||||
self.data.description = self.get_line_edit_text("lineEdit_description")
|
||||
self.data.description = self.get_line_edit_text(
|
||||
"lineEdit_description")
|
||||
self.data.set_input(
|
||||
self.get_line_edit_text("lineEdit_input"),
|
||||
self.get_line_edit_text("lineEdit_input_cmd")
|
||||
|
||||
@@ -22,6 +22,7 @@ from View.Tools.PamhyrTranslate import PamhyrTranslate
|
||||
|
||||
_translate = QCoreApplication.translate
|
||||
|
||||
|
||||
class ConfigureTranslate(PamhyrTranslate):
|
||||
def __init__(self):
|
||||
super(ConfigureTranslate, self).__init__()
|
||||
|
||||
@@ -49,6 +49,7 @@ from Solver.Solvers import solver_long_name
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
|
||||
class SolverTableModel(PamhyrTableModel):
|
||||
def data(self, index, role):
|
||||
if role != Qt.ItemDataRole.DisplayRole:
|
||||
@@ -83,10 +84,10 @@ class ConfigureWindow(PamhyrDialog):
|
||||
config = Config()
|
||||
|
||||
super(ConfigureWindow, self).__init__(
|
||||
title = self._pamhyr_name,
|
||||
config = config,
|
||||
trad = ConfigureTranslate(),
|
||||
options = [],
|
||||
title=self._pamhyr_name,
|
||||
config=config,
|
||||
trad=ConfigureTranslate(),
|
||||
options=[],
|
||||
parent=parent
|
||||
)
|
||||
|
||||
@@ -101,38 +102,43 @@ class ConfigureWindow(PamhyrDialog):
|
||||
def setup_solver(self):
|
||||
table = self.find(QTableView, "tableView_solver")
|
||||
self.solver_table_model = SolverTableModel(
|
||||
table_view = table,
|
||||
table_headers = self._trad.get_dict("table_headers"),
|
||||
data = self._config.solvers
|
||||
table_view=table,
|
||||
table_headers=self._trad.get_dict("table_headers"),
|
||||
data=self._config.solvers
|
||||
)
|
||||
|
||||
def setup_stricklers(self):
|
||||
table = self.find(QTableView, f"tableView_stricklers")
|
||||
self._stricklers = deepcopy(self._config.stricklers)
|
||||
self._stricklers_table = TableModel(
|
||||
table_view = table,
|
||||
table_headers = self._trad_stricklers.get_dict("table_headers"),
|
||||
editable_headers = ["name", "comment", "minor", "medium"],
|
||||
data = self._stricklers,
|
||||
undo = self._undo_stack,
|
||||
table_view=table,
|
||||
table_headers=self._trad_stricklers.get_dict("table_headers"),
|
||||
editable_headers=["name", "comment", "minor", "medium"],
|
||||
data=self._stricklers,
|
||||
undo=self._undo_stack,
|
||||
)
|
||||
|
||||
def setup_data(self):
|
||||
# Meshing_Tool
|
||||
self.set_line_edit_text("lineEdit_meshing_tool", self._config.meshing_tool)
|
||||
self.set_line_edit_text("lineEdit_meshing_tool",
|
||||
self._config.meshing_tool)
|
||||
|
||||
# Const
|
||||
self.set_line_edit_text("lineEdit_segment", str(self._config.segment))
|
||||
self.set_line_edit_text("lineEdit_max_listing", str(self._config.max_listing))
|
||||
self.set_line_edit_text("lineEdit_max_listing",
|
||||
str(self._config.max_listing))
|
||||
|
||||
# Backup
|
||||
self.set_check_box("checkBox_backup", self._config.backup_enable)
|
||||
self.set_line_edit_text("lineEdit_backup_path", self._config.backup_path)
|
||||
self.set_time_edit("timeEdit_backup_frequence", self._config.backup_frequence)
|
||||
self.set_line_edit_text("lineEdit_backup_path",
|
||||
self._config.backup_path)
|
||||
self.set_time_edit("timeEdit_backup_frequence",
|
||||
self._config.backup_frequence)
|
||||
self.set_spin_box("spinBox_backup_max", self._config.backup_max)
|
||||
|
||||
# Editor
|
||||
self.set_line_edit_text("lineEdit_editor_cmd", str(self._config.editor))
|
||||
self.set_line_edit_text("lineEdit_editor_cmd",
|
||||
str(self._config.editor))
|
||||
|
||||
# Language
|
||||
languages = Config.languages()
|
||||
@@ -157,14 +163,14 @@ class ConfigureWindow(PamhyrDialog):
|
||||
"pushButton_stricklers_sort": self.sort_stricklers,
|
||||
# Others
|
||||
"pushButton_backup_path": lambda: self.file_dialog(
|
||||
select_file = False,
|
||||
callback = lambda f: self.set_line_edit_text(
|
||||
select_file=False,
|
||||
callback=lambda f: self.set_line_edit_text(
|
||||
"lineEdit_backup_path", f[0]
|
||||
)
|
||||
),
|
||||
"pushButton_meshing_tool" : lambda: self.file_dialog(
|
||||
select_file = True,
|
||||
callback = lambda f: self.set_line_edit_text(
|
||||
"pushButton_meshing_tool": lambda: self.file_dialog(
|
||||
select_file=True,
|
||||
callback=lambda f: self.set_line_edit_text(
|
||||
"lineEdit_meshing_tool", f[0]
|
||||
)
|
||||
),
|
||||
@@ -178,16 +184,20 @@ class ConfigureWindow(PamhyrDialog):
|
||||
self._config.solvers = self.solver_table_model._data.copy()
|
||||
|
||||
# Meshing_Tool
|
||||
self._config.meshing_tool = self.get_line_edit_text("lineEdit_meshing_tool")
|
||||
self._config.meshing_tool = self.get_line_edit_text(
|
||||
"lineEdit_meshing_tool")
|
||||
|
||||
# Const
|
||||
self._config.segment = self.get_line_edit_text("lineEdit_segment")
|
||||
self._config.max_listing = self.get_line_edit_text("lineEdit_max_listing")
|
||||
self._config.max_listing = self.get_line_edit_text(
|
||||
"lineEdit_max_listing")
|
||||
|
||||
# Backup
|
||||
self._config.backup_enable = self.get_check_box("checkBox_backup")
|
||||
self._config.backup_path = self.get_line_edit_text("lineEdit_backup_path")
|
||||
self._config.backup_frequence = self.get_time_edit("timeEdit_backup_frequence")
|
||||
self._config.backup_path = self.get_line_edit_text(
|
||||
"lineEdit_backup_path")
|
||||
self._config.backup_frequence = self.get_time_edit(
|
||||
"timeEdit_backup_frequence")
|
||||
self._config.backup_max = self.get_spin_box("spinBox_backup_max")
|
||||
|
||||
# Stricklers
|
||||
@@ -197,7 +207,8 @@ class ConfigureWindow(PamhyrDialog):
|
||||
self._config.editor = self.get_line_edit_text("lineEdit_editor_cmd")
|
||||
|
||||
# Language
|
||||
self._config.lang = Config.languages()[self.get_combobox_text("comboBox_language")]
|
||||
self._config.lang = Config.languages(
|
||||
)[self.get_combobox_text("comboBox_language")]
|
||||
|
||||
self.end()
|
||||
|
||||
@@ -219,7 +230,8 @@ class ConfigureWindow(PamhyrDialog):
|
||||
# Solvers
|
||||
|
||||
def edit_solver(self):
|
||||
indexes = self.find(QTableView, "tableView_solver").selectionModel().selectedRows()
|
||||
indexes = self.find(
|
||||
QTableView, "tableView_solver").selectionModel().selectedRows()
|
||||
for index in indexes:
|
||||
self.edit_solver = ConfigureSolverWindow(
|
||||
data=self.solver_table_model._data[index.row()],
|
||||
@@ -227,7 +239,8 @@ class ConfigureWindow(PamhyrDialog):
|
||||
parent=self
|
||||
)
|
||||
if self.edit_solver.exec_():
|
||||
self.solver_table_model.change_solver(self.edit_solver.data, index)
|
||||
self.solver_table_model.change_solver(
|
||||
self.edit_solver.data, index)
|
||||
|
||||
def add_solver(self):
|
||||
dialog_solver = ConfigureSolverWindow(parent=self)
|
||||
@@ -235,7 +248,8 @@ class ConfigureWindow(PamhyrDialog):
|
||||
self.solver_table_model.add_solver(dialog_solver.data)
|
||||
|
||||
def remove_solver(self):
|
||||
indices = self.find(QTableView, "tableView_solver").selectionModel().selectedRows()
|
||||
indices = self.find(
|
||||
QTableView, "tableView_solver").selectionModel().selectedRows()
|
||||
for index in sorted(indices):
|
||||
self.solver_table_model.removeRow(index)
|
||||
|
||||
|
||||
@@ -44,6 +44,7 @@ logger = logging.getLogger()
|
||||
|
||||
_translate = QCoreApplication.translate
|
||||
|
||||
|
||||
class ReplWindow(PamhyrWindow):
|
||||
_pamhyr_ui = "DebugRepl"
|
||||
_pamhyr_name = "Debug REPL"
|
||||
@@ -51,11 +52,11 @@ class ReplWindow(PamhyrWindow):
|
||||
def __init__(self, study=None, config=None,
|
||||
solver=None, parent=None):
|
||||
super(ReplWindow, self).__init__(
|
||||
title = self._pamhyr_name,
|
||||
study = study,
|
||||
config = config,
|
||||
options = [],
|
||||
parent = parent
|
||||
title=self._pamhyr_name,
|
||||
study=study,
|
||||
config=config,
|
||||
options=[],
|
||||
parent=parent
|
||||
)
|
||||
|
||||
self.__debug_exec_result__ = None
|
||||
@@ -75,12 +76,14 @@ class ReplWindow(PamhyrWindow):
|
||||
def history_up(self):
|
||||
if self._history_ind < len(self._history):
|
||||
self._history_ind += 1
|
||||
self.set_plaintext_edit_text("plainTextEdit", self._history[-self._history_ind])
|
||||
self.set_plaintext_edit_text(
|
||||
"plainTextEdit", self._history[-self._history_ind])
|
||||
|
||||
def history_down(self):
|
||||
if self._history_ind > 0:
|
||||
self._history_ind -= 1
|
||||
self.set_plaintext_edit_text("plainTextEdit", self._history[-self._history_ind])
|
||||
self.set_plaintext_edit_text(
|
||||
"plainTextEdit", self._history[-self._history_ind])
|
||||
else:
|
||||
self.set_plaintext_edit_text("plainTextEdit", "")
|
||||
|
||||
|
||||
+11
-10
@@ -16,7 +16,8 @@
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os, sys
|
||||
import os
|
||||
import sys
|
||||
import logging
|
||||
import subprocess
|
||||
|
||||
@@ -55,11 +56,11 @@ class DocWindow(PamhyrWindow):
|
||||
study=None, config=None,
|
||||
parent=None):
|
||||
super(DocWindow, self).__init__(
|
||||
title = self._pamhyr_name,
|
||||
study = study,
|
||||
config = config,
|
||||
options = [],
|
||||
parent = parent
|
||||
title=self._pamhyr_name,
|
||||
study=study,
|
||||
config=config,
|
||||
options=[],
|
||||
parent=parent
|
||||
)
|
||||
|
||||
self._path = self._path_file(filename)
|
||||
@@ -70,11 +71,11 @@ class DocWindow(PamhyrWindow):
|
||||
|
||||
def setup_connection(self):
|
||||
self.findChild(QAction, "action_back").triggered.connect(self.back)
|
||||
self.findChild(QAction, "action_forward").triggered.connect(self.forward)
|
||||
self.findChild(QAction, "action_forward").triggered.connect(
|
||||
self.forward)
|
||||
|
||||
self.findChild(QAction, "action_open").triggered.connect(self.open)
|
||||
|
||||
|
||||
def setup_web_engine(self):
|
||||
vl = self.find(QVBoxLayout, "verticalLayout")
|
||||
self._web_view = QWebEngineView()
|
||||
@@ -97,5 +98,5 @@ class DocWindow(PamhyrWindow):
|
||||
self._web_view.forward()
|
||||
|
||||
def open(self):
|
||||
url = QUrl(f"file://{self._path}")
|
||||
QDesktopServices.openUrl(url)
|
||||
url = QUrl(f"file://{self._path}")
|
||||
QDesktopServices.openUrl(url)
|
||||
@@ -18,12 +18,13 @@
|
||||
|
||||
from View.Tools.PamhyrWindow import PamhyrWindow
|
||||
|
||||
|
||||
class DummyWindow(PamhyrWindow):
|
||||
__ui = "Dummy"
|
||||
__name = "Pamhyr Dummy Window"
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super(DummyWindow, self).__init__(
|
||||
title = self.__name,
|
||||
parent = parent,
|
||||
title=self.__name,
|
||||
parent=parent,
|
||||
)
|
||||
@@ -25,10 +25,11 @@ from PyQt5.QtCore import (
|
||||
|
||||
_translate = QCoreApplication.translate
|
||||
|
||||
|
||||
class PlotStricklers(PamhyrPlot):
|
||||
def draw_frictions(self, frictions, color="r"):
|
||||
lst = frictions
|
||||
lst.sort(key = lambda s: s.begin_kp)
|
||||
lst.sort(key=lambda s: s.begin_kp)
|
||||
|
||||
coef = flatten(
|
||||
map(
|
||||
@@ -57,7 +58,6 @@ class PlotStricklers(PamhyrPlot):
|
||||
color=color, lw=1.
|
||||
)
|
||||
|
||||
|
||||
@timer
|
||||
def draw(self, highlight=None):
|
||||
self.canvas.axes.cla()
|
||||
@@ -77,7 +77,7 @@ class PlotStricklers(PamhyrPlot):
|
||||
|
||||
kp = self.data.reach.get_kp()
|
||||
self.canvas.axes.set_xlim(
|
||||
left = min(kp), right = max(kp)
|
||||
left=min(kp), right=max(kp)
|
||||
)
|
||||
|
||||
frictions = self.data.frictions
|
||||
|
||||
@@ -49,6 +49,7 @@ logger = logging.getLogger()
|
||||
|
||||
_translate = QCoreApplication.translate
|
||||
|
||||
|
||||
class ComboBoxDelegate(QItemDelegate):
|
||||
def __init__(self, data=None, study=None, mode="stricklers", parent=None):
|
||||
super(ComboBoxDelegate, self).__init__(parent)
|
||||
|
||||
@@ -26,6 +26,7 @@ from PyQt5.QtWidgets import (
|
||||
from Model.Friction.Friction import Friction
|
||||
from Model.Friction.FrictionList import FrictionList
|
||||
|
||||
|
||||
class SetNameCommand(QUndoCommand):
|
||||
def __init__(self, frictions, index, new_value):
|
||||
QUndoCommand.__init__(self)
|
||||
@@ -41,6 +42,7 @@ class SetNameCommand(QUndoCommand):
|
||||
def redo(self):
|
||||
self._frictions.get(self._index).name = self._new
|
||||
|
||||
|
||||
class SetBeginCommand(QUndoCommand):
|
||||
def __init__(self, frictions, index, new_value):
|
||||
QUndoCommand.__init__(self)
|
||||
@@ -56,6 +58,7 @@ class SetBeginCommand(QUndoCommand):
|
||||
def redo(self):
|
||||
self._frictions.get(self._index).begin_kp = float(self._new)
|
||||
|
||||
|
||||
class SetEndCommand(QUndoCommand):
|
||||
def __init__(self, frictions, index, new_value):
|
||||
QUndoCommand.__init__(self)
|
||||
@@ -87,6 +90,7 @@ class SetBeginStricklerCommand(QUndoCommand):
|
||||
def redo(self):
|
||||
self._frictions.get(self._index).begin_strickler = self._new
|
||||
|
||||
|
||||
class SetEndStricklerCommand(QUndoCommand):
|
||||
def __init__(self, frictions, index, new_value):
|
||||
QUndoCommand.__init__(self)
|
||||
@@ -118,6 +122,7 @@ class SetEdgeCommand(QUndoCommand):
|
||||
def redo(self):
|
||||
self._frictions.get(self._index).edge = self._new
|
||||
|
||||
|
||||
class AddCommand(QUndoCommand):
|
||||
def __init__(self, frictions, index, reach):
|
||||
QUndoCommand.__init__(self)
|
||||
@@ -137,6 +142,7 @@ class AddCommand(QUndoCommand):
|
||||
else:
|
||||
self._frictions.insert(self._index, self._new)
|
||||
|
||||
|
||||
class DelCommand(QUndoCommand):
|
||||
def __init__(self, frictions, rows):
|
||||
QUndoCommand.__init__(self)
|
||||
@@ -156,6 +162,7 @@ class DelCommand(QUndoCommand):
|
||||
def redo(self):
|
||||
self._frictions.delete_i(self._rows)
|
||||
|
||||
|
||||
class SortCommand(QUndoCommand):
|
||||
def __init__(self, frictions, _reverse):
|
||||
QUndoCommand.__init__(self)
|
||||
|
||||
@@ -56,6 +56,7 @@ from View.Stricklers.Window import StricklersWindow
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
|
||||
class FrictionsWindow(PamhyrWindow):
|
||||
_pamhyr_ui = "Frictions"
|
||||
_pamhyr_name = "Edit frictions"
|
||||
@@ -75,43 +76,42 @@ class FrictionsWindow(PamhyrWindow):
|
||||
)
|
||||
|
||||
super(FrictionsWindow, self).__init__(
|
||||
title = name,
|
||||
study = study,
|
||||
config = config,
|
||||
trad = FrictionsTranslate(),
|
||||
parent = parent
|
||||
title=name,
|
||||
study=study,
|
||||
config=config,
|
||||
trad=FrictionsTranslate(),
|
||||
parent=parent
|
||||
)
|
||||
|
||||
self.setup_table()
|
||||
self.setup_graph()
|
||||
self.setup_connections()
|
||||
|
||||
|
||||
def setup_table(self):
|
||||
self._table = {}
|
||||
|
||||
self._delegate_stricklers = ComboBoxDelegate(
|
||||
data = self._reach,
|
||||
study = self._study,
|
||||
mode = "stricklers",
|
||||
data=self._reach,
|
||||
study=self._study,
|
||||
mode="stricklers",
|
||||
parent=self
|
||||
)
|
||||
|
||||
table = self.find(QTableView, f"tableView")
|
||||
self._table = TableModel(
|
||||
table_view = table,
|
||||
table_headers = self._trad.get_dict("table_headers"),
|
||||
editable_headers = [
|
||||
table_view=table,
|
||||
table_headers=self._trad.get_dict("table_headers"),
|
||||
editable_headers=[
|
||||
"name", "begin_kp", "end_kp",
|
||||
"begin_strickler", "end_strickler"
|
||||
],
|
||||
delegates = {
|
||||
delegates={
|
||||
"begin_strickler": self._delegate_stricklers,
|
||||
"end_strickler": self._delegate_stricklers,
|
||||
},
|
||||
data = self._reach,
|
||||
undo = self._undo_stack,
|
||||
opt_data = self._study
|
||||
data=self._reach,
|
||||
undo=self._undo_stack,
|
||||
opt_data=self._study
|
||||
)
|
||||
table.setModel(self._table)
|
||||
table.setSelectionBehavior(QAbstractItemView.SelectRows)
|
||||
@@ -125,10 +125,10 @@ class FrictionsWindow(PamhyrWindow):
|
||||
self.plot_layout.addWidget(self.canvas)
|
||||
|
||||
self.plot = PlotKPZ(
|
||||
canvas = self.canvas,
|
||||
data = self._reach.reach,
|
||||
toolbar = None,
|
||||
display_current = False
|
||||
canvas=self.canvas,
|
||||
data=self._reach.reach,
|
||||
toolbar=None,
|
||||
display_current=False
|
||||
)
|
||||
self.plot.draw()
|
||||
|
||||
@@ -138,18 +138,18 @@ class FrictionsWindow(PamhyrWindow):
|
||||
self.plot_layout_2.addWidget(self.canvas_2)
|
||||
|
||||
self.plot_2 = PlotStricklers(
|
||||
canvas = self.canvas_2,
|
||||
data = self._reach,
|
||||
toolbar = None
|
||||
canvas=self.canvas_2,
|
||||
data=self._reach,
|
||||
toolbar=None
|
||||
)
|
||||
self.plot_2.draw()
|
||||
|
||||
|
||||
def setup_connections(self):
|
||||
self.find(QAction, "action_add").triggered.connect(self.add)
|
||||
self.find(QAction, "action_del").triggered.connect(self.delete)
|
||||
self.find(QAction, "action_sort").triggered.connect(self.sort)
|
||||
self.find(QAction, "action_edit_stricklers").triggered.connect(self.edit_stricklers)
|
||||
self.find(QAction, "action_edit_stricklers").triggered.connect(
|
||||
self.edit_stricklers)
|
||||
|
||||
table = self.find(QTableView, f"tableView")
|
||||
table.selectionModel()\
|
||||
@@ -185,17 +185,17 @@ class FrictionsWindow(PamhyrWindow):
|
||||
highlight = (sec.begin_kp, sec.end_kp)
|
||||
|
||||
self.plot = PlotKPZ(
|
||||
canvas = self.canvas,
|
||||
data = reach,
|
||||
toolbar = None,
|
||||
display_current = False
|
||||
canvas=self.canvas,
|
||||
data=reach,
|
||||
toolbar=None,
|
||||
display_current=False
|
||||
)
|
||||
self.plot.draw(highlight=highlight)
|
||||
|
||||
self.plot = PlotStricklers(
|
||||
canvas = self.canvas_2,
|
||||
data = data,
|
||||
toolbar = None
|
||||
canvas=self.canvas_2,
|
||||
data=data,
|
||||
toolbar=None
|
||||
)
|
||||
self.plot.draw(highlight=highlight)
|
||||
|
||||
@@ -239,14 +239,14 @@ class FrictionsWindow(PamhyrWindow):
|
||||
def edit_stricklers(self):
|
||||
strick = self.sub_win_filter_first(
|
||||
"Stricklers",
|
||||
contain = []
|
||||
contain=[]
|
||||
)
|
||||
|
||||
if strick is None:
|
||||
strick = StricklersWindow(
|
||||
study = self._study,
|
||||
config = self.parent.conf,
|
||||
parent = self
|
||||
study=self._study,
|
||||
config=self.parent.conf,
|
||||
parent=self
|
||||
)
|
||||
strick.show()
|
||||
else:
|
||||
|
||||
@@ -22,6 +22,7 @@ from View.Tools.PamhyrTranslate import PamhyrTranslate
|
||||
|
||||
_translate = QCoreApplication.translate
|
||||
|
||||
|
||||
class FrictionsTranslate(PamhyrTranslate):
|
||||
def __init__(self):
|
||||
super(FrictionsTranslate, self).__init__()
|
||||
|
||||
+24
-15
@@ -29,15 +29,16 @@ _translate = QCoreApplication.translate
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
|
||||
class PlotAC(PamhyrPlot):
|
||||
def __init__(self, canvas=None, trad=None, data=None, toolbar=None,
|
||||
plot_xy=None, parent=None):
|
||||
super(PlotAC, self).__init__(
|
||||
canvas = canvas,
|
||||
trad = trad,
|
||||
data = data,
|
||||
toolbar = toolbar,
|
||||
parent = parent
|
||||
canvas=canvas,
|
||||
trad=trad,
|
||||
data=data,
|
||||
toolbar=toolbar,
|
||||
parent=parent
|
||||
)
|
||||
|
||||
self.plot_xy = plot_xy
|
||||
@@ -79,9 +80,11 @@ class PlotAC(PamhyrPlot):
|
||||
)
|
||||
self.canvas.figure.tight_layout()
|
||||
|
||||
label_before_plot_selected = _translate("MainWindow_reach", "Previous cross-section")
|
||||
label_before_plot_selected = _translate(
|
||||
"MainWindow_reach", "Previous cross-section")
|
||||
label_plot_selected = _translate("MainWindow_reach", "Cross-section")
|
||||
label_after_plot_selected = _translate("MainWindow_reach", "Next cross-section")
|
||||
label_after_plot_selected = _translate(
|
||||
"MainWindow_reach", "Next cross-section")
|
||||
color_before_plot_selected = "k" # 'grey'
|
||||
color_plot_selected = 'b'
|
||||
color_after_plot_selected = 'm'
|
||||
@@ -133,10 +136,12 @@ class PlotAC(PamhyrPlot):
|
||||
|
||||
x_gl_complete.append(station[i])
|
||||
y_gl_complete.append(elevation[i])
|
||||
color_scat_complete_gl.append(self.color_complete_gl[lcomplete.index(txt)])
|
||||
color_scat_complete_gl.append(
|
||||
self.color_complete_gl[lcomplete.index(txt)])
|
||||
elif txt.strip() in self.incomplete_gl:
|
||||
annotate = self.canvas.axes.annotate(
|
||||
txt, (station[i], elevation[i]), horizontalalignment='left',
|
||||
txt, (station[i], elevation[i]
|
||||
), horizontalalignment='left',
|
||||
verticalalignment='top', annotation_clip=True, fontsize=11,
|
||||
color=self.color_incomplete_gl[
|
||||
lincomplete.index(txt)
|
||||
@@ -179,9 +184,12 @@ class PlotAC(PamhyrPlot):
|
||||
)
|
||||
self.canvas.figure.tight_layout()
|
||||
|
||||
label_before_plot_selected = _translate("MainWindow_reach", "Profil précédent")
|
||||
label_plot_selected = _translate("MainWindow_reach", "Profil sélectionné")
|
||||
label_after_plot_selected = _translate("MainWindow_reach", "Profil suivant")
|
||||
label_before_plot_selected = _translate(
|
||||
"MainWindow_reach", "Profil précédent")
|
||||
label_plot_selected = _translate(
|
||||
"MainWindow_reach", "Profil sélectionné")
|
||||
label_after_plot_selected = _translate(
|
||||
"MainWindow_reach", "Profil suivant")
|
||||
color_before_plot_selected = "k" # 'grey'
|
||||
color_plot_selected = 'b'
|
||||
color_after_plot_selected = 'm'
|
||||
@@ -233,10 +241,12 @@ class PlotAC(PamhyrPlot):
|
||||
|
||||
x_gl_complete.append(station[i])
|
||||
y_gl_complete.append(elevation[i])
|
||||
color_scat_complete_gl.append(self.color_complete_gl[lcomplete.index(txt)])
|
||||
color_scat_complete_gl.append(
|
||||
self.color_complete_gl[lcomplete.index(txt)])
|
||||
elif txt.strip() in self.incomplete_gl:
|
||||
annotate = self.canvas.axes.annotate(
|
||||
txt, (station[i], elevation[i]), horizontalalignment='left',
|
||||
txt, (station[i], elevation[i]
|
||||
), horizontalalignment='left',
|
||||
verticalalignment='top', annotation_clip=True, fontsize=11,
|
||||
color=self.color_incomplete_gl[
|
||||
lincomplete.index(txt)
|
||||
@@ -311,7 +321,6 @@ class PlotAC(PamhyrPlot):
|
||||
|
||||
self.canvas.figure.canvas.draw_idle()
|
||||
|
||||
|
||||
@timer
|
||||
def update(self, ind=None):
|
||||
if self._init == False:
|
||||
|
||||
@@ -29,15 +29,16 @@ _translate = QCoreApplication.translate
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
|
||||
class PlotKPZ(PamhyrPlot):
|
||||
def __init__(self, canvas=None, trad=None, data=None, toolbar=None,
|
||||
display_current=True, parent=None):
|
||||
super(PlotKPZ, self).__init__(
|
||||
canvas = canvas,
|
||||
trad = trad,
|
||||
data = data,
|
||||
toolbar = toolbar,
|
||||
parent = parent
|
||||
canvas=canvas,
|
||||
trad=trad,
|
||||
data=data,
|
||||
toolbar=toolbar,
|
||||
parent=parent
|
||||
)
|
||||
|
||||
self.display_current = display_current
|
||||
@@ -75,7 +76,7 @@ class PlotKPZ(PamhyrPlot):
|
||||
z_max = self.data.get_z_max()
|
||||
|
||||
self.canvas.axes.set_xlim(
|
||||
left = min(kp), right = max(kp)
|
||||
left=min(kp), right=max(kp)
|
||||
)
|
||||
|
||||
self.line_kp_zmin_zmax = self.canvas.axes.vlines(
|
||||
@@ -98,7 +99,7 @@ class PlotKPZ(PamhyrPlot):
|
||||
)
|
||||
)
|
||||
|
||||
indexes_filter = lambda data: list(
|
||||
def indexes_filter(data): return list(
|
||||
map(
|
||||
lambda x: x[1],
|
||||
filter(
|
||||
|
||||
@@ -25,15 +25,16 @@ from PyQt5.QtCore import (
|
||||
|
||||
_translate = QCoreApplication.translate
|
||||
|
||||
|
||||
class PlotXY(PamhyrPlot):
|
||||
def __init__(self, canvas=None, trad=None, data=None, toolbar=None,
|
||||
display_current=True, parent=None):
|
||||
super(PlotXY, self).__init__(
|
||||
canvas = canvas,
|
||||
trad = trad,
|
||||
data = data,
|
||||
toolbar = toolbar,
|
||||
parent = parent
|
||||
canvas=canvas,
|
||||
trad=trad,
|
||||
data=data,
|
||||
toolbar=toolbar,
|
||||
parent=parent
|
||||
)
|
||||
|
||||
self.display_current = display_current
|
||||
@@ -74,7 +75,7 @@ class PlotXY(PamhyrPlot):
|
||||
|
||||
kp = self.data.get_kp()
|
||||
self.canvas.axes.set_xlim(
|
||||
left = min(kp), right = max(kp)
|
||||
left=min(kp), right=max(kp)
|
||||
)
|
||||
|
||||
# Draw line for each profile
|
||||
@@ -85,8 +86,8 @@ class PlotXY(PamhyrPlot):
|
||||
markersize=3, marker='+'
|
||||
)
|
||||
for x, y, kp in zip(
|
||||
self.data.get_x(), self.data.get_y(),
|
||||
kp
|
||||
self.data.get_x(), self.data.get_y(),
|
||||
kp
|
||||
)
|
||||
]
|
||||
|
||||
|
||||
@@ -30,15 +30,16 @@ _translate = QCoreApplication.translate
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
|
||||
class Plot(PamhyrPlot):
|
||||
def __init__(self, canvas=None, trad=None, data=None, toolbar=None,
|
||||
table=None, parent=None):
|
||||
super(Plot, self).__init__(
|
||||
canvas = canvas,
|
||||
trad = trad,
|
||||
data = data,
|
||||
toolbar = toolbar,
|
||||
parent = parent
|
||||
canvas=canvas,
|
||||
trad=trad,
|
||||
data=data,
|
||||
toolbar=toolbar,
|
||||
parent=parent
|
||||
)
|
||||
|
||||
self._table = table
|
||||
@@ -63,7 +64,7 @@ class Plot(PamhyrPlot):
|
||||
y_carto = self.data.y()
|
||||
|
||||
if (len(x_carto) < 3 or len(y_carto) < 3 or
|
||||
len(x) < 3):
|
||||
len(x) < 3):
|
||||
# Noting to do in this case
|
||||
return
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ from View.Geometry.Translate import GeometryTranslate
|
||||
|
||||
_translate = QCoreApplication.translate
|
||||
|
||||
|
||||
class GeometryProfileTranslate(GeometryTranslate):
|
||||
def __init__(self):
|
||||
super(GeometryProfileTranslate, self).__init__()
|
||||
|
||||
@@ -34,6 +34,7 @@ class SetDataCommand(QUndoCommand):
|
||||
self._old = old_value
|
||||
self._new = self.type(new_value)
|
||||
|
||||
|
||||
class SetXCommand(SetDataCommand):
|
||||
def __init__(self, reach, index, old_value, new_value):
|
||||
self.type = float
|
||||
@@ -45,6 +46,7 @@ class SetXCommand(SetDataCommand):
|
||||
def redo(self):
|
||||
self._profile.point(self._index).x = self._new
|
||||
|
||||
|
||||
class SetYCommand(SetDataCommand):
|
||||
def __init__(self, reach, index, old_value, new_value):
|
||||
self.type = float
|
||||
@@ -56,6 +58,7 @@ class SetYCommand(SetDataCommand):
|
||||
def redo(self):
|
||||
self._profile.point(self._index).y = self._new
|
||||
|
||||
|
||||
class SetZCommand(SetDataCommand):
|
||||
def __init__(self, reach, index, old_value, new_value):
|
||||
self.type = float
|
||||
@@ -67,10 +70,12 @@ class SetZCommand(SetDataCommand):
|
||||
def redo(self):
|
||||
self._profile.point(self._index).z = self._new
|
||||
|
||||
|
||||
class SetNameCommand(SetDataCommand):
|
||||
def __init__(self, reach, index, old_value, new_value):
|
||||
self.type = str
|
||||
super(SetNameCommand, self).__init__(reach, index, old_value, new_value)
|
||||
super(SetNameCommand, self).__init__(
|
||||
reach, index, old_value, new_value)
|
||||
|
||||
def undo(self):
|
||||
self._profile.point(self._index).name = self._old
|
||||
@@ -96,6 +101,7 @@ class AddCommand(QUndoCommand):
|
||||
else:
|
||||
self._profile.insert_point(self._index, self._point)
|
||||
|
||||
|
||||
class DelCommand(QUndoCommand):
|
||||
def __init__(self, profile, rows):
|
||||
QUndoCommand.__init__(self)
|
||||
@@ -115,6 +121,7 @@ class DelCommand(QUndoCommand):
|
||||
def redo(self):
|
||||
self._profile.delete(self._rows)
|
||||
|
||||
|
||||
class SortCommand(QUndoCommand):
|
||||
def __init__(self, profile, column, _reverse):
|
||||
QUndoCommand.__init__(self)
|
||||
|
||||
@@ -58,11 +58,11 @@ class ProfileWindow(PamhyrWindow):
|
||||
|
||||
name = f"{self._pamhyr_name} - {self._profile.name} {self._profile.kp}"
|
||||
super(ProfileWindow, self).__init__(
|
||||
title = name,
|
||||
study = study,
|
||||
config = config,
|
||||
trad = GeometryProfileTranslate(),
|
||||
parent = parent
|
||||
title=name,
|
||||
study=study,
|
||||
config=config,
|
||||
trad=GeometryProfileTranslate(),
|
||||
parent=parent
|
||||
)
|
||||
|
||||
self.setup_table()
|
||||
@@ -74,11 +74,11 @@ class ProfileWindow(PamhyrWindow):
|
||||
|
||||
table = self.find(QTableView, "tableView")
|
||||
self._tablemodel = GeometryProfileTableModel(
|
||||
table_view = table,
|
||||
table_headers = table_headers,
|
||||
editable_headers = ["name", "x", "y", "z"],
|
||||
data = self._profile,
|
||||
undo = self._undo_stack
|
||||
table_view=table,
|
||||
table_headers=table_headers,
|
||||
editable_headers=["name", "x", "y", "z"],
|
||||
data=self._profile,
|
||||
undo=self._undo_stack
|
||||
)
|
||||
table.setModel(self._tablemodel)
|
||||
table.setSelectionBehavior(QAbstractItemView.SelectRows)
|
||||
@@ -92,17 +92,17 @@ class ProfileWindow(PamhyrWindow):
|
||||
self._canvas.setObjectName("canvas")
|
||||
self._toolbar = PamhyrPlotToolbar(
|
||||
self._canvas, self,
|
||||
items = ["home", "zoom", "save", "iso", "back/forward", "move"]
|
||||
items=["home", "zoom", "save", "iso", "back/forward", "move"]
|
||||
)
|
||||
self._plot_layout = self.find(QVBoxLayout, "verticalLayout")
|
||||
self._plot_layout.addWidget(self._toolbar)
|
||||
self._plot_layout.addWidget(self._canvas)
|
||||
|
||||
self._plot = Plot(
|
||||
canvas = self._canvas,
|
||||
data = self._profile,
|
||||
toolbar = self._toolbar,
|
||||
table = self.find(QTableView, "tableView")
|
||||
canvas=self._canvas,
|
||||
data=self._profile,
|
||||
toolbar=self._toolbar,
|
||||
table=self.find(QTableView, "tableView")
|
||||
)
|
||||
self._plot.draw()
|
||||
|
||||
@@ -134,15 +134,15 @@ class ProfileWindow(PamhyrWindow):
|
||||
|
||||
def index_selected_row(self):
|
||||
rows = self._tablemodel\
|
||||
.selectionModel()\
|
||||
.selectedRows()
|
||||
.selectionModel()\
|
||||
.selectedRows()
|
||||
if len(rows) == 0:
|
||||
return 0
|
||||
|
||||
return self._tablemodel\
|
||||
.selectionModel()\
|
||||
.selectedRows()[0]\
|
||||
.row()
|
||||
.selectionModel()\
|
||||
.selectedRows()[0]\
|
||||
.row()
|
||||
|
||||
def add(self):
|
||||
table = self.find(QTableView, "tableView")
|
||||
@@ -213,8 +213,8 @@ class ProfileWindow(PamhyrWindow):
|
||||
|
||||
def copy(self):
|
||||
rows = self._tablemodel\
|
||||
.selectionModel()\
|
||||
.selectedRows()
|
||||
.selectionModel()\
|
||||
.selectedRows()
|
||||
table = []
|
||||
table.append(["x", "y", "z", "name"])
|
||||
|
||||
|
||||
@@ -66,10 +66,10 @@ class GeometryReachTableModel(PamhyrTableModel):
|
||||
|
||||
if role == Qt.ForegroundRole and index.column() == 0:
|
||||
name = self._data.profile(index.row()).name\
|
||||
.strip()\
|
||||
.lower()
|
||||
.strip()\
|
||||
.lower()
|
||||
if (name == "upstream" or name == "up" or
|
||||
name == _translate("Geometry", "upstream")):
|
||||
name == _translate("Geometry", "upstream")):
|
||||
return QColor("Green")
|
||||
elif (name == "downstream" or name == "down" or
|
||||
name == _translate("Geometry", "downstream")):
|
||||
@@ -97,7 +97,7 @@ class GeometryReachTableModel(PamhyrTableModel):
|
||||
SetKPCommand(
|
||||
self._data, index.row(),
|
||||
self._data.profile(index.row()).kp,
|
||||
value
|
||||
value
|
||||
)
|
||||
)
|
||||
except Exception as e:
|
||||
@@ -151,7 +151,6 @@ class GeometryReachTableModel(PamhyrTableModel):
|
||||
self.layoutAboutToBeChanged.emit()
|
||||
self.layoutChanged.emit()
|
||||
|
||||
|
||||
def move_up(self, row, parent=QModelIndex()):
|
||||
if row <= 0:
|
||||
return
|
||||
@@ -199,7 +198,6 @@ class GeometryReachTableModel(PamhyrTableModel):
|
||||
self.layoutAboutToBeChanged.emit()
|
||||
self.layoutChanged.emit()
|
||||
|
||||
|
||||
def paste(self, row, header, data):
|
||||
if row > self._data.number_profiles:
|
||||
return
|
||||
|
||||
@@ -22,13 +22,16 @@ from View.Tools.PamhyrTranslate import PamhyrTranslate
|
||||
|
||||
_translate = QCoreApplication.translate
|
||||
|
||||
|
||||
class GeometryTranslate(PamhyrTranslate):
|
||||
def __init__(self):
|
||||
super(GeometryTranslate, self).__init__()
|
||||
|
||||
self._dict["open_file"] = _translate("Geometry", "Open a file")
|
||||
self._dict["file_st"] = _translate("Geometry", "File mage geometry (*.ST)")
|
||||
self._dict["file_m"] = _translate("Geometry", "File mage meshed geometry (*.M)")
|
||||
self._dict["file_st"] = _translate(
|
||||
"Geometry", "File mage geometry (*.ST)")
|
||||
self._dict["file_m"] = _translate(
|
||||
"Geometry", "File mage meshed geometry (*.M)")
|
||||
self._dict["file_all"] = _translate("Geometry", "All file (*)")
|
||||
|
||||
self._dict["reach"] = _translate("Geometry", "reach")
|
||||
|
||||
@@ -35,10 +35,12 @@ class SetDataCommand(QUndoCommand):
|
||||
self._old = old_value
|
||||
self._new = self.type(new_value)
|
||||
|
||||
|
||||
class SetNameCommand(SetDataCommand):
|
||||
def __init__(self, reach, index, old_value, new_value):
|
||||
self.type = str
|
||||
super(SetNameCommand, self).__init__(reach, index, old_value, new_value)
|
||||
super(SetNameCommand, self).__init__(
|
||||
reach, index, old_value, new_value)
|
||||
|
||||
def undo(self):
|
||||
self._reach.profile(self._index).name = self._old
|
||||
@@ -46,6 +48,7 @@ class SetNameCommand(SetDataCommand):
|
||||
def redo(self):
|
||||
self._reach.profile(self._index).name = self._new
|
||||
|
||||
|
||||
class SetKPCommand(SetDataCommand):
|
||||
def __init__(self, reach, index, old_value, new_value):
|
||||
self.type = float
|
||||
@@ -75,6 +78,7 @@ class AddCommand(QUndoCommand):
|
||||
else:
|
||||
self._reach.insert_profile(self._index, self._profile)
|
||||
|
||||
|
||||
class DelCommand(QUndoCommand):
|
||||
def __init__(self, reach, rows):
|
||||
QUndoCommand.__init__(self)
|
||||
@@ -94,6 +98,7 @@ class DelCommand(QUndoCommand):
|
||||
def redo(self):
|
||||
self._reach.delete(self._rows)
|
||||
|
||||
|
||||
class SortCommand(QUndoCommand):
|
||||
def __init__(self, reach, _reverse):
|
||||
QUndoCommand.__init__(self)
|
||||
|
||||
+40
-35
@@ -66,11 +66,11 @@ class GeometryWindow(PamhyrWindow):
|
||||
name = f"{self._pamhyr_name} - {self._reach.name}"
|
||||
|
||||
super(GeometryWindow, self).__init__(
|
||||
title = name,
|
||||
study = study,
|
||||
config = config,
|
||||
trad = GeometryTranslate(),
|
||||
parent = parent
|
||||
title=name,
|
||||
study=study,
|
||||
config=config,
|
||||
trad=GeometryTranslate(),
|
||||
parent=parent
|
||||
)
|
||||
|
||||
self._tablemodel = None
|
||||
@@ -87,11 +87,11 @@ class GeometryWindow(PamhyrWindow):
|
||||
|
||||
table = self.find(QTableView, "tableView")
|
||||
self._tablemodel = GeometryReachTableModel(
|
||||
table_view = table,
|
||||
table_headers = table_headers,
|
||||
editable_headers = ["name", "kp"],
|
||||
data = self._reach,
|
||||
undo = self._undo_stack
|
||||
table_view=table,
|
||||
table_headers=table_headers,
|
||||
editable_headers=["name", "kp"],
|
||||
data=self._reach,
|
||||
undo=self._undo_stack
|
||||
)
|
||||
table.setModel(self._tablemodel)
|
||||
table.setSelectionBehavior(QAbstractItemView.SelectRows)
|
||||
@@ -103,7 +103,7 @@ class GeometryWindow(PamhyrWindow):
|
||||
self._canvas_xy.setObjectName("canvas_xy")
|
||||
self._toolbar_xy = PamhyrPlotToolbar(
|
||||
self._canvas_xy, self,
|
||||
items = ["home", "zoom", "save", "iso", "back/forward", "move"]
|
||||
items=["home", "zoom", "save", "iso", "back/forward", "move"]
|
||||
)
|
||||
self._plot_layout_xy = self.find(QVBoxLayout, "verticalLayout")
|
||||
self._plot_layout_xy.addWidget(self._toolbar_xy)
|
||||
@@ -114,7 +114,7 @@ class GeometryWindow(PamhyrWindow):
|
||||
self._canvas_kpc.setObjectName("canvas_kpc")
|
||||
self._toolbar_kpc = PamhyrPlotToolbar(
|
||||
self._canvas_kpc, self,
|
||||
items = ["home", "zoom", "save", "iso", "back/forward", "move"]
|
||||
items=["home", "zoom", "save", "iso", "back/forward", "move"]
|
||||
)
|
||||
self._plot_layout_kpc = self.find(QVBoxLayout, "verticalLayout_2")
|
||||
self._plot_layout_kpc.addWidget(self._toolbar_kpc)
|
||||
@@ -125,7 +125,7 @@ class GeometryWindow(PamhyrWindow):
|
||||
self._canvas_ac.setObjectName("canvas_ac")
|
||||
self._toolbar_ac = PamhyrPlotToolbar(
|
||||
self._canvas_ac, self,
|
||||
items = ["home", "zoom", "save", "iso", "back/forward", "move"]
|
||||
items=["home", "zoom", "save", "iso", "back/forward", "move"]
|
||||
)
|
||||
self._plot_layout_ac = self.find(QVBoxLayout, "verticalLayout_3")
|
||||
self._plot_layout_ac.addWidget(self._toolbar_ac)
|
||||
@@ -169,19 +169,22 @@ class GeometryWindow(PamhyrWindow):
|
||||
self.find(QAction, action)\
|
||||
.triggered.connect(actions[action])
|
||||
|
||||
self.find(QSlider, "verticalSlider").valueChanged.connect(self.changed_slider_value)
|
||||
self.find(QPushButton, "pushButton_up").clicked.connect(self.decrement_value_slider)
|
||||
self.find(QPushButton, "pushButton_down").clicked.connect(self.increment_value_slider)
|
||||
self.find(QSlider, "verticalSlider").valueChanged.connect(
|
||||
self.changed_slider_value)
|
||||
self.find(QPushButton, "pushButton_up").clicked.connect(
|
||||
self.decrement_value_slider)
|
||||
self.find(QPushButton, "pushButton_down").clicked.connect(
|
||||
self.increment_value_slider)
|
||||
|
||||
# Profile selection when line change in table
|
||||
self.find(QTableView, "tableView").selectionModel()\
|
||||
.selectionChanged\
|
||||
.connect(self.select_current_profile)
|
||||
|
||||
|
||||
def import_from_file(self):
|
||||
options = QFileDialog.Options()
|
||||
settings = QSettings(QSettings.IniFormat, QSettings.UserScope, 'MyOrg', )
|
||||
settings = QSettings(QSettings.IniFormat,
|
||||
QSettings.UserScope, 'MyOrg', )
|
||||
options |= QFileDialog.DontUseNativeDialog
|
||||
|
||||
file_types = [
|
||||
@@ -222,13 +225,13 @@ class GeometryWindow(PamhyrWindow):
|
||||
|
||||
win = self.sub_win_filter_first(
|
||||
"Profile",
|
||||
contain = [self._reach.name, str(profile.kp)]
|
||||
contain=[self._reach.name, str(profile.kp)]
|
||||
)
|
||||
|
||||
if win is None:
|
||||
win = ProfileWindow(
|
||||
profile = profile,
|
||||
parent = self,
|
||||
profile=profile,
|
||||
parent=self,
|
||||
)
|
||||
self._profile_window.append(win)
|
||||
win.show()
|
||||
@@ -250,9 +253,9 @@ class GeometryWindow(PamhyrWindow):
|
||||
self.tableView.model().blockSignals(True)
|
||||
|
||||
self._plot_xy = PlotXY(
|
||||
canvas = self._canvas_xy,
|
||||
data = self._reach,
|
||||
toolbar = self._toolbar_xy
|
||||
canvas=self._canvas_xy,
|
||||
data=self._reach,
|
||||
toolbar=self._toolbar_xy
|
||||
)
|
||||
self._plot_xy.draw()
|
||||
|
||||
@@ -267,9 +270,9 @@ class GeometryWindow(PamhyrWindow):
|
||||
self.tableView.model().blockSignals(True)
|
||||
|
||||
self._plot_kpc = PlotKPZ(
|
||||
canvas = self._canvas_kpc,
|
||||
data = self._reach,
|
||||
toolbar = self._toolbar_kpc
|
||||
canvas=self._canvas_kpc,
|
||||
data=self._reach,
|
||||
toolbar=self._toolbar_kpc
|
||||
)
|
||||
self._plot_kpc.draw()
|
||||
|
||||
@@ -284,10 +287,10 @@ class GeometryWindow(PamhyrWindow):
|
||||
self.tableView.model().blockSignals(True)
|
||||
|
||||
self._plot_ac = PlotAC(
|
||||
canvas = self._canvas_ac,
|
||||
data = self._reach,
|
||||
toolbar = self._toolbar_ac,
|
||||
plot_xy = self._plot_xy
|
||||
canvas=self._canvas_ac,
|
||||
data=self._reach,
|
||||
toolbar=self._toolbar_ac,
|
||||
plot_xy=self._plot_xy
|
||||
)
|
||||
self._plot_ac.draw()
|
||||
|
||||
@@ -489,14 +492,16 @@ class GeometryWindow(PamhyrWindow):
|
||||
def export_to_file(self):
|
||||
options = QFileDialog.Options()
|
||||
DEFAULT_DIRECTORY = '/home/'
|
||||
settings = QSettings(QSettings.IniFormat, QSettings.UserScope, 'MyOrg', )
|
||||
current_dir = settings.value('current_directory', DEFAULT_DIRECTORY, type=str)
|
||||
settings = QSettings(QSettings.IniFormat,
|
||||
QSettings.UserScope, 'MyOrg', )
|
||||
current_dir = settings.value(
|
||||
'current_directory', DEFAULT_DIRECTORY, type=str)
|
||||
options |= QFileDialog.DontUseNativeDialog
|
||||
|
||||
filename, filters = QFileDialog.getSaveFileName(
|
||||
self,
|
||||
filter = self._trad["file_st"] + ";; " + self._trad["file_all"],
|
||||
options = options
|
||||
filter=self._trad["file_st"] + ";; " + self._trad["file_all"],
|
||||
options=options
|
||||
)
|
||||
|
||||
current_dir = os.path.split(filename)[0] or DEFAULT_DIRECTORY
|
||||
|
||||
@@ -31,15 +31,16 @@ from PyQt5.QtWidgets import (
|
||||
QDoubleSpinBox,
|
||||
)
|
||||
|
||||
|
||||
class DischargeDialog(PamhyrDialog):
|
||||
_pamhyr_ui = "InitialConditions_Dialog_Generator_Discharge"
|
||||
_pamhyr_name = "Discharge"
|
||||
|
||||
def __init__(self, title="Discharge", parent=None):
|
||||
super(DischargeDialog, self).__init__(
|
||||
title = self._pamhyr_name,
|
||||
options = [],
|
||||
parent = parent
|
||||
title=self._pamhyr_name,
|
||||
options=[],
|
||||
parent=parent
|
||||
)
|
||||
|
||||
self.value = None
|
||||
|
||||
@@ -31,15 +31,16 @@ from PyQt5.QtWidgets import (
|
||||
QDoubleSpinBox,
|
||||
)
|
||||
|
||||
|
||||
class HeightDialog(PamhyrDialog):
|
||||
_pamhyr_ui = "InitialConditions_Dialog_Generator_Height"
|
||||
_pamhyr_name = "Height"
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super(HeightDialog, self).__init__(
|
||||
title = self._pamhyr_name,
|
||||
options = [],
|
||||
parent = parent
|
||||
title=self._pamhyr_name,
|
||||
options=[],
|
||||
parent=parent
|
||||
)
|
||||
|
||||
self.value = None
|
||||
|
||||
@@ -25,6 +25,7 @@ from PyQt5.QtCore import (
|
||||
|
||||
_translate = QCoreApplication.translate
|
||||
|
||||
|
||||
class PlotDKP(PamhyrPlot):
|
||||
@timer
|
||||
def draw(self, highlight=None):
|
||||
@@ -47,7 +48,7 @@ class PlotDKP(PamhyrPlot):
|
||||
z_min = self.data.reach.reach.get_z_min()
|
||||
|
||||
self.canvas.axes.set_xlim(
|
||||
left = min(kp), right = max(kp)
|
||||
left=min(kp), right=max(kp)
|
||||
)
|
||||
|
||||
self.line_kp_zmin = self.canvas.axes.plot(
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
from tools import timer
|
||||
from View.Tools.PamhyrPlot import PamhyrPlot
|
||||
|
||||
|
||||
class PlotDischarge(PamhyrPlot):
|
||||
@timer
|
||||
def draw(self, highlight=None):
|
||||
@@ -40,7 +41,7 @@ class PlotDischarge(PamhyrPlot):
|
||||
kp = self.data.reach.reach.get_kp()
|
||||
|
||||
self.canvas.axes.set_xlim(
|
||||
left = min(kp), right = max(kp)
|
||||
left=min(kp), right=max(kp)
|
||||
)
|
||||
|
||||
if len(self.data) != 0:
|
||||
|
||||
@@ -45,6 +45,7 @@ logger = logging.getLogger()
|
||||
|
||||
_translate = QCoreApplication.translate
|
||||
|
||||
|
||||
class ComboBoxDelegate(QItemDelegate):
|
||||
def __init__(self, reach=None, parent=None):
|
||||
super(ComboBoxDelegate, self).__init__(parent)
|
||||
|
||||
@@ -26,6 +26,7 @@ from PyQt5.QtWidgets import (
|
||||
from Model.InitialConditions.InitialConditions import InitialConditions
|
||||
from Model.InitialConditions.InitialConditionsDict import InitialConditionsDict
|
||||
|
||||
|
||||
class SetCommand(QUndoCommand):
|
||||
def __init__(self, ics, row, column, new_value):
|
||||
QUndoCommand.__init__(self)
|
||||
@@ -47,6 +48,7 @@ class SetCommand(QUndoCommand):
|
||||
def redo(self):
|
||||
self._ics.get(self._row)[self._column] = self._new
|
||||
|
||||
|
||||
class AddCommand(QUndoCommand):
|
||||
def __init__(self, ics, index):
|
||||
QUndoCommand.__init__(self)
|
||||
@@ -64,6 +66,7 @@ class AddCommand(QUndoCommand):
|
||||
else:
|
||||
self._ics.insert(self._index, self._new)
|
||||
|
||||
|
||||
class DelCommand(QUndoCommand):
|
||||
def __init__(self, ics, rows):
|
||||
QUndoCommand.__init__(self)
|
||||
@@ -83,6 +86,7 @@ class DelCommand(QUndoCommand):
|
||||
def redo(self):
|
||||
self._ics.delete_i(self._rows)
|
||||
|
||||
|
||||
class SortCommand(QUndoCommand):
|
||||
def __init__(self, ics, _reverse):
|
||||
QUndoCommand.__init__(self)
|
||||
@@ -168,6 +172,7 @@ class DuplicateCommand(QUndoCommand):
|
||||
for ic in self._ics:
|
||||
self._ics.insert(self._rows[0], ic)
|
||||
|
||||
|
||||
class GenerateCommand(QUndoCommand):
|
||||
def __init__(self, ics, generator, param):
|
||||
QUndoCommand.__init__(self)
|
||||
|
||||
@@ -60,6 +60,7 @@ _translate = QCoreApplication.translate
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
|
||||
class InitialConditionsWindow(PamhyrWindow):
|
||||
_pamhyr_ui = "InitialConditions"
|
||||
_pamhyr_name = "Initial condition"
|
||||
@@ -77,11 +78,11 @@ class InitialConditionsWindow(PamhyrWindow):
|
||||
)
|
||||
|
||||
super(InitialConditionsWindow, self).__init__(
|
||||
title = name,
|
||||
study = study,
|
||||
config = config,
|
||||
trad = ICTranslate(),
|
||||
parent = parent
|
||||
title=name,
|
||||
study=study,
|
||||
config=config,
|
||||
trad=ICTranslate(),
|
||||
parent=parent
|
||||
)
|
||||
|
||||
self._ics = study.river.initial_conditions.get(self._reach)
|
||||
@@ -95,19 +96,19 @@ class InitialConditionsWindow(PamhyrWindow):
|
||||
def setup_table(self):
|
||||
table = self.find(QTableView, f"tableView")
|
||||
self._delegate_kp = ComboBoxDelegate(
|
||||
reach = self._reach,
|
||||
parent = self
|
||||
reach=self._reach,
|
||||
parent=self
|
||||
)
|
||||
|
||||
self._table = InitialConditionTableModel(
|
||||
reach = self._reach,
|
||||
table_view = table,
|
||||
table_headers = self._trad.get_dict("table_headers"),
|
||||
editable_headers = ["kp", "discharge", "elevation", "height"],
|
||||
delegates = {"kp": self._delegate_kp},
|
||||
data = self._study,
|
||||
undo = self._undo_stack,
|
||||
trad = self._trad
|
||||
reach=self._reach,
|
||||
table_view=table,
|
||||
table_headers=self._trad.get_dict("table_headers"),
|
||||
editable_headers=["kp", "discharge", "elevation", "height"],
|
||||
delegates={"kp": self._delegate_kp},
|
||||
data=self._study,
|
||||
undo=self._undo_stack,
|
||||
trad=self._trad
|
||||
)
|
||||
|
||||
table.setModel(self._table)
|
||||
@@ -126,11 +127,11 @@ class InitialConditionsWindow(PamhyrWindow):
|
||||
self.plot_layout_1.addWidget(self.canvas_1)
|
||||
|
||||
self.plot_1 = PlotDKP(
|
||||
canvas = self.canvas_1,
|
||||
data = self._ics,
|
||||
trad = self._trad,
|
||||
toolbar = self.toolbar_1,
|
||||
parent = self
|
||||
canvas=self.canvas_1,
|
||||
data=self._ics,
|
||||
trad=self._trad,
|
||||
toolbar=self.toolbar_1,
|
||||
parent=self
|
||||
)
|
||||
self.plot_1.draw()
|
||||
|
||||
@@ -144,11 +145,11 @@ class InitialConditionsWindow(PamhyrWindow):
|
||||
self.plot_layout_2.addWidget(self.canvas_2)
|
||||
|
||||
self.plot_2 = PlotDischarge(
|
||||
canvas = self.canvas_2,
|
||||
data = self._ics,
|
||||
trad = self._trad,
|
||||
toolbar = self.toolbar_2,
|
||||
parent = self
|
||||
canvas=self.canvas_2,
|
||||
data=self._ics,
|
||||
trad=self._trad,
|
||||
toolbar=self.toolbar_2,
|
||||
parent=self
|
||||
)
|
||||
self.plot_2.draw()
|
||||
|
||||
|
||||
@@ -22,12 +22,15 @@ from View.Tools.PamhyrTranslate import PamhyrTranslate
|
||||
|
||||
_translate = QCoreApplication.translate
|
||||
|
||||
|
||||
class ICTranslate(PamhyrTranslate):
|
||||
def __init__(self):
|
||||
super(ICTranslate, self).__init__()
|
||||
|
||||
self._dict["elevation"] = _translate("InitialCondition", "Elevation (m)")
|
||||
self._dict["discharge"] = _translate("InitialCondition", "Discharge (m³/s)")
|
||||
self._dict["elevation"] = _translate(
|
||||
"InitialCondition", "Elevation (m)")
|
||||
self._dict["discharge"] = _translate(
|
||||
"InitialCondition", "Discharge (m³/s)")
|
||||
self._dict["kp"] = _translate("InitialCondition", "KP (m)")
|
||||
|
||||
self._sub_dict["table_headers"] = {
|
||||
|
||||
@@ -29,16 +29,17 @@ from View.LateralContribution.Edit.translate import *
|
||||
|
||||
_translate = QCoreApplication.translate
|
||||
|
||||
|
||||
class Plot(PamhyrPlot):
|
||||
def __init__(self, mode = "time", data=None,
|
||||
def __init__(self, mode="time", data=None,
|
||||
canvas=None, trad=None, toolbar=None,
|
||||
parent=None):
|
||||
super(Plot, self).__init__(
|
||||
canvas = canvas,
|
||||
trad = trad,
|
||||
data = data,
|
||||
toolbar = toolbar,
|
||||
parent = parent
|
||||
canvas=canvas,
|
||||
trad=trad,
|
||||
data=data,
|
||||
toolbar=toolbar,
|
||||
parent=parent
|
||||
)
|
||||
|
||||
self._table_headers = self._trad.get_dict("table_headers")
|
||||
@@ -68,8 +69,8 @@ class Plot(PamhyrPlot):
|
||||
map(
|
||||
lambda v: str(
|
||||
datetime.fromtimestamp(v[0]) - t0
|
||||
).split(",")[0]\
|
||||
.replace("days", _translate("LateralContribution", "days"))\
|
||||
).split(",")[0]
|
||||
.replace("days", _translate("LateralContribution", "days"))
|
||||
.replace("day", _translate("LateralContribution", "day")),
|
||||
fx
|
||||
)
|
||||
@@ -84,7 +85,6 @@ class Plot(PamhyrPlot):
|
||||
|
||||
self.canvas.axes.set_xticks(ticks=xx, labels=xt, rotation=45)
|
||||
|
||||
|
||||
@timer
|
||||
def draw(self):
|
||||
self.canvas.axes.cla()
|
||||
@@ -118,7 +118,7 @@ class Plot(PamhyrPlot):
|
||||
self.canvas.axes.autoscale_view(True, True, True)
|
||||
self.canvas.figure.tight_layout()
|
||||
self.canvas.figure.canvas.draw_idle()
|
||||
#self.toolbar.update()
|
||||
# self.toolbar.update()
|
||||
|
||||
self._init = True
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ from PyQt5.QtWidgets import (
|
||||
|
||||
from Model.LateralContribution.LateralContribution import LateralContribution
|
||||
|
||||
|
||||
class SetDataCommand(QUndoCommand):
|
||||
def __init__(self, data, index, column, new_value):
|
||||
QUndoCommand.__init__(self)
|
||||
@@ -42,6 +43,7 @@ class SetDataCommand(QUndoCommand):
|
||||
def redo(self):
|
||||
self._data._set_i_c_v(self._index, self._column, self._new)
|
||||
|
||||
|
||||
class AddCommand(QUndoCommand):
|
||||
def __init__(self, data, index):
|
||||
QUndoCommand.__init__(self)
|
||||
@@ -59,6 +61,7 @@ class AddCommand(QUndoCommand):
|
||||
else:
|
||||
self._data.insert(self._index, self._new)
|
||||
|
||||
|
||||
class DelCommand(QUndoCommand):
|
||||
def __init__(self, data, rows):
|
||||
QUndoCommand.__init__(self)
|
||||
@@ -78,6 +81,7 @@ class DelCommand(QUndoCommand):
|
||||
def redo(self):
|
||||
self._data.delete_i(self._rows)
|
||||
|
||||
|
||||
class SortCommand(QUndoCommand):
|
||||
def __init__(self, data, _reverse):
|
||||
QUndoCommand.__init__(self)
|
||||
|
||||
@@ -45,6 +45,7 @@ from View.LateralContribution.Edit.Plot import Plot
|
||||
|
||||
_translate = QCoreApplication.translate
|
||||
|
||||
|
||||
class EditLateralContributionWindow(PamhyrWindow):
|
||||
_pamhyr_ui = "EditLateralContribution"
|
||||
_pamhyr_name = "Edit lateral contribution"
|
||||
@@ -67,11 +68,11 @@ class EditLateralContributionWindow(PamhyrWindow):
|
||||
)
|
||||
|
||||
super(EditLateralContributionWindow, self).__init__(
|
||||
title = name,
|
||||
study = study,
|
||||
config = config,
|
||||
trad = trad,
|
||||
parent = parent
|
||||
title=name,
|
||||
study=study,
|
||||
config=config,
|
||||
trad=trad,
|
||||
parent=parent
|
||||
)
|
||||
|
||||
self.setup_table()
|
||||
@@ -80,9 +81,9 @@ class EditLateralContributionWindow(PamhyrWindow):
|
||||
|
||||
def setup_table(self):
|
||||
self._delegate_time = PamhyrExTimeDelegate(
|
||||
data = self._data,
|
||||
mode = self._study.time_system,
|
||||
parent = self
|
||||
data=self._data,
|
||||
mode=self._study.time_system,
|
||||
parent=self
|
||||
)
|
||||
|
||||
headers = {}
|
||||
@@ -92,16 +93,16 @@ class EditLateralContributionWindow(PamhyrWindow):
|
||||
|
||||
table = self.find(QTableView, "tableView")
|
||||
self._table = TableModel(
|
||||
table_view = table,
|
||||
table_headers = headers,
|
||||
editable_headers = self._data.header,
|
||||
delegates = {
|
||||
table_view=table,
|
||||
table_headers=headers,
|
||||
editable_headers=self._data.header,
|
||||
delegates={
|
||||
"time": self._delegate_time,
|
||||
},
|
||||
data = self._data,
|
||||
undo = self._undo_stack,
|
||||
trad = self._trad,
|
||||
opt_data = self._study.time_system
|
||||
data=self._data,
|
||||
undo=self._undo_stack,
|
||||
trad=self._trad,
|
||||
opt_data=self._study.time_system
|
||||
)
|
||||
|
||||
table.setModel(self._table)
|
||||
@@ -119,12 +120,12 @@ class EditLateralContributionWindow(PamhyrWindow):
|
||||
self.verticalLayout.addWidget(self.canvas)
|
||||
|
||||
self.plot = Plot(
|
||||
canvas = self.canvas,
|
||||
data = self._data,
|
||||
mode = self._study.time_system,
|
||||
toolbar = self.toolbar,
|
||||
trad = self._trad,
|
||||
parent = self
|
||||
canvas=self.canvas,
|
||||
data=self._data,
|
||||
mode=self._study.time_system,
|
||||
toolbar=self.toolbar,
|
||||
trad=self._trad,
|
||||
parent=self
|
||||
)
|
||||
self.plot.draw()
|
||||
|
||||
@@ -156,7 +157,6 @@ class EditLateralContributionWindow(PamhyrWindow):
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def add(self):
|
||||
rows = self.index_selected_rows()
|
||||
if len(self._data) == 0 or len(rows) == 0:
|
||||
|
||||
@@ -23,6 +23,7 @@ from View.LateralContribution.translate import LCTranslate
|
||||
|
||||
_translate = QCoreApplication.translate
|
||||
|
||||
|
||||
class LCETranslate(LCTranslate):
|
||||
def __init__(self):
|
||||
super(LCETranslate, self).__init__()
|
||||
|
||||
@@ -52,8 +52,9 @@ logger = logging.getLogger()
|
||||
|
||||
_translate = QCoreApplication.translate
|
||||
|
||||
|
||||
class ComboBoxDelegate(QItemDelegate):
|
||||
def __init__(self, data=None, mode="type", tab="", trad = None, parent=None):
|
||||
def __init__(self, data=None, mode="type", tab="", trad=None, parent=None):
|
||||
super(ComboBoxDelegate, self).__init__(parent)
|
||||
|
||||
self._data = data
|
||||
@@ -154,7 +155,8 @@ class TableModel(PamhyrTableModel):
|
||||
)
|
||||
)
|
||||
elif self._headers[column] == "type":
|
||||
key = next(k for k, v in self._long_types.items() if v == value)
|
||||
key = next(k for k, v in self._long_types.items()
|
||||
if v == value)
|
||||
self._undo.push(
|
||||
SetTypeCommand(
|
||||
self._lst, self._tab, row, LC_types[key]
|
||||
|
||||
@@ -26,6 +26,7 @@ from PyQt5.QtWidgets import (
|
||||
from Model.LateralContribution.LateralContribution import LateralContribution
|
||||
from Model.LateralContribution.LateralContributionList import LateralContributionList
|
||||
|
||||
|
||||
class SetNameCommand(QUndoCommand):
|
||||
def __init__(self, lcs, tab, index, new_value):
|
||||
QUndoCommand.__init__(self)
|
||||
@@ -42,6 +43,7 @@ class SetNameCommand(QUndoCommand):
|
||||
def redo(self):
|
||||
self._lcs.get(self._tab, self._index).name = self._new
|
||||
|
||||
|
||||
class SetBeginCommand(QUndoCommand):
|
||||
def __init__(self, lcs, tab, index, new_value):
|
||||
QUndoCommand.__init__(self)
|
||||
@@ -58,6 +60,7 @@ class SetBeginCommand(QUndoCommand):
|
||||
def redo(self):
|
||||
self._lcs.get(self._tab, self._index).begin_kp = float(self._new)
|
||||
|
||||
|
||||
class SetEndCommand(QUndoCommand):
|
||||
def __init__(self, lcs, tab, index, new_value):
|
||||
QUndoCommand.__init__(self)
|
||||
@@ -91,6 +94,7 @@ class SetEdgeCommand(QUndoCommand):
|
||||
def redo(self):
|
||||
self._lcs.get(self._tab, self._index).edge = self._new
|
||||
|
||||
|
||||
class SetTypeCommand(QUndoCommand):
|
||||
def __init__(self, lcs, tab, index, _type):
|
||||
QUndoCommand.__init__(self)
|
||||
@@ -109,6 +113,7 @@ class SetTypeCommand(QUndoCommand):
|
||||
def redo(self):
|
||||
self._lcs.set(self._tab, self._index, self._new)
|
||||
|
||||
|
||||
class AddCommand(QUndoCommand):
|
||||
def __init__(self, lcs, tab, index):
|
||||
QUndoCommand.__init__(self)
|
||||
@@ -127,6 +132,7 @@ class AddCommand(QUndoCommand):
|
||||
else:
|
||||
self._lcs.insert(self._tab, self._index, self._new)
|
||||
|
||||
|
||||
class DelCommand(QUndoCommand):
|
||||
def __init__(self, lcs, tab, rows):
|
||||
QUndoCommand.__init__(self)
|
||||
@@ -147,6 +153,7 @@ class DelCommand(QUndoCommand):
|
||||
def redo(self):
|
||||
self._lcs.delete_i(self._tab, self._rows)
|
||||
|
||||
|
||||
class SortCommand(QUndoCommand):
|
||||
def __init__(self, lcs, tab, _reverse):
|
||||
QUndoCommand.__init__(self)
|
||||
|
||||
@@ -62,6 +62,7 @@ from View.LateralContribution.Edit.Window import EditLateralContributionWindow
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
|
||||
class LateralContributionWindow(PamhyrWindow):
|
||||
_pamhyr_ui = "LateralContributions"
|
||||
_pamhyr_name = "Lateral contribution"
|
||||
@@ -70,10 +71,10 @@ class LateralContributionWindow(PamhyrWindow):
|
||||
name = self._pamhyr_name + " - " + study.name
|
||||
|
||||
super(LateralContributionWindow, self).__init__(
|
||||
title = name,
|
||||
study = study,
|
||||
trad = LCTranslate(),
|
||||
config = config,
|
||||
title=name,
|
||||
study=study,
|
||||
trad=LCTranslate(),
|
||||
config=config,
|
||||
parent=parent
|
||||
)
|
||||
|
||||
@@ -88,33 +89,33 @@ class LateralContributionWindow(PamhyrWindow):
|
||||
|
||||
for t in ["liquid", "solid", "suspenssion"]:
|
||||
self._delegate_type = ComboBoxDelegate(
|
||||
data = self._study.river,
|
||||
mode = "type",
|
||||
tab = t,
|
||||
trad = self._trad,
|
||||
data=self._study.river,
|
||||
mode="type",
|
||||
tab=t,
|
||||
trad=self._trad,
|
||||
parent=self
|
||||
)
|
||||
self._delegate_edge = ComboBoxDelegate(
|
||||
data = self._study.river,
|
||||
mode = "edge",
|
||||
tab = t,
|
||||
trad = self._trad,
|
||||
data=self._study.river,
|
||||
mode="edge",
|
||||
tab=t,
|
||||
trad=self._trad,
|
||||
parent=self
|
||||
)
|
||||
|
||||
table = self.find(QTableView, f"tableView_{t}")
|
||||
self._table[t] = TableModel(
|
||||
table_view = table,
|
||||
table_headers = self._trad.get_dict("table_headers"),
|
||||
editable_headers = True,
|
||||
delegates = {
|
||||
table_view=table,
|
||||
table_headers=self._trad.get_dict("table_headers"),
|
||||
editable_headers=True,
|
||||
delegates={
|
||||
"type": self._delegate_type,
|
||||
"edge": self._delegate_edge,
|
||||
},
|
||||
data = self._study.river,
|
||||
undo = self._undo_stack,
|
||||
trad = self._trad,
|
||||
opt_data = t,
|
||||
data=self._study.river,
|
||||
undo=self._undo_stack,
|
||||
trad=self._trad,
|
||||
opt_data=t,
|
||||
)
|
||||
table.setModel(self._table[t])
|
||||
table.setSelectionBehavior(QAbstractItemView.SelectRows)
|
||||
@@ -128,9 +129,9 @@ class LateralContributionWindow(PamhyrWindow):
|
||||
self.plot_layout.addWidget(self.canvas)
|
||||
|
||||
self.plot = PlotXY(
|
||||
canvas = self.canvas,
|
||||
data = None,
|
||||
toolbar = None,
|
||||
canvas=self.canvas,
|
||||
data=None,
|
||||
toolbar=None,
|
||||
)
|
||||
|
||||
def setup_connections(self):
|
||||
@@ -193,9 +194,9 @@ class LateralContributionWindow(PamhyrWindow):
|
||||
highlight = (lc.begin_kp, lc.end_kp)
|
||||
|
||||
self.plot = PlotXY(
|
||||
canvas = self.canvas,
|
||||
data = data,
|
||||
toolbar = None,
|
||||
canvas=self.canvas,
|
||||
data=data,
|
||||
toolbar=None,
|
||||
)
|
||||
self.plot.draw(highlight=highlight)
|
||||
|
||||
@@ -259,7 +260,7 @@ class LateralContributionWindow(PamhyrWindow):
|
||||
for row in rows:
|
||||
win = self.sub_win_filter_first(
|
||||
"Edit lateral contribution",
|
||||
contain = [f"({self._lcs.get(tab, row).id})"]
|
||||
contain=[f"({self._lcs.get(tab, row).id})"]
|
||||
)
|
||||
|
||||
if win is None:
|
||||
|
||||
@@ -33,6 +33,7 @@ LC_types = {
|
||||
"EV": Evaporation,
|
||||
}
|
||||
|
||||
|
||||
class LCTranslate(PamhyrTranslate):
|
||||
def __init__(self):
|
||||
super(LCTranslate, self).__init__()
|
||||
|
||||
+67
-63
@@ -16,7 +16,8 @@
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os, sys
|
||||
import os
|
||||
import sys
|
||||
import logging
|
||||
import subprocess
|
||||
from queue import Queue
|
||||
@@ -107,6 +108,7 @@ action = (
|
||||
no_model_action + model_action + define_model_action
|
||||
)
|
||||
|
||||
|
||||
class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
||||
def __init__(self, conf=None):
|
||||
super(ApplicationWindow, self).__init__()
|
||||
@@ -132,10 +134,10 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
||||
self.setup_sc()
|
||||
self.setup_connection()
|
||||
self.default_style()
|
||||
self.setup_debug_mode(init = True)
|
||||
self.setup_debug_mode(init=True)
|
||||
|
||||
self.trans = QTranslator(self)
|
||||
#self.ui.retranslateUi()
|
||||
# self.ui.retranslateUi()
|
||||
|
||||
if self.conf.last_study != "" and not self.conf.close_correctly:
|
||||
self.dialog_reopen_study()
|
||||
@@ -153,7 +155,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
||||
title += "Pamhyr2"
|
||||
self.setWindowTitle(title)
|
||||
|
||||
def enable_actions(self, action:str, enable:bool):
|
||||
def enable_actions(self, action: str, enable: bool):
|
||||
"""Enable of disable an action componant
|
||||
|
||||
Args:
|
||||
@@ -196,7 +198,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
||||
"action_menu_edit_reach_sediment_layers": self.open_reach_sediment_layers,
|
||||
"action_menu_close": self.close_model,
|
||||
"action_menu_results_last": self.open_last_results,
|
||||
## Help
|
||||
# Help
|
||||
"action_menu_pamhyr_users_pdf": lambda: self.open_doc_user(ext="pdf"),
|
||||
"action_menu_pamhyr_developers_pdf": lambda: self.open_doc_dev(ext="pdf"),
|
||||
"action_menu_pamhyr_users_html": lambda: self.open_doc_user(ext="html"),
|
||||
@@ -209,7 +211,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
||||
"action_toolBar_save": self.save_study,
|
||||
"action_toolBar_close": self.close_model,
|
||||
"action_toolBar_run_solver": self.run_solver,
|
||||
## Current actions
|
||||
# Current actions
|
||||
"action_toolBar_network": self.open_network,
|
||||
"action_toolBar_geometry": self.open_geometry,
|
||||
"action_toolBar_mesh": lambda: self.open_dummy("Mesh"),
|
||||
@@ -255,7 +257,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
||||
def closeEvent(self, event):
|
||||
if not self._close_question:
|
||||
if self._study is not None and not self._study.is_saved:
|
||||
if self.dialog_close(cancel = False):
|
||||
if self.dialog_close(cancel=False):
|
||||
# PAMHYR is close correctly (no crash)
|
||||
self.conf.set_close_correctly()
|
||||
super(ApplicationWindow, self).closeEvent(event)
|
||||
@@ -272,7 +274,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
||||
# Maximise window
|
||||
self.showMaximized()
|
||||
|
||||
def set_debug_lvl(self, debug = True):
|
||||
def set_debug_lvl(self, debug=True):
|
||||
if debug:
|
||||
logger.setLevel(logging.DEBUG)
|
||||
logger.info("Set logging level to DEBUG")
|
||||
@@ -280,7 +282,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
||||
logger.setLevel(logging.INFO)
|
||||
logger.info("Set logging level to INFO")
|
||||
|
||||
def setup_debug_mode(self, init = False):
|
||||
def setup_debug_mode(self, init=False):
|
||||
menu = self.findChild(QMenu, "menu_help")
|
||||
self.set_title()
|
||||
|
||||
@@ -290,22 +292,23 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
||||
self.debug_action.triggered.connect(self.open_debug)
|
||||
|
||||
self.debug_sqlite_action = QAction("Debug SQLite", self)
|
||||
self.debug_sqlite_action.setStatusTip("Open SQLite debuging tool (sqlitebrowser)")
|
||||
self.debug_sqlite_action.setStatusTip(
|
||||
"Open SQLite debuging tool (sqlitebrowser)")
|
||||
self.debug_sqlite_action.triggered.connect(self.open_sqlite)
|
||||
|
||||
if self.conf.debug:
|
||||
menu.addAction(self.debug_action)
|
||||
menu.addAction(self.debug_sqlite_action)
|
||||
self.set_debug_lvl(debug = True)
|
||||
self.set_debug_lvl(debug=True)
|
||||
else:
|
||||
if self.conf.debug:
|
||||
menu.addAction(self.debug_action)
|
||||
menu.addAction(self.debug_sqlite_action)
|
||||
self.set_debug_lvl(debug = True)
|
||||
self.set_debug_lvl(debug=True)
|
||||
else:
|
||||
menu.removeAction(self.debug_action)
|
||||
menu.removeAction(self.debug_sqlite_action)
|
||||
self.set_debug_lvl(debug = False)
|
||||
self.set_debug_lvl(debug=False)
|
||||
|
||||
#########
|
||||
# MODEL #
|
||||
@@ -430,7 +433,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
||||
|
||||
dlg.setWindowTitle("Last open study")
|
||||
dlg.setText("Do you want to open again the last open study?")
|
||||
opt = QMessageBox.Cancel | QMessageBox.Ok #| QMessageBox.Open
|
||||
opt = QMessageBox.Cancel | QMessageBox.Ok # | QMessageBox.Open
|
||||
|
||||
dlg.setStandardButtons(opt)
|
||||
dlg.setIcon(QMessageBox.Question)
|
||||
@@ -446,7 +449,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
||||
elif res == QMessageBox.Cancel:
|
||||
return False
|
||||
|
||||
def dialog_close(self, cancel = True):
|
||||
def dialog_close(self, cancel=True):
|
||||
dlg = QMessageBox(self)
|
||||
|
||||
dlg.setWindowTitle("Close PAMHYR without saving study")
|
||||
@@ -504,7 +507,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
||||
dialog = QFileDialog(self)
|
||||
dialog.setFileMode(QFileDialog.FileMode.ExistingFile)
|
||||
dialog.setDefaultSuffix(".pamhyr")
|
||||
#dialog.setFilter(dialog.filter() | QtCore.QDir.Hidden)
|
||||
# dialog.setFilter(dialog.filter() | QtCore.QDir.Hidden)
|
||||
dialog.setNameFilters(['PamHyr (*.pamhyr)'])
|
||||
dialog.setDirectory(os.path.dirname(self.conf.last_study))
|
||||
|
||||
@@ -554,11 +557,12 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
||||
if (self._study is not None and self._study.river.has_current_reach()):
|
||||
geometry = self.sub_win_filter_first(
|
||||
"Geometry",
|
||||
contain = [self._study.river.current_reach().name]
|
||||
contain=[self._study.river.current_reach().name]
|
||||
)
|
||||
|
||||
if geometry is None:
|
||||
geometry = GeometryWindow(study=self._study, config=self.conf, parent=self)
|
||||
geometry = GeometryWindow(
|
||||
study=self._study, config=self.conf, parent=self)
|
||||
geometry.show()
|
||||
else:
|
||||
geometry.activateWindow()
|
||||
@@ -568,11 +572,11 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
||||
def open_boundary_cond(self):
|
||||
bound = self.sub_win_filter_first(
|
||||
"Boundary conditions",
|
||||
contain = []
|
||||
contain=[]
|
||||
)
|
||||
|
||||
if bound is None:
|
||||
bound = BoundaryConditionWindow(study = self._study, parent = self)
|
||||
bound = BoundaryConditionWindow(study=self._study, parent=self)
|
||||
bound.show()
|
||||
else:
|
||||
bound.activateWindow()
|
||||
@@ -580,11 +584,11 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
||||
def open_lateral_contrib(self):
|
||||
lateral = self.sub_win_filter_first(
|
||||
"Lateral contribution",
|
||||
contain = []
|
||||
contain=[]
|
||||
)
|
||||
|
||||
if lateral is None:
|
||||
lateral = LateralContributionWindow(study = self._study, parent = self)
|
||||
lateral = LateralContributionWindow(study=self._study, parent=self)
|
||||
lateral.show()
|
||||
else:
|
||||
lateral.activateWindow()
|
||||
@@ -592,14 +596,14 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
||||
def open_stricklers(self):
|
||||
strick = self.sub_win_filter_first(
|
||||
"Stricklers",
|
||||
contain = []
|
||||
contain=[]
|
||||
)
|
||||
|
||||
if strick is None:
|
||||
strick = StricklersWindow(
|
||||
study = self._study,
|
||||
config = self.conf,
|
||||
parent = self
|
||||
study=self._study,
|
||||
config=self.conf,
|
||||
parent=self
|
||||
)
|
||||
strick.show()
|
||||
else:
|
||||
@@ -607,17 +611,17 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
||||
|
||||
def open_frictions(self):
|
||||
if (self._study is not None and
|
||||
self._study.river.has_current_reach()):
|
||||
self._study.river.has_current_reach()):
|
||||
|
||||
frictions = self.sub_win_filter_first(
|
||||
"Frictions",
|
||||
contain = [self._study.river.current_reach().name]
|
||||
contain=[self._study.river.current_reach().name]
|
||||
)
|
||||
|
||||
if frictions is None:
|
||||
frictions = FrictionsWindow(
|
||||
study = self._study,
|
||||
parent = self
|
||||
study=self._study,
|
||||
parent=self
|
||||
)
|
||||
frictions.show()
|
||||
else:
|
||||
@@ -629,14 +633,14 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
||||
if self._study.river.has_current_reach():
|
||||
initial = self.sub_win_filter_first(
|
||||
"Initial condition",
|
||||
contain = [self._study.river.current_reach().name]
|
||||
contain=[self._study.river.current_reach().name]
|
||||
)
|
||||
|
||||
if initial is None:
|
||||
initial = InitialConditionsWindow(
|
||||
study = self._study,
|
||||
config = self.conf,
|
||||
parent = self
|
||||
study=self._study,
|
||||
config=self.conf,
|
||||
parent=self
|
||||
)
|
||||
initial.show()
|
||||
else:
|
||||
@@ -647,13 +651,13 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
||||
def open_solver_parameters(self):
|
||||
params = self.sub_win_filter_first(
|
||||
"Solver parameters",
|
||||
contain = []
|
||||
contain=[]
|
||||
)
|
||||
|
||||
if params is None:
|
||||
params = SolverParametersWindow(
|
||||
study = self._study,
|
||||
parent = self
|
||||
study=self._study,
|
||||
parent=self
|
||||
)
|
||||
params.show()
|
||||
else:
|
||||
@@ -661,15 +665,15 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
||||
|
||||
def open_sediment_layers(self):
|
||||
sl = SedimentLayersWindow(
|
||||
study = self._study,
|
||||
parent = self
|
||||
study=self._study,
|
||||
parent=self
|
||||
)
|
||||
sl.show()
|
||||
|
||||
def open_reach_sediment_layers(self):
|
||||
sl = ReachSedimentLayersWindow(
|
||||
study = self._study,
|
||||
parent = self
|
||||
study=self._study,
|
||||
parent=self
|
||||
)
|
||||
sl.show()
|
||||
|
||||
@@ -678,30 +682,30 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
||||
return
|
||||
|
||||
run = SelectSolverWindow(
|
||||
study = self._study,
|
||||
config = self.conf,
|
||||
parent = self
|
||||
study=self._study,
|
||||
config=self.conf,
|
||||
parent=self
|
||||
)
|
||||
if run.exec():
|
||||
solver = run.solver
|
||||
check = CheckListWindow(
|
||||
study = self._study,
|
||||
config = self.conf,
|
||||
solver = solver,
|
||||
parent = self
|
||||
study=self._study,
|
||||
config=self.conf,
|
||||
solver=solver,
|
||||
parent=self
|
||||
)
|
||||
check.show()
|
||||
|
||||
def solver_log(self, solver):
|
||||
sol = SolverLogWindow(
|
||||
study = self._study,
|
||||
config = self.conf,
|
||||
solver = solver,
|
||||
parent = self
|
||||
study=self._study,
|
||||
config=self.conf,
|
||||
solver=solver,
|
||||
parent=self
|
||||
)
|
||||
sol.show()
|
||||
|
||||
def open_solver_results(self, solver, results = None):
|
||||
def open_solver_results(self, solver, results=None):
|
||||
# If no specific results, get last results
|
||||
if results is None:
|
||||
results = self._last_results
|
||||
@@ -713,15 +717,15 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
||||
# Windows already opened
|
||||
res = self.sub_win_filter_first(
|
||||
"Results",
|
||||
contain = [solver.name, results.date]
|
||||
contain=[solver.name, results.date]
|
||||
)
|
||||
|
||||
if res is None:
|
||||
res = ResultsWindow(
|
||||
study = self._study,
|
||||
solver = solver,
|
||||
results = results,
|
||||
parent = self
|
||||
study=self._study,
|
||||
solver=solver,
|
||||
results=results,
|
||||
parent=self
|
||||
)
|
||||
res.show()
|
||||
else:
|
||||
@@ -763,8 +767,8 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
||||
QDesktopServices.openUrl(url)
|
||||
else:
|
||||
doc = DocWindow(
|
||||
filename = filename,
|
||||
parent = self
|
||||
filename=filename,
|
||||
parent=self
|
||||
)
|
||||
doc.show()
|
||||
|
||||
@@ -783,9 +787,9 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
||||
|
||||
def open_debug(self):
|
||||
repl = ReplWindow(
|
||||
study = self._study,
|
||||
config = self.conf,
|
||||
parent = self
|
||||
study=self._study,
|
||||
config=self.conf,
|
||||
parent=self
|
||||
)
|
||||
repl.show()
|
||||
|
||||
|
||||
@@ -115,6 +115,7 @@ class NodeItem(QGraphicsItem):
|
||||
if not self.graph._only_display:
|
||||
super(NodeItem, self).mouseMoveEvent(event)
|
||||
|
||||
|
||||
class EdgeItem(QGraphicsItem):
|
||||
Type = QGraphicsItem.UserType + 2
|
||||
|
||||
@@ -216,6 +217,7 @@ class EdgeItem(QGraphicsItem):
|
||||
painter.drawPolygon(poly)
|
||||
painter.fillPath(path, brush)
|
||||
|
||||
|
||||
class NodeText(QGraphicsTextItem):
|
||||
def __init__(self, node_item):
|
||||
super(NodeText, self).__init__()
|
||||
@@ -228,9 +230,9 @@ class NodeText(QGraphicsTextItem):
|
||||
|
||||
def set_custom_pos(self, pos):
|
||||
x = pos.x()
|
||||
y = pos.y() - 42 # Dont panic! The answer is 42
|
||||
y = pos.y() - 42 # Dont panic! The answer is 42
|
||||
|
||||
self.setPos(QPointF(x,y))
|
||||
self.setPos(QPointF(x, y))
|
||||
|
||||
@timer
|
||||
def paint(self, painter, option, widget):
|
||||
@@ -248,6 +250,7 @@ class NodeText(QGraphicsTextItem):
|
||||
# Update the node text
|
||||
self.setPlainText(self.item.node.name)
|
||||
|
||||
|
||||
class NewEdgeLine(QGraphicsItem):
|
||||
def __init__(self, src, dest):
|
||||
super(NewEdgeLine, self).__init__()
|
||||
@@ -278,13 +281,14 @@ class NewEdgeLine(QGraphicsItem):
|
||||
Qt.RoundJoin))
|
||||
painter.drawLine(line)
|
||||
|
||||
|
||||
class GraphWidget(QGraphicsView):
|
||||
changeEdge = pyqtSignal(object)
|
||||
changeNode = pyqtSignal(object)
|
||||
|
||||
def __init__(self, graph, parent=None,
|
||||
min_size=(400, 400), max_size=None,
|
||||
size=None, only_display=False, undo = None):
|
||||
size=None, only_display=False, undo=None):
|
||||
super(GraphWidget, self).__init__(parent=parent)
|
||||
|
||||
self.timerId = 0
|
||||
@@ -522,7 +526,6 @@ class GraphWidget(QGraphicsView):
|
||||
self.changeNode.emit(self.sender())
|
||||
self.changeEdge.emit(self.sender())
|
||||
|
||||
|
||||
def update_edges(self, node):
|
||||
"""Update display of all edges linked with the node
|
||||
|
||||
@@ -791,7 +794,7 @@ class GraphWidget(QGraphicsView):
|
||||
if self._state == "move":
|
||||
# Move on scene
|
||||
if (not self.selected_item() and
|
||||
event.buttons() & Qt.LeftButton):
|
||||
event.buttons() & Qt.LeftButton):
|
||||
old_p = self.mapToScene(self.m_origin_x, self.m_origin_y)
|
||||
new_p = self.mapToScene(event.pos())
|
||||
translation = new_p - old_p
|
||||
@@ -805,7 +808,6 @@ class GraphWidget(QGraphicsView):
|
||||
self.update()
|
||||
super(GraphWidget, self).mouseMoveEvent(event)
|
||||
|
||||
|
||||
# Contextual menu
|
||||
|
||||
def _menu_default(self, event, pos, items, menu):
|
||||
@@ -835,7 +837,8 @@ class GraphWidget(QGraphicsView):
|
||||
enable = menu.addAction(_translate("Network", "Enable the reach"))
|
||||
is_enable = False
|
||||
|
||||
reverse = menu.addAction(_translate("Network", "Reverse the reach orientation"))
|
||||
reverse = menu.addAction(_translate(
|
||||
"Network", "Reverse the reach orientation"))
|
||||
|
||||
action = menu.exec_(self.mapToGlobal(event.pos()))
|
||||
|
||||
|
||||
@@ -69,6 +69,7 @@ class ComboBoxDelegate(QItemDelegate):
|
||||
def currentItemChanged(self):
|
||||
self.commitData.emit(self.sender())
|
||||
|
||||
|
||||
class NodeTableModel(PamhyrTableModel):
|
||||
def _setup_lst(self):
|
||||
self._lst = self._data.nodes()
|
||||
@@ -120,6 +121,7 @@ class NodeTableModel(PamhyrTableModel):
|
||||
self._lst = self._data.nodes()
|
||||
self.layoutChanged.emit()
|
||||
|
||||
|
||||
class EdgeTableModel(PamhyrTableModel):
|
||||
def _setup_lst(self):
|
||||
self._lst = self._data.edges()
|
||||
@@ -140,7 +142,7 @@ class EdgeTableModel(PamhyrTableModel):
|
||||
|
||||
try:
|
||||
if (self._headers[index.column()] == "node1" or
|
||||
self._headers[index.column()] == "node2"):
|
||||
self._headers[index.column()] == "node2"):
|
||||
node = self.graph.node(value)
|
||||
self._undo.push(
|
||||
SetNodeCommand(
|
||||
|
||||
@@ -31,6 +31,7 @@ from Model.Network.Node import Node
|
||||
from Model.Network.Edge import Edge
|
||||
from Model.Network.Graph import Graph
|
||||
|
||||
|
||||
class AddNodeCommand(QUndoCommand):
|
||||
def __init__(self, graph, node):
|
||||
QUndoCommand.__init__(self)
|
||||
@@ -44,6 +45,7 @@ class AddNodeCommand(QUndoCommand):
|
||||
def redo(self):
|
||||
self._graph.insert_node(self._node)
|
||||
|
||||
|
||||
class SetNodePosCommand(QUndoCommand):
|
||||
def __init__(self, node, new, old):
|
||||
QUndoCommand.__init__(self)
|
||||
@@ -58,6 +60,7 @@ class SetNodePosCommand(QUndoCommand):
|
||||
def redo(self):
|
||||
self._node.node.setPos(self._new[0], self._new[1])
|
||||
|
||||
|
||||
class DelNodeCommand(QUndoCommand):
|
||||
def __init__(self, graph, node):
|
||||
QUndoCommand.__init__(self)
|
||||
@@ -86,6 +89,7 @@ class DelNodeCommand(QUndoCommand):
|
||||
|
||||
self._graph.remove_node(self._node.name)
|
||||
|
||||
|
||||
class AddEdgeCommand(QUndoCommand):
|
||||
def __init__(self, graph, edge):
|
||||
QUndoCommand.__init__(self)
|
||||
@@ -99,6 +103,7 @@ class AddEdgeCommand(QUndoCommand):
|
||||
def redo(self):
|
||||
self._graph.insert_edge(self._edge)
|
||||
|
||||
|
||||
class DelEdgeCommand(QUndoCommand):
|
||||
def __init__(self, graph, edge):
|
||||
QUndoCommand.__init__(self)
|
||||
@@ -144,6 +149,7 @@ class SetNodeCommand(QUndoCommand):
|
||||
def redo(self):
|
||||
self._el[self._column] = self._new
|
||||
|
||||
|
||||
class EnableEdgeCommand(QUndoCommand):
|
||||
def __init__(self, edge, enable):
|
||||
QUndoCommand.__init__(self)
|
||||
@@ -153,10 +159,11 @@ class EnableEdgeCommand(QUndoCommand):
|
||||
self._enable = enable
|
||||
|
||||
def undo(self):
|
||||
self._edge.enable(enable = self._old)
|
||||
self._edge.enable(enable=self._old)
|
||||
|
||||
def redo(self):
|
||||
self._edge.enable(enable = self._enable)
|
||||
self._edge.enable(enable=self._enable)
|
||||
|
||||
|
||||
class ReverseEdgeCommand(QUndoCommand):
|
||||
def __init__(self, edge):
|
||||
|
||||
+22
-21
@@ -57,11 +57,11 @@ class NetworkWindow(PamhyrWindow):
|
||||
|
||||
def __init__(self, study=None, config=None, parent=None):
|
||||
super(NetworkWindow, self).__init__(
|
||||
title = self._pamhyr_name + " - " + study.name,
|
||||
study = study,
|
||||
config = config,
|
||||
trad = NetworkTranslate(),
|
||||
options = ['undo'],
|
||||
title=self._pamhyr_name + " - " + study.name,
|
||||
study=study,
|
||||
config=config,
|
||||
trad=NetworkTranslate(),
|
||||
options=['undo'],
|
||||
parent=parent,
|
||||
)
|
||||
|
||||
@@ -77,11 +77,11 @@ class NetworkWindow(PamhyrWindow):
|
||||
# Nodes table
|
||||
table = self.find(QTableView, "tableView_nodes")
|
||||
self._nodes_model = NodeTableModel(
|
||||
table_view = table,
|
||||
table_headers = self._table_headers_node,
|
||||
editable_headers = ["name"],
|
||||
data = self._graph,
|
||||
undo = self._undo_stack,
|
||||
table_view=table,
|
||||
table_headers=self._table_headers_node,
|
||||
editable_headers=["name"],
|
||||
data=self._graph,
|
||||
undo=self._undo_stack,
|
||||
)
|
||||
table.setModel(self._nodes_model)
|
||||
|
||||
@@ -91,30 +91,30 @@ class NetworkWindow(PamhyrWindow):
|
||||
# Edges table
|
||||
table = self.find(QTableView, "tableView_reachs")
|
||||
self.delegate_combobox = ComboBoxDelegate(
|
||||
graph = self._graph,
|
||||
parent = self,
|
||||
graph=self._graph,
|
||||
parent=self,
|
||||
)
|
||||
|
||||
self._reachs_model = EdgeTableModel(
|
||||
table_view = table,
|
||||
table_headers = self._table_headers_edge,
|
||||
editable_headers = ["name", "node1", "node2"],
|
||||
delegates = {
|
||||
table_view=table,
|
||||
table_headers=self._table_headers_edge,
|
||||
editable_headers=["name", "node1", "node2"],
|
||||
delegates={
|
||||
"node1": self.delegate_combobox,
|
||||
"node2": self.delegate_combobox,
|
||||
},
|
||||
data = self._graph,
|
||||
undo = self._undo_stack,
|
||||
data=self._graph,
|
||||
undo=self._undo_stack,
|
||||
)
|
||||
table.setModel(self._reachs_model)
|
||||
table.setSelectionBehavior(QAbstractItemView.SelectRows)
|
||||
table.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch)
|
||||
#table.resizeColumnsToContents()
|
||||
# table.resizeColumnsToContents()
|
||||
|
||||
def setup_graph(self):
|
||||
self._graph_widget = GraphWidget(
|
||||
self._graph, parent=self,
|
||||
undo = self._undo_stack
|
||||
undo=self._undo_stack
|
||||
)
|
||||
self._graph_layout = self.find(QHBoxLayout, "horizontalLayout_graph")
|
||||
self._graph_layout.addWidget(self._graph_widget)
|
||||
@@ -122,7 +122,8 @@ class NetworkWindow(PamhyrWindow):
|
||||
def setup_connections(self):
|
||||
self._nodes_model.dataChanged.connect(self._reachs_model.update)
|
||||
self._nodes_model.dataChanged.connect(self._graph_widget.rename_nodes)
|
||||
self._reachs_model.dataChanged.connect(self._graph_widget.display_update)
|
||||
self._reachs_model.dataChanged.connect(
|
||||
self._graph_widget.display_update)
|
||||
self._reachs_model.dataChanged.connect(self._nodes_model.update)
|
||||
self._graph_widget.changeEdge.connect(self._reachs_model.update)
|
||||
self._graph_widget.changeNode.connect(self._nodes_model.update)
|
||||
|
||||
@@ -22,6 +22,7 @@ from View.Tools.PamhyrTranslate import PamhyrTranslate
|
||||
|
||||
_translate = QCoreApplication.translate
|
||||
|
||||
|
||||
class NetworkTranslate(PamhyrTranslate):
|
||||
def __init__(self):
|
||||
super(NetworkTranslate, self).__init__()
|
||||
|
||||
@@ -25,16 +25,17 @@ from PyQt5.QtCore import (
|
||||
|
||||
_translate = QCoreApplication.translate
|
||||
|
||||
|
||||
class PlotAC(PamhyrPlot):
|
||||
def __init__(self, canvas=None, trad=None, toolbar=None,
|
||||
results=None, reach_id=0, profile_id=0,
|
||||
parent=None):
|
||||
super(PlotAC, self).__init__(
|
||||
canvas = canvas,
|
||||
trad = trad,
|
||||
data = results,
|
||||
toolbar = toolbar,
|
||||
parent = parent
|
||||
canvas=canvas,
|
||||
trad=trad,
|
||||
data=results,
|
||||
toolbar=toolbar,
|
||||
parent=parent
|
||||
)
|
||||
|
||||
self._current_timestamp = max(results.get("timestamps"))
|
||||
@@ -68,7 +69,7 @@ class PlotAC(PamhyrPlot):
|
||||
z = profile.geometry.z()
|
||||
|
||||
self.canvas.axes.set_xlim(
|
||||
left = min(x), right = max(x)
|
||||
left=min(x), right=max(x)
|
||||
)
|
||||
|
||||
self.line_kp, = self.canvas.axes.plot(
|
||||
|
||||
@@ -32,16 +32,17 @@ _translate = QCoreApplication.translate
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
|
||||
class PlotH(PamhyrPlot):
|
||||
def __init__(self, canvas=None, trad=None, toolbar=None,
|
||||
results=None, reach_id=0, profile_id=0,
|
||||
parent=None):
|
||||
super(PlotH, self).__init__(
|
||||
canvas = canvas,
|
||||
trad = trad,
|
||||
data = results,
|
||||
toolbar = toolbar,
|
||||
parent = parent
|
||||
canvas=canvas,
|
||||
trad=trad,
|
||||
data=results,
|
||||
toolbar=toolbar,
|
||||
parent=parent
|
||||
)
|
||||
|
||||
self._mode = "time"
|
||||
@@ -87,7 +88,7 @@ class PlotH(PamhyrPlot):
|
||||
ts.sort()
|
||||
|
||||
self.canvas.axes.set_xlim(
|
||||
left = min(ts), right = max(ts)
|
||||
left=min(ts), right=max(ts)
|
||||
)
|
||||
|
||||
# Draw discharge for each timestamp
|
||||
@@ -103,7 +104,7 @@ class PlotH(PamhyrPlot):
|
||||
return
|
||||
|
||||
self.canvas.axes.set_ylim(
|
||||
[min(min(y),0), max(y) + 10]
|
||||
[min(min(y), 0), max(y) + 10]
|
||||
)
|
||||
|
||||
self._line = [
|
||||
@@ -136,8 +137,8 @@ class PlotH(PamhyrPlot):
|
||||
lambda v: (
|
||||
str(
|
||||
datetime.fromtimestamp(v) - t0
|
||||
).split(",")[0]\
|
||||
.replace("days", _translate("Results", "days"))\
|
||||
).split(",")[0]
|
||||
.replace("days", _translate("Results", "days"))
|
||||
.replace("day", _translate("Results", "day"))
|
||||
),
|
||||
fx
|
||||
|
||||
@@ -25,16 +25,17 @@ from PyQt5.QtCore import (
|
||||
|
||||
_translate = QCoreApplication.translate
|
||||
|
||||
|
||||
class PlotKPC(PamhyrPlot):
|
||||
def __init__(self, canvas=None, trad=None, toolbar=None,
|
||||
results=None, reach_id=0, profile_id=0,
|
||||
parent=None):
|
||||
super(PlotKPC, self).__init__(
|
||||
canvas = canvas,
|
||||
trad = trad,
|
||||
data = results,
|
||||
toolbar = toolbar,
|
||||
parent = parent
|
||||
canvas=canvas,
|
||||
trad=trad,
|
||||
data=results,
|
||||
toolbar=toolbar,
|
||||
parent=parent
|
||||
)
|
||||
|
||||
self._current_timestamp = max(results.get("timestamps"))
|
||||
@@ -68,7 +69,7 @@ class PlotKPC(PamhyrPlot):
|
||||
z_min = reach.geometry.get_z_min()
|
||||
|
||||
self.canvas.axes.set_xlim(
|
||||
left = min(kp), right = max(kp)
|
||||
left=min(kp), right=max(kp)
|
||||
)
|
||||
|
||||
self.line_kp_zmin = self.canvas.axes.plot(
|
||||
|
||||
@@ -15,16 +15,17 @@ _translate = QCoreApplication.translate
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
|
||||
class PlotSedProfile(PamhyrPlot):
|
||||
def __init__(self, canvas=None, trad=None, toolbar=None,
|
||||
results=None, reach_id=0, profile_id=0,
|
||||
parent=None):
|
||||
super(PlotSedProfile, self).__init__(
|
||||
canvas = canvas,
|
||||
trad = trad,
|
||||
data = results,
|
||||
toolbar = toolbar,
|
||||
parent = parent
|
||||
canvas=canvas,
|
||||
trad=trad,
|
||||
data=results,
|
||||
toolbar=toolbar,
|
||||
parent=parent
|
||||
)
|
||||
|
||||
self._results = results
|
||||
@@ -59,8 +60,8 @@ class PlotSedProfile(PamhyrPlot):
|
||||
cur_0 = []
|
||||
|
||||
for p in range(profile.geometry.number_points):
|
||||
cur.append(profile_sl)
|
||||
cur_0.append(profile_sl_0)
|
||||
cur.append(profile_sl)
|
||||
cur_0.append(profile_sl_0)
|
||||
|
||||
sl.append(cur)
|
||||
sl_0.append(cur_0)
|
||||
@@ -106,7 +107,6 @@ class PlotSedProfile(PamhyrPlot):
|
||||
|
||||
return list(reversed(z_sl))
|
||||
|
||||
|
||||
@timer
|
||||
def draw(self):
|
||||
self.canvas.axes.cla()
|
||||
@@ -133,7 +133,7 @@ class PlotSedProfile(PamhyrPlot):
|
||||
z = profile.geometry.z()
|
||||
|
||||
self.canvas.axes.set_xlim(
|
||||
left = min(x), right = max(x)
|
||||
left=min(x), right=max(x)
|
||||
)
|
||||
|
||||
z_sl = self.get_zsl(profile)
|
||||
|
||||
@@ -15,16 +15,17 @@ _translate = QCoreApplication.translate
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
|
||||
class PlotSedReach(PamhyrPlot):
|
||||
def __init__(self, canvas=None, trad=None, toolbar=None,
|
||||
results=None, reach_id=0, profile_id=0,
|
||||
parent=None):
|
||||
super(PlotSedReach, self).__init__(
|
||||
canvas = canvas,
|
||||
trad = trad,
|
||||
data = results,
|
||||
toolbar = toolbar,
|
||||
parent = parent
|
||||
canvas=canvas,
|
||||
trad=trad,
|
||||
data=results,
|
||||
toolbar=toolbar,
|
||||
parent=parent
|
||||
)
|
||||
|
||||
self._results = results
|
||||
|
||||
@@ -31,16 +31,17 @@ _translate = QCoreApplication.translate
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
|
||||
class PlotXY(PamhyrPlot):
|
||||
def __init__(self, canvas=None, trad=None, toolbar=None,
|
||||
results=None, reach_id=0, profile_id=0,
|
||||
display_current=True, parent=None):
|
||||
super(PlotXY, self).__init__(
|
||||
canvas = canvas,
|
||||
trad = trad,
|
||||
data = results,
|
||||
toolbar = toolbar,
|
||||
parent = parent
|
||||
canvas=canvas,
|
||||
trad=trad,
|
||||
data=results,
|
||||
toolbar=toolbar,
|
||||
parent=parent
|
||||
)
|
||||
|
||||
self.display_current = display_current
|
||||
@@ -87,7 +88,7 @@ class PlotXY(PamhyrPlot):
|
||||
|
||||
kp = reach.geometry.get_kp()
|
||||
self.canvas.axes.set_xlim(
|
||||
left = min(kp), right = max(kp)
|
||||
left=min(kp), right=max(kp)
|
||||
)
|
||||
|
||||
# Draw line for each profile
|
||||
@@ -98,9 +99,9 @@ class PlotXY(PamhyrPlot):
|
||||
markersize=3, marker='+'
|
||||
)
|
||||
for x, y, kp in zip(
|
||||
reach.geometry.get_x(),
|
||||
reach.geometry.get_y(),
|
||||
kp
|
||||
reach.geometry.get_x(),
|
||||
reach.geometry.get_y(),
|
||||
kp
|
||||
)
|
||||
]
|
||||
|
||||
|
||||
+52
-48
@@ -59,6 +59,7 @@ _translate = QCoreApplication.translate
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
|
||||
class ResultsWindow(PamhyrWindow):
|
||||
_pamhyr_ui = "Results"
|
||||
_pamhyr_name = "Results"
|
||||
@@ -79,10 +80,10 @@ class ResultsWindow(PamhyrWindow):
|
||||
)
|
||||
|
||||
super(ResultsWindow, self).__init__(
|
||||
title = name,
|
||||
study = study,
|
||||
config = config,
|
||||
trad = ResultsTranslate(),
|
||||
title=name,
|
||||
study=study,
|
||||
config=config,
|
||||
trad=ResultsTranslate(),
|
||||
parent=parent
|
||||
)
|
||||
|
||||
@@ -97,11 +98,11 @@ class ResultsWindow(PamhyrWindow):
|
||||
for t in ["reach", "profile"]:
|
||||
table = self.find(QTableView, f"tableView_{t}")
|
||||
self._table[t] = TableModel(
|
||||
table_view = table,
|
||||
table_headers = self._trad.get_dict(f"table_headers_{t}"),
|
||||
data = self._results,
|
||||
undo = self._undo_stack,
|
||||
opt_data = t
|
||||
table_view=table,
|
||||
table_headers=self._trad.get_dict(f"table_headers_{t}"),
|
||||
data=self._results,
|
||||
undo=self._undo_stack,
|
||||
opt_data=t
|
||||
)
|
||||
|
||||
def setup_slider(self):
|
||||
@@ -125,12 +126,12 @@ class ResultsWindow(PamhyrWindow):
|
||||
self.plot_layout.addWidget(self.canvas)
|
||||
|
||||
self.plot_xy = PlotXY(
|
||||
canvas = self.canvas,
|
||||
results = self._results,
|
||||
reach_id = 0,
|
||||
profile_id = 0,
|
||||
toolbar = self.toolbar,
|
||||
display_current = False
|
||||
canvas=self.canvas,
|
||||
results=self._results,
|
||||
reach_id=0,
|
||||
profile_id=0,
|
||||
toolbar=self.toolbar,
|
||||
display_current=False
|
||||
)
|
||||
self.plot_xy.draw()
|
||||
|
||||
@@ -144,11 +145,11 @@ class ResultsWindow(PamhyrWindow):
|
||||
self.plot_layout_2.addWidget(self.canvas_2)
|
||||
|
||||
self.plot_kpc = PlotKPC(
|
||||
canvas = self.canvas_2,
|
||||
results = self._results,
|
||||
reach_id = 0,
|
||||
profile_id = 0,
|
||||
toolbar = self.toolbar_2
|
||||
canvas=self.canvas_2,
|
||||
results=self._results,
|
||||
reach_id=0,
|
||||
profile_id=0,
|
||||
toolbar=self.toolbar_2
|
||||
)
|
||||
self.plot_kpc.draw()
|
||||
|
||||
@@ -162,11 +163,11 @@ class ResultsWindow(PamhyrWindow):
|
||||
self.plot_layout_3.addWidget(self.canvas_3)
|
||||
|
||||
self.plot_ac = PlotAC(
|
||||
canvas = self.canvas_3,
|
||||
results = self._results,
|
||||
reach_id = 0,
|
||||
profile_id = 0,
|
||||
toolbar = self.toolbar_3
|
||||
canvas=self.canvas_3,
|
||||
results=self._results,
|
||||
reach_id=0,
|
||||
profile_id=0,
|
||||
toolbar=self.toolbar_3
|
||||
)
|
||||
self.plot_ac.draw()
|
||||
|
||||
@@ -175,16 +176,17 @@ class ResultsWindow(PamhyrWindow):
|
||||
self.toolbar_4 = PamhyrPlotToolbar(
|
||||
self.canvas_4, self
|
||||
)
|
||||
self.plot_layout_4 = self.find(QVBoxLayout, "verticalLayout_hydrograph")
|
||||
self.plot_layout_4 = self.find(
|
||||
QVBoxLayout, "verticalLayout_hydrograph")
|
||||
self.plot_layout_4.addWidget(self.toolbar_4)
|
||||
self.plot_layout_4.addWidget(self.canvas_4)
|
||||
|
||||
self.plot_h = PlotH(
|
||||
canvas = self.canvas_4,
|
||||
results = self._results,
|
||||
reach_id = 0,
|
||||
profile_id = 0,
|
||||
toolbar = self.toolbar_4
|
||||
canvas=self.canvas_4,
|
||||
results=self._results,
|
||||
reach_id=0,
|
||||
profile_id=0,
|
||||
toolbar=self.toolbar_4
|
||||
)
|
||||
self.plot_h.draw()
|
||||
|
||||
@@ -199,11 +201,11 @@ class ResultsWindow(PamhyrWindow):
|
||||
|
||||
if self._study.river.has_sediment():
|
||||
self.plot_sed_reach = PlotSedReach(
|
||||
canvas = self.canvas_5,
|
||||
results = self._results,
|
||||
reach_id = 0,
|
||||
profile_id = 0,
|
||||
toolbar = self.toolbar_5
|
||||
canvas=self.canvas_5,
|
||||
results=self._results,
|
||||
reach_id=0,
|
||||
profile_id=0,
|
||||
toolbar=self.toolbar_5
|
||||
)
|
||||
self.plot_sed_reach.draw()
|
||||
|
||||
@@ -212,17 +214,18 @@ class ResultsWindow(PamhyrWindow):
|
||||
self.toolbar_6 = PamhyrPlotToolbar(
|
||||
self.canvas_6, self
|
||||
)
|
||||
self.plot_layout_6 = self.find(QVBoxLayout, "verticalLayout_sed_profile")
|
||||
self.plot_layout_6 = self.find(
|
||||
QVBoxLayout, "verticalLayout_sed_profile")
|
||||
self.plot_layout_6.addWidget(self.toolbar_6)
|
||||
self.plot_layout_6.addWidget(self.canvas_6)
|
||||
|
||||
if self._study.river.has_sediment():
|
||||
self.plot_sed_profile = PlotSedProfile(
|
||||
canvas = self.canvas_6,
|
||||
results = self._results,
|
||||
reach_id = 0,
|
||||
profile_id = 0,
|
||||
toolbar = self.toolbar_6
|
||||
canvas=self.canvas_6,
|
||||
results=self._results,
|
||||
reach_id=0,
|
||||
profile_id=0,
|
||||
toolbar=self.toolbar_6
|
||||
)
|
||||
self.plot_sed_profile.draw()
|
||||
|
||||
@@ -283,7 +286,8 @@ class ResultsWindow(PamhyrWindow):
|
||||
|
||||
self._table[t].dataChanged.connect(fun[t])
|
||||
|
||||
self._slider_profile.valueChanged.connect(self._set_current_profile_slider)
|
||||
self._slider_profile.valueChanged.connect(
|
||||
self._set_current_profile_slider)
|
||||
self._slider_time.valueChanged.connect(self._set_current_timestamp)
|
||||
|
||||
def update_table_selection_reach(self, ind):
|
||||
@@ -312,7 +316,7 @@ class ResultsWindow(PamhyrWindow):
|
||||
)
|
||||
table.scrollTo(index)
|
||||
|
||||
def update(self, reach_id = None, profile_id = None, timestamp = None):
|
||||
def update(self, reach_id=None, profile_id=None, timestamp=None):
|
||||
if reach_id is not None:
|
||||
self.plot_xy.set_reach(reach_id)
|
||||
self.plot_ac.set_reach(reach_id)
|
||||
@@ -364,7 +368,7 @@ class ResultsWindow(PamhyrWindow):
|
||||
if len(indexes) == 0:
|
||||
return
|
||||
|
||||
self.update(reach_id = indexes[0].row())
|
||||
self.update(reach_id=indexes[0].row())
|
||||
|
||||
def _set_current_profile(self):
|
||||
table = self.find(QTableView, f"tableView_profile")
|
||||
@@ -373,18 +377,18 @@ class ResultsWindow(PamhyrWindow):
|
||||
return
|
||||
|
||||
ind = indexes[0].row()
|
||||
self.update(profile_id = ind)
|
||||
self.update(profile_id=ind)
|
||||
self._slider_profile.setValue(ind)
|
||||
|
||||
def _set_current_profile_slider(self):
|
||||
pid = self._slider_profile.value()
|
||||
self.update(profile_id = pid)
|
||||
self.update(profile_id=pid)
|
||||
|
||||
return
|
||||
|
||||
def _set_current_timestamp(self):
|
||||
timestamp = self._timestamps[self._slider_time.value()]
|
||||
self.update(timestamp = timestamp)
|
||||
self.update(timestamp=timestamp)
|
||||
|
||||
def _copy(self):
|
||||
logger.info("TODO: copy")
|
||||
|
||||
@@ -22,6 +22,7 @@ from View.Tools.PamhyrTranslate import PamhyrTranslate
|
||||
|
||||
_translate = QCoreApplication.translate
|
||||
|
||||
|
||||
class ResultsTranslate(PamhyrTranslate):
|
||||
def __init__(self):
|
||||
super(ResultsTranslate, self).__init__()
|
||||
|
||||
@@ -44,22 +44,23 @@ from PyQt5.QtWidgets import (
|
||||
|
||||
_translate = QCoreApplication.translate
|
||||
|
||||
|
||||
class SolverLogFileWindow(PamhyrWindow):
|
||||
_pamhyr_ui = "SolverLogFile"
|
||||
_pamhyr_name = "Solver logs"
|
||||
|
||||
def __init__(self, file_name = None,
|
||||
def __init__(self, file_name=None,
|
||||
study=None, config=None,
|
||||
solver=None, parent=None):
|
||||
self._solver = solver
|
||||
self._file_name = file_name
|
||||
|
||||
super(SolverLogFileWindow, self).__init__(
|
||||
title = self._pamhyr_name,
|
||||
study = study,
|
||||
config = config,
|
||||
options = [],
|
||||
parent = parent
|
||||
title=self._pamhyr_name,
|
||||
study=study,
|
||||
config=config,
|
||||
options=[],
|
||||
parent=parent
|
||||
)
|
||||
|
||||
self.setup_action()
|
||||
@@ -75,7 +76,8 @@ class SolverLogFileWindow(PamhyrWindow):
|
||||
|
||||
def setup_connections(self):
|
||||
self.find(QAction, "action_revert").triggered.connect(self.revert)
|
||||
self.find(QAction, "action_open_in_editor").triggered.connect(self.open_on_editor)
|
||||
self.find(QAction, "action_open_in_editor").triggered.connect(
|
||||
self.open_on_editor)
|
||||
|
||||
def setup_text(self):
|
||||
with open(self._file_name, "r") as f:
|
||||
|
||||
@@ -55,6 +55,7 @@ _translate = QCoreApplication.translate
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
|
||||
class SelectSolverWindow(PamhyrDialog):
|
||||
_pamhyr_ui = "SelectSolver"
|
||||
_pamhyr_name = "Select solver"
|
||||
@@ -64,11 +65,11 @@ class SelectSolverWindow(PamhyrDialog):
|
||||
self._solver = None
|
||||
|
||||
super(SelectSolverWindow, self).__init__(
|
||||
title = self._pamhyr_name,
|
||||
study = study,
|
||||
config = config,
|
||||
options = [],
|
||||
parent = parent
|
||||
title=self._pamhyr_name,
|
||||
study=study,
|
||||
config=config,
|
||||
options=[],
|
||||
parent=parent
|
||||
)
|
||||
|
||||
self.setup_combobox()
|
||||
@@ -101,6 +102,7 @@ class SelectSolverWindow(PamhyrDialog):
|
||||
|
||||
super(SelectSolverWindow, self).accept()
|
||||
|
||||
|
||||
class SolverLogWindow(PamhyrWindow):
|
||||
_pamhyr_ui = "SolverLog"
|
||||
_pamhyr_name = "Solver Log"
|
||||
@@ -111,11 +113,11 @@ class SolverLogWindow(PamhyrWindow):
|
||||
self._results = None
|
||||
|
||||
super(SolverLogWindow, self).__init__(
|
||||
title = self._pamhyr_name,
|
||||
study = study,
|
||||
config = config,
|
||||
options = [],
|
||||
parent = parent
|
||||
title=self._pamhyr_name,
|
||||
study=study,
|
||||
config=config,
|
||||
options=[],
|
||||
parent=parent
|
||||
)
|
||||
|
||||
self.setup_action()
|
||||
@@ -132,22 +134,22 @@ class SolverLogWindow(PamhyrWindow):
|
||||
self._study.name.replace(" ", "_"),
|
||||
self._solver.name.replace(" ", "_"),
|
||||
)
|
||||
os.makedirs(self._workdir, exist_ok = True)
|
||||
os.makedirs(self._workdir, exist_ok=True)
|
||||
|
||||
self._alarm.start(500)
|
||||
self._output = Queue()
|
||||
self._process = self.new_process(parent)
|
||||
|
||||
self._log(f" *** Export study {self._solver.name}", color="blue")
|
||||
self._solver.export(self._study, self._workdir, qlog = self._output)
|
||||
self._solver.export(self._study, self._workdir, qlog=self._output)
|
||||
|
||||
self.update()
|
||||
|
||||
self._log(f" *** Run solver {self._solver.name}", color="blue")
|
||||
self._solver.run(
|
||||
study,
|
||||
process = self._process,
|
||||
output_queue = self._output
|
||||
process=self._process,
|
||||
output_queue=self._output
|
||||
)
|
||||
|
||||
def new_process(self, parent):
|
||||
@@ -206,7 +208,8 @@ class SolverLogWindow(PamhyrWindow):
|
||||
|
||||
# Get results
|
||||
if self._results is None:
|
||||
self._results = self._solver.results(self._study, self._workdir, qlog = self._output)
|
||||
self._results = self._solver.results(
|
||||
self._study, self._workdir, qlog=self._output)
|
||||
self._parent.set_results(self._solver, self._results)
|
||||
|
||||
while self._output.qsize() != 0:
|
||||
@@ -219,14 +222,14 @@ class SolverLogWindow(PamhyrWindow):
|
||||
def start(self):
|
||||
if self._solver.is_stoped():
|
||||
self._log(f" *** Export study {self._solver.name}", color="blue")
|
||||
self._solver.export(self._study, self._workdir, qlog = self._output)
|
||||
self._solver.export(self._study, self._workdir, qlog=self._output)
|
||||
self.update()
|
||||
|
||||
self._process = self.new_process(self._parent)
|
||||
|
||||
self._log(" *** Start", color="blue")
|
||||
self._results = None
|
||||
self._solver.start(self._study, process = self._process)
|
||||
self._solver.start(self._study, process=self._process)
|
||||
|
||||
self.find(QAction, "action_start").setEnabled(False)
|
||||
if _signal:
|
||||
@@ -259,7 +262,8 @@ class SolverLogWindow(PamhyrWindow):
|
||||
|
||||
def results(self):
|
||||
if self._results is None:
|
||||
self._results = self._solver.results(self._study, self._workdir, qlog = self._output)
|
||||
self._results = self._solver.results(
|
||||
self._study, self._workdir, qlog=self._output)
|
||||
|
||||
self._parent.set_results(self._solver, self._results)
|
||||
self._parent.open_solver_results(self._solver, self._results)
|
||||
@@ -267,10 +271,10 @@ class SolverLogWindow(PamhyrWindow):
|
||||
def log_file(self):
|
||||
file_name = os.path.join(self._workdir, self._solver.log_file())
|
||||
log = SolverLogFileWindow(
|
||||
file_name = file_name,
|
||||
study = self._study,
|
||||
config = self._config,
|
||||
solver = self._solver,
|
||||
parent = self,
|
||||
file_name=file_name,
|
||||
study=self._study,
|
||||
config=self._config,
|
||||
solver=self._solver,
|
||||
parent=self,
|
||||
)
|
||||
log.show()
|
||||
@@ -9,15 +9,16 @@ from View.Tools.PamhyrPlot import PamhyrPlot
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
|
||||
class Plot(PamhyrPlot):
|
||||
def __init__(self, canvas=None, trad=None, data=None, toolbar=None,
|
||||
display_current=True, parent=None):
|
||||
super(Plot, self).__init__(
|
||||
canvas = canvas,
|
||||
trad = trad,
|
||||
data = data,
|
||||
toolbar = toolbar,
|
||||
parent = parent
|
||||
canvas=canvas,
|
||||
trad=trad,
|
||||
data=data,
|
||||
toolbar=toolbar,
|
||||
parent=parent
|
||||
)
|
||||
|
||||
self._display_current = display_current
|
||||
@@ -39,13 +40,13 @@ class Plot(PamhyrPlot):
|
||||
if self.data is None:
|
||||
return
|
||||
|
||||
x = [0,1]
|
||||
z = [0,0]
|
||||
x = [0, 1]
|
||||
z = [0, 0]
|
||||
sl = self.data.height()
|
||||
names = ["bottom"] + self.data.names()
|
||||
|
||||
self.canvas.axes.set_xlim(
|
||||
left = min(x), right = max(x)
|
||||
left=min(x), right=max(x)
|
||||
)
|
||||
|
||||
lsl = []
|
||||
@@ -75,7 +76,8 @@ class Plot(PamhyrPlot):
|
||||
lw=1.8,
|
||||
color='grey' if i == len(names) - 1 else None
|
||||
)
|
||||
self.canvas.axes.text(x[0] + 0.01, zsl[0] + 0.01, f'{names[-(i+1)]}')
|
||||
self.canvas.axes.text(
|
||||
x[0] + 0.01, zsl[0] + 0.01, f'{names[-(i+1)]}')
|
||||
|
||||
self.canvas.figure.tight_layout()
|
||||
self.canvas.figure.canvas.draw_idle()
|
||||
|
||||
@@ -10,6 +10,7 @@ from PyQt5.QtWidgets import (
|
||||
from Model.SedimentLayer.SedimentLayer import SedimentLayer
|
||||
from Model.SedimentLayer.SedimentLayerList import SedimentLayerList
|
||||
|
||||
|
||||
class SetNameCommand(QUndoCommand):
|
||||
def __init__(self, sediment_layers, index, new_value):
|
||||
QUndoCommand.__init__(self)
|
||||
@@ -25,6 +26,7 @@ class SetNameCommand(QUndoCommand):
|
||||
def redo(self):
|
||||
self._sediment_layers.get(self._index).name = self._new
|
||||
|
||||
|
||||
class SetTypeCommand(QUndoCommand):
|
||||
def __init__(self, sediment_layers, index, new_value):
|
||||
QUndoCommand.__init__(self)
|
||||
@@ -40,6 +42,7 @@ class SetTypeCommand(QUndoCommand):
|
||||
def redo(self):
|
||||
self._sediment_layers.get(self._index).type = self._new
|
||||
|
||||
|
||||
class SetHeightCommand(QUndoCommand):
|
||||
def __init__(self, sediment_layers, index, new_value):
|
||||
QUndoCommand.__init__(self)
|
||||
@@ -55,6 +58,7 @@ class SetHeightCommand(QUndoCommand):
|
||||
def redo(self):
|
||||
self._sediment_layers.get(self._index).height = self._new
|
||||
|
||||
|
||||
class SetD50Command(QUndoCommand):
|
||||
def __init__(self, sediment_layers, index, new_value):
|
||||
QUndoCommand.__init__(self)
|
||||
@@ -70,6 +74,7 @@ class SetD50Command(QUndoCommand):
|
||||
def redo(self):
|
||||
self._sediment_layers.get(self._index).d50 = self._new
|
||||
|
||||
|
||||
class SetSigmaCommand(QUndoCommand):
|
||||
def __init__(self, sediment_layers, index, new_value):
|
||||
QUndoCommand.__init__(self)
|
||||
@@ -85,6 +90,7 @@ class SetSigmaCommand(QUndoCommand):
|
||||
def redo(self):
|
||||
self._sediment_layers.get(self._index).sigma = self._new
|
||||
|
||||
|
||||
class SetCriticalConstraintCommand(QUndoCommand):
|
||||
def __init__(self, sediment_layers, index, new_value):
|
||||
QUndoCommand.__init__(self)
|
||||
@@ -100,6 +106,7 @@ class SetCriticalConstraintCommand(QUndoCommand):
|
||||
def redo(self):
|
||||
self._sediment_layers.get(self._index).critical_constraint = self._new
|
||||
|
||||
|
||||
class AddCommand(QUndoCommand):
|
||||
def __init__(self, sediment_layers, index):
|
||||
QUndoCommand.__init__(self)
|
||||
@@ -117,6 +124,7 @@ class AddCommand(QUndoCommand):
|
||||
else:
|
||||
self._sediment_layers.insert(self._index, self._new)
|
||||
|
||||
|
||||
class DelCommand(QUndoCommand):
|
||||
def __init__(self, sediment_layers, rows):
|
||||
QUndoCommand.__init__(self)
|
||||
@@ -136,6 +144,7 @@ class DelCommand(QUndoCommand):
|
||||
def redo(self):
|
||||
self._sediment_layers.delete_i(self._rows)
|
||||
|
||||
|
||||
class MoveCommand(QUndoCommand):
|
||||
def __init__(self, sediment_layers, up, i):
|
||||
QUndoCommand.__init__(self)
|
||||
|
||||
@@ -51,11 +51,12 @@ _translate = QCoreApplication.translate
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
|
||||
class EditSedimentLayersWindow(PamhyrWindow):
|
||||
_pamhyr_ui = "EditSedimentLayers"
|
||||
_pamhyr_name = "Edit Sediment Layers"
|
||||
|
||||
def __init__(self, study=None, config = None,
|
||||
def __init__(self, study=None, config=None,
|
||||
sl=None, parent=None):
|
||||
self._sl = sl
|
||||
|
||||
@@ -68,11 +69,11 @@ class EditSedimentLayersWindow(PamhyrWindow):
|
||||
)
|
||||
|
||||
super(EditSedimentLayersWindow, self).__init__(
|
||||
title = name,
|
||||
study = study,
|
||||
config = config,
|
||||
trad = SedimentEditTranslate(),
|
||||
parent = parent
|
||||
title=name,
|
||||
study=study,
|
||||
config=config,
|
||||
trad=SedimentEditTranslate(),
|
||||
parent=parent
|
||||
)
|
||||
|
||||
self.setup_table()
|
||||
@@ -83,12 +84,12 @@ class EditSedimentLayersWindow(PamhyrWindow):
|
||||
table_headers = self._trad.get_dict("table_headers")
|
||||
table = self.find(QTableView, f"tableView")
|
||||
self._table = TableModel(
|
||||
table_view = table,
|
||||
table_headers = table_headers,
|
||||
editable_headers = list(table_headers),
|
||||
data = self._sl,
|
||||
trad = self._trad,
|
||||
undo = self._undo_stack,
|
||||
table_view=table,
|
||||
table_headers=table_headers,
|
||||
editable_headers=list(table_headers),
|
||||
data=self._sl,
|
||||
trad=self._trad,
|
||||
undo=self._undo_stack,
|
||||
)
|
||||
table.setModel(self._table)
|
||||
table.setSelectionBehavior(QAbstractItemView.SelectRows)
|
||||
@@ -108,20 +109,20 @@ class EditSedimentLayersWindow(PamhyrWindow):
|
||||
|
||||
def _set_plot(self):
|
||||
self.plot = Plot(
|
||||
canvas = self.canvas,
|
||||
data = self._sl,
|
||||
toolbar = self.toolbar,
|
||||
trad = self._trad,
|
||||
display_current = False
|
||||
canvas=self.canvas,
|
||||
data=self._sl,
|
||||
toolbar=self.toolbar,
|
||||
trad=self._trad,
|
||||
display_current=False
|
||||
)
|
||||
self.plot.draw()
|
||||
|
||||
|
||||
def setup_connections(self):
|
||||
self.find(QAction, "action_add").triggered.connect(self.add)
|
||||
self.find(QAction, "action_del").triggered.connect(self.delete)
|
||||
self.find(QAction, "action_move_up").triggered.connect(self.move_up)
|
||||
self.find(QAction, "action_move_down").triggered.connect(self.move_down)
|
||||
self.find(QAction, "action_move_down").triggered.connect(
|
||||
self.move_down)
|
||||
|
||||
self._table.dataChanged.connect(self._set_plot)
|
||||
self._table.layoutChanged.connect(self._set_plot)
|
||||
|
||||
@@ -6,6 +6,7 @@ from View.SedimentLayers.translate import SedimentTranslate
|
||||
|
||||
_translate = QCoreApplication.translate
|
||||
|
||||
|
||||
class SedimentEditTranslate(SedimentTranslate):
|
||||
def __init__(self):
|
||||
super(SedimentEditTranslate, self).__init__()
|
||||
|
||||
@@ -15,16 +15,17 @@ _translate = QCoreApplication.translate
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
|
||||
class Plot(PamhyrPlot):
|
||||
def __init__(self, data=None, display_current=True,
|
||||
canvas=None, trad=None, toolbar=None,
|
||||
parent=None):
|
||||
super(Plot, self).__init__(
|
||||
canvas = canvas,
|
||||
trad = trad,
|
||||
data = data,
|
||||
toolbar = toolbar,
|
||||
parent = parent
|
||||
canvas=canvas,
|
||||
trad=trad,
|
||||
data=data,
|
||||
toolbar=toolbar,
|
||||
parent=parent
|
||||
)
|
||||
|
||||
self._display_current = display_current
|
||||
@@ -58,7 +59,7 @@ class Plot(PamhyrPlot):
|
||||
z_max = self.data.get_z_max()
|
||||
|
||||
self.canvas.axes.set_xlim(
|
||||
left = min(kp), right = max(kp)
|
||||
left=min(kp), right=max(kp)
|
||||
)
|
||||
|
||||
# Compute sediment layer in function to profile z_min
|
||||
|
||||
@@ -15,16 +15,17 @@ _translate = QCoreApplication.translate
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
|
||||
class Plot(PamhyrPlot):
|
||||
def __init__(self, data=None, display_current=True,
|
||||
canvas=None, trad=None, toolbar=None,
|
||||
parent=None):
|
||||
super(Plot, self).__init__(
|
||||
canvas = canvas,
|
||||
trad = trad,
|
||||
data = data,
|
||||
toolbar = toolbar,
|
||||
parent = parent
|
||||
canvas=canvas,
|
||||
trad=trad,
|
||||
data=data,
|
||||
toolbar=toolbar,
|
||||
parent=parent
|
||||
)
|
||||
|
||||
self._display_current = display_current
|
||||
@@ -57,7 +58,7 @@ class Plot(PamhyrPlot):
|
||||
sl = self.data.get_sl()
|
||||
|
||||
self.canvas.axes.set_xlim(
|
||||
left = min(x), right = max(x)
|
||||
left=min(x), right=max(x)
|
||||
)
|
||||
|
||||
# Compute sediment layer in function to point z
|
||||
|
||||
@@ -26,6 +26,7 @@ _translate = QCoreApplication.translate
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
|
||||
class ComboBoxDelegate(QItemDelegate):
|
||||
def __init__(self, study=None, parent=None):
|
||||
super(ComboBoxDelegate, self).__init__(parent)
|
||||
|
||||
@@ -16,6 +16,7 @@ from Model.SedimentLayer.SedimentLayerList import SedimentLayerList
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
|
||||
class SetSLCommand(QUndoCommand):
|
||||
def __init__(self, profile, index, new_value):
|
||||
QUndoCommand.__init__(self)
|
||||
|
||||
@@ -37,6 +37,7 @@ _translate = QCoreApplication.translate
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
|
||||
class ProfileSedimentLayersWindow(PamhyrWindow):
|
||||
_pamhyr_ui = "ProfileSedimentLayers"
|
||||
_pamhyr_name = "Profile sediment layers"
|
||||
@@ -49,11 +50,11 @@ class ProfileSedimentLayersWindow(PamhyrWindow):
|
||||
name = self.compute_name(study)
|
||||
|
||||
super(ProfileSedimentLayersWindow, self).__init__(
|
||||
title = name,
|
||||
study = study,
|
||||
config = config,
|
||||
trad = SedimentProfileTranslate(),
|
||||
parent = parent
|
||||
title=name,
|
||||
study=study,
|
||||
config=config,
|
||||
trad=SedimentProfileTranslate(),
|
||||
parent=parent
|
||||
)
|
||||
|
||||
self.setup_table()
|
||||
@@ -72,7 +73,7 @@ class ProfileSedimentLayersWindow(PamhyrWindow):
|
||||
pname = _translate(
|
||||
"SedimentLayers",
|
||||
"(no name - @kp)").replace("@kp", str(self._profile.kp)
|
||||
)
|
||||
)
|
||||
|
||||
return (
|
||||
self._pamhyr_name + " - "
|
||||
@@ -84,20 +85,20 @@ class ProfileSedimentLayersWindow(PamhyrWindow):
|
||||
table_headers = self._trad.get_dict("table_headers")
|
||||
|
||||
self._delegate_sl = ComboBoxDelegate(
|
||||
study = self._study,
|
||||
study=self._study,
|
||||
parent=self
|
||||
)
|
||||
|
||||
table = self.find(QTableView, f"tableView")
|
||||
self._table = TableModel(
|
||||
table_view = table,
|
||||
data = self._profile,
|
||||
opt_data = self._study,
|
||||
table_headers = table_headers,
|
||||
editable_headers = ["sl"],
|
||||
delegates = {"sl": self._delegate_sl},
|
||||
trad = self._trad,
|
||||
undo = self._undo_stack,
|
||||
table_view=table,
|
||||
data=self._profile,
|
||||
opt_data=self._study,
|
||||
table_headers=table_headers,
|
||||
editable_headers=["sl"],
|
||||
delegates={"sl": self._delegate_sl},
|
||||
trad=self._trad,
|
||||
undo=self._undo_stack,
|
||||
)
|
||||
table.setModel(self._table)
|
||||
table.setSelectionBehavior(QAbstractItemView.SelectRows)
|
||||
@@ -118,10 +119,10 @@ class ProfileSedimentLayersWindow(PamhyrWindow):
|
||||
|
||||
def _update_plot(self):
|
||||
self.plot = Plot(
|
||||
canvas = self.canvas,
|
||||
data = self._profile,
|
||||
toolbar = self.toolbar,
|
||||
display_current = False
|
||||
canvas=self.canvas,
|
||||
data=self._profile,
|
||||
toolbar=self.toolbar,
|
||||
display_current=False
|
||||
)
|
||||
self.plot.draw()
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ from View.SedimentLayers.Reach.translate import SedimentReachTranslate
|
||||
|
||||
_translate = QCoreApplication.translate
|
||||
|
||||
|
||||
class SedimentProfileTranslate(SedimentReachTranslate):
|
||||
def __init__(self):
|
||||
super(SedimentProfileTranslate, self).__init__()
|
||||
|
||||
@@ -19,15 +19,16 @@ from View.SedimentLayers.Reach.translate import *
|
||||
|
||||
_translate = QCoreApplication.translate
|
||||
|
||||
|
||||
class SLDialog(PamhyrDialog):
|
||||
_pamhyr_ui = "SLDialog"
|
||||
_pamhyr_name = "SL"
|
||||
|
||||
def __init__(self, study=None, config=None, parent=None):
|
||||
super(SLDialog, self).__init__(
|
||||
title = self._pamhyr_name,
|
||||
study = study,
|
||||
config = config,
|
||||
title=self._pamhyr_name,
|
||||
study=study,
|
||||
config=config,
|
||||
parent=parent
|
||||
)
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ _translate = QCoreApplication.translate
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
|
||||
class ComboBoxDelegate(QItemDelegate):
|
||||
def __init__(self, study=None, trad=None, parent=None):
|
||||
super(ComboBoxDelegate, self).__init__(parent)
|
||||
|
||||
@@ -16,6 +16,7 @@ from Model.SedimentLayer.SedimentLayerList import SedimentLayerList
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
|
||||
class SetSLCommand(QUndoCommand):
|
||||
def __init__(self, reach, index, new_value):
|
||||
QUndoCommand.__init__(self)
|
||||
|
||||
@@ -39,6 +39,7 @@ _translate = QCoreApplication.translate
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
|
||||
class ReachSedimentLayersWindow(PamhyrWindow):
|
||||
_pamhyr_ui = "ReachSedimentLayers"
|
||||
_pamhyr_name = "Reach sediment layers"
|
||||
@@ -54,11 +55,11 @@ class ReachSedimentLayersWindow(PamhyrWindow):
|
||||
)
|
||||
|
||||
super(ReachSedimentLayersWindow, self).__init__(
|
||||
title = name,
|
||||
study = study,
|
||||
config = config,
|
||||
trad = SedimentReachTranslate(),
|
||||
parent = parent
|
||||
title=name,
|
||||
study=study,
|
||||
config=config,
|
||||
trad=SedimentReachTranslate(),
|
||||
parent=parent
|
||||
)
|
||||
|
||||
self.setup_table()
|
||||
@@ -69,21 +70,21 @@ class ReachSedimentLayersWindow(PamhyrWindow):
|
||||
table_headers = self._trad.get_dict("table_headers")
|
||||
|
||||
self._delegate_sl = ComboBoxDelegate(
|
||||
study = self._study,
|
||||
trad = self._trad,
|
||||
study=self._study,
|
||||
trad=self._trad,
|
||||
parent=self
|
||||
)
|
||||
|
||||
table = self.find(QTableView, f"tableView")
|
||||
self._table = TableModel(
|
||||
table_view = table,
|
||||
data = self._reach,
|
||||
opt_data = self._study,
|
||||
table_headers = table_headers,
|
||||
editable_headers = ["sl"],
|
||||
delegates = {"sl": self._delegate_sl},
|
||||
trad = self._trad,
|
||||
undo = self._undo_stack,
|
||||
table_view=table,
|
||||
data=self._reach,
|
||||
opt_data=self._study,
|
||||
table_headers=table_headers,
|
||||
editable_headers=["sl"],
|
||||
delegates={"sl": self._delegate_sl},
|
||||
trad=self._trad,
|
||||
undo=self._undo_stack,
|
||||
)
|
||||
table.setModel(self._table)
|
||||
table.setSelectionBehavior(QAbstractItemView.SelectRows)
|
||||
@@ -104,15 +105,14 @@ class ReachSedimentLayersWindow(PamhyrWindow):
|
||||
|
||||
def _update_plot(self):
|
||||
self.plot = Plot(
|
||||
canvas = self.canvas,
|
||||
data = self._reach,
|
||||
toolbar = self.toolbar,
|
||||
trad = self._trad,
|
||||
display_current = False
|
||||
canvas=self.canvas,
|
||||
data=self._reach,
|
||||
toolbar=self.toolbar,
|
||||
trad=self._trad,
|
||||
display_current=False
|
||||
)
|
||||
self.plot.draw()
|
||||
|
||||
|
||||
def setup_connections(self):
|
||||
self.find(QAction, "action_edit").triggered.connect(self.edit_profile)
|
||||
|
||||
@@ -128,7 +128,6 @@ class ReachSedimentLayersWindow(PamhyrWindow):
|
||||
self._table.dataChanged\
|
||||
.connect(self._update_plot)
|
||||
|
||||
|
||||
def index_selected_rows(self):
|
||||
table = self.find(QTableView, f"tableView")
|
||||
return list(
|
||||
@@ -157,8 +156,8 @@ class ReachSedimentLayersWindow(PamhyrWindow):
|
||||
|
||||
def apply_sl_each_profile(self):
|
||||
slw = SLDialog(
|
||||
study = self._study,
|
||||
parent = self
|
||||
study=self._study,
|
||||
parent=self
|
||||
)
|
||||
if slw.exec():
|
||||
sl = slw.sl
|
||||
@@ -171,16 +170,15 @@ class ReachSedimentLayersWindow(PamhyrWindow):
|
||||
|
||||
for row in rows:
|
||||
slw = ProfileSedimentLayersWindow(
|
||||
study = self._study,
|
||||
profile = self._reach.profile(row),
|
||||
parent = self
|
||||
study=self._study,
|
||||
profile=self._reach.profile(row),
|
||||
parent=self
|
||||
)
|
||||
slw.show()
|
||||
|
||||
|
||||
def edit_sl(self):
|
||||
slw = SedimentLayersWindow(
|
||||
study = self._study,
|
||||
parent = self
|
||||
study=self._study,
|
||||
parent=self
|
||||
)
|
||||
slw.show()
|
||||
@@ -6,6 +6,7 @@ from View.SedimentLayers.translate import SedimentTranslate
|
||||
|
||||
_translate = QCoreApplication.translate
|
||||
|
||||
|
||||
class SedimentReachTranslate(SedimentTranslate):
|
||||
def __init__(self):
|
||||
super(SedimentReachTranslate, self).__init__()
|
||||
|
||||
@@ -10,6 +10,7 @@ from PyQt5.QtWidgets import (
|
||||
from Model.SedimentLayer.SedimentLayer import SedimentLayer
|
||||
from Model.SedimentLayer.SedimentLayerList import SedimentLayerList
|
||||
|
||||
|
||||
class SetNameCommand(QUndoCommand):
|
||||
def __init__(self, sediment_layers_list, index, new_value):
|
||||
QUndoCommand.__init__(self)
|
||||
@@ -25,6 +26,7 @@ class SetNameCommand(QUndoCommand):
|
||||
def redo(self):
|
||||
self._sediment_layers_list.get(self._index).name = self._new
|
||||
|
||||
|
||||
class SetCommentCommand(QUndoCommand):
|
||||
def __init__(self, sediment_layers_list, index, new_value):
|
||||
QUndoCommand.__init__(self)
|
||||
@@ -40,6 +42,7 @@ class SetCommentCommand(QUndoCommand):
|
||||
def redo(self):
|
||||
self._sediment_layers_list.get(self._index).comment = self._new
|
||||
|
||||
|
||||
class AddCommand(QUndoCommand):
|
||||
def __init__(self, sediment_layers_list, index):
|
||||
QUndoCommand.__init__(self)
|
||||
@@ -57,6 +60,7 @@ class AddCommand(QUndoCommand):
|
||||
else:
|
||||
self._sediment_layers_list.insert(self._index, self._new)
|
||||
|
||||
|
||||
class DelCommand(QUndoCommand):
|
||||
def __init__(self, sediment_layers_list, rows):
|
||||
QUndoCommand.__init__(self)
|
||||
@@ -76,6 +80,7 @@ class DelCommand(QUndoCommand):
|
||||
def redo(self):
|
||||
self._sediment_layers_list.delete_i(self._rows)
|
||||
|
||||
|
||||
class MoveCommand(QUndoCommand):
|
||||
def __init__(self, sediment_layers_list, up, i):
|
||||
QUndoCommand.__init__(self)
|
||||
|
||||
@@ -51,6 +51,7 @@ from View.SedimentLayers.Edit.Window import EditSedimentLayersWindow
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
|
||||
class SedimentLayersWindow(PamhyrWindow):
|
||||
_pamhyr_ui = "SedimentLayersList"
|
||||
_pamhyr_name = "Sediment Layers List"
|
||||
@@ -63,10 +64,10 @@ class SedimentLayersWindow(PamhyrWindow):
|
||||
)
|
||||
|
||||
super(SedimentLayersWindow, self).__init__(
|
||||
title = name,
|
||||
study = study,
|
||||
config = config,
|
||||
trad = SedimentTranslate(),
|
||||
title=name,
|
||||
study=study,
|
||||
config=config,
|
||||
trad=SedimentTranslate(),
|
||||
parent=parent
|
||||
)
|
||||
|
||||
@@ -77,12 +78,12 @@ class SedimentLayersWindow(PamhyrWindow):
|
||||
def setup_table(self):
|
||||
table = self.find(QTableView, f"tableView")
|
||||
self._table = TableModel(
|
||||
table_view = table,
|
||||
table_headers = self._trad.get_dict("table_headers"),
|
||||
editable_headers = ["name", "comment"],
|
||||
data = self._study.river.sediment_layers,
|
||||
trad = self._trad,
|
||||
undo = self._undo_stack,
|
||||
table_view=table,
|
||||
table_headers=self._trad.get_dict("table_headers"),
|
||||
editable_headers=["name", "comment"],
|
||||
data=self._study.river.sediment_layers,
|
||||
trad=self._trad,
|
||||
undo=self._undo_stack,
|
||||
)
|
||||
table.setModel(self._table)
|
||||
table.setSelectionBehavior(QAbstractItemView.SelectRows)
|
||||
@@ -98,7 +99,8 @@ class SedimentLayersWindow(PamhyrWindow):
|
||||
def setup_connections(self):
|
||||
self.find(QAction, "action_add").triggered.connect(self.add)
|
||||
self.find(QAction, "action_del").triggered.connect(self.delete)
|
||||
self.find(QAction, "action_edit").triggered.connect(self.edit_sediment_layers)
|
||||
self.find(QAction, "action_edit").triggered.connect(
|
||||
self.edit_sediment_layers)
|
||||
|
||||
table = self.find(QTableView, f"tableView")
|
||||
table.selectionModel()\
|
||||
@@ -115,15 +117,14 @@ class SedimentLayersWindow(PamhyrWindow):
|
||||
return
|
||||
|
||||
self.plot = Plot(
|
||||
canvas = self.canvas,
|
||||
data = self._sediment_layers.get(rows[0]),
|
||||
trad = self._trad,
|
||||
toolbar = None,
|
||||
display_current = False
|
||||
canvas=self.canvas,
|
||||
data=self._sediment_layers.get(rows[0]),
|
||||
trad=self._trad,
|
||||
toolbar=None,
|
||||
display_current=False
|
||||
)
|
||||
self.plot.draw()
|
||||
|
||||
|
||||
def index_selected_rows(self):
|
||||
table = self.find(QTableView, f"tableView")
|
||||
return list(
|
||||
@@ -167,8 +168,8 @@ class SedimentLayersWindow(PamhyrWindow):
|
||||
|
||||
for row in rows:
|
||||
slw = EditSedimentLayersWindow(
|
||||
study = self._study,
|
||||
sl = self._sediment_layers.get(row),
|
||||
parent = self
|
||||
study=self._study,
|
||||
sl=self._sediment_layers.get(row),
|
||||
parent=self
|
||||
)
|
||||
slw.show()
|
||||
@@ -6,6 +6,7 @@ from View.Tools.PamhyrTranslate import PamhyrTranslate
|
||||
|
||||
_translate = QCoreApplication.translate
|
||||
|
||||
|
||||
class SedimentTranslate(PamhyrTranslate):
|
||||
def __init__(self):
|
||||
super(SedimentTranslate, self).__init__()
|
||||
|
||||
@@ -44,6 +44,7 @@ logger = logging.getLogger()
|
||||
|
||||
_translate = QCoreApplication.translate
|
||||
|
||||
|
||||
class TableModel(PamhyrTableModel):
|
||||
def _setup_lst(self):
|
||||
self._tab = self._opt_data
|
||||
|
||||
@@ -25,6 +25,7 @@ from PyQt5.QtWidgets import (
|
||||
|
||||
from Model.SolverParameters.SolverParametersList import SolverParametersList
|
||||
|
||||
|
||||
class SetCommand(QUndoCommand):
|
||||
def __init__(self, data, index, column, new_value):
|
||||
QUndoCommand.__init__(self)
|
||||
|
||||
@@ -50,6 +50,7 @@ _translate = QCoreApplication.translate
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
|
||||
class SolverParametersWindow(PamhyrWindow):
|
||||
_pamhyr_ui = "SolverParameters"
|
||||
_pamhyr_name = "Solver parameters"
|
||||
@@ -57,12 +58,12 @@ class SolverParametersWindow(PamhyrWindow):
|
||||
def __init__(self, study=None, config=None, parent=None):
|
||||
name = self._pamhyr_name + " - " + study.name
|
||||
super(SolverParametersWindow, self).__init__(
|
||||
title = name,
|
||||
study = study,
|
||||
config = config,
|
||||
options = ['copy'],
|
||||
trad = ParamTranslate(),
|
||||
parent = parent
|
||||
title=name,
|
||||
study=study,
|
||||
config=config,
|
||||
options=['copy'],
|
||||
trad=ParamTranslate(),
|
||||
parent=parent
|
||||
)
|
||||
|
||||
self._params = self._study.river.parameters
|
||||
@@ -96,13 +97,13 @@ class SolverParametersWindow(PamhyrWindow):
|
||||
|
||||
# Create table model
|
||||
self._table[st] = TableModel(
|
||||
table_view = table,
|
||||
data = self._study.river,
|
||||
opt_data = st,
|
||||
table_headers = self._trad.get_dict("table_headers"),
|
||||
editable_headers = ["value"],
|
||||
trad = self._trad,
|
||||
undo = self._undo_stack[st],
|
||||
table_view=table,
|
||||
data=self._study.river,
|
||||
opt_data=st,
|
||||
table_headers=self._trad.get_dict("table_headers"),
|
||||
editable_headers=["value"],
|
||||
trad=self._trad,
|
||||
undo=self._undo_stack[st],
|
||||
)
|
||||
|
||||
table.setModel(self._table[st])
|
||||
|
||||
@@ -22,6 +22,7 @@ from View.Tools.PamhyrTranslate import PamhyrTranslate
|
||||
|
||||
_translate = QCoreApplication.translate
|
||||
|
||||
|
||||
class ParamTranslate(PamhyrTranslate):
|
||||
def __init__(self):
|
||||
super(ParamTranslate, self).__init__()
|
||||
|
||||
@@ -46,6 +46,7 @@ logger = logging.getLogger()
|
||||
|
||||
_translate = QCoreApplication.translate
|
||||
|
||||
|
||||
class TableModel(PamhyrTableModel):
|
||||
def data(self, index, role):
|
||||
if role != Qt.ItemDataRole.DisplayRole:
|
||||
|
||||
@@ -26,6 +26,7 @@ from PyQt5.QtWidgets import (
|
||||
from Model.LateralContribution.LateralContribution import LateralContribution
|
||||
from Model.LateralContribution.LateralContributionList import LateralContributionList
|
||||
|
||||
|
||||
class SetNameCommand(QUndoCommand):
|
||||
def __init__(self, data, index, new_value):
|
||||
QUndoCommand.__init__(self)
|
||||
@@ -41,6 +42,7 @@ class SetNameCommand(QUndoCommand):
|
||||
def redo(self):
|
||||
self._data.get(self._index).name = self._new
|
||||
|
||||
|
||||
class SetCommentCommand(QUndoCommand):
|
||||
def __init__(self, data, index, new_value):
|
||||
QUndoCommand.__init__(self)
|
||||
@@ -56,6 +58,7 @@ class SetCommentCommand(QUndoCommand):
|
||||
def redo(self):
|
||||
self._data.get(self._index).comment = self._new
|
||||
|
||||
|
||||
class SetMinorCommand(QUndoCommand):
|
||||
def __init__(self, data, index, new_value):
|
||||
QUndoCommand.__init__(self)
|
||||
@@ -71,6 +74,7 @@ class SetMinorCommand(QUndoCommand):
|
||||
def redo(self):
|
||||
self._data.get(self._index).minor = self._new
|
||||
|
||||
|
||||
class SetMediumCommand(QUndoCommand):
|
||||
def __init__(self, data, index, new_value):
|
||||
QUndoCommand.__init__(self)
|
||||
@@ -104,6 +108,7 @@ class AddCommand(QUndoCommand):
|
||||
else:
|
||||
self._data.insert(self._index, self._new)
|
||||
|
||||
|
||||
class DelCommand(QUndoCommand):
|
||||
def __init__(self, data, rows):
|
||||
QUndoCommand.__init__(self)
|
||||
@@ -123,6 +128,7 @@ class DelCommand(QUndoCommand):
|
||||
def redo(self):
|
||||
self._data.delete_i(self._rows)
|
||||
|
||||
|
||||
class SortCommand(QUndoCommand):
|
||||
def __init__(self, data, _reverse):
|
||||
QUndoCommand.__init__(self)
|
||||
@@ -150,6 +156,7 @@ class SortCommand(QUndoCommand):
|
||||
)
|
||||
self._old = None
|
||||
|
||||
|
||||
class PasteCommand(QUndoCommand):
|
||||
def __init__(self, data, row, el):
|
||||
QUndoCommand.__init__(self)
|
||||
|
||||
@@ -49,6 +49,7 @@ _translate = QCoreApplication.translate
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
|
||||
class StricklersWindow(PamhyrWindow):
|
||||
_pamhyr_ui = "Stricklers"
|
||||
_pamhyr_name = "Stricklers"
|
||||
@@ -57,11 +58,11 @@ class StricklersWindow(PamhyrWindow):
|
||||
name = self._pamhyr_name + " - " + study.name
|
||||
|
||||
super(StricklersWindow, self).__init__(
|
||||
title = name,
|
||||
study = study,
|
||||
config = config,
|
||||
trad = StricklersTranslate(),
|
||||
parent = parent
|
||||
title=name,
|
||||
study=study,
|
||||
config=config,
|
||||
trad=StricklersTranslate(),
|
||||
parent=parent
|
||||
)
|
||||
|
||||
self.setup_table()
|
||||
@@ -78,11 +79,11 @@ class StricklersWindow(PamhyrWindow):
|
||||
data = self._config.stricklers
|
||||
|
||||
self._table[t] = TableModel(
|
||||
table_view = table,
|
||||
table_headers = self._trad.get_dict("table_headers"),
|
||||
editable_headers = ["name", "comment", "minor", "medium"],
|
||||
data = data,
|
||||
undo = self._undo_stack,
|
||||
table_view=table,
|
||||
table_headers=self._trad.get_dict("table_headers"),
|
||||
editable_headers=["name", "comment", "minor", "medium"],
|
||||
data=data,
|
||||
undo=self._undo_stack,
|
||||
)
|
||||
|
||||
table.setModel(self._table[t])
|
||||
@@ -106,7 +107,6 @@ class StricklersWindow(PamhyrWindow):
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def add(self):
|
||||
rows = self.index_selected_rows()
|
||||
if len(rows) == 0:
|
||||
|
||||
@@ -27,27 +27,29 @@ from PyQt5.QtWidgets import (
|
||||
|
||||
_translate = QCoreApplication.translate
|
||||
|
||||
|
||||
class NewStudyWindow(PamhyrDialog):
|
||||
_pamhyr_ui = "NewStudy"
|
||||
_pamhyr_name = "Edit/New Study"
|
||||
|
||||
def __init__(self, study=None, config = None, parent=None):
|
||||
def __init__(self, study=None, config=None, parent=None):
|
||||
if study is not None:
|
||||
name = f"Edit study - {study.name}"
|
||||
else:
|
||||
name = "New study"
|
||||
|
||||
super(NewStudyWindow, self).__init__(
|
||||
title = name,
|
||||
study = study,
|
||||
config = config,
|
||||
options = [],
|
||||
parent = parent
|
||||
title=name,
|
||||
study=study,
|
||||
config=config,
|
||||
options=[],
|
||||
parent=parent
|
||||
)
|
||||
|
||||
if not self._study is None:
|
||||
self.set_line_edit_text("lineEdit_name", self._study.name)
|
||||
self.set_text_edit_text("textEdit_description", self._study.description)
|
||||
self.set_text_edit_text(
|
||||
"textEdit_description", self._study.description)
|
||||
self.set_datetime_edit("dateTimeEdit_date", self._study.date)
|
||||
|
||||
self.find(QLabel, "label_creation_date_data").setText(
|
||||
@@ -81,7 +83,6 @@ class NewStudyWindow(PamhyrDialog):
|
||||
self.find(QLabel, "label_date").setEnabled(True)
|
||||
self.find(QDateTimeEdit, "dateTimeEdit_date").setEnabled(True)
|
||||
|
||||
|
||||
def accept(self):
|
||||
name = self.get_line_edit_text("lineEdit_name")
|
||||
description = self.get_text_edit_text("textEdit_description")
|
||||
|
||||
@@ -46,6 +46,7 @@ from Model.Except import ClipboardFormatError
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
|
||||
class WindowToolKit(object):
|
||||
def __init__(self, parent=None):
|
||||
super(WindowToolKit, self).__init__()
|
||||
@@ -150,7 +151,7 @@ class ASubWindowFeatures(object):
|
||||
|
||||
return qtype
|
||||
|
||||
def get_label_text(self, name:str):
|
||||
def get_label_text(self, name: str):
|
||||
"""Get text of label component
|
||||
|
||||
Args:
|
||||
@@ -161,7 +162,7 @@ class ASubWindowFeatures(object):
|
||||
"""
|
||||
return self.find(QLabel, name).text()
|
||||
|
||||
def set_label_text(self, name:str, text:str):
|
||||
def set_label_text(self, name: str, text: str):
|
||||
"""Set text of label component
|
||||
|
||||
Args:
|
||||
@@ -173,8 +174,7 @@ class ASubWindowFeatures(object):
|
||||
"""
|
||||
self.find(QLabel, name).setText(text)
|
||||
|
||||
|
||||
def set_line_edit_text(self, name:str, text:str):
|
||||
def set_line_edit_text(self, name: str, text: str):
|
||||
"""Set text of line edit component
|
||||
|
||||
Args:
|
||||
@@ -189,7 +189,7 @@ class ASubWindowFeatures(object):
|
||||
except AttributeError as e:
|
||||
logger.error(e)
|
||||
|
||||
def get_line_edit_text(self, name:str):
|
||||
def get_line_edit_text(self, name: str):
|
||||
"""Get text of line edit component
|
||||
|
||||
Args:
|
||||
@@ -200,7 +200,7 @@ class ASubWindowFeatures(object):
|
||||
"""
|
||||
return self.find(QLineEdit, name).text()
|
||||
|
||||
def set_text_edit_text(self, name:str, text:str):
|
||||
def set_text_edit_text(self, name: str, text: str):
|
||||
"""Set text of text edit component
|
||||
|
||||
Args:
|
||||
@@ -212,7 +212,7 @@ class ASubWindowFeatures(object):
|
||||
"""
|
||||
self.find(QTextEdit, name).setText(text)
|
||||
|
||||
def get_text_edit_text(self, name:str):
|
||||
def get_text_edit_text(self, name: str):
|
||||
"""Get text of text edit component
|
||||
|
||||
Args:
|
||||
@@ -223,7 +223,7 @@ class ASubWindowFeatures(object):
|
||||
"""
|
||||
return self.find(QTextEdit, name).toHtml()
|
||||
|
||||
def set_plaintext_edit_text(self, name:str, text:str):
|
||||
def set_plaintext_edit_text(self, name: str, text: str):
|
||||
"""Set text of text edit component
|
||||
|
||||
Args:
|
||||
@@ -235,7 +235,7 @@ class ASubWindowFeatures(object):
|
||||
"""
|
||||
self.find(QPlainTextEdit, name).setPlainText(text)
|
||||
|
||||
def get_plaintext_edit_text(self, name:str):
|
||||
def get_plaintext_edit_text(self, name: str):
|
||||
"""Get text of text edit component
|
||||
|
||||
Args:
|
||||
@@ -246,7 +246,7 @@ class ASubWindowFeatures(object):
|
||||
"""
|
||||
return self.find(QPlainTextEdit, name).toPlainText()
|
||||
|
||||
def set_check_box(self, name:str, checked:bool):
|
||||
def set_check_box(self, name: str, checked: bool):
|
||||
"""Set status of checkbox component
|
||||
|
||||
Args:
|
||||
@@ -258,7 +258,7 @@ class ASubWindowFeatures(object):
|
||||
"""
|
||||
self.find(QCheckBox, name).setChecked(checked)
|
||||
|
||||
def get_check_box(self, name:str):
|
||||
def get_check_box(self, name: str):
|
||||
"""Get status of checkbox component
|
||||
|
||||
Args:
|
||||
@@ -269,8 +269,7 @@ class ASubWindowFeatures(object):
|
||||
"""
|
||||
return self.find(QCheckBox, name).isChecked()
|
||||
|
||||
|
||||
def set_time_edit(self, name:str, time:str):
|
||||
def set_time_edit(self, name: str, time: str):
|
||||
"""Set time of timeedit component
|
||||
|
||||
Args:
|
||||
@@ -283,7 +282,7 @@ class ASubWindowFeatures(object):
|
||||
qtime = QTime.fromString(time)
|
||||
self.find(QTimeEdit, name).setTime(qtime)
|
||||
|
||||
def get_time_edit(self, name:str):
|
||||
def get_time_edit(self, name: str):
|
||||
"""Get time of timeedit component
|
||||
|
||||
Args:
|
||||
@@ -294,7 +293,7 @@ class ASubWindowFeatures(object):
|
||||
"""
|
||||
return self.find(QTimeEdit, name).time().toString()
|
||||
|
||||
def set_spin_box(self, name:str, value:int):
|
||||
def set_spin_box(self, name: str, value: int):
|
||||
"""Set value of spinbox component
|
||||
|
||||
Args:
|
||||
@@ -306,7 +305,7 @@ class ASubWindowFeatures(object):
|
||||
"""
|
||||
self.find(QSpinBox, name).setValue(value)
|
||||
|
||||
def get_spin_box(self, name:str):
|
||||
def get_spin_box(self, name: str):
|
||||
"""Get time of spin box component
|
||||
|
||||
Args:
|
||||
@@ -317,7 +316,7 @@ class ASubWindowFeatures(object):
|
||||
"""
|
||||
return self.find(QSpinBox, name).value()
|
||||
|
||||
def set_action_checkable(self, name:str, checked:bool):
|
||||
def set_action_checkable(self, name: str, checked: bool):
|
||||
"""Set value of action
|
||||
|
||||
Args:
|
||||
@@ -329,7 +328,7 @@ class ASubWindowFeatures(object):
|
||||
"""
|
||||
self.find(QAction, name).setChecked(checked)
|
||||
|
||||
def get_action_checkable(self, name:str):
|
||||
def get_action_checkable(self, name: str):
|
||||
"""Get status of action
|
||||
|
||||
Args:
|
||||
@@ -340,8 +339,7 @@ class ASubWindowFeatures(object):
|
||||
"""
|
||||
return self.find(QAction, name).isChecked()
|
||||
|
||||
|
||||
def set_push_button_checkable(self, name:str, checked:bool):
|
||||
def set_push_button_checkable(self, name: str, checked: bool):
|
||||
"""Set value of push button component
|
||||
|
||||
Args:
|
||||
@@ -353,7 +351,7 @@ class ASubWindowFeatures(object):
|
||||
"""
|
||||
self.find(QPushButton, name).setChecked(checked)
|
||||
|
||||
def get_push_button_checkable(self, name:str):
|
||||
def get_push_button_checkable(self, name: str):
|
||||
"""Get status of push button
|
||||
|
||||
Args:
|
||||
@@ -364,7 +362,7 @@ class ASubWindowFeatures(object):
|
||||
"""
|
||||
return self.find(QPushButton, name).isChecked()
|
||||
|
||||
def set_radio_button(self, name:str, checked:bool):
|
||||
def set_radio_button(self, name: str, checked: bool):
|
||||
"""Set value of radio button component
|
||||
|
||||
Args:
|
||||
@@ -376,7 +374,7 @@ class ASubWindowFeatures(object):
|
||||
"""
|
||||
self.find(QRadioButton, name).setChecked(checked)
|
||||
|
||||
def get_radio_button(self, name:str):
|
||||
def get_radio_button(self, name: str):
|
||||
"""Get status of radio button
|
||||
|
||||
Args:
|
||||
@@ -387,7 +385,7 @@ class ASubWindowFeatures(object):
|
||||
"""
|
||||
return self.find(QRadioButton, name).isChecked()
|
||||
|
||||
def combobox_add_item(self, name:str, item:str):
|
||||
def combobox_add_item(self, name: str, item: str):
|
||||
"""Add item in combo box
|
||||
|
||||
Args:
|
||||
@@ -399,7 +397,7 @@ class ASubWindowFeatures(object):
|
||||
"""
|
||||
self.find(QComboBox, name).addItem(item)
|
||||
|
||||
def combobox_add_items(self, name:str, items:str):
|
||||
def combobox_add_items(self, name: str, items: str):
|
||||
"""Add item in combo box
|
||||
|
||||
Args:
|
||||
@@ -412,7 +410,7 @@ class ASubWindowFeatures(object):
|
||||
for item in items:
|
||||
self.find(QComboBox, name).addItem(item)
|
||||
|
||||
def set_combobox_text(self, name:str, item:str):
|
||||
def set_combobox_text(self, name: str, item: str):
|
||||
"""Set current text of combo box
|
||||
|
||||
Args:
|
||||
@@ -424,7 +422,7 @@ class ASubWindowFeatures(object):
|
||||
"""
|
||||
self.find(QComboBox, name).setCurrentText(item)
|
||||
|
||||
def get_combobox_text(self, name:str):
|
||||
def get_combobox_text(self, name: str):
|
||||
"""Get current text of combo box
|
||||
|
||||
Args:
|
||||
@@ -435,7 +433,7 @@ class ASubWindowFeatures(object):
|
||||
"""
|
||||
return self.find(QComboBox, name).currentText()
|
||||
|
||||
def get_datetime_edit(self, name:str):
|
||||
def get_datetime_edit(self, name: str):
|
||||
"""Get datetime of datetime edit
|
||||
|
||||
Args:
|
||||
@@ -446,7 +444,7 @@ class ASubWindowFeatures(object):
|
||||
"""
|
||||
return self.find(QDateTimeEdit, name).dateTime().toPyDateTime()
|
||||
|
||||
def set_datetime_edit(self, name:str, date:datetime):
|
||||
def set_datetime_edit(self, name: str, date: datetime):
|
||||
"""Set datetime of a datetime edit
|
||||
|
||||
Args:
|
||||
@@ -500,6 +498,7 @@ class ASubMainWindow(QMainWindow, ASubWindowFeatures, WindowToolKit):
|
||||
|
||||
return self.ui.findChild(qtype, name)
|
||||
|
||||
|
||||
class ASubWindow(QDialog, ASubWindowFeatures, WindowToolKit):
|
||||
def __init__(self, name="", ui="dummy", parent=None, **kwargs):
|
||||
super(ASubWindow, self).__init__(parent=parent)
|
||||
@@ -536,6 +535,7 @@ class ASubWindow(QDialog, ASubWindowFeatures, WindowToolKit):
|
||||
|
||||
return self.ui.findChild(qtype, name)
|
||||
|
||||
|
||||
class AWidget(QWidget, ASubWindowFeatures):
|
||||
def __init__(self, ui="", parent=None):
|
||||
super(AWidget, self).__init__(parent=parent)
|
||||
|
||||
@@ -21,6 +21,7 @@ from functools import reduce
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
|
||||
class ListedSubWindow(object):
|
||||
def __init__(self, **kwargs):
|
||||
super(ListedSubWindow, self).__init__()
|
||||
@@ -37,7 +38,8 @@ class ListedSubWindow(object):
|
||||
self.sub_win_list.append((name, win))
|
||||
self.sub_win_cnt += 1
|
||||
try:
|
||||
logger.info(f"Open window: {name}: {self.sub_win_cnt}: {win.hash()}")
|
||||
logger.info(
|
||||
f"Open window: {name}: {self.sub_win_cnt}: {win.hash()}")
|
||||
except:
|
||||
logger.info(f"Open window: {name}: {self.sub_win_cnt}: X")
|
||||
|
||||
@@ -75,7 +77,7 @@ class ListedSubWindow(object):
|
||||
False
|
||||
)
|
||||
|
||||
def sub_win_exists(self, name, contain = []):
|
||||
def sub_win_exists(self, name, contain=[]):
|
||||
if contain == []:
|
||||
return self._sub_win_exists(name)
|
||||
else:
|
||||
|
||||
@@ -32,6 +32,7 @@ from View.Tools.PamhyrWidget import (
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
|
||||
class PamhyrExTimeDelegate(QItemDelegate):
|
||||
def __init__(self, data=None, mode="time", parent=None):
|
||||
super(PamhyrExTimeDelegate, self).__init__(parent)
|
||||
|
||||
@@ -20,6 +20,7 @@ from View.Tools.Plot.APlot import APlot
|
||||
from View.Tools.Plot.PamhyrCanvas import MplCanvas
|
||||
from View.Tools.Plot.PamhyrToolbar import PamhyrPlotToolbar
|
||||
|
||||
|
||||
class PamhyrPlot(APlot):
|
||||
def __init__(self, data=None, trad=None,
|
||||
canvas=None, toolbar=None,
|
||||
@@ -32,7 +33,7 @@ class PamhyrPlot(APlot):
|
||||
self._toolbar = toolbar
|
||||
self._parent = parent
|
||||
|
||||
super(PamhyrPlot, self).__init__(data = data)
|
||||
super(PamhyrPlot, self).__init__(data=data)
|
||||
|
||||
@property
|
||||
def canvas(self):
|
||||
|
||||
@@ -57,6 +57,7 @@ class PamhyrTextDelegate(QStyledItemDelegate):
|
||||
def updateEditorGeometry(self, editor, option, index):
|
||||
editor.setGeometry(option.rect)
|
||||
|
||||
|
||||
class PamhyrTableModel(QAbstractTableModel):
|
||||
def _setup_delegates(self):
|
||||
if self._table_view is None:
|
||||
@@ -75,14 +76,14 @@ class PamhyrTableModel(QAbstractTableModel):
|
||||
)
|
||||
|
||||
def __init__(self,
|
||||
table_view = None,
|
||||
table_headers = {},
|
||||
editable_headers = [],
|
||||
delegates = {},
|
||||
trad = None,
|
||||
data = None,
|
||||
undo = None,
|
||||
opt_data = None):
|
||||
table_view=None,
|
||||
table_headers={},
|
||||
editable_headers=[],
|
||||
delegates={},
|
||||
trad=None,
|
||||
data=None,
|
||||
undo=None,
|
||||
opt_data=None):
|
||||
super(PamhyrTableModel, self).__init__()
|
||||
|
||||
self._table_view = table_view
|
||||
@@ -112,14 +113,13 @@ class PamhyrTableModel(QAbstractTableModel):
|
||||
self._table_view.setAlternatingRowColors(True)
|
||||
self._table_view.resizeColumnsToContents()
|
||||
|
||||
|
||||
def flags(self, index):
|
||||
column = index.column()
|
||||
|
||||
options = Qt.ItemIsEnabled | Qt.ItemIsSelectable
|
||||
|
||||
if (self._editable_headers or
|
||||
self._headers[column] in self._editable_headers):
|
||||
self._headers[column] in self._editable_headers):
|
||||
options |= Qt.ItemIsEditable
|
||||
|
||||
return options
|
||||
|
||||
@@ -32,14 +32,15 @@ from View.Tools.ASubWindow import AWidget
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
|
||||
class PamhyrWidget(AWidget):
|
||||
_pamhyr_ui = None
|
||||
_pamhyr_name = "PamhyrWidget"
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super(PamhyrWidget, self).__init__(
|
||||
ui = self._pamhyr_ui,
|
||||
parent = parent
|
||||
ui=self._pamhyr_ui,
|
||||
parent=parent
|
||||
)
|
||||
|
||||
|
||||
@@ -83,6 +84,7 @@ class PamhyrExtendedTimeEdit(AWidget):
|
||||
|
||||
return timedelta(days=days, seconds=secs)
|
||||
|
||||
|
||||
class PamhyrExtendedDateTimeEdit(AWidget):
|
||||
def __init__(self, parent=None):
|
||||
super(ExtendedDateTimeEdit, self).__init__(
|
||||
|
||||
@@ -31,8 +31,9 @@ from View.Tools.ListedSubWindow import ListedSubWindow
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
|
||||
class PamhyrWindowTools(object):
|
||||
def __init__(self, options = ["undo", "copy"], parent = None, **kwargs):
|
||||
def __init__(self, options=["undo", "copy"], parent=None, **kwargs):
|
||||
super(PamhyrWindowTools, self).__init__()
|
||||
|
||||
self._hash_data = []
|
||||
@@ -139,10 +140,10 @@ class PamhyrWindow(ASubMainWindow, ListedSubWindow, PamhyrWindowTools):
|
||||
_pamhyr_name = "PamhyrWindow"
|
||||
|
||||
def __init__(self,
|
||||
title = "Pamhyr2",
|
||||
study = None, config = None, trad = None,
|
||||
options = ["undo", "copy"],
|
||||
parent = None):
|
||||
title="Pamhyr2",
|
||||
study=None, config=None, trad=None,
|
||||
options=["undo", "copy"],
|
||||
parent=None):
|
||||
self._title = title
|
||||
self._study = study
|
||||
self._config = config
|
||||
@@ -150,9 +151,9 @@ class PamhyrWindow(ASubMainWindow, ListedSubWindow, PamhyrWindowTools):
|
||||
self._parent = parent
|
||||
|
||||
super(PamhyrWindow, self).__init__(
|
||||
name = self._pamhyr_name,
|
||||
ui = self._pamhyr_ui,
|
||||
parent = parent,
|
||||
name=self._pamhyr_name,
|
||||
ui=self._pamhyr_ui,
|
||||
parent=parent,
|
||||
)
|
||||
|
||||
self._hash_data.append(self._study)
|
||||
@@ -166,10 +167,10 @@ class PamhyrDialog(ASubWindow, ListedSubWindow, PamhyrWindowTools):
|
||||
_pamhyr_name = "PamhyrWindow"
|
||||
|
||||
def __init__(self,
|
||||
title = "Pamhyr2",
|
||||
study = None, config = None, trad = None,
|
||||
options = ["undo", "copy"],
|
||||
parent = None):
|
||||
title="Pamhyr2",
|
||||
study=None, config=None, trad=None,
|
||||
options=["undo", "copy"],
|
||||
parent=None):
|
||||
self._title = title
|
||||
self._study = study
|
||||
self._config = config
|
||||
@@ -177,9 +178,9 @@ class PamhyrDialog(ASubWindow, ListedSubWindow, PamhyrWindowTools):
|
||||
self._parent = parent
|
||||
|
||||
super(PamhyrDialog, self).__init__(
|
||||
name = self._pamhyr_name,
|
||||
ui = self._pamhyr_ui,
|
||||
parent = parent,
|
||||
name=self._pamhyr_name,
|
||||
ui=self._pamhyr_ui,
|
||||
parent=parent,
|
||||
)
|
||||
|
||||
self._hash_data.append(self._study)
|
||||
|
||||
Loaded 100 of 152 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user