Skip to content

Commit ef8562e

Browse files
committed
fixed problem with updating
1 parent be211f0 commit ef8562e

2 files changed

Lines changed: 29 additions & 14 deletions

File tree

src/petab_gui/views/main_view.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,16 +126,16 @@ def __init__(self):
126126

127127
self.tab_widget.currentChanged.connect(self.set_docks_visible)
128128

129+
# Track if we're in a minimize/restore cycle (must be set before load_ui_settings)
130+
self._was_minimized = False
131+
129132
settings_manager.load_ui_settings(self)
130133

131134
# drag drop
132135
self.setAcceptDrops(True)
133136

134137
self.find_replace_bar = None
135138

136-
# Track if we're in a minimize/restore cycle
137-
self._was_minimized = False
138-
139139
def default_view(self):
140140
"""Reset the view to a fixed 3x2 grid using manual geometry."""
141141
if hasattr(self, "dock_visibility"):

src/petab_gui/views/simple_plot_view.py

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,14 @@ def _get_cached_df(self, table_name, proxy_model):
105105

106106
def _connect_proxy_signals(self, proxy, cache_key):
107107
"""Connect proxy signals for cache invalidation and plotting."""
108-
for signal in [
109-
proxy.dataChanged,
110-
proxy.rowsInserted,
111-
proxy.rowsRemoved,
112-
]:
113-
signal.connect(
114-
lambda *, key=cache_key: self._invalidate_cache(key)
115-
)
116-
signal.connect(self._debounced_plot)
108+
109+
def on_data_change(*args, **kwargs):
110+
self._invalidate_cache(cache_key)
111+
self._debounced_plot()
112+
113+
proxy.dataChanged.connect(on_data_change)
114+
proxy.rowsInserted.connect(on_data_change)
115+
proxy.rowsRemoved.connect(on_data_change)
117116

118117
def initialize(
119118
self, meas_proxy, sim_proxy, cond_proxy, vis_proxy, petab_model
@@ -124,6 +123,10 @@ def initialize(
124123
self.vis_proxy = vis_proxy
125124
self.petab_model = petab_model
126125

126+
# Clear all cache when reinitializing
127+
for key in self._cache_valid:
128+
self._cache_valid[key] = False
129+
127130
# Connect cache invalidation and data changes
128131
self.options_manager.option_changed.connect(self._debounced_plot)
129132

@@ -218,6 +221,9 @@ def _render_on_main_thread(self, payload):
218221
self._update_tabs(fig)
219222

220223
def _update_tabs(self, fig: plt.Figure):
224+
# Save current tab index before clearing
225+
current_tab_index = self.tab_widget.currentIndex()
226+
221227
# Clean previous tabs
222228
self.tab_widget.clear()
223229
# Clear Highlighter
@@ -329,6 +335,10 @@ def _update_tabs(self, fig: plt.Figure):
329335
# Plot residuals if necessary
330336
self.plot_residuals()
331337

338+
# Restore the previously selected tab (if valid)
339+
if 0 <= current_tab_index < self.tab_widget.count():
340+
self.tab_widget.setCurrentIndex(current_tab_index)
341+
332342
def highlight_from_selection(
333343
self, selected_rows: list[int], proxy=None, y_axis_col="measurement"
334344
):
@@ -556,8 +566,13 @@ def __init__(self, canvas, parent):
556566
self.addWidget(self.settings_btn)
557567

558568
def update_checked_state(self, selected_option):
559-
for action in self.groupy_by_options.values():
560-
action.setChecked(action.text() == f"Groupy by {selected_option}")
569+
for grp, action in self.groupy_by_options.items():
570+
if grp == "vis_df":
571+
action.setChecked(selected_option == "vis_df")
572+
else:
573+
action.setChecked(
574+
action.text() == f"Group by {selected_option}"
575+
)
561576

562577

563578
def create_plot_tab(

0 commit comments

Comments
 (0)