27 #include "../../../common/STLUtils.h" 28 #include "../../../common/StringUtils.h" 29 #include "../../../dataaccess/utils/Utils.h" 30 #include "../../../maptools/RasterContrast.h" 31 #include "../../../maptools/Utils.h" 32 #include "../../../raster.h" 33 #include "../../../se/Utils.h" 34 #include "../canvas/MapDisplay.h" 35 #include "../charts/ChartDisplay.h" 36 #include "../charts/ChartStyle.h" 37 #include "../charts/Histogram.h" 38 #include "../charts/HistogramChart.h" 39 #include "../charts/HistogramStyle.h" 40 #include "../rp/RasterHistogramWidget.h" 41 #include "../utils/HorizontalSliderWidget.h" 42 #include "../utils/ScopedCursor.h" 44 #include "ui_RasterSymbolizerWidgetForm.h" 48 #include <QMessageBox> 54 #define GAIN_CONSTANT_VALUE 0.1 55 #define OFFSET_CONSTANT_VALUE 10 59 m_ui(new
Ui::RasterSymbolizerWidgetForm),
60 m_sliderWidget(nullptr),
62 m_symbolizer(nullptr),
64 m_contrastRed(nullptr),
65 m_contrastGreen(nullptr),
66 m_contrastBlue(nullptr),
67 m_contrastMono(nullptr),
72 m_cs(new
te::se::ChannelSelection),
73 m_setLocalSymbol(false)
83 QGridLayout* layout =
new QGridLayout(
m_ui->m_opacityWidget);
84 layout->setContentsMargins(0,0,0,0);
85 layout->setAlignment(Qt::AlignTop);
89 QGridLayout* histogramLayout =
new QGridLayout(
m_ui->m_histogramGroupBox);
92 histogramLayout->setContentsMargins(0, 0, 0, 0);
102 m_ui->m_inMinLineEdit->setValidator(
new QDoubleValidator(
this));
103 m_ui->m_inMaxLineEdit->setValidator(
new QDoubleValidator(
this));
115 m_ui->m_visibleAreaRadioButton->setChecked(
true);
117 m_ui->m_allImageSummaryRadioButton->setChecked(
true);
136 connect(
m_ui->m_contrastMHorizontalSlider, SIGNAL(valueChanged(
int)),
this, SLOT(
onMonoGammaChanged(
int)));
137 connect(
m_ui->m_contrastRHorizontalSlider, SIGNAL(valueChanged(
int)),
this, SLOT(
onRedGammaChanged(
int)));
139 connect(
m_ui->m_contrastBHorizontalSlider, SIGNAL(valueChanged(
int)),
this, SLOT(
onBlueGammaChanged(
int)));
147 connect(
m_ui->m_gainMinusPushButton, SIGNAL(clicked()),
this, SLOT(
onDecreaseGain()));
148 connect(
m_ui->m_gainResetPushButton, SIGNAL(clicked()),
this, SLOT(
onDefaultGain()));
165 m_ui->m_histogramToolButton->setIcon(QIcon::fromTheme(
"chart-bar"));
166 m_ui->m_applyToolButton->setIcon(QIcon::fromTheme(
"check"));
167 m_ui->m_resetToolButton->setIcon(QIcon::fromTheme(
"edit-undo"));
169 m_ui->m_calcSummaryToolButton->setIcon(QIcon::fromTheme(
"view-data-table"));
170 m_ui->m_resetSummaryToolButton->setIcon(QIcon::fromTheme(
"edit-undo"));
173 list.append(tr(
"Band"));
174 list.append(tr(
"Min"));
175 list.append(tr(
"Max"));
176 list.append(tr(
"Std Dev"));
177 list.append(tr(
"Mean"));
179 m_ui->m_bandTableWidget->setColumnCount(5);
180 m_ui->m_bandTableWidget->setHorizontalHeaderLabels(list);
182 m_ui->m_bandTableWidget->resizeColumnsToContents();
183 #if (QT_VERSION >= 0x050000) 184 m_ui->m_bandTableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
186 m_ui->m_bandTableWidget->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
219 m_ui->m_composeCRadioButton->setChecked(
true);
225 m_ui->m_composeMRadioButton->setChecked(
true);
231 m_ui->m_composeRRadioButton->setChecked(
true);
237 m_ui->m_composeGRadioButton->setChecked(
true);
243 m_ui->m_composeBRadioButton->setChecked(
true);
324 m_ui->m_inMinLineEdit->clear();
325 m_ui->m_inMaxLineEdit->clear();
327 m_ui->m_gainLineEdit->clear();
328 m_ui->m_offset1LineEdit->clear();
329 m_ui->m_offset2LineEdit->clear();
337 QStringList bandNames;
339 m_ui->m_bandComboBox->clear();
341 for(
size_t i = 0; i < bp.size(); ++i)
343 m_ui->m_bandComboBox->addItem(QString::number(i));
347 if(bp[i]->m_description.empty())
350 bandInfo.setNum(bp[i]->m_idx);
352 bandNames.push_back(bandInfo);
356 bandNames.push_back(bp[i]->m_description.c_str());
361 if (bp[i]->m_noDataValue == std::numeric_limits<double>::max())
362 m_ui->m_rasterDummyLineEdit->clear();
364 m_ui->m_rasterDummyLineEdit->setText(QString::number(bp[i]->m_noDataValue));
368 m_ui->m_composeMComboBox->clear();
369 m_ui->m_composeMComboBox->addItems(bandNames);
371 m_ui->m_composeRComboBox->clear();
372 m_ui->m_composeRComboBox->addItems(bandNames);
374 m_ui->m_composeGComboBox->clear();
375 m_ui->m_composeGComboBox->addItems(bandNames);
377 m_ui->m_composeBComboBox->clear();
378 m_ui->m_composeBComboBox->addItems(bandNames);
389 m_ui->m_gainLabel->setPixmap(QIcon::fromTheme(
"gain").pixmap(16,16));
390 m_ui->m_offSetLabel->setPixmap(QIcon::fromTheme(
"offset").pixmap(16,16));
391 m_ui->m_gainPlusPushButton->setIcon(QIcon::fromTheme(
"list-add"));
392 m_ui->m_gainPlusPushButton->setIconSize(QSize(16,16));
393 m_ui->m_gainMinusPushButton->setIcon(QIcon::fromTheme(
"list-remove"));
394 m_ui->m_gainMinusPushButton->setIconSize(QSize(16,16));
395 m_ui->m_gainResetPushButton->setIcon(QIcon::fromTheme(
"edit-undo"));
396 m_ui->m_gainResetPushButton->setIconSize(QSize(16,16));
397 m_ui->m_offsetPlusPushButton->setIcon(QIcon::fromTheme(
"list-add"));
398 m_ui->m_offsetPlusPushButton->setIconSize(QSize(16,16));
399 m_ui->m_offsetMinusPushButton->setIcon(QIcon::fromTheme(
"list-remove"));
400 m_ui->m_offsetMinusPushButton->setIconSize(QSize(16,16));
401 m_ui->m_offsetResetPushButton->setIcon(QIcon::fromTheme(
"edit-undo"));
402 m_ui->m_offsetResetPushButton->setIconSize(QSize(16,16));
404 m_ui->m_dummyPushButton->setIcon(QIcon::fromTheme(
"check"));
405 m_ui->m_dummyPushButton->setIconSize(QSize(16, 16));
407 m_ui->m_composeMonoLabel->setPixmap(QIcon::fromTheme(
"bullet-black").pixmap(16,16));
408 m_ui->m_composeRedLabel->setPixmap(QIcon::fromTheme(
"bullet-red").pixmap(16,16));
409 m_ui->m_composeGreenLabel->setPixmap(QIcon::fromTheme(
"bullet-green").pixmap(16,16));
410 m_ui->m_composeBlueLabel->setPixmap(QIcon::fromTheme(
"bullet-blue").pixmap(16,16));
412 m_ui->m_composeCRadioButton->setIcon(QIcon::fromTheme(
"channels").pixmap(16,16));
413 m_ui->m_composeRRadioButton->setIcon(QIcon::fromTheme(
"channel-red").pixmap(16,16));
414 m_ui->m_composeGRadioButton->setIcon(QIcon::fromTheme(
"channel-green").pixmap(16,16));
415 m_ui->m_composeBRadioButton->setIcon(QIcon::fromTheme(
"channel-blue").pixmap(16,16));
416 m_ui->m_composeMRadioButton->setIcon(QIcon::fromTheme(
"channel-gray").pixmap(16,16));
418 m_ui->m_rContrastLabel->setPixmap(QIcon::fromTheme(
"contrast-red").pixmap(16,16));
419 m_ui->m_gContrastLabel->setPixmap(QIcon::fromTheme(
"contrast-green").pixmap(16,16));
420 m_ui->m_bContrastLabel->setPixmap(QIcon::fromTheme(
"contrast-blue").pixmap(16,16));
421 m_ui->m_mContrastLabel->setPixmap(QIcon::fromTheme(
"contrast-mono").pixmap(16,16));
426 m_ceNames.insert(std::map<te::se::ContrastEnhancement::ContrastEnhancementType, QString>::value_type
428 m_ceNames.insert(std::map<te::se::ContrastEnhancement::ContrastEnhancementType, QString>::value_type
430 m_ceNames.insert(std::map<te::se::ContrastEnhancement::ContrastEnhancementType, QString>::value_type
433 std::map<te::se::ContrastEnhancement::ContrastEnhancementType, QString>::iterator it =
m_ceNames.begin();
437 m_ui->m_contrastTypeComboBox->addItem(it->second);
444 m_ui->m_contrastTypeComboBox->setVisible(
false);
445 m_ui->m_contrastTypeLabel->setVisible(
false);
455 m_ui->m_dummyLineEdit->setValidator(
new QDoubleValidator(
this));
504 m_ui->m_dummyLineEdit->setText(QString::number(value));
508 m_ui->m_dummyLineEdit->clear();
512 m_ui->m_contrastGroupBox->setChecked(
false);
518 m_ui->m_composeRComboBox->setCurrentIndex(index);
524 m_ui->m_contrastRHorizontalSlider->setValue((
int)v);
527 m_ui->m_contrastGroupBox->setChecked(
true);
531 m_ui->m_contrastRHorizontalSlider->setValue(100.);
539 m_ui->m_composeGComboBox->setCurrentIndex(index);
545 m_ui->m_contrastGHorizontalSlider->setValue((
int)v);
548 m_ui->m_contrastGroupBox->setChecked(
true);
552 m_ui->m_contrastGHorizontalSlider->setValue(100.);
560 m_ui->m_composeBComboBox->setCurrentIndex(index);
566 m_ui->m_contrastBHorizontalSlider->setValue((
int)v);
569 m_ui->m_contrastGroupBox->setChecked(
true);
573 m_ui->m_contrastBHorizontalSlider->setValue(100.);
581 m_ui->m_composeMComboBox->setCurrentIndex(index);
587 m_ui->m_contrastMHorizontalSlider->setValue((
int)v);
590 m_ui->m_contrastGroupBox->setChecked(
true);
594 m_ui->m_contrastMHorizontalSlider->setValue(100.);
604 QString name = value.c_str();
608 for(
int i = 0; i < cb->count(); ++i)
610 if(cb->itemText(i) == name)
612 cb->setCurrentIndex(i);
621 cb->setCurrentIndex(cb->count() - 1);
630 double seOpacity = opacity / 100.;
632 qStrOpacity.setNum(seOpacity);
640 m_ui->m_composeMComboBox->setEnabled(
true);
641 m_ui->m_composeRComboBox->setEnabled(
false);
642 m_ui->m_composeGComboBox->setEnabled(
false);
643 m_ui->m_composeBComboBox->setEnabled(
false);
661 m_ui->m_composeMComboBox->setEnabled(
false);
662 m_ui->m_composeRComboBox->setEnabled(
true);
663 m_ui->m_composeGComboBox->setEnabled(
false);
664 m_ui->m_composeBComboBox->setEnabled(
false);
682 m_ui->m_composeMComboBox->setEnabled(
false);
683 m_ui->m_composeRComboBox->setEnabled(
false);
684 m_ui->m_composeGComboBox->setEnabled(
true);
685 m_ui->m_composeBComboBox->setEnabled(
false);
703 m_ui->m_composeMComboBox->setEnabled(
false);
704 m_ui->m_composeRComboBox->setEnabled(
false);
705 m_ui->m_composeGComboBox->setEnabled(
false);
706 m_ui->m_composeBComboBox->setEnabled(
true);
724 m_ui->m_composeMComboBox->setEnabled(
false);
725 m_ui->m_composeRComboBox->setEnabled(
true);
726 m_ui->m_composeGComboBox->setEnabled(
true);
727 m_ui->m_composeBComboBox->setEnabled(
true);
811 std::map<te::se::ContrastEnhancement::ContrastEnhancementType, QString>::iterator it =
m_ceNames.begin();
839 double value = double(v) / 100.;
852 double value = double(v) / 100.;
865 double value = double(v) / 100.;
878 double value = double(v) / 100.;
995 if (
m_ui->m_dummyLineEdit->text().isEmpty())
1011 if(
m_ui->m_contrastGroupBox->isChecked() ==
false)
1013 m_ui->m_contrastRHorizontalSlider->setValue(100);
1014 m_ui->m_contrastGHorizontalSlider->setValue(100);
1015 m_ui->m_contrastBHorizontalSlider->setValue(100);
1016 m_ui->m_contrastMHorizontalSlider->setValue(100);
1047 m_ui->m_contrastRHorizontalSlider->setEnabled(
false);
1048 m_ui->m_contrastGHorizontalSlider->setEnabled(
false);
1049 m_ui->m_contrastBHorizontalSlider->setEnabled(
false);
1050 m_ui->m_contrastMHorizontalSlider->setEnabled(
false);
1052 if(
m_ui->m_composeMRadioButton->isChecked())
1054 m_ui->m_contrastMHorizontalSlider->setEnabled(
true);
1057 if(
m_ui->m_composeRRadioButton->isChecked())
1059 m_ui->m_contrastRHorizontalSlider->setEnabled(
true);
1062 if(
m_ui->m_composeGRadioButton->isChecked())
1064 m_ui->m_contrastGHorizontalSlider->setEnabled(
true);
1067 if(
m_ui->m_composeBRadioButton->isChecked())
1069 m_ui->m_contrastBHorizontalSlider->setEnabled(
true);
1072 if(
m_ui->m_composeCRadioButton->isChecked())
1074 m_ui->m_contrastRHorizontalSlider->setEnabled(
true);
1075 m_ui->m_contrastGHorizontalSlider->setEnabled(
true);
1076 m_ui->m_contrastBHorizontalSlider->setEnabled(
true);
1082 int bandIdx =
m_ui->m_bandComboBox->currentText().toInt();
1093 std::map<std::string, std::string> info;
1094 info[
"FORCE_MEM_DRIVER"] =
"TRUE";
1096 if(
m_ui->m_visibleAreaRadioButton->isChecked())
1098 raster.reset(raster->trim(visibleAreaRasterProj, info));
1106 raster.reset(rasterExt->trim(env, info));
1111 double rx = resx / raster->getResolutionX();
1112 double ry = resy / raster->getResolutionY();
1114 double factor = std::min(rx, ry);
1115 factor = std::max(factor, 1.0);
1117 std::size_t level =
static_cast<std::size_t
>(std::log(factor) / std::log(2.0));
1118 std::size_t numberOfLevels = raster->getMultiResLevelsCount();
1122 if (level != 0 && numberOfLevels != 0)
1124 if (numberOfLevels >= level)
1127 overview = raster->
getMultiResLevel(static_cast<unsigned int>(numberOfLevels - 1));
1133 for (std::size_t t = 0; t < raster->getNumberOfBands(); ++t)
1145 raster.reset(overview);
1161 if (bp->
m_min != std::numeric_limits<double>::max() &&
1162 bp->
m_max != std::numeric_limits<double>::max())
1178 m_ui->m_inMinLineEdit->setText(QString::number(min));
1179 m_ui->m_inMaxLineEdit->setText(QString::number(max));
1183 std::vector<double> gain, offset1, offset2, min, max;
1186 m_ui->m_gainLineEdit->setText(QString::number(gain[bandIdx]));
1187 m_ui->m_offset1LineEdit->setText(QString::number(offset1[bandIdx]));
1188 m_ui->m_offset2LineEdit->setText(QString::number(offset2[bandIdx]));
1192 bool defaultValues =
false;
1194 if (gain[bandIdx] == 1. && offset1[bandIdx] == 0. && offset2[bandIdx] == 0.)
1195 defaultValues =
true;
1199 m_ui->m_inMinLineEdit->setText(QString::number(min[bandIdx]));
1200 m_ui->m_inMaxLineEdit->setText(QString::number(max[bandIdx]));
1216 m_ui->m_inMinLineEdit->setText(QString::number(value));
1224 m_ui->m_inMaxLineEdit->setText(QString::number(value));
1232 m_ui->m_inMinLineEdit->setText(QString::number(value));
1240 m_ui->m_inMaxLineEdit->setText(QString::number(value));
1253 m_ui->m_gainLineEdit->clear();
1254 m_ui->m_offset1LineEdit->clear();
1255 m_ui->m_offset2LineEdit->clear();
1257 m_ui->m_inMinLineEdit->clear();
1258 m_ui->m_inMaxLineEdit->clear();
1271 int type =
m_ui->m_typeComboBox->currentData().toInt();
1279 if (
m_ui->m_inMinLineEdit->text().isEmpty() ||
m_ui->m_inMaxLineEdit->text().isEmpty())
1281 QMessageBox::warning(
this, tr(
"Warning"), tr(
"Input values not defined."));
1285 double minValue =
m_ui->m_inMinLineEdit->text().toDouble();
1286 double maxValue =
m_ui->m_inMaxLineEdit->text().toDouble();
1288 if (minValue >= maxValue)
1290 QMessageBox::warning(
this, tr(
"Warning"), tr(
"Invalid input values."));
1294 double gain, offset1, offset2;
1298 int bandIdx =
m_ui->m_bandComboBox->currentText().toInt();
1302 m_ui->m_gainLineEdit->setText(QString::number(gain));
1303 m_ui->m_offset1LineEdit->setText(QString::number(offset1));
1304 m_ui->m_offset2LineEdit->setText(QString::number(offset2));
1314 QMessageBox::warning(
this, tr(
"Warning"), tr(
"Internal error."));
1323 m_ui->m_bandTableWidget->setRowCount((
int)inputRaster->getNumberOfBands());
1331 std::map<std::string, std::string> info;
1332 info[
"FORCE_MEM_DRIVER"] =
"TRUE";
1334 if(
m_ui->m_visibleAreaSummaryRadioButton->isChecked())
1336 inputRaster.reset(inputRaster->trim(visibleAreaRasterProj, info));
1342 for(std::size_t i = 0; i < inputRaster->getNumberOfBands(); ++i)
1349 QTableWidgetItem* itemBand =
new QTableWidgetItem(QString::number(i));
1350 itemBand->setFlags(Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsSelectable);
1351 m_ui->m_bandTableWidget->setItem(i, 0, itemBand);
1354 itemMin->setFlags(Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsSelectable);
1355 m_ui->m_bandTableWidget->setItem(i, 1, itemMin);
1358 itemMax->setFlags(Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsSelectable);
1359 m_ui->m_bandTableWidget->setItem(i, 2, itemMax);
1362 itemStd->setFlags(Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsSelectable);
1363 m_ui->m_bandTableWidget->setItem(i, 3, itemStd);
1366 itemMean->setFlags(Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsSelectable);
1367 m_ui->m_bandTableWidget->setItem(i, 4, itemMean);
1373 m_ui->m_bandTableWidget->setRowCount(0);
TEDATAACCESSEXPORT te::rst::RasterProperty * GetFirstRasterProperty(const DataSetType *dt)
void setRedChannel(SelectedChannel *c)
A selected channel to be display.
void setValues(const double &gain, const double &offset1, const double &offset2, const double &min, const double &max, const std::size_t &band)
It set the transformation values for contranst of one band.
TERASTEREXPORT void GetDataTypeRanges(const int &dataType, double &min, double &max)
Return the values range of a given data type.
This is the base class for layers.
virtual const te::gm::Envelope & getExtent() const
It returns the Layer extent (or minimum bounding box).
A raster band description.
virtual void setRasterContrast(te::map::RasterContrast *contrast)
It sets the raster contrast associated to the Layer.
ParameterValue * getOffset() const
void setGain(ParameterValue *p)
double m_min
Minimum pixel value (default is std::numeric_limits<double>::max() which means no value set)...
static bool getGainAndOffset(const InputParameters::ContrastType &type, const double &inRangeMin, const double &inRangeMax, const double &outRangeMin, const double &outRangeMax, double &gain, double &offset1, double &offset2)
Returns gain and offset values for contrast types (when applicable).
te::se::ChannelSelection * getChannelSelection() const
double getWidth() const
It returns the envelope width.
SelectedChannel * getRedChannel() const
void setGammaValue(const double &v)
TESEEXPORT double GetDouble(const te::se::ParameterValue *param)
It gets the parameter value as a double.
void setGrayChannel(SelectedChannel *c)
SelectedChannel * getBlueChannel() const
double m_noDataValue
Value to indicate elements where there is no data, default is std::numeric_limits<double>::max().
double m_max
Maximum pixel value (default is std::numeric_limits<double>::max() which means no value set)...
The "ParameterValueType" uses WFS-Filter expressions to give values for SE graphic parameters...
std::string getSourceChannelName() const
ParameterValue * getGain() const
static RasterSummaryManager & getInstance()
It returns a reference to the singleton instance.
An Envelope defines a 2D rectangular region.
An abstract class for raster data strucutures.
virtual std::size_t getNumberOfBands() const =0
Returns the number of bands (dimension of cells attribute values) in the raster.
virtual int getSRID() const
It return the Spatial Reference System used by the Map Display.
void setNoDataValue(ParameterValue *p)
Calculate the standard deviation value.
BandProperty * getProperty()
Returns the band property.
void setColorCompositionType(ColorCompositionType cct)
virtual std::unique_ptr< LayerSchema > getSchema() const =0
It returns the layer schema.
ParameterValue * getOpacity() const
ContrastEnhancement defines the 'stretching' of contrast for a channel of a false-color image or for ...
void setChannelSelection(ChannelSelection *c)
ColorCompositionType getColorCompositionType() const
virtual const te::gm::Envelope & getExtent() const
It returns the world extent showned by the MapDisplay.
The RasterSymbolizer describes how to render raster/matrix-coverage data (e.g., satellite photos...
void setOpacity(ParameterValue *p)
virtual const Band * getBand(std::size_t i) const =0
Returns the raster i-th band.
virtual Raster * getMultiResLevel(const unsigned int level) const =0
Returns the required level of a multi-resolution pyramid or NULL if that level does not exists...
Grid * getGrid()
It returns the raster grid.
int getType() const
It returns the property data type.
This class contains the parameters needed to apply dynamic contrast over a raster.
TEMAPEXPORT te::rst::Raster * GetRaster(AbstractLayer *layer)
It gets the raster referenced by the given data set layer.
ContrastEnhancementType getContrastEnhancementType() const
void setContrastEnhancementType(ContrastEnhancementType t)
SelectedChannel * getGreenChannel() const
ContrastEnhancement * getContrastEnhancement() const
void setOffset(ParameterValue *p)
void setContrastEnhancement(ContrastEnhancement *c)
void setSourceChannelName(const std::string &name)
virtual int getSRID() const
It returns the Spatial Reference System ID associated to the Layer.
int getType() const
It returns the data type of the elements in the band.
void setSRID(int srid)
Just sets the grid spatial reference system identifier.
std::string Convert2String(boost::int16_t value)
It converts a short integer value to a string.
void getValues(std::vector< double > &gain, std::vector< double > &offset1, std::vector< double > &offset2, std::vector< double > &min, std::vector< double > &max)
It get the contrast transformation values.
void setBlueChannel(SelectedChannel *c)
ParameterValue * getNoDataValue() const
SelectedChannel * getGrayChannel() const
void transform(int oldsrid, int newsrid)
It will transform the coordinates of the Envelope from the old SRS to the new one.
Calculate the mean value.
double getHeight() const
It returns the envelope height.
double getGammaValue() const
void setGreenChannel(SelectedChannel *c)