修改引用逻辑、新增Pattern更改界面、新增Calman灰阶界面
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
"""CCT 参数面板及其处理函数(与主文件重构版本保持同步)。"""
|
||||
"""CCT 参数面板及其处理函数(与主文件重构版本保持同步)。"""
|
||||
|
||||
import time
|
||||
import traceback
|
||||
@@ -8,8 +8,14 @@ import ttkbootstrap as ttk
|
||||
|
||||
import algorithm.pq_algorithm as pq_algorithm
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
def create_cct_params_frame(self):
|
||||
if TYPE_CHECKING:
|
||||
from pqAutomationApp import PQAutomationApp
|
||||
|
||||
|
||||
|
||||
def create_cct_params_frame(self: "PQAutomationApp"):
|
||||
"""创建色度参数设置区域 - 屏模组、SDR、HDR 独立(增加色域参考标准选择 + 单步调试按钮)"""
|
||||
|
||||
# ==================== 屏模组色度参数 Frame ====================
|
||||
@@ -330,7 +336,7 @@ def create_cct_params_frame(self):
|
||||
).grid(row=5, column=0, columnspan=4, sticky=tk.W, padx=5, pady=5)
|
||||
|
||||
|
||||
def _get_cct_var_dict(self, test_type):
|
||||
def _get_cct_var_dict(self: "PQAutomationApp", test_type):
|
||||
"""按测试类型返回 CCT 变量映射。"""
|
||||
if test_type == "sdr_movie":
|
||||
return {
|
||||
@@ -354,7 +360,7 @@ def _get_cct_var_dict(self, test_type):
|
||||
}
|
||||
|
||||
|
||||
def _parse_cct_float(self, var, default):
|
||||
def _parse_cct_float(self: "PQAutomationApp", var, default):
|
||||
"""读取并解析 CCT 输入值,失败时回落默认值。"""
|
||||
try:
|
||||
value = var.get().strip()
|
||||
@@ -365,7 +371,7 @@ def _parse_cct_float(self, var, default):
|
||||
return default
|
||||
|
||||
|
||||
def _save_cct_params_for(self, test_type):
|
||||
def _save_cct_params_for(self: "PQAutomationApp", test_type):
|
||||
"""保存指定测试类型的 CCT 参数。"""
|
||||
try:
|
||||
default_params = self.config.get_default_cct_params(test_type)
|
||||
@@ -384,7 +390,7 @@ def _save_cct_params_for(self, test_type):
|
||||
pass
|
||||
|
||||
|
||||
def _handle_cct_focus_out(self, var, default_value, save_func, label):
|
||||
def _handle_cct_focus_out(self: "PQAutomationApp", var, default_value, save_func, label):
|
||||
"""统一处理 CCT 参数失焦校验并保存。"""
|
||||
try:
|
||||
value = var.get().strip()
|
||||
@@ -414,27 +420,27 @@ def _handle_cct_focus_out(self, var, default_value, save_func, label):
|
||||
self.log_gui.log(f"处理 {label} 参数失败: {str(e)}", level="error")
|
||||
|
||||
|
||||
def on_sdr_cct_param_focus_out(self, var, default_value):
|
||||
def on_sdr_cct_param_focus_out(self: "PQAutomationApp", var, default_value):
|
||||
"""SDR 色度参数失去焦点时的处理。"""
|
||||
_handle_cct_focus_out(self, var, default_value, self.save_sdr_cct_params, "SDR")
|
||||
|
||||
|
||||
def save_sdr_cct_params(self):
|
||||
def save_sdr_cct_params(self: "PQAutomationApp"):
|
||||
"""保存 SDR 色度参数。"""
|
||||
_save_cct_params_for(self, "sdr_movie")
|
||||
|
||||
|
||||
def on_hdr_cct_param_focus_out(self, var, default_value):
|
||||
def on_hdr_cct_param_focus_out(self: "PQAutomationApp", var, default_value):
|
||||
"""HDR 色度参数失去焦点时的处理。"""
|
||||
_handle_cct_focus_out(self, var, default_value, self.save_hdr_cct_params, "HDR")
|
||||
|
||||
|
||||
def save_hdr_cct_params(self):
|
||||
def save_hdr_cct_params(self: "PQAutomationApp"):
|
||||
"""保存 HDR 色度参数。"""
|
||||
_save_cct_params_for(self, "hdr_movie")
|
||||
|
||||
|
||||
def recalculate_cct(self):
|
||||
def recalculate_cct(self: "PQAutomationApp"):
|
||||
"""重新计算并绘制色度图"""
|
||||
try:
|
||||
# 1. 保存新参数
|
||||
@@ -496,7 +502,7 @@ def recalculate_cct(self):
|
||||
messagebox.showerror("错误", f"重新计算失败: {str(e)}")
|
||||
|
||||
|
||||
def recalculate_gamut(self):
|
||||
def recalculate_gamut(self: "PQAutomationApp"):
|
||||
"""重新计算并绘制色域图(使用新的参考标准)"""
|
||||
try:
|
||||
# 1. 收起配置项
|
||||
@@ -644,17 +650,17 @@ def recalculate_gamut(self):
|
||||
messagebox.showerror("错误", f"重新计算失败: {str(e)}")
|
||||
|
||||
|
||||
def on_cct_param_focus_out(self, var, default_value):
|
||||
def on_cct_param_focus_out(self: "PQAutomationApp", var, default_value):
|
||||
"""色度参数失去焦点时的处理 - 空值恢复默认"""
|
||||
_handle_cct_focus_out(self, var, default_value, self.save_cct_params, "屏模组")
|
||||
|
||||
|
||||
def save_cct_params(self):
|
||||
def save_cct_params(self: "PQAutomationApp"):
|
||||
"""保存色度参数 - 简化版"""
|
||||
_save_cct_params_for(self, self.config.current_test_type)
|
||||
|
||||
|
||||
def reload_cct_params(self):
|
||||
def reload_cct_params(self: "PQAutomationApp"):
|
||||
"""切换测试类型时重新加载色度参数"""
|
||||
try:
|
||||
current_type = self.config.current_test_type
|
||||
@@ -676,7 +682,7 @@ def reload_cct_params(self):
|
||||
self.log_gui.log(f"重新加载色度参数失败: {str(e)}", level="error")
|
||||
|
||||
|
||||
def toggle_cct_params_frame(self):
|
||||
def toggle_cct_params_frame(self: "PQAutomationApp"):
|
||||
"""根据测试类型和测试项的选中状态显示对应参数框"""
|
||||
selected_items = self.get_selected_test_items()
|
||||
current_test_type = self.config.current_test_type
|
||||
@@ -718,7 +724,7 @@ _GAMUT_REF_CONFIGS = {
|
||||
}
|
||||
|
||||
|
||||
def _on_gamut_ref_changed(self, test_type, event=None):
|
||||
def _on_gamut_ref_changed(self: "PQAutomationApp", test_type, event=None):
|
||||
cfg = _GAMUT_REF_CONFIGS[test_type]
|
||||
try:
|
||||
new_ref = getattr(self, cfg["var_attr"]).get()
|
||||
@@ -732,13 +738,38 @@ def _on_gamut_ref_changed(self, test_type, event=None):
|
||||
self.log_gui.log(f"保存 {cfg['label']} 色域参考标准失败: {str(e)}", level="error")
|
||||
|
||||
|
||||
def on_screen_gamut_ref_changed(self, event=None):
|
||||
def on_screen_gamut_ref_changed(self: "PQAutomationApp", event=None):
|
||||
_on_gamut_ref_changed(self, "screen_module", event)
|
||||
|
||||
|
||||
def on_sdr_gamut_ref_changed(self, event=None):
|
||||
def on_sdr_gamut_ref_changed(self: "PQAutomationApp", event=None):
|
||||
_on_gamut_ref_changed(self, "sdr_movie", event)
|
||||
|
||||
|
||||
def on_hdr_gamut_ref_changed(self, event=None):
|
||||
def on_hdr_gamut_ref_changed(self: "PQAutomationApp", event=None):
|
||||
_on_gamut_ref_changed(self, "hdr_movie", event)
|
||||
|
||||
|
||||
class CctPanelMixin:
|
||||
"""由 tools/refactor_to_mixins.py 自动生成。
|
||||
把本模块的自由函数挂到 PQAutomationApp 上,便于 F12 跳转与类型推断。
|
||||
"""
|
||||
create_cct_params_frame = create_cct_params_frame
|
||||
_get_cct_var_dict = _get_cct_var_dict
|
||||
_parse_cct_float = _parse_cct_float
|
||||
_save_cct_params_for = _save_cct_params_for
|
||||
_handle_cct_focus_out = _handle_cct_focus_out
|
||||
on_sdr_cct_param_focus_out = on_sdr_cct_param_focus_out
|
||||
save_sdr_cct_params = save_sdr_cct_params
|
||||
on_hdr_cct_param_focus_out = on_hdr_cct_param_focus_out
|
||||
save_hdr_cct_params = save_hdr_cct_params
|
||||
recalculate_cct = recalculate_cct
|
||||
recalculate_gamut = recalculate_gamut
|
||||
on_cct_param_focus_out = on_cct_param_focus_out
|
||||
save_cct_params = save_cct_params
|
||||
reload_cct_params = reload_cct_params
|
||||
toggle_cct_params_frame = toggle_cct_params_frame
|
||||
_on_gamut_ref_changed = _on_gamut_ref_changed
|
||||
on_screen_gamut_ref_changed = on_screen_gamut_ref_changed
|
||||
on_sdr_gamut_ref_changed = on_sdr_gamut_ref_changed
|
||||
on_hdr_gamut_ref_changed = on_hdr_gamut_ref_changed
|
||||
|
||||
Reference in New Issue
Block a user