ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
ecvRasterizeTool.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #pragma once
9 
10 #include <ui_rasterizeDlg.h>
11 
12 // Local
13 #include "ecv2.5DimEditor.h"
14 
15 // Qt
16 #include <QString>
17 
19 class ccPointCloud;
20 class ccPolyline;
21 
23 class ccRasterizeTool : public QDialog,
24  public cc2Point5DimEditor,
25  public Ui::RasterizeToolDialog {
26  Q_OBJECT
27 
28 public:
30  ccRasterizeTool(ccGenericPointCloud* cloud, QWidget* parent = 0);
31 
34 
35 public: // raster export
37  struct ExportBands {
38  bool height = true;
39  bool rgb = false;
40  bool density = false;
41  bool visibleSF = false;
42  bool allSFs = false;
43  };
44 
46  static bool ExportGeoTiff(
47  QString outputFilename,
48  const ExportBands& exportBands,
49  ccRasterGrid::EmptyCellFillOption fillEmptyCellsStrategy,
50  const ccRasterGrid& grid,
51  const ccBBox& gridBBox,
52  unsigned char Z,
53  double customHeightForEmptyCells =
54  std::numeric_limits<double>::quiet_NaN(),
55  ccGenericPointCloud* originCloud = 0,
56  int visibleSfIndex = -1);
57 
58 protected slots:
59 
61  ccPointCloud* generateCloud(bool autoExport = true) const;
62 
64  void generateRaster() const;
65 
67  void generateMesh() const;
68 
70  void exportContourLines();
71 
73  void generateContours();
74 
76  void generateHillshade();
77 
79  void removeContourLines();
80 
82  void testAndAccept();
84  void testAndReject();
85 
87  void saveSettings();
88 
90  void activeLayerChanged(int, bool autoRedraw = true);
91 
93  void projectionDirChanged(int);
94 
96  void projectionTypeChanged(int);
97 
99  void resampleOptionToggled(bool);
100 
102  void sfProjectionTypeChanged(int);
103 
104  // Inherited from cc2Point5DimEditor
105  virtual bool showGridBoxEditor() override;
106 
109 
111  void gridOptionChanged();
112 
114  void updateGridInfo();
115 
117  void updateGridAndDisplay();
118 
120  virtual void generateImage() const;
121 
123  virtual void generateASCIIMatrix() const;
124 
125 protected: // standard methods
126  // Inherited from cc2Point5DimEditor
127  virtual double getGridStep() const override;
128  virtual unsigned char getProjectionDimension() const override;
129  virtual ccRasterGrid::ProjectionType getTypeOfProjection() const override;
130 
132  double getCustomHeightForEmptyCells() const;
133 
136  double& emptyCellsHeight,
137  double& minHeight,
138  double& maxHeight) const;
139 
142  bool exportAsSF(ccRasterGrid::ExportableFields field) const;
143 
146  bool resampleOriginalCloud() const;
147 
150 
151  // Inherited from cc2Point5DimEditor
152  virtual void gridIsUpToDate(bool state) override;
153 
155  void loadSettings();
156 
158  bool updateGrid(bool interpolateSF = false);
159 
161  bool canClose();
162 
164  void addNewContour(ccPolyline* poly, double height, unsigned subIndex);
165 
166 protected: // raster grid related stuff
169  const std::vector<ccRasterGrid::ExportableFields>& exportedFields,
170  bool interpolateSF,
171  bool interpolateColors,
172  bool copyHillshadeSF,
173  QString activeSFName,
174  bool exportToOriginalCS) const;
175 
176 protected: // members
178  enum LayerType { LAYER_HEIGHT = 0, LAYER_RGB = 1, LAYER_SF = 2 };
179 
182 
184  std::vector<ccPolyline*> m_contourLines;
185 };
int height
#define slots
2.5D data editor (generic interface)
Bounding box structure.
Definition: ecvBBox.h:25
A 3D cloud interface with associated features (color, normals, octree, etc.)
A 3D cloud and its associated features (color, normals, scalar fields, etc.)
Colored polyline.
Definition: ecvPolyline.h:24
Rasterize tool (dialog)
void addNewContour(ccPolyline *poly, double height, unsigned subIndex)
Adds a new contour line.
ccPointCloud * generateCloud(bool autoExport=true) const
Exports the grid as a cloud.
virtual ccRasterGrid::ProjectionType getTypeOfProjection() const override
Returns type of projection.
void generateMesh() const
Exports the grid as a mesh.
void updateGridAndDisplay()
Update the grid and the 2D display.
void projectionDirChanged(int)
Called when the projection direction changes.
virtual unsigned char getProjectionDimension() const override
Returns projection dimension.
virtual void generateASCIIMatrix() const
Exports the grid as an ASCII matrix.
virtual void generateImage() const
Exports the grid as an image.
void generateContours()
Generates a contour plot.
void resampleOptionToggled(bool)
Called when the 'resampled' option changes.
double getCustomHeightForEmptyCells() const
Returns user defined height for empty cells.
void updateGridInfo()
Updates the gid info.
bool exportAsSF(ccRasterGrid::ExportableFields field) const
ccRasterizeTool(ccGenericPointCloud *cloud, QWidget *parent=0)
Default constructor.
LayerType
Layer types.
void projectionTypeChanged(int)
Called when the projection type changes.
bool resampleOriginalCloud() const
void loadSettings()
Load persistent settings.
static bool ExportGeoTiff(QString outputFilename, const ExportBands &exportBands, ccRasterGrid::EmptyCellFillOption fillEmptyCellsStrategy, const ccRasterGrid &grid, const ccBBox &gridBBox, unsigned char Z, double customHeightForEmptyCells=std::numeric_limits< double >::quiet_NaN(), ccGenericPointCloud *originCloud=0, int visibleSfIndex=-1)
Exports a raster grid as a geotiff file.
void fillEmptyCellStrategyChanged(int)
Called when the empty cell filling strategy changes.
std::vector< ccPolyline * > m_contourLines
Contour lines.
void saveSettings()
Save persistent settings and 'accept' dialog.
void testAndAccept()
Accepts the dialog (if some conditions are met) and save settings.
ccGenericPointCloud * m_cloud
Associated cloud.
bool updateGrid(bool interpolateSF=false)
Updates the grid.
void exportContourLines()
Exports the (already generated) contour lines.
ccRasterGrid::EmptyCellFillOption getFillEmptyCellsStrategyExt(double &emptyCellsHeight, double &minHeight, double &maxHeight) const
Returns strategy for empty cell filling (extended version)
void generateHillshade()
Generates hillshade.
~ccRasterizeTool()
Destructor.
virtual bool showGridBoxEditor() override
virtual void gridIsUpToDate(bool state) override
Declares whether the grid is up-to-date or not.
void generateRaster() const
Exports the grid as a raster.
void sfProjectionTypeChanged(int)
Called when the SF projection type changes.
void removeContourLines()
Removes all displayed contour lines.
bool canClose()
Tests if the dialog can be safely closed.
void gridOptionChanged()
Called when the an option of the grid generation has changed.
ccRasterGrid::ProjectionType getTypeOfSFInterpolation() const
Returns type of SF interpolation.
void testAndReject()
Rejects the dialog (if some conditions are met)
ccPointCloud * convertGridToCloud(const std::vector< ccRasterGrid::ExportableFields > &exportedFields, bool interpolateSF, bool interpolateColors, bool copyHillshadeSF, QString activeSFName, bool exportToOriginalCS) const
Converts the grid to a cloud with scalar field(s)
virtual double getGridStep() const override
Returns projection grid step.
void activeLayerChanged(int, bool autoRedraw=true)
Called when the active layer changes.
bool interpolateColors(const ccHObject::Container &selectedEntities, QWidget *parent)
Interpolate colors from on entity and transfer them to another one.
Raster grid type.
Definition: ecvRasterGrid.h:53
ExportableFields
Exportable fields.
Definition: ecvRasterGrid.h:79
ProjectionType
Types of projection.
EmptyCellFillOption
Option for handling empty cells.
Bands to be exported.