mirror of https://gitlab.com/pamhyr/pamhyr2
Geometry: Fix profile sub window open.
parent
4d1eb0fecc
commit
f074e1fdf2
|
|
@ -65,6 +65,8 @@ class ProfileWindow(PamhyrWindow):
|
|||
parent=parent
|
||||
)
|
||||
|
||||
self._hash_data.append(profile)
|
||||
|
||||
self.setup_table()
|
||||
self.setup_plot()
|
||||
self.setup_connections()
|
||||
|
|
|
|||
|
|
@ -216,6 +216,30 @@ class GeometryWindow(PamhyrWindow):
|
|||
self.plot_kpc()
|
||||
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):
|
||||
self.tableView.model().blockSignals(True)
|
||||
|
||||
|
|
@ -228,20 +252,18 @@ class GeometryWindow(PamhyrWindow):
|
|||
for row in rows:
|
||||
profile = self._reach.profile(row)
|
||||
|
||||
win = self.sub_win_filter_first(
|
||||
"Profile",
|
||||
contain=[self._reach.name, str(profile.kp)]
|
||||
)
|
||||
if self._sub_window_exists(
|
||||
ProfileWindow,
|
||||
data=[None, None, profile]
|
||||
):
|
||||
continue
|
||||
|
||||
if win is None:
|
||||
win = ProfileWindow(
|
||||
profile=profile,
|
||||
parent=self,
|
||||
)
|
||||
self._profile_window.append(win)
|
||||
win.show()
|
||||
else:
|
||||
win.activateWindow()
|
||||
win = ProfileWindow(
|
||||
profile=profile,
|
||||
parent=self,
|
||||
)
|
||||
self._profile_window.append(win)
|
||||
win.show()
|
||||
|
||||
self.tableView.model().blockSignals(False)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue