ccInterpolationDlg.cpp 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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: Daniel Girardeau-Montaut #
  15. //# #
  16. //##########################################################################
  17. #include "ccInterpolationDlg.h"
  18. //System
  19. #include <assert.h>
  20. ccInterpolationDlg::ccInterpolationDlg(QWidget* parent/*=nullptr*/)
  21. : QDialog(parent, Qt::Tool)
  22. , Ui::InterpolationDlg()
  23. {
  24. setupUi(this);
  25. connect(radiusDoubleSpinBox, qOverload<double>(&QDoubleSpinBox::valueChanged), this, &ccInterpolationDlg::onRadiusUpdated);
  26. }
  27. ccPointCloudInterpolator::Parameters::Method ccInterpolationDlg::getInterpolationMethod() const
  28. {
  29. if (nnRadioButton->isChecked())
  30. return ccPointCloudInterpolator::Parameters::NEAREST_NEIGHBOR;
  31. else if (radiusRadioButton->isChecked())
  32. return ccPointCloudInterpolator::Parameters::RADIUS;
  33. else if (knnRadioButton->isChecked())
  34. return ccPointCloudInterpolator::Parameters::K_NEAREST_NEIGHBORS;
  35. assert(false);
  36. return ccPointCloudInterpolator::Parameters::NEAREST_NEIGHBOR;
  37. }
  38. void ccInterpolationDlg::setInterpolationMethod(ccPointCloudInterpolator::Parameters::Method method)
  39. {
  40. switch (method)
  41. {
  42. case ccPointCloudInterpolator::Parameters::NEAREST_NEIGHBOR:
  43. nnRadioButton->setChecked(true);
  44. break;
  45. case ccPointCloudInterpolator::Parameters::RADIUS:
  46. radiusRadioButton->setChecked(true);
  47. break;
  48. case ccPointCloudInterpolator::Parameters::K_NEAREST_NEIGHBORS:
  49. knnRadioButton->setChecked(true);
  50. break;
  51. default:
  52. assert(false);
  53. }
  54. }
  55. ccPointCloudInterpolator::Parameters::Algo ccInterpolationDlg::getInterpolationAlgorithm() const
  56. {
  57. if (averageRadioButton->isChecked())
  58. return ccPointCloudInterpolator::Parameters::AVERAGE;
  59. else if (medianRadioButton->isChecked())
  60. return ccPointCloudInterpolator::Parameters::MEDIAN;
  61. else if (normalDistribRadioButton->isChecked())
  62. return ccPointCloudInterpolator::Parameters::NORMAL_DIST;
  63. assert(false);
  64. return ccPointCloudInterpolator::Parameters::AVERAGE;
  65. }
  66. void ccInterpolationDlg::setInterpolationAlgorithm(ccPointCloudInterpolator::Parameters::Algo algo)
  67. {
  68. switch (algo)
  69. {
  70. case ccPointCloudInterpolator::Parameters::AVERAGE:
  71. averageRadioButton->setChecked(true);
  72. break;
  73. case ccPointCloudInterpolator::Parameters::MEDIAN:
  74. medianRadioButton->setChecked(true);
  75. break;
  76. case ccPointCloudInterpolator::Parameters::NORMAL_DIST:
  77. normalDistribRadioButton->setChecked(true);
  78. break;
  79. default:
  80. assert(false);
  81. }
  82. }
  83. void ccInterpolationDlg::onRadiusUpdated(double radius)
  84. {
  85. kernelDoubleSpinBox->setValue(radius / 2.5);
  86. }