Commit f074e1fd authored by Pierre-Antoine Rouby's avatar Pierre-Antoine Rouby
Browse files

Geometry: Fix profile sub window open.

Showing with 37 additions and 13 deletions
+37 -13
...@@ -65,6 +65,8 @@ class ProfileWindow(PamhyrWindow): ...@@ -65,6 +65,8 @@ class ProfileWindow(PamhyrWindow):
parent=parent parent=parent
) )
self._hash_data.append(profile)
self.setup_table() self.setup_table()
self.setup_plot() self.setup_plot()
self.setup_connections() self.setup_connections()
......
...@@ -216,6 +216,30 @@ class GeometryWindow(PamhyrWindow): ...@@ -216,6 +216,30 @@ 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)
...@@ -228,20 +252,18 @@ class GeometryWindow(PamhyrWindow): ...@@ -228,20 +252,18 @@ class GeometryWindow(PamhyrWindow):
for row in rows: for row in rows:
profile = self._reach.profile(row) profile = self._reach.profile(row)
win = self.sub_win_filter_first( if self._sub_window_exists(
"Profile", ProfileWindow,
contain=[self._reach.name, str(profile.kp)] data=[None, None, profile]
) ):
continue
if win is None: win = ProfileWindow(
win = ProfileWindow( profile=profile,
profile=profile, parent=self,
parent=self, )
) self._profile_window.append(win)
self._profile_window.append(win) win.show()
win.show()
else:
win.activateWindow()
self.tableView.model().blockSignals(False) self.tableView.model().blockSignals(False)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment