继续优化UI加载速度

This commit is contained in:
xinzhu.yin
2026-06-22 10:52:51 +08:00
parent 92cba114a9
commit 2d8d4119e3
7 changed files with 307 additions and 72 deletions

View File

@@ -699,9 +699,14 @@ def _on_calman_panel_shown(self: "PQAutomationApp") -> None:
"""面板切到前台时只做轻量刷新,不重绘 Matplotlib。"""
_refresh_calman_config_summary(self)
_schedule_adaptive_matrix_columns(self)
if getattr(self, "_calman_theme_dirty", False):
_redraw_calman_charts(self)
self._calman_theme_dirty = False
def _schedule_adaptive_matrix_columns(self: "PQAutomationApp") -> None:
if getattr(self, "_theme_transition", False):
return
job = getattr(self, "_calman_matrix_col_job", None)
if job is not None:
try:
@@ -1116,7 +1121,7 @@ def _adaptive_matrix_columns(self: "PQAutomationApp") -> None:
self.calman_data_tree.column(str(p), width=width, minwidth=min_w, stretch=False)
def _redraw_calman_charts(self: "PQAutomationApp") -> None:
def _redraw_calman_charts(self: "PQAutomationApp", *, sync_draw: bool = False) -> None:
"""根据 calman_results 重绘四张图和 xy 散点。"""
palette = _get_calman_palette()
if hasattr(self, "calman_fig"):
@@ -1236,12 +1241,15 @@ def _redraw_calman_charts(self: "PQAutomationApp") -> None:
a4.set_ylim(1.8, 2.8)
a4.set_xlabel("", fontsize=8)
self.calman_canvas.draw_idle()
if sync_draw or getattr(self, "_theme_transition", False):
self.calman_canvas.draw()
else:
self.calman_canvas.draw_idle()
_redraw_xy_chart(self)
_redraw_xy_chart(self, sync_draw=sync_draw)
def _redraw_xy_chart(self: "PQAutomationApp") -> None:
def _redraw_xy_chart(self: "PQAutomationApp", *, sync_draw: bool = False) -> None:
palette = _get_calman_palette()
if hasattr(self, "calman_xy_fig"):
self.calman_xy_fig.patch.set_facecolor(palette["figure_bg"])
@@ -1268,7 +1276,10 @@ def _redraw_xy_chart(self: "PQAutomationApp") -> None:
last = recs[-1]
ax.plot([last["x"]], [last["y"]], marker="o", color="#ffcc00", markersize=5)
ax.plot([last["x"], D65_X], [last["y"], D65_Y], color=_mix(palette["fg"], palette["axes_bg"], 0.4), linewidth=0.8)
self.calman_xy_canvas.draw_idle()
if sync_draw or getattr(self, "_theme_transition", False):
self.calman_xy_canvas.draw()
else:
self.calman_xy_canvas.draw_idle()
def _update_actual_strip(self: "PQAutomationApp") -> None:
@@ -1360,11 +1371,18 @@ def _refresh_metric_table(self: "PQAutomationApp") -> None:
self.calman_table_ysb.set(first, last)
def refresh_calman_theme(self: "PQAutomationApp") -> None:
def refresh_calman_theme(self: "PQAutomationApp", *, redraw_charts: bool | None = None) -> None:
"""主题切换后刷新 Calman 灰阶调试面板的表格与图表颜色。"""
if not hasattr(self, "calman_frame"):
return
if getattr(self, "current_panel", None) != "calman":
self._calman_theme_dirty = True
return
if redraw_charts is None:
redraw_charts = True
palette = _get_calman_palette()
if hasattr(self, "calman_elapsed_label"):
@@ -1388,7 +1406,11 @@ def refresh_calman_theme(self: "PQAutomationApp") -> None:
_refresh_metric_table(self)
_refresh_calman_config_summary(self)
_redraw_calman_charts(self)
if redraw_charts:
_redraw_calman_charts(self, sync_draw=getattr(self, "_theme_transition", False))
self._calman_theme_dirty = False
else:
self._calman_theme_dirty = True
class CalmanPanelMixin: