2 #include "ui_quaternion_to_rpy.h"
4 #include <QDialogButtonBox>
7 #include <QDragEnterEvent>
15 ui =
new Ui::quaternion_to_RPY;
19 ui->lineEditX->installEventFilter(
this);
20 ui->lineEditY->installEventFilter(
this);
21 ui->lineEditZ->installEventFilter(
this);
22 ui->lineEditW->installEventFilter(
this);
26 connect(
ui->checkBoxUnwrap, &QCheckBox::toggled,
this,
29 connect(
ui->radioButtonDegrees, &QRadioButton::toggled,
this,
32 connect(
ui->pushButtonSave, &QPushButton::clicked,
this,
48 auto preview_layout =
new QHBoxLayout(
ui->framePlotPreview);
49 preview_layout->setMargin(6);
53 std::pair<QWidget*, PJ::ToolboxPlugin::WidgetType>
66 if (ev->type() == QEvent::DragEnter)
68 auto event =
static_cast<QDragEnterEvent*
>(ev);
69 const QMimeData* mimeData =
event->mimeData();
70 QStringList mimeFormats = mimeData->formats();
72 for (
const QString&
format : mimeFormats)
74 QByteArray encoded = mimeData->data(
format);
75 QDataStream stream(&encoded, QIODevice::ReadOnly);
77 if (
format !=
"curveslist/add_curve")
83 while (!stream.atEnd())
87 if (!curve_name.isEmpty())
89 curves.push_back(curve_name);
92 if (curves.size() != 1)
99 if (obj ==
ui->lineEditX || obj ==
ui->lineEditY || obj ==
ui->lineEditZ ||
100 obj ==
ui->lineEditW)
102 event->acceptProposedAction();
107 else if (ev->type() == QEvent::Drop)
109 auto lineEdit = qobject_cast<QLineEdit*>(obj);
131 QStringList suffix = {
"x",
"y",
"z",
"w" };
132 std::array<QLineEdit*, 4> lineEdits = {
ui->lineEditX,
ui->lineEditY,
ui->lineEditZ,
135 for (
int i = 0; i < 4; i++)
137 QString
name = prefix + suffix[i];
141 names.push_back(
name);
145 if (names.size() == 4)
147 for (
int i = 0; i < 4; i++)
149 lineEdits[i]->setText(names[i]);
151 ui->lineEditOut->setText(prefix);
152 ui->pushButtonSave->setEnabled(
true);
162 bool wrap =
ui->checkBoxUnwrap->isChecked();
163 double unit_scale =
ui->radioButtonDegrees->isChecked() ? (180.0 /
M_PI) : 1.0;
164 auto transform = std::make_shared<QuaternionToRollPitchYaw>();
166 std::vector<const PlotData*> src_data;
168 for (QLineEdit* line : {
ui->lineEditX,
ui->lineEditY,
ui->lineEditZ,
ui->lineEditW })
175 src_data.push_back(&it->second);
179 std::string prefix =
ui->lineEditOut->text().toStdString();
198 transform->setData(
_plot_data, src_data, dst_vector);
199 transform->setWarp(wrap);
200 transform->setScale(unit_scale);
202 transform->calculate();
207 for (
auto dst_data : dst_vector)
216 _transforms->insert({ prefix +
"RPY", transform });
229 ui->lineEditX->setText({});
230 ui->lineEditY->setText({});
231 ui->lineEditZ->setText({});
232 ui->lineEditW->setText({});
233 ui->lineEditOut->setText({});
241 if (
ui->lineEditX->text().isEmpty() ||
ui->lineEditY->text().isEmpty() ||
242 ui->lineEditZ->text().isEmpty() ||
ui->lineEditW->text().isEmpty() ||
243 ui->lineEditOut->text().isEmpty())
245 ui->pushButtonSave->setEnabled(
false);
249 ui->pushButtonSave->setEnabled(valid);