2026-08-04 14:23:07 +08:00
|
|
|
#include "resultitem.h"
|
|
|
|
|
#include "ui_resultitem.h"
|
|
|
|
|
|
2026-08-17 14:11:44 +08:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
|
|
QString WorkpiecePositionText(int workpieceType)
|
|
|
|
|
{
|
|
|
|
|
switch (workpieceType) {
|
|
|
|
|
case 0: return QStringLiteral("中央");
|
|
|
|
|
case 1: return QStringLiteral("上边");
|
|
|
|
|
case 2: return QStringLiteral("下边");
|
|
|
|
|
case 3: return QStringLiteral("左边");
|
|
|
|
|
case 4: return QStringLiteral("右边");
|
|
|
|
|
case 5: return QStringLiteral("左上角");
|
|
|
|
|
case 6: return QStringLiteral("右上角");
|
|
|
|
|
case 7: return QStringLiteral("左下角");
|
|
|
|
|
case 8: return QStringLiteral("右下角");
|
|
|
|
|
default: return QStringLiteral("未知");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
2026-08-04 14:23:07 +08:00
|
|
|
ResultItem::ResultItem(QWidget *parent)
|
|
|
|
|
: QWidget(parent)
|
|
|
|
|
, ui(new Ui::ResultItem)
|
|
|
|
|
{
|
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
|
|
|
|
|
// 强制应用样式表
|
|
|
|
|
this->setAttribute(Qt::WA_StyledBackground, true);
|
|
|
|
|
|
|
|
|
|
// 初始化时设置样式
|
|
|
|
|
setItemStyle();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ResultItem::~ResultItem()
|
|
|
|
|
{
|
|
|
|
|
delete ui;
|
|
|
|
|
}
|
|
|
|
|
|
2026-08-17 14:11:44 +08:00
|
|
|
void ResultItem::setResultData(
|
|
|
|
|
int workpieceIndex,
|
|
|
|
|
const WorkpiecePosition& position,
|
|
|
|
|
bool isCurrentPickup)
|
2026-08-04 14:23:07 +08:00
|
|
|
{
|
2026-08-17 14:11:44 +08:00
|
|
|
ui->result_id->setStyleSheet(isCurrentPickup
|
|
|
|
|
? QStringLiteral("color: rgb(255, 213, 79); background-color: transparent;")
|
|
|
|
|
: QStringLiteral("color: rgb(239, 241, 245); background-color: transparent;"));
|
|
|
|
|
ui->result_id->setText(QString("工件 %1 位置:%2")
|
2026-08-04 14:23:07 +08:00
|
|
|
.arg(workpieceIndex)
|
2026-08-17 14:11:44 +08:00
|
|
|
.arg(WorkpiecePositionText(position.workpieceType)));
|
2026-08-04 14:23:07 +08:00
|
|
|
|
|
|
|
|
ui->result_xyz_rpy->setText(QString(
|
|
|
|
|
"X:%1 Y:%2 Z:%3 R:%4 P:%5 Y:%6")
|
|
|
|
|
.arg(position.x, 0, 'f', 3)
|
|
|
|
|
.arg(position.y, 0, 'f', 3)
|
|
|
|
|
.arg(position.z, 0, 'f', 3)
|
|
|
|
|
.arg(position.roll, 0, 'f', 3)
|
|
|
|
|
.arg(position.pitch, 0, 'f', 3)
|
|
|
|
|
.arg(position.yaw, 0, 'f', 3));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ResultItem::setItemStyle()
|
|
|
|
|
{
|
|
|
|
|
// 设置边框作为分隔线
|
|
|
|
|
this->setStyleSheet(
|
|
|
|
|
"ResultItem { "
|
|
|
|
|
" border: 1px solid #191A1C; "
|
|
|
|
|
" border-radius: 0px; "
|
|
|
|
|
"} "
|
|
|
|
|
);
|
|
|
|
|
}
|