修复误删文件
This commit is contained in:
@@ -5,6 +5,32 @@ import copy
|
|||||||
|
|
||||||
class PQConfig:
|
class PQConfig:
|
||||||
def __init__(self, current_test_type="screen_module", device_config={}, pattern={}):
|
def __init__(self, current_test_type="screen_module", device_config={}, pattern={}):
|
||||||
|
self.default_cct_params_by_type = {
|
||||||
|
"screen_module": {
|
||||||
|
"x_ideal": 0.3127,
|
||||||
|
"x_tolerance": 0.003,
|
||||||
|
"y_ideal": 0.3290,
|
||||||
|
"y_tolerance": 0.003,
|
||||||
|
},
|
||||||
|
"sdr_movie": {
|
||||||
|
"x_ideal": 0.3127,
|
||||||
|
"x_tolerance": 0.003,
|
||||||
|
"y_ideal": 0.3290,
|
||||||
|
"y_tolerance": 0.003,
|
||||||
|
},
|
||||||
|
"hdr_movie": {
|
||||||
|
"x_ideal": 0.3127,
|
||||||
|
"x_tolerance": 0.003,
|
||||||
|
"y_ideal": 0.3290,
|
||||||
|
"y_tolerance": 0.003,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
self.default_gamut_reference_by_type = {
|
||||||
|
"screen_module": "DCI-P3",
|
||||||
|
"sdr_movie": "BT.709",
|
||||||
|
"hdr_movie": "BT.2020",
|
||||||
|
}
|
||||||
|
|
||||||
self.default_test_types = {
|
self.default_test_types = {
|
||||||
"screen_module": {
|
"screen_module": {
|
||||||
"name": "屏模组性能测试",
|
"name": "屏模组性能测试",
|
||||||
@@ -285,6 +311,17 @@ class PQConfig:
|
|||||||
self.current_test_type = current_test_type
|
self.current_test_type = current_test_type
|
||||||
self.current_pattern = self.default_pattern_rgb
|
self.current_pattern = self.default_pattern_rgb
|
||||||
|
|
||||||
|
def get_default_cct_params(self, test_type):
|
||||||
|
"""获取指定测试类型的默认 CCT 参数副本。"""
|
||||||
|
default = self.default_cct_params_by_type.get(
|
||||||
|
test_type, self.default_cct_params_by_type["screen_module"]
|
||||||
|
)
|
||||||
|
return copy.deepcopy(default)
|
||||||
|
|
||||||
|
def get_default_gamut_reference(self, test_type):
|
||||||
|
"""获取指定测试类型的默认色域参考。"""
|
||||||
|
return self.default_gamut_reference_by_type.get(test_type, "DCI-P3")
|
||||||
|
|
||||||
# ========== 获取临时配置(用于 Full/Limited 转换)==========
|
# ========== 获取临时配置(用于 Full/Limited 转换)==========
|
||||||
def get_temp_config_with_converted_params(self, mode, converted_params):
|
def get_temp_config_with_converted_params(self, mode, converted_params):
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import ttkbootstrap as ttk
|
|||||||
|
|
||||||
import algorithm.pq_algorithm as pq_algorithm
|
import algorithm.pq_algorithm as pq_algorithm
|
||||||
|
|
||||||
|
|
||||||
def create_cct_params_frame(self):
|
def create_cct_params_frame(self):
|
||||||
"""创建色度参数设置区域 - 屏模组、SDR、HDR 独立(✅ 增加色域参考标准选择 + 单步调试按钮)"""
|
"""创建色度参数设置区域 - 屏模组、SDR、HDR 独立(✅ 增加色域参考标准选择 + 单步调试按钮)"""
|
||||||
|
|
||||||
@@ -558,8 +559,6 @@ def recalculate_cct(self):
|
|||||||
self.log_gui.log("开始重新计算色度一致性...")
|
self.log_gui.log("开始重新计算色度一致性...")
|
||||||
self.log_gui.log("=" * 50)
|
self.log_gui.log("=" * 50)
|
||||||
|
|
||||||
import algorithm.pq_algorithm as pq_algorithm
|
|
||||||
|
|
||||||
cct_values = pq_algorithm.calculate_cct_from_results(gray_data)
|
cct_values = pq_algorithm.calculate_cct_from_results(gray_data)
|
||||||
|
|
||||||
# 7. 更新结果
|
# 7. 更新结果
|
||||||
@@ -576,8 +575,6 @@ def recalculate_cct(self):
|
|||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.log_gui.log(f"❌ 重新计算失败: {str(e)}")
|
self.log_gui.log(f"❌ 重新计算失败: {str(e)}")
|
||||||
import traceback
|
|
||||||
|
|
||||||
self.log_gui.log(traceback.format_exc())
|
self.log_gui.log(traceback.format_exc())
|
||||||
messagebox.showerror("错误", f"重新计算失败: {str(e)}")
|
messagebox.showerror("错误", f"重新计算失败: {str(e)}")
|
||||||
|
|
||||||
@@ -633,7 +630,6 @@ def recalculate_gamut(self):
|
|||||||
# 7. 重新计算 XY 色域覆盖率
|
# 7. 重新计算 XY 色域覆盖率
|
||||||
xy_points = [[result[0], result[1]] for result in rgb_data]
|
xy_points = [[result[0], result[1]] for result in rgb_data]
|
||||||
|
|
||||||
# 根据参考标准计算 XY 覆盖率
|
|
||||||
if reference_standard == "BT.2020":
|
if reference_standard == "BT.2020":
|
||||||
area_xy, coverage_xy = pq_algorithm.calculate_gamut_coverage_BT2020(
|
area_xy, coverage_xy = pq_algorithm.calculate_gamut_coverage_BT2020(
|
||||||
xy_points
|
xy_points
|
||||||
@@ -655,12 +651,10 @@ def recalculate_gamut(self):
|
|||||||
self.log_gui.log(f"✓ 参考标准: {reference_standard}")
|
self.log_gui.log(f"✓ 参考标准: {reference_standard}")
|
||||||
self.log_gui.log(f"✓ XY 色域覆盖率: {coverage_xy:.1f}%")
|
self.log_gui.log(f"✓ XY 色域覆盖率: {coverage_xy:.1f}%")
|
||||||
|
|
||||||
# ========== ✅✅✅ 8. 重新计算 UV 色域覆盖率 ==========
|
# 8. 重新计算 UV 色域覆盖率
|
||||||
# 将 XY 坐标转换为 UV 坐标
|
|
||||||
uv_points = []
|
uv_points = []
|
||||||
for x, y in xy_points:
|
for x, y in xy_points:
|
||||||
try:
|
try:
|
||||||
# XY转UV公式
|
|
||||||
denom = -2 * x + 12 * y + 3
|
denom = -2 * x + 12 * y + 3
|
||||||
if abs(denom) < 1e-10:
|
if abs(denom) < 1e-10:
|
||||||
u, v = 0, 0
|
u, v = 0, 0
|
||||||
@@ -673,7 +667,6 @@ def recalculate_gamut(self):
|
|||||||
|
|
||||||
self.log_gui.log(f"✓ 转换后的 UV 点数量: {len(uv_points)}")
|
self.log_gui.log(f"✓ 转换后的 UV 点数量: {len(uv_points)}")
|
||||||
|
|
||||||
# 根据参考标准计算 UV 覆盖率
|
|
||||||
if reference_standard == "BT.2020":
|
if reference_standard == "BT.2020":
|
||||||
area_uv, coverage_uv = pq_algorithm.calculate_gamut_coverage_BT2020_uv(
|
area_uv, coverage_uv = pq_algorithm.calculate_gamut_coverage_BT2020_uv(
|
||||||
uv_points
|
uv_points
|
||||||
@@ -692,19 +685,18 @@ def recalculate_gamut(self):
|
|||||||
)
|
)
|
||||||
|
|
||||||
self.log_gui.log(f"✓ UV 色域覆盖率: {coverage_uv:.1f}%")
|
self.log_gui.log(f"✓ UV 色域覆盖率: {coverage_uv:.1f}%")
|
||||||
# ========================================================
|
|
||||||
|
|
||||||
# 9. ✅ 更新结果(同时保存 XY 和 UV 覆盖率)
|
# 9. 更新结果
|
||||||
self.results.set_test_item_result(
|
self.results.set_test_item_result(
|
||||||
"gamut",
|
"gamut",
|
||||||
{
|
{
|
||||||
"area": area_xy, # ← 兼容旧字段
|
"area": area_xy,
|
||||||
"coverage": coverage_xy, # ← 兼容旧字段
|
"coverage": coverage_xy,
|
||||||
"area_xy": area_xy, # ← XY 面积
|
"area_xy": area_xy,
|
||||||
"coverage_xy": coverage_xy, # ← XY 覆盖率
|
"coverage_xy": coverage_xy,
|
||||||
"area_uv": area_uv, # ← UV 面积
|
"area_uv": area_uv,
|
||||||
"coverage_uv": coverage_uv, # ← UV 覆盖率
|
"coverage_uv": coverage_uv,
|
||||||
"uv_coverage": coverage_uv, # ← 兼容字段(Excel 导出用)
|
"uv_coverage": coverage_uv,
|
||||||
"reference": reference_standard,
|
"reference": reference_standard,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@@ -726,8 +718,6 @@ def recalculate_gamut(self):
|
|||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.log_gui.log(f"❌ 重新计算失败: {str(e)}")
|
self.log_gui.log(f"❌ 重新计算失败: {str(e)}")
|
||||||
import traceback
|
|
||||||
|
|
||||||
self.log_gui.log(traceback.format_exc())
|
self.log_gui.log(traceback.format_exc())
|
||||||
messagebox.showerror("错误", f"重新计算失败: {str(e)}")
|
messagebox.showerror("错误", f"重新计算失败: {str(e)}")
|
||||||
|
|
||||||
@@ -738,12 +728,10 @@ def on_cct_param_change(self, var, default_value):
|
|||||||
value = var.get().strip()
|
value = var.get().strip()
|
||||||
|
|
||||||
if value == "":
|
if value == "":
|
||||||
# 空值:恢复默认值
|
|
||||||
var.set(str(default_value))
|
var.set(str(default_value))
|
||||||
if hasattr(self, "log_gui"):
|
if hasattr(self, "log_gui"):
|
||||||
self.log_gui.log(f"输入框为空,恢复默认值: {default_value}")
|
self.log_gui.log(f"输入框为空,恢复默认值: {default_value}")
|
||||||
else:
|
else:
|
||||||
# 验证是否为有效数字
|
|
||||||
try:
|
try:
|
||||||
float_val = float(value)
|
float_val = float(value)
|
||||||
if float_val < 0 or float_val > 1:
|
if float_val < 0 or float_val > 1:
|
||||||
@@ -757,7 +745,6 @@ def on_cct_param_change(self, var, default_value):
|
|||||||
if hasattr(self, "log_gui"):
|
if hasattr(self, "log_gui"):
|
||||||
self.log_gui.log(f"无效的参数值,恢复默认值: {default_value}")
|
self.log_gui.log(f"无效的参数值,恢复默认值: {default_value}")
|
||||||
|
|
||||||
# 保存配置
|
|
||||||
self.save_cct_params()
|
self.save_cct_params()
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@@ -771,12 +758,10 @@ def on_cct_param_focus_out(self, var, default_value):
|
|||||||
value = var.get().strip()
|
value = var.get().strip()
|
||||||
|
|
||||||
if value == "":
|
if value == "":
|
||||||
# 空值:恢复默认值
|
|
||||||
var.set(str(default_value))
|
var.set(str(default_value))
|
||||||
if hasattr(self, "log_gui"):
|
if hasattr(self, "log_gui"):
|
||||||
self.log_gui.log(f"✓ 输入框为空,恢复默认值: {default_value}")
|
self.log_gui.log(f"✓ 输入框为空,恢复默认值: {default_value}")
|
||||||
else:
|
else:
|
||||||
# 验证是否为有效数字
|
|
||||||
try:
|
try:
|
||||||
float_val = float(value)
|
float_val = float(value)
|
||||||
if float_val < 0 or float_val > 1:
|
if float_val < 0 or float_val > 1:
|
||||||
@@ -790,7 +775,6 @@ def on_cct_param_focus_out(self, var, default_value):
|
|||||||
if hasattr(self, "log_gui"):
|
if hasattr(self, "log_gui"):
|
||||||
self.log_gui.log(f"⚠️ 无效的参数值,恢复默认值: {default_value}")
|
self.log_gui.log(f"⚠️ 无效的参数值,恢复默认值: {default_value}")
|
||||||
|
|
||||||
# 保存配置
|
|
||||||
self.save_cct_params()
|
self.save_cct_params()
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@@ -857,45 +841,3 @@ def reload_cct_params(self):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
if hasattr(self, "log_gui"):
|
if hasattr(self, "log_gui"):
|
||||||
self.log_gui.log(f"重新加载色度参数失败: {str(e)}")
|
self.log_gui.log(f"重新加载色度参数失败: {str(e)}")
|
||||||
|
|
||||||
|
|
||||||
def toggle_cct_params_frame(self):
|
|
||||||
"""根据测试类型和测试项的选中状态显示对应参数框"""
|
|
||||||
selected_items = self.get_selected_test_items()
|
|
||||||
current_test_type = self.config.current_test_type
|
|
||||||
|
|
||||||
# ========== 默认隐藏所有参数框 ==========
|
|
||||||
self.cct_params_frame.pack_forget()
|
|
||||||
self.sdr_cct_params_frame.pack_forget()
|
|
||||||
|
|
||||||
# HDR 色度参数框(如果存在的话)
|
|
||||||
if hasattr(self, "hdr_cct_params_frame"):
|
|
||||||
self.hdr_cct_params_frame.pack_forget()
|
|
||||||
|
|
||||||
# ========== 根据测试类型和选中项显示对应参数框 ==========
|
|
||||||
if current_test_type == "screen_module":
|
|
||||||
# 屏模组:只有色度参数
|
|
||||||
if "cct" in selected_items:
|
|
||||||
self.cct_params_frame.pack(fill=tk.X, padx=5, pady=5)
|
|
||||||
if hasattr(self, "log_gui"):
|
|
||||||
self.log_gui.log("✓ 显示屏模组色度参数设置")
|
|
||||||
|
|
||||||
elif current_test_type == "sdr_movie":
|
|
||||||
# SDR:只有色度参数(色准不需要参数设置框)
|
|
||||||
if "cct" in selected_items:
|
|
||||||
self.sdr_cct_params_frame.pack(fill=tk.X, padx=5, pady=5)
|
|
||||||
if hasattr(self, "log_gui"):
|
|
||||||
self.log_gui.log("✓ 显示 SDR 色度参数设置")
|
|
||||||
|
|
||||||
elif current_test_type == "hdr_movie":
|
|
||||||
# HDR:只有色度参数(色准不需要参数设置框)
|
|
||||||
if "cct" in selected_items:
|
|
||||||
if hasattr(self, "hdr_cct_params_frame"):
|
|
||||||
self.hdr_cct_params_frame.pack(fill=tk.X, padx=5, pady=5)
|
|
||||||
if hasattr(self, "log_gui"):
|
|
||||||
self.log_gui.log("✓ 显示 HDR 色度参数设置")
|
|
||||||
else:
|
|
||||||
if hasattr(self, "log_gui"):
|
|
||||||
self.log_gui.log("⚠️ HDR 色度参数框尚未创建")
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -139,6 +139,15 @@ from app.views.panels.custom_template_panel import (
|
|||||||
start_custom_row_single_step as _ctpl_start_custom_row_single_step,
|
start_custom_row_single_step as _ctpl_start_custom_row_single_step,
|
||||||
start_custom_template_test as _ctpl_start_custom_template_test,
|
start_custom_template_test as _ctpl_start_custom_template_test,
|
||||||
)
|
)
|
||||||
|
from app.views.panels.main_layout import (
|
||||||
|
create_connection_content as _layout_create_connection_content,
|
||||||
|
create_floating_config_panel as _layout_create_floating_config_panel,
|
||||||
|
create_operation_frame as _layout_create_operation_frame,
|
||||||
|
create_signal_format_content as _layout_create_signal_format_content,
|
||||||
|
create_test_items_content as _layout_create_test_items_content,
|
||||||
|
create_test_type_frame as _layout_create_test_type_frame,
|
||||||
|
update_config_info_display as _layout_update_config_info_display,
|
||||||
|
)
|
||||||
from app.views.panels.cct_panel import (
|
from app.views.panels.cct_panel import (
|
||||||
create_cct_params_frame as _cct_create_cct_params_frame,
|
create_cct_params_frame as _cct_create_cct_params_frame,
|
||||||
on_cct_param_change as _cct_on_cct_param_change,
|
on_cct_param_change as _cct_on_cct_param_change,
|
||||||
@@ -151,16 +160,6 @@ from app.views.panels.cct_panel import (
|
|||||||
save_cct_params as _cct_save_cct_params,
|
save_cct_params as _cct_save_cct_params,
|
||||||
save_hdr_cct_params as _cct_save_hdr_cct_params,
|
save_hdr_cct_params as _cct_save_hdr_cct_params,
|
||||||
save_sdr_cct_params as _cct_save_sdr_cct_params,
|
save_sdr_cct_params as _cct_save_sdr_cct_params,
|
||||||
toggle_cct_params_frame as _cct_toggle_cct_params_frame,
|
|
||||||
)
|
|
||||||
from app.views.panels.main_layout import (
|
|
||||||
create_connection_content as _layout_create_connection_content,
|
|
||||||
create_floating_config_panel as _layout_create_floating_config_panel,
|
|
||||||
create_operation_frame as _layout_create_operation_frame,
|
|
||||||
create_signal_format_content as _layout_create_signal_format_content,
|
|
||||||
create_test_items_content as _layout_create_test_items_content,
|
|
||||||
create_test_type_frame as _layout_create_test_type_frame,
|
|
||||||
update_config_info_display as _layout_update_config_info_display,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
plt.rcParams["font.family"] = ["sans-serif"]
|
plt.rcParams["font.family"] = ["sans-serif"]
|
||||||
@@ -2836,7 +2835,35 @@ class PQAutomationApp:
|
|||||||
# 控制参数框的显示
|
# 控制参数框的显示
|
||||||
self.toggle_cct_params_frame()
|
self.toggle_cct_params_frame()
|
||||||
|
|
||||||
toggle_cct_params_frame = _cct_toggle_cct_params_frame
|
def toggle_cct_params_frame(self):
|
||||||
|
"""根据测试类型和测试项的选中状态显示对应参数框"""
|
||||||
|
selected_items = self.get_selected_test_items()
|
||||||
|
current_test_type = self.config.current_test_type
|
||||||
|
# 默认隐藏所有参数框
|
||||||
|
self.cct_params_frame.pack_forget()
|
||||||
|
self.sdr_cct_params_frame.pack_forget()
|
||||||
|
if hasattr(self, "hdr_cct_params_frame"):
|
||||||
|
self.hdr_cct_params_frame.pack_forget()
|
||||||
|
# 根据测试类型和选中项显示对应参数框
|
||||||
|
if current_test_type == "screen_module":
|
||||||
|
if "cct" in selected_items:
|
||||||
|
self.cct_params_frame.pack(fill=tk.X, padx=5, pady=5)
|
||||||
|
if hasattr(self, "log_gui"):
|
||||||
|
self.log_gui.log("✓ 显示屏模组色度参数设置")
|
||||||
|
elif current_test_type == "sdr_movie":
|
||||||
|
if "cct" in selected_items:
|
||||||
|
self.sdr_cct_params_frame.pack(fill=tk.X, padx=5, pady=5)
|
||||||
|
if hasattr(self, "log_gui"):
|
||||||
|
self.log_gui.log("✓ 显示 SDR 色度参数设置")
|
||||||
|
elif current_test_type == "hdr_movie":
|
||||||
|
if "cct" in selected_items:
|
||||||
|
if hasattr(self, "hdr_cct_params_frame"):
|
||||||
|
self.hdr_cct_params_frame.pack(fill=tk.X, padx=5, pady=5)
|
||||||
|
if hasattr(self, "log_gui"):
|
||||||
|
self.log_gui.log("✓ 显示 HDR 色度参数设置")
|
||||||
|
else:
|
||||||
|
if hasattr(self, "log_gui"):
|
||||||
|
self.log_gui.log("⚠️ HDR 色度参数框尚未创建")
|
||||||
|
|
||||||
def on_screen_module_timing_changed(self, event=None):
|
def on_screen_module_timing_changed(self, event=None):
|
||||||
"""屏模组信号格式改变时的回调"""
|
"""屏模组信号格式改变时的回调"""
|
||||||
|
|||||||
Reference in New Issue
Block a user