修改引用逻辑、新增Pattern更改界面、新增Calman灰阶界面

This commit is contained in:
xinzhu.yin
2026-05-27 11:26:28 +08:00
parent a903c17cb3
commit dff4e0df4d
24 changed files with 3327 additions and 386 deletions

View File

@@ -1,4 +1,4 @@
"""图表框架相关逻辑Step 3 重构)。
"""图表框架相关逻辑Step 3 重构)。
从 pqAutomationApp.PQAutomationApp 中搬迁而来。每个函数第一行 `self = app`
以保留原有 `self.xxx` 属性访问不变。
@@ -10,7 +10,13 @@ import matplotlib.pyplot as plt
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
from app.views.pq_debug_panel import PQDebugPanel
def init_gamut_chart(self):
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from pqAutomationApp import PQAutomationApp
def init_gamut_chart(self: "PQAutomationApp"):
"""初始化色域图表 - 手动设置subplot位置完全避免重叠"""
container = ttk.Frame(self.gamut_chart_frame)
container.pack(expand=True, fill=tk.BOTH)
@@ -65,7 +71,7 @@ def init_gamut_chart(self):
self.gamut_canvas.draw()
def sync_gamut_toolbar(self):
def sync_gamut_toolbar(self: "PQAutomationApp"):
"""将工具栏参考标准按钮同步为当前测试类型的 ref var 值。"""
if not hasattr(self, "_gamut_ref_toolbar_var"):
return
@@ -80,7 +86,7 @@ def sync_gamut_toolbar(self):
self._gamut_ref_toolbar_var.set(getattr(self, attr).get())
def _on_gamut_toolbar_changed(self, std):
def _on_gamut_toolbar_changed(self: "PQAutomationApp", std):
"""用户点击工具栏参考标准按钮时:更新 var → 保存配置 → 重绘(有数据时)。"""
test_type = self.config.current_test_type
var_map = {
@@ -105,7 +111,7 @@ def _on_gamut_toolbar_changed(self, std):
self.recalculate_gamut()
def init_gamma_chart(self):
def init_gamma_chart(self: "PQAutomationApp"):
"""初始化Gamma曲线图表 - 左侧曲线 + 右侧表格4列 + 通用说明)"""
container = ttk.Frame(self.gamma_chart_frame)
container.pack(expand=True, fill=tk.BOTH)
@@ -214,7 +220,7 @@ def init_gamma_chart(self):
self.gamma_fig.suptitle("Gamma曲线 + 数据表格", fontsize=12, y=0.98)
self.gamma_canvas.draw()
def init_eotf_chart(self):
def init_eotf_chart(self: "PQAutomationApp"):
"""初始化 EOTF 曲线图表HDR 专用)- 左侧曲线 + 右侧表格4列"""
container = ttk.Frame(self.eotf_chart_frame)
container.pack(expand=True, fill=tk.BOTH)
@@ -319,7 +325,7 @@ def init_eotf_chart(self):
self.eotf_fig.suptitle("EOTF 曲线 + 数据表格", fontsize=12, y=0.98)
self.eotf_canvas.draw()
def init_cct_chart(self):
def init_cct_chart(self: "PQAutomationApp"):
"""初始化色度坐标图表 - 正向横坐标,标题居中最上方"""
container = ttk.Frame(self.cct_chart_frame)
container.pack(expand=True)
@@ -364,7 +370,7 @@ def init_cct_chart(self):
self.cct_canvas.draw()
def init_contrast_chart(self):
def init_contrast_chart(self: "PQAutomationApp"):
"""初始化对比度图表 - 固定大小,居中显示"""
container = ttk.Frame(self.contrast_chart_frame)
container.pack(expand=True)
@@ -399,7 +405,7 @@ def init_contrast_chart(self):
self.contrast_canvas.draw()
def init_accuracy_chart(self):
def init_accuracy_chart(self: "PQAutomationApp"):
"""初始化色准图表 - 固定大小,居中显示"""
container = ttk.Frame(self.accuracy_chart_frame)
container.pack(expand=True)
@@ -434,7 +440,7 @@ def init_accuracy_chart(self):
self.accuracy_canvas.draw()
def clear_chart(self):
def clear_chart(self: "PQAutomationApp"):
"""清空所有图表"""
# ========== 1. 清空色域图表 ==========
@@ -729,7 +735,7 @@ def clear_chart(self):
self.accuracy_canvas.draw()
def update_chart_tabs_state(self):
def update_chart_tabs_state(self: "PQAutomationApp"):
"""根据测试项目复选框状态动态增删图表 Tab保持规范顺序
- 色域 / Gamma 或 EOTF / 色度一致性 / 对比度 / 色准 全部走动态 add/forget
@@ -801,7 +807,7 @@ def update_chart_tabs_state(self):
if hasattr(self, "log_gui"):
self.log_gui.log(f"更新Tab状态失败: {str(e)}", level="error")
def create_result_chart_frame(self):
def create_result_chart_frame(self: "PQAutomationApp"):
"""创建结果图表区域 - 6个独立TabGamma 和 EOTF 分离)"""
# 创建Notebook用于图表切换
self.chart_notebook = ttk.Notebook(self.result_frame)
@@ -859,7 +865,7 @@ def create_result_chart_frame(self):
# 创建单步调试面板实例
self.debug_panel = PQDebugPanel(self.debug_container, self)
def on_chart_tab_changed(self, event):
def on_chart_tab_changed(self: "PQAutomationApp", event):
"""Tab切换时的事件处理"""
try:
self._last_tab_index = self.chart_notebook.index(
@@ -868,3 +874,21 @@ def on_chart_tab_changed(self, event):
except Exception as e:
self.log_gui.log(f"Tab切换事件处理失败: {str(e)}", level="error")
class ChartFrameMixin:
"""由 tools/refactor_to_mixins.py 自动生成。
把本模块的自由函数挂到 PQAutomationApp 上,便于 F12 跳转与类型推断。
"""
init_gamut_chart = init_gamut_chart
sync_gamut_toolbar = sync_gamut_toolbar
_on_gamut_toolbar_changed = _on_gamut_toolbar_changed
init_gamma_chart = init_gamma_chart
init_eotf_chart = init_eotf_chart
init_cct_chart = init_cct_chart
init_contrast_chart = init_contrast_chart
init_accuracy_chart = init_accuracy_chart
clear_chart = clear_chart
update_chart_tabs_state = update_chart_tabs_state
create_result_chart_frame = create_result_chart_frame
on_chart_tab_changed = on_chart_tab_changed