mirror of https://gitlab.com/pamhyr/pamhyr2
refactoring: Add PamhyrWidget and continue refacto using PamhyrWindow.
parent
fa32e42933
commit
cc9f853a34
|
|
@ -23,8 +23,6 @@ from datetime import date, time, datetime, timedelta
|
|||
|
||||
from tools import trace, timer
|
||||
|
||||
from View.ASubWindow import ASubMainWindow, AWidget
|
||||
from View.ListedSubWindow import ListedSubWindow
|
||||
from View.Tools.PamhyrTable import PamhyrTableModel
|
||||
|
||||
from PyQt5.QtCore import (
|
||||
|
|
|
|||
|
|
@ -20,8 +20,8 @@ import logging
|
|||
|
||||
from tools import timer, trace
|
||||
|
||||
from View.ASubWindow import ASubMainWindow, AWidget
|
||||
from View.ListedSubWindow import ListedSubWindow
|
||||
from View.Tools.PamhyrWindow import PamhyrWindow
|
||||
from View.Tools.PamhyrWidget import PamhyrWidget
|
||||
from View.Tools.PamhyrDelegate import PamhyrExTimeDelegate
|
||||
|
||||
from PyQt5.QtGui import (
|
||||
|
|
@ -54,16 +54,16 @@ _translate = QCoreApplication.translate
|
|||
|
||||
logger = logging.getLogger()
|
||||
|
||||
class WD50Sigma(AWidget):
|
||||
class WD50Sigma(PamhyrWidget):
|
||||
_pamhyr_ui = "d50sigma"
|
||||
|
||||
d50Changed = pyqtSignal(float)
|
||||
sigmaChanged = pyqtSignal(float)
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super(WD50Sigma, self).__init__(
|
||||
ui="d50sigma",
|
||||
parent=parent
|
||||
)
|
||||
self.parent = parent
|
||||
|
||||
self.spinBox_d50 = self.find(QDoubleSpinBox, "doubleSpinBox_d50")
|
||||
self.spinBox_sigma = self.find(QDoubleSpinBox, "doubleSpinBox_sigma")
|
||||
|
|
@ -95,45 +95,37 @@ class WD50Sigma(AWidget):
|
|||
def valueChangedSigma(self, value):
|
||||
self.sigmaChanged.emit(value)
|
||||
|
||||
class EditBoundaryConditionWindow(ASubMainWindow, ListedSubWindow):
|
||||
def __init__(self, title="Edit boundary condition",
|
||||
data=None, study=None, parent=None):
|
||||
class EditBoundaryConditionWindow(PamhyrWindow):
|
||||
_pamhyr_ui = "EditBoundaryConditions"
|
||||
_pamhyr_name = "Edit Boundary Conditions"
|
||||
|
||||
def __init__(self, data=None, study=None, config=None, parent=None):
|
||||
self._data = data
|
||||
self._study = study
|
||||
self._title = title
|
||||
|
||||
self.compute_title()
|
||||
|
||||
super(EditBoundaryConditionWindow, self).__init__(
|
||||
name=self._title, ui="EditBoundaryConditions", parent=parent
|
||||
)
|
||||
|
||||
self.ui.setWindowTitle(self._title)
|
||||
|
||||
self.setup_sc()
|
||||
self.setup_table()
|
||||
self.setup_plot()
|
||||
self.setup_data()
|
||||
self.setup_connections()
|
||||
|
||||
def compute_title(self):
|
||||
name = self._pamhyr_name
|
||||
if self._data is not None:
|
||||
node_name = (self._data.node.name if self._data.node is not None
|
||||
else _translate("BoundaryCondition", "Not associate"))
|
||||
self._title = (
|
||||
_translate("Edit boundary condition", self._title) +
|
||||
f" - {self._study.name} " +
|
||||
name = (
|
||||
_translate("Edit boundary condition", self._pamhyr_name) +
|
||||
f" - {study.name} " +
|
||||
f" - {self._data.name} ({self._data.id}) " +
|
||||
f"({long_types[self._data.bctype]} - {node_name})"
|
||||
)
|
||||
|
||||
def setup_sc(self):
|
||||
self._undo_stack = QUndoStack()
|
||||
super(EditBoundaryConditionWindow, self).__init__(
|
||||
title = name,
|
||||
study = study,
|
||||
config = config,
|
||||
parent = parent
|
||||
)
|
||||
|
||||
self.undo_sc = QShortcut(QKeySequence.Undo, self)
|
||||
self.redo_sc = QShortcut(QKeySequence.Redo, self)
|
||||
self.copy_sc = QShortcut(QKeySequence.Copy, self)
|
||||
self.paste_sc = QShortcut(QKeySequence.Paste, self)
|
||||
self.ui.setWindowTitle(self._title)
|
||||
|
||||
self.setup_table()
|
||||
self.setup_plot()
|
||||
self.setup_data()
|
||||
self.setup_connections()
|
||||
|
||||
def setup_data(self):
|
||||
self._is_solid = self._data.bctype == "SL"
|
||||
|
|
@ -193,17 +185,11 @@ class EditBoundaryConditionWindow(ASubMainWindow, ListedSubWindow):
|
|||
)
|
||||
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_sort").triggered.connect(self.sort)
|
||||
|
||||
self.undo_sc.activated.connect(self.undo)
|
||||
self.redo_sc.activated.connect(self.redo)
|
||||
self.copy_sc.activated.connect(self.copy)
|
||||
self.paste_sc.activated.connect(self.paste)
|
||||
|
||||
self._table.dataChanged.connect(self.update)
|
||||
|
||||
if self._is_solid:
|
||||
|
|
@ -252,7 +238,6 @@ class EditBoundaryConditionWindow(ASubMainWindow, ListedSubWindow):
|
|||
)
|
||||
)
|
||||
|
||||
|
||||
def add(self):
|
||||
rows = self.index_selected_rows()
|
||||
if len(self._data) == 0 or len(rows) == 0:
|
||||
|
|
@ -285,7 +270,7 @@ class EditBoundaryConditionWindow(ASubMainWindow, ListedSubWindow):
|
|||
self.plot.update()
|
||||
|
||||
|
||||
def copy(self):
|
||||
def _copy(self):
|
||||
rows = self.index_selected_rows()
|
||||
|
||||
table = []
|
||||
|
|
@ -297,7 +282,7 @@ class EditBoundaryConditionWindow(ASubMainWindow, ListedSubWindow):
|
|||
|
||||
self.copyTableIntoClipboard(table)
|
||||
|
||||
def paste(self):
|
||||
def _paste(self):
|
||||
header, data = self.parseClipboardTable()
|
||||
|
||||
if len(data) == 0:
|
||||
|
|
@ -311,12 +296,12 @@ class EditBoundaryConditionWindow(ASubMainWindow, ListedSubWindow):
|
|||
self._table.paste(row, header, data)
|
||||
self.plot.update()
|
||||
|
||||
def undo(self):
|
||||
def _undo(self):
|
||||
self._table.undo()
|
||||
self.plot.update()
|
||||
self.widget_update()
|
||||
|
||||
def redo(self):
|
||||
def _redo(self):
|
||||
self._table.redo()
|
||||
self.plot.update()
|
||||
self.widget_update()
|
||||
|
|
|
|||
|
|
@ -20,8 +20,7 @@ import logging
|
|||
|
||||
from tools import trace, timer
|
||||
|
||||
from View.ASubWindow import ASubMainWindow
|
||||
from View.ListedSubWindow import ListedSubWindow
|
||||
from View.Tools.PamhyrWindow import PamhyrWindow
|
||||
|
||||
from PyQt5.QtGui import (
|
||||
QKeySequence,
|
||||
|
|
@ -63,32 +62,28 @@ _translate = QCoreApplication.translate
|
|||
|
||||
logger = logging.getLogger()
|
||||
|
||||
class BoundaryConditionWindow(ASubMainWindow, ListedSubWindow):
|
||||
def __init__(self, title="Boundary conditions", study=None, parent=None):
|
||||
self._title = title + " - " + study.name
|
||||
class BoundaryConditionWindow(PamhyrWindow):
|
||||
_pamhyr_ui = "BoundaryConditions"
|
||||
_pamhyr_name = "Boundary conditions"
|
||||
|
||||
def __init__(self, study=None, config=None, parent=None):
|
||||
name = self._pamhyr_name + " - " + study.name
|
||||
|
||||
super(BoundaryConditionWindow, self).__init__(
|
||||
name=title, ui="BoundaryConditions", parent=parent
|
||||
title = name,
|
||||
study = study,
|
||||
config = config,
|
||||
parent=parent
|
||||
)
|
||||
|
||||
self._study = study
|
||||
self._bcs = self._study.river.boundary_condition
|
||||
|
||||
self.setup_sc()
|
||||
self.setup_table()
|
||||
self.setup_graph()
|
||||
self.setup_connections()
|
||||
|
||||
self.ui.setWindowTitle(self._title)
|
||||
|
||||
def setup_sc(self):
|
||||
self._undo_stack = QUndoStack()
|
||||
|
||||
self.undo_sc = QShortcut(QKeySequence.Undo, self)
|
||||
self.redo_sc = QShortcut(QKeySequence.Redo, self)
|
||||
self.copy_sc = QShortcut(QKeySequence.Copy, self)
|
||||
self.paste_sc = QShortcut(QKeySequence.Paste, self)
|
||||
|
||||
def setup_table(self):
|
||||
retranslate()
|
||||
self._table = {}
|
||||
|
|
@ -141,11 +136,6 @@ class BoundaryConditionWindow(ASubMainWindow, ListedSubWindow):
|
|||
self.find(QAction, "action_edit").triggered.connect(self.edit)
|
||||
self.find(QAction, "action_sort").triggered.connect(self.sort)
|
||||
|
||||
self.undo_sc.activated.connect(self.undo)
|
||||
self.redo_sc.activated.connect(self.redo)
|
||||
self.copy_sc.activated.connect(self.copy)
|
||||
self.paste_sc.activated.connect(self.paste)
|
||||
|
||||
def current_tab(self):
|
||||
return self.find(QTabWidget, "tabWidget")\
|
||||
.currentWidget()\
|
||||
|
|
@ -202,17 +192,17 @@ class BoundaryConditionWindow(ASubMainWindow, ListedSubWindow):
|
|||
row = self.index_selected_row()
|
||||
self._table[tab].move_down(row)
|
||||
|
||||
def copy(self):
|
||||
def _copy(self):
|
||||
logger.info("TODO: copy")
|
||||
|
||||
def paste(self):
|
||||
def _paste(self):
|
||||
logger.info("TODO: paste")
|
||||
|
||||
def undo(self):
|
||||
def _undo(self):
|
||||
tab = self.current_tab()
|
||||
self._table[tab].undo()
|
||||
|
||||
def redo(self):
|
||||
def _redo(self):
|
||||
tab = self.current_tab()
|
||||
self._table[tab].redo()
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,8 @@ from PyQt5.QtWidgets import (
|
|||
from Model.Geometry.Reach import Reach
|
||||
from Model.Geometry.ProfileXYZ import ProfileXYZ
|
||||
|
||||
from View.ASubWindow import ASubMainWindow
|
||||
from View.Tools.ASubWindow import ASubMainWindow
|
||||
|
||||
from View.Geometry.Profile.mainwindow_ui_profile import Ui_MainWindow
|
||||
from View.Geometry.Profile.Plot import Plot
|
||||
from View.Geometry.Profile.Table import *
|
||||
|
|
|
|||
|
|
@ -41,8 +41,9 @@ from View.Geometry.PlotXY import PlotXY
|
|||
from View.Geometry.PlotKPZ import PlotKPZ
|
||||
from View.Geometry.PlotAC import PlotAC
|
||||
|
||||
from View.ASubWindow import ASubMainWindow, WindowToolKit
|
||||
from View.ListedSubWindow import ListedSubWindow
|
||||
from View.Tools.ASubWindow import ASubMainWindow, WindowToolKit
|
||||
from View.Tools.ListedSubWindow import ListedSubWindow
|
||||
|
||||
from View.Geometry.mainwindow_ui_reach import Ui_MainWindow
|
||||
from View.Geometry.Table import *
|
||||
from View.Geometry.Profile.Window import ProfileWindow
|
||||
|
|
|
|||
|
|
@ -44,8 +44,8 @@ from View.Configure.Window import ConfigureWindow
|
|||
from View.Study.Window import NewStudyWindow
|
||||
from View.About.Window import AboutWindow
|
||||
from View.Network.Window import NetworkWindow
|
||||
# from View.Geometry.Window import GeometryWindow
|
||||
# from View.BoundaryCondition.Window import BoundaryConditionWindow
|
||||
from View.Geometry.Window import GeometryWindow
|
||||
from View.BoundaryCondition.Window import BoundaryConditionWindow
|
||||
# from View.LateralContribution.Window import LateralContributionWindow
|
||||
# from View.InitialConditions.Window import InitialConditionsWindow
|
||||
# from View.Stricklers.Window import StricklersWindow
|
||||
|
|
|
|||
|
|
@ -81,8 +81,6 @@ class PamhyrPlotToolbar(NavigationToolbar2QT):
|
|||
os.path.abspath(f"{file_path}/../ui/ressources/zoom.png")
|
||||
))
|
||||
|
||||
logger.info(os.path.abspath(f"{file_path}/../ui/ressources/zoom.png"))
|
||||
|
||||
icons.append(("zoom",icon_zoom))
|
||||
|
||||
if "iso" in items:
|
||||
|
|
|
|||
|
|
@ -26,10 +26,21 @@ from PyQt5.QtWidgets import (
|
|||
QSpinBox, QTimeEdit, QDateTimeEdit, QItemDelegate,
|
||||
)
|
||||
|
||||
from View.ASubWindow import AWidget
|
||||
from View.Tools.ASubWindow import AWidget
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
class PamhyrWidget(AWidget):
|
||||
_pamhyr_ui = ""
|
||||
_pamhyr_name = "PamhyrWidget"
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super(PamhyrWidget, self).__init__(
|
||||
ui = self._pamhyr_ui,
|
||||
parent = parent
|
||||
)
|
||||
|
||||
|
||||
class PamhyrExtendedTimeEdit(AWidget):
|
||||
def __init__(self, parent=None):
|
||||
super(PamhyrExtendedTimeEdit, self).__init__(
|
||||
|
|
|
|||
Loading…
Reference in New Issue