ccComputeOctreeDlg.cpp 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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 "ccComputeOctreeDlg.h"
  18. //Local
  19. #include "ccBoundingBoxEditorDlg.h"
  20. //qCC_db
  21. #include <ccOctree.h>
  22. ccComputeOctreeDlg::ccComputeOctreeDlg(const ccBBox& baseBBox, double minCellSize, QWidget* parent/*=nullptr*/)
  23. : QDialog(parent)
  24. , Ui::ComputeOctreeDialog()
  25. , m_bbEditorDlg(nullptr)
  26. {
  27. setupUi(this);
  28. headerLabel->setText(QString("Max subdivision level: %1").arg(ccOctree::MAX_OCTREE_LEVEL));
  29. //minimum cell size
  30. if (minCellSize > 0.0)
  31. {
  32. cellSizeDoubleSpinBox->setMinimum(minCellSize);
  33. cellSizeDoubleSpinBox->setMaximum(1.0e9);
  34. }
  35. else
  36. {
  37. ccLog::Warning("[ccComputeOctreeDlg] Invalid minimum cell size specified!");
  38. cellSizeRadioButton->setEnabled(false);
  39. }
  40. //custom bbox editor
  41. if (baseBBox.isValid())
  42. {
  43. m_bbEditorDlg = new ccBoundingBoxEditorDlg(false, false, this);
  44. m_bbEditorDlg->setBaseBBox(baseBBox,true);
  45. m_bbEditorDlg->forceKeepSquare(true);
  46. connect(customBBToolButton, &QAbstractButton::clicked, m_bbEditorDlg, &ccBoundingBoxEditorDlg::exec);
  47. }
  48. else
  49. {
  50. ccLog::Warning("[ccComputeOctreeDlg] Invalid base bounding-box specified!");
  51. customBBRadioButton->setEnabled(false);
  52. }
  53. }
  54. ccComputeOctreeDlg::ComputationMode ccComputeOctreeDlg::getMode() const
  55. {
  56. //defaultRadioButton
  57. if (cellSizeRadioButton->isChecked())
  58. return MIN_CELL_SIZE;
  59. else if (customBBRadioButton->isChecked())
  60. return CUSTOM_BBOX;
  61. assert(defaultRadioButton->isChecked());
  62. return DEFAULT;
  63. }
  64. double ccComputeOctreeDlg::getMinCellSize() const
  65. {
  66. return cellSizeDoubleSpinBox->value();
  67. }
  68. ccBBox ccComputeOctreeDlg::getCustomBBox() const
  69. {
  70. return (m_bbEditorDlg ? m_bbEditorDlg->getBox() : ccBBox());
  71. }