ccSubsamplingDlg.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. #pragma once
  2. //##########################################################################
  3. //# #
  4. //# CLOUDCOMPARE #
  5. //# #
  6. //# This program is free software; you can redistribute it and/or modify #
  7. //# it under the terms of the GNU General Public License as published by #
  8. //# the Free Software Foundation; version 2 or later of the License. #
  9. //# #
  10. //# This program is distributed in the hope that it will be useful, #
  11. //# but WITHOUT ANY WARRANTY; without even the implied warranty of #
  12. //# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
  13. //# GNU General Public License for more details. #
  14. //# #
  15. //# COPYRIGHT: EDF R&D / TELECOM ParisTech (ENST-TSI) #
  16. //# #
  17. //##########################################################################
  18. //Qt
  19. #include <QDialog>
  20. //CCCoreLib
  21. #include <CCTypes.h>
  22. //System
  23. #include <array>
  24. class ccGenericPointCloud;
  25. namespace CCCoreLib
  26. {
  27. class GenericProgressCallback;
  28. class ReferenceCloud;
  29. }
  30. namespace Ui
  31. {
  32. class SubsamplingDialog;
  33. }
  34. //! Subsampling cloud dialog
  35. class ccSubsamplingDlg : public QDialog
  36. {
  37. Q_OBJECT
  38. public:
  39. //! Sub-sampling method
  40. enum CC_SUBSAMPLING_METHOD
  41. {
  42. RANDOM = 0,
  43. RANDOM_PERCENT = 1,
  44. SPATIAL = 2,
  45. OCTREE = 3,
  46. COUNT = 4 //Should always be the last one
  47. };
  48. //! Default constructor
  49. ccSubsamplingDlg(unsigned maxPointCount, double maxCloudRadius, QWidget* parent = nullptr);
  50. //! Destructor
  51. ~ccSubsamplingDlg() override;
  52. //! Returns the subsampled version of a cloud according to the current parameters
  53. /** Should only be called after the dialog has been validated.
  54. **/
  55. CCCoreLib::ReferenceCloud* getSampledCloud(ccGenericPointCloud* cloud, CCCoreLib::GenericProgressCallback* progressCb = nullptr);
  56. //! Enables the SF modulation option (SPATIAL method)
  57. void enableSFModulation(ScalarType sfMin, ScalarType sfMax);
  58. //! Saves the current state to persistent settings
  59. void saveToPersistentSettings() const;
  60. //! Loads the state from persistent settings
  61. void loadFromPersistentSettings();
  62. protected:
  63. void sliderMoved(int sliderPos);
  64. void valueChanged(double value);
  65. void changeSamplingMethod(int index);
  66. protected: //methods
  67. //! Updates the dialog lables depending on the active mode
  68. void updateLabels();
  69. protected: //members
  70. //! Max point count (for RANDOM method)
  71. unsigned m_maxPointCount;
  72. //! Max radius (for SPACE method)
  73. double m_maxRadius;
  74. //! Scalar modulation
  75. bool m_sfModEnabled;
  76. //! Scalar modulation (min SF value)
  77. ScalarType m_sfMin;
  78. //! Scalar modulation (max SF value)
  79. ScalarType m_sfMax;
  80. //! Last known sampling values (per method)
  81. std::array<double, CC_SUBSAMPLING_METHOD::COUNT> m_lastUsedValues;
  82. //! Associated UI
  83. Ui::SubsamplingDialog* m_ui;
  84. };