ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
SACSegmentationDlg.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 "SACSegmentationDlg.h"
9 
11  : QDialog(parent, Qt::Tool), Ui::SACSegmentationDlg() {
12  setupUi(this);
13  initParameters();
14  connect(modelTypeCombo,
15  static_cast<void (QComboBox::*)(int)>(
16  &QComboBox::currentIndexChanged),
17  this,
18  static_cast<void (SACSegmentationDlg::*)(int)>(
20 }
21 
22 void SACSegmentationDlg::modelsChanged(int currentIndex) {
23  switch (modelTypeCombo->currentIndex()) {
24  case 5: // SACMODEL_CYLINDER
25  case 6: // SACMODEL_CONE
26  case 11: // SACMODEL_NORMAL_PLANE
27  case 12: // SACMODEL_NORMAL_SPHERE
28  case 16: // SACMODEL_NORMAL_PARALLEL_PLANE
29  {
30  normalDisWeightLabel->setEnabled(true);
31  normalDisWeightSpinBox->setEnabled(true);
32  } break;
33  default: {
34  normalDisWeightLabel->setEnabled(false);
35  normalDisWeightSpinBox->setEnabled(false);
36  } break;
37  }
38 }
39 void SACSegmentationDlg::updateModelTypeComboBox(const QStringList& fields) {
40  modelTypeCombo->clear();
41  for (int i = 0; i < fields.size(); i++) {
42  modelTypeCombo->addItem(fields[i], i);
43  modelTypeCombo->setItemText(i, fields[i]);
44  }
45 }
46 
47 void SACSegmentationDlg::updateMethodTypeComboBox(const QStringList& fields) {
48  methodTypeCombo->clear();
49  for (int i = 0; i < fields.size(); i++) {
50  methodTypeCombo->addItem(fields[i], i);
51  methodTypeCombo->setItemText(i, fields[i]);
52  }
53 }
54 
55 void SACSegmentationDlg::initParameters() {
56  QStringList methodFields;
57  QStringList modelFields;
58  if (modelFields.isEmpty()) {
59  modelFields << tr("SACMODEL_PLANE") << tr("SACMODEL_LINE")
60  << tr("SACMODEL_CIRCLE2D") << tr("SACMODEL_CIRCLE3D")
61  << tr("SACMODEL_SPHERE") << tr("SACMODEL_CYLINDER")
62  << tr("SACMODEL_CONE") << tr("SACMODEL_TORUS")
63  << tr("SACMODEL_PARALLEL_LINE")
64  << tr("SACMODEL_PERPENDICULAR_PLANE")
65  << tr("SACMODEL_PARALLEL_LINES")
66  << tr("SACMODEL_NORMAL_PLANE")
67  << tr("SACMODEL_NORMAL_SPHERE")
68  << tr("SACMODEL_REGISTRATION")
69  << tr("SACMODEL_REGISTRATION_2D")
70  << tr("SACMODEL_PARALLEL_PLANE")
71  << tr("SACMODEL_NORMAL_PARALLEL_PLANE")
72  << tr("SACMODEL_STICK");
73  }
74  if (methodFields.isEmpty()) {
75  methodFields << tr("SAC_RANSAC") << tr("SAC_LMEDS") << tr("SAC_MSAC")
76  << tr("SAC_RRANSAC") << tr("SAC_RMSAC") << tr("SAC_MLESAC")
77  << tr("SAC_PROSAC");
78  }
79 
80  // update the combo box
81  updateModelTypeComboBox(modelFields);
82  updateMethodTypeComboBox(methodFields);
83 }
std::vector< PCLPointField > fields
SACSegmentationDlg(QWidget *parent=0)
void modelsChanged(int currentIndex=0)