|
|
|
@ -391,19 +391,33 @@ struct Det_File_Result_Info
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (size_t i = 0; i < qx_result_list.size(); i++)
|
|
|
|
for (size_t i = 0; i < qx_result_list.size(); i++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
float fr = qx_result_list.at(i).num * 1.0 / qx_all_num * 100;
|
|
|
|
// 除零保护:没有任何缺陷统计时百分比按 0 处理
|
|
|
|
|
|
|
|
float fr = (qx_all_num > 0) ? (qx_result_list.at(i).num * 100.0f / qx_all_num) : 0.0f;
|
|
|
|
std::string str_qx = "";
|
|
|
|
std::string str_qx = "";
|
|
|
|
// printf("len %d \n", qx_result_list.at(i).qx_name.length());
|
|
|
|
// 名称补空格对齐到 20 字节。
|
|
|
|
for (int k = 0; k < (20 - qx_result_list.at(i).qx_name.length()); k++)
|
|
|
|
// 注意:qx_name.length() 返回 size_t(无符号),若写成 20 - length(),
|
|
|
|
|
|
|
|
// 当名称超过 20 字节时(中文缺陷名如"铜箔面不良标签"为 21 字节)会下溢成
|
|
|
|
|
|
|
|
// 巨大无符号值,导致循环近似死循环(-f 批量卡住的根因)。
|
|
|
|
|
|
|
|
size_t nNameLen = qx_result_list.at(i).qx_name.length();
|
|
|
|
|
|
|
|
if (nNameLen < 20)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
str_qx += " ";
|
|
|
|
str_qx.append(20 - nNameLen, ' ');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
str_qx += qx_result_list.at(i).qx_name;
|
|
|
|
str_qx += qx_result_list.at(i).qx_name;
|
|
|
|
char buffer123[64];
|
|
|
|
char buffer123[64];
|
|
|
|
sprintf(buffer123, ":%d %.1f%% ", qx_result_list.at(i).num, fr);
|
|
|
|
sprintf(buffer123, ":%d %.1f%% ", qx_result_list.at(i).num, fr);
|
|
|
|
std::string st1 = buffer123;
|
|
|
|
std::string st1 = buffer123;
|
|
|
|
str_qx += st1;
|
|
|
|
str_qx += st1;
|
|
|
|
int nlen = fr;
|
|
|
|
// 百分比条长度限制在 [0,100],避免异常值造成超长字符串
|
|
|
|
|
|
|
|
int nlen = static_cast<int>(fr);
|
|
|
|
|
|
|
|
if (nlen < 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
nlen = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nlen > 100)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
nlen = 100;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for (int j = 0; j < nlen; j++)
|
|
|
|
for (int j = 0; j < nlen; j++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|