mirror of https://gitlab.com/pamhyr/pamhyr2
BC, LC: Fix sub window open.
parent
f074e1fdf2
commit
e395f9f575
|
|
@ -124,6 +124,8 @@ class EditBoundaryConditionWindow(PamhyrWindow):
|
||||||
parent=parent
|
parent=parent
|
||||||
)
|
)
|
||||||
|
|
||||||
|
self._hash_data.append(data)
|
||||||
|
|
||||||
self.setup_table()
|
self.setup_table()
|
||||||
self.setup_plot()
|
self.setup_plot()
|
||||||
self.setup_data()
|
self.setup_data()
|
||||||
|
|
|
||||||
|
|
@ -214,17 +214,17 @@ class BoundaryConditionWindow(PamhyrWindow):
|
||||||
tab = self.current_tab()
|
tab = self.current_tab()
|
||||||
rows = self.index_selected_rows()
|
rows = self.index_selected_rows()
|
||||||
for row in rows:
|
for row in rows:
|
||||||
win = self.sub_win_filter_first(
|
data = self._bcs.get(tab, row)
|
||||||
"Edit boundary condition",
|
|
||||||
contain=[f"({self._bcs.get(tab, row).id})"]
|
if self.sub_window_exists(
|
||||||
)
|
EditBoundaryConditionWindow,
|
||||||
|
data=[self._study, None, data]
|
||||||
|
):
|
||||||
|
continue
|
||||||
|
|
||||||
if win is None:
|
|
||||||
win = EditBoundaryConditionWindow(
|
win = EditBoundaryConditionWindow(
|
||||||
data=self._bcs.get(tab, row),
|
data=data,
|
||||||
study=self._study,
|
study=self._study,
|
||||||
parent=self
|
parent=self
|
||||||
)
|
)
|
||||||
win.show()
|
win.show()
|
||||||
else:
|
|
||||||
win.activateWindow()
|
|
||||||
|
|
|
||||||
|
|
@ -216,30 +216,6 @@ class GeometryWindow(PamhyrWindow):
|
||||||
self.plot_kpc()
|
self.plot_kpc()
|
||||||
self.plot_ac()
|
self.plot_ac()
|
||||||
|
|
||||||
def _sub_window_exists(self, cls,
|
|
||||||
data=None):
|
|
||||||
"""Check if window already exists
|
|
||||||
|
|
||||||
Check if window already exists, used to deni window open
|
|
||||||
duplication
|
|
||||||
|
|
||||||
Args:
|
|
||||||
cls: Window class, must inerit to PamhyrWindow or
|
|
||||||
PamhyrDialog
|
|
||||||
data: Data used for hash computation of cls
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
The window if hash already exists on sub window dictionary,
|
|
||||||
otherelse None
|
|
||||||
"""
|
|
||||||
hash = cls._hash(data)
|
|
||||||
if self.sub_win_exists(hash):
|
|
||||||
win = self.get_sub_win(hash)
|
|
||||||
win.activateWindow()
|
|
||||||
return True
|
|
||||||
else:
|
|
||||||
return False
|
|
||||||
|
|
||||||
def edit_profile(self):
|
def edit_profile(self):
|
||||||
self.tableView.model().blockSignals(True)
|
self.tableView.model().blockSignals(True)
|
||||||
|
|
||||||
|
|
@ -252,7 +228,7 @@ class GeometryWindow(PamhyrWindow):
|
||||||
for row in rows:
|
for row in rows:
|
||||||
profile = self._reach.profile(row)
|
profile = self._reach.profile(row)
|
||||||
|
|
||||||
if self._sub_window_exists(
|
if self.sub_window_exists(
|
||||||
ProfileWindow,
|
ProfileWindow,
|
||||||
data=[None, None, profile]
|
data=[None, None, profile]
|
||||||
):
|
):
|
||||||
|
|
|
||||||
|
|
@ -77,6 +77,8 @@ class EditLateralContributionWindow(PamhyrWindow):
|
||||||
parent=parent
|
parent=parent
|
||||||
)
|
)
|
||||||
|
|
||||||
|
self._hash_data.append(data)
|
||||||
|
|
||||||
self.setup_table()
|
self.setup_table()
|
||||||
self.setup_plot()
|
self.setup_plot()
|
||||||
self.setup_connections()
|
self.setup_connections()
|
||||||
|
|
|
||||||
|
|
@ -258,17 +258,17 @@ class LateralContributionWindow(PamhyrWindow):
|
||||||
tab = self.current_tab()
|
tab = self.current_tab()
|
||||||
rows = self.index_selected_rows()
|
rows = self.index_selected_rows()
|
||||||
for row in rows:
|
for row in rows:
|
||||||
win = self.sub_win_filter_first(
|
data = self._lcs.get(tab, row)
|
||||||
"Edit lateral contribution",
|
|
||||||
contain=[f"({self._lcs.get(tab, row).id})"]
|
if self.sub_window_exists(
|
||||||
)
|
EditLateralContributionWindow,
|
||||||
|
data=[self._study, None, data]
|
||||||
|
):
|
||||||
|
continue
|
||||||
|
|
||||||
if win is None:
|
|
||||||
win = EditLateralContributionWindow(
|
win = EditLateralContributionWindow(
|
||||||
data=self._lcs.get(tab, row),
|
data=data,
|
||||||
study=self._study,
|
study=self._study,
|
||||||
parent=self
|
parent=self
|
||||||
)
|
)
|
||||||
win.show()
|
win.show()
|
||||||
else:
|
|
||||||
win.activateWindow()
|
|
||||||
|
|
|
||||||
|
|
@ -480,30 +480,6 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
||||||
# SUBWINDOW #
|
# SUBWINDOW #
|
||||||
#############
|
#############
|
||||||
|
|
||||||
def _sub_window_exists(self, cls,
|
|
||||||
data=None):
|
|
||||||
"""Check if window already exists
|
|
||||||
|
|
||||||
Check if window already exists, used to deni window open
|
|
||||||
duplication
|
|
||||||
|
|
||||||
Args:
|
|
||||||
cls: Window class, must inerit to PamhyrWindow or
|
|
||||||
PamhyrDialog
|
|
||||||
data: Data used for hash computation of cls
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
The window if hash already exists on sub window dictionary,
|
|
||||||
otherelse None
|
|
||||||
"""
|
|
||||||
hash = cls._hash(data)
|
|
||||||
if self.sub_win_exists(hash):
|
|
||||||
win = self.get_sub_win(hash)
|
|
||||||
win.activateWindow()
|
|
||||||
return True
|
|
||||||
else:
|
|
||||||
return False
|
|
||||||
|
|
||||||
def open_configure(self):
|
def open_configure(self):
|
||||||
"""Open configure window
|
"""Open configure window
|
||||||
|
|
||||||
|
|
@ -512,7 +488,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
||||||
Returns:
|
Returns:
|
||||||
Nothing
|
Nothing
|
||||||
"""
|
"""
|
||||||
if self._sub_window_exists(
|
if self.sub_window_exists(
|
||||||
ConfigureWindow,
|
ConfigureWindow,
|
||||||
data=[None, self.conf]
|
data=[None, self.conf]
|
||||||
):
|
):
|
||||||
|
|
@ -529,7 +505,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
||||||
Returns:
|
Returns:
|
||||||
Nothing
|
Nothing
|
||||||
"""
|
"""
|
||||||
if self._sub_window_exists(
|
if self.sub_window_exists(
|
||||||
AboutWindow,
|
AboutWindow,
|
||||||
data=[None, None]
|
data=[None, None]
|
||||||
):
|
):
|
||||||
|
|
@ -563,7 +539,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
||||||
Nothing
|
Nothing
|
||||||
"""
|
"""
|
||||||
if self._study is None:
|
if self._study is None:
|
||||||
if self._sub_window_exists(
|
if self.sub_window_exists(
|
||||||
NewStudyWindow,
|
NewStudyWindow,
|
||||||
data=[None, None]
|
data=[None, None]
|
||||||
):
|
):
|
||||||
|
|
@ -579,7 +555,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
||||||
Nothing
|
Nothing
|
||||||
"""
|
"""
|
||||||
if self._study is not None:
|
if self._study is not None:
|
||||||
if self._sub_window_exists(
|
if self.sub_window_exists(
|
||||||
NewStudyWindow,
|
NewStudyWindow,
|
||||||
data=[self._study, None]
|
data=[self._study, None]
|
||||||
):
|
):
|
||||||
|
|
@ -595,7 +571,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
||||||
Nothing
|
Nothing
|
||||||
"""
|
"""
|
||||||
if self._study is not None:
|
if self._study is not None:
|
||||||
if self._sub_window_exists(
|
if self.sub_window_exists(
|
||||||
NetworkWindow,
|
NetworkWindow,
|
||||||
data=[self._study, None]
|
data=[self._study, None]
|
||||||
):
|
):
|
||||||
|
|
@ -613,7 +589,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
||||||
if (self._study is not None and self._study.river.has_current_reach()):
|
if (self._study is not None and self._study.river.has_current_reach()):
|
||||||
reach = self._study.river.current_reach().reach
|
reach = self._study.river.current_reach().reach
|
||||||
|
|
||||||
if self._sub_window_exists(
|
if self.sub_window_exists(
|
||||||
GeometryWindow,
|
GeometryWindow,
|
||||||
data=[self._study, self.conf, reach]
|
data=[self._study, self.conf, reach]
|
||||||
):
|
):
|
||||||
|
|
@ -630,7 +606,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
||||||
self.msg_select_reach()
|
self.msg_select_reach()
|
||||||
|
|
||||||
def open_boundary_cond(self):
|
def open_boundary_cond(self):
|
||||||
if self._sub_window_exists(
|
if self.sub_window_exists(
|
||||||
BoundaryConditionWindow,
|
BoundaryConditionWindow,
|
||||||
data=[self._study, None]
|
data=[self._study, None]
|
||||||
):
|
):
|
||||||
|
|
@ -640,7 +616,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
||||||
bound.show()
|
bound.show()
|
||||||
|
|
||||||
def open_lateral_contrib(self):
|
def open_lateral_contrib(self):
|
||||||
if self._sub_window_exists(
|
if self.sub_window_exists(
|
||||||
LateralContributionWindow,
|
LateralContributionWindow,
|
||||||
data=[self._study, None]
|
data=[self._study, None]
|
||||||
):
|
):
|
||||||
|
|
@ -650,7 +626,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
||||||
lateral.show()
|
lateral.show()
|
||||||
|
|
||||||
def open_stricklers(self):
|
def open_stricklers(self):
|
||||||
if self._sub_window_exists(
|
if self.sub_window_exists(
|
||||||
StricklersWindow,
|
StricklersWindow,
|
||||||
data=[self._study, self.conf]
|
data=[self._study, self.conf]
|
||||||
):
|
):
|
||||||
|
|
@ -668,7 +644,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
||||||
if self._study.river.has_current_reach():
|
if self._study.river.has_current_reach():
|
||||||
reach = self._study.river.current_reach()
|
reach = self._study.river.current_reach()
|
||||||
|
|
||||||
if self._sub_window_exists(
|
if self.sub_window_exists(
|
||||||
FrictionsWindow,
|
FrictionsWindow,
|
||||||
data=[self._study, None, reach]
|
data=[self._study, None, reach]
|
||||||
):
|
):
|
||||||
|
|
@ -686,7 +662,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
||||||
if self._study.river.has_current_reach():
|
if self._study.river.has_current_reach():
|
||||||
reach = self._study.river.current_reach()
|
reach = self._study.river.current_reach()
|
||||||
|
|
||||||
if self._sub_window_exists(
|
if self.sub_window_exists(
|
||||||
InitialConditionsWindow,
|
InitialConditionsWindow,
|
||||||
data=[self._study, self.conf, reach]
|
data=[self._study, self.conf, reach]
|
||||||
):
|
):
|
||||||
|
|
@ -703,7 +679,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
||||||
self.msg_select_reach()
|
self.msg_select_reach()
|
||||||
|
|
||||||
def open_solver_parameters(self):
|
def open_solver_parameters(self):
|
||||||
if self._sub_window_exists(
|
if self.sub_window_exists(
|
||||||
SolverParametersWindow,
|
SolverParametersWindow,
|
||||||
data=[self._study, None]
|
data=[self._study, None]
|
||||||
):
|
):
|
||||||
|
|
@ -716,7 +692,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
||||||
params.show()
|
params.show()
|
||||||
|
|
||||||
def open_sediment_layers(self):
|
def open_sediment_layers(self):
|
||||||
if self._sub_window_exists(
|
if self.sub_window_exists(
|
||||||
SedimentLayersWindow,
|
SedimentLayersWindow,
|
||||||
data=[self._study, None]
|
data=[self._study, None]
|
||||||
):
|
):
|
||||||
|
|
@ -731,7 +707,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
||||||
def open_reach_sediment_layers(self):
|
def open_reach_sediment_layers(self):
|
||||||
reach = self._study.river.current_reach().reach
|
reach = self._study.river.current_reach().reach
|
||||||
|
|
||||||
if self._sub_window_exists(
|
if self.sub_window_exists(
|
||||||
ReachSedimentLayersWindow,
|
ReachSedimentLayersWindow,
|
||||||
data=[self._study, None, reach]
|
data=[self._study, None, reach]
|
||||||
):
|
):
|
||||||
|
|
@ -756,7 +732,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
||||||
if run.exec():
|
if run.exec():
|
||||||
solver = run.solver
|
solver = run.solver
|
||||||
|
|
||||||
if self._sub_window_exists(
|
if self.sub_window_exists(
|
||||||
CheckListWindow,
|
CheckListWindow,
|
||||||
data=[
|
data=[
|
||||||
self._study,
|
self._study,
|
||||||
|
|
@ -793,7 +769,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
||||||
return
|
return
|
||||||
|
|
||||||
# Windows already opened
|
# Windows already opened
|
||||||
if self._sub_window_exists(
|
if self.sub_window_exists(
|
||||||
ResultsWindow,
|
ResultsWindow,
|
||||||
data=[
|
data=[
|
||||||
self._study,
|
self._study,
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ class ListedSubWindow(object):
|
||||||
self.sub_win_cnt += 1
|
self.sub_win_cnt += 1
|
||||||
try:
|
try:
|
||||||
logger.info(
|
logger.info(
|
||||||
f"Open window: {name}: {self.sub_win_cnt}: {win.hash()}")
|
f"Open window: {name}: {self.sub_win_cnt}")
|
||||||
except Exception:
|
except Exception:
|
||||||
logger.info(f"Open window: {name}: {self.sub_win_cnt}: X")
|
logger.info(f"Open window: {name}: {self.sub_win_cnt}: X")
|
||||||
logger.warning(f"Sub window without hash method !")
|
logger.warning(f"Sub window without hash method !")
|
||||||
|
|
@ -52,7 +52,7 @@ 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: {h}: {self.sub_win_cnt}")
|
logger.info(f"Close window: ({h}) {self.sub_win_cnt}")
|
||||||
|
|
||||||
def _sub_win_exists(self, h):
|
def _sub_win_exists(self, h):
|
||||||
return reduce(
|
return reduce(
|
||||||
|
|
@ -74,3 +74,27 @@ class ListedSubWindow(object):
|
||||||
)[1]
|
)[1]
|
||||||
except Exception:
|
except Exception:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def sub_window_exists(self, cls,
|
||||||
|
data=None):
|
||||||
|
"""Check if window already exists
|
||||||
|
|
||||||
|
Check if window already exists, used to deni window open
|
||||||
|
duplication
|
||||||
|
|
||||||
|
Args:
|
||||||
|
cls: Window class, must inerit to PamhyrWindow or
|
||||||
|
PamhyrDialog
|
||||||
|
data: Data used for hash computation of cls
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
The window if hash already exists on sub window dictionary,
|
||||||
|
otherelse None
|
||||||
|
"""
|
||||||
|
hash = cls._hash(data)
|
||||||
|
if self.sub_win_exists(hash):
|
||||||
|
win = self.get_sub_win(hash)
|
||||||
|
win.activateWindow()
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue