11from collections import defaultdict
22
3+ import petab .v1 .C as PETAB_C
34import qtawesome as qta
45from matplotlib import pyplot as plt
56from matplotlib .backends .backend_qtagg import FigureCanvasQTAgg as FigureCanvas
@@ -102,6 +103,18 @@ def _get_cached_df(self, table_name, proxy_model):
102103 self ._cache_valid [table_name ] = True
103104 return self ._df_cache [table_name ]
104105
106+ def _connect_proxy_signals (self , proxy , cache_key ):
107+ """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 )
117+
105118 def initialize (
106119 self , meas_proxy , sim_proxy , cond_proxy , vis_proxy , petab_model
107120 ):
@@ -114,61 +127,11 @@ def initialize(
114127 # Connect cache invalidation and data changes
115128 self .options_manager .option_changed .connect (self ._debounced_plot )
116129
117- # Measurements cache invalidation
118- self .meas_proxy .dataChanged .connect (
119- lambda : self ._invalidate_cache ("measurements" )
120- )
121- self .meas_proxy .rowsInserted .connect (
122- lambda : self ._invalidate_cache ("measurements" )
123- )
124- self .meas_proxy .rowsRemoved .connect (
125- lambda : self ._invalidate_cache ("measurements" )
126- )
127- self .meas_proxy .dataChanged .connect (self ._debounced_plot )
128- self .meas_proxy .rowsInserted .connect (self ._debounced_plot )
129- self .meas_proxy .rowsRemoved .connect (self ._debounced_plot )
130-
131- # Conditions cache invalidation
132- self .cond_proxy .dataChanged .connect (
133- lambda : self ._invalidate_cache ("conditions" )
134- )
135- self .cond_proxy .rowsInserted .connect (
136- lambda : self ._invalidate_cache ("conditions" )
137- )
138- self .cond_proxy .rowsRemoved .connect (
139- lambda : self ._invalidate_cache ("conditions" )
140- )
141- self .cond_proxy .dataChanged .connect (self ._debounced_plot )
142- self .cond_proxy .rowsInserted .connect (self ._debounced_plot )
143- self .cond_proxy .rowsRemoved .connect (self ._debounced_plot )
144-
145- # Simulations cache invalidation
146- self .sim_proxy .dataChanged .connect (
147- lambda : self ._invalidate_cache ("simulations" )
148- )
149- self .sim_proxy .rowsInserted .connect (
150- lambda : self ._invalidate_cache ("simulations" )
151- )
152- self .sim_proxy .rowsRemoved .connect (
153- lambda : self ._invalidate_cache ("simulations" )
154- )
155- self .sim_proxy .dataChanged .connect (self ._debounced_plot )
156- self .sim_proxy .rowsInserted .connect (self ._debounced_plot )
157- self .sim_proxy .rowsRemoved .connect (self ._debounced_plot )
158-
159- # Visualization cache invalidation
160- self .vis_proxy .dataChanged .connect (
161- lambda : self ._invalidate_cache ("visualization" )
162- )
163- self .vis_proxy .rowsInserted .connect (
164- lambda : self ._invalidate_cache ("visualization" )
165- )
166- self .vis_proxy .rowsRemoved .connect (
167- lambda : self ._invalidate_cache ("visualization" )
168- )
169- self .vis_proxy .dataChanged .connect (self ._debounced_plot )
170- self .vis_proxy .rowsInserted .connect (self ._debounced_plot )
171- self .vis_proxy .rowsRemoved .connect (self ._debounced_plot )
130+ # Connect proxy signals for all tables
131+ self ._connect_proxy_signals (self .meas_proxy , "measurements" )
132+ self ._connect_proxy_signals (self .cond_proxy , "conditions" )
133+ self ._connect_proxy_signals (self .sim_proxy , "simulations" )
134+ self ._connect_proxy_signals (self .vis_proxy , "visualization" )
172135
173136 self .visibilityChanged .connect (self ._debounced_plot )
174137
@@ -336,8 +299,8 @@ def highlight_from_selection(
336299 if not proxy :
337300 return
338301
339- x_axis_col = "time"
340- observable_col = "observableId"
302+ x_axis_col = PETAB_C . TIME
303+ observable_col = PETAB_C . OBSERVABLE_ID
341304
342305 def column_index (name ):
343306 for col in range (proxy .columnCount ()):
0 commit comments