mirror of https://gitlab.com/pamhyr/pamhyr2
refactoring: Continue apply PamhyrWindow.
parent
1a36d78ee2
commit
ca10f19fe5
|
|
@ -18,8 +18,7 @@
|
|||
|
||||
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,
|
||||
|
|
@ -44,30 +43,31 @@ from View.CheckList.Worker import Worker
|
|||
|
||||
_translate = QCoreApplication.translate
|
||||
|
||||
class CheckListWindow(ASubMainWindow, ListedSubWindow):
|
||||
class CheckListWindow(PamhyrWindow):
|
||||
_pamhyr_ui = "CheckList"
|
||||
_pamhyr_name = "Check list"
|
||||
|
||||
signalStatus = pyqtSignal(str)
|
||||
|
||||
def __init__(self, title="Check list",
|
||||
autorun:bool=True,
|
||||
def __init__(self, autorun:bool=True,
|
||||
study=None, config=None,
|
||||
solver=None, parent=None):
|
||||
self._title = title + " - " + study.name
|
||||
|
||||
self._autorun = autorun
|
||||
|
||||
self._study = study
|
||||
self._config = config
|
||||
self._solver = solver
|
||||
self._parent = parent
|
||||
|
||||
name = self._pamhyr_name + " - " + study.name
|
||||
|
||||
super(CheckListWindow, self).__init__(
|
||||
name=self._title, ui="CheckList", parent=parent
|
||||
title = name,
|
||||
study = study,
|
||||
config = config,
|
||||
options = [],
|
||||
parent = parent
|
||||
)
|
||||
self.ui.setWindowTitle(self._title)
|
||||
|
||||
self._checker_list = (
|
||||
self._study.checkers() + self._solver.checkers()
|
||||
self._study.checkers() +
|
||||
self._solver.checkers()
|
||||
)
|
||||
|
||||
self.setup_table()
|
||||
|
|
|
|||
|
|
@ -52,10 +52,10 @@ from View.Stricklers.Window import StricklersWindow
|
|||
from View.Frictions.Window import FrictionsWindow
|
||||
from View.SedimentLayers.Window import SedimentLayersWindow
|
||||
from View.SedimentLayers.Reach.Window import ReachSedimentLayersWindow
|
||||
# from View.SolverParameters.Window import SolverParametersWindow
|
||||
# from View.RunSolver.Window import SelectSolverWindow, SolverLogWindow
|
||||
# from View.CheckList.Window import CheckListWindow
|
||||
# from View.Results.Window import ResultsWindow
|
||||
from View.SolverParameters.Window import SolverParametersWindow
|
||||
from View.RunSolver.Window import SelectSolverWindow, SolverLogWindow
|
||||
from View.CheckList.Window import CheckListWindow
|
||||
from View.Results.Window import ResultsWindow
|
||||
# from View.Debug.Window import ReplWindow
|
||||
|
||||
from Model.Study import Study
|
||||
|
|
|
|||
|
|
@ -21,8 +21,7 @@ from datetime import datetime
|
|||
|
||||
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,23 +62,32 @@ _translate = QCoreApplication.translate
|
|||
|
||||
logger = logging.getLogger()
|
||||
|
||||
class ResultsWindow(ASubMainWindow, ListedSubWindow):
|
||||
def __init__(self, title="Results",
|
||||
study=None, solver=None, results=None,
|
||||
class ResultsWindow(PamhyrWindow):
|
||||
_pamhyr_ui = "Results"
|
||||
_pamhyr_name = "Results"
|
||||
|
||||
def __init__(self, study=None, config=None,
|
||||
solver=None, results=None,
|
||||
parent=None):
|
||||
self._study = study
|
||||
self._solver = solver
|
||||
self._results = results
|
||||
|
||||
self._timestamps = sorted(list(self._results.get("timestamps")))
|
||||
|
||||
self.setup_title(title)
|
||||
|
||||
super(ResultsWindow, self).__init__(
|
||||
name=title, ui="Results", parent=parent
|
||||
name = (
|
||||
self._pamhyr_name + " - "
|
||||
+ study.name + " - "
|
||||
+ self._solver.name + " - "
|
||||
+ self._results.date
|
||||
)
|
||||
|
||||
super(ResultsWindow, self).__init__(
|
||||
title = name,
|
||||
study = study,
|
||||
config = config,
|
||||
parent=parent
|
||||
)
|
||||
|
||||
self.setup_sc()
|
||||
self.setup_table()
|
||||
self.setup_graph()
|
||||
self.setup_slider()
|
||||
|
|
@ -96,14 +104,6 @@ class ResultsWindow(ASubMainWindow, ListedSubWindow):
|
|||
+ self._results.date
|
||||
)
|
||||
|
||||
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 = {}
|
||||
|
|
@ -289,11 +289,6 @@ class ResultsWindow(ASubMainWindow, ListedSubWindow):
|
|||
self._status_label.setText(txt)
|
||||
|
||||
def setup_connections(self):
|
||||
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)
|
||||
|
||||
fun = {
|
||||
"reach": self._set_current_reach,
|
||||
"profile": self._set_current_profile,
|
||||
|
|
@ -411,14 +406,14 @@ class ResultsWindow(ASubMainWindow, ListedSubWindow):
|
|||
timestamp = self._timestamps[self._slider_time.value()]
|
||||
self.update(timestamp = timestamp)
|
||||
|
||||
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):
|
||||
self._table.undo()
|
||||
|
||||
def redo(self):
|
||||
def _redo(self):
|
||||
self._table.redo()
|
||||
|
|
|
|||
|
|
@ -22,8 +22,7 @@ import os
|
|||
from queue import Queue
|
||||
from tools import trace, timer
|
||||
|
||||
from View.ASubWindow import ASubWindow, ASubMainWindow
|
||||
from View.ListedSubWindow import ListedSubWindow
|
||||
from View.Tools.PamhyrWindow import PamhyrDialog, PamhyrWindow
|
||||
|
||||
from PyQt5.QtGui import (
|
||||
QKeySequence,
|
||||
|
|
@ -45,24 +44,23 @@ from PyQt5.QtWidgets import (
|
|||
|
||||
_translate = QCoreApplication.translate
|
||||
|
||||
class SolverLogFileWindow(ASubMainWindow, ListedSubWindow):
|
||||
def __init__(self, title="Solver logs",
|
||||
file_name = None,
|
||||
class SolverLogFileWindow(PamhyrWindow):
|
||||
_pamhyr_ui = "SolverLogFile"
|
||||
_pamhyr_name = "Solver logs"
|
||||
|
||||
def __init__(self, file_name = None,
|
||||
study=None, config=None,
|
||||
solver=None, parent=None):
|
||||
self._title = title
|
||||
self._parent = parent
|
||||
|
||||
self._study = study
|
||||
self._config = config
|
||||
self._solver = solver
|
||||
|
||||
self._file_name = file_name
|
||||
|
||||
super(SolverLogFileWindow, self).__init__(
|
||||
name=self._title, ui="SolverLogFile", parent=parent
|
||||
title = self._pamhyr_name,
|
||||
study = study,
|
||||
config = config,
|
||||
options = [],
|
||||
parent = parent
|
||||
)
|
||||
self.ui.setWindowTitle(self._title)
|
||||
|
||||
self.setup_action()
|
||||
self.setup_connections()
|
||||
|
|
|
|||
|
|
@ -23,8 +23,7 @@ import tempfile
|
|||
from queue import Queue
|
||||
from tools import trace, timer
|
||||
|
||||
from View.ASubWindow import ASubWindow, ASubMainWindow
|
||||
from View.ListedSubWindow import ListedSubWindow
|
||||
from View.Tools.PamhyrWindow import PamhyrDialog, PamhyrWindow
|
||||
|
||||
from PyQt5.QtGui import (
|
||||
QKeySequence,
|
||||
|
|
@ -56,20 +55,21 @@ _translate = QCoreApplication.translate
|
|||
|
||||
logger = logging.getLogger()
|
||||
|
||||
class SelectSolverWindow(ASubWindow, ListedSubWindow):
|
||||
def __init__(self, title="Select solver",
|
||||
study=None, config=None,
|
||||
parent=None):
|
||||
self._title = title
|
||||
class SelectSolverWindow(PamhyrDialog):
|
||||
_pamhyr_ui = "SelectSolver"
|
||||
_pamhyr_name = "Select solver"
|
||||
|
||||
self._study = study
|
||||
self._config = config
|
||||
def __init__(self, study=None, config=None,
|
||||
parent=None):
|
||||
self._solver = None
|
||||
|
||||
super(SelectSolverWindow, self).__init__(
|
||||
name=self._title, ui="SelectSolver", parent=parent
|
||||
title = self._pamhyr_name,
|
||||
study = study,
|
||||
config = config,
|
||||
options = [],
|
||||
parent = parent
|
||||
)
|
||||
self.ui.setWindowTitle(self._title)
|
||||
|
||||
self.setup_combobox()
|
||||
self.setup_connections()
|
||||
|
|
@ -101,24 +101,22 @@ class SelectSolverWindow(ASubWindow, ListedSubWindow):
|
|||
|
||||
super(SelectSolverWindow, self).accept()
|
||||
|
||||
class SolverLogWindow(PamhyrWindow):
|
||||
_pamhyr_ui = "SolverLog"
|
||||
_pamhyr_name = "Solver Log"
|
||||
|
||||
class SolverLogWindow(ASubMainWindow, ListedSubWindow):
|
||||
def __init__(self, title="Solver logs",
|
||||
study=None, config=None,
|
||||
def __init__(self, study=None, config=None,
|
||||
solver=None, parent=None):
|
||||
self._title = title
|
||||
self._parent = parent
|
||||
|
||||
self._study = study
|
||||
self._config = config
|
||||
self._solver = solver
|
||||
|
||||
self._results = None
|
||||
|
||||
super(SolverLogWindow, self).__init__(
|
||||
name=self._title, ui="SolverLog", parent=parent
|
||||
title = self._pamhyr_name,
|
||||
study = study,
|
||||
config = config,
|
||||
options = [],
|
||||
parent = parent
|
||||
)
|
||||
self.ui.setWindowTitle(self._title)
|
||||
|
||||
self.setup_action()
|
||||
self.setup_alarm()
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
@ -51,23 +50,28 @@ _translate = QCoreApplication.translate
|
|||
|
||||
logger = logging.getLogger()
|
||||
|
||||
class SolverParametersWindow(ASubMainWindow, ListedSubWindow):
|
||||
def __init__(self, title="Solver parameters", study=None, parent=None):
|
||||
class SolverParametersWindow(PamhyrWindow):
|
||||
_pamhyr_ui = "SolverParameters"
|
||||
_pamhyr_name = "Solver parameters"
|
||||
|
||||
def __init__(self, study=None, config=None, parent=None):
|
||||
# Init tanslate dictionary
|
||||
tr.init()
|
||||
|
||||
self._title = title + " - " + study.name
|
||||
name = self._pamhyr_name + " - " + study.name
|
||||
|
||||
super(SolverParametersWindow, self).__init__(
|
||||
name=title, ui="SolverParameters", parent=parent
|
||||
title = name,
|
||||
study = study,
|
||||
config = config,
|
||||
options = ['copy'],
|
||||
parent = parent
|
||||
)
|
||||
|
||||
self._study = study
|
||||
self._params = self._study.river.parameters
|
||||
|
||||
self.setup_sc()
|
||||
self.setup_table()
|
||||
self.setup_connections()
|
||||
|
||||
self.ui.setWindowTitle(self._title)
|
||||
|
||||
|
|
@ -77,10 +81,10 @@ class SolverParametersWindow(ASubMainWindow, ListedSubWindow):
|
|||
for st in solver_type_list:
|
||||
self._undo_stack[st] = 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)
|
||||
self._undo_sc = QShortcut(QKeySequence.Undo, self)
|
||||
self._redo_sc = QShortcut(QKeySequence.Redo, self)
|
||||
self._undo_sc.activated.connect(self._undo)
|
||||
self._redo_sc.activated.connect(self._redo)
|
||||
|
||||
def setup_table(self):
|
||||
self._table = {}
|
||||
|
|
@ -115,31 +119,24 @@ class SolverParametersWindow(ASubMainWindow, ListedSubWindow):
|
|||
# Create tab
|
||||
self._tab_widget.addTab(widget, f"{solver_long_name[st]}")
|
||||
|
||||
|
||||
def setup_connections(self):
|
||||
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()\
|
||||
.objectName()\
|
||||
.replace("tab_", "")
|
||||
|
||||
def undo(self):
|
||||
def _undo(self):
|
||||
tab = self.current_tab()
|
||||
self._table[tab].undo()
|
||||
self._set_current_reach()
|
||||
|
||||
def redo(self):
|
||||
def _redo(self):
|
||||
tab = self.current_tab()
|
||||
self._table[tab].redo()
|
||||
self._set_current_reach()
|
||||
|
||||
def copy(self):
|
||||
def _copy(self):
|
||||
logger.info("TODO: copy")
|
||||
|
||||
def paste(self):
|
||||
def _paste(self):
|
||||
logger.info("TODO: paste")
|
||||
|
|
|
|||
Loading…
Reference in New Issue