ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
ecvUnrollDlg.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 
8 #include "ecvUnrollDlg.h"
9 
10 // Qt
11 #include <QSettings>
12 
13 ccUnrollDlg::ccUnrollDlg(QWidget* parent /*=0*/)
14  : QDialog(parent), Ui::UnrollDialog() {
15  setupUi(this);
16 
17  connect(checkBoxAuto, &QCheckBox::stateChanged, this,
19  connect(comboBoxUnrollShapeType,
20  static_cast<void (QComboBox::*)(int)>(
21  &QComboBox::currentIndexChanged),
23  connect(comboBoxAxisDimension,
24  static_cast<void (QComboBox::*)(int)>(
25  &QComboBox::currentIndexChanged),
27 
28  checkBoxAuto->setChecked(true);
29 
30  shapeTypeChanged(comboBoxUnrollShapeType->currentIndex());
31  axisDimensionChanged(comboBoxAxisDimension->currentIndex());
32 }
33 
35  return static_cast<ccPointCloud::UnrollMode>(
36  comboBoxUnrollShapeType->currentIndex());
37 }
38 
40  return comboBoxAxisDimension->currentIndex();
41 }
42 
44  return (checkBoxAuto->checkState() == Qt::Checked);
45 }
46 
47 void ccUnrollDlg::getAngleRange(double& start_deg, double& stop_deg) const {
48  start_deg = startAngleDoubleSpinBox->value();
49  stop_deg = stopAngleDoubleSpinBox->value();
50 }
51 
53  return CCVector3(
54  static_cast<PointCoordinateType>(doubleSpinBoxAxisX->value()),
55  static_cast<PointCoordinateType>(doubleSpinBoxAxisY->value()),
56  static_cast<PointCoordinateType>(doubleSpinBoxAxisZ->value()));
57 }
58 
59 double ccUnrollDlg::getRadius() const { return radiusDoubleSpinBox->value(); }
60 
62  return halfAngleDoubleSpinBox->value();
63 }
64 
66  return exportDeviationSFCheckBox->isChecked();
67 }
68 
70  switch (index) {
71  case ccPointCloud::CYLINDER: // cylinder
72  {
73  angleFrame->setVisible(false);
74  autoCenterFrame->setVisible(true);
75  radiusFrame->setVisible(true);
76  groupBoxAxisPosition->setTitle("Axis position");
77  radiusLabel->setText("Radius");
78  axisAutoStateChanged(checkBoxAuto->checkState());
79  } break;
80  case ccPointCloud::CONE: // cone
81  {
82  angleFrame->setVisible(true);
83  autoCenterFrame->setVisible(false);
84  radiusFrame->setVisible(false);
85  radiusLabel->setText("Base radius");
86  groupBoxAxisPosition->setTitle("Cone apex");
87  axisAutoStateChanged(Qt::Unchecked);
88  // may be disabled if we were in cylinder mode previously
89  doubleSpinBoxAxisX->setDisabled(false);
90  doubleSpinBoxAxisY->setDisabled(false);
91  doubleSpinBoxAxisZ->setDisabled(false);
92  } break;
93  case ccPointCloud::STRAIGHTENED_CONE: // straightened cone (fixed
94  // radius)
95  case ccPointCloud::STRAIGHTENED_CONE2: // straightened cone 2
96  {
97  angleFrame->setVisible(true);
98  radiusFrame->setVisible(true);
99  autoCenterFrame->setVisible(false);
100  groupBoxAxisPosition->setTitle("Cone apex");
101  axisAutoStateChanged(Qt::Unchecked);
102  // may be disabled if we were in cylinder mode previously
103  doubleSpinBoxAxisX->setDisabled(false);
104  doubleSpinBoxAxisY->setDisabled(false);
105  doubleSpinBoxAxisZ->setDisabled(false);
106  } break;
107  };
108 }
109 
110 void ccUnrollDlg::axisAutoStateChanged(int checkState) {
111  if (checkState == Qt::Unchecked) {
112  axisFrame->setEnabled(true);
113  axisDimensionChanged(comboBoxAxisDimension->currentIndex());
114  } else {
115  axisFrame->setEnabled(false);
116  }
117 }
118 
120  // if axis is in auto mode, no need to change anything
121  if (comboBoxUnrollShapeType->currentIndex() != 0 ||
122  checkBoxAuto->checkState() == Qt::Checked) {
123  return;
124  }
125 
126  // in 'cylinder' mode, we hide the axis coordinate that is not needed
127  doubleSpinBoxAxisX->setDisabled(index == 0);
128  doubleSpinBoxAxisY->setDisabled(index == 1);
129  doubleSpinBoxAxisZ->setDisabled(index == 2);
130 }
131 
132 // semi-persistent settings
133 static CCVector3d s_axisCenter(0, 0, 0);
134 static double s_startAngle_deg = 0.0;
135 static double s_stopAngle_deg = 360.0;
136 
138  QSettings settings;
139  settings.beginGroup("Unroll");
140  {
141  settings.setValue("shapeType", comboBoxUnrollShapeType->currentIndex());
142  settings.setValue("axisDimension",
143  comboBoxAxisDimension->currentIndex());
144  settings.setValue("angle", halfAngleDoubleSpinBox->value());
145  settings.setValue("radius", radiusDoubleSpinBox->value());
146  settings.setValue("autoCenter", checkBoxAuto->isChecked());
147  settings.setValue("exportDeviationSF",
148  exportDeviationSFCheckBox->isChecked());
149 
150  // save the axis center as semi-persistent only
151  s_axisCenter.x = doubleSpinBoxAxisX->value();
152  s_axisCenter.y = doubleSpinBoxAxisY->value();
153  s_axisCenter.z = doubleSpinBoxAxisZ->value();
154 
156  }
157  settings.endGroup();
158 }
159 
161  QSettings settings;
162  settings.beginGroup("Unroll");
163  {
164  int shapeType = settings.value("shapeType",
165  comboBoxUnrollShapeType->currentIndex())
166  .toInt();
167  int axisDim = settings.value("axisDimension",
168  comboBoxAxisDimension->currentIndex())
169  .toInt();
170  double angle = settings.value("angle", halfAngleDoubleSpinBox->value())
171  .toDouble();
172  double radius = settings.value("radius", radiusDoubleSpinBox->value())
173  .toDouble();
174  bool autoCenter =
175  settings.value("autoCenter", checkBoxAuto->isChecked())
176  .toBool();
177  bool exportDeviationSF =
178  settings.value("exportDeviationSF",
179  exportDeviationSFCheckBox->isChecked())
180  .toBool();
181 
182  comboBoxUnrollShapeType->setCurrentIndex(shapeType);
183  comboBoxAxisDimension->setCurrentIndex(axisDim);
184  halfAngleDoubleSpinBox->setValue(angle);
185  radiusDoubleSpinBox->setValue(radius);
186  checkBoxAuto->setChecked(autoCenter);
187  exportDeviationSFCheckBox->setChecked(exportDeviationSF);
188 
189  doubleSpinBoxAxisX->setValue(s_axisCenter.x);
190  doubleSpinBoxAxisY->setValue(s_axisCenter.y);
191  doubleSpinBoxAxisZ->setValue(s_axisCenter.z);
192 
193  startAngleDoubleSpinBox->setValue(s_startAngle_deg);
194  stopAngleDoubleSpinBox->setValue(s_stopAngle_deg);
195  }
196  settings.endGroup();
197 }
Vector3Tpl< PointCoordinateType > CCVector3
Default 3D Vector.
Definition: CVGeom.h:798
float PointCoordinateType
Type of the coordinates of a (N-D) point.
Definition: CVTypes.h:16
Type y
Definition: CVGeom.h:137
Type x
Definition: CVGeom.h:137
Type z
Definition: CVGeom.h:137
CCVector3 getAxisPosition() const
double getConeHalfAngle() const
void shapeTypeChanged(int index)
bool isAxisPositionAuto() const
void axisDimensionChanged(int index)
void toPersistentSettings() const
ccPointCloud::UnrollMode getType() const
int getAxisDimension() const
ccUnrollDlg(QWidget *parent=0)
Default constructor.
bool exportDeviationSF() const
void fromPersistentSettings()
double getRadius() const
void getAngleRange(double &start_deg, double &stop_deg) const
void axisAutoStateChanged(int checkState)
static CCVector3d s_axisCenter(0, 0, 0)
static double s_startAngle_deg
static double s_stopAngle_deg