mirror of https://gitlab.com/pamhyr/pamhyr2
refactoring: refacto SL list & edit.
parent
4ce597a2a0
commit
1d45ccb8b8
|
|
@ -50,7 +50,7 @@ from View.LateralContribution.Window import LateralContributionWindow
|
||||||
from View.InitialConditions.Window import InitialConditionsWindow
|
from View.InitialConditions.Window import InitialConditionsWindow
|
||||||
from View.Stricklers.Window import StricklersWindow
|
from View.Stricklers.Window import StricklersWindow
|
||||||
from View.Frictions.Window import FrictionsWindow
|
from View.Frictions.Window import FrictionsWindow
|
||||||
# from View.SedimentLayers.Window import SedimentLayersWindow
|
from View.SedimentLayers.Window import SedimentLayersWindow
|
||||||
# from View.SedimentLayers.Reach.Window import ReachSedimentLayersWindow
|
# from View.SedimentLayers.Reach.Window import ReachSedimentLayersWindow
|
||||||
# from View.SolverParameters.Window import SolverParametersWindow
|
# from View.SolverParameters.Window import SolverParametersWindow
|
||||||
# from View.RunSolver.Window import SelectSolverWindow, SolverLogWindow
|
# from View.RunSolver.Window import SelectSolverWindow, SolverLogWindow
|
||||||
|
|
|
||||||
|
|
@ -5,23 +5,19 @@ import logging
|
||||||
from functools import reduce
|
from functools import reduce
|
||||||
|
|
||||||
from tools import timer
|
from tools import timer
|
||||||
from View.Plot.APlot import APlot
|
from View.Tools.PamhyrPlot import PamhyrPlot
|
||||||
|
|
||||||
from PyQt5.QtCore import (
|
|
||||||
QCoreApplication
|
|
||||||
)
|
|
||||||
|
|
||||||
_translate = QCoreApplication.translate
|
|
||||||
|
|
||||||
logger = logging.getLogger()
|
logger = logging.getLogger()
|
||||||
|
|
||||||
class Plot(APlot):
|
class Plot(PamhyrPlot):
|
||||||
def __init__(self, canvas=None, data=None, toolbar=None,
|
def __init__(self, canvas=None, trad=None, data=None, toolbar=None,
|
||||||
display_current=True):
|
display_current=True, parent=None):
|
||||||
super(Plot, self).__init__(
|
super(Plot, self).__init__(
|
||||||
canvas=canvas,
|
canvas = canvas,
|
||||||
data=data,
|
trad = trad,
|
||||||
toolbar=toolbar
|
data = data,
|
||||||
|
toolbar = toolbar,
|
||||||
|
parent = parent
|
||||||
)
|
)
|
||||||
|
|
||||||
self._display_current = display_current
|
self._display_current = display_current
|
||||||
|
|
@ -34,13 +30,9 @@ class Plot(APlot):
|
||||||
self.canvas.axes.cla()
|
self.canvas.axes.cla()
|
||||||
self.canvas.axes.grid(color='grey', linestyle='--', linewidth=0.5)
|
self.canvas.axes.grid(color='grey', linestyle='--', linewidth=0.5)
|
||||||
|
|
||||||
# self.canvas.axes.set_xlabel(
|
|
||||||
# _translate("MainWindow_reach", "X (m)"),
|
|
||||||
# color='green', fontsize=12
|
|
||||||
# )
|
|
||||||
self.canvas.axes.axes.get_xaxis().set_visible(False)
|
self.canvas.axes.axes.get_xaxis().set_visible(False)
|
||||||
self.canvas.axes.set_ylabel(
|
self.canvas.axes.set_ylabel(
|
||||||
_translate("MainWindow_reach", "Height (m)"),
|
self._trad["height"],
|
||||||
color='green', fontsize=12
|
color='green', fontsize=12
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,32 +15,14 @@ from PyQt5.QtWidgets import (
|
||||||
QComboBox,
|
QComboBox,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
from View.Tools.PamhyrTable import PamhyrTableModel
|
||||||
|
|
||||||
from View.SedimentLayers.Edit.UndoCommand import *
|
from View.SedimentLayers.Edit.UndoCommand import *
|
||||||
from View.SedimentLayers.Edit.translate import *
|
|
||||||
|
|
||||||
_translate = QCoreApplication.translate
|
_translate = QCoreApplication.translate
|
||||||
|
|
||||||
|
|
||||||
class TableModel(QAbstractTableModel):
|
class TableModel(PamhyrTableModel):
|
||||||
def __init__(self, study=None, sl=None, undo=None):
|
|
||||||
super(QAbstractTableModel, self).__init__()
|
|
||||||
self._headers = list(table_headers.keys())
|
|
||||||
self._study = study
|
|
||||||
self._undo = undo
|
|
||||||
self._sl = sl
|
|
||||||
|
|
||||||
def flags(self, index):
|
|
||||||
options = Qt.ItemIsEnabled | Qt.ItemIsSelectable
|
|
||||||
options |= Qt.ItemIsEditable
|
|
||||||
|
|
||||||
return options
|
|
||||||
|
|
||||||
def rowCount(self, parent):
|
|
||||||
return len(self._sl)
|
|
||||||
|
|
||||||
def columnCount(self, parent):
|
|
||||||
return len(self._headers)
|
|
||||||
|
|
||||||
def data(self, index, role):
|
def data(self, index, role):
|
||||||
if role != Qt.ItemDataRole.DisplayRole:
|
if role != Qt.ItemDataRole.DisplayRole:
|
||||||
return QVariant()
|
return QVariant()
|
||||||
|
|
@ -49,23 +31,17 @@ class TableModel(QAbstractTableModel):
|
||||||
column = index.column()
|
column = index.column()
|
||||||
|
|
||||||
if self._headers[column] == "name":
|
if self._headers[column] == "name":
|
||||||
return self._sl.get(row).name
|
return self._data.get(row).name
|
||||||
elif self._headers[column] == "type":
|
elif self._headers[column] == "type":
|
||||||
return self._sl.get(row).type
|
return self._data.get(row).type
|
||||||
elif self._headers[column] == "height":
|
elif self._headers[column] == "height":
|
||||||
return self._sl.get(row).height
|
return self._data.get(row).height
|
||||||
elif self._headers[column] == "d50":
|
elif self._headers[column] == "d50":
|
||||||
return self._sl.get(row).d50
|
return self._data.get(row).d50
|
||||||
elif self._headers[column] == "sigma":
|
elif self._headers[column] == "sigma":
|
||||||
return self._sl.get(row).sigma
|
return self._data.get(row).sigma
|
||||||
elif self._headers[column] == "critical_constraint":
|
elif self._headers[column] == "critical_constraint":
|
||||||
return self._sl.get(row).critical_constraint
|
return self._data.get(row).critical_constraint
|
||||||
|
|
||||||
return QVariant()
|
|
||||||
|
|
||||||
def headerData(self, friction, orientation, role):
|
|
||||||
if role == Qt.ItemDataRole.DisplayRole and orientation == Qt.Orientation.Horizontal:
|
|
||||||
return table_headers[self._headers[friction]]
|
|
||||||
|
|
||||||
return QVariant()
|
return QVariant()
|
||||||
|
|
||||||
|
|
@ -79,37 +55,37 @@ class TableModel(QAbstractTableModel):
|
||||||
if self._headers[column] == "name":
|
if self._headers[column] == "name":
|
||||||
self._undo.push(
|
self._undo.push(
|
||||||
SetNameCommand(
|
SetNameCommand(
|
||||||
self._sl, row, value
|
self._data, row, value
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
if self._headers[column] == "type":
|
if self._headers[column] == "type":
|
||||||
self._undo.push(
|
self._undo.push(
|
||||||
SetTypeCommand(
|
SetTypeCommand(
|
||||||
self._sl, row, value
|
self._data, row, value
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
if self._headers[column] == "height":
|
if self._headers[column] == "height":
|
||||||
self._undo.push(
|
self._undo.push(
|
||||||
SetHeightCommand(
|
SetHeightCommand(
|
||||||
self._sl, row, value
|
self._data, row, value
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
if self._headers[column] == "d50":
|
if self._headers[column] == "d50":
|
||||||
self._undo.push(
|
self._undo.push(
|
||||||
SetD50Command(
|
SetD50Command(
|
||||||
self._sl, row, value
|
self._data, row, value
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
if self._headers[column] == "sigma":
|
if self._headers[column] == "sigma":
|
||||||
self._undo.push(
|
self._undo.push(
|
||||||
SetSigmaCommand(
|
SetSigmaCommand(
|
||||||
self._sl, row, value
|
self._data, row, value
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
if self._headers[column] == "critical_constraint":
|
if self._headers[column] == "critical_constraint":
|
||||||
self._undo.push(
|
self._undo.push(
|
||||||
SetCriticalConstraintCommand(
|
SetCriticalConstraintCommand(
|
||||||
self._sl, row, value
|
self._data, row, value
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -121,7 +97,7 @@ class TableModel(QAbstractTableModel):
|
||||||
|
|
||||||
self._undo.push(
|
self._undo.push(
|
||||||
AddCommand(
|
AddCommand(
|
||||||
self._sl, row
|
self._data, row
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -133,7 +109,7 @@ class TableModel(QAbstractTableModel):
|
||||||
|
|
||||||
self._undo.push(
|
self._undo.push(
|
||||||
DelCommand(
|
DelCommand(
|
||||||
self._sl, rows
|
self._data, rows
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -150,7 +126,7 @@ class TableModel(QAbstractTableModel):
|
||||||
|
|
||||||
self._undo.push(
|
self._undo.push(
|
||||||
MoveCommand(
|
MoveCommand(
|
||||||
self._sl, "up", row
|
self._data, "up", row
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -158,7 +134,7 @@ class TableModel(QAbstractTableModel):
|
||||||
self.layoutChanged.emit()
|
self.layoutChanged.emit()
|
||||||
|
|
||||||
def move_down(self, row, parent=QModelIndex()):
|
def move_down(self, row, parent=QModelIndex()):
|
||||||
if row + 1 >= len(self._sl):
|
if row + 1 >= len(self._data):
|
||||||
return
|
return
|
||||||
|
|
||||||
target = row
|
target = row
|
||||||
|
|
@ -167,7 +143,7 @@ class TableModel(QAbstractTableModel):
|
||||||
|
|
||||||
self._undo.push(
|
self._undo.push(
|
||||||
MoveCommand(
|
MoveCommand(
|
||||||
self._sl, "down", row
|
self._data, "down", row
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,13 +39,13 @@ from PyQt5.QtWidgets import (
|
||||||
QComboBox, QVBoxLayout, QHeaderView, QTabWidget,
|
QComboBox, QVBoxLayout, QHeaderView, QTabWidget,
|
||||||
)
|
)
|
||||||
|
|
||||||
from View.Plot.MplCanvas import MplCanvas
|
from View.Tools.Plot.PamhyrCanvas import MplCanvas
|
||||||
from View.Plot.PamhyrToolbar import PamhyrPlotToolbar
|
from View.Tools.Plot.PamhyrToolbar import PamhyrPlotToolbar
|
||||||
|
|
||||||
from View.SedimentLayers.Edit.UndoCommand import *
|
from View.SedimentLayers.Edit.UndoCommand import *
|
||||||
from View.SedimentLayers.Edit.Table import *
|
from View.SedimentLayers.Edit.Table import *
|
||||||
from View.SedimentLayers.Edit.Plot import Plot
|
from View.SedimentLayers.Edit.Plot import Plot
|
||||||
from View.SedimentLayers.Edit.translate import table_headers, retranslate
|
from View.SedimentLayers.Edit.translate import SedimentEditTranslate
|
||||||
|
|
||||||
_translate = QCoreApplication.translate
|
_translate = QCoreApplication.translate
|
||||||
|
|
||||||
|
|
@ -71,7 +71,8 @@ class EditSedimentLayersWindow(PamhyrWindow):
|
||||||
title = name,
|
title = name,
|
||||||
study = study,
|
study = study,
|
||||||
config = config,
|
config = config,
|
||||||
parent=parent
|
trad = SedimentEditTranslate(),
|
||||||
|
parent = parent
|
||||||
)
|
)
|
||||||
|
|
||||||
self.setup_table()
|
self.setup_table()
|
||||||
|
|
@ -79,17 +80,17 @@ class EditSedimentLayersWindow(PamhyrWindow):
|
||||||
self.setup_connections()
|
self.setup_connections()
|
||||||
|
|
||||||
def setup_table(self):
|
def setup_table(self):
|
||||||
retranslate()
|
table_headers = self._trad.get_dict("table_headers")
|
||||||
self._table = {}
|
|
||||||
|
|
||||||
table = self.find(QTableView, f"tableView")
|
table = self.find(QTableView, f"tableView")
|
||||||
self._table = TableModel(
|
self._table = TableModel(
|
||||||
study = self._study,
|
table_view = table,
|
||||||
sl = self._sl,
|
table_headers = table_headers,
|
||||||
|
editable_headers = list(table_headers),
|
||||||
|
data = self._sl,
|
||||||
|
trad = self._trad,
|
||||||
undo = self._undo_stack,
|
undo = self._undo_stack,
|
||||||
)
|
)
|
||||||
table.setModel(self._table)
|
table.setModel(self._table)
|
||||||
|
|
||||||
table.setSelectionBehavior(QAbstractItemView.SelectRows)
|
table.setSelectionBehavior(QAbstractItemView.SelectRows)
|
||||||
table.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch)
|
table.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch)
|
||||||
table.setAlternatingRowColors(True)
|
table.setAlternatingRowColors(True)
|
||||||
|
|
@ -110,6 +111,7 @@ class EditSedimentLayersWindow(PamhyrWindow):
|
||||||
canvas = self.canvas,
|
canvas = self.canvas,
|
||||||
data = self._sl,
|
data = self._sl,
|
||||||
toolbar = self.toolbar,
|
toolbar = self.toolbar,
|
||||||
|
trad = self._trad,
|
||||||
display_current = False
|
display_current = False
|
||||||
)
|
)
|
||||||
self.plot.draw()
|
self.plot.draw()
|
||||||
|
|
|
||||||
|
|
@ -2,21 +2,21 @@
|
||||||
|
|
||||||
from PyQt5.QtCore import QCoreApplication
|
from PyQt5.QtCore import QCoreApplication
|
||||||
|
|
||||||
|
from View.SedimentLayers.translate import SedimentTranslate
|
||||||
|
|
||||||
_translate = QCoreApplication.translate
|
_translate = QCoreApplication.translate
|
||||||
|
|
||||||
table_headers = {
|
class SedimentEditTranslate(SedimentTranslate):
|
||||||
|
def __init__(self):
|
||||||
|
super(SedimentEditTranslate, self).__init__()
|
||||||
|
|
||||||
|
self._dict["height"] = _translate("SedimentLayers", "Height (m)"),
|
||||||
|
|
||||||
|
self._sub_dict["table_headers"] = {
|
||||||
"name": _translate("SedimentLayers", "Name"),
|
"name": _translate("SedimentLayers", "Name"),
|
||||||
# "type": _translate("SedimentLayers", "Type"),
|
# "type": _translate("SedimentLayers", "Type"),
|
||||||
"height": _translate("SedimentLayers", "Height"),
|
"height": _translate("SedimentLayers", "Height"),
|
||||||
"d50": _translate("SedimentLayers", "D50"),
|
"d50": _translate("SedimentLayers", "D50"),
|
||||||
"sigma": _translate("SedimentLayers", "Sigma"),
|
"sigma": _translate("SedimentLayers", "Sigma"),
|
||||||
"critical_constraint": _translate("SedimentLayers", "Critical constraint"),
|
"critical_constraint": _translate("SedimentLayers", "Critical constraint"),
|
||||||
}
|
}
|
||||||
|
|
||||||
def retranslate():
|
|
||||||
table_headers["name"] = _translate("SedimentLayers", "Name")
|
|
||||||
# table_headers["type"] = _translate("SedimentLayers", "Type")
|
|
||||||
table_headers["height"] = _translate("SedimentLayers", "Height")
|
|
||||||
table_headers["d50"] = _translate("SedimentLayers", "D50")
|
|
||||||
table_headers["sigma"] = _translate("SedimentLayers", "Sigma")
|
|
||||||
table_headers["critical_constraint"] = _translate("SedimentLayers", "Critical constraint")
|
|
||||||
|
|
|
||||||
|
|
@ -15,32 +15,12 @@ from PyQt5.QtWidgets import (
|
||||||
QComboBox,
|
QComboBox,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
from View.Tools.PamhyrTable import PamhyrTableModel
|
||||||
|
|
||||||
from View.SedimentLayers.UndoCommand import *
|
from View.SedimentLayers.UndoCommand import *
|
||||||
from View.SedimentLayers.translate import *
|
|
||||||
|
|
||||||
_translate = QCoreApplication.translate
|
|
||||||
|
|
||||||
|
|
||||||
class TableModel(QAbstractTableModel):
|
class TableModel(PamhyrTableModel):
|
||||||
def __init__(self, study=None, undo=None):
|
|
||||||
super(QAbstractTableModel, self).__init__()
|
|
||||||
self._headers = list(table_headers.keys())
|
|
||||||
self._study = study
|
|
||||||
self._undo = undo
|
|
||||||
self._sl = self._study.river.sediment_layers
|
|
||||||
|
|
||||||
def flags(self, index):
|
|
||||||
options = Qt.ItemIsEnabled | Qt.ItemIsSelectable
|
|
||||||
options |= Qt.ItemIsEditable
|
|
||||||
|
|
||||||
return options
|
|
||||||
|
|
||||||
def rowCount(self, parent):
|
|
||||||
return len(self._sl)
|
|
||||||
|
|
||||||
def columnCount(self, parent):
|
|
||||||
return len(self._headers)
|
|
||||||
|
|
||||||
def data(self, index, role):
|
def data(self, index, role):
|
||||||
if role != Qt.ItemDataRole.DisplayRole:
|
if role != Qt.ItemDataRole.DisplayRole:
|
||||||
return QVariant()
|
return QVariant()
|
||||||
|
|
@ -49,15 +29,9 @@ class TableModel(QAbstractTableModel):
|
||||||
column = index.column()
|
column = index.column()
|
||||||
|
|
||||||
if self._headers[column] == "name":
|
if self._headers[column] == "name":
|
||||||
return self._sl.get(row).name
|
return self._data.get(row).name
|
||||||
elif self._headers[column] == "comment":
|
elif self._headers[column] == "comment":
|
||||||
return self._sl.get(row).comment
|
return self._data.get(row).comment
|
||||||
|
|
||||||
return QVariant()
|
|
||||||
|
|
||||||
def headerData(self, friction, orientation, role):
|
|
||||||
if role == Qt.ItemDataRole.DisplayRole and orientation == Qt.Orientation.Horizontal:
|
|
||||||
return table_headers[self._headers[friction]]
|
|
||||||
|
|
||||||
return QVariant()
|
return QVariant()
|
||||||
|
|
||||||
|
|
@ -71,13 +45,13 @@ class TableModel(QAbstractTableModel):
|
||||||
if self._headers[column] == "name":
|
if self._headers[column] == "name":
|
||||||
self._undo.push(
|
self._undo.push(
|
||||||
SetNameCommand(
|
SetNameCommand(
|
||||||
self._sl, row, value
|
self._data, row, value
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
if self._headers[column] == "comment":
|
if self._headers[column] == "comment":
|
||||||
self._undo.push(
|
self._undo.push(
|
||||||
SetCommentCommand(
|
SetCommentCommand(
|
||||||
self._sl, row, value
|
self._data, row, value
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -89,7 +63,7 @@ class TableModel(QAbstractTableModel):
|
||||||
|
|
||||||
self._undo.push(
|
self._undo.push(
|
||||||
AddCommand(
|
AddCommand(
|
||||||
self._sl, row
|
self._data, row
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -101,7 +75,7 @@ class TableModel(QAbstractTableModel):
|
||||||
|
|
||||||
self._undo.push(
|
self._undo.push(
|
||||||
DelCommand(
|
DelCommand(
|
||||||
self._sl, rows
|
self._data, rows
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -118,7 +92,7 @@ class TableModel(QAbstractTableModel):
|
||||||
|
|
||||||
self._undo_stack.push(
|
self._undo_stack.push(
|
||||||
MoveCommand(
|
MoveCommand(
|
||||||
self._sl, "up", row
|
self._data, "up", row
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -126,7 +100,7 @@ class TableModel(QAbstractTableModel):
|
||||||
self.layoutChanged.emit()
|
self.layoutChanged.emit()
|
||||||
|
|
||||||
def move_down(self, index, parent=QModelIndex()):
|
def move_down(self, index, parent=QModelIndex()):
|
||||||
if row > len(self._sl):
|
if row > len(self._data):
|
||||||
return
|
return
|
||||||
|
|
||||||
target = row
|
target = row
|
||||||
|
|
@ -135,7 +109,7 @@ class TableModel(QAbstractTableModel):
|
||||||
|
|
||||||
self._undo_stack.push(
|
self._undo_stack.push(
|
||||||
MoveCommand(
|
MoveCommand(
|
||||||
self._sl, "down", row
|
self._data, "down", row
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -44,13 +44,11 @@ from View.SedimentLayers.Table import *
|
||||||
|
|
||||||
from View.SedimentLayers.Edit.Plot import Plot
|
from View.SedimentLayers.Edit.Plot import Plot
|
||||||
|
|
||||||
from View.Plot.MplCanvas import MplCanvas
|
from View.Tools.Plot.PamhyrCanvas import MplCanvas
|
||||||
from View.SedimentLayers.translate import table_headers, retranslate
|
from View.SedimentLayers.translate import SedimentTranslate
|
||||||
|
|
||||||
from View.SedimentLayers.Edit.Window import EditSedimentLayersWindow
|
from View.SedimentLayers.Edit.Window import EditSedimentLayersWindow
|
||||||
|
|
||||||
_translate = QCoreApplication.translate
|
|
||||||
|
|
||||||
logger = logging.getLogger()
|
logger = logging.getLogger()
|
||||||
|
|
||||||
class SedimentLayersWindow(PamhyrWindow):
|
class SedimentLayersWindow(PamhyrWindow):
|
||||||
|
|
@ -68,34 +66,31 @@ class SedimentLayersWindow(PamhyrWindow):
|
||||||
title = name,
|
title = name,
|
||||||
study = study,
|
study = study,
|
||||||
config = config,
|
config = config,
|
||||||
|
trad = SedimentTranslate(),
|
||||||
parent=parent
|
parent=parent
|
||||||
)
|
)
|
||||||
|
|
||||||
self.setup_table()
|
self.setup_table()
|
||||||
self.setup_graph()
|
self.setup_plot()
|
||||||
self.setup_connections()
|
self.setup_connections()
|
||||||
|
|
||||||
def setup_title(self, title):
|
|
||||||
self._title = (
|
|
||||||
title + " - " + self._study.name
|
|
||||||
)
|
|
||||||
|
|
||||||
def setup_table(self):
|
def setup_table(self):
|
||||||
retranslate()
|
|
||||||
|
|
||||||
table = self.find(QTableView, f"tableView")
|
table = self.find(QTableView, f"tableView")
|
||||||
self._table = TableModel(
|
self._table = TableModel(
|
||||||
study = self._study,
|
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,
|
undo = self._undo_stack,
|
||||||
)
|
)
|
||||||
table.setModel(self._table)
|
table.setModel(self._table)
|
||||||
|
|
||||||
table.setSelectionBehavior(QAbstractItemView.SelectRows)
|
table.setSelectionBehavior(QAbstractItemView.SelectRows)
|
||||||
table.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch)
|
table.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch)
|
||||||
table.setAlternatingRowColors(True)
|
table.setAlternatingRowColors(True)
|
||||||
|
|
||||||
def setup_graph(self):
|
def setup_plot(self):
|
||||||
self.canvas = MplCanvas(width=5, height=4, dpi=100)
|
self.canvas = MplCanvas(width=2, height=4, dpi=100)
|
||||||
self.canvas.setObjectName("canvas")
|
self.canvas.setObjectName("canvas")
|
||||||
self.plot_layout = self.find(QVBoxLayout, "verticalLayout")
|
self.plot_layout = self.find(QVBoxLayout, "verticalLayout")
|
||||||
self.plot_layout.addWidget(self.canvas)
|
self.plot_layout.addWidget(self.canvas)
|
||||||
|
|
@ -122,6 +117,7 @@ class SedimentLayersWindow(PamhyrWindow):
|
||||||
self.plot = Plot(
|
self.plot = Plot(
|
||||||
canvas = self.canvas,
|
canvas = self.canvas,
|
||||||
data = self._sediment_layers.get(rows[0]),
|
data = self._sediment_layers.get(rows[0]),
|
||||||
|
trad = self._trad,
|
||||||
toolbar = None,
|
toolbar = None,
|
||||||
display_current = False
|
display_current = False
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -2,13 +2,15 @@
|
||||||
|
|
||||||
from PyQt5.QtCore import QCoreApplication
|
from PyQt5.QtCore import QCoreApplication
|
||||||
|
|
||||||
|
from View.Tools.PamhyrTranslate import PamhyrTranslate
|
||||||
|
|
||||||
_translate = QCoreApplication.translate
|
_translate = QCoreApplication.translate
|
||||||
|
|
||||||
table_headers = {
|
class SedimentTranslate(PamhyrTranslate):
|
||||||
|
def __init__(self):
|
||||||
|
super(SedimentTranslate, self).__init__()
|
||||||
|
|
||||||
|
self._sub_dict["table_headers"] = {
|
||||||
"name": _translate("SedimentLayers", "Name"),
|
"name": _translate("SedimentLayers", "Name"),
|
||||||
"comment": _translate("SedimentLayers", "Comment"),
|
"comment": _translate("SedimentLayers", "Comment"),
|
||||||
}
|
}
|
||||||
|
|
||||||
def retranslate():
|
|
||||||
table_headers["name"] = _translate("SedimentLayers", "Name")
|
|
||||||
table_headers["comment"] = _translate("SedimentLayers", "Comment")
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue