27 #include "../canvas/Canvas.h" 28 #include "../canvas/MapDisplay.h" 29 #include "../../../common/StringUtils.h" 30 #include "../../../geometry/Coord2D.h" 31 #include "../../../geometry/Envelope.h" 32 #include "../../../geometry/Point.h" 33 #include "../../../maptools/Utils.h" 34 #include "../../../raster/Grid.h" 35 #include "../../../rp/MixtureModel.h" 36 #include "../../../rp/MixtureModelLinearStrategy.h" 37 #include "../../../rp/MixtureModelPCAStrategy.h" 38 #include "../../../rp/Functions.h" 39 #include "../../widgets/tools/CoordTracking.h" 40 #include "../../widgets/tools/Pan.h" 41 #include "../../widgets/tools/ZoomWheel.h" 45 #include <ui_MixtureModelForm.h> 50 #include <QGridLayout> 54 #include <QMessageBox> 60 :
QObject(parent), m_mDisplay(parent)
70 if(event->type() == QEvent::Enter)
72 else if(event->type() == QEvent::Leave)
74 else if(event->type() == QEvent::KeyPress)
84 const std::map<std::string, std::string>& outpuRasterInfo,
QWidget* parent, Qt::WindowFlags f)
86 m_inputRasterPtr(
te::map::
GetRaster(inputLayerPtr.get())),
87 m_outpuRasterDSType(outpuRasterDSType),
88 m_outpuRasterInfo(outpuRasterInfo),
89 m_maxComponentsInserted(0)
91 m_uiPtr =
new Ui::MixtureModelForm;
96 QGridLayout* rasterGridLayout =
new QGridLayout(
m_uiPtr->m_rasterFrame);
101 std::list<te::map::AbstractLayerPtr> layerList;
102 layerList.push_back(inputLayerPtr);
126 QStringList sensorsDescriptions;
128 for(
unsigned int i = 0; i < bandNames.size(); i++)
129 sensorsDescriptions.append(bandNames[i].c_str());
132 QGridLayout *bandsListLayout =
new QGridLayout();
136 QCheckBox* bandCheckBox =
new QCheckBox(tr(bname.c_str()));
138 QComboBox* sensorDescriptionComboBox =
new QComboBox();
139 sensorDescriptionComboBox->addItems(sensorsDescriptions);
141 bandsListLayout->addWidget(bandCheckBox,
b, 0);
142 bandsListLayout->addWidget(sensorDescriptionComboBox,
b, 1);
144 m_uiPtr->m_bandsListGroupBox->setLayout(bandsListLayout);
147 QGridLayout *componentsListLayout =
new QGridLayout();
148 m_uiPtr->m_componentsListGroupBox->setLayout(componentsListLayout);
197 QMessageBox::critical(
this,
"", tr(
"Invalid input raster"));
206 algoInputParameters.
m_strategyName = (
m_uiPtr->m_mmTypeComboBox->currentText() ==
"Linear" ?
"linear" :
"pca");
209 unsigned selectedBands = 0;
210 std::vector<bool> selectedBandsVector;
211 for (
int i = 0; i < (
m_uiPtr->m_bandsListGroupBox->layout()->count() - 1); i += 2)
213 QCheckBox* bandCheckBox = (QCheckBox*)
m_uiPtr->m_bandsListGroupBox->layout()->itemAt(i)->widget();
215 if (bandCheckBox->isChecked())
217 selectedBandsVector.push_back(
true);
224 QComboBox *sensorComboBox = (QComboBox*)
m_uiPtr->m_bandsListGroupBox->layout()->itemAt(i + 1)->widget();
225 #if (QT_VERSION >= 0x050000) 226 algoInputParameters.
m_inputSensorBands.push_back(std::string(sensorComboBox->currentText().toUtf8().data()));
228 algoInputParameters.
m_inputSensorBands.push_back(std::string(sensorComboBox->currentText().toAscii()));
232 selectedBandsVector.push_back(
false);
236 std::map<std::string, std::vector<double> >::const_iterator cit =
m_components.begin();
237 std::vector<double> components;
242 for (
unsigned int i = 0; i < selectedBandsVector.size(); i++)
243 if (selectedBandsVector[i])
244 components.push_back(cit->second[i]);
246 algoInputParameters.
m_components[cit->first] = components;
252 if (
m_uiPtr->m_mmTypeComboBox->currentText() ==
"Linear")
273 if(!MixtureModelinstance.
initialize(algoInputParameters))
275 QMessageBox::critical(
this,
"", tr(
"MixtureModel initialization error"));
280 if(!MixtureModelinstance.
execute(algoOutputParameters))
282 QMessageBox::critical(
this,
"", tr(
"MixtureModel execution error"));
286 QMessageBox::information(
this,
"", tr(
"Mixture model decomposition ended sucessfully"));
306 std::vector<double> componentsVector;
315 componentsVector.push_back(value);
318 m_components[className->toUtf8().data()] = componentsVector;
331 std::string className = sender->statusTip().toUtf8().data();
348 mapDisplayExtent.
m_urx, mapDisplayExtent.
m_ury);
355 std::map<std::string, te::gm::Coord2D>::const_iterator cpit =
m_coordinates.begin();
360 auxCoord2D.
x, auxCoord2D.
y);
362 auxPoint.
setX(auxCoord2D.
x);
363 auxPoint.
setY(auxCoord2D.
y);
365 canvasInstance.draw(&auxPoint);
373 QGridLayout* componentsListLayout = (QGridLayout*)
m_uiPtr->m_componentsListGroupBox->layout();
376 for (
int i = 0; i < (componentsListLayout->count() / 5); i++)
378 std::string className = ((QLineEdit*) componentsListLayout->itemAtPosition(i, 1)->widget())->text().toUtf8().data();
379 std::string originalClassName = ((QLineEdit*) componentsListLayout->itemAtPosition(i, 1)->widget())->toolTip().toUtf8().data();
382 if (className != originalClassName)
395 while ((child = componentsListLayout->takeAt(0)) !=
nullptr)
397 delete child->widget();
406 std::map<std::string, std::vector<double> >::const_iterator cit =
m_components.begin();
407 unsigned int totalComponents = 0;
413 removeButton->setStatusTip(cit->first.c_str());
414 removeButton->setMaximumSize(20, 20);
417 componentsListLayout->addWidget(removeButton, totalComponents, 0);
419 QLineEdit* className =
new QLineEdit(cit->first.c_str());
420 className->setToolTip(cit->first.c_str());
421 componentsListLayout->addWidget(className, totalComponents, 1);
423 std::vector<double> components = cit->second;
424 for (
unsigned int i = 0; i < components.size(); i++)
426 QLineEdit* currentPixel =
new QLineEdit(QString::number(components[i]));
428 currentPixel->setMaximumSize(50, currentPixel->maximumHeight());
430 componentsListLayout->addWidget(currentPixel, totalComponents, i + 2);
te::gm::Envelope * getExtent()
Returns the geographic extension of the raster data.
void setColor(const std::string &hexColor)
It sets the color using a two hexadecimal RGB-encoded color.
Raster decomposition using mixture model.
std::string m_rType
Output raster data source type (as described in te::raster::RasterFactory ).
unsigned int getNumberOfColumns() const
Returns the raster number of columns.
std::vector< std::string > GetBandNames()
Returns a vector os with band's names.
double m_urx
Upper right corner x-coordinate.
#define TE_OPAQUE
For an RGBA color this is the value of the alpha-channel for totally opaque.
An utility struct for representing 2D coordinates.
void geoToGrid(const double &x, const double &y, double &col, double &row) const
Get the grid point associated to a spatial location.
std::map< std::string, std::string > m_rInfo
The necessary information to create the output raster (as described in te::raster::RasterFactory).
virtual void setLayerList(const std::list< te::map::AbstractLayerPtr > &layers)
It sets the layer list to be showed in the Map Display.
double m_llx
Lower left corner x-coordinate.
A point with x and y coordinate values.
An Envelope defines a 2D rectangular region.
A dialog used to execute mixture model decomposition.
unsigned int getNumberOfRows() const
Returns the raster number of rows.
virtual std::size_t getNumberOfBands() const =0
Returns the number of bands (dimension of cells attribute values) in the raster.
virtual const te::gm::Envelope & getExtent() const
It returns the world extent showned by the MapDisplay.
Grid * getGrid()
It returns the raster grid.
virtual void getValue(unsigned int c, unsigned int r, double &value, std::size_t b=0) const
Returns the attribute value of a band of a cell.
double m_lly
Lower left corner y-coordinate.
TEMAPEXPORT te::rst::Raster * GetRaster(AbstractLayer *layer)
It gets the raster referenced by the given data set layer.
MixtureModel output parameters.
int getSRID() const
Returns the raster spatial reference system identifier.
void setX(const double &x)
It sets the Point x-coordinate value.
double m_ury
Upper right corner y-coordinate.
bool execute(AlgorithmOutputParameters &outputParams)
Executes the mixing model using the parameters defined in inputParams and outputParams.
boost::intrusive_ptr< DataSetLayer > DataSetLayerPtr
A helper class for 32-bit RGBA (Red-Green-Blue-Alpha channel) color.
void gridToGeo(const double &col, const double &row, double &x, double &y) const
Get the spatial location of a grid point.
void setY(const double &y)
It sets the Point y-coordinate value.
std::string Convert2String(boost::int16_t value)
It converts a short integer value to a string.
bool m_createErrorRaster
A flag to indicate that output raster will include the error bands.
bool initialize(const AlgorithmInputParameters &inputParams)
Initializes model with paramters defined in inputParams.
#define TE_TRANSPARENT
For an RGBA color this is the value of the alpha-channel for totally transparent. ...