重构提取部分面板切换函数
This commit is contained in:
@@ -3651,272 +3651,150 @@ class PQAutomationApp:
|
|||||||
print(f"关闭窗口时出错: {str(e)}")
|
print(f"关闭窗口时出错: {str(e)}")
|
||||||
self.root.destroy()
|
self.root.destroy()
|
||||||
|
|
||||||
def on_screen_gamut_ref_changed(self, event=None):
|
# ---- gamut 参考标准改变回调(统一实现) ----
|
||||||
"""屏模组色域参考标准改变时的回调"""
|
_GAMUT_REF_CONFIGS = {
|
||||||
|
"screen_module": {"var_attr": "screen_gamut_ref_var", "label": "屏模组"},
|
||||||
|
"sdr_movie": {"var_attr": "sdr_gamut_ref_var", "label": "SDR"},
|
||||||
|
"hdr_movie": {"var_attr": "hdr_gamut_ref_var", "label": "HDR"},
|
||||||
|
}
|
||||||
|
|
||||||
|
def _on_gamut_ref_changed(self, test_type, event=None):
|
||||||
|
cfg = self._GAMUT_REF_CONFIGS[test_type]
|
||||||
try:
|
try:
|
||||||
new_ref = self.screen_gamut_ref_var.get()
|
new_ref = getattr(self, cfg["var_attr"]).get()
|
||||||
self.log_gui.log(f"✓ 屏模组色域参考标准已更改为: {new_ref}")
|
self.log_gui.log(f"✓ {cfg['label']} 色域参考标准已更改为: {new_ref}")
|
||||||
|
|
||||||
# 保存到配置
|
if test_type not in self.config.current_test_types:
|
||||||
if "screen_module" not in self.config.current_test_types:
|
self.config.current_test_types[test_type] = {}
|
||||||
self.config.current_test_types["screen_module"] = {}
|
self.config.current_test_types[test_type]["gamut_reference"] = new_ref
|
||||||
|
|
||||||
self.config.current_test_types["screen_module"]["gamut_reference"] = new_ref
|
|
||||||
self.save_pq_config()
|
self.save_pq_config()
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.log_gui.log(f"保存屏模组色域参考标准失败: {str(e)}")
|
self.log_gui.log(f"保存 {cfg['label']} 色域参考标准失败: {str(e)}")
|
||||||
|
|
||||||
|
def on_screen_gamut_ref_changed(self, event=None):
|
||||||
|
self._on_gamut_ref_changed("screen_module", event)
|
||||||
|
|
||||||
def on_sdr_gamut_ref_changed(self, event=None):
|
def on_sdr_gamut_ref_changed(self, event=None):
|
||||||
"""SDR 色域参考标准改变时的回调"""
|
self._on_gamut_ref_changed("sdr_movie", event)
|
||||||
try:
|
|
||||||
new_ref = self.sdr_gamut_ref_var.get()
|
|
||||||
self.log_gui.log(f"✓ SDR 色域参考标准已更改为: {new_ref}")
|
|
||||||
|
|
||||||
# 保存到配置
|
|
||||||
if "sdr_movie" not in self.config.current_test_types:
|
|
||||||
self.config.current_test_types["sdr_movie"] = {}
|
|
||||||
|
|
||||||
self.config.current_test_types["sdr_movie"]["gamut_reference"] = new_ref
|
|
||||||
self.save_pq_config()
|
|
||||||
|
|
||||||
except Exception as e:
|
|
||||||
self.log_gui.log(f"保存 SDR 色域参考标准失败: {str(e)}")
|
|
||||||
|
|
||||||
def on_hdr_gamut_ref_changed(self, event=None):
|
def on_hdr_gamut_ref_changed(self, event=None):
|
||||||
"""HDR 色域参考标准改变时的回调"""
|
self._on_gamut_ref_changed("hdr_movie", event)
|
||||||
try:
|
|
||||||
new_ref = self.hdr_gamut_ref_var.get()
|
|
||||||
self.log_gui.log(f"✓ HDR 色域参考标准已更改为: {new_ref}")
|
|
||||||
|
|
||||||
# 保存到配置
|
# ---- 单步调试面板(统一实现) ----
|
||||||
if "hdr_movie" not in self.config.current_test_types:
|
_DEBUG_PANEL_CONFIGS = {
|
||||||
self.config.current_test_types["hdr_movie"] = {}
|
"screen_module": {
|
||||||
|
"window_attr": "debug_window",
|
||||||
|
"btn_attr": "screen_debug_btn",
|
||||||
|
"title": "🔧 单步调试面板",
|
||||||
|
"window_log_prefix": "",
|
||||||
|
"data_log_prefix": "屏模组",
|
||||||
|
"failure_data_label": "调试数据",
|
||||||
|
# (item_key, debug_key, (category, subkey), data_label, enable_desc)
|
||||||
|
"data_items": [
|
||||||
|
("gamma", "gamma", ("shared", "gray"), "灰阶", "Gamma 单步调试"),
|
||||||
|
("gamut", "rgb", ("gamut", "rgb"), "RGB", "RGB 单步调试"),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
"sdr_movie": {
|
||||||
|
"window_attr": "sdr_debug_window",
|
||||||
|
"btn_attr": "sdr_debug_btn",
|
||||||
|
"title": "🔧 SDR 单步调试面板",
|
||||||
|
"window_log_prefix": "SDR ",
|
||||||
|
"data_log_prefix": "SDR",
|
||||||
|
"failure_data_label": "SDR 调试数据",
|
||||||
|
"data_items": [
|
||||||
|
("gamma", "gamma", ("shared", "gray"), "灰阶", "Gamma 单步调试"),
|
||||||
|
("accuracy", "accuracy", ("accuracy", "measured"), "色准", "色准单步调试"),
|
||||||
|
("gamut", "rgb", ("gamut", "rgb"), "RGB", "RGB 单步调试"),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
"hdr_movie": {
|
||||||
|
"window_attr": "hdr_debug_window",
|
||||||
|
"btn_attr": "hdr_debug_btn",
|
||||||
|
"title": "🔧 HDR 单步调试面板",
|
||||||
|
"window_log_prefix": "HDR ",
|
||||||
|
"data_log_prefix": "HDR",
|
||||||
|
"failure_data_label": "HDR 调试数据",
|
||||||
|
"data_items": [
|
||||||
|
("eotf", "eotf", ("shared", "gray"), "灰阶", "EOTF 单步调试"),
|
||||||
|
("accuracy", "accuracy", ("accuracy", "measured"), "色准", "色准单步调试"),
|
||||||
|
("gamut", "rgb", ("gamut", "rgb"), "RGB", "RGB 单步调试"),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
self.config.current_test_types["hdr_movie"]["gamut_reference"] = new_ref
|
def _toggle_debug_panel(self, test_type):
|
||||||
self.save_pq_config()
|
"""打开/关闭对应测试类型的单步调试面板(独立窗口)。"""
|
||||||
|
cfg = self._DEBUG_PANEL_CONFIGS[test_type]
|
||||||
|
win_attr = cfg["window_attr"]
|
||||||
|
btn = getattr(self, cfg["btn_attr"])
|
||||||
|
wlp = cfg["window_log_prefix"]
|
||||||
|
|
||||||
except Exception as e:
|
|
||||||
self.log_gui.log(f"保存 HDR 色域参考标准失败: {str(e)}")
|
|
||||||
|
|
||||||
def toggle_screen_debug_panel(self):
|
|
||||||
"""打开/关闭屏模组单步调试面板(独立窗口)"""
|
|
||||||
# 如果窗口已存在且可见,关闭它
|
# 如果窗口已存在且可见,关闭它
|
||||||
if hasattr(self, "debug_window") and self.debug_window.winfo_exists():
|
existing = getattr(self, win_attr, None)
|
||||||
self.debug_window.destroy()
|
if existing is not None and existing.winfo_exists():
|
||||||
self.screen_debug_btn.config(text="打开调试面板")
|
existing.destroy()
|
||||||
self.log_gui.log("✓ 单步调试面板已关闭")
|
btn.config(text="打开调试面板")
|
||||||
|
self.log_gui.log(f"✓ {wlp}单步调试面板已关闭")
|
||||||
return
|
return
|
||||||
|
|
||||||
# 创建新窗口
|
# 创建新窗口
|
||||||
self.debug_window = ttk.Toplevel(self.root)
|
win = ttk.Toplevel(self.root)
|
||||||
self.debug_window.title("🔧 单步调试面板")
|
win.title(cfg["title"])
|
||||||
self.debug_window.geometry("900x400")
|
win.geometry("900x400")
|
||||||
self.debug_window.transient(self.root)
|
win.transient(self.root)
|
||||||
|
setattr(self, win_attr, win)
|
||||||
|
|
||||||
# 创建调试面板容器
|
# 调试面板容器
|
||||||
debug_container = ttk.Frame(self.debug_window, padding=10)
|
debug_container = ttk.Frame(win, padding=10)
|
||||||
debug_container.pack(fill=tk.BOTH, expand=True) # ← 这个 pack 是对的
|
debug_container.pack(fill=tk.BOTH, expand=True)
|
||||||
|
|
||||||
# 创建调试面板实例
|
# 创建调试面板实例(不要对它调用 pack)
|
||||||
debug_panel_instance = PQDebugPanel(debug_container, self)
|
debug_panel_instance = PQDebugPanel(debug_container, self)
|
||||||
# ← 这里不应该有任何 pack 调用!
|
|
||||||
|
|
||||||
self.log_gui.log("✓ 单步调试面板实例已创建")
|
self.log_gui.log(f"✓ {wlp}单步调试面板实例已创建")
|
||||||
|
|
||||||
# 重新启用调试(如果有数据)
|
# 重新启用调试(如果有数据)
|
||||||
try:
|
try:
|
||||||
test_type = self.config.current_test_type
|
|
||||||
selected_items = self.get_selected_test_items()
|
selected_items = self.get_selected_test_items()
|
||||||
|
dlp = cfg["data_log_prefix"]
|
||||||
if test_type == "screen_module":
|
for item_key, debug_key, (cat, sub), data_label, enable_desc in cfg["data_items"]:
|
||||||
if "gamma" in selected_items:
|
if item_key not in selected_items:
|
||||||
gray_data = self.results.get_intermediate_data("shared", "gray")
|
continue
|
||||||
if gray_data:
|
data = self.results.get_intermediate_data(cat, sub)
|
||||||
self.log_gui.log(f" → 加载 {len(gray_data)} 个灰阶数据点")
|
if not data:
|
||||||
debug_panel_instance.enable_debug(
|
if test_type == "screen_module" and item_key == "gamma":
|
||||||
"screen_module", "gamma", gray_data
|
|
||||||
)
|
|
||||||
self.log_gui.log("✓ 屏模组 Gamma 单步调试已重新启用")
|
|
||||||
else:
|
|
||||||
self.log_gui.log(" ✗ 没有可用的灰阶数据")
|
self.log_gui.log(" ✗ 没有可用的灰阶数据")
|
||||||
|
continue
|
||||||
if "gamut" in selected_items:
|
self.log_gui.log(f" → 加载 {len(data)} 个{data_label}数据点")
|
||||||
rgb_data = self.results.get_intermediate_data("gamut", "rgb")
|
debug_panel_instance.enable_debug(test_type, debug_key, data)
|
||||||
if rgb_data:
|
self.log_gui.log(f"✓ {dlp} {enable_desc}已重新启用")
|
||||||
self.log_gui.log(f" → 加载 {len(rgb_data)} 个RGB数据点")
|
|
||||||
debug_panel_instance.enable_debug(
|
|
||||||
"screen_module", "rgb", rgb_data
|
|
||||||
)
|
|
||||||
self.log_gui.log("✓ 屏模组 RGB 单步调试已重新启用")
|
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.log_gui.log(f"⚠️ 加载调试数据失败: {str(e)}")
|
self.log_gui.log(f"⚠️ 加载{cfg['failure_data_label']}失败: {str(e)}")
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
self.log_gui.log(traceback.format_exc())
|
self.log_gui.log(traceback.format_exc())
|
||||||
|
|
||||||
# 更新按钮文字
|
btn.config(text="关闭调试面板")
|
||||||
self.screen_debug_btn.config(text="关闭调试面板")
|
|
||||||
|
|
||||||
# 窗口关闭时的回调
|
|
||||||
def on_closing():
|
def on_closing():
|
||||||
self.screen_debug_btn.config(text="打开调试面板")
|
btn.config(text="打开调试面板")
|
||||||
self.debug_window.destroy()
|
getattr(self, win_attr).destroy()
|
||||||
self.log_gui.log("✓ 单步调试窗口已关闭")
|
self.log_gui.log(f"✓ {wlp}单步调试窗口已关闭")
|
||||||
|
|
||||||
self.debug_window.protocol("WM_DELETE_WINDOW", on_closing)
|
win.protocol("WM_DELETE_WINDOW", on_closing)
|
||||||
self.debug_window.update_idletasks()
|
win.update_idletasks()
|
||||||
|
|
||||||
self.log_gui.log("✓ 单步调试面板已打开(独立窗口)")
|
self.log_gui.log(f"✓ {wlp}单步调试面板已打开(独立窗口)")
|
||||||
|
|
||||||
|
def toggle_screen_debug_panel(self):
|
||||||
|
self._toggle_debug_panel("screen_module")
|
||||||
|
|
||||||
def toggle_sdr_debug_panel(self):
|
def toggle_sdr_debug_panel(self):
|
||||||
"""打开/关闭 SDR 单步调试面板(独立窗口)"""
|
self._toggle_debug_panel("sdr_movie")
|
||||||
# 如果窗口已存在且可见,关闭它
|
|
||||||
if hasattr(self, "sdr_debug_window") and self.sdr_debug_window.winfo_exists():
|
|
||||||
self.sdr_debug_window.destroy()
|
|
||||||
self.sdr_debug_btn.config(text="打开调试面板")
|
|
||||||
self.log_gui.log("✓ SDR 单步调试面板已关闭")
|
|
||||||
return
|
|
||||||
|
|
||||||
# 创建新窗口
|
|
||||||
self.sdr_debug_window = ttk.Toplevel(self.root)
|
|
||||||
self.sdr_debug_window.title("🔧 SDR 单步调试面板")
|
|
||||||
self.sdr_debug_window.geometry("900x400")
|
|
||||||
self.sdr_debug_window.transient(self.root)
|
|
||||||
|
|
||||||
# 创建调试面板容器
|
|
||||||
debug_container = ttk.Frame(self.sdr_debug_window, padding=10)
|
|
||||||
debug_container.pack(fill=tk.BOTH, expand=True)
|
|
||||||
|
|
||||||
# ✅ 创建调试面板实例(不要对它调用 pack)
|
|
||||||
debug_panel_instance = PQDebugPanel(debug_container, self)
|
|
||||||
# ← 删除:debug_panel_instance.pack(...)
|
|
||||||
|
|
||||||
self.log_gui.log("✓ SDR 单步调试面板实例已创建")
|
|
||||||
|
|
||||||
# ✅ 重新启用调试(如果有数据)
|
|
||||||
try:
|
|
||||||
selected_items = self.get_selected_test_items()
|
|
||||||
|
|
||||||
if "gamma" in selected_items:
|
|
||||||
gray_data = self.results.get_intermediate_data("shared", "gray")
|
|
||||||
if gray_data:
|
|
||||||
self.log_gui.log(f" → 加载 {len(gray_data)} 个灰阶数据点")
|
|
||||||
debug_panel_instance.enable_debug("sdr_movie", "gamma", gray_data)
|
|
||||||
self.log_gui.log("✓ SDR Gamma 单步调试已重新启用")
|
|
||||||
|
|
||||||
if "accuracy" in selected_items:
|
|
||||||
accuracy_data = self.results.get_intermediate_data(
|
|
||||||
"accuracy", "measured"
|
|
||||||
)
|
|
||||||
if accuracy_data:
|
|
||||||
self.log_gui.log(f" → 加载 {len(accuracy_data)} 个色准数据点")
|
|
||||||
debug_panel_instance.enable_debug(
|
|
||||||
"sdr_movie", "accuracy", accuracy_data
|
|
||||||
)
|
|
||||||
self.log_gui.log("✓ SDR 色准单步调试已重新启用")
|
|
||||||
|
|
||||||
if "gamut" in selected_items:
|
|
||||||
rgb_data = self.results.get_intermediate_data("gamut", "rgb")
|
|
||||||
if rgb_data:
|
|
||||||
self.log_gui.log(f" → 加载 {len(rgb_data)} 个RGB数据点")
|
|
||||||
debug_panel_instance.enable_debug("sdr_movie", "rgb", rgb_data)
|
|
||||||
self.log_gui.log("✓ SDR RGB 单步调试已重新启用")
|
|
||||||
|
|
||||||
except Exception as e:
|
|
||||||
self.log_gui.log(f"⚠️ 加载 SDR 调试数据失败: {str(e)}")
|
|
||||||
import traceback
|
|
||||||
|
|
||||||
self.log_gui.log(traceback.format_exc())
|
|
||||||
|
|
||||||
# 更新按钮文字
|
|
||||||
self.sdr_debug_btn.config(text="关闭调试面板")
|
|
||||||
|
|
||||||
# 窗口关闭时的回调
|
|
||||||
def on_closing():
|
|
||||||
self.sdr_debug_btn.config(text="打开调试面板")
|
|
||||||
self.sdr_debug_window.destroy()
|
|
||||||
self.log_gui.log("✓ SDR 单步调试窗口已关闭")
|
|
||||||
|
|
||||||
self.sdr_debug_window.protocol("WM_DELETE_WINDOW", on_closing)
|
|
||||||
self.sdr_debug_window.update_idletasks()
|
|
||||||
|
|
||||||
self.log_gui.log("✓ SDR 单步调试面板已打开(独立窗口)")
|
|
||||||
|
|
||||||
def toggle_hdr_debug_panel(self):
|
def toggle_hdr_debug_panel(self):
|
||||||
"""打开/关闭 HDR 单步调试面板(独立窗口)"""
|
self._toggle_debug_panel("hdr_movie")
|
||||||
# 如果窗口已存在且可见,关闭它
|
|
||||||
if hasattr(self, "hdr_debug_window") and self.hdr_debug_window.winfo_exists():
|
|
||||||
self.hdr_debug_window.destroy()
|
|
||||||
self.hdr_debug_btn.config(text="打开调试面板")
|
|
||||||
self.log_gui.log("✓ HDR 单步调试面板已关闭")
|
|
||||||
return
|
|
||||||
|
|
||||||
# 创建新窗口
|
|
||||||
self.hdr_debug_window = ttk.Toplevel(self.root)
|
|
||||||
self.hdr_debug_window.title("🔧 HDR 单步调试面板")
|
|
||||||
self.hdr_debug_window.geometry("900x400")
|
|
||||||
self.hdr_debug_window.transient(self.root)
|
|
||||||
|
|
||||||
# 创建调试面板容器
|
|
||||||
debug_container = ttk.Frame(self.hdr_debug_window, padding=10)
|
|
||||||
debug_container.pack(fill=tk.BOTH, expand=True)
|
|
||||||
|
|
||||||
# ✅ 创建调试面板实例(不要对它调用 pack)
|
|
||||||
debug_panel_instance = PQDebugPanel(debug_container, self)
|
|
||||||
# ← 删除:debug_panel_instance.pack(...)
|
|
||||||
|
|
||||||
self.log_gui.log("✓ HDR 单步调试面板实例已创建")
|
|
||||||
|
|
||||||
# ✅ 重新启用调试(如果有数据)
|
|
||||||
try:
|
|
||||||
selected_items = self.get_selected_test_items()
|
|
||||||
|
|
||||||
if "eotf" in selected_items:
|
|
||||||
gray_data = self.results.get_intermediate_data("shared", "gray")
|
|
||||||
if gray_data:
|
|
||||||
self.log_gui.log(f" → 加载 {len(gray_data)} 个灰阶数据点")
|
|
||||||
debug_panel_instance.enable_debug("hdr_movie", "eotf", gray_data)
|
|
||||||
self.log_gui.log("✓ HDR EOTF 单步调试已重新启用")
|
|
||||||
|
|
||||||
if "accuracy" in selected_items:
|
|
||||||
accuracy_data = self.results.get_intermediate_data(
|
|
||||||
"accuracy", "measured"
|
|
||||||
)
|
|
||||||
if accuracy_data:
|
|
||||||
self.log_gui.log(f" → 加载 {len(accuracy_data)} 个色准数据点")
|
|
||||||
debug_panel_instance.enable_debug(
|
|
||||||
"hdr_movie", "accuracy", accuracy_data
|
|
||||||
)
|
|
||||||
self.log_gui.log("✓ HDR 色准单步调试已重新启用")
|
|
||||||
|
|
||||||
if "gamut" in selected_items:
|
|
||||||
rgb_data = self.results.get_intermediate_data("gamut", "rgb")
|
|
||||||
if rgb_data:
|
|
||||||
self.log_gui.log(f" → 加载 {len(rgb_data)} 个RGB数据点")
|
|
||||||
debug_panel_instance.enable_debug("hdr_movie", "rgb", rgb_data)
|
|
||||||
self.log_gui.log("✓ HDR RGB 单步调试已重新启用")
|
|
||||||
|
|
||||||
except Exception as e:
|
|
||||||
self.log_gui.log(f"⚠️ 加载 HDR 调试数据失败: {str(e)}")
|
|
||||||
import traceback
|
|
||||||
|
|
||||||
self.log_gui.log(traceback.format_exc())
|
|
||||||
|
|
||||||
# 更新按钮文字
|
|
||||||
self.hdr_debug_btn.config(text="关闭调试面板")
|
|
||||||
|
|
||||||
# 窗口关闭时的回调
|
|
||||||
def on_closing():
|
|
||||||
self.hdr_debug_btn.config(text="打开调试面板")
|
|
||||||
self.hdr_debug_window.destroy()
|
|
||||||
self.log_gui.log("✓ HDR 单步调试窗口已关闭")
|
|
||||||
|
|
||||||
self.hdr_debug_window.protocol("WM_DELETE_WINDOW", on_closing)
|
|
||||||
self.hdr_debug_window.update_idletasks()
|
|
||||||
|
|
||||||
self.log_gui.log("✓ HDR 单步调试面板已打开(独立窗口)")
|
|
||||||
|
|
||||||
clear_config_file = _cfg_clear_config_file
|
clear_config_file = _cfg_clear_config_file
|
||||||
start_local_dimming_test = _ld_start_local_dimming_test
|
start_local_dimming_test = _ld_start_local_dimming_test
|
||||||
|
|||||||
Reference in New Issue
Block a user