ccRasterizeTool.h 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  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. //Local
  19. #include "cc2.5DimEditor.h"
  20. //Qt
  21. #include <QDialog>
  22. #include <QString>
  23. class ccGenericPointCloud;
  24. class ccPointCloud;
  25. class ccPolyline;
  26. namespace Ui
  27. {
  28. class RasterizeToolDialog;
  29. }
  30. //! Rasterize tool (dialog)
  31. class ccRasterizeTool : public QDialog, public cc2Point5DimEditor
  32. {
  33. Q_OBJECT
  34. public:
  35. //! Default constructor
  36. ccRasterizeTool(ccGenericPointCloud* cloud, QWidget* parent = nullptr);
  37. //! Destructor
  38. ~ccRasterizeTool() override;
  39. public: //raster export
  40. //! Bands to be exported
  41. struct ExportBands
  42. {
  43. bool height = true;
  44. bool rgb = false;
  45. bool density = false;
  46. bool visibleSF = false;
  47. bool allSFs = false;
  48. };
  49. //! Exports a raster grid as a geotiff file
  50. static bool ExportGeoTiff( const QString& outputFilename,
  51. const ExportBands& exportBands,
  52. ccRasterGrid::EmptyCellFillOption fillEmptyCellsStrategy,
  53. const ccRasterGrid& grid,
  54. const ccBBox& gridBBox,
  55. unsigned char Z,
  56. double customHeightForEmptyCells = std::numeric_limits<double>::quiet_NaN(),
  57. ccGenericPointCloud* originCloud = nullptr,
  58. int visibleSfIndex = -1);
  59. private:
  60. //! Exports the grid as a cloud
  61. ccPointCloud* generateCloud(bool autoExport = true);
  62. //! Exports the grid as a raster
  63. void generateRaster() const;
  64. //! Exports the grid as a mesh
  65. void generateMesh();
  66. //! Exports the (already generated) contour lines
  67. void exportContourLines();
  68. //! Generates a contour plot
  69. void generateContours();
  70. //! Generates hillshade
  71. void generateHillshade();
  72. //! Removes all displayed contour lines
  73. void removeContourLines();
  74. //! Accepts the dialog (if some conditions are met) and save settings
  75. void testAndAccept();
  76. //! Rejects the dialog (if some conditions are met)
  77. void testAndReject();
  78. //! Save persistent settings and 'accept' dialog
  79. void saveSettings();
  80. //! Called when the active layer changes
  81. void activeLayerChanged(int, bool autoRedraw = true);
  82. //! Called when the projection direction changes
  83. void projectionDirChanged(int);
  84. //! Called when the Std Dev layer changes
  85. void stdDevLayerChanged(int);
  86. //! Called when the projection type changes
  87. void projectionTypeChanged(int);
  88. //! Called when the 'resampled' option changes
  89. void resampleOptionToggled(bool);
  90. //! Called when the SF projection type changes
  91. void sfProjectionTypeChanged(int);
  92. //Inherited from cc2Point5DimEditor
  93. bool showGridBoxEditor() override;
  94. //! Called when the empty cell filling strategy changes
  95. void fillEmptyCellStrategyChanged(int);
  96. //! Called when the an option of the grid generation has changed
  97. void gridOptionChanged();
  98. //! Updates the gid info
  99. void updateGridInfo(bool withNonEmptyCells = false);
  100. //! Update the grid and the 2D display
  101. void updateGridAndDisplay();
  102. //! Update the cloud name (and non-empty cell number if required)
  103. void updateCloudName(bool withNonEmptyCellNumber);
  104. //! Exports the grid as an image
  105. void generateImage() const;
  106. //! Exports the grid as an ASCII matrix
  107. void generateASCIIMatrix() const;
  108. //! Called when a statistics export target changes
  109. void onStatExportTargetChanged(bool);
  110. //! Show the interpolation parametrers dialog (depending on the current interpolation mode)
  111. void showInterpolationParamsDialog();
  112. private: //standard methods
  113. //Inherited from cc2Point5DimEditor
  114. double getGridStep() const override;
  115. unsigned char getProjectionDimension() const override;
  116. ccRasterGrid::ProjectionType getTypeOfProjection() const override;
  117. //! Returns the index of the std. dev. layer (field)
  118. int getStdDevLayerIndex() const;
  119. //! Returns user defined height for empty cells
  120. double getCustomHeightForEmptyCells() const;
  121. //! Returns user defined percentile value for SF statistics export
  122. double getStatisticsPercentileValue() const;
  123. //! Returns strategy for empty cell filling (extended version)
  124. ccRasterGrid::EmptyCellFillOption getFillEmptyCellsStrategyExt( double& emptyCellsHeight,
  125. double& minHeight,
  126. double& maxHeight) const;
  127. //! Returns the list of statistics that should be computed on the height values or the scalar fields
  128. void getExportedStats(std::vector<ccRasterGrid::ExportableFields>& stats) const;
  129. //! Returns whether the output cloud should use the original cloud or the grid as 'support'
  130. bool resampleOriginalCloud() const;
  131. //! Returns type of SF projection
  132. ccRasterGrid::ProjectionType getTypeOfSFProjection() const;
  133. //! Updates the std. dev. SF combox status depending on the current state of the other options
  134. void updateStdDevLayerComboBox();
  135. //Inherited from cc2Point5DimEditor
  136. void gridIsUpToDate(bool state) override;
  137. //! Load persistent settings
  138. void loadSettings();
  139. //! Updates the grid
  140. bool updateGrid(bool projectSFs = false);
  141. //! Tests if the dialog can be safely closed
  142. bool canClose();
  143. //! Adds a new contour line
  144. void addNewContour(ccPolyline* poly, double height);
  145. protected: //raster grid related stuff
  146. //! Converts the grid to a cloud with scalar field(s)
  147. ccPointCloud* convertGridToCloud( bool exportHeightStats,
  148. bool exportSFStats,
  149. const std::vector<ccRasterGrid::ExportableFields>& exportedStatistics,
  150. bool projectSFs,
  151. bool projectColors,
  152. bool copyHillshadeSF,
  153. const QString& activeSFName,
  154. double percentileValue,
  155. bool exportToOriginalCS,
  156. bool appendGridSizeToSFNames,
  157. ccProgressDialog* progressDialog = nullptr ) const;
  158. private: //members
  159. //! Layer types
  160. enum LayerType { LAYER_HEIGHT = 0,
  161. LAYER_RGB = 1,
  162. LAYER_SF = 2
  163. };
  164. //! Associated Qt UI
  165. Ui::RasterizeToolDialog* m_UI;
  166. //! Associated cloud
  167. ccGenericPointCloud* m_cloud;
  168. //! Whether the cloud has scalar fields
  169. bool m_cloudHasScalarFields;
  170. //! Contour lines
  171. std::vector<ccPolyline*> m_contourLines;
  172. //! Delunay interpolation parameters
  173. ccRasterGrid::DelaunayInterpolationParams m_delaunayInterpParams;
  174. //! Kriging parameters
  175. ccRasterGrid::KrigingParams m_krigingParams;
  176. };