ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
ecvClippingBoxRepeatDlg.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 // Qt
11 #include <QPushButton>
12 
13 // system
14 #include <assert.h>
15 
17  bool singleContourMode /*=false*/, QWidget* parent /*=0*/)
18  : QDialog(parent) {
19  setupUi(this);
20 
21  if (!singleContourMode) {
22  connect(xRepeatCheckBox, &QAbstractButton::toggled, this,
24  connect(yRepeatCheckBox, &QAbstractButton::toggled, this,
26  connect(zRepeatCheckBox, &QAbstractButton::toggled, this,
28  } else {
29  // single contour extraction mode!
30  repeatDimGroupBox->setTitle("Flat dimension");
31 
32  connect(xRepeatCheckBox, &QAbstractButton::toggled, this,
34  connect(yRepeatCheckBox, &QAbstractButton::toggled, this,
36  connect(zRepeatCheckBox, &QAbstractButton::toggled, this,
38  setFlatDim(0);
39 
40  extractContoursGroupBox->setChecked(true);
41  extractContoursGroupBox->setCheckable(false);
42  projectOnBestFitCheckBox->setVisible(true);
43  projectOnBestFitCheckBox->setChecked(false);
44 
45  randomColorCheckBox->setChecked(false);
46  otherOptionsGroupBox->setVisible(false);
47  }
48 }
49 
50 void ccClippingBoxRepeatDlg::setRepeatDim(unsigned char dim) {
51  assert(dim < 3);
52  QCheckBox* boxes[3] = {xRepeatCheckBox, yRepeatCheckBox, zRepeatCheckBox};
53 
54  for (unsigned char d = 0; d < 3; ++d) {
55  boxes[d]->setChecked(d == dim);
56  }
57 }
58 
60  assert(state);
61  setFlatDim(0);
62 }
64  assert(state);
65  setFlatDim(1);
66 }
68  assert(state);
69  setFlatDim(2);
70 }
71 
72 void ccClippingBoxRepeatDlg::setFlatDim(unsigned char dim) {
73  assert(dim < 3);
74  QCheckBox* boxes[3] = {xRepeatCheckBox, yRepeatCheckBox, zRepeatCheckBox};
75 
76  for (unsigned char d = 0; d < 3; ++d) {
77  boxes[d]->blockSignals(true);
78  // disable the current dimension
79  // and uncheck the other dimensions
80  boxes[d]->setChecked(d == dim);
81  boxes[d]->setEnabled(d != dim);
82  boxes[d]->blockSignals(false);
83  }
84 }
85 
87  // if only one dimension is checked, then the user can choose to project
88  // the points along this dimension
89  int sum = static_cast<int>(xRepeatCheckBox->isChecked()) +
90  static_cast<int>(yRepeatCheckBox->isChecked()) +
91  static_cast<int>(zRepeatCheckBox->isChecked());
92 
93  if (sum == 1) {
94  if (!projectOnBestFitCheckBox->isVisible())
95  projectOnBestFitCheckBox->setChecked(false);
96  projectOnBestFitCheckBox->setVisible(true);
97  } else {
98  projectOnBestFitCheckBox->setVisible(false);
99  projectOnBestFitCheckBox->setChecked(true);
100  }
101 
102  buttonBox->button(QDialogButtonBox::Ok)->setEnabled(sum != 0);
103 }
void setFlatDim(unsigned char dim)
Sets flat dimension (single contour mode only!)
void setRepeatDim(unsigned char dim)
Sets repeat dimension (multiple contour mode only!)
ccClippingBoxRepeatDlg(bool singleContourMode=false, QWidget *parent=0)
Default constructor.