重构删除/移动主文件冗余函数
This commit is contained in:
@@ -182,231 +182,138 @@ def toggle_log_panel(self):
|
||||
self.show_panel("log")
|
||||
|
||||
|
||||
def toggle_screen_debug_panel(self):
|
||||
"""打开/关闭屏模组单步调试面板(独立窗口)"""
|
||||
# ---- 单步调试面板(统一实现) ----
|
||||
DEBUG_PANEL_CONFIGS = {
|
||||
"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 单步调试"),
|
||||
],
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
def _toggle_debug_panel(self, test_type):
|
||||
"""打开/关闭对应测试类型的单步调试面板(独立窗口)。"""
|
||||
cfg = DEBUG_PANEL_CONFIGS[test_type]
|
||||
win_attr = cfg["window_attr"]
|
||||
btn = getattr(self, cfg["btn_attr"])
|
||||
wlp = cfg["window_log_prefix"]
|
||||
|
||||
# 如果窗口已存在且可见,关闭它
|
||||
if hasattr(self, "debug_window") and self.debug_window.winfo_exists():
|
||||
self.debug_window.destroy()
|
||||
self.screen_debug_btn.config(text="打开调试面板")
|
||||
self.log_gui.log("✓ 单步调试面板已关闭")
|
||||
existing = getattr(self, win_attr, None)
|
||||
if existing is not None and existing.winfo_exists():
|
||||
existing.destroy()
|
||||
btn.config(text="打开调试面板")
|
||||
self.log_gui.log(f"✓ {wlp}单步调试面板已关闭")
|
||||
return
|
||||
|
||||
# 创建新窗口
|
||||
self.debug_window = ttk.Toplevel(self.root)
|
||||
self.debug_window.title("🔧 单步调试面板")
|
||||
self.debug_window.geometry("900x400")
|
||||
self.debug_window.transient(self.root)
|
||||
win = ttk.Toplevel(self.root)
|
||||
win.title(cfg["title"])
|
||||
win.geometry("900x400")
|
||||
win.transient(self.root)
|
||||
setattr(self, win_attr, win)
|
||||
|
||||
# 创建调试面板容器
|
||||
debug_container = ttk.Frame(self.debug_window, padding=10)
|
||||
debug_container.pack(fill=tk.BOTH, expand=True) # ← 这个 pack 是对的
|
||||
|
||||
# 创建调试面板实例
|
||||
from app.views.pq_debug_panel import PQDebugPanel
|
||||
# 调试面板容器
|
||||
debug_container = ttk.Frame(win, padding=10)
|
||||
debug_container.pack(fill=tk.BOTH, expand=True)
|
||||
|
||||
# 创建调试面板实例(不要对它调用 pack)
|
||||
debug_panel_instance = PQDebugPanel(debug_container, self)
|
||||
# ← 这里不应该有任何 pack 调用!
|
||||
|
||||
self.log_gui.log("✓ 单步调试面板实例已创建")
|
||||
self.log_gui.log(f"✓ {wlp}单步调试面板实例已创建")
|
||||
|
||||
# 重新启用调试(如果有数据)
|
||||
try:
|
||||
test_type = self.config.current_test_type
|
||||
selected_items = self.get_selected_test_items()
|
||||
|
||||
if test_type == "screen_module":
|
||||
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(
|
||||
"screen_module", "gamma", gray_data
|
||||
)
|
||||
self.log_gui.log("✓ 屏模组 Gamma 单步调试已重新启用")
|
||||
else:
|
||||
dlp = cfg["data_log_prefix"]
|
||||
for item_key, debug_key, (cat, sub), data_label, enable_desc in cfg["data_items"]:
|
||||
if item_key not in selected_items:
|
||||
continue
|
||||
data = self.results.get_intermediate_data(cat, sub)
|
||||
if not data:
|
||||
if test_type == "screen_module" and item_key == "gamma":
|
||||
self.log_gui.log(" ✗ 没有可用的灰阶数据")
|
||||
|
||||
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(
|
||||
"screen_module", "rgb", rgb_data
|
||||
)
|
||||
self.log_gui.log("✓ 屏模组 RGB 单步调试已重新启用")
|
||||
|
||||
continue
|
||||
self.log_gui.log(f" → 加载 {len(data)} 个{data_label}数据点")
|
||||
debug_panel_instance.enable_debug(test_type, debug_key, data)
|
||||
self.log_gui.log(f"✓ {dlp} {enable_desc}已重新启用")
|
||||
except Exception as e:
|
||||
self.log_gui.log(f"⚠️ 加载调试数据失败: {str(e)}")
|
||||
import traceback
|
||||
|
||||
self.log_gui.log(f"⚠️ 加载{cfg['failure_data_label']}失败: {str(e)}")
|
||||
self.log_gui.log(traceback.format_exc())
|
||||
|
||||
# 更新按钮文字
|
||||
self.screen_debug_btn.config(text="关闭调试面板")
|
||||
btn.config(text="关闭调试面板")
|
||||
|
||||
# 窗口关闭时的回调
|
||||
def on_closing():
|
||||
self.screen_debug_btn.config(text="打开调试面板")
|
||||
self.debug_window.destroy()
|
||||
self.log_gui.log("✓ 单步调试窗口已关闭")
|
||||
btn.config(text="打开调试面板")
|
||||
getattr(self, win_attr).destroy()
|
||||
self.log_gui.log(f"✓ {wlp}单步调试窗口已关闭")
|
||||
|
||||
self.debug_window.protocol("WM_DELETE_WINDOW", on_closing)
|
||||
self.debug_window.update_idletasks()
|
||||
win.protocol("WM_DELETE_WINDOW", on_closing)
|
||||
win.update_idletasks()
|
||||
|
||||
self.log_gui.log("✓ 单步调试面板已打开(独立窗口)")
|
||||
self.log_gui.log(f"✓ {wlp}单步调试面板已打开(独立窗口)")
|
||||
|
||||
|
||||
def toggle_screen_debug_panel(self):
|
||||
_toggle_debug_panel(self, "screen_module")
|
||||
|
||||
|
||||
def toggle_sdr_debug_panel(self):
|
||||
"""打开/关闭 SDR 单步调试面板(独立窗口)"""
|
||||
# 如果窗口已存在且可见,关闭它
|
||||
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)
|
||||
from app.views.pq_debug_panel import PQDebugPanel
|
||||
|
||||
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 单步调试面板已打开(独立窗口)")
|
||||
_toggle_debug_panel(self, "sdr_movie")
|
||||
|
||||
|
||||
def toggle_hdr_debug_panel(self):
|
||||
"""打开/关闭 HDR 单步调试面板(独立窗口)"""
|
||||
# 如果窗口已存在且可见,关闭它
|
||||
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)
|
||||
from app.views.pq_debug_panel import PQDebugPanel
|
||||
|
||||
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 单步调试面板已打开(独立窗口)")
|
||||
_toggle_debug_panel(self, "hdr_movie")
|
||||
|
||||
|
||||
|
||||
def update_sidebar_selection(self):
|
||||
"""更新侧边栏按钮的选中状态"""
|
||||
# 重置所有按钮样式为默认
|
||||
self.screen_module_btn.configure(style="Sidebar.TButton")
|
||||
self.sdr_movie_btn.configure(style="Sidebar.TButton")
|
||||
self.hdr_movie_btn.configure(style="Sidebar.TButton")
|
||||
|
||||
# 设置当前选中按钮的样式
|
||||
current_type = self.test_type_var.get()
|
||||
if current_type == "screen_module":
|
||||
self.screen_module_btn.configure(style="SidebarSelected.TButton")
|
||||
elif current_type == "sdr_movie":
|
||||
self.sdr_movie_btn.configure(style="SidebarSelected.TButton")
|
||||
elif current_type == "hdr_movie":
|
||||
self.hdr_movie_btn.configure(style="SidebarSelected.TButton")
|
||||
|
||||
Reference in New Issue
Block a user