ccScalarFieldArithmeticsDlg.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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. #ifndef CC_SF_ARITMETHIC_DLG_HEADER
  18. #define CC_SF_ARITMETHIC_DLG_HEADER
  19. #include <QDialog>
  20. class ccPointCloud;
  21. namespace Ui
  22. {
  23. class SFArithmeticsDlg;
  24. }
  25. //! Dialog to choose 2 scalar fields (SF) and one operation for arithmetics processing
  26. class ccScalarFieldArithmeticsDlg : public QDialog
  27. {
  28. Q_OBJECT
  29. public:
  30. //! Default constructor
  31. ccScalarFieldArithmeticsDlg(ccPointCloud* cloud, QWidget* parent = nullptr);
  32. ~ccScalarFieldArithmeticsDlg() override;
  33. //! Arithmetic operations
  34. enum Operation { /* Operations requiring two SFs */
  35. PLUS = 0,
  36. MINUS = 1,
  37. MULTIPLY = 2,
  38. DIVIDE = 3,
  39. MIN = 4,
  40. MAX = 5,
  41. /* Operations requiring only one SF */
  42. SQRT = 6,
  43. POW2 = 7,
  44. POW3 = 8,
  45. EXP = 9,
  46. LOG = 10,
  47. LOG10 = 11,
  48. COS = 12,
  49. SIN = 13,
  50. TAN = 14,
  51. ACOS = 15,
  52. ASIN = 16,
  53. ATAN = 17,
  54. INT = 18,
  55. INVERSE = 19,
  56. SET = 20,
  57. ABS = 21,
  58. /* Invalid enum. (always last) */
  59. INVALID = 255
  60. };
  61. //! Returns selected operation
  62. Operation getOperation() const;
  63. //! Returns the operation enumerator based on its name
  64. static Operation GetOperationByName(const QString& name);
  65. //! Returns operation name
  66. static QString GetOperationName(Operation op, const QString& sf1, const QString& sf2 = QString());
  67. //! Applies operation on a given cloud
  68. /** Should be applied on the same cloud as the one input to the constructor
  69. Otherwise you'd better know what you're doing ;).
  70. \param cloud cloud on which to apply the SF operation
  71. \return success
  72. **/
  73. bool apply(ccPointCloud* cloud);
  74. //! Secondary SF descriptor
  75. struct SF2
  76. {
  77. bool isConstantValue = true;
  78. double constantValue = 0.0;
  79. int sfIndex = -1;
  80. };
  81. //! Applies operation on a given cloud
  82. /** \param cloud cloud on which to apply the SF operation
  83. \param op operation
  84. \param sf1Idx first (or only) scalar field index
  85. \param inplace whether the operation should be applied in place (SF1). Otherwise a new SF will be created.
  86. \param sf2 secondary scalar field / value (only for PLUS, MINUS, MULTIPLY, DIVIDE, MIN and MAX operations)
  87. \param parent parent widget (optional)
  88. \return success
  89. **/
  90. static bool Apply( ccPointCloud* cloud,
  91. Operation op,
  92. int sf1Idx,
  93. bool inplace,
  94. SF2* sf2 = nullptr,
  95. QWidget* parent = nullptr);
  96. protected:
  97. //! Called when the operation combo-box is modified
  98. void onOperationIndexChanged(int index);
  99. //! Called when the SF2 combo-box is modified
  100. void onSF2IndexChanged(int index);
  101. protected:
  102. //! Returns first selected SF index
  103. int getSF1Index();
  104. //! Returns second selected SF index
  105. int getSF2Index();
  106. private:
  107. Ui::SFArithmeticsDlg* m_ui;
  108. };
  109. #endif //CC_SF_ARITMETHIC_DLG_HEADER