32const double M_PI = std::acos(-1.0);
33const double M_PI_2 = M_PI / 2.0;
38 #define DEG2RAD(angle) ((angle) * M_PI / 180.0)
41 #define RAD2DEG(angle) ((angle) * 180.0 / M_PI)
62class cSensorManipulator :
public QWidget
69 virtual void ValuesChangedInManipulator(cSensorManipulator* pManip) = 0;
72 explicit cSensorManipulator(QWidget* parent =
nullptr, Qt::WindowFlags flags = Qt::Widget): QWidget(parent)
74 setWindowFlags(flags);
77 auto pLayout =
new QGridLayout;
78 auto pLabel =
new QLabel(
"Roll [degrees]",
this);
80 pLayout->addWidget(pLabel, row, 0);
82 m_pRollSlider =
new QSlider(Qt::Horizontal,
this);
83 m_pRollSlider->setMinimum(-1799);
84 m_pRollSlider->setMaximum(1800);
85 m_pRollSlider->setPageStep(10);
86 m_pRollSlider->setValue(0);
87 pLayout->addWidget(m_pRollSlider, row, 1);
88 QObject::connect(m_pRollSlider, SIGNAL(valueChanged(
int)),
this, SLOT(rollChanged(
int)));
90 m_pRollLine =
new QLineEdit;
91 m_pRollLine->setText(
"0.0");
92 pLayout->addWidget(m_pRollLine, row, 2);
93 QObject::connect(m_pRollLine, SIGNAL(editingFinished()),
this, SLOT(rollEditFinished()));
99 pLabel =
new QLabel(
"Pitch [degrees]",
this);
100 pLayout->addWidget(pLabel, row, 0);
102 m_pPitchSlider =
new QSlider(Qt::Horizontal,
this);
103 m_pPitchSlider->setMinimum(-1799);
104 m_pPitchSlider->setMaximum(1800);
105 m_pPitchSlider->setPageStep(10);
106 m_pPitchSlider->setValue(0);
107 pLayout->addWidget(m_pPitchSlider, row, 1);
108 QObject::connect(m_pPitchSlider, SIGNAL(valueChanged(
int)),
this, SLOT(pitchChanged(
int)));
110 m_pPitchLine =
new QLineEdit;
111 m_pPitchLine->setText(
"0.0");
112 pLayout->addWidget(m_pPitchLine, row, 2);
113 QObject::connect(m_pPitchLine, SIGNAL(editingFinished()),
this, SLOT(pitchEditFinished()));
119 pLabel =
new QLabel(
"Yaw [degrees]",
this);
120 pLayout->addWidget(pLabel, row, 0);
122 m_pYawSlider =
new QSlider(Qt::Horizontal,
this);
123 m_pYawSlider->setMinimum(-1799);
124 m_pYawSlider->setMaximum(1800);
125 m_pYawSlider->setPageStep(10);
126 m_pYawSlider->setValue(0);
127 pLayout->addWidget(m_pYawSlider, row, 1);
128 QObject::connect(m_pYawSlider, SIGNAL(valueChanged(
int)),
this, SLOT(yawChanged(
int)));
130 m_pYawLine =
new QLineEdit;
131 m_pYawLine->setText(
"0.0");
132 pLayout->addWidget(m_pYawLine, row, 2);
133 QObject::connect(m_pYawLine, SIGNAL(editingFinished()),
this, SLOT(yawEditFinished()));
139 pLabel =
new QLabel(
"X [m]",
this);
140 pLayout->addWidget(pLabel, row, 0);
142 m_pXSlider =
new QSlider(Qt::Horizontal,
this);
143 m_pXSlider->setMinimum(-10000);
144 m_pXSlider->setMaximum(10000);
145 m_pXSlider->setPageStep(100);
146 m_pXSlider->setValue(0);
147 pLayout->addWidget(m_pXSlider, row, 1);
148 QObject::connect(m_pXSlider, SIGNAL(valueChanged(
int)),
this, SLOT(xChanged(
int)));
150 m_pXLine =
new QLineEdit;
151 m_pXLine->setText(
"0.00");
152 pLayout->addWidget(m_pXLine, row, 2);
153 QObject::connect(m_pXLine, SIGNAL(editingFinished()),
this, SLOT(xEditFinished()));
159 pLabel =
new QLabel(
"Y [m]",
this);
160 pLayout->addWidget(pLabel, row, 0);
162 m_pYSlider =
new QSlider(Qt::Horizontal,
this);
163 m_pYSlider->setMinimum(-10000);
164 m_pYSlider->setMaximum(10000);
165 m_pYSlider->setPageStep(100);
166 m_pYSlider->setValue(0);
167 pLayout->addWidget(m_pYSlider, row, 1);
168 QObject::connect(m_pYSlider, SIGNAL(valueChanged(
int)),
this, SLOT(yChanged(
int)));
170 m_pYLine =
new QLineEdit;
171 m_pYLine->setText(
"0.00");
172 pLayout->addWidget(m_pYLine, row, 2);
173 QObject::connect(m_pYLine, SIGNAL(editingFinished()),
this, SLOT(yEditFinished()));
179 pLabel =
new QLabel(
"Z [m]",
this);
180 pLayout->addWidget(pLabel, row, 0);
182 m_pZSlider =
new QSlider(Qt::Horizontal,
this);
183 m_pZSlider->setMinimum(-10000);
184 m_pZSlider->setMaximum(10000);
185 m_pZSlider->setPageStep(100);
186 m_pZSlider->setValue(0);
187 pLayout->addWidget(m_pZSlider, row, 1);
188 QObject::connect(m_pZSlider, SIGNAL(valueChanged(
int)),
this, SLOT(zChanged(
int)));
190 m_pZLine =
new QLineEdit;
191 m_pZLine->setText(
"0.00");
192 pLayout->addWidget(m_pZLine, row, 2);
193 QObject::connect(m_pZLine, SIGNAL(editingFinished()),
this, SLOT(zEditFinished()));
195 pLayout->setColumnMinimumWidth(1, 200);
196 pLayout->setColumnStretch(1, 1);
201 ~cSensorManipulator()
override =
default;
204 void setRollPitchYawRad(tFloat64 fRoll, tFloat64 fPitch, tFloat64 fYaw)
206 setRollPitchYawDeg(RAD2DEG(fRoll), RAD2DEG(fPitch), RAD2DEG(fYaw));
210 void setRollPitchYawDeg(tFloat64 fRoll, tFloat64 fPitch, tFloat64 fYaw)
212 m_pRollSlider->setValue(
static_cast<int>(fRoll * 10.0f + 0.5f));
213 m_pRollLine->setText(QString(
"%1").arg(fRoll, 0,
'f', 1));
214 m_pPitchSlider->setValue(
static_cast<int>(fPitch * 10.0f + 0.5f));
215 m_pPitchLine->setText(QString(
"%1").arg(fPitch, 0,
'f', 1));
216 m_pYawSlider->setValue(
static_cast<int>(fYaw * 10.0f + 0.5f));
217 m_pYawLine->setText(QString(
"%1").arg(fYaw, 0,
'f', 1));
221 void getRollPitchYawRad(tFloat64& fRoll, tFloat64& fPitch, tFloat64& fYaw)
223 fRoll = DEG2RAD(m_pRollSlider->value() / 10.0f);
224 fPitch = DEG2RAD(m_pPitchSlider->value() / 10.0f);
225 fYaw = DEG2RAD(m_pYawSlider->value() / 10.0f);
229 void setXYZ(tFloat64 fX, tFloat64 fY, tFloat64 fZ)
231 m_pXSlider->setValue(
static_cast<int>(fX * 100.0f + 0.5f));
232 m_pXLine->setText(QString(
"%1").arg(fX, 0,
'f', 2));
233 m_pYSlider->setValue(
static_cast<int>(fY * 100.0f + 0.5f));
234 m_pYLine->setText(QString(
"%1").arg(fY, 0,
'f', 2));
235 m_pZSlider->setValue(
static_cast<int>(fZ * 100.0f + 0.5f));
236 m_pZLine->setText(QString(
"%1").arg(fZ, 0,
'f', 2));
240 void getXYZ(tFloat64& fX, tFloat64& fY, tFloat64& fZ)
242 fX = (tFloat64) m_pXSlider->value() / 100.0f;
243 fY = (tFloat64) m_pYSlider->value() / 100.0f;
244 fZ = (tFloat64) m_pZSlider->value() / 100.0f;
247 void setDelegate(Delegate* deleg,
void* userData =
nullptr)
250 m_pUserData = userData;
259 void rollChanged(
int value)
261 m_pRollLine->setText(QString(
"%1").arg(
static_cast<float>(value / 10.0f), 0,
'f', 1));
264 m_pDeleg->ValuesChangedInManipulator(
this);
268 void rollEditFinished()
270 const QString& str = m_pRollLine->text();
272 int val = str.toInt(&ok);
274 m_pRollSlider->setValue(
static_cast<int>(val * 10.0f + 0.5f));
277 m_pDeleg->ValuesChangedInManipulator(
this);
281 void pitchChanged(
int value)
283 m_pPitchLine->setText(QString(
"%1").arg((tFloat64) value / 10.0f, 0,
'f', 1));
286 m_pDeleg->ValuesChangedInManipulator(
this);
290 void pitchEditFinished()
292 const QString& str = m_pPitchLine->text();
294 int val = str.toInt(&ok);
298 m_pPitchSlider->setValue(
static_cast<int>(val * 10.0f + 0.5f));
303 m_pDeleg->ValuesChangedInManipulator(
this);
307 void yawChanged(
int value)
309 m_pYawLine->setText(QString(
"%1").arg((tFloat64) value / 10.0f, 0,
'f', 1));
312 m_pDeleg->ValuesChangedInManipulator(
this);
316 void yawEditFinished()
318 const QString& str = m_pYawLine->text();
320 int val = str.toInt(&ok);
324 m_pYawSlider->setValue(
static_cast<int>(val * 10.0f + 0.5f));
329 m_pDeleg->ValuesChangedInManipulator(
this);
333 void xChanged(
int value)
335 m_pXLine->setText(QString(
"%1").arg((tFloat64) value / 100.0f, 0,
'f', 2));
338 m_pDeleg->ValuesChangedInManipulator(
this);
344 const QString& str = m_pXLine->text();
346 tFloat64 val = str.toDouble(&ok);
350 m_pXSlider->setValue(
static_cast<int>(val * 100.0f + 0.5f));
355 m_pDeleg->ValuesChangedInManipulator(
this);
359 void yChanged(
int value)
361 m_pYLine->setText(QString(
"%1").arg((tFloat64) value / 100.0f, 0,
'f', 2));
364 m_pDeleg->ValuesChangedInManipulator(
this);
370 const QString& str = m_pYLine->text();
372 tFloat64 val = str.toDouble(&ok);
376 m_pYSlider->setValue(
static_cast<int>(val * 100.0f + 0.5f));
381 m_pDeleg->ValuesChangedInManipulator(
this);
385 void zChanged(
int value)
387 m_pZLine->setText(QString(
"%1").arg((tFloat64) value / 100.0f, 0,
'f', 2));
390 m_pDeleg->ValuesChangedInManipulator(
this);
396 const QString& str = m_pZLine->text();
398 tFloat64 val = str.toDouble(&ok);
402 m_pZSlider->setValue(
static_cast<int>(val * 100.0f + 0.5f));
407 m_pDeleg->ValuesChangedInManipulator(
this);
412 QFrame* m_p6DPoseFrame;
414 QSlider *m_pRollSlider, *m_pPitchSlider, *m_pYawSlider;
415 QSlider *m_pXSlider, *m_pYSlider, *m_pZSlider;
416 QLineEdit *m_pRollLine, *m_pPitchLine, *m_pYawLine;
417 QLineEdit *m_pXLine, *m_pYLine, *m_pZLine;
419 Delegate* m_pDeleg =
nullptr;
420 void* m_pUserData =
nullptr;
422 void closeEvent(QCloseEvent* event)
override
434using endor::cSensorManipulator;
Copyright © Audi Electronics Venture GmbH.
Namespace for functionality provided by the Mixin Library.
Namespace for functionality provided by the Display Toolbox.