ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
ecvGBLSensorProjectionDlg.cpp
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
9 
10 // local
12 
13 // CV_DB_LIB
14 #include <ecvGBLSensor.h>
15 
17  : QDialog(parent), Ui::GBLSensorProjectDialog() {
18  setupUi(this);
19 
20  posXEdit->setValidator(new ccCustomDoubleValidator(this));
21  posYEdit->setValidator(new ccCustomDoubleValidator(this));
22  posZEdit->setValidator(new ccCustomDoubleValidator(this));
23 
24  x1rot->setValidator(new ccCustomDoubleValidator(this));
25  x2rot->setValidator(new ccCustomDoubleValidator(this));
26  x3rot->setValidator(new ccCustomDoubleValidator(this));
27  y1rot->setValidator(new ccCustomDoubleValidator(this));
28  y2rot->setValidator(new ccCustomDoubleValidator(this));
29  y3rot->setValidator(new ccCustomDoubleValidator(this));
30  z1rot->setValidator(new ccCustomDoubleValidator(this));
31  z2rot->setValidator(new ccCustomDoubleValidator(this));
32  z3rot->setValidator(new ccCustomDoubleValidator(this));
33 }
34 
36  if (!sensor) return;
37 
38  const int precision = sizeof(PointCoordinateType) == 8 ? 12 : 8;
39 
40  /*** Rotation order ***/
41  {
43  rotationOrderComboBox->setCurrentIndex(0);
44  else if (sensor->getRotationOrder() == ccGBLSensor::PITCH_THEN_YAW)
45  rotationOrderComboBox->setCurrentIndex(1);
46  }
47 
48  /*** Position + Orientation ***/
49  {
50  // rotation matrix
51  const ccGLMatrix& rot = sensor->getRigidTransformation();
52  {
53  const float* mat = rot.data();
54  x1rot->setText(QString::number(mat[0], 'f', precision));
55  y1rot->setText(QString::number(mat[1], 'f', precision));
56  z1rot->setText(QString::number(mat[2], 'f', precision));
57 
58  x2rot->setText(QString::number(mat[4], 'f', precision));
59  y2rot->setText(QString::number(mat[5], 'f', precision));
60  z2rot->setText(QString::number(mat[6], 'f', precision));
61 
62  x3rot->setText(QString::number(mat[8], 'f', precision));
63  y3rot->setText(QString::number(mat[9], 'f', precision));
64  z3rot->setText(QString::number(mat[10], 'f', precision));
65  }
66 
67  // center
68  const float* C = sensor->getRigidTransformation().getTranslation();
69  posXEdit->setText(QString::number(C[0], 'f', precision));
70  posYEdit->setText(QString::number(C[1], 'f', precision));
71  posZEdit->setText(QString::number(C[2], 'f', precision));
72  }
73 
74  /*** Angular steps ***/
75  {
76  // pitch step
77  pitchStepSpinBox->setValue(
79  // yaw step
80  yawStepSpinBox->setValue(
82  }
83 
84  /*** Other ***/
85  {
86  // max range
87  maxRangeDoubleSpinBox->setValue(sensor->getSensorRange());
88  // uncertainty
89  uncertaintyDoubleSpinBox->setValue(sensor->getUncertainty());
90  }
91 }
92 
94  if (!sensor) return;
95 
96  /*** rotation order ***/
97  {
99  (rotationOrderComboBox->currentIndex() == 0
102  sensor->setRotationOrder(rotOrder);
103  }
104 
105  /*** Position + Orientation ***/
106  {
107  // orientation matrix
108  ccGLMatrix rot;
109  {
110  float* mat = rot.data();
111  mat[0] = x1rot->text().toFloat();
112  mat[1] = y1rot->text().toFloat();
113  mat[2] = z1rot->text().toFloat();
114 
115  mat[4] = x2rot->text().toFloat();
116  mat[5] = y2rot->text().toFloat();
117  mat[6] = z2rot->text().toFloat();
118 
119  mat[8] = x3rot->text().toFloat();
120  mat[9] = y3rot->text().toFloat();
121  mat[10] = z3rot->text().toFloat();
122  }
123 
124  // center
125  CCVector3 C(
126  static_cast<PointCoordinateType>(posXEdit->text().toDouble()),
127  static_cast<PointCoordinateType>(posYEdit->text().toDouble()),
128  static_cast<PointCoordinateType>(posZEdit->text().toDouble()));
129  rot.setTranslation(C);
130 
131  sensor->setRigidTransformation(rot);
132  }
133 
134  /*** Angular steps ***/
135  {
136  // pitch step
137  sensor->setPitchStep(static_cast<PointCoordinateType>(
138  cloudViewer::DegreesToRadians(pitchStepSpinBox->value())));
139  // yax step
140  sensor->setYawStep(static_cast<PointCoordinateType>(
141  cloudViewer::DegreesToRadians(yawStepSpinBox->value())));
142  }
143 
144  /*** Other ***/
145  {
146  // max. range
147  sensor->setSensorRange(
148  static_cast<ScalarType>(maxRangeDoubleSpinBox->value()));
149 
150  // uncertainty
151  sensor->setUncertainty(
152  static_cast<ScalarType>(uncertaintyDoubleSpinBox->value()));
153  }
154 }
float PointCoordinateType
Type of the coordinates of a (N-D) point.
Definition: CVTypes.h:16
ccGBLSensorProjectionDlg(QWidget *parent=0)
Default constructor.
void initWithGBLSensor(const ccGBLSensor *sensor)
void updateGBLSensor(ccGBLSensor *sensor)
Ground-based Laser sensor.
Definition: ecvGBLSensor.h:26
void setRotationOrder(ROTATION_ORDER rotOrder)
Sets the sensor internal rotations order.
Definition: ecvGBLSensor.h:161
ROTATION_ORDER
The order of inner-rotations of the sensor (body/mirrors)
Definition: ecvGBLSensor.h:33
PointCoordinateType getSensorRange() const
Returns the sensor max. range.
Definition: ecvGBLSensor.h:137
void setUncertainty(PointCoordinateType u)
Sets the Z-buffer uncertainty on depth values.
Definition: ecvGBLSensor.h:153
PointCoordinateType getUncertainty() const
Returns the Z-buffer uncertainty on depth values.
Definition: ecvGBLSensor.h:147
void setSensorRange(PointCoordinateType range)
Sets the sensor max. range.
Definition: ecvGBLSensor.h:142
PointCoordinateType getPitchStep() const
Returns the lateral pitch step (in radians)
Definition: ecvGBLSensor.h:105
void setYawStep(PointCoordinateType dTheta)
Sets the yaw step.
ROTATION_ORDER getRotationOrder() const
Returns the sensor internal rotations order.
Definition: ecvGBLSensor.h:156
PointCoordinateType getYawStep() const
Returns the yaw step (in radians)
Definition: ecvGBLSensor.h:130
void setPitchStep(PointCoordinateType dPhi)
Sets the pitch step.
T * getTranslation()
Retruns a pointer to internal translation.
T * data()
Returns a pointer to internal data.
void setTranslation(const Vector3Tpl< float > &Tr)
Sets translation (float version)
Float version of ccGLMatrixTpl.
Definition: ecvGLMatrix.h:19
virtual ccGLMatrix & getRigidTransformation()
Definition: ecvSensor.h:105
virtual void setRigidTransformation(const ccGLMatrix &mat)
Definition: ecvSensor.h:99
float RadiansToDegrees(int radians)
Convert radians to degrees.
Definition: CVMath.h:71
float DegreesToRadians(int degrees)
Convert degrees to radians.
Definition: CVMath.h:98