47 lines
1.8 KiB
C++
47 lines
1.8 KiB
C++
#include "XyzRpyItem.h"
|
|
#include "ui_XyzRpyItem.h"
|
|
|
|
XyzRpyItem::XyzRpyItem(QWidget *parent)
|
|
: QWidget(parent)
|
|
, ui(new Ui::XyzRpyItem)
|
|
{
|
|
ui->setupUi(this);
|
|
|
|
// 寮哄埗搴旂敤鏍峰紡琛?
|
|
this->setAttribute(Qt::WA_StyledBackground, true);
|
|
}
|
|
|
|
XyzRpyItem::~XyzRpyItem()
|
|
{
|
|
delete ui;
|
|
}
|
|
|
|
void XyzRpyItem::setResultData(int index, const QString& titlePrefix, const PositionData<double>& position, int precision)
|
|
{
|
|
// 璁剧疆鏍囬锛氬墠缂€ + 缂栧彿
|
|
ui->result_id->setText(QString("%1 %2").arg(titlePrefix).arg(index));
|
|
|
|
// 鍧愭爣锛氭瘡琛屼竴涓酱
|
|
ui->result_x->setText(QString("X: %1").arg(position.x, 0, 'f', precision));
|
|
ui->result_y->setText(QString("Y: %1").arg(position.y, 0, 'f', precision));
|
|
ui->result_z->setText(QString("Z: %1").arg(position.z, 0, 'f', precision));
|
|
|
|
// 濮挎€佽锛氭瘡琛屼竴涓?
|
|
ui->result_r->setText(QString("A: %1").arg(position.roll, 0, 'f', precision));
|
|
ui->result_p->setText(QString("B: %1").arg(position.pitch, 0, 'f', precision));
|
|
ui->result_yaw->setText(QString("C: %1").arg(position.yaw, 0, 'f', precision));
|
|
}
|
|
|
|
void XyzRpyItem::setResultData(int index, const QString& titlePrefix,
|
|
const QString& locationText,
|
|
const PositionData<double>& position,
|
|
bool highlighted, int precision)
|
|
{
|
|
setResultData(index, titlePrefix, position, precision);
|
|
if (!locationText.isEmpty()) {
|
|
ui->result_id->setText(QString("%1%2 %3").arg(titlePrefix).arg(index).arg(locationText));
|
|
}
|
|
const QString color = highlighted ? QStringLiteral("rgb(255, 90, 90)") : QStringLiteral("rgb(239, 241, 245)");
|
|
ui->result_id->setStyleSheet(QString("color: %1; background-color: transparent; border: none;").arg(color));
|
|
}
|