ColorMapWidget.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/se/ColorMapWidget.cpp
22 
23  \brief A dialog used to build a Color Map element.
24 */
25 
26 // TerraLib
27 
28 #include "../../../color/ColorBar.h"
29 #include "../../../common/STLUtils.h"
30 #include "../../../dataaccess/dataset/DataSet.h"
31 #include "../../../dataaccess/dataset/DataSetType.h"
32 #include "../../../dataaccess/utils/Utils.h"
33 #include "../../../datatype.h"
34 #include "../../../maptools/DataSetLayer.h"
35 #include "../../../maptools/GroupingAlgorithms.h"
36 #include "../../../maptools/RasterLayer.h"
37 #include "../../../fe/Literal.h"
38 #include "../../../fe/Utils.h"
39 #include "../../../raster.h"
40 #include "../../../raster/RasterSummary.h"
41 #include "../../../raster/RasterSummaryManager.h"
42 #include "../../../se/ColorMap.h"
43 #include "../../../se/Categorize.h"
44 #include "../../../se/Interpolate.h"
45 #include "../../../se/InterpolationPoint.h"
46 #include "../../../se/MapItem.h"
47 #include "../../../se/ParameterValue.h"
48 #include "../../../se/RasterSymbolizer.h"
49 #include "../../../se/Recode.h"
50 #include "../../../se/Rule.h"
51 #include "../../../se/Utils.h"
52 #include "../../widgets/colorbar/ColorBar.h"
53 #include "../../widgets/colorbar/ColorCatalogWidget.h"
54 #include "../../widgets/utils/ScopedCursor.h"
55 #include "ColorMapWidget.h"
56 #include "ui_ColorMapWidgetForm.h"
57 
58 // Qt
59 #include <QColorDialog>
60 #include <QMessageBox>
61 #include <QPainter>
62 #include <QValidator>
63 #include <QFileDialog>
64 
65 // Boost
66 #include <boost/algorithm/string.hpp>
67 #include <boost/filesystem.hpp>
68 #include <boost/lexical_cast.hpp>
69 #include <boost/property_tree/json_parser.hpp>
70 
71 // STL
72 #include <cassert>
73 
75 
76 te::qt::widgets::ColorMapWidget::ColorMapWidget(QWidget* parent, Qt::WindowFlags f)
77  : QWidget(parent, f),
78  m_ui(new Ui::ColorMapWidgetForm),
79  m_cm(nullptr),
80  m_cb(nullptr),
81  m_raster(nullptr)
82 {
83  m_ui->setupUi(this);
84 
85  QGridLayout* l = new QGridLayout(m_ui->m_colorBarWidget);
86  l->setContentsMargins(0,0,0,0);
87  m_colorBar = new te::qt::widgets::ColorCatalogWidget(m_ui->m_colorBarWidget);
88  l->addWidget(m_colorBar);
89 
90  m_ui->m_minValueLineEdit->setValidator(new QDoubleValidator(this));
91  m_ui->m_maxValueLineEdit->setValidator(new QDoubleValidator(this));
92 
93  initialize();
94 
95  // Signals & slots
96  connect(m_colorBar, SIGNAL(colorBarChanged()), this, SLOT(onApplyPushButtonClicked()));
97  connect(m_ui->m_bandComboBox, SIGNAL(activated(QString)), this, SLOT(onBandSelected(QString)));
98  connect(m_ui->m_applyPushButton, SIGNAL(clicked()), this, SLOT(onApplyPushButtonClicked()));
99  connect(m_ui->m_tableWidget, SIGNAL(itemDoubleClicked(QTableWidgetItem*)), this, SLOT(onTableWidgetItemDoubleClicked(QTableWidgetItem*)));
100  connect(m_ui->m_importPushButton, SIGNAL(clicked()), this, SLOT(onImportPushButtonClicked()));
101  connect(m_ui->m_transformComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(onTransformComboBoxCurrentIndexChanged(int)));
102  connect(m_ui->m_loadLegendPushButton, SIGNAL(clicked()), this, SLOT(onLoadPushButtonClicked()));
103  connect(m_ui->m_saveLegendPushButton, SIGNAL(clicked()), this, SLOT(onSavePushButtonClicked()));
104 }
105 
107 {
108  delete m_cb;
109 
110  delete m_cm;
111 }
112 
114 {
115  assert(r);
116 
117  m_raster = r;
118 
119  int nBands = static_cast<int>(m_raster->getNumberOfBands());
120 
121  m_ui->m_bandComboBox->clear();
122 
123  for(int i = 0; i < nBands; ++i)
124  {
125  QString strBand;
126  strBand.setNum(i);
127 
128  m_ui->m_bandComboBox->addItem(strBand);
129  }
130 
131  if(nBands > 0)
132  onBandSelected(m_ui->m_bandComboBox->itemText(0));
133 }
134 
136 {
137  assert(cm);
138 
139  m_cm = cm->clone();
140 
141  updateUi(true);
142 }
143 
145 {
146  if (m_ui->m_tableWidget->rowCount() < 1)
147  return nullptr;
148 
149  int index = m_ui->m_transformComboBox->currentIndex();
150 
151  int type = m_ui->m_transformComboBox->itemData(index).toInt();
152 
154  {
156  }
157  else if(type == te::se::INTERPOLATE_TRANSFORMATION)
158  {
160  }
161  else if(type == te::se::RECODE_TRANSFORMATION)
162  {
164  }
165 
166  return m_cm->clone();
167 }
168 
170 {
171  if(m_ui->m_bandComboBox->count() != 0)
172  {
173  return m_ui->m_bandComboBox->currentText().toUtf8().data();
174  }
175 
176  return "";
177 }
178 
180 {
181  return m_ui.get();
182 }
183 
185 {
188 
189  m_ui->m_transformComboBox->clear();
190 
191  m_ui->m_transformComboBox->addItem(tr("Categorize"), te::se::CATEGORIZE_TRANSFORMATION);
192  m_ui->m_transformComboBox->addItem(tr("Interpolate"), te::se::INTERPOLATE_TRANSFORMATION);
193  m_ui->m_transformComboBox->addItem(tr("Recode"), te::se::RECODE_TRANSFORMATION);
194 
195  m_ui->m_typeComboBox->addItem(tr("Equal Steps"), te::se::EQUAL_STEP_SLICE);
196  m_ui->m_typeComboBox->addItem(tr("Unique Value"), te::se::UNIQUE_VALUE_SLICE);
197 }
198 
200 {
201  m_ui->m_tableWidget->setRowCount(0);
202 
203  if(!m_cm)
204  {
205  return;
206  }
207 
208  te::color::ColorBar* cb = nullptr;
209 
210  if(m_cm->getCategorize())
211  {
213 
214  for(int i = 0; i < m_ui->m_transformComboBox->count(); ++i)
215  {
216  if(m_ui->m_transformComboBox->itemData(i).toInt() == te::se::CATEGORIZE_TRANSFORMATION)
217  m_ui->m_transformComboBox->setCurrentIndex(i);
218  }
219 
220  std::vector<te::se::ParameterValue*> t = m_cm->getCategorize()->getThresholds();
221  std::vector<te::se::ParameterValue*> tV = m_cm->getCategorize()->getThresholdValues();
222 
223  m_ui->m_slicesSpinBox->setValue(static_cast<int>(tV.size() - 2));
224 
225  m_ui->m_tableWidget->setRowCount(static_cast<int>(tV.size() - 2));
226 
227  te::color::RGBAColor initColor(te::se::GetString(tV[1]));
228  te::color::RGBAColor endColor(te::se::GetString(tV[tV.size() - 2]));
229 
230  if(loadColorBar)
231  cb = new te::color::ColorBar(initColor, endColor, 256);
232 
233  int count = 0;
234 
235  for(size_t i = 1; i < tV.size() - 1; ++i)
236  {
237  QColor color;
238  std::string lowerLimit;
239  std::string upperLimit;
240 
241  if(i == 0)
242  {
243  lowerLimit = "...";
244  upperLimit = te::se::GetString(t[i]);
245  color.setNamedColor(te::se::GetString(tV[i]).c_str());
246  }
247  else if(i == tV.size() - 1)
248  {
249  lowerLimit = te::se::GetString(t[i - 1]);
250  upperLimit = "...";
251  color.setNamedColor(te::se::GetString(tV[i]).c_str());
252  }
253  else
254  {
255  lowerLimit = te::se::GetString(t[i - 1]);
256  upperLimit = te::se::GetString(t[i]);
257  color.setNamedColor(te::se::GetString(tV[i]).c_str());
258  }
259 
260  if(loadColorBar)
261  {
262  if(count != 0 && count != static_cast<int>(tV.size()) - 2)
263  {
264  double pos = (1. / (tV.size() - 2)) * count;
265 
267 
268  cb->addColor(color, pos);
269  }
270  }
271 
272  ++count;
273 
274  //color
275  QPixmap pix(24, 24);
276  QPainter p(&pix);
277 
278  p.fillRect(0,0,24, 24, color);
279  p.setBrush(Qt::transparent);
280  p.setPen(Qt::black);
281  p.drawRect(0, 0, 23, 23);
282 
283  QIcon icon(pix);
284 
285  QTableWidgetItem* item = new QTableWidgetItem(pix, "");
286  item->setFlags(Qt::ItemIsEnabled);
287  m_ui->m_tableWidget->setItem(static_cast<int>(i - 1), 0, item);
288 
289  //value From
290  std::string rangeLower = lowerLimit;
291  QTableWidgetItem* itemRangeLower = new QTableWidgetItem();
292  itemRangeLower->setText(rangeLower.c_str());
293  itemRangeLower->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled|Qt::ItemIsEditable);
294  m_ui->m_tableWidget->setItem(static_cast<int>(i - 1), 1, itemRangeLower);
295 
296  //value To
297  std::string rangeUpper = upperLimit;
298  QTableWidgetItem* itemRangeUpper = new QTableWidgetItem();
299  itemRangeUpper->setText(rangeUpper.c_str());
300  itemRangeUpper->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled|Qt::ItemIsEditable);
301 
302  m_ui->m_tableWidget->setItem(static_cast<int>(i - 1), 2, itemRangeUpper);
303  }
304  }
305  else if(m_cm->getInterpolate())
306  {
308 
309  for(int i = 0; i < m_ui->m_transformComboBox->count(); ++i)
310  {
311  if(m_ui->m_transformComboBox->itemData(i).toInt() == te::se::INTERPOLATE_TRANSFORMATION)
312  m_ui->m_transformComboBox->setCurrentIndex(i);
313  }
314 
315  std::vector<te::se::InterpolationPoint*> ip = m_cm->getInterpolate()->getInterpolationPoints();
316 
317  m_ui->m_slicesSpinBox->setValue(static_cast<int>(ip.size() - 1));
318 
319  m_ui->m_tableWidget->setRowCount(static_cast<int>(ip.size() - 1));
320 
321  te::color::RGBAColor initColor(te::se::GetString(ip[0]->getValue()));
322  te::color::RGBAColor endColor(
323  te::se::GetString(ip[ip.size() - 1]->getValue()));
324 
325  if(loadColorBar)
326  cb = new te::color::ColorBar(initColor, endColor, 256);
327 
328  int count = 0;
329 
330  for(size_t i = 0; i < ip.size() - 1; ++i)
331  {
332  QColor color1;
333  QColor color2;
334  QString valStrBegin;
335  QString valStrEnd;
336 
337  te::se::InterpolationPoint* ipItem = ip[i];
338  te::se::InterpolationPoint* ipItem2 = ip[i + 1];
339 
340  color1.setNamedColor(te::se::GetString(ipItem->getValue()).c_str());
341  color2.setNamedColor(te::se::GetString(ipItem2->getValue()).c_str());
342 
343  valStrBegin.setNum(ipItem->getData());
344  valStrEnd.setNum(ipItem2->getData());
345 
346  QString valStr;
347  valStr.append(valStrBegin);
348  valStr.append(" - ");
349  valStr.append(valStrEnd);
350 
351  if(loadColorBar)
352  {
353  if(count != 0 && count != static_cast<int>(ip.size()) - 1)
354  {
355  double pos = (1. / (ip.size() - 1)) * count;
356 
358 
359  cb->addColor(color, pos);
360  }
361  }
362 
363  ++count;
364 
365  //color
366  QPixmap pix(24, 24);
367  QPainter p(&pix);
368 
369  p.fillRect(0,0,12, 24, color1);
370  p.fillRect(12,0,12, 24, color2);
371  p.setBrush(Qt::transparent);
372  p.setPen(Qt::black);
373  p.drawRect(0, 0, 23, 23);
374 
375  QIcon icon(pix);
376 
377  QTableWidgetItem* item = new QTableWidgetItem(icon, "");
378  //item->setBackgroundColor(color);
379  item->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled);
380  m_ui->m_tableWidget->setItem(static_cast<int>(i), 0, item);
381 
382  //value lower
383  QTableWidgetItem* itemRangeLower = new QTableWidgetItem();
384  itemRangeLower->setText(valStrBegin);
385  itemRangeLower->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled|Qt::ItemIsEditable);
386  m_ui->m_tableWidget->setItem(static_cast<int>(i), 1, itemRangeLower);
387 
388  //value upper
389  QTableWidgetItem* itemRangeUpper = new QTableWidgetItem();
390  itemRangeUpper->setText(valStrEnd);
391  itemRangeUpper->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled|Qt::ItemIsEditable);
392  m_ui->m_tableWidget->setItem(static_cast<int>(i), 2, itemRangeUpper);
393  }
394  }
395  else if (m_cm->getRecode())
396  {
398 
399  for (int i = 0; i < m_ui->m_transformComboBox->count(); ++i)
400  {
401  if (m_ui->m_transformComboBox->itemData(i).toInt() == te::se::RECODE_TRANSFORMATION)
402  m_ui->m_transformComboBox->setCurrentIndex(i);
403  }
404 
405  if (loadColorBar)
406  cb = new te::color::ColorBar;
407 
408  te::se::Recode* rec = m_cm->getRecode();
409 
410  std::vector<te::se::MapItem*> items = rec->getMapItems();
411 
412  m_ui->m_tableWidget->setRowCount(static_cast<int>(items.size()));
413 
414  int count = 0;
415 
416  for (std::size_t i = 0; i < items.size(); ++i)
417  {
418  std::string title = items[i]->getTitle();
419  double data = items[i]->getData();
420  te::se::ParameterValue* value = items[i]->getValue();
421 
422  if (loadColorBar)
423  {
425 
426  if (count == 0)
427  cb->addColor(color, 0);
428  else if (count == static_cast<int>(items.size())-1)
429  cb->addColor(color, 1);
430  else
431  {
432  double pos = (1. / (items.size() - 2)) * count;
433 
434  cb->addColor(color, pos);
435  }
436  }
437 
438  ++count;
439 
440  QColor color;
441  color.setNamedColor(te::se::GetString(value).c_str());
442 
443  //color
444  QPixmap pix(24, 24);
445  QPainter p(&pix);
446 
447  p.fillRect(0, 0, 24, 24, color);
448  p.setBrush(Qt::transparent);
449  p.setPen(Qt::black);
450  p.drawRect(0, 0, 23, 23);
451 
452  QIcon icon(pix);
453 
454  QTableWidgetItem* item = new QTableWidgetItem(pix, "");
455  item->setFlags(Qt::ItemIsEnabled);
456  m_ui->m_tableWidget->setItem(static_cast<int>(i), 0, item);
457 
458  // Data
459  QTableWidgetItem* itemData = new QTableWidgetItem();
460  itemData->setText(QString::number(data));
461  itemData->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);// | Qt::ItemIsEditable);
462  m_ui->m_tableWidget->setItem(static_cast<int>(i), 1, itemData);
463 
464  // Title
465  QTableWidgetItem* itemTitle = new QTableWidgetItem();
466  itemTitle->setText(title.c_str());
467  itemTitle->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable);
468  m_ui->m_tableWidget->setItem(static_cast<int>(i), 2, itemTitle);
469  }
470  }
471 
472  if(cb)
473  {
474  disconnect(m_colorBar, SIGNAL(colorBarChanged()), this, SLOT(onApplyPushButtonClicked()));
475 
477  cbW->setColorBar(cb);
478 
479  connect(m_colorBar, SIGNAL(colorBarChanged()), this, SLOT(onApplyPushButtonClicked()));
480  }
481 
482  m_ui->m_tableWidget->resizeColumnsToContents();
483 #if (QT_VERSION >= 0x050000)
484  m_ui->m_tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
485 #else
486  m_ui->m_tableWidget->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
487 #endif
488 }
489 
491 {
493 
494  c->setFallbackValue("#000000");
495  c->setLookupValue(new te::se::ParameterValue("Rasterdata"));
496 
497  QColor cWhite(Qt::white);
498  std::string colorWhiteStr = cWhite.name().toUtf8().data();
499 
500  //added dummy color for values < than min values...
501  c->addValue(new te::se::ParameterValue(colorWhiteStr));
502 
503  for(int i = 0; i < m_ui->m_tableWidget->rowCount(); ++i)
504  {
505  QColor color = QColor::fromRgb(m_ui->m_tableWidget->item(i, 0)->icon().pixmap(24, 24).toImage().pixel(1,1));
506 
507  std::string rangeStr = m_ui->m_tableWidget->item(i, 1)->text().toUtf8().data();
508  std::string colorStr = color.name().toUtf8().data();
509 
510  c->addThreshold(new te::se::ParameterValue(rangeStr));
511  c->addValue(new te::se::ParameterValue(colorStr));
512 
513  if(i == m_ui->m_tableWidget->rowCount() - 1)
514  {
515  rangeStr = m_ui->m_tableWidget->item(i, 2)->text().toUtf8().data();
516  c->addThreshold(new te::se::ParameterValue(rangeStr));
517  }
518  }
519 
520  //added dummy color for values > than max values...
521  c->addValue(new te::se::ParameterValue(colorWhiteStr));
522 
524 
525  if(m_cm)
526  {
527  m_cm->setCategorize(c);
528  m_cm->setInterpolate(nullptr);
529  m_cm->setRecode(nullptr);
530  }
531 }
532 
534 {
535  te::se::Interpolate* interpolate = new te::se::Interpolate();
536 
537  interpolate->setFallbackValue("#000000");
538  interpolate->setLookupValue(new te::se::ParameterValue("Rasterdata"));
540 
541  for(int i = 0; i < m_ui->m_tableWidget->rowCount(); ++i)
542  {
543  QColor color = QColor::fromRgb(m_ui->m_tableWidget->item(i, 0)->icon().pixmap(24, 24).toImage().pixel(1,1));
544 
545  if(i == m_ui->m_tableWidget->rowCount() - 1)
546  {
547  {
548  QString rangeStr = m_ui->m_tableWidget->item(i, 1)->text();
549  std::string colorStr = color.name().toUtf8().data();
550 
552 
553  ip->setData(rangeStr.toDouble());
554  ip->setValue(new te::se::ParameterValue(colorStr));
555 
556  interpolate->add(ip);
557  }
558 
559  {
560  color = QColor::fromRgb(m_ui->m_tableWidget->item(i, 0)->icon().pixmap(24, 24).toImage().pixel(22,1));
561 
562  QString rangeStr = m_ui->m_tableWidget->item(i, 2)->text();
563  std::string colorStr = color.name().toUtf8().data();
564 
566 
567  ip->setData(rangeStr.toDouble());
568  ip->setValue(new te::se::ParameterValue(colorStr));
569 
570  interpolate->add(ip);
571  }
572 
573  }
574  else
575  {
576  QString rangeStr = m_ui->m_tableWidget->item(i, 1)->text();
577  std::string colorStr = color.name().toUtf8().data();
578 
580 
581  ip->setData(rangeStr.toDouble());
582  ip->setValue(new te::se::ParameterValue(colorStr));
583 
584  interpolate->add(ip);
585  }
586  }
587 
588  if(m_cm)
589  {
590  m_cm->setInterpolate(interpolate);
591  m_cm->setCategorize(nullptr);
592  m_cm->setRecode(nullptr);
593  }
594 }
595 
597 {
598  te::se::Recode* r = new te::se::Recode();
599 
600  r->setFallbackValue("#000000");
601  r->setLookupValue(new te::se::ParameterValue("Rasterdata"));
602 
603  for (int i = 0; i < m_ui->m_tableWidget->rowCount(); ++i)
604  {
605  QColor color = QColor::fromRgb(m_ui->m_tableWidget->item(i, 0)->icon().pixmap(24, 24).toImage().pixel(1, 1));
606 
607  double data = m_ui->m_tableWidget->item(i, 1)->text().toDouble();
608  std::string colorStr = color.name().toUtf8().data();
609  std::string title = m_ui->m_tableWidget->item(i, 2)->text().toUtf8().data();
610 
611  te::se::MapItem* m = new te::se::MapItem();
612  m->setData(data);
613  m->setValue(new te::se::ParameterValue(colorStr));
614  m->setTitle(title);
615 
616  r->add(m);
617  }
618 
619  if (m_cm)
620  {
621  m_cm->setCategorize(nullptr);
622  m_cm->setInterpolate(nullptr);
623  m_cm->setRecode(r);
624  }
625 }
626 
628 {
629  delete m_cb;
630 
632 
633  int sliceValue = m_ui->m_slicesSpinBox->value();
634 
635  std::vector<te::color::RGBAColor> colorVec;
636 
637  int index = m_ui->m_transformComboBox->currentIndex();
638 
639  int transType = m_ui->m_transformComboBox->itemData(index).toInt();
640 
642 
643  if (transType == te::se::CATEGORIZE_TRANSFORMATION)
644  {
645  colorVec = m_cb->getSlices(sliceValue);
646  }
647  else if (transType == te::se::INTERPOLATE_TRANSFORMATION)
648  {
649  colorVec = m_cb->getSlices(sliceValue + 1);
650  }
651  else if (transType == te::se::RECODE_TRANSFORMATION)
652  {
653  colorVec = m_cb->getSlices(static_cast<int>(getRecodeValues().size()));
654  }
655 
656  std::vector<te::se::Rule*> legVec;
657 
658  std::vector<double> vec;
659  vec.push_back(m_ui->m_minValueLineEdit->text().toDouble());
660  vec.push_back(m_ui->m_maxValueLineEdit->text().toDouble());
661 
662  te::qt::widgets::ScopedCursor cursor(Qt::WaitCursor);
663 
664  int sliceType = m_ui->m_typeComboBox->itemData(index).toInt();
665 
666  if (sliceType == te::se::EQUAL_STEP_SLICE)
667  {
668  te::map::GroupingByEqualSteps("raster", vec.begin(), vec.end(), sliceValue, legVec, m_ui->m_precisionSpinBox->value());
669  }
670  else if (sliceType == te::se::UNIQUE_VALUE_SLICE)
671  {
672  std::vector<std::string> values = getValues();
673  std::vector<std::string> valuesAux;
674 
675  for (std::size_t i = 0; i < values.size(); ++i)
676  {
677  double val = boost::lexical_cast<double>(values[i]);
678 
679  if (val >= m_ui->m_minValueLineEdit->text().toDouble() && val <= m_ui->m_maxValueLineEdit->text().toDouble())
680  {
681  valuesAux.push_back(values[i]);
682  }
683  }
684 
685  te::map::GroupingByUniqueValues("raster", valuesAux, te::dt::STRING_TYPE, legVec, m_ui->m_precisionSpinBox->value());
686  }
687 
688  m_ui->m_tableWidget->setRowCount(static_cast<int>(legVec.size()));
689 
690  for(std::size_t t = 0; t < legVec.size(); ++t)
691  {
692  if (transType == te::se::CATEGORIZE_TRANSFORMATION)
693  {
694  //color
695  QColor color(colorVec[t].getRed(), colorVec[t].getGreen(), colorVec[t].getBlue(), colorVec[t].getAlpha());
696 
697  QPixmap pix(24, 24);
698  QPainter p(&pix);
699 
700  p.fillRect(0,0,24, 24, color);
701  p.setBrush(Qt::transparent);
702  p.setPen(Qt::black);
703  p.drawRect(0, 0, 23, 23);
704 
705  QIcon icon(pix);
706 
707  QTableWidgetItem* item = new QTableWidgetItem(icon, "");
708  item->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled);
709  m_ui->m_tableWidget->setItem(static_cast<int>(t), 0, item);
710  }
711  else if (transType == te::se::RECODE_TRANSFORMATION)
712  {
713  QColor color(colorVec[t].getRed(), colorVec[t].getGreen(), colorVec[t].getBlue(), colorVec[t].getAlpha());
714 
715  QPixmap pix(24, 24);
716  QPainter p(&pix);
717 
718  p.fillRect(0, 0, 24, 24, color);
719  p.setBrush(Qt::transparent);
720  p.setPen(Qt::black);
721  p.drawRect(0, 0, 23, 23);
722 
723  QIcon icon(pix);
724 
725  QTableWidgetItem* item = new QTableWidgetItem(icon, "");
726  item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
727  m_ui->m_tableWidget->setItem(static_cast<int>(t), 0, item);
728  }
729  else if (transType == te::se::INTERPOLATE_TRANSFORMATION)
730  {
731  QColor color1(colorVec[t].getRed(), colorVec[t].getGreen(), colorVec[t].getBlue(), colorVec[t].getAlpha());
732  QColor color2(colorVec[t + 1].getRed(), colorVec[t + 1].getGreen(), colorVec[t + 1].getBlue(), colorVec[t + 1].getAlpha());
733 
734  QPixmap pix(24, 24);
735  QPainter p(&pix);
736 
737  p.fillRect(0,0,12, 24, color1);
738  p.fillRect(12,0,12, 24, color2);
739 
740  p.setBrush(Qt::transparent);
741  p.setPen(Qt::black);
742  p.drawRect(0, 0, 23, 23);
743 
744  QIcon icon(pix);
745 
746  QTableWidgetItem* item = new QTableWidgetItem(icon, "");
747  item->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled);
748  m_ui->m_tableWidget->setItem(static_cast<int>(t), 0, item);
749  }
750 
751  if (transType == te::se::RECODE_TRANSFORMATION)
752  {
753  //value lower
754  std::string value;
755  std::string title = *legVec[t]->getName();
756 
757  te::fe::GetFilterUniqueValue(legVec[t]->getFilter(), value);
758 
759  QTableWidgetItem* itemValue = new QTableWidgetItem();
760  itemValue->setText(value.c_str());
761  itemValue->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable);
762  m_ui->m_tableWidget->setItem(static_cast<int>(t), 1, itemValue);
763 
764  QTableWidgetItem* itemTitle = new QTableWidgetItem();
765  itemTitle->setText(title.c_str());
766  itemTitle->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable);
767  m_ui->m_tableWidget->setItem(static_cast<int>(t), 2, itemTitle);
768  }
769  else
770  {
771  std::string rangeStrLower;
772  std::string rangeStrUpper;
773 
774  te::fe::GetFilterStepValues(legVec[t]->getFilter(), rangeStrLower, rangeStrUpper);
775 
776  //value lower
777  QTableWidgetItem* itemRangeLower = new QTableWidgetItem();
778  itemRangeLower->setText(rangeStrLower.c_str());
779  itemRangeLower->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable);
780  m_ui->m_tableWidget->setItem(static_cast<int>(t), 1, itemRangeLower);
781 
782  //value upper
783  QTableWidgetItem* itemRangeUpper = new QTableWidgetItem();
784  itemRangeUpper->setText(rangeStrUpper.c_str());
785  itemRangeUpper->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable);
786  m_ui->m_tableWidget->setItem(static_cast<int>(t), 2, itemRangeUpper);
787  }
788  }
789 
790  m_ui->m_tableWidget->resizeColumnsToContents();
791 #if (QT_VERSION >= 0x050000)
792  m_ui->m_tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
793 #else
794  m_ui->m_tableWidget->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
795 #endif
796 
797  emit applyPushButtonClicked();
798 }
799 
801 {
802  if(value.isEmpty())
803  {
804  return;
805  }
806 
809  const std::complex<double>* cmin = rsMin->at(value.toInt()).m_minVal;
810  const std::complex<double>* cmax = rsMax->at(value.toInt()).m_maxVal;
811  double min = cmin->real();
812  double max = cmax->real();
813 
814  QString strMin;
815  strMin.setNum(min);
816  m_ui->m_minValueLineEdit->setText(strMin);
817 
818  QString strMax;
819  strMax.setNum(max);
820  m_ui->m_maxValueLineEdit->setText(strMax);
821 
822  te::rst::Band* band = m_raster->getBand(value.toInt());
824 
825  int pos = m_ui->m_transformComboBox->findText("Recode");
826 
827  if (interp != te::rst::PaletteIdxCInt)
828  {
829  if (pos >= 0)
830  {
831  m_ui->m_transformComboBox->removeItem(pos);
832  }
833  }
834  else
835  {
836  if (pos < 0)
837  {
838  m_ui->m_transformComboBox->addItem(tr("Recode"), te::se::RECODE_TRANSFORMATION);
839  }
840  }
841 
842  emit applyPushButtonClicked();
843 }
844 
846 {
847  int curCol = m_ui->m_tableWidget->currentColumn();
848 
849  int index = m_ui->m_transformComboBox->currentIndex();
850 
851  int type = m_ui->m_transformComboBox->itemData(index).toInt();
852 
853  if(curCol == 0)
854  {
856  {
857  QColor bgColor = QColor::fromRgb(item->icon().pixmap(24, 24).toImage().pixel(1,1));
858 
859  QColor newBgColor = QColorDialog::getColor(bgColor, m_ui->m_tableWidget);
860 
861  if(newBgColor.isValid())
862  bgColor = newBgColor;
863 
864  QPixmap pix(24, 24);
865  pix.fill(bgColor);
866  QIcon icon(pix);
867 
868  item->setIcon(icon);
869  }
870  else if(type == te::se::INTERPOLATE_TRANSFORMATION)
871  {
872  QMessageBox::information(this, tr("Classification"),
873  tr("Set the colors for the min and max values of this range. Also necessary to change the colors equivalents at another level to maintain consistency."));
874 
875  QColor color1 = QColor::fromRgb(item->icon().pixmap(24, 24).toImage().pixel(1,1));
876 
877  QColor newBgColor = QColorDialog::getColor(color1, m_ui->m_tableWidget);
878 
879  if(newBgColor.isValid())
880  color1 = newBgColor;
881 
882  QColor color2 = QColor::fromRgb(item->icon().pixmap(24, 24).toImage().pixel(22,1));
883 
884  newBgColor = QColorDialog::getColor(color2, m_ui->m_tableWidget);
885 
886  if(newBgColor.isValid())
887  color2 = newBgColor;
888 
889  QPixmap pix(24, 24);
890  QPainter p(&pix);
891 
892  p.fillRect(0,0,12, 24, color1);
893  p.fillRect(12,0,12, 24, color2);
894 
895  QIcon icon(pix);
896 
897  item->setIcon(icon);
898  }
899  }
900 
901  emit applyPushButtonClicked();
902 }
903 
905 {
906  te::se::RasterSymbolizer* symb = nullptr;
907 
908  if(layer->getType() == "DATASETLAYER")
909  {
910  te::map::DataSetLayer* l = dynamic_cast<te::map::DataSetLayer*>(layer.get());
911 
912  if(l)
913  {
915  }
916  }
917  else if(layer->getType() == "RASTERLAYER")
918  {
919  te::map::RasterLayer* l = dynamic_cast<te::map::RasterLayer*>(layer.get());
920 
921  if(l)
922  {
924  }
925  }
926 
927  if(symb)
928  {
929  if(symb->getColorMap())
930  {
931  return symb->getColorMap();
932  }
933  }
934 
935  return nullptr;
936 }
937 
939 {
940  if(layer->getType() == "DATASETLAYER")
941  {
942  te::map::DataSetLayer* l = dynamic_cast<te::map::DataSetLayer*>(layer.get());
943 
944  if(l)
945  {
946  std::unique_ptr<te::da::DataSet> ds = layer->getData();
947 
948  if(ds.get())
949  {
950  std::size_t rpos = te::da::GetFirstPropertyPos(ds.get(), te::dt::RASTER_TYPE);
951  return ds->getRaster(rpos).release();
952  }
953  }
954  }
955  else if(layer->getType() == "RASTERLAYER")
956  {
957  te::map::RasterLayer* l = dynamic_cast<te::map::RasterLayer*>(layer.get());
958 
959  if(l)
960  {
961  return l->getRaster();
962  }
963  }
964 
965  return nullptr;
966 }
967 
968 void te::qt::widgets::ColorMapWidget::setLayers(te::map::AbstractLayerPtr selectedLayer, std::vector<te::map::AbstractLayerPtr> allLayers)
969 {
970  for(std::size_t i = 0; i < allLayers.size(); ++i)
971  {
972  std::unique_ptr<te::da::DataSetType> dt(allLayers[i]->getSchema());
973 
974  if(dt->hasRaster() && getLayerColorMap(allLayers[i]) && allLayers[i]->getId() != selectedLayer->getId())
975  {
976  m_ui->m_layersComboBox->addItem(allLayers[i]->getTitle().c_str(), QVariant::fromValue(allLayers[i]));
977  }
978  }
979 }
980 
982 {
983  if(m_ui->m_layersComboBox->currentText() == "")
984  {
985  QMessageBox::warning(this, tr("Grouping"), tr("There are no other layers with Grouping!"));
986  return;
987  }
988 
989  QVariant varLayer = m_ui->m_layersComboBox->itemData(m_ui->m_layersComboBox->currentIndex(), Qt::UserRole);
990  te::map::AbstractLayerPtr layer = varLayer.value<te::map::AbstractLayerPtr>();
991 
992  te::se::ColorMap* cm = getLayerColorMap(layer);
993 
994  setColorMap(cm);
995 
996  updateUi(true);
997 
998  emit applyPushButtonClicked();
999 }
1000 
1002 {
1003  QString fileName = QFileDialog::getOpenFileName(this, tr("Open..."),
1004  QString(), tr("LEG (*.leg *.LEG);;"), nullptr, QFileDialog::DontConfirmOverwrite);
1005 
1006  if (fileName.isEmpty())
1007  return;
1008 
1009  m_ui->m_tableWidget->setRowCount(0);
1010 
1011  boost::property_tree::ptree pt;
1012 
1013  try
1014  {
1015  boost::property_tree::json_parser::read_json(fileName.toUtf8().data(), pt);
1016 
1017  try
1018  {
1019  boost::property_tree::ptree legend = pt.get_child("Legend");
1020 
1021  std::string tranformation = legend.get<std::string>("Transformation");
1022  std::string type = legend.get<std::string>("Type");
1023  std::string slices = legend.get<std::string>("Slices");
1024  std::string precision = legend.get<std::string>("Precision");
1025 
1026  std::string catalog = legend.get<std::string>("Catalog");
1027  std::string group = legend.get<std::string>("Group");
1028  std::string schema = legend.get<std::string>("Schema");
1029 
1030  m_ui->m_transformComboBox->setCurrentIndex(m_ui->m_transformComboBox->findText(tranformation.c_str()));
1031  m_ui->m_typeComboBox->setCurrentIndex(m_ui->m_typeComboBox->findText(type.c_str()));
1032  m_ui->m_slicesSpinBox->setValue(boost::lexical_cast<double>(slices));
1033  m_ui->m_precisionSpinBox->setValue(boost::lexical_cast<double>(precision));
1034 
1036 
1037  m_colorBar->setCatalog(catalog);
1038  m_colorBar->setGroup(group);
1039  m_colorBar->setSchema(schema);
1040 
1041  std::vector<std::vector<std::string> > items;
1042 
1043  for(boost::property_tree::ptree::value_type &v: legend.get_child("Items"))
1044  {
1045  std::vector<std::string> item;
1046  item.push_back(v.second.get<std::string>("From"));
1047  item.push_back(v.second.get<std::string>("To"));
1048  item.push_back(v.second.get<std::string>("R"));
1049  item.push_back(v.second.get<std::string>("G"));
1050  item.push_back(v.second.get<std::string>("B"));
1051 
1052  items.push_back(item);
1053  }
1054 
1055  m_ui->m_tableWidget->setRowCount(items.size());
1056 
1057  for (std::size_t i = 0; i < items.size(); ++i)
1058  {
1059  m_ui->m_tableWidget->setItem(i, 1, new QTableWidgetItem(items[i][0].c_str()));
1060  m_ui->m_tableWidget->setItem(i, 2, new QTableWidgetItem(items[i][1].c_str()));
1061 
1062  QColor color;
1063  color.setRgb(boost::lexical_cast<int>(items[i][3]), boost::lexical_cast<int>(items[i][4]), boost::lexical_cast<int>(items[i][5]));
1064 
1065  QPixmap pix(24, 24);
1066  QPainter p(&pix);
1067 
1068  p.fillRect(0, 0, 12, 24, color);
1069  p.fillRect(12, 0, 12, 24, color);
1070  p.setBrush(Qt::transparent);
1071  p.setPen(Qt::black);
1072  p.drawRect(0, 0, 23, 23);
1073 
1074  QIcon icon(pix);
1075 
1076  QTableWidgetItem* item = new QTableWidgetItem(icon, "");
1077  item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
1078  m_ui->m_tableWidget->setItem(i, 0, item);
1079 
1080  }
1081  }
1082  catch(boost::property_tree::ptree_error& e)
1083  {
1084  QMessageBox::warning(this, tr("Grouping"), tr("Attribute not found."));
1085  return;
1086  }
1087  }
1088  catch(boost::property_tree::json_parser::json_parser_error& e)
1089  {
1090  QMessageBox::warning(this, tr("Grouping"), tr("Invalid file"));
1091  return;
1092  }
1093 }
1094 
1096 {
1097  QString fileName = QFileDialog::getSaveFileName(this, tr("Save as..."),
1098  QString(), tr("LEG (*.leg *.LEG);;"), nullptr, QFileDialog::DontConfirmOverwrite);
1099 
1100  saveLegend(fileName.toUtf8().data());
1101 }
1102 
1103 void te::qt::widgets::ColorMapWidget::saveLegend(const std::string& path)
1104 {
1105  int rowCount = m_ui->m_tableWidget->rowCount();
1106 
1107  if (rowCount < 1)
1108  return;
1109 
1110  if (path.empty())
1111  return;
1112 
1113  boost::property_tree::ptree pt;
1114  boost::property_tree::ptree legend;
1115 
1116  std::string tranformation = m_ui->m_transformComboBox->currentText().toUtf8().data();
1117  std::string type = m_ui->m_typeComboBox->currentText().toUtf8().data();
1118  std::string slices = m_ui->m_slicesSpinBox->text().toUtf8().data();
1119  std::string precision = m_ui->m_precisionSpinBox->text().toUtf8().data();
1120 
1121  std::string catalog = m_colorBar->getCatalog();
1122  std::string group = m_colorBar->getGroup();
1123  std::string schema = m_colorBar->getSchema();
1124 
1125  legend.add("Transformation", tranformation);
1126  legend.add("Type", type);
1127  legend.add("Slices", slices);
1128  legend.add("Precision", precision);
1129  legend.add("Catalog", catalog);
1130  legend.add("Group", group);
1131  legend.add("Schema", schema);
1132 
1133  boost::property_tree::ptree items;
1134 
1135  std::vector<te::color::RGBAColor> colorVec;
1136 
1137  int sliceValue = m_ui->m_slicesSpinBox->value();
1138 
1139  int index = m_ui->m_transformComboBox->currentIndex();
1140 
1141  int transType = m_ui->m_transformComboBox->itemData(index).toInt();
1142 
1143  if (transType == te::se::CATEGORIZE_TRANSFORMATION)
1144  {
1145  colorVec = m_cb->getSlices(sliceValue);
1146  }
1147  else if (transType == te::se::INTERPOLATE_TRANSFORMATION)
1148  {
1149  colorVec = m_cb->getSlices(sliceValue + 1);
1150  }
1151  else if (transType == te::se::RECODE_TRANSFORMATION)
1152  {
1153  colorVec = m_cb->getSlices(getRecodeValues().size());
1154  }
1155 
1156  for (int i = 0; i < m_ui->m_tableWidget->rowCount(); ++i)
1157  {
1158  std::string from = m_ui->m_tableWidget->item(i, 1)->text().toUtf8().data();
1159  std::string to = m_ui->m_tableWidget->item(i, 2)->text().toUtf8().data();
1160 
1161  boost::property_tree::ptree item;
1162  item.add("From", from);
1163  item.add("To", to);
1164  item.add("Red", colorVec.at(i).getRed());
1165  item.add("Green", colorVec.at(i).getGreen());
1166  item.add("Blue", colorVec.at(i).getBlue());
1167 
1168  items.add_child("Item", item);
1169  }
1170 
1171  legend.add_child("Items", items);
1172 
1173  pt.add_child("Legend", legend);
1174 
1175  boost::property_tree::write_json(path, pt);
1176 }
1177 
1179 {
1180  int band = m_ui->m_bandComboBox->currentText().toInt();
1181 
1182  unsigned int rows = m_raster->getNumberOfRows(),
1183  cols = m_raster->getNumberOfColumns();
1184 
1185  std::vector<std::string> values;
1186 
1187  for (unsigned int r = 0; r < rows; ++r)
1188  {
1189  for (unsigned int c = 0; c < cols; ++c)
1190  {
1191  double value;
1192  m_raster->getValue(c, r, value, static_cast<size_t>(band));
1193  std::string strValue = boost::lexical_cast<std::string>(value);
1194 
1195  if (std::find(values.begin(), values.end(), strValue) == values.end())
1196  values.push_back(strValue);
1197  }
1198  }
1199 
1200  return values;
1201 }
1202 
1204 {
1205  std::vector<std::string> values;
1206 
1207  int min = m_ui->m_minValueLineEdit->text().toInt();
1208  int max = m_ui->m_maxValueLineEdit->text().toInt();
1209 
1210  for (int i = min; i <= max; ++i)
1211  {
1212  values.push_back(boost::lexical_cast<std::string>(i));
1213  }
1214 
1215  return values;
1216 }
1217 
1219 {
1220  te::se::ColorMapTransformationType t = (te::se::ColorMapTransformationType)m_ui->m_transformComboBox->itemData(index).toInt();
1221 
1223  {
1224  m_ui->m_minValueLineEdit->setEnabled(true);
1225  m_ui->m_maxValueLineEdit->setEnabled(true);
1226  m_ui->m_slicesSpinBox->setEnabled(false);
1227  m_ui->m_precisionSpinBox->setEnabled(false);
1228 
1229  m_ui->m_typeComboBox->setCurrentIndex(1); // Unique Value
1230  m_ui->m_typeComboBox->setEnabled(false);
1231 
1232  }
1233  else
1234  {
1235  m_ui->m_minValueLineEdit->setEnabled(true);
1236  m_ui->m_maxValueLineEdit->setEnabled(true);
1237  m_ui->m_slicesSpinBox->setEnabled(true);
1238  m_ui->m_precisionSpinBox->setEnabled(true);
1239 
1240  m_ui->m_typeComboBox->setCurrentIndex(0); // Equal Steps
1241  m_ui->m_typeComboBox->setEnabled(false);
1242  }
1243 }
1244 
1246 {
1247  if (type == te::se::RECODE_TRANSFORMATION)
1248  {
1249  m_ui->m_tableWidget->setHorizontalHeaderItem(0, new QTableWidgetItem(tr("Color")));
1250  m_ui->m_tableWidget->setHorizontalHeaderItem(1, new QTableWidgetItem(tr("Value")));
1251  m_ui->m_tableWidget->setHorizontalHeaderItem(2, new QTableWidgetItem(tr("Title")));
1252  }
1253  else
1254  {
1255  m_ui->m_tableWidget->setHorizontalHeaderItem(0, new QTableWidgetItem(tr("Color")));
1256  m_ui->m_tableWidget->setHorizontalHeaderItem(1, new QTableWidgetItem(tr("From")));
1257  m_ui->m_tableWidget->setHorizontalHeaderItem(2, new QTableWidgetItem(tr("To")));
1258  }
1259 }
ParameterValue * getValue() const
Palette indexes color interpretation.
void setScaleVisible(bool flag)
Sets scale of color bar visibility.
unsigned int band
ColorMap * clone() const
Definition: ColorMap.cpp:100
The transformation of continuous values to distinct values (Categorize function). ...
Definition: Categorize.h:90
Interpolate * getInterpolate() const
Definition: ColorMap.cpp:84
ColorInterp
Color model component use.
void setData(const double &d)
unsigned int getNumberOfColumns() const
Returns the raster number of columns.
void setHeight(int value)
Sets the height of colobar.
void setMethodType(MethodType t)
Definition: Interpolate.cpp:86
TESEEXPORT RasterSymbolizer * GetRasterSymbolizer(Style *s)
Try to get raster symbolizer from a style.
TEMAPEXPORT void GroupingByUniqueValues(std::string attrName, std::vector< std::string > &inputValues, int dataType, std::vector< te::se::Rule * > &rules, int precision)
It groups the values using the unique value algorithm.
te::rst::Raster * getRaster() const
void setLookupValue(ParameterValue *v)
Definition: Categorize.cpp:81
const std::vector< InterpolationPoint * > & getInterpolationPoints() const
Definition: Interpolate.cpp:91
void setCategorize(Categorize *c)
Definition: ColorMap.cpp:67
void onTableWidgetItemDoubleClicked(QTableWidgetItem *item)
static te::dt::Date ds(2010, 01, 01)
void updateTableHeader(te::se::ColorMapTransformationType type)
void GroupingByEqualSteps(std::string attrName, iterator begin, iterator end, int nSteps, std::vector< te::se::Rule * > &rules, int precision=0)
It groups the values defined by a range of iterators using the equal steps algorithm.
The transformation of continuous values to a number of values (Interpolate function).
Definition: Interpolate.h:88
The "ParameterValueType" uses WFS-Filter expressions to give values for SE graphic parameters...
A widget used to build.
void setCatalog(const std::string &catalog)
void setValue(ParameterValue *v)
const std::vector< ParameterValue * > & getThresholds() const
Definition: Categorize.cpp:109
std::unique_ptr< Ui::ColorMapWidgetForm > m_ui
Dialog form.
void setLookupValue(ParameterValue *v)
Definition: Interpolate.cpp:70
TEFEEXPORT void GetFilterStepValues(const te::fe::Filter *filter, std::string &valueMin, std::string &valueMax)
A layer with reference to a raster.
Definition: RasterLayer.h:52
Ui::ColorMapWidgetForm * getForm()
void updateUi(bool loadColorBar=false)
Updates the widget form based on internal fill element.
void setData(const double &d)
Definition: MapItem.cpp:57
std::vector< std::string > getRecodeValues()
static RasterSummaryManager & getInstance()
It returns a reference to the singleton instance.
void setColorMap(te::se::ColorMap *cm)
void add(InterpolationPoint *i)
Definition: Interpolate.cpp:76
An abstract class for raster data strucutures.
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.
void onBandSelected(QString value)
std::vector< std::string > getValues()
virtual te::se::Style * getStyle() const
It returns the Style associated to the layer.
BandProperty * getProperty()
Returns the band property.
URI C++ Library.
Definition: Attributes.h:37
void setTitle(const std::string &title)
Definition: MapItem.cpp:83
static te::dt::TimeDuration dt(20, 30, 50, 11)
void setLookupValue(ParameterValue *v)
Definition: Recode.cpp:62
boost::ptr_vector< BandSummary > RasterSummary
RasterSummary is just a typedef of a boost::ptr_vector.
Definition: RasterSummary.h:44
te::se::ColorMap * getLayerColorMap(te::map::AbstractLayerPtr layer)
void setRaster(te::rst::Raster *r)
te::gm::Polygon * p
Recode * getRecode() const
Definition: ColorMap.cpp:95
The RasterSymbolizer describes how to render raster/matrix-coverage data (e.g., satellite photos...
A raster band description.
virtual const Band * getBand(std::size_t i) const =0
Returns the raster i-th band.
void onTransformComboBoxCurrentIndexChanged(int index)
ColorMapTransformationType
Allowed color transformations type.
void initialize()
Internal method to initialize the widget (e.g.: color, combos, icons, etc.)
Transformation of discrete values to other values.
Definition: Recode.h:75
void setRecode(Recode *i)
Definition: ColorMap.cpp:89
const std::vector< te::color::RGBAColor > & getSlices(const int &n)
It generates color bar.
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.
std::vector< MapItem * > getMapItems() const
Definition: Recode.cpp:73
void addColor(const RGBAColor &color, const double &pos)
It adds a color in the color bar.
void setSchema(const std::string &schema)
te::se::ColorMap * m_cm
SE Color Map element.
They are used to define a graph of points.
void setValue(ParameterValue *v)
Definition: MapItem.cpp:62
te::qt::widgets::ColorCatalogWidget * m_colorBar
Widget used to pick a color.
te::color::ColorBar * m_cb
Terralib color bar objetc.
void add(MapItem *m)
Definition: Recode.cpp:68
A helper class for 32-bit RGBA (Red-Green-Blue-Alpha channel) color.
Definition: RGBAColor.h:57
te::rst::Raster * getLayerRaster(te::map::AbstractLayerPtr layer)
void setLayers(te::map::AbstractLayerPtr selectedLayer, std::vector< te::map::AbstractLayerPtr > allLayers)
te::se::ColorMap * getColorMap()
te::color::ColorBar * getColorBar()
It returns the colorbar.
Categorize * getCategorize() const
Definition: ColorMap.cpp:73
It models the concept of color bar.
te::qt::widgets::colorbar::ColorBar * getColorBar()
te::se::ColorMap * getColorMap() const
A layer with reference to a dataset.
Definition: DataSetLayer.h:47
TEDATAACCESSEXPORT std::size_t GetFirstPropertyPos(const te::da::DataSet *dataset, int datatype)
void setColorBar(te::color::ColorBar *cb)
It sets the color bar.
void setGroup(const std::string &group)
te::rst::Raster * m_raster
TerraLib raster object.
Calculate the min value.
Calculate the max value.
ColorInterp m_colorInterp
The color interpretation.
Definition: BandProperty.h:140
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
void setThresholdsBelongTo(ThresholdsBelongToType t)
Definition: Categorize.cpp:104
void setInterpolate(Interpolate *i)
Definition: ColorMap.cpp:78
void addThreshold(ParameterValue *v)
Definition: Categorize.cpp:94
TESEEXPORT std::string GetString(const te::se::ParameterValue *param)
It gets the parameter value as a string.
A ColorMap defines either the colors of a pallette-type raster source or the mapping of numeric pixel...
Definition: ColorMap.h:61
void addValue(ParameterValue *v)
Definition: Categorize.cpp:99
Q_DECLARE_METATYPE(te::map::AbstractLayerPtr) te
void saveLegend(const std::string &path)
const std::vector< ParameterValue * > & getThresholdValues() const
Definition: Categorize.cpp:114
void setFallbackValue(const std::string &v)
Definition: se/Function.cpp:33
An object that when created shows a cursor during its scope.
Definition: ScopedCursor.h:48
TEFEEXPORT void GetFilterUniqueValue(const te::fe::Filter *filter, std::string &value)