4 #include <QDoubleSpinBox>
16 #define cmp_or_log(l,c,r) \
19 out << " FAILED: " #l " " #c " " #r " " \
20 << VAROUT(l) << ", " << VAROUT(r) << '\n',\
24 return cmp_or_log(desc.minPos.x, <=, desc.maxPos.x)
25 &&
cmp_or_log(desc.minPos.y, <=, desc.maxPos.y)
26 &&
cmp_or_log(desc.minPos.z, <=, desc.maxPos.z)
34 &&
cmp_or_log(desc.minRPY.x, <=, desc.maxRPY.x)
35 &&
cmp_or_log(desc.minRPY.y, <=, desc.maxRPY.y)
36 &&
cmp_or_log(desc.minRPY.z, <=, desc.maxRPY.z)
47 const QObject* stateChangeReceiver,
const char* stateChangeSlot)
50 QWidget* widget =
new QWidget;
51 QHBoxLayout* l =
new QHBoxLayout;
52 l->setContentsMargins(0, 0, 0, 0);
54 widget->setToolTip(QString::fromStdString(desc.toolTip));
56 Eigen::Vector3f minPos =
fromIce(desc.minPos);
57 Eigen::Vector3f maxPos =
fromIce(desc.maxPos);
58 Eigen::Vector3i decimalsPos =
fromIce(desc.decimalsPos);
59 Eigen::Vector3i stepsPos =
fromIce(desc.stepsPos);
60 for (
int i = 0; i < 3; ++i)
62 QDoubleSpinBox* e =
new QDoubleSpinBox;
64 e->setMinimum(minPos(i));
65 e->setMaximum(maxPos(i));
66 e->setDecimals(decimalsPos(i));
67 e->setSingleStep((maxPos(i) - minPos(i)) / stepsPos(i));
68 QObject::connect(e, SIGNAL(valueChanged(
double)), stateChangeReceiver, stateChangeSlot);
70 l->addWidget(
new QLabel{
"/"});
72 Eigen::Vector3f minRPY =
fromIce(desc.minRPY);
73 Eigen::Vector3f maxRPY =
fromIce(desc.maxRPY);
74 Eigen::Vector3i decimalsRPY =
fromIce(desc.decimalsRPY);
75 Eigen::Vector3i stepsRPY =
fromIce(desc.stepsRPY);
76 for (
int i = 0; i < 3; ++i)
78 QDoubleSpinBox* e =
new QDoubleSpinBox;
80 e->setMinimum(minRPY(i));
81 e->setMaximum(maxRPY(i));
82 e->setDecimals(decimalsRPY(i));
83 e->setSingleStep((maxRPY(i) - minRPY(i)) / stepsRPY(i));
84 QObject::connect(e, SIGNAL(valueChanged(
double)), stateChangeReceiver, stateChangeSlot);
92 ry = std::atan2(-m(2, 0), sqrtf(m(0, 0) * m(0, 0) + m(1, 0) * m(1, 0)));
94 if (fabs(ry -
static_cast<float>(
M_PI) * 0.5f) < 1e-10f)
97 rz = std::atan2(m(0, 1), m(1, 1));
99 else if (std::fabs(ry +
static_cast<float>(
M_PI) * 0.5f) < 1e-10f)
102 rz = -std::atan2(m(0, 1), m(1, 1));
106 float cb = 1.0f / std::cos(ry);
107 rx = std::atan2(m(2, 1) * cb, m(2, 2) * cb);
108 rz = std::atan2(m(1, 0) * cb, m(0, 0) * cb);
111 static_cast<QDoubleSpinBox*
>(widget->layout()->itemAt(0)->widget())->setValue(m(0, 3));
112 static_cast<QDoubleSpinBox*
>(widget->layout()->itemAt(1)->widget())->setValue(m(1, 3));
113 static_cast<QDoubleSpinBox*
>(widget->layout()->itemAt(2)->widget())->setValue(m(2, 3));
115 static_cast<QDoubleSpinBox*
>(widget->layout()->itemAt(4)->widget())->setValue(rx);
116 static_cast<QDoubleSpinBox*
>(widget->layout()->itemAt(5)->widget())->setValue(ry);
117 static_cast<QDoubleSpinBox*
>(widget->layout()->itemAt(6)->widget())->setValue(rz);
122 QWidgetT* parent =
static_cast<QWidget*
>(widget->parent());
126 const float tx =
static_cast<float>(
static_cast<QDoubleSpinBox*
>(parent->layout()->itemAt(0)->widget())->
value());
127 const float ty =
static_cast<float>(
static_cast<QDoubleSpinBox*
>(parent->layout()->itemAt(1)->widget())->
value());
128 const float tz =
static_cast<float>(
static_cast<QDoubleSpinBox*
>(parent->layout()->itemAt(2)->widget())->
value());
129 const float rx =
static_cast<float>(
static_cast<QDoubleSpinBox*
>(parent->layout()->itemAt(4)->widget())->
value());
130 const float ry =
static_cast<float>(
static_cast<QDoubleSpinBox*
>(parent->layout()->itemAt(5)->widget())->
value());
131 const float rz =
static_cast<float>(
static_cast<QDoubleSpinBox*
>(parent->layout()->itemAt(6)->widget())->
value());
133 const float sgamma = sinf(rx);
134 const float cgamma = cosf(rx);
135 const float sbeta = sinf(ry);
136 const float cbeta = cosf(ry);
137 const float salpha = sinf(rz);
138 const float calpha = cosf(rz);
140 m(0, 0) = calpha * cbeta;
141 m(0, 1) = calpha * sbeta * sgamma - salpha * cgamma;
142 m(0, 2) = calpha * sbeta * cgamma + salpha * sgamma;
145 m(1, 0) = salpha * cbeta;
146 m(1, 1) = salpha * sbeta * sgamma + calpha * cgamma;
147 m(1, 2) = salpha * sbeta * cgamma - calpha * sgamma;
151 m(2, 1) = cbeta * sgamma;
152 m(2, 2) = cbeta * cgamma;