mirror of https://gitlab.com/pamhyr/pamhyr2
Geometry, ListedSubWindow: Use ListedSubWindow in Geometry windows.
parent
61f31403d4
commit
ec16586755
|
|
@ -462,10 +462,12 @@ class ASubWindowFeatures(object):
|
||||||
class ASubMainWindow(QMainWindow, ASubWindowFeatures, WindowToolKit):
|
class ASubMainWindow(QMainWindow, ASubWindowFeatures, WindowToolKit):
|
||||||
def __init__(self, name="", ui="dummy", parent=None):
|
def __init__(self, name="", ui="dummy", parent=None):
|
||||||
super(ASubMainWindow, self).__init__(parent=parent)
|
super(ASubMainWindow, self).__init__(parent=parent)
|
||||||
self.ui = loadUi(
|
if ui is not None:
|
||||||
os.path.join(os.path.dirname(__file__), "ui", f"{ui}.ui"),
|
self.ui = loadUi(
|
||||||
self
|
os.path.join(os.path.dirname(__file__), "ui", f"{ui}.ui"),
|
||||||
)
|
self
|
||||||
|
)
|
||||||
|
|
||||||
self.name = name
|
self.name = name
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
if self.parent is not None:
|
if self.parent is not None:
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ from PyQt5.QtWidgets import (
|
||||||
from Model.Geometry.Reach import Reach
|
from Model.Geometry.Reach import Reach
|
||||||
from Model.Geometry.ProfileXYZ import ProfileXYZ
|
from Model.Geometry.ProfileXYZ import ProfileXYZ
|
||||||
|
|
||||||
from View.ASubWindow import WindowToolKit
|
from View.ASubWindow import ASubMainWindow
|
||||||
from View.Geometry.Profile.mainwindow_ui_profile import Ui_MainWindow
|
from View.Geometry.Profile.mainwindow_ui_profile import Ui_MainWindow
|
||||||
from View.Geometry.Profile.Plot import Plot
|
from View.Geometry.Profile.Plot import Plot
|
||||||
from View.Geometry.Profile.Table import *
|
from View.Geometry.Profile.Table import *
|
||||||
|
|
@ -45,10 +45,14 @@ from View.Geometry.Profile.Table import *
|
||||||
_translate = QCoreApplication.translate
|
_translate = QCoreApplication.translate
|
||||||
|
|
||||||
|
|
||||||
class ProfileWindow(QMainWindow, WindowToolKit):
|
class ProfileWindow(ASubMainWindow):
|
||||||
def __init__(self, profile=None, parent=None):
|
def __init__(self, profile=None, title="Profile", parent=None):
|
||||||
|
self._title = title
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
super(ProfileWindow, self).__init__(self.parent)
|
super(ProfileWindow, self).__init__(
|
||||||
|
name=self._title,
|
||||||
|
parent=self.parent
|
||||||
|
)
|
||||||
|
|
||||||
self.ui = Ui_MainWindow()
|
self.ui = Ui_MainWindow()
|
||||||
self.ui.setupUi(self)
|
self.ui.setupUi(self)
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,8 @@ from View.Geometry.PlotXY import PlotXY
|
||||||
from View.Geometry.PlotKPC import PlotKPC
|
from View.Geometry.PlotKPC import PlotKPC
|
||||||
from View.Geometry.PlotAC import PlotAC
|
from View.Geometry.PlotAC import PlotAC
|
||||||
|
|
||||||
from View.ASubWindow import WindowToolKit
|
from View.ASubWindow import ASubMainWindow, WindowToolKit
|
||||||
|
from View.ListedSubWindow import ListedSubWindow
|
||||||
from View.Geometry.mainwindow_ui_reach import Ui_MainWindow
|
from View.Geometry.mainwindow_ui_reach import Ui_MainWindow
|
||||||
from View.Geometry.Table import *
|
from View.Geometry.Table import *
|
||||||
from View.Geometry.Profile.Window import ProfileWindow
|
from View.Geometry.Profile.Window import ProfileWindow
|
||||||
|
|
@ -49,10 +50,14 @@ from View.Geometry.Profile.Window import ProfileWindow
|
||||||
_translate = QCoreApplication.translate
|
_translate = QCoreApplication.translate
|
||||||
|
|
||||||
|
|
||||||
class GeometryWindow(QMainWindow, WindowToolKit):
|
class GeometryWindow(ASubMainWindow, ListedSubWindow):
|
||||||
def __init__(self, model=None, parent=None):
|
def __init__(self, model=None, title="Geometry", parent=None):
|
||||||
|
self._title = title
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
super(GeometryWindow, self).__init__(parent=parent)
|
super(GeometryWindow, self).__init__(
|
||||||
|
name=self._title,
|
||||||
|
parent=parent
|
||||||
|
)
|
||||||
|
|
||||||
self._model = model
|
self._model = model
|
||||||
self._reach = model.river.current_reach().reach
|
self._reach = model.river.current_reach().reach
|
||||||
|
|
|
||||||
|
|
@ -48,9 +48,32 @@ class ListedSubWindow(object):
|
||||||
self.sub_win_cnt = len(self.sub_win_list)
|
self.sub_win_cnt = len(self.sub_win_list)
|
||||||
logger.info(f"Close window: {name} ({self.sub_win_cnt})")
|
logger.info(f"Close window: {name} ({self.sub_win_cnt})")
|
||||||
|
|
||||||
def sub_win_exists(self, name):
|
def _sub_win_exists(self, name):
|
||||||
return reduce(
|
return reduce(
|
||||||
lambda acc, n: (acc or (n[0] == name)),
|
lambda acc, n: (acc or (n[0] == name)),
|
||||||
self.sub_win_list,
|
self.sub_win_list,
|
||||||
False
|
False
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def _sub_win_exists_with_contain(self, name, contain):
|
||||||
|
return reduce(
|
||||||
|
lambda acc, n: (
|
||||||
|
acc or
|
||||||
|
(
|
||||||
|
(n[0] == name) and
|
||||||
|
reduce(
|
||||||
|
lambda acc, a: acc and (a in n[1]._title),
|
||||||
|
contain,
|
||||||
|
True
|
||||||
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
self.sub_win_list,
|
||||||
|
False
|
||||||
|
)
|
||||||
|
|
||||||
|
def sub_win_exists(self, name, contain = []):
|
||||||
|
if contain == []:
|
||||||
|
self._sub_win_exists(name)
|
||||||
|
else:
|
||||||
|
self._sub_win_exists_with_contain(name, contain)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue