继续优化色准测试结果显示模块
This commit is contained in:
@@ -75,7 +75,7 @@ def _xy_to_uv(x: float, y: float):
|
||||
# 子图:左侧 Calman 风格面板
|
||||
# ============================================================
|
||||
|
||||
def _draw_left_panel(ax, color_patches, delta_e_values):
|
||||
def _draw_left_panel(ax, color_patches, delta_e_values, font_scale=1.0):
|
||||
"""左侧仅保留大条形图。"""
|
||||
ax.clear()
|
||||
|
||||
@@ -99,11 +99,12 @@ def _draw_left_panel(ax, color_patches, delta_e_values):
|
||||
)
|
||||
|
||||
ax.set_yticks(y_pos)
|
||||
ax.set_yticklabels(color_patches, fontsize=7)
|
||||
ax.set_yticklabels(color_patches, fontsize=max(5, 7 * font_scale))
|
||||
ax.invert_yaxis()
|
||||
|
||||
x_max = max(15.0, max(delta_e_values) * 1.15)
|
||||
ax.set_xlim(0, x_max)
|
||||
ax.tick_params(axis="x", labelsize=max(6, 8 * font_scale))
|
||||
ax.grid(axis="x", linestyle="-", linewidth=0.6, alpha=0.3, zorder=0)
|
||||
ax.grid(axis="y", linestyle=":", linewidth=0.35, alpha=0.15, zorder=0)
|
||||
|
||||
@@ -117,7 +118,7 @@ def _draw_left_panel(ax, color_patches, delta_e_values):
|
||||
# 子图:CIE 1976 u'v' 色度图(目标 vs 实测)
|
||||
# ============================================================
|
||||
|
||||
def _draw_uv_diagram(ax, color_patches, measurements, standards):
|
||||
def _draw_uv_diagram(ax, color_patches, measurements, standards, font_scale=1.0):
|
||||
"""绘制 CIE 1976 u'v' 上的色准对比。"""
|
||||
ax.clear()
|
||||
try:
|
||||
@@ -136,11 +137,11 @@ def _draw_uv_diagram(ax, color_patches, measurements, standards):
|
||||
|
||||
ax.set_facecolor("#000")
|
||||
ax.set_aspect("equal", adjustable="box")
|
||||
ax.set_title("CIE 1976 u'v'", fontsize=11, fontweight="bold",
|
||||
ax.set_title("CIE 1976 u'v'", fontsize=max(8, 11 * font_scale), fontweight="bold",
|
||||
color="#111", pad=4)
|
||||
ax.set_xlabel("u'", fontsize=9, color="#222", labelpad=1)
|
||||
ax.set_ylabel("v'", fontsize=9, color="#222", labelpad=1)
|
||||
ax.tick_params(axis="both", labelsize=8, colors="#222")
|
||||
ax.set_xlabel("u'", fontsize=max(7, 9 * font_scale), color="#222", labelpad=1)
|
||||
ax.set_ylabel("v'", fontsize=max(7, 9 * font_scale), color="#222", labelpad=1)
|
||||
ax.tick_params(axis="both", labelsize=max(6, 8 * font_scale), colors="#222")
|
||||
for sp in ax.spines.values():
|
||||
sp.set_color("#666")
|
||||
sp.set_linewidth(0.9)
|
||||
@@ -190,7 +191,7 @@ def _draw_uv_diagram(ax, color_patches, measurements, standards):
|
||||
]
|
||||
leg = ax.legend(
|
||||
handles=legend_handles,
|
||||
loc="lower right", fontsize=8,
|
||||
loc="lower right", fontsize=max(6, 8 * font_scale),
|
||||
framealpha=0.88, labelcolor="#FFF",
|
||||
)
|
||||
if leg is not None:
|
||||
@@ -199,7 +200,7 @@ def _draw_uv_diagram(ax, color_patches, measurements, standards):
|
||||
leg.set_zorder(50)
|
||||
|
||||
|
||||
def _draw_result_judgement(ax, accuracy_data):
|
||||
def _draw_result_judgement(ax, accuracy_data, font_scale=1.0):
|
||||
"""底部结果条"""
|
||||
ax.clear()
|
||||
ax.set_xlim(0, 1)
|
||||
@@ -219,14 +220,14 @@ def _draw_result_judgement(ax, accuracy_data):
|
||||
0.03, 0.50,
|
||||
f"Avg dE2000: {avg:.2f}",
|
||||
ha="left", va="center",
|
||||
fontsize=20, fontweight="normal", color="#111111",
|
||||
fontsize=max(11, 20 * font_scale), fontweight="normal", color="#111111",
|
||||
transform=ax.transAxes,
|
||||
)
|
||||
ax.text(
|
||||
0.52, 0.50,
|
||||
f"Max dE2000: {mx:.2f}",
|
||||
ha="left", va="center",
|
||||
fontsize=20, fontweight="normal", color="#111111",
|
||||
fontsize=max(11, 20 * font_scale), fontweight="normal", color="#111111",
|
||||
transform=ax.transAxes,
|
||||
)
|
||||
|
||||
@@ -241,6 +242,17 @@ def plot_accuracy(self: "PQAutomationApp", accuracy_data, test_type):
|
||||
fig = self.accuracy_fig
|
||||
fig.clear()
|
||||
|
||||
# 根据当前画布像素尺寸动态缩放字体,避免窗口缩小时文字挤压重叠。
|
||||
font_scale = 1.0
|
||||
try:
|
||||
canvas_widget = self.accuracy_canvas.get_tk_widget()
|
||||
cw = max(1, int(canvas_widget.winfo_width()))
|
||||
ch = max(1, int(canvas_widget.winfo_height()))
|
||||
font_scale = min(cw / 1000.0, ch / 600.0)
|
||||
font_scale = max(0.60, min(1.0, font_scale))
|
||||
except Exception:
|
||||
font_scale = 1.0
|
||||
|
||||
color_patches = accuracy_data.get("color_patches", []) or []
|
||||
delta_e_values = accuracy_data.get("delta_e_values", []) or []
|
||||
measurements = accuracy_data.get("color_measurements", []) or []
|
||||
@@ -259,15 +271,21 @@ def plot_accuracy(self: "PQAutomationApp", accuracy_data, test_type):
|
||||
else:
|
||||
title = f"{test_type_name} - 色准测试(全 29色 | Gamma {target_gamma})"
|
||||
|
||||
fig.suptitle(title, fontsize=11, y=0.975, fontweight="bold", color="#111")
|
||||
fig.suptitle(
|
||||
title,
|
||||
fontsize=max(8, 11 * font_scale),
|
||||
y=0.975,
|
||||
fontweight="bold",
|
||||
color="#111",
|
||||
)
|
||||
|
||||
gs = fig.add_gridspec(
|
||||
2, 2,
|
||||
width_ratios=[1.12, 1.0],
|
||||
height_ratios=[4.0, 0.62],
|
||||
height_ratios=[4.8, 0.48],
|
||||
left=0.08, right=0.985,
|
||||
top=0.91, bottom=0.06,
|
||||
wspace=0.14, hspace=0.10,
|
||||
top=0.92, bottom=0.05,
|
||||
wspace=0.14, hspace=0.08,
|
||||
)
|
||||
|
||||
ax_left = fig.add_subplot(gs[0, 0])
|
||||
@@ -277,14 +295,26 @@ def plot_accuracy(self: "PQAutomationApp", accuracy_data, test_type):
|
||||
# 兼容外部对 self.accuracy_ax 的引用
|
||||
self.accuracy_ax = ax_judge
|
||||
|
||||
_draw_left_panel(ax_left, color_patches, delta_e_values)
|
||||
_draw_left_panel(ax_left, color_patches, delta_e_values, font_scale=font_scale)
|
||||
|
||||
try:
|
||||
standards = get_accuracy_color_standards(test_type)
|
||||
except Exception:
|
||||
standards = {}
|
||||
_draw_uv_diagram(ax_uv, color_patches, measurements, standards)
|
||||
_draw_result_judgement(ax_judge, accuracy_data)
|
||||
|
||||
_draw_uv_diagram(
|
||||
ax_uv,
|
||||
color_patches,
|
||||
measurements,
|
||||
standards,
|
||||
font_scale=font_scale,
|
||||
)
|
||||
_draw_result_judgement(ax_judge, accuracy_data, font_scale=font_scale)
|
||||
|
||||
try:
|
||||
self.update_accuracy_result_table(accuracy_data, standards)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
self.accuracy_canvas.draw()
|
||||
self.chart_notebook.select(self.accuracy_chart_frame)
|
||||
|
||||
Reference in New Issue
Block a user