diff --git a/src/View/Geometry/Profile/Window.py b/src/View/Geometry/Profile/Window.py index dfce6d9d76836e39c7835a38fea8d6b5728f98ad..9fd3f1aa76a8b55562a20082fd456ec23c29a848 100644 --- a/src/View/Geometry/Profile/Window.py +++ b/src/View/Geometry/Profile/Window.py @@ -65,6 +65,8 @@ class ProfileWindow(PamhyrWindow): parent=parent ) + self._hash_data.append(profile) + self.setup_table() self.setup_plot() self.setup_connections() diff --git a/src/View/Geometry/Window.py b/src/View/Geometry/Window.py index ac021ad1b3b3541e6ab766cdc761f4dc5a1a5407..459bc95d173767e94b11eb05dcc79ee29667bb0d 100644 --- a/src/View/Geometry/Window.py +++ b/src/View/Geometry/Window.py @@ -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)