ccClippingBoxRepeatDlg.cpp 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. //##########################################################################
  2. //# #
  3. //# CLOUDCOMPARE #
  4. //# #
  5. //# This program is free software; you can redistribute it and/or modify #
  6. //# it under the terms of the GNU General Public License as published by #
  7. //# the Free Software Foundation; version 2 or later of the License. #
  8. //# #
  9. //# This program is distributed in the hope that it will be useful, #
  10. //# but WITHOUT ANY WARRANTY; without even the implied warranty of #
  11. //# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
  12. //# GNU General Public License for more details. #
  13. //# #
  14. //# COPYRIGHT: EDF R&D / TELECOM ParisTech (ENST-TSI) #
  15. //# #
  16. //##########################################################################
  17. #include "ccClippingBoxRepeatDlg.h"
  18. //Qt
  19. #include <QPushButton>
  20. //system
  21. #include <assert.h>
  22. ccClippingBoxRepeatDlg::ccClippingBoxRepeatDlg(bool singleSliceMode/*=false*/, QWidget* parent/*=nullptr*/)
  23. : QDialog(parent)
  24. {
  25. setupUi(this);
  26. if (!singleSliceMode)
  27. {
  28. connect(xRepeatCheckBox, &QAbstractButton::toggled, this, &ccClippingBoxRepeatDlg::onDimChecked);
  29. connect(yRepeatCheckBox, &QAbstractButton::toggled, this, &ccClippingBoxRepeatDlg::onDimChecked);
  30. connect(zRepeatCheckBox, &QAbstractButton::toggled, this, &ccClippingBoxRepeatDlg::onDimChecked);
  31. }
  32. else
  33. {
  34. //single slice extraction mode!
  35. repeatDimGroupBox->setTitle("Flat dimension");
  36. connect(xRepeatCheckBox, &QAbstractButton::toggled, this, &ccClippingBoxRepeatDlg::onDimXChecked);
  37. connect(yRepeatCheckBox, &QAbstractButton::toggled, this, &ccClippingBoxRepeatDlg::onDimYChecked);
  38. connect(zRepeatCheckBox, &QAbstractButton::toggled, this, &ccClippingBoxRepeatDlg::onDimZChecked);
  39. setFlatDim(0);
  40. randomColorCheckBox->setChecked(false);
  41. otherOptionsGroupBox->setVisible(false);
  42. }
  43. }
  44. void ccClippingBoxRepeatDlg::setRepeatDim(unsigned char dim)
  45. {
  46. assert(dim < 3);
  47. QCheckBox* boxes[3] = { xRepeatCheckBox,
  48. yRepeatCheckBox,
  49. zRepeatCheckBox };
  50. for (unsigned char d = 0; d < 3; ++d)
  51. {
  52. boxes[d]->setChecked(d == dim);
  53. }
  54. }
  55. void ccClippingBoxRepeatDlg::onDimXChecked(bool state)
  56. {
  57. assert(state);
  58. setFlatDim(0);
  59. }
  60. void ccClippingBoxRepeatDlg::onDimYChecked(bool state)
  61. {
  62. assert(state);
  63. setFlatDim(1);
  64. }
  65. void ccClippingBoxRepeatDlg::onDimZChecked(bool state)
  66. {
  67. assert(state);
  68. setFlatDim(2);
  69. }
  70. void ccClippingBoxRepeatDlg::setFlatDim(unsigned char dim)
  71. {
  72. assert(dim < 3);
  73. QCheckBox* boxes[3] = { xRepeatCheckBox,
  74. yRepeatCheckBox,
  75. zRepeatCheckBox };
  76. for (unsigned char d = 0; d < 3; ++d)
  77. {
  78. boxes[d]->blockSignals(true);
  79. //disable the current dimension
  80. //and uncheck the other dimensions
  81. boxes[d]->setChecked(d == dim);
  82. boxes[d]->setEnabled(d != dim);
  83. boxes[d]->blockSignals(false);
  84. }
  85. extractLevelSetGroupBox->setEnabled(true);
  86. }
  87. void ccClippingBoxRepeatDlg::onDimChecked(bool)
  88. {
  89. //if only one dimension is checked, then the user can choose to project
  90. //the points along this dimension
  91. int sum = static_cast<int>(xRepeatCheckBox->isChecked())
  92. + static_cast<int>(yRepeatCheckBox->isChecked())
  93. + static_cast<int>(zRepeatCheckBox->isChecked());
  94. if (sum == 1)
  95. {
  96. if (!envProjectPointsOnBestFitCheckBox->isVisible())
  97. {
  98. envProjectPointsOnBestFitCheckBox->setChecked(false);
  99. }
  100. envProjectPointsOnBestFitCheckBox->setVisible(true);
  101. envelopeTypeComboBox->setEnabled(true);
  102. extractLevelSetGroupBox->setEnabled(true);
  103. }
  104. else
  105. {
  106. envProjectPointsOnBestFitCheckBox->setVisible(false);
  107. envProjectPointsOnBestFitCheckBox->setChecked(true);
  108. envelopeTypeComboBox->setCurrentIndex(2);
  109. envelopeTypeComboBox->setEnabled(false);
  110. extractLevelSetGroupBox->setEnabled(false);
  111. extractLevelSetGroupBox->setChecked(false);
  112. }
  113. buttonBox->button(QDialogButtonBox::Ok)->setEnabled(sum != 0);
  114. }