21 #include "../../../dataaccess/utils/Utils.h" 22 #include "../../../raster/Band.h" 23 #include "../../../raster/Raster.h" 24 #include "../../../geometry/Utils.h" 25 #include "../../../rp/Functions.h" 26 #include "../../../maptools/Utils.h" 27 #include "../../../se/Categorize.h" 28 #include "../../../se/ColorMap.h" 29 #include "../../../se/CoverageStyle.h" 30 #include "../../../se/Utils.h" 31 #include "../../../se/ParameterValue.h" 32 #include "../../../common/STLUtils.h" 33 #include "../charts/ChartDisplay.h" 34 #include "../charts/ChartStyle.h" 35 #include "../charts/Histogram.h" 36 #include "../charts/HistogramChart.h" 37 #include "../charts/HistogramStyle.h" 38 #include "../charts/Utils.h" 39 #include "../se/SlicingColorMapWidget.h" 40 #include "../utils/ScopedCursor.h" 41 #include "../canvas/Canvas.h" 42 #include "../canvas/MapDisplay.h" 43 #include "../progress/ProgressViewerDialog.h" 45 #include "ui_SlicingColorMapForm.h" 46 #include "ui_RasterSlicingWizardPageForm.h" 51 #include <QMessageBox> 56 m_ui.reset(
new Ui::RasterSlicingWizardPageForm);
60 m_ui->m_histogramToolButton->setIcon(QIcon::fromTheme(
"chart-bar"));
63 this->setTitle(tr(
"Raster Slicing"));
64 this->setSubTitle(tr(
"Define the raster slicing parameters."));
73 QGridLayout* displayLayout =
new QGridLayout(
m_ui->m_toolWidget);
75 displayLayout->addWidget(
m_tool.get());
76 displayLayout->setContentsMargins(0,0,0,0);
79 QGridLayout* chartLayout =
new QGridLayout(
m_ui->m_histWidget);
87 chartLayout->setContentsMargins(0, 0, 0, 0);
95 QGridLayout* slicesWidgetLayout =
new QGridLayout(
m_ui->m_slicesWidget);
98 slicesWidgetLayout->setContentsMargins(0, 0, 0, 0);
102 m_ui->m_visibleAreaCheckBox->setEnabled(
false);
105 connect(
m_ui->m_bandComboBox, SIGNAL(currentIndexChanged(
int)),
m_colorMapWidget, SLOT(onBandSelected(
int)));
106 connect(
m_colorMapWidget->
getForm()->m_tableWidget, SIGNAL(cellChanged(
int,
int)),
this, SIGNAL(completeChanged()));
119 return m_ui->m_bandComboBox->currentText().toUtf8().data();
134 m_tool->setMapDisplay(mapDisplay);
140 m_tool->setActionGroup(actionGroup);
141 m_tool->enableBoxAction();
146 bool useVisibleArea =
m_ui->m_visibleAreaCheckBox->isChecked();
150 if (useVisibleArea && extValid && isWithinRaster)
167 std::unique_ptr<te::rst::Raster> inputRst = ds->getRaster(rpos);
175 size_t bandsNumber =
m_raster->getNumberOfBands();
177 m_ui->m_bandComboBox->clear();
180 m_ui->m_bandComboBox->addItem(QString::number(
band));
191 m_ui->m_visibleAreaCheckBox->setEnabled(
true);
193 m_ui->m_visibleAreaCheckBox->setEnabled(
false);
205 std::unique_ptr<te::da::DataSet> dataset(
m_rasterLayer->getData().release());
206 std::unique_ptr<te::da::DataSetType> dsType(
m_rasterLayer->getSchema().release());
214 int band =
m_ui->m_bandComboBox->currentIndex();
227 m_ui->m_bandComboBox->setCurrentIndex(index);
249 unsigned int& inputRasterBand,
bool& eqHistogram)
251 inputRasterBand = (
unsigned int)
m_ui->m_bandComboBox->currentText().toUInt();
252 eqHistogram =
m_ui->m_equalizeHistogramCheckBox->isChecked();
281 delete canvasInstance;
288 canvasInstance.
clear();
297 QApplication::setOverrideCursor(Qt::WaitCursor);
302 bool needRemap =
false;
320 std::map<std::string, std::string> info;
321 info[
"FORCE_MEM_DRIVER"] =
"TRUE";
327 QApplication::restoreOverrideCursor();
333 QApplication::setOverrideCursor(Qt::WaitCursor);
338 std::unique_ptr<te::se::CoverageStyle> cs(dynamic_cast<te::se::CoverageStyle*>(
360 delete canvasInstance;
362 QApplication::restoreOverrideCursor();
370 unsigned int inputRasterBand = 0;
371 bool eqHistogram =
false;
378 QApplication::setOverrideCursor(Qt::WaitCursor);
379 std::unique_ptr< te::rst::Raster > outRasterPtr;
381 std::map<std::string, std::string> rinfo;
382 rinfo[
"MEM_RASTER_NROWS"] = boost::lexical_cast<std::string>(
m_rasterPreview->getNumberOfRows());
383 rinfo[
"MEM_RASTER_NCOLS"] = boost::lexical_cast<std::string>(
m_rasterPreview->getNumberOfColumns());
384 rinfo[
"MEM_RASTER_DATATYPE"] = boost::lexical_cast<std::string>(
m_rasterPreview->getBandDataType(0));
385 rinfo[
"MEM_RASTER_NBANDS"] = boost::lexical_cast<std::string>(
m_rasterPreview->getNumberOfBands());
388 std::unique_ptr<te::se::ColorMap> colorMap(
getColorMap());
390 std::vector<te::se::ParameterValue*> values = colorMap->getCategorize()->getThresholds();
391 std::map<double, double> slice_limits;
392 for (
size_t i = 0; i < values.size(); ++i)
395 size_t pos = limits.find(
" ");
396 double min = std::stod(limits.substr(0, pos));
397 double max = std::stod(limits.substr(pos));
398 slice_limits.insert(std::pair< double, double >(min,max));
401 std::vector<te::se::ParameterValue*> colors = colorMap->getCategorize()->getThresholdValues();
403 std::vector< te::rst::BandProperty::ColorEntry > palette;
405 for(
size_t i = 0; i < colors.size(); ++i)
416 palette.push_back(color);
420 static_cast<int>(palette.size()), eqHistogram, rinfo,
421 "MEM",
true, &palette, outRasterPtr, slice_limits ) )
425 QApplication::restoreOverrideCursor();
430 QMessageBox::critical(
this, tr(
"Raster slicing"), tr(
"Raster slicing execution error.") +
435 QApplication::restoreOverrideCursor();
te::gm::Envelope * getExtent()
Returns the geographic extension of the raster data.
te::map::AbstractLayerPtr m_rasterLayer
Testing a better way to show the chart.
void makeInvalid()
It will invalidated the envelope.
te::qt::widgets::HistogramChart * m_histogramChart
The preview histogram chart.
void setSRID(int srid=0)
This function sets the srid of the display when the wizard was initiated.
bool intersects(const Envelope &rhs) const
It returns true if the envelopes "spatially intersects".
void getParameters(unsigned int &inputRasterBand, bool &eqHistogram)
This function returns the parameters as configured by the user.
int getRed() const
It returns the red component color value (a value from 0 to 255).
#define TE_UNKNOWN_SRS
A numeric value to represent a unknown SRS identification in TerraLib.
std::unique_ptr< Ui::RasterSlicingWizardPageForm > m_ui
The wizard page form.
bool RasterSlicing(const te::rst::Raster &inputRaster, const unsigned int inputRasterBand, const bool createPaletteRaster, const unsigned int slicesNumber, const bool eqHistogram, const std::map< std::string, std::string > &rasterInfo, const std::string &rasterType, const bool enableProgress, std::vector< te::rst::BandProperty::ColorEntry > const *const palettePtr, std::unique_ptr< te::rst::Raster > &outRasterPtr, std::map< double, double > limits)
Generate all wavelet planes from the given input raster.
const double & getUpperRightX() const
It returns a constant refernce to the x coordinate of the upper right corner.
TESEEXPORT Style * CreateCoverageStyle(const std::vector< te::rst::BandProperty * > &properties)
Try creates an appropriate coverage style based on given band properties.
te::qt::widgets::MapDisplay * m_mapDisplay
The map display.
int getBlue() const
It returns the blue component color value (a value from 0 to 255).
double m_urx
Upper right corner x-coordinate.
int getGreen() const
It returns the green component color value (a value from 0 to 255).
short c4
alpha or blackband.
#define TE_OPAQUE
For an RGBA color this is the value of the alpha-channel for totally opaque.
const double & getLowerLeftY() const
It returns a constant refernce to the y coordinate of the lower left corner.
void drawPreview(te::rst::Raster *raster)
static te::dt::Date ds(2010, 01, 01)
const double & getUpperRightY() const
It returns a constant refernce to the x coordinate of the upper right corner.
std::unique_ptr< te::gm::Geometry > m_geom
The geometry.
void applyPreview()
This function applies preview of raster slicing result.
static const std::string getLastLogStr()
Returns the last log string generated by this module.
te::gm::Envelope m_extent
The envelope that can be used to trim the output raster.
bool isComplete() const
This function evaluates the page to confirm if the user has completed the minimum configuration requi...
void clearCanvas()
This function cleans the canvas.
TEMAPEXPORT void DrawRaster(te::da::DataSetType *type, te::da::DataSourcePtr ds, Canvas *canvas, const te::gm::Envelope &bbox, int bboxSRID, const te::gm::Envelope &visibleArea, int srid, te::se::CoverageStyle *style, te::map::RasterContrast *rc, const double &scale, bool *cancel)
double m_llx
Lower left corner x-coordinate.
std::unique_ptr< te::rst::Raster > m_rasterPreview
The raster used for preview.
An Envelope defines a 2D rectangular region.
void setExtent(const te::gm::Envelope &extent)
This function sets the envelope that will be used to trim tha raster if the user requests it...
An abstract class for raster data strucutures.
RasterSlicingWizardPage(QWidget *parent=0)
Constructor.
virtual std::size_t getNumberOfBands() const =0
Returns the number of bands (dimension of cells attribute values) in the raster.
std::string getCurrentBand()
This function returns the band from the raster taht will be used.
virtual int getSRID() const
It return the Spatial Reference System used by the Map Display.
std::unique_ptr< te::rst::Raster > m_raster
The raster that will be sliced.
int getAlpha() const
It returns the alpha component color value (a value from 0 to 255).
virtual const te::gm::Envelope & getExtent() const
It returns the world extent showned by the MapDisplay.
void setLayer(te::map::AbstractLayerPtr layer)
This function sets the layer that contains the raster that will be sliced.
double m_lly
Lower left corner y-coordinate.
std::unique_ptr< te::qt::widgets::RpToolsWidget > m_tool
Toolbar.
A Converter is responsible for the conversion of coordinates between different Coordinate Systems (CS...
TEMAPEXPORT te::rst::Raster * GetRaster(AbstractLayer *layer)
It gets the raster referenced by the given data set layer.
bool trimRaster()
This function will check if the conditions required to trim the raster have been met.
int getSRID() const
Returns the raster spatial reference system identifier.
short c1
gray, red, cyan or hue.
void onSliceBandComboBoxIndexCHanged(int index)
~RasterSlicingWizardPage()
Destructor.
double m_ury
Upper right corner y-coordinate.
te::se::ColorMap * getColorMap()
This function returns the Color Map generated by the user.
const double & getLowerLeftX() const
It returns a constant reference to the x coordinate of the lower left corner.
A helper class for 32-bit RGBA (Red-Green-Blue-Alpha channel) color.
void setMapDisplay(te::qt::widgets::MapDisplay *mapDisplay)
This function sets the map display.
short c3
blue, yellow, or saturation.
te::qt::widgets::SlicingColorMapWidget * m_colorMapWidget
The widget used to edit the legend of the output layer.
te::qt::widgets::ChartDisplay * m_chartDisplay
The display used to draw the preview histogram.
An structure to represent a color tuple.
const te::gm::Envelope & getExtent()
This function returns the envelope that can be used to trim the raster if the user requests it...
int m_srid
The current srid from the display.
TEDATAACCESSEXPORT std::size_t GetFirstPropertyPos(const te::da::DataSet *dataset, int datatype)
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
void transform(int oldsrid, int newsrid)
It will transform the coordinates of the Envelope from the old SRS to the new one.
void FreeContents(boost::unordered_map< K, V * > &m)
This function can be applied to a map of pointers. It will delete each pointer in the map...
TESEEXPORT std::string GetString(const te::se::ParameterValue *param)
It gets the parameter value as a string.
void setActionGroup(QActionGroup *actionGroup)
This function sets the QActionGroup.
A ColorMap defines either the colors of a pallette-type raster source or the mapping of numeric pixel...
short c2
green, magenta, or lightness.
bool isValid() const
It tells if the rectangle is valid or not.
int getSRID()
This function returns the srid of the display when the wizard was initiated.
TEGEOMEXPORT Geometry * GetGeomFromEnvelope(const Envelope *const e, int srid)
It creates a Geometry (a polygon) from the given envelope.
void drawGeom()
This function draws geometry after the envelope was acquired.
void onEnvelopeAcquired(te::gm::Envelope env)