All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GroupingWidget.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2011-2012 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/GroupingWidget.cpp
22 
23  \brief A widget used to build a grouping.
24 */
25 
26 // TerraLib
27 #include "../../../color/ColorBar.h"
28 #include "../../../common/Globals.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 "../../../geometry/GeometryProperty.h"
34 #include "../../../maptools/Enums.h"
35 #include "../../../maptools/Grouping.h"
36 #include "../../../maptools/GroupingAlgorithms.h"
37 #include "../../../maptools/GroupingItem.h"
38 #include "../../../maptools/Utils.h"
39 #include "../../../se/Utils.h"
40 #include "../colorbar/ColorBar.h"
41 #include "../se/SymbologyPreview.h"
42 #include "GroupingWidget.h"
43 #include "ui_GroupingWidgetForm.h"
44 
45 // STL
46 #include <cassert>
47 
48 // QT
49 #include <QtGui/QMessageBox>
50 
51 #define MAX_SLICES 200
52 #define PRECISION 15
53 #define NO_TITLE "No Value"
54 
55 
56 te::qt::widgets::GroupingWidget::GroupingWidget(QWidget* parent, Qt::WindowFlags f)
57  : QWidget(parent, f),
58  m_ui(new Ui::GroupingWidgetForm)
59 {
60  m_ui->setupUi(this);
61 
62  QGridLayout* l = new QGridLayout(m_ui->m_colorBarWidget);
63  l->setContentsMargins(0,0,0,0);
64  m_colorBar = new te::qt::widgets::colorbar::ColorBar(m_ui->m_colorBarWidget);
65  l->addWidget(m_colorBar);
66 
67 //connects
68  connect(m_colorBar, SIGNAL(colorBarChanged()), this, SLOT(onColorBarChanged()));
69  connect(m_ui->m_typeComboBox, SIGNAL(activated(int)), this, SLOT(onTypeComboBoxActivated(int)));
70  connect(m_ui->m_attrComboBox, SIGNAL(activated(int)), this, SLOT(onAttrComboBoxActivated(int)));
71  connect(m_ui->m_applyPushButton, SIGNAL(clicked()), this, SLOT(onApplyPushButtonClicked()));
72 
73  initialize();
74 }
75 
77 {
78  te::common::FreeContents(m_legend);
79  m_legend.clear();
80 }
81 
83 {
84  m_layer = layer;
85 
86  //set data type
87  setDataSetType();
88 
89  //set grouping
90  setGrouping();
91 }
92 
93 std::auto_ptr<te::map::Grouping> te::qt::widgets::GroupingWidget::getGrouping()
94 {
95  std::string attr = m_ui->m_attrComboBox->currentText().toStdString();
96  int attrIdx = m_ui->m_attrComboBox->currentIndex();
97  int attrType = m_ui->m_attrComboBox->itemData(attrIdx).toInt();
98 
99  int index = m_ui->m_typeComboBox->currentIndex();
100  int type = m_ui->m_typeComboBox->itemData(index).toInt();
101 
102  std::auto_ptr<te::map::Grouping> group(new te::map::Grouping(attr, (te::map::GroupingType)type));
103 
104  group->setPropertyType(attrType);
105 
106  group->setNumSlices(m_ui->m_slicesSpinBox->value());
107 
108  group->setPrecision(m_ui->m_precSpinBox->value());
109 
110  group->setStdDeviation(m_ui->m_stdDevDoubleSpinBox->value());
111 
112  std::vector<te::map::GroupingItem*> groupingItems;
113  for(std::size_t t = 0; t < m_legend.size(); ++t)
114  {
115  te::map::GroupingItem* gi = new te::map::GroupingItem(*m_legend[t]);
116 
117  groupingItems.push_back(gi);
118  }
119  group->setGroupingItems(groupingItems);
120 
121  return group;
122 }
123 
125 {
126  // create color bar
127  m_cb = new te::color::ColorBar(te::color::RGBAColor(255, 0, 0, TE_OPAQUE), te::color::RGBAColor(0, 0, 0, TE_OPAQUE), 256);
128 
129  m_colorBar->setHeight(20);
130  m_colorBar->setColorBar(m_cb);
131  m_colorBar->setScaleVisible(false);
132 
133  // fill grouping type combo box
134  m_ui->m_typeComboBox->addItem(tr("Equal Steps"), te::map::EQUAL_STEPS);
135  m_ui->m_typeComboBox->addItem(tr("Quantil"), te::map::QUANTIL);
136  m_ui->m_typeComboBox->addItem(tr("Standard Deviation"), te::map::STD_DEVIATION);
137  m_ui->m_typeComboBox->addItem(tr("Unique Value"), te::map::UNIQUE_VALUE);
138 
139  onTypeComboBoxActivated(0);
140 
141  //set number of slices
142  m_ui->m_slicesSpinBox->setMinimum(1);
143  m_ui->m_slicesSpinBox->setMaximum(MAX_SLICES);
144  m_ui->m_slicesSpinBox->setValue(5);
145  m_ui->m_slicesSpinBox->setSingleStep(1);
146 
147  //set standard deviation values
148  m_ui->m_stdDevDoubleSpinBox->setMinimum(0.25);
149  m_ui->m_stdDevDoubleSpinBox->setMaximum(1.0);
150  m_ui->m_stdDevDoubleSpinBox->setValue(0.5);
151  m_ui->m_stdDevDoubleSpinBox->setSingleStep(0.25);
152 
153  //set number of precision
154  m_ui->m_precSpinBox->setMinimum(1);
155  m_ui->m_precSpinBox->setMaximum(PRECISION);
156  m_ui->m_precSpinBox->setValue(6);
157  m_ui->m_precSpinBox->setSingleStep(1);
158 
159  //adjust table
160  m_ui->m_tableWidget->resizeColumnsToContents();
161  m_ui->m_tableWidget->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
162 
163  m_manual = false;
164 }
165 
167 {
168  disconnect(m_ui->m_tableWidget, SIGNAL(itemChanged(QTableWidgetItem*)), this, SLOT(onTableWidgetItemChanged(QTableWidgetItem*)));
169 
170  m_ui->m_tableWidget->setRowCount(0);
171 
172  int index = m_ui->m_typeComboBox->currentIndex();
173  int type = m_ui->m_typeComboBox->itemData(index).toInt();
174 
175  if(type == te::map::EQUAL_STEPS || type == te::map::QUANTIL || type == te::map::STD_DEVIATION)
176  {
177  QStringList list;
178  list.append(tr("Symbol"));
179  list.append(tr("Title"));
180  list.append(tr("Min"));
181  list.append(tr("Max"));
182  list.append(tr("Count"));
183 
184  m_ui->m_tableWidget->setColumnCount(5);
185  m_ui->m_tableWidget->setHorizontalHeaderLabels(list);
186  }
187  else if(type == te::map::UNIQUE_VALUE)
188  {
189  QStringList list;
190  list.append(tr("Symbol"));
191  list.append(tr("Title"));
192  list.append(tr("Value"));
193  list.append(tr("Count"));
194 
195  m_ui->m_tableWidget->setColumnCount(4);
196  m_ui->m_tableWidget->setHorizontalHeaderLabels(list);
197  }
198 
199  for(std::size_t t = 0; t < m_legend.size(); ++t)
200  {
201  te::map::GroupingItem* gi = m_legend[t];
202 
203  int newrow = m_ui->m_tableWidget->rowCount();
204  m_ui->m_tableWidget->insertRow(newrow);
205 
206  //symbol
207  {
208  const std::vector<te::se::Symbolizer*>& ss = gi->getSymbolizers();
209  QPixmap pix = te::qt::widgets::SymbologyPreview::build(ss, QSize(24, 24));
210  QIcon icon(pix);
211  QTableWidgetItem* item = new QTableWidgetItem(icon, "");
212  item->setFlags(Qt::ItemIsEnabled);
213  m_ui->m_tableWidget->setItem(newrow, 0, item);
214  }
215 
216  //title
217  {
218  QTableWidgetItem* item = new QTableWidgetItem(QString::fromStdString(gi->getTitle()));
219  item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsEditable);
220  m_ui->m_tableWidget->setItem(newrow, 1, item);
221  }
222 
223 
224  if(type == te::map::EQUAL_STEPS || type == te::map::QUANTIL || type == te::map::STD_DEVIATION)
225  {
226  if(gi->getTitle() != NO_TITLE)
227  {
228  //Min
229  {
230  QTableWidgetItem* item = new QTableWidgetItem(QString::fromStdString(gi->getLowerLimit()));
231  item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsEditable);
232  m_ui->m_tableWidget->setItem(newrow, 2, item);
233  }
234 
235  //Max
236  {
237  QTableWidgetItem* item = new QTableWidgetItem(QString::fromStdString(gi->getUpperLimit()));
238  item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsEditable);
239  m_ui->m_tableWidget->setItem(newrow, 3, item);
240  }
241  }
242 
243  //Count
244  QTableWidgetItem* item = new QTableWidgetItem(QString::number(gi->getCount()));
245  item->setFlags(Qt::ItemIsEnabled);
246  m_ui->m_tableWidget->setItem(newrow, 4, item);
247 
248  }
249  else if(type == te::map::UNIQUE_VALUE)
250  {
251  if(gi->getTitle() != NO_TITLE)
252  {
253  //Value
254  QTableWidgetItem* item = new QTableWidgetItem(QString::fromStdString(gi->getValue()));
255  item->setFlags(Qt::ItemIsEnabled);
256  m_ui->m_tableWidget->setItem(newrow, 2, item);
257  }
258 
259  //Count
260  QTableWidgetItem* item = new QTableWidgetItem(QString::number(gi->getCount()));
261  item->setFlags(Qt::ItemIsEnabled);
262  m_ui->m_tableWidget->setItem(newrow, 3, item);
263 
264  }
265  }
266 
267  m_ui->m_tableWidget->resizeColumnsToContents();
268  m_ui->m_tableWidget->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
269 
270  connect(m_ui->m_tableWidget, SIGNAL(itemChanged(QTableWidgetItem*)), this, SLOT(onTableWidgetItemChanged(QTableWidgetItem*)));
271 }
272 
274 {
275  listAttributes();
276 }
277 
279 {
280  te::map::Grouping* grouping = m_layer->getGrouping();
281 
282  if(!grouping)
283  return;
284 
285  //type
286  te::map::GroupingType type = grouping->getType();
287 
288  for(int i = 0; i < m_ui->m_typeComboBox->count(); ++i)
289  {
290  if(type == m_ui->m_typeComboBox->itemData(i).toInt())
291  {
292  m_ui->m_typeComboBox->setCurrentIndex(i);
293  break;
294  }
295  }
296 
297  //attr name
298  std::string attrName = grouping->getPropertyName();
299 
300  for(int i = 0; i < m_ui->m_attrComboBox->count(); ++i)
301  {
302  if(attrName == m_ui->m_attrComboBox->itemText(i).toStdString())
303  {
304  m_ui->m_attrComboBox->setCurrentIndex(i);
305  break;
306  }
307  }
308 
309  //precision
310  size_t prec = grouping->getPrecision();
311 
312  m_ui->m_precSpinBox->setValue((int)prec);
313 
314  //slices
315  size_t slices = grouping->getNumSlices();
316 
317  m_ui->m_slicesSpinBox->setValue((int)slices);
318 
319  //std dev
320  float stdDev = grouping->getStdDeviation();
321 
322  m_ui->m_stdDevDoubleSpinBox->setValue((double)stdDev);
323 
324  //grouping items
325  te::common::FreeContents(m_legend);
326  m_legend.clear();
327 
328  for(size_t t = 0; t < grouping->getGroupingItems().size(); ++t)
329  {
331 
332  m_legend.push_back(gi);
333  }
334 
335  updateUi();
336 }
337 
339 {
340  if(m_manual)
341  {
342  int reply = QMessageBox::question(this, tr("Classification"), tr("Manual changes will be lost. Continue?"), QMessageBox::Yes | QMessageBox::Cancel);
343 
344  if(reply != QMessageBox::Yes)
345  return;
346  }
347 
348  int index = m_ui->m_typeComboBox->currentIndex();
349 
350  int type = m_ui->m_typeComboBox->itemData(index).toInt();
351  int slices = m_ui->m_slicesSpinBox->value();
352  int prec = m_ui->m_precSpinBox->value();
353  double stdDev = m_ui->m_stdDevDoubleSpinBox->value();
354 
355  std::string attr = m_ui->m_attrComboBox->currentText().toStdString();
356  int attrIdx = m_ui->m_attrComboBox->currentIndex();
357  int attrType = m_ui->m_attrComboBox->itemData(attrIdx).toInt();
358 
359  te::common::FreeContents(m_legend);
360  m_legend.clear();
361 
362  std::string mean = "";
363 
364  int nullValues = 0;
365 
366  if(type == te::map::EQUAL_STEPS)
367  {
368  std::vector<double> vec;
369 
370  getDataAsDouble(vec, attr, attrType, nullValues);
371 
372  te::map::GroupingByEqualSteps(vec.begin(), vec.end(), slices, m_legend, prec);
373 
374  buildSymbolizer(mean);
375 
376  createDoubleNullGroupingItem(nullValues);
377  }
378  else if(type == te::map::QUANTIL)
379  {
380  std::vector<double> vec;
381 
382  getDataAsDouble(vec, attr, attrType, nullValues);
383 
384  te::map::GroupingByQuantil(vec.begin(), vec.end(), slices, m_legend, prec);
385 
386  buildSymbolizer(mean);
387 
388  createDoubleNullGroupingItem(nullValues);
389  }
390  else if(type == te::map::STD_DEVIATION)
391  {
392  std::vector<double> vec;
393 
394  getDataAsDouble(vec, attr, attrType, nullValues);
395 
396  te::map::GroupingByStdDeviation(vec.begin(), vec.end(), stdDev, m_legend, mean, prec);
397 
398  buildSymbolizer(mean);
399 
400  createDoubleNullGroupingItem(nullValues);
401  }
402  else if(type == te::map::UNIQUE_VALUE)
403  {
404  std::vector<std::string> vec;
405 
406  getDataAsString(vec, attr, nullValues);
407 
408  te::map::GroupingByUniqueValues(vec, attrType, m_legend, prec);
409 
410  buildSymbolizer(mean);
411 
412  createStringNullGroupingItem(nullValues);
413  }
414 
415  updateUi();
416 
417  m_manual = false;
418 
419  emit applyPushButtonClicked();
420 }
421 
423 {
424  int type = m_ui->m_typeComboBox->itemData(idx).toInt();
425 
426  if(type == te::map::EQUAL_STEPS)
427  {
428  m_ui->m_slicesSpinBox->setEnabled(true);
429  m_ui->m_precSpinBox->setEnabled(true);
430  m_ui->m_stdDevDoubleSpinBox->setEnabled(false);
431  }
432  else if(type == te::map::QUANTIL)
433  {
434  m_ui->m_slicesSpinBox->setEnabled(true);
435  m_ui->m_precSpinBox->setEnabled(true);
436  m_ui->m_stdDevDoubleSpinBox->setEnabled(false);
437  }
438  else if(type == te::map::STD_DEVIATION)
439  {
440  m_ui->m_slicesSpinBox->setEnabled(false);
441  m_ui->m_precSpinBox->setEnabled(true);
442  m_ui->m_stdDevDoubleSpinBox->setEnabled(true);
443  }
444  else if(type == te::map::UNIQUE_VALUE)
445  {
446  m_ui->m_slicesSpinBox->setEnabled(false);
447  m_ui->m_precSpinBox->setEnabled(true);
448  m_ui->m_stdDevDoubleSpinBox->setEnabled(false);
449  }
450 
451  if(m_layer.get())
452  listAttributes();
453 }
454 
456 {
457 // int attrType = m_ui->m_attrComboBox->itemData(idx).toInt();
458 }
459 
461 {
462  if(m_layer.get())
463  {
464  buildSymbolizer();
465 
466  updateUi();
467  }
468 }
469 
471 {
472  int index = m_ui->m_typeComboBox->currentIndex();
473  int type = m_ui->m_typeComboBox->itemData(index).toInt();
474 
475  int curRow = m_ui->m_tableWidget->currentRow();
476  int curCol = m_ui->m_tableWidget->currentColumn();
477 
478  QString str = item->text();
479 
480  if(curCol == 1) // title
481  {
482  m_legend[curRow]->setTitle(str.toStdString());
483 
484  m_manual = true;
485  }
486  else if(curCol == 2 || curCol == 3) // min and max
487  {
488  if(type == te::map::EQUAL_STEPS || type == te::map::QUANTIL || type == te::map::STD_DEVIATION)
489  {
490  bool ok = false;
491 
492  str.toDouble(&ok);
493 
494  if(!ok)
495  {
496  if(curCol == 2)
497  item->setText(m_legend[curRow]->getLowerLimit().c_str());
498  else if(curCol ==3)
499  item->setText(m_legend[curRow]->getUpperLimit().c_str());
500  }
501  else
502  {
503  if(curCol == 2)
504  m_legend[curRow]->setLowerLimit(item->text().toStdString());
505  else if(curCol ==3)
506  m_legend[curRow]->setUpperLimit(item->text().toStdString());
507 
508  m_manual = true;
509  }
510  }
511  }
512 }
513 
514 void te::qt::widgets::GroupingWidget::getDataAsDouble(std::vector<double>& vec, const std::string& attrName, const int& dataType, int& nullValues)
515 {
516  assert(m_layer.get());
517 
518  std::auto_ptr<te::map::LayerSchema> dsType(m_layer->getSchema());
519 
520  std::size_t idx;
521 
522  for(std::size_t t = 0; t < dsType->getProperties().size(); ++t)
523  {
524  if(dsType->getProperty(t)->getName() == attrName)
525  {
526  idx = t;
527  break;
528  }
529  }
530 
531  std::auto_ptr<te::da::DataSet> ds(m_layer->getData());
532 
533  ds->moveBeforeFirst();
534 
535  while(ds->moveNext())
536  {
537  if(ds->isNull(idx))
538  {
539  ++nullValues;
540  continue;
541  }
542 
543  if(dataType == te::dt::INT16_TYPE)
544  vec.push_back((double)ds->getInt16(idx));
545  else if(dataType == te::dt::INT32_TYPE)
546  vec.push_back((double)ds->getInt32(idx));
547  else if(dataType == te::dt::INT64_TYPE)
548  vec.push_back((double)ds->getInt64(idx));
549  else if(dataType == te::dt::FLOAT_TYPE)
550  vec.push_back((double)ds->getFloat(idx));
551  else if(dataType == te::dt::DOUBLE_TYPE)
552  vec.push_back(ds->getDouble(idx));
553  else if(dataType == te::dt::NUMERIC_TYPE)
554  {
555  QString strNum = ds->getNumeric(idx).c_str();
556 
557  bool ok = false;
558 
559  double value = strNum.toDouble(&ok);
560 
561  if(ok)
562  vec.push_back(value);
563  }
564  }
565 }
566 
567 void te::qt::widgets::GroupingWidget::getDataAsString(std::vector<std::string>& vec, const std::string& attrName, int& nullValues)
568 {
569  assert(m_layer.get());
570 
571  std::auto_ptr<te::map::LayerSchema> dsType(m_layer->getSchema());
572 
573  std::size_t idx;
574 
575  for(std::size_t t = 0; t < dsType->getProperties().size(); ++t)
576  {
577  if(dsType->getProperty(t)->getName() == attrName)
578  {
579  idx = t;
580  break;
581  }
582  }
583 
584  std::auto_ptr<te::da::DataSet> ds(m_layer->getData());
585 
586  ds->moveBeforeFirst();
587 
588  while(ds->moveNext())
589  {
590  if(!ds->isNull(idx))
591  vec.push_back(ds->getAsString(idx));
592  else
593  ++nullValues;
594  }
595 }
596 
598 {
599  if(count == 0)
600  return;
601 
605  legendItem->setTitle(NO_TITLE);
606  legendItem->setCount(count);
607 
608  int geomType = getGeometryType();
609  std::vector<te::se::Symbolizer*> symbVec;
611  symbVec.push_back(s);
612  legendItem->setSymbolizers(symbVec);
613 
614  m_legend.push_back(legendItem);
615 }
616 
618 {
619  if(count == 0)
620  return;
621 
624  legendItem->setTitle(NO_TITLE);
625  legendItem->setCount(count);
626 
627  int geomType = getGeometryType();
628  std::vector<te::se::Symbolizer*> symbVec;
630  symbVec.push_back(s);
631  legendItem->setSymbolizers(symbVec);
632 
633  m_legend.push_back(legendItem);
634 }
635 
637 {
638  assert(m_layer.get());
639 
640  return te::map::GetGeomType(m_layer);
641 }
642 
644 {
645  int legendSize = m_legend.size();
646 
647  std::vector<te::color::RGBAColor> colorVec;
648 
649  if(meanTitle.empty())
650  {
651  colorVec = m_cb->getSlices(legendSize);
652  }
653  else
654  {
655  int beforeMean = 0;
656  int afterMean = 0;
657  int meanIdx = 0;
658 
659  for(size_t t = 0; t < m_legend.size(); ++t)
660  {
661  if(m_legend[t]->getTitle() != meanTitle)
662  {
663  beforeMean++;
664  }
665  else
666  {
667  meanIdx = t;
668  afterMean = m_legend.size() - t - 1;
669  break;
670  }
671  }
672 
673  std::vector<te::color::RGBAColor> lowerColorVec = m_cb->getLowerMeanSlices(beforeMean);
674  te::color::RGBAColor meanColor = m_cb->getMeanSlice();
675  std::vector<te::color::RGBAColor> upperColorVec = m_cb->getUpperMeanSlices(afterMean);
676 
677  for(size_t t = 0; t < lowerColorVec.size(); ++t)
678  colorVec.push_back(lowerColorVec[t]);
679 
680  colorVec.push_back(meanColor);
681 
682  for(size_t t = 0; t < upperColorVec.size(); ++t)
683  colorVec.push_back(upperColorVec[t]);
684  }
685 
686  if(colorVec.size() != m_legend.size())
687  return;
688 
689  int geomType = getGeometryType();
690 
691  for(size_t t = 0; t < colorVec.size(); ++t)
692  {
693  std::vector<te::se::Symbolizer*> symbVec;
694 
695  te::se::Symbolizer* s = te::se::CreateSymbolizer((te::gm::GeomType)geomType, colorVec[t].getColor());
696 
697  symbVec.push_back(s);
698 
699  m_legend[t]->setSymbolizers(symbVec);
700  }
701 }
702 
704 {
705  QString curValue = m_ui->m_attrComboBox->currentText();
706 
707  m_ui->m_attrComboBox->clear();
708 
709  std::auto_ptr<te::map::LayerSchema> dsType(m_layer->getSchema());
710 
711  //grouping type
712  int index = m_ui->m_typeComboBox->currentIndex();
713  int type = m_ui->m_typeComboBox->itemData(index).toInt();
714 
715  if(type == te::map::EQUAL_STEPS ||type == te::map::QUANTIL || type == te::map::STD_DEVIATION)
716  {
717  for(size_t t = 0; t < dsType->getProperties().size(); ++t)
718  {
719  te::dt::Property* p = dsType->getProperty(t);
720 
721  int dataType = p->getType();
722 
723  switch(dataType)
724  {
725  case te::dt::INT16_TYPE:
726  case te::dt::INT32_TYPE:
727  case te::dt::INT64_TYPE:
728  case te::dt::FLOAT_TYPE:
729  case te::dt::DOUBLE_TYPE:
731  m_ui->m_attrComboBox->addItem(p->getName().c_str(), p->getType());
732 
733  default:
734  continue;
735  }
736  }
737  }
738  else if(type == te::map::UNIQUE_VALUE)
739  {
740  for(size_t t = 0; t < dsType->getProperties().size(); ++t)
741  {
742  te::dt::Property* p = dsType->getProperty(t);
743 
744  int dataType = p->getType();
745 
746  switch(dataType)
747  {
748  case te::dt::INT16_TYPE:
749  case te::dt::INT32_TYPE:
750  case te::dt::INT64_TYPE:
751  case te::dt::FLOAT_TYPE:
752  case te::dt::DOUBLE_TYPE:
754  case te::dt::STRING_TYPE:
755  m_ui->m_attrComboBox->addItem(p->getName().c_str(), p->getType());
756 
757  default:
758  continue;
759  }
760  }
761  }
762 
763  if(curValue.isEmpty() == false)
764  {
765  int idx = m_ui->m_attrComboBox->findText(curValue);
766 
767  if(idx != -1)
768  m_ui->m_attrComboBox->setCurrentIndex(idx);
769  }
770 }
static QPixmap build(const te::se::Symbolizer *symb, const QSize &size)
Generates the preview of given symbolizer element.
GroupingType
The grouping type associated to the layer.
Definition: Enums.h:150
It models the concept of color bar.
Definition: ColorBar.h:49
#define MAX_SLICES
te::qt::widgets::colorbar::ColorBar * m_colorBar
Widget used to pick a color.
This class contains the parameters needed for grouping the values of a Property.
Definition: Grouping.h:59
std::auto_ptr< te::map::Grouping > getGrouping()
const double getStdDeviation() const
It gets the standard deviation used in the Standard Deviation grouping.
Definition: Grouping.cpp:99
void FreeContents(boost::unordered_map< K, V * > &m)
This function can be applied to a map of pointers. It will delete each pointer in the map...
Definition: BoostUtils.h:55
A Symbolizer describes how a feature is to appear on a map.
Definition: Symbolizer.h:80
It QWidget implementation of color bar.
Definition: ColorBar.h:67
const std::string & getName() const
It returns the property name.
Definition: Property.h:126
const std::string & getValue() const
It gets the value of the legend item.
std::size_t getCount() const
It gets the number of objects whose values are between the lower and upper limits.
void GroupingByQuantil(iterator begin, iterator end, int nSteps, std::vector< te::map::GroupingItem * > &legend, int precision=0, bool countElements=true)
It groups the values defined by a range of iterators using the quantil algorithm. ...
void setLowerLimit(const std::string &from)
It sets the lower limit value of the legend item.
void updateUi()
Updates the widget form based on internal fill element.
void onTableWidgetItemChanged(QTableWidgetItem *item)
void GroupingByEqualSteps(iterator begin, iterator end, int nSteps, std::vector< te::map::GroupingItem * > &legend, int precision=0, bool countElements=true)
It groups the values defined by a range of iterators using the equal steps algorithm.
void setUpperLimit(const std::string &to)
It sets the upper limit value of the legend item.
#define NO_TITLE
const size_t getNumSlices() const
It gets the number of slices used in the Equal Steps and Quantil groupings.
Definition: Grouping.cpp:89
std::string getPropertyName() const
It gets the property name whose values will be grouped.
Definition: Grouping.cpp:47
A helper class for 32-bit RGBA (Red-Green-Blue-Alpha channel) color.
Definition: RGBAColor.h:57
TESEEXPORT Symbolizer * CreateSymbolizer(const te::gm::GeomType &geomType)
Try creates an appropriate symbolizer based on given geometry type.
Definition: Utils.cpp:218
std::auto_ptr< Ui::GroupingWidgetForm > m_ui
Widget form.
GeomType
Each enumerated type is compatible with a Well-known Binary (WKB) type code.
Definition: Enums.h:41
void setCount(std::size_t count)
It It sets the number of objects whose values are between the lower and upper limits.
void setTitle(const std::string &title)
It sets the title of the legend item.
GroupingWidget(QWidget *parent=0, Qt::WindowFlags f=0)
Constructs a basic fill widget which is a child of parent, with widget flags set to f...
const size_t getPrecision() const
It gets the precision used for the property values.
Definition: Grouping.cpp:79
void createDoubleNullGroupingItem(int count)
const std::string & getLowerLimit() const
It gets the lower limit value of the legend item.
void setSymbolizers(const std::vector< te::se::Symbolizer * > &symbolizers)
It sets the symbolizers of the legend item.
TEMAPEXPORT void GroupingByUniqueValues(std::vector< std::string > &inputValues, int dataType, std::vector< te::map::GroupingItem * > &legend, int precision)
It groups the values using the unique value algorithm.
#define TE_OPAQUE
For an RGBA color this is the value of the alpha-channel for totally opaque.
Definition: Config.h:39
void GroupingByStdDeviation(iterator begin, iterator end, double nDevs, std::vector< te::map::GroupingItem * > &legend, std::string &meanTitle, int precision=0, bool countElements=true)
It groups the values defined by a range of iterators using the standard deviation algorithm...
void setValue(const std::string &value)
It sets value of the legend item.
void getDataAsDouble(std::vector< double > &vec, const std::string &attrName, const int &dataType, int &nullValues)
const std::vector< te::se::Symbolizer * > & getSymbolizers() const
It gets the symbolizer of the legend item.
It models a property definition.
Definition: Property.h:59
#define PRECISION
void initialize()
Internal method to initialize the widget (e.g.: color, combos, icons, etc.)
int getType() const
It returns the property data type.
Definition: Property.h:143
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
A widget used to build a grouping.
std::string getTitle()
It gets the title of the legend item.
TEMAPEXPORT te::gm::GeomType GetGeomType(const te::map::AbstractLayerPtr &layer)
It gets the geometry type of the given layer.
Definition: Utils.cpp:789
void createStringNullGroupingItem(int count)
static const std::string sm_nanStr
Not a number string value.
Definition: Globals.h:57
void buildSymbolizer(std::string meanTitle="")
const std::string & getUpperLimit() const
It gets the upper limit value of the legend item.
const std::vector< te::map::GroupingItem * > & getGroupingItems() const
It gets the vector of grouping items.
Definition: Grouping.cpp:109
void getDataAsString(std::vector< std::string > &vec, const std::string &attrName, int &nullValues)
void setLayer(te::map::AbstractLayerPtr layer)
const GroupingType getType() const
It gets the grouping type.
Definition: Grouping.cpp:69
A GroupingItem contains information about a grouping item associated to a layer.
Definition: GroupingItem.h:48