MixtureModelWizardPage.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib 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 Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file terralib/qt/widgets/rp/MixtureModelWizardPage.cpp
22 
23  \brief This file defines a class for a Mixture Model Wizard page.
24 */
25 
26 // TerraLib
27 #include "../../af/ApplicationController.h"
28 #include "../../../common/Exception.h"
29 #include "../../../common/STLUtils.h"
30 #include "../../../dataaccess/dataset/DataSet.h"
31 #include "../../../dataaccess/utils/Utils.h"
32 #include "../../../geometry/CurvePolygon.h"
33 #include "../../../geometry/Enums.h"
34 #include "../../../geometry/Point.h"
35 #include "../../../geometry/Polygon.h"
36 #include "../../../geometry/Utils.h"
37 #include "../../../maptools/MarkRendererManager.h"
38 #include "../../../maptools/Utils.h"
39 #include "../../../raster/PositionIterator.h"
40 #include "../../../raster/Raster.h"
41 #include "../../../rp/MixtureModel.h"
42 #include "../../../rp/MixtureModelLinearStrategy.h"
43 #include "../../../rp/MixtureModelPCAStrategy.h"
44 #include "../../../se/Fill.h"
45 #include "../../../se/Mark.h"
46 #include "../../../se/Stroke.h"
47 #include "../../../se/Utils.h"
48 #include "../canvas/Canvas.h"
49 #include "../canvas/MapDisplay.h"
50 #include "MixtureModelWizardPage.h"
51 #include "RpToolsWidget.h"
52 #include "RpToolsDialog.h"
53 #include "SensorManagerDialog.h"
54 
55 #include "../../widgets/tools/PointPicker.h"
56 
57 #include "ui_MixtureModelWizardPageForm.h"
58 
59 // Qt
60 #include <QAbstractItemModel>
61 #include <QPushButton>
62 #include <QColorDialog>
63 #include <QFileDialog>
64 #include <QGridLayout>
65 #include <QMessageBox>
66 
67 // Boost
68 #include <boost/lexical_cast.hpp>
69 #include <boost/property_tree/ptree.hpp>
70 #include <boost/property_tree/json_parser.hpp>
71 #include <boost/uuid/random_generator.hpp>
72 #include <boost/uuid/uuid_io.hpp>
73 
74 //STL
75 #include <fstream>
76 #include <memory>
77 
78 //QWT
79 #include <qwt_symbol.h>
80 #include <qwt_text.h>
81 
82 #define PATTERN_SIZE 12
83 
85  : QWizardPage(parent),
86  m_ui(new Ui::MixtureModelWizardPageForm),
87  m_countComponents(0),
88  m_layers(0),
89  m_mapDisplay(0)
90 {
91 //setup controls
92  m_ui->setupUi(this);
93 
94  m_ui->m_loadToolButton->setIcon(QIcon::fromTheme("document-open"));
95  m_ui->m_saveToolButton->setIcon(QIcon::fromTheme("document-save"));
96 
98 
99 //define mark
100  te::se::Stroke* stroke = te::se::CreateStroke("#000000", "2");
101  te::se::Fill* fill = te::se::CreateFill("#FF0000", "1.0");
102  m_mark = te::se::CreateMark("cross", stroke, fill);
103 
105 
106 //connects
107  QObject::connect(m_ui->m_typeComboBox, SIGNAL(currentIndexChanged(const QString &)), this, SLOT(onMixturetypeChanged()));
108 
109  m_ui->m_noDataValueLineEdit->setValidator(new QDoubleValidator(this));
110 
111 
112  QObject::connect(m_ui->m_mixturetabWidget, SIGNAL(currentChanged(int)), this, SLOT(onMixturetabChanged(int)));
113  QObject::connect(m_ui->m_componentTreeWidget, SIGNAL(itemClicked(QTreeWidgetItem*, int)), this, SLOT(onComponentItemClicked(QTreeWidgetItem*, int)));
114 
115  connect(m_ui->m_removeToolButton, SIGNAL(clicked()), this, SLOT(onRemoveToolButtonClicked()));
116  connect(m_ui->m_loadToolButton, SIGNAL(clicked()), this, SLOT(onLoadToolButtonClicked()));
117  connect(m_ui->m_saveToolButton, SIGNAL(clicked()), this, SLOT(onSaveToolButtonClicked()));
118 
119  connect(m_ui->m_componentLineEdit, SIGNAL(editingFinished()), this, SLOT(oncomponentChanged()));
120  connect(m_ui->m_colorToolButton, SIGNAL(clicked()), this, SLOT(oncolorToolButtonClicked()));
121  connect(m_ui->m_selectedRadioButton, SIGNAL(toggled(bool)), this, SLOT(onselectedEnabled(bool)));
122  connect(m_ui->m_allRadioButton, SIGNAL(toggled(bool)), this, SLOT(onallEnabled(bool)));
123 
124 //configure raster navigator
125  QGridLayout* layout = new QGridLayout(m_ui->m_navigatorWidget);
126  m_navigator.reset(new te::qt::widgets::RpToolsWidget(m_ui->m_navigatorWidget));
127  layout->addWidget(m_navigator.get(), 0, 0);
128  layout->setContentsMargins(0, 0, 0, 0);
129  layout->setSizeConstraint(QLayout::SetMinimumSize);
130 
131 //connects
132  connect(m_navigator.get(), SIGNAL(pointPicked(double, double)), this, SLOT(onPointPicked(double, double)));
133  connect(m_navigator.get(), SIGNAL(geomAquired(te::gm::Polygon*)), this, SLOT(onGeomAquired(te::gm::Polygon*)));
134  connect(m_navigator.get(), SIGNAL(envelopeAcquired(te::gm::Envelope)), this, SLOT(onEnvelopeAcquired(te::gm::Envelope)));
135 
136  //configure page
137  this->setTitle(tr("Mixture Model"));
138  this->setSubTitle(tr("Select the type of mixture model and set their specific parameters."));
139 
140  m_ui->m_removeToolButton->setIcon(QIcon::fromTheme("edit-deletetool"));
141 
143  te::qt::widgets::ChartDisplay* m_chartDisplay;
144  QwtPlotCurve *m_graphic;
145 
146  //Adjusting the chart Display's style.
147  m_chartStyle->setTitle(tr("Spectral Curves"));
148  m_chartStyle->setAxisX(tr("Wave Lenght"));
149  m_chartStyle->setAxisY(tr("Answer"));
150  m_chartStyle->setGridChecked(true);
151 
152  //Creating and adjusting the chart Display
153  m_chartDisplay = new te::qt::widgets::ChartDisplay(m_ui->m_graphicFrame, "", m_chartStyle);
154 
155  m_graphic = new QwtPlotCurve();
156  m_graphic->setOrientation(Qt::Horizontal);
157  m_graphic->attach(m_chartDisplay);
158  m_displayWidget = new te::qt::widgets::ChartDisplayWidget(m_graphic, m_graphic->rtti(), m_chartDisplay, m_ui->m_graphicFrame);
159 
160  m_layoutg = new QGridLayout(m_ui->m_graphicFrame);
161  m_layoutg->addWidget(m_displayWidget);
162  m_chartDisplay->adjustDisplay();
163 
164  QPixmap px(16, 16);
165  px.fill(m_color);
166  m_ui->m_colorToolButton->setIcon(px);
167 
169  m_sensorManagerDialog->setWindowTitle(tr("Choose the Spectral Sensor"));
170 }
171 
173 {
174  clearComponents();
175 
177 
178  delete m_mark;
179  delete m_sensorManagerDialog;
180  }
181 
183 {
184  std::map<std::string, MixModelComponent>::iterator it = m_components.begin();
185  while (it != m_components.end())
186  {
187  delete (*it).second.m_geomGeo;
188  delete (*it).second.m_geomGrid;
189  (*it).second.m_values.clear();
190  m_components.erase(it);
191  it = m_components.begin();
192  }
193 }
194 
196 {
197  if(m_ui->m_componentTreeWidget->selectedItems().size() == 0)
198  return false;
199 
200  int nBands = m_ui->m_bandTableWidget->rowCount();
201 
202  bool isChecked = false;
203 
204  std::size_t count = 0;
205  for(int i = 0; i < nBands; ++i)
206  {
207  QCheckBox* checkBox = (QCheckBox*)m_ui->m_bandTableWidget->cellWidget(i, 0);
208 
209  if(checkBox->isChecked())
210  {
211  isChecked = true;
212  ++count;
213  }
214  }
215 
216  if(!isChecked)
217  return false;
218 
219  if(count != m_components.size())
220  return false;
221 
222  return true;
223 }
224 
225 void te::qt::widgets::MixtureModelWizardPage::set(std::list<te::map::AbstractLayerPtr> layers)
226 {
227  m_layers = layers;
228 
229  while (m_ui->m_bandTableWidget->rowCount())
230  m_ui->m_bandTableWidget->removeRow(0);
231 
232  listBands();
233 }
234 
236 {
237  m_mapDisplay = mapDisplay;
238  m_navigator->setMapDisplay(mapDisplay);
239 }
240 
242 {
243  //configure tools
244  m_navigator->setActionGroup(actionGroup);
245  m_navigator->enablePickerAction();
246  m_navigator->enableGeomAction();
247  m_navigator->enableBoxAction();
248 }
249 
250 std::list<te::map::AbstractLayerPtr> te::qt::widgets::MixtureModelWizardPage::get()
251 {
252  return m_layers;
253 }
254 
256 {
257  int idx = m_ui->m_typeComboBox->currentIndex();
258  int type = m_ui->m_typeComboBox->itemData(idx).toInt();
259 
261 
262  if(type == MIXMODEL_LINEAR)
263  {
264  algoInputParams.m_strategyName = "linear";
266  algoInputParams.setMixtureModelStrategyParams(specificParameters);
267  }
268  else if(type == MIXMODEL_PCA)
269  {
270  algoInputParams.m_strategyName = "pca";
272  algoInputParams.setMixtureModelStrategyParams(specificParameters);
273  }
274 
275 // insert selected bands
276  unsigned selectedBands = 0;
277  std::vector<bool> selectedBandsVector;
278 
279  for (int i = 0; i < m_ui->m_bandTableWidget->rowCount(); ++i)
280  {
281  QCheckBox* bandCheckBox = (QCheckBox*) m_ui->m_bandTableWidget->cellWidget(i, 0);
282 
283  if (bandCheckBox->isChecked())
284  {
285  selectedBandsVector.push_back(true);
286  selectedBands++;
287 
288  algoInputParams.m_inputRasterBands.push_back(i);
289 
290  QComboBox *sensorComboBox = (QComboBox*) m_ui->m_bandTableWidget->cellWidget(i, 1);
291  algoInputParams.m_inputSensorBands.push_back(std::string(sensorComboBox->currentText().toUtf8().data()));
292  }
293  else
294  selectedBandsVector.push_back(false);
295  }
296 
297 // insert mixture components
298  std::map<std::string, MixModelComponent>::iterator it = m_components.begin();
299  std::vector<double> components;
300 
301  while(it != m_components.end())
302  {
303  components.clear();
304 
305  for (unsigned int i = 0; i < selectedBandsVector.size(); i++)
306  if (selectedBandsVector[i])
307  components.push_back(it->second.m_values[i]);
308 
309  algoInputParams.m_components[it->second.m_name] = components;
310 
311  ++it;
312  }
313 
314  if (m_ui->m_noDataValueCheckBox->isChecked() && !m_ui->m_noDataValueLineEdit->text().isEmpty())
315  {
316  algoInputParams.m_inputRasterNoDataValues.push_back(m_ui->m_noDataValueLineEdit->text().toDouble());
317  }
318 
319 
320  return algoInputParams;
321 }
322 
324 {
325  return m_ui->m_decomposeCheckBox->isChecked();
326 }
327 
329 {
331 
332  algoOutputParams.m_createErrorRaster = m_ui->m_createErrorRasterCheckBox->isChecked();
333  algoOutputParams.m_normalizeOutput = m_ui->m_normalizeOutputCheckBox->isChecked();
334  algoOutputParams.m_normalMin = 0;
335  algoOutputParams.m_normalMax = 255;
336 
337  return algoOutputParams;
338 }
339 
341 {
342  boost::property_tree::ptree pt;
343  std::map<std::string, MixModelComponent >::iterator it = m_components.begin();
344  boost::property_tree::ptree children;
345  boost::property_tree::ptree bands;
346  boost::property_tree::ptree srid;
347 
348  for (int b = 0; b < m_ui->m_bandTableWidget->rowCount(); b++)
349  {
350  QCheckBox* bandCheckBox = (QCheckBox*)m_ui->m_bandTableWidget->cellWidget(b, 0);
351  QComboBox *sensorComboBox = (QComboBox*)m_ui->m_bandTableWidget->cellWidget(b, 1);
352 
353  boost::property_tree::ptree band;
354 
355  band.put("band", boost::lexical_cast<std::string>(b));
356  band.put("use", bandCheckBox->isChecked() ? "true" : "false");
357  band.put("sensor", sensorComboBox->currentText().toUtf8().data());
358 
359  bands.push_back(std::make_pair("Band", band));
360  }
361 
362  pt.add_child("Band_Sensors", bands);
363 
364  std::unique_ptr<te::rst::Raster> inputRst(te::map::GetRaster(m_layers.begin()->get()));
365 
366  pt.put("SRID", inputRst->getSRID());
367 
368  while(it != m_components.end())
369  {
370  boost::property_tree::ptree child;
371 
372  child.put("name", it->second.m_name);
373 
374  boost::property_tree::ptree coordGrid;
375  boost::property_tree::ptree coordGeo;
376  std::string type = it->second.m_geomGeo->getGeometryType();
377  if (type == "Point")
378  {
379  te::gm::Point *pgrid = dynamic_cast<te::gm::Point*>(it->second.m_geomGrid);
380  coordGrid.put("xGrid", pgrid->getX());
381  coordGrid.put("yGrid", pgrid->getY());
382  child.push_back(std::make_pair("coordGrid", coordGrid));
383 
384  te::gm::Point *pgeo = dynamic_cast<te::gm::Point*>(it->second.m_geomGeo);
385  coordGeo.put("xGeo", pgeo->getX());
386  coordGeo.put("yGeo", pgeo->getY());
387  child.push_back(std::make_pair("coordGeo", coordGeo));
388  }
389  else
390  {
391  te::gm::CurvePolygon *pgrid = dynamic_cast<te::gm::CurvePolygon*>(it->second.m_geomGrid);
392  te::gm::LinearRing* lgrid = static_cast<te::gm::LinearRing*>(pgrid->getExteriorRing());
393  std::size_t npts = lgrid->getNPoints();
394  boost::property_tree::ptree ptgrid, ptgeo;
395 
396  for (size_t pt = 0; pt < npts; pt++)
397  {
398  boost::property_tree::ptree val;
399  val.put("xGrid", lgrid->getPointN(pt)->getX());
400  val.put("yGrid", lgrid->getPointN(pt)->getY());
401  ptgrid.push_back(std::make_pair("", val));
402  }
403  child.add_child("geomGrid", ptgrid);
404 
405  te::gm::CurvePolygon *pgeo = dynamic_cast<te::gm::CurvePolygon*>(it->second.m_geomGeo);
406  te::gm::LinearRing* lgeo = static_cast<te::gm::LinearRing*>(pgeo->getExteriorRing());
407 
408  for (size_t pt = 0; pt < npts; pt++)
409  {
410  boost::property_tree::ptree val;
411  val.put("xGeo", lgeo->getPointN(pt)->getX());
412  val.put("yGeo", lgeo->getPointN(pt)->getY());
413  ptgeo.push_back(std::make_pair("", val));
414  }
415  child.add_child("geomCoord", ptgeo);
416  }
417 
418  child.put("Color", it->second.m_color.getColor());
419  children.push_back(std::make_pair("Component", child));
420 
421  ++it;
422  }
423 
424  pt.add_child("MixModel_Components", children);
425 
427  if (algoInputParams.m_inputRasterBands.size() != algoInputParams.m_components.size())
428  return;
429 
430  algoInputParams.m_inputRasterPtr = inputRst.get();
431 
432  te::rp::MixtureModel algorithmInstance;
433  if (algorithmInstance.initialize(algoInputParams))
434  {
435 
436  if (algorithmInstance.generateTransformMatrix(m_transfMatrix))
437  {
438  boost::property_tree::ptree matrix_node;
439  for (size_t j = 0; j < m_transfMatrix.size1(); j++) // nrow
440  {
441  boost::property_tree::ptree row;
442  for (size_t i = 0; i < m_transfMatrix.size2(); i++) // ncol
443  {
444  boost::property_tree::ptree cell;
445  cell.put_value((m_transfMatrix)(j, i));
446  row.push_back(std::make_pair("", cell));
447  }
448  matrix_node.push_back(std::make_pair("", row));
449  }
450 
451  boost::property_tree::ptree child;
452  child.put("Method", algoInputParams.m_strategyName);
453  pt.add_child("Mixture Model", child);
454  pt.add_child("Transform Matrix", matrix_node);
455  }
456  }
457 
458  boost::property_tree::json_parser::write_json(m_json_out, pt);
459 }
460 
462 {
463  clearComponents();
464 
465  try
466  {
467  boost::property_tree::ptree pt;
468  boost::property_tree::json_parser::read_json(fileName, pt);
469 
470  int nBands = m_ui->m_bandTableWidget->rowCount();
471 
472  try
473  {
474  for(boost::property_tree::ptree::value_type &v: pt.get_child("Band_Sensors"))
475  {
476  std::string band = v.second.get<std::string>("band");
477  std::string used = v.second.get<std::string>("use");
478  std::string sensor = v.second.get<std::string>("sensor");
479 
480  int row = std::atoi(band.c_str());
481 
482  if (row < nBands)
483  {
484  QCheckBox* bandCheckBox = (QCheckBox*)m_ui->m_bandTableWidget->cellWidget(row, 0);
485  QComboBox *sensorComboBox = (QComboBox*)m_ui->m_bandTableWidget->cellWidget(row, 1);
486 
487  bandCheckBox->setChecked(used.compare("true") == 0);
488  int index = sensorComboBox->findText(sensor.c_str());
489  if (index != -1)
490  sensorComboBox->setCurrentIndex(index);
491  }
492  }
493  }
494  catch (const std::exception&)
495  {
496  std::cout << std::endl << "Old mixture file" << std::endl;
497  }
498 
499  int srid = pt.get("SRID", 0);
500  if (srid == 0)
501  {
502  std::unique_ptr<te::rst::Raster> inputRst(te::map::GetRaster(m_layers.begin()->get()));
503  srid = inputRst->getSRID();
504  }
505 
506  for(boost::property_tree::ptree::value_type &v: pt.get_child("MixModel_Components"))
507  {
508  std::string name = v.second.get<std::string>("name");
509  std::vector<te::gm::Point*> pointsVecg, pointsVecc;
510  bool ispoint;
511 
512  m_ui->m_componentLineEdit->setText(name.c_str());
513 
514  if (v.second.find("geomCoord") != v.second.not_found())
515  {
516  for(boost::property_tree::ptree::value_type &c: v.second.get_child("geomCoord"))
517  {
518  double x = c.second.get<double>("xGeo");
519  double y = c.second.get<double>("yGeo");
520  pointsVecc.push_back(new te::gm::Point(x, y));
521  }
522  te::gm::LinearRing *l = new te::gm::LinearRing(pointsVecg.size(), te::gm::LineStringType);
523  for (std::size_t i = 0; i < pointsVecc.size(); i++)
524  l->setPointN(i, *pointsVecc[i]);
526  pol->setRingN(0, l);
527  m_geom = dynamic_cast<te::gm::Geometry*>(pol);
528  ispoint = false;
529  }
530 
531  if (v.second.find("coordGeo") != v.second.not_found())
532  {
533  double xGeo = v.second.get<double>("coordGeo.xGeo");
534  double yGeo = v.second.get<double>("coordGeo.yGeo");
535  m_geom = new te::gm::Point(xGeo, yGeo, srid);
536  ispoint = true;
537  }
538 
539  //Test point
540  if (m_geom)
541  {
542  te::gm::Envelope box_cmp(*m_geom->getMBR());
543  std::list<te::map::AbstractLayerPtr>::iterator it = m_layers.begin();
544  while (it != m_layers.end())
545  {
546  te::gm::Envelope box = it->get()->getExtent();
547  if (!box.contains(box_cmp))
548  {
549  throw te::common::Exception(tr("Invalid Componet Coordinate.").toUtf8().data());
550  }
551  ++it;
552  }
553  }
554 
555  std::string color = v.second.get<std::string>("Color");
556  te::color::RGBAColor c_color(color);
557  m_color = QColor(c_color.getRed(), c_color.getGreen(), c_color.getBlue(), c_color.getAlpha());
558 
559  if (ispoint)
560  {
562  }
563  else
564  {
566  }
567  }
568 
569  if (m_components.size())
570  m_ui->m_componentLineEdit->setText(m_components.begin()->first.c_str());
571 
573 
574  int idx = m_ui->m_typeComboBox->currentIndex();
575  m_type = m_ui->m_typeComboBox->itemData(idx).toInt();
576 
577  try{
578  for(boost::property_tree::ptree::value_type &v: pt.get_child("Mixture Model"))
579  {
580  std::string method = v.second.data();
581  if ((method == "linear" && m_type == MIXMODEL_LINEAR) ||
582  (method == "pca" && m_type == MIXMODEL_PCA))
583  {
584  size_t matrix_size = m_components.size();
585  if (m_type == MIXMODEL_LINEAR)
586  matrix_size++;
587  boost::numeric::ublas::matrix<double> matrix = boost::numeric::ublas::matrix<double>(matrix_size, matrix_size);
588  int x = 0;
589  for(boost::property_tree::ptree::value_type &v: pt.get_child("Transform Matrix"))
590  {
591  int y = 0;
592  for (boost::property_tree::ptree::value_type &cell : v.second)
593  {
594  matrix(x,y) = cell.second.get_value<double>();
595  y++;
596  }
597  x++;
598 
599  }
600  m_transfMatrix = matrix;
601  }
602  }
603  }
604  catch (const std::exception&)
605  {
606  std::cout << std::endl << "Old mixture file" << std::endl;
607  }
608 
609  }
610  catch(boost::property_tree::json_parser::json_parser_error &je)
611  {
612  QString errmsg = tr("Error parsing: ") + je.filename().c_str() + ": " + je.message().c_str();
613  QMessageBox::warning(this, tr("Warning"), errmsg);
614  return;
615  }
616  catch (te::common::Exception const& e)
617  {
618  QString errmsg = e.what();
619  QMessageBox::warning(this, tr("Warning"), errmsg);
620  m_ui->m_componentTreeWidget->clear();
621  }
622 
623 }
624 
626 {
627  m_json_out = QFileDialog::getSaveFileName(this, tr("Save MixModel Components"), "", "JSON File (*.json)").toUtf8().data();
628 
629  if(!m_json_out.empty())
631 }
632 
634 {
635  std::string fileName = QFileDialog::getOpenFileName(this, tr("Load MixModel Components"), "", "JSON File (*.json)").toUtf8().data();
636 
637  if(!fileName.empty())
638  loadMixtureModelComponents(fileName);
639 }
640 
642 {
643  if(m_components.empty() == false)
644  drawMarks();
645 }
646 
648 {
649  m_geom = new te::gm::Point(x, y, m_mapDisplay->getSRID());
650 
652 }
653 
654 
656 {
657  assert(m_layers.size());
658  assert(m_geom);
659  te::gm::Point *pt = dynamic_cast<te::gm::Point*>(m_geom);
660  double x = pt->getX();
661  double y = pt->getY();
662 
663  QString comp(m_ui->m_componentLineEdit->text());
664 
665  if (comp.isEmpty())
666  {
667  QMessageBox::warning(this, tr("Mixture Model"), tr("First edit component name"));
668  return;
669  }
670 
671  //get input raster
672  std::list<te::map::AbstractLayerPtr>::iterator it = m_layers.begin();
673  while (it != m_layers.end())
674  {
675  std::unique_ptr<te::da::DataSet> ds =it->get()->getData();
676  if(ds.get())
677  {
678  std::size_t rpos = te::da::GetFirstPropertyPos(ds.get(), te::dt::RASTER_TYPE);
679  std::unique_ptr<te::rst::Raster> inputRst = ds->getRaster(rpos);
680 
681  int srid = inputRst->getSRID();
682 
683  if(inputRst.get())
684  {
685  if (m_mapDisplay->getSRID() != srid)
686  {
687  te::gm::Point pt(x, y, m_mapDisplay->getSRID());
688  pt.transform(srid);
689  x = pt.getX();
690  y = pt.getY();
691  }
692 
693  te::gm::Coord2D pixelLocation = inputRst->getGrid()->geoToGrid(x, y);
694 
695  int currentColumn = te::rst::Round(pixelLocation.x);
696  int currentRow = te::rst::Round(pixelLocation.y);
697 
698  if (currentColumn < 0 || currentColumn >= (int) inputRst->getNumberOfColumns())
699  return;
700  if (currentRow < 0 || currentRow >= (int) inputRst->getNumberOfRows())
701  return;
702 
703  //component name
704  QString className = comp;
705 
706  //component values
707  std::vector<double> componentsVector;
708 
709  double value;
710  for(unsigned b = 0 ; b < inputRst->getNumberOfBands(); b++)
711  {
712  inputRst->getValue(currentColumn, currentRow, value, b);
713  QString bName(it->get()->getTitle().c_str());
714  bName.append(tr(" Band "));
715  bName.append(QString::number(b));
716  componentsVector.push_back(value);
717  }
718 
719  //component coordinate
720  MixModelComponent mmc;
721  mmc.m_name = className.toUtf8().data();
722  mmc.m_values = componentsVector;
723  mmc.m_geomGrid = new te::gm::Point(currentColumn, currentRow);
724  mmc.m_geomGeo = new te::gm::Point(x, y, srid);
725 
726  te::color::RGBAColor newcolor(m_color.red(), m_color.green(), m_color.blue(), 255);
727  mmc.m_color.setColor(newcolor.getColor());
728 
729  std::map<std::string, MixModelComponent > ::iterator it = m_components.find(className.toUtf8().data());
730 
731  if (it != m_components.end())
732  it->second = mmc;
733  else
734  m_components.insert(std::map<std::string, MixModelComponent >::value_type(className.toUtf8().data(), mmc));
735 
737 
738  } //if (inputRst.get())
739  } //if (ds.get())
740  ++it;
741  }
742 }
743 
745 {
746  assert(m_layers.size());
747 
748  std::list<te::map::AbstractLayerPtr>::iterator it = m_layers.begin();
749  if (m_mapDisplay->getSRID() != it->get()->getSRID())
750  env.transform(m_mapDisplay->getSRID(), it->get()->getSRID());
751 
752  if (!env.isValid())
753  return;
754 
755  m_geom = te::gm::GetGeomFromEnvelope(&env, it->get()->getSRID());
756 
758 }
759 
761 {
762  assert(m_layers.size());
763 
764  std::list<te::map::AbstractLayerPtr>::iterator it = m_layers.begin();
765  if (m_mapDisplay->getSRID() != it->get()->getSRID())
766  poly->transform(it->get()->getSRID());
767 
768  if (!poly->isValid())
769  return;
770 
771  m_geom = poly;
773 }
774 
776 {
777  if(m_ui->m_componentLineEdit->text().isEmpty())
778  return;
779 
780  std::string comp = m_ui->m_componentLineEdit->text().toUtf8().data();
781  std::map<std::string, MixModelComponent>::iterator it = m_components.find(comp);
782  if (it == m_components.end())
783  return;
784 
785  QTreeWidgetItemIterator itqt(m_ui->m_componentTreeWidget);
786  while (*itqt) {
787  if (comp.compare((*itqt)->text(0).toUtf8().data()) == 0)
788  {
789  QTreeWidgetItem* item = *itqt;
790  int x = m_ui->m_componentTreeWidget->indexOfTopLevelItem(item);
791  if (x >= 0 && x < m_ui->m_componentTreeWidget->topLevelItemCount())
792  {
793  item = m_ui->m_componentTreeWidget->takeTopLevelItem(x);
794  if (item)delete item;
795  }
796  delete (*it).second.m_geomGeo;
797  delete (*it).second.m_geomGrid;
798  (*it).second.m_values.clear();
799  m_components.erase(comp);
800  break;
801  }
802  ++itqt;
803  }
804 
805  //Set first as current
806  if (m_components.size())
807  m_ui->m_componentLineEdit->setText(m_components.begin()->first.c_str());
808 
810 }
811 
813 {
814  drawMarks();
815 }
816 
818 {
820 
821  canvasInstance.clear();
822 
823  m_mapDisplay->repaint();
824 }
825 
827 {
828  m_ui->m_typeComboBox->clear();
829 
830  m_ui->m_typeComboBox->addItem(tr("Linear"), MIXMODEL_LINEAR);
831  m_ui->m_typeComboBox->addItem(tr("PCA - Principal Component Analysis"), MIXMODEL_PCA);
832 }
833 
835 {
836  assert(m_layers.size());
837 
838  m_maxValue.clear();
839 
841 
842  std::map<std::string, te::rp::SpectralSensorParams > ::iterator it_sen;
843  QStringList sensorNames;
844 
845  for(it_sen = m_SensorParams.begin(); it_sen != m_SensorParams.end(); it_sen++)
846  sensorNames.append((it_sen->first).c_str());
847 
848  //get input raster
849  std::list<te::map::AbstractLayerPtr>::iterator it = m_layers.begin();
850  int newrow = 0;
851 
852  while (it != m_layers.end())
853  {
854  std::unique_ptr<te::da::DataSet> ds = it->get()->getData();
855  if(ds.get())
856  {
857  std::size_t rpos = te::da::GetFirstPropertyPos(ds.get(), te::dt::RASTER_TYPE);
858  std::unique_ptr<te::rst::Raster> inputRst = ds->getRaster(rpos);
859 
860  if(inputRst.get())
861  {
862  m_ui->m_bandTableWidget->setRowCount(newrow);
863  connect(&m_ButtonSignalMapper, SIGNAL(mapped(int)), this, SLOT(onSensorToolButtonClicked(int)));
864 
865  // initializing the list of bands
866  for(unsigned b = 0 ; b < inputRst->getNumberOfBands(); b++)
867  {
868  m_ui->m_bandTableWidget->insertRow(newrow);
869 
870  QString bName(it->get()->getTitle().c_str());
871  bName.append(tr(" Band "));
872 
873  bName.append(QString::number(b));
874 
875  QCheckBox* bandCheckBox = new QCheckBox(bName, this);
876 
877  connect(bandCheckBox, SIGNAL(stateChanged(int)), this, SIGNAL(completeChanged()));
878 
879  QComboBox* sensorDescriptionComboBox = new QComboBox(this);
880  sensorDescriptionComboBox->addItems(sensorNames);
881  QToolButton *sensorFindButton = new QToolButton(this);
882  sensorFindButton->setFixedSize(20, 20);
883  sensorFindButton->setText("...");
884 
885  m_ui->m_bandTableWidget->setCellWidget(newrow, 0, bandCheckBox);
886  m_ui->m_bandTableWidget->setCellWidget(newrow, 1, sensorDescriptionComboBox);
887  m_ui->m_bandTableWidget->setCellWidget(newrow, 2, sensorFindButton);
888 #if (QT_VERSION >= 0x050000)
889  m_ui->m_bandTableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
890 #else
891  m_ui->m_bandTableWidget->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
892 #endif
893 
894  m_ButtonSignalMapper.setMapping(sensorFindButton, newrow);
895  connect(sensorFindButton, SIGNAL(clicked()), &m_ButtonSignalMapper, SLOT(map()));
896  connect(bandCheckBox, SIGNAL(clicked()), this, SLOT(onBandItemClicked()));
897  connect(sensorDescriptionComboBox, SIGNAL(currentIndexChanged(const QString &)), this, SLOT(onBandItemClicked()));
898  newrow++;
899 
900  bandCheckBox->setChecked(true);
901  double max = inputRst->getBand(b)->getMaxValue(true).real();
902  m_maxValue.push_back(max);
903  } // initializing the list of bands - end
904  } //if(inputRst.get())
905  } // if(ds.get())
906  ++it;
907  } //while (it != m_layers.end())
908 
909 
910 }
911 
913 {
914  m_mapDisplay->getDraftPixmap()->fill(Qt::transparent);
915 
916  const te::gm::Envelope& mapExt = m_mapDisplay->getExtent();
917 
919  canvasInstance.setWindow(mapExt.m_llx, mapExt.m_lly, mapExt.m_urx, mapExt.m_ury);
920 
921  std::map<std::string, MixModelComponent>::iterator it = m_components.begin();
922 
923  try
924  {
925  while (it != m_components.end())
926  {
927  std::string type = it->second.m_geomGeo->getGeometryType();
928  if (type == "Point")
929  {
930  canvasInstance.setPointPattern(m_rgbaMark, PATTERN_SIZE, PATTERN_SIZE);
931  te::gm::Point *cGeo = dynamic_cast<te::gm::Point*>(it->second.m_geomGeo);
932 
933  te::gm::Point point(*cGeo);
934  if (m_mapDisplay->getSRID() != cGeo->getSRID())
935  point.transform(m_mapDisplay->getSRID());
936 
937  canvasInstance.setPointColor(it->second.m_color);
938 
939  if (it->first == m_comp)
940  {
941  canvasInstance.setPointWidth(30);
942  }
943 
944  canvasInstance.draw(&point);
945  }
946  else
947  {
948  te::gm::Polygon *cGeo = dynamic_cast<te::gm::Polygon*>(it->second.m_geomGeo);
949  te::gm::Polygon pol(*cGeo);
950 
951  if (m_mapDisplay->getSRID() != it->second.m_geomGeo->getSRID())
953 
954  te::color::RGBAColor black(0, 0, 0, 255);
955  te::color::RGBAColor red(255, 0, 0, 255);
956  short opacity = 127;
957  if (it->first == m_comp)
958  {
959  opacity = 255;
960  canvasInstance.setPolygonContourColor(red);
961  }
962  else
963  canvasInstance.setPolygonContourColor(black);
964 
965  te::color::RGBAColor polcolor(it->second.m_color.getRed(), it->second.m_color.getGreen(), it->second.m_color.getBlue(), opacity);
966  canvasInstance.setPolygonFillColor(polcolor);
967  canvasInstance.setPolygonContourWidth(1);
968 
969  canvasInstance.draw(&pol);
970  }
971 
972  ++it;
973  }
974  }
975  catch (const std::exception&)
976  {
977  std::cout << std::endl << "Points out" << std::endl;
978  }
979 
980  m_mapDisplay->repaint();
981 }
982 
984 {
985  m_ui->m_componentTreeWidget->clear();
986 
987  std::map<std::string, MixModelComponent>::iterator it;
988 
989  unsigned int nBands = m_ui->m_bandTableWidget->rowCount();
990 
991  for (it = m_components.begin(); it != m_components.end(); ++it)
992  {
993  QBrush brush(QColor(it->second.m_color.getRed(), it->second.m_color.getGreen(), it->second.m_color.getBlue(), 255));
994  QTreeWidgetItem* compItem = new QTreeWidgetItem;
995  compItem->setText(0, it->first.c_str());
996  compItem->setForeground(0, brush);
997  m_ui->m_componentTreeWidget->addTopLevelItem(compItem);
998  m_ui->m_componentTreeWidget->setCurrentItem(compItem);
999 
1000  for (unsigned int i = 0; i < nBands; ++i)
1001  {
1002  QCheckBox* checkBox = (QCheckBox*)m_ui->m_bandTableWidget->cellWidget(i, 0);
1003  if (checkBox && checkBox->isChecked())
1004  {
1005  QComboBox* comboBox = (QComboBox*)m_ui->m_bandTableWidget->cellWidget(i, 1);
1006  QTreeWidgetItem* item = new QTreeWidgetItem(compItem);
1007  item->setText(0, comboBox->currentText());
1008  if (i < it->second.m_values.size())
1009  item->setText(1, QString::number(it->second.m_values[i] / m_maxValue[i]));
1010  else
1011  item->setText(1, QString::number(0.0));
1012  item->setForeground(0, brush);
1013  item->setForeground(1, brush);
1014  m_ui->m_componentTreeWidget->setCurrentItem(item);
1015  m_ui->m_componentTreeWidget->resizeColumnToContents(0);
1016  m_ui->m_componentTreeWidget->resizeColumnToContents(1);
1017  }
1018  }
1019  }
1020 
1021  m_transfMatrix.resize(0,0,false);
1022 
1023  drawMarks();
1024 
1026 
1027  emit completeChanged();
1028 }
1029 
1031 {
1032  assert(item);
1033 
1034  m_comp = "";
1035 
1036  if (!item->childCount())
1037  {
1038  QTreeWidgetItem* parent = item->parent();
1039  if (!parent)
1040  return;
1041  item = parent;
1042  }
1043 
1044  m_ui->m_componentLineEdit->setText(item->text(0));
1045 
1046  std::map<std::string, MixModelComponent>::iterator it = m_components.find(item->text(0).toStdString());
1047  if (it != m_components.end())
1048  {
1049  m_color = QColor(it->second.m_color.getRed(), it->second.m_color.getGreen(), it->second.m_color.getBlue(), it->second.m_color.getAlpha());
1050  QPixmap px(16, 16);
1051  px.fill(m_color);
1052  m_ui->m_colorToolButton->setIcon(px);
1053  m_comp = it->first;
1054  }
1055 
1056  drawMarks();
1057 
1059 }
1060 
1062 {
1064  te::qt::widgets::ChartDisplay* m_chartDisplay;
1065  if (m_displayWidget)
1066  {
1067  m_layoutg->removeWidget(m_displayWidget);
1068  delete m_displayWidget;
1069  m_displayWidget = 0;
1070  }
1071 
1072  if (m_ui->m_selectedRadioButton->isChecked())
1073  {
1074  m_chartStyle->setTitle(m_ui->m_componentLineEdit->text());
1075  }
1076  else
1077  m_chartStyle->setTitle(tr("Spectral Curves"));
1078 
1079  m_chartStyle->setAxisX(tr("Wave Lenght"));
1080  m_chartStyle->setAxisY(tr("Answer"));
1081  m_chartStyle->setGridChecked(true);
1082 
1083  //Creating and adjusting the chart Display
1084  m_chartDisplay = new te::qt::widgets::ChartDisplay(m_ui->m_graphicFrame, "", m_chartStyle);
1085  m_chartDisplay->adjustDisplay();
1086 
1087  bool first = true;
1088  for (std::map<std::string, MixModelComponent > ::iterator it = m_components.begin(); it != m_components.end(); it++)
1089  {
1090  if (m_ui->m_selectedRadioButton->isChecked())
1091  {
1092  if (it->first.compare(m_ui->m_componentLineEdit->text().toStdString()) != 0)
1093  continue;
1094  }
1095  QwtPlotCurve *graphic = new QwtPlotCurve();
1096  graphic->setOrientation(Qt::Horizontal);
1097  QVector<QPointF> values;
1098  double wave = 0;
1099  for (unsigned int ii = 0; ii < it->second.m_values.size(); ++ii)
1100  {
1101  QCheckBox* bandCheckBox = (QCheckBox*)m_ui->m_bandTableWidget->cellWidget(ii, 0);
1102  if (bandCheckBox->isChecked())
1103  {
1104  QComboBox* sensor = (QComboBox*)m_ui->m_bandTableWidget->cellWidget(ii, 1);
1105  wave = GetMediumWavelength(sensor->currentText().toStdString());
1106  bool insert = false;
1107  for (int iv = 0; iv < values.size(); ++iv)
1108  {
1109  if (values[iv].x() > wave)
1110  {
1111  values.insert(iv, QPointF(wave, it->second.m_values[ii]/m_maxValue[ii]));
1112  insert = true;
1113  break;
1114  }
1115  }
1116  if (!insert)
1117  values.push_back(QPointF(wave, it->second.m_values[ii]/m_maxValue[ii]));
1118  }
1119  }
1120 
1121  graphic->setSamples(values);
1122 
1123  QPen CurvePen;
1124  CurvePen.setColor(QColor(it->second.m_color.getRed(), it->second.m_color.getGreen(), it->second.m_color.getBlue()));
1125  CurvePen.setStyle(Qt::SolidLine);
1126  CurvePen.setWidth(0);
1127  graphic->setPen(CurvePen);
1128 
1129  graphic->attach(m_chartDisplay);
1130 
1131  if (first)
1132  {
1133  m_displayWidget = new te::qt::widgets::ChartDisplayWidget(graphic, graphic->rtti(), m_chartDisplay, m_ui->m_graphicFrame);
1134  first = false;
1135  }
1136  }
1137 
1138  if (!m_displayWidget)
1139  return;
1140 
1141  m_layoutg->addWidget(m_displayWidget);
1142  m_chartDisplay->adjustDisplay();
1143  m_displayWidget->show();
1144 
1145 }
1146 
1148 {
1150  return ((val.m_lower + val.m_upper)/2.);
1151 }
1152 
1154 {
1155  updateComponents();
1156 }
1157 
1159 {
1160  // m_rgbaMark
1161  QString comp(m_ui->m_componentLineEdit->text());
1162 
1163  std::map<std::string, MixModelComponent>::iterator itc = m_components.find(comp.toUtf8().data());
1164  if (itc != m_components.end())
1165  m_color = QColor(itc->second.m_color.getRed(), itc->second.m_color.getGreen(),itc->second.m_color.getBlue(),itc->second.m_color.getAlpha());
1166 
1167  m_color = QColorDialog::getColor(m_color, this);
1168  if (itc != m_components.end())
1169  {
1170  te::color::RGBAColor newcolor(m_color.red(), m_color.green(), m_color.blue(),255);
1171  itc->second.m_color.setColor(newcolor.getColor());
1172  }
1173 
1174  QPixmap px(16, 16);
1175  px.fill(m_color);
1176  m_ui->m_colorToolButton->setIcon(px);
1177 
1178  updateComponents();
1179 }
1180 
1182 {
1183  if (status)
1185 }
1186 
1188 {
1189  if (status)
1191 }
1192 
1194 {
1195  m_transfMatrix.clear();
1196  m_transfMatrix.resize(0, 0, false);
1197 
1198 }
1199 
1201 {
1202  if (page == 1)
1203  updateComponents();
1204 }
1205 
1207 {
1208  assert(m_layers.size());
1209 
1210  m_comp = m_ui->m_componentLineEdit->text().toStdString();
1211 
1212  if (m_comp.length() == 0)
1213  {
1214  QMessageBox::warning(this, tr("Mixture Model"), tr("First edit component name"));
1215  return;
1216  }
1217 
1218  te::gm::Polygon* pol = dynamic_cast<te::gm::Polygon*>(m_geom->clone());
1219 
1220  std::vector<double> allvalues;
1221 
1222  //get input raster
1223  std::list<te::map::AbstractLayerPtr>::iterator it = m_layers.begin();
1224  while (it != m_layers.end())
1225  {
1226  std::unique_ptr<te::da::DataSet> ds = it->get()->getData();
1227  if (ds.get())
1228  {
1229  std::size_t rpos = te::da::GetFirstPropertyPos(ds.get(), te::dt::RASTER_TYPE);
1230  std::unique_ptr<te::rst::Raster> inputRst = ds->getRaster(rpos);
1231 
1232  if (inputRst.get())
1233  {
1234  if (inputRst->getSRID() != it->get()->getSRID())
1235  inputRst->getGrid()->setSRID(it->get()->getSRID());
1236 
1237  //component name
1238  std::string className(m_comp);
1239  //component values
1240  std::vector<double> componentsVector;
1241 
1243 
1244  //iterate polygon
1245  int npixels = 0;
1246  for (std::size_t nb = 0; nb < inputRst->getNumberOfBands(); nb++)
1247  allvalues.push_back(0);
1248 
1249  std::vector<double>::iterator itv, ita;
1250  for (te::rst::PolygonIterator<double> itRaster = te::rst::PolygonIterator<double>::begin(inputRst.get(), pol); itRaster != itRasterEnd; ++itRaster)
1251  {
1252  std::vector<double> values;
1253  int currentColumn = itRaster.getColumn();
1254  int currentRow = itRaster.getRow();
1255 
1256  if (currentColumn < 0 || currentColumn >= (int)inputRst->getNumberOfColumns())
1257  continue;
1258  if (currentRow < 0 || currentRow >= (int)inputRst->getNumberOfRows())
1259  continue;
1260 
1261  inputRst->getValues(currentColumn, currentRow, values);
1262  for (itv = values.begin(), ita = allvalues.begin(); itv != values.end(), ita != allvalues.end(); itv++, ita++)
1263  (*ita) += *itv;
1264  npixels++;
1265  }
1266 
1267  for (ita = allvalues.begin(); ita != allvalues.end(); ita++)
1268  (*ita) /= npixels;
1269 
1270  for (unsigned b = 0; b < inputRst->getNumberOfBands(); b++)
1271  {
1272  QString bName(it->get()->getTitle().c_str());
1273  bName.append(tr(" Band "));
1274  bName.append(QString::number(b));
1275  componentsVector.push_back(allvalues[b]);
1276  }
1277 
1278  //component coordinate
1279  te::gm::Polygon *pgrid = new te::gm::Polygon(*pol);
1280  te::gm::LinearRing *lr = dynamic_cast<te::gm::LinearRing*>(pol->getExteriorRing());
1281  te::gm::LinearRing *lrg = dynamic_cast<te::gm::LinearRing*>(pgrid->getExteriorRing());
1282  for (std::size_t i = 0; i < lr->getNPoints(); i++)
1283  {
1284  te::gm::Coord2D pixelLocation = inputRst->getGrid()->geoToGrid(lr->getPointN(i)->getX(), lr->getPointN(i)->getY());
1285  int currentColumn = te::rst::Round(pixelLocation.x);
1286  int currentRow = te::rst::Round(pixelLocation.y);
1287  lrg->setX(i, currentColumn);
1288  lrg->setY(i, currentRow);
1289  }
1290 
1291  delete pol;
1292 
1293  MixModelComponent mmc;
1294  mmc.m_name = className;
1295  mmc.m_values = componentsVector;
1296  mmc.m_geomGrid = dynamic_cast<te::gm::Geometry*>(pgrid);
1297  mmc.m_geomGeo = m_geom;
1298  mmc.m_color.setColor(m_color.red(), m_color.green(), m_color.blue(), 255);
1299 
1300  std::map<std::string, MixModelComponent > ::iterator it = m_components.find(className);
1301  if (it != m_components.end())
1302  it->second = mmc;
1303  else
1304  m_components.insert(std::map<std::string, MixModelComponent >::value_type(className, mmc));
1305 
1306  updateComponents();
1307  } //if (inputRst.get())
1308  } //if (ds.get())
1309  ++it;
1310  }
1311 }
1312 
1314 {
1315  if (m_sensorManagerDialog->exec() == QDialog::Rejected)
1316  return;
1317 
1318  QString sensor = m_sensorManagerDialog->getSelectedSensor();
1319 
1320  if(!sensor.size())
1321  return;
1322 
1323  QComboBox *sensorComboBox = (QComboBox*)m_ui->m_bandTableWidget->cellWidget(row, 1);
1324 
1326  {
1327  sensorComboBox->clear();
1328 
1330 
1331  std::map<std::string, te::rp::SpectralSensorParams > ::iterator it_sen;
1332  QStringList sensorNames;
1333 
1334  for (it_sen = m_SensorParams.begin(); it_sen != m_SensorParams.end(); it_sen++)
1335  sensorNames.append((it_sen->first).c_str());
1336 
1337  sensorComboBox->addItems(sensorNames);
1338  }
1339 
1340  int index = sensorComboBox->findText(sensor);
1341  sensorComboBox->setCurrentIndex(index);
1342 
1343 }
1344 
1346 {
1347  updateComponents();
1348 }
te::color::RGBAColor ** m_rgbaMark
component color
std::list< te::map::AbstractLayerPtr > m_layers
list of input layers
bool isModified()
Returns the selected sensor paramters.
void clear()
It clears the canvas content and fills with the background color.
unsigned int band
void adjustDisplay()
Updates the general display settings according to the ChartStyle. The adjusted properties are: Title;...
This file defines a class for a MixtureModel Wizard page.
double y
y-coordinate.
Definition: Coord2D.h:114
void setX(std::size_t i, const double &x)
It sets the n-th x coordinate value.
void setColor(const std::string &hexColor)
It sets the color using a two hexadecimal RGB-encoded color.
Definition: RGBAColor.h:341
std::map< std::string, te::rp::SpectralSensorParams > m_SensorParams
map with sensor parameters
Raster decomposition using mixture model.
Definition: MixtureModel.h:62
void transform(int srid)
It converts the coordinate values of the geometry to the new spatial reference system.
te::gm::Geometry * m_geomGeo
component coordinates in geografic coordinates
double x
x-coordinate.
Definition: Coord2D.h:113
te::rp::MixtureModel::InputParameters getInputParams()
virtual const char * what() const
It outputs the exception message.
std::map< std::string, SpectralSensorParams > getSensorParams()
Returns a map with spectral sensors parameters defined in SpectralSensor.json file.
void setGridChecked(bool newGridChecked)
It sets the boolean used to decided weather to display the grid or not.
Definition: ChartStyle.cpp:155
This class implements the strategy to iterate with spatial restriction, the iteration occurs inside a...
This file defines a class for a Raster Navigator Dialog.
Curve * getExteriorRing() const
It returns the exterior ring of this CurvePolygon.
double m_urx
Upper right corner x-coordinate.
std::unique_ptr< Point > getPointN(std::size_t i) const
It returns the specified point in this LineString.
std::vector< std::string > m_inputSensorBands
The names of the sensor/bands.
Definition: MixtureModel.h:113
A widget to control the display of a set of layers.
boost::numeric::ublas::matrix< double > m_transfMatrix
Transformation matrix;.
An utility struct for representing 2D coordinates.
Definition: Coord2D.h:40
static te::dt::Date ds(2010, 01, 01)
std::string m_strategyName
The mixture model strategy name see each te::rp::MixtureModelStrategyFactory inherited classes docume...
Definition: MixtureModel.h:115
te::gm::Geometry * m_geomGrid
component coordinades in raster lineXcolumn
void setTitle(QString newTitle)
It sets the style&#39;s title.
Definition: ChartStyle.cpp:71
double m_normalMax
Upper limit to normalized.
Definition: MixtureModel.h:161
double m_normalMin
Lower limit to normalized.
Definition: MixtureModel.h:160
te::qt::widgets::ChartDisplayWidget * m_displayWidget
int m_type
algorithm mixture model type (MIXMODEL_LINEAR or MIXMODEL_PCA)
void onComponentItemClicked(QTreeWidgetItem *item, int column)
MixtureModel input parameters.
Definition: MixtureModel.h:72
int b
Definition: TsRtree.cpp:32
A LinearRing is a LineString that is both closed and simple.
Definition: LinearRing.h:53
void Free(std::vector< T * > *v)
This function can be applied to a pointer to a vector of pointers.
Definition: STLUtils.h:131
int getSRID() const _NOEXCEPT_OP(true)
It returns the Spatial Reference System ID associated to this geometric object.
void setWindow(const double &llx, const double &lly, const double &urx, const double &ury)
It sets the world (or window) coordinates area (supposing a cartesian reference system).
double m_llx
Lower left corner x-coordinate.
static PolygonIterator end(const te::rst::Raster *r, const te::gm::Polygon *p)
Returns an iterator referring to after the end of the iterator.
const double & getY() const
It returns the Point y-coordinate value.
Definition: Point.h:152
static MarkRendererManager & getInstance()
It returns a reference to the singleton instance.
bool m_normalizeOutput
A flag to indicate that output raster will be normalized , default [0, 1].
Definition: MixtureModel.h:159
A point with x and y coordinate values.
Definition: Point.h:50
const Envelope * getMBR() const _NOEXCEPT_OP(true)
It returns the minimum bounding rectangle for the geometry in an internal representation.
virtual bool isValid() const _NOEXCEPT_OP(false)
It tells if the geometry is well formed.
An Envelope defines a 2D rectangular region.
std::map< std::string, MixModelComponent > m_components
The map of selected components.
bool contains(const Envelope &rhs) const
It returns true if this envelope "spatially contains" the rhs envelope.
void setAxisY(QString newAxisY)
It sets the style&#39;s y axis label.
Definition: ChartStyle.cpp:101
virtual int getSRID() const
It return the Spatial Reference System used by the Map Display.
mydialect insert("+", new te::da::BinaryOpEncoder("+"))
te::gm::Geometry * m_geom
Current geometry/envelope component.
TERASTEREXPORT int Round(double val)
Round a double value to a integer value.
void setActionGroup(QActionGroup *actionGroup)
list bands
Definition: compose.py:2
std::vector< double > m_maxValue
vector to store maximum value of each band
void transform(int srid) _NOEXCEPT_OP(false)
It converts the coordinate values of the point to the new spatial reference system.
std::vector< std::complex< double > > m_inputRasterNoDataValues
A vector of values to be used as input raster no-data values or an empty vector indicating to use the...
Definition: MixtureModel.h:118
bool generateTransformMatrix(boost::numeric::ublas::matrix< double > &matrix)
Generates a Transform Matrix.
virtual const te::gm::Envelope & getExtent() const
It returns the world extent showned by the MapDisplay.
te::se::Mark * m_mark
component point mark type
A class to represent a chart display.
Definition: ChartDisplay.h:65
void setAxisX(QString newAxisX)
It sets the style&#39;s x axis label.
Definition: ChartStyle.cpp:91
std::size_t getNPoints() const
It returns the number of points (vertexes) in the linestring.
Definition: LineString.h:193
CurvePolygon is a planar surface defined by 1 exterior boundary and 0 or more interior boundaries...
Definition: CurvePolygon.h:57
virtual AbstractData * clone() const =0
It returns a clone of this object.
A Fill specifies the pattern for filling an area geometry.
Definition: Fill.h:59
const QString & getSelectedSensor() const
Returns the selected sensor name.
TESEEXPORT Mark * CreateMark(const std::string &wellKnownName, Stroke *stroke, Fill *fill)
Creates a mark.
This class is designed to declare objects to be thrown as exceptions by TerraLib. ...
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
std::string m_json_out
Json filename to save components.
double m_lly
Lower left corner y-coordinate.
TESEEXPORT Stroke * CreateStroke(const std::string &color, const std::string &width)
Creates a stroke.
std::unique_ptr< Ui::MixtureModelWizardPageForm > m_ui
te::rp::MixtureModel::OutputParameters getOutputParams()
TEMAPEXPORT te::rst::Raster * GetRaster(AbstractLayer *layer)
It gets the raster referenced by the given data set layer.
std::map< std::string, std::vector< double > > m_components
A set of endmembers and its radiances.
Definition: MixtureModel.h:114
A wdiget used to display a chart.
MixtureModel output parameters.
Definition: MixtureModel.h:127
Polygon is a subclass of CurvePolygon whose rings are defined by linear rings.
Definition: Polygon.h:50
virtual QPixmap * getDraftPixmap() const
It returns the map display draft pixmap.
double m_ury
Upper right corner y-coordinate.
A Stroke specifies the appearance of a linear geometry.
Definition: Stroke.h:67
A helper class for 32-bit RGBA (Red-Green-Blue-Alpha channel) color.
Definition: RGBAColor.h:57
void set(std::list< te::map::AbstractLayerPtr > layers)
This method is used to set the selected layer for mixture model operation.
#define PATTERN_SIZE
This class is used to navigate over a DataSetLayer (having a raster representation) and given a set o...
Definition: RpToolsWidget.h:70
void setMixtureModelStrategyParams(const StrategyParameters &p)
Set specific mixture model strategy parameters.
te::rst::Raster const * m_inputRasterPtr
Input raster.
Definition: MixtureModel.h:111
te::qt::widgets::SensorManagerDialog * m_sensorManagerDialog
Dialog to select/edit spectral sensors.
QColor m_color
Current component color.
void setPointN(std::size_t i, const Point &p)
It sets the value of the specified point to this new one.
std::list< te::map::AbstractLayerPtr > get()
TEDATAACCESSEXPORT std::size_t GetFirstPropertyPos(const te::da::DataSet *dataset, int datatype)
bool m_createErrorRaster
A flag to indicate that output raster will include the error bands.
Definition: MixtureModel.h:162
void setY(std::size_t i, const double &y)
It sets the n-th y coordinate value.
A dialog used to manage Spectral Sensors.
bool initialize(const AlgorithmInputParameters &inputParams)
Initializes model with paramters defined in inputParams.
unsigned int getColumn() const
Returns the current column in iterator.
void setMapDisplay(te::qt::widgets::MapDisplay *mapDisplay)
void loadMixtureModelComponents(const std::string &fileName)
This file has the RpToolsWidget class.
void transform(int oldsrid, int newsrid)
It will transform the coordinates of the Envelope from the old SRS to the new one.
std::unique_ptr< te::qt::widgets::RpToolsWidget > m_navigator
A dialog used to build a SensorManagerDialog element.
const double & getX() const
It returns the Point x-coordinate value.
Definition: Point.h:138
bool isValid() const
It tells if the rectangle is valid or not.
te::qt::widgets::MapDisplay * m_mapDisplay
std::vector< unsigned int > m_inputRasterBands
Bands to be processed from the input raster.
Definition: MixtureModel.h:112
TEGEOMEXPORT Geometry * GetGeomFromEnvelope(const Envelope *const e, int srid)
It creates a Geometry (a polygon) from the given envelope.
TESEEXPORT Fill * CreateFill(const std::string &color, const std::string &opacity)
Creates a fill.
void setRingN(std::size_t i, Curve *r)
It sets the informed position ring to the new one.