All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ROIManagerWidget.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/classification/ROIManagerWidget.cpp
22 
23  \brief This file has the ROIManagerWidget class.
24 */
25 
26 // TerraLib
27 #include "../../../classification/ROI.h"
28 #include "../../../classification/ROISet.h"
29 #include "../../../dataaccess/utils/Utils.h"
30 #include "../../../geometry/Coord2D.h"
31 #include "../../../geometry/Geometry.h"
32 #include "../../../geometry/GeometryProperty.h"
33 #include "../../../geometry/MultiPolygon.h"
34 #include "../../../geometry/Point.h"
35 #include "../../../geometry/Utils.h"
36 #include "../../../se/PolygonSymbolizer.h"
37 #include "../../../se/Fill.h"
38 #include "../../../se/Rule.h"
39 #include "../../../se/Style.h"
40 #include "../../../se/Symbolizer.h"
41 #include "../../../se/Utils.h"
42 #include "../canvas/Canvas.h"
43 #include "../canvas/MapDisplay.h"
44 #include "../rp/RasterNavigatorWidget.h"
45 #include "../utils/ColorPickerToolButton.h"
46 #include "ROIManagerWidget.h"
47 #include "ui_ROIManagerWidgetForm.h"
48 
49 // Qt
50 #include <QFileDialog>
51 #include <QGridLayout>
52 #include <QMessageBox>
53 #include <QPointF>
54 
55 //STL
56 #include <memory>
57 
58 // Boost
59 #include <boost/uuid/random_generator.hpp>
60 #include <boost/uuid/uuid_io.hpp>
61 
63 
64 #define ROI_TREE_ITEM 0
65 #define ROI_POLYGON_TREE_ITEM 1
66 
67 te::qt::widgets::ROIManagerWidget::ROIManagerWidget(QWidget* parent, Qt::WindowFlags f)
68  : QWidget(parent, f),
69  m_ui(new Ui::ROIManagerWidgetForm),
70  m_rs(0),
71  m_sampleCounter(0)
72 {
73  m_ui->setupUi(this);
74 
75  m_ui->m_openLayerROIToolButton->setIcon(QIcon::fromTheme("folder-open"));
76  m_ui->m_fileDialogToolButton->setIcon(QIcon::fromTheme("folder-open"));
77  m_ui->m_removeROIToolButton->setIcon(QIcon::fromTheme("list-remove"));
78  m_ui->m_exportROISetToolButton->setIcon(QIcon::fromTheme("document-export"));
79  m_ui->m_addROIToolButton->setIcon(QIcon::fromTheme("list-add"));
80  m_ui->m_vectorLayerToolButton->setIcon(QIcon::fromTheme("map-draw"));
81 
82  // Color Picker
84  m_colorPicker->setFixedSize(70, 24);
85  m_colorPicker->setColor(QColor(255, 255, 0, 128));
86 
87  //build form
88  QGridLayout* colorPickerLayout = new QGridLayout(m_ui->m_colorWidget);
89  colorPickerLayout->setContentsMargins(0, 0, 0, 0);
90  colorPickerLayout->addWidget(m_colorPicker);
91 
92  QGridLayout* layout = new QGridLayout(m_ui->m_navigatorWidget);
93  m_navigator.reset( new te::qt::widgets::RasterNavigatorWidget(m_ui->m_navigatorWidget));
94  layout->addWidget(m_navigator.get(), 0, 0);
95  layout->setContentsMargins(0,0,0,0);
96  layout->setSizeConstraint(QLayout::SetMinimumSize);
97 
98  m_navigator->setSelectionMode(true);
99  m_navigator->hidePickerTool(true);
100  m_navigator->hideInfoTool(true);
101  m_navigator->hideBoxTool(true);
102 
103  //connects
104  connect(m_ui->m_openLayerROIToolButton, SIGNAL(clicked()), this, SLOT(onOpenLayerROIToolButtonClicked()));
105  connect(m_ui->m_addROIToolButton, SIGNAL(clicked()), this, SLOT(onAddROIToolButtonClicked()));
106  connect(m_ui->m_removeROIToolButton, SIGNAL(clicked()), this, SLOT(onRemoveROIToolButtonClicked()));
107  connect(m_ui->m_fileDialogToolButton, SIGNAL(clicked()), this, SLOT(onFileDialogToolButtonClicked()));
108  connect(m_ui->m_exportROISetToolButton, SIGNAL(clicked()), this, SLOT(onExportROISetToolButtonClicked()));
109  connect(m_ui->m_vectorLayerToolButton, SIGNAL(clicked(bool)), this, SLOT(onVectorLayerToolButtonClicked(bool)));
110  connect(m_ui->m_roiSetTreeWidget, SIGNAL(itemClicked(QTreeWidgetItem*, int)), this, SLOT(onROITreItemClicked(QTreeWidgetItem*, int)));
111  connect(m_navigator.get(), SIGNAL(mapDisplayExtentChanged()), this, SLOT(onMapDisplayExtentChanged()));
112  connect(m_navigator.get(), SIGNAL(geomAquired(te::gm::Polygon*)), this, SLOT(onGeomAquired(te::gm::Polygon*)));
113  connect(m_navigator.get(), SIGNAL(pointPicked(double, double)), this, SLOT(onPointPicked(double, double)));
114 }
115 
117 {
118  if(m_vectorLayer.get())
119  {
120  m_vectorLayer->setVisibility(m_vectorLayerVisibility);
121 
122  te::se::Style* s = m_vectorLayer->getStyle();
123  te::se::Rule* r = s->getRule(0);
124 
125  r->setSymbolizer(0, m_symb);
126  }
127 }
128 
129 Ui::ROIManagerWidgetForm* te::qt::widgets::ROIManagerWidget::getForm() const
130 {
131  return m_ui.get();
132 }
133 
134 void te::qt::widgets::ROIManagerWidget::setList(std::list<te::map::AbstractLayerPtr>& layerList)
135 {
136  m_ui->m_layerROIComboBox->clear();
137  m_ui->m_vectorLayerComboBox->clear();
138 
139  std::list<te::map::AbstractLayerPtr>::iterator it = layerList.begin();
140 
141  while(it != layerList.end())
142  {
144 
145  std::auto_ptr<te::da::DataSetType> dsType = l->getSchema();
146 
147  if(dsType->hasGeom())
148  {
150 
151  if(gp && gp->getGeometryType() == te::gm::MultiPolygonType)
152  m_ui->m_vectorLayerComboBox->addItem(it->get()->getTitle().c_str(), QVariant::fromValue(l));
153 
154 
155  if(dsType->getProperties().size() == 5 &&
156  dsType->getProperty(1)->getName() == TE_CL_ROI_GEOM_ID_NAME &&
157  dsType->getProperty(2)->getName() == TE_CL_ROI_LABEL_NAME &&
158  dsType->getProperty(3)->getName() == TE_CL_ROI_COLOR_NAME)
159  {
160  m_ui->m_layerROIComboBox->addItem(it->get()->getTitle().c_str(), QVariant::fromValue(l));
161  }
162  }
163 
164  ++it;
165  }
166 }
167 
169 {
170  m_layer = layer;
171 
172  m_navigator->set(layer);
173 }
174 
176 {
177  return m_rs;
178 }
179 
181 {
182  if(!m_rs)
183  return;
184 
185  te::qt::widgets::MapDisplay* mapDisplay = m_navigator->getDisplay();
186 
187  mapDisplay->getDraftPixmap()->fill(QColor(0, 0, 0, 0));
188 
189  const te::gm::Envelope& mapExt = mapDisplay->getExtent();
190 
191  te::qt::widgets::Canvas canvasInstance(mapDisplay->getDraftPixmap());
192  canvasInstance.setWindow(mapExt.m_llx, mapExt.m_lly, mapExt.m_urx, mapExt.m_ury);
193 
194  std::map<std::string, te::cl::ROI*> roiMap = m_rs->getROISet();
195  std::map<std::string, te::cl::ROI*>::iterator it = roiMap.begin();
196 
197  while(it != roiMap.end())
198  {
199  te::cl::ROI* roi = it->second;
200 
201  std::map<std::string, te::gm::Polygon*> polyMap = roi->getPolygons();
202  std::map<std::string, te::gm::Polygon*>::iterator itPoly = polyMap.begin();
203 
204  te::color::RGBAColor rgba(roi->getColor());
205 
206  canvasInstance.setPolygonContourWidth(2);
207  canvasInstance.setPolygonContourColor(rgba);
208  canvasInstance.setPolygonFillColor(te::color::RGBAColor(rgba.getRed(), rgba.getGreen(), rgba.getBlue(), 80));
209 
210  while(itPoly != polyMap.end())
211  {
212  te::gm::Polygon* poly = itPoly->second;
213 
214  canvasInstance.draw(poly);
215 
216  ++itPoly;
217  }
218  ++it;
219  }
220 
221  //draw selected
222  if(!m_ui->m_roiSetTreeWidget->selectedItems().isEmpty())
223  {
224  QTreeWidgetItem* item = m_ui->m_roiSetTreeWidget->selectedItems()[0];
225 
226  if(item->type() == ROI_POLYGON_TREE_ITEM)
227  {
228  std::string id = item->data(0, Qt::UserRole).toString().toStdString();
229 
230  QTreeWidgetItem* parent = item->parent();
231 
232  std::string label = parent->text(0).toStdString();
233 
234  te::cl::ROI* roi = m_rs->getROI(label);
235 
236  te::color::RGBAColor rgba(roi->getColor());
237 
238  te::gm::Polygon* p = roi->getPolygons()[id];
239 
240  canvasInstance.setPolygonContourWidth(1);
241  canvasInstance.setPolygonContourColor(rgba);
242  canvasInstance.setPolygonFillColor(rgba);
243 
244  canvasInstance.draw(p);
245  }
246  }
247 
248  mapDisplay->repaint();
249 }
250 
252 {
253  int idxLayer = m_ui->m_layerROIComboBox->currentIndex();
254  QVariant varLayer = m_ui->m_layerROIComboBox->itemData(idxLayer, Qt::UserRole);
255  te::map::AbstractLayerPtr layer = varLayer.value<te::map::AbstractLayerPtr>();
256 
257  if(!layer.get())
258  return;
259 
260  std::auto_ptr<te::da::DataSet> ds = layer->getData();
261 
262  if(m_rs)
263  delete m_rs;
264 
265  m_ui->m_roiSetTreeWidget->clear();
266 
267  m_sampleCounter = 0;
268 
269  try
270  {
271  m_rs = te::cl::ROISet::createROISet(ds);
272  }
273  catch(...)
274  {
275  QMessageBox::warning(this, tr("Warning"), tr("Error extracting ROISet Information. Invalid layer."));
276  return;
277  }
278 
279  std::map<std::string, te::cl::ROI*> roiMap = m_rs->getROISet();
280  std::map<std::string, te::cl::ROI*>::iterator it = roiMap.begin();
281 
282  while(it != roiMap.end())
283  {
284  te::cl::ROI* roi = it->second;
285 
286  std::map<std::string, te::gm::Polygon*> polyMap = roi->getPolygons();
287  std::map<std::string, te::gm::Polygon*>::iterator itPoly = polyMap.begin();
288 
289  //update roi set tree
290  QPixmap pix(16,16);
291  pix.fill(QColor(roi->getColor().c_str()));
292  QIcon icon(pix);
293 
294  QTreeWidgetItem* item = new QTreeWidgetItem(m_ui->m_roiSetTreeWidget, ROI_TREE_ITEM);
295  item->setText(0, roi->getLabel().c_str());
296  item->setIcon(0, icon);
297 
298  m_ui->m_roiSetTreeWidget->addTopLevelItem(item);
299 
300  while(itPoly != polyMap.end())
301  {
302  //update tree
303  m_sampleCounter ++;
304 
305  QString sampleCounter;
306  sampleCounter.setNum(m_sampleCounter);
307  QString sampleName(tr("Sample"));
308  QString fullName;
309  fullName.append(sampleName);
310  fullName.append(" - ");
311  fullName.append(sampleCounter);
312 
313  QTreeWidgetItem* subItem = new QTreeWidgetItem(item, ROI_POLYGON_TREE_ITEM);
314  subItem->setText(0, fullName);
315  subItem->setData(0, Qt::UserRole, QVariant(itPoly->first.c_str()));
316  subItem->setIcon(0, QIcon::fromTheme("file-vector"));
317  item->addChild(subItem);
318  item->setExpanded(true);
319 
320  ++itPoly;
321  }
322  ++it;
323  }
324 
325  emit roiSetChanged(m_rs);
326 
327  drawROISet();
328 }
329 
331 {
332  if(m_ui->m_labelROILineEdit->text().isEmpty())
333  {
334  QMessageBox::warning(this, tr("Warning"), tr("ROI Label is empty."));
335  return;
336  }
337 
338  //get roi info
339  std::string label = m_ui->m_labelROILineEdit->text().toStdString();
340  std::string color = m_colorPicker->getColor().name().toStdString();
341 
342  //create roi
343  te::cl::ROI* roi = new te::cl::ROI(label);
344  roi->setColor(color);
345 
346  //check if roi set exist
347  if(!m_rs)
348  {
349  m_rs = new te::cl::ROISet();
350  }
351 
352  //add roi into roi set
353  m_rs->addROI(roi);
354 
355  //update roi set tree
356  QPixmap pix(16,16);
357  pix.fill(m_colorPicker->getColor());
358  QIcon icon(pix);
359 
360  QTreeWidgetItem* item = new QTreeWidgetItem(m_ui->m_roiSetTreeWidget, ROI_TREE_ITEM);
361  item->setText(0, roi->getLabel().c_str());
362  item->setIcon(0, icon);
363 
364  m_ui->m_roiSetTreeWidget->addTopLevelItem(item);
365 
366  m_ui->m_labelROILineEdit->clear();
367 
368  emit roiSetChanged(m_rs);
369 }
370 
372 {
373  if(m_ui->m_roiSetTreeWidget->selectedItems().empty())
374  {
375  QMessageBox::warning(this, tr("Warning"), tr("Select a item first."));
376  return;
377  }
378 
379  QTreeWidgetItem* item = m_ui->m_roiSetTreeWidget->selectedItems()[0];
380 
381  if(item->type() == ROI_TREE_ITEM)
382  {
383  std::string label = item->text(0).toStdString();
384  m_rs->removeROI(label);
385 
386  delete item;
387  }
388  else if(item->type() == ROI_POLYGON_TREE_ITEM)
389  {
390  std::string id = item->data(0, Qt::UserRole).toString().toStdString();
391 
392  QTreeWidgetItem* parent = item->parent();
393 
394  std::string label = parent->text(0).toStdString();
395 
396  te::cl::ROI* roi = m_rs->getROI(label);
397 
398  roi->removePolygon(id);
399 
400  parent->removeChild(item);
401  }
402 
403  if(m_rs && m_rs->getROISet().empty())
404  {
405  m_sampleCounter = 0;
406  }
407 
408  drawROISet();
409 
410  emit roiSetChanged(m_rs);
411 }
412 
414 {
415  QString fileName = QFileDialog::getSaveFileName(this, tr("Save ROI Set to File"), "", tr("Shape Files (*.shp *.SHP)"));
416 
417  if (fileName.isEmpty())
418  return;
419 
420  QFileInfo file(fileName);
421 
422  if(file.suffix().isEmpty())
423  fileName.append(".shp");
424 
425  m_ui->m_roiSetNameLineEdit->setText(fileName);
426 }
427 
428 void te::qt::widgets::ROIManagerWidget::onROITreItemClicked(QTreeWidgetItem* item, int column)
429 {
430  drawROISet();
431 
432  if(!item || item->type() != ROI_POLYGON_TREE_ITEM)
433  return;
434 
435  te::qt::widgets::MapDisplay* mapDisplay = m_navigator->getDisplay();
436  const te::gm::Envelope& mapExt = mapDisplay->getExtent();
437 
438  te::qt::widgets::Canvas canvasInstance(mapDisplay->getDraftPixmap());
439  canvasInstance.setWindow(mapExt.m_llx, mapExt.m_lly, mapExt.m_urx, mapExt.m_ury);
440 
441  std::string id = item->data(0, Qt::UserRole).toString().toStdString();
442 
443  QTreeWidgetItem* parent = item->parent();
444 
445  std::string label = parent->text(0).toStdString();
446 
447  te::cl::ROI* roi = m_rs->getROI(label);
448 
449  te::color::RGBAColor rgba(roi->getColor());
450 
451  te::gm::Polygon* p = roi->getPolygons()[id];
452 
453  canvasInstance.setPolygonContourWidth(1);
454  canvasInstance.setPolygonContourColor(rgba);
455  canvasInstance.setPolygonFillColor(rgba);
456 
457  canvasInstance.draw(p);
458 
459  mapDisplay->repaint();
460 
461 }
462 
464 {
465  if(m_ui->m_roiSetNameLineEdit->text().isEmpty())
466  {
467  QMessageBox::warning(this, tr("Warning"), tr("File name not defined."));
468  return;
469  }
470  std::string fileName = m_ui->m_roiSetNameLineEdit->text().toStdString();
471 
472  if(m_rs->getROISet().empty())
473  {
474  QMessageBox::warning(this, tr("Warning"), tr("ROI Set is empty."));
475  return;
476  }
477  int srid = m_layer->getSRID();
478 
479  try
480  {
481  m_rs->exportToFile(fileName, srid);
482  }
483  catch(...)
484  {
485  QMessageBox::warning(this, tr("Warning"), tr("Error exporting ROI Set."));
486  return;
487  }
488 
489  QMessageBox::warning(this, tr("Warning"), tr("ROI Set exported successfully."));
490 }
491 
493 {
494  if(flag)
495  {
496  int idxLayer = m_ui->m_vectorLayerComboBox->currentIndex();
497  QVariant varLayer = m_ui->m_vectorLayerComboBox->itemData(idxLayer, Qt::UserRole);
498  te::map::AbstractLayerPtr layer = varLayer.value<te::map::AbstractLayerPtr>();
499 
500  m_vectorLayer = layer;
501  m_vectorLayerVisibility = m_layer->getVisibility();
502  m_vectorLayer->setVisibility(te::map::VISIBLE);
503 
504  te::se::Style* s = m_vectorLayer->getStyle();
505  te::se::Rule* r = s->getRule(0);
506  const te::se::Symbolizer* symb = r->getSymbolizer(0);
507 
508  m_symb = symb->clone();
509 
510  if(symb->getType() == "PolygonSymbolizer")
511  {
513 
514  te::se::Fill* fill = ps->getFill()->clone();
515  fill->setOpacity("0.2");
516 
517  ps->setFill(fill);
518 
519  r->setSymbolizer(0, ps);
520  }
521 
522  m_navigator->setVectorial(m_vectorLayer);
523  m_navigator->hidePickerTool(false);
524  }
525  else
526  {
527  m_navigator->removeVectorial();
528  m_navigator->hidePickerTool(true);
529  }
530 }
531 
533 {
534  drawROISet();
535 }
536 
538 {
539  if(m_ui->m_roiSetTreeWidget->selectedItems().empty())
540  {
541  QMessageBox::warning(this, tr("Warning"), tr("Select a ROI item first."));
542  return;
543  }
544 
545  QTreeWidgetItem* item = m_ui->m_roiSetTreeWidget->selectedItems()[0];
546 
547  if(item->type() != ROI_TREE_ITEM)
548  {
549  QMessageBox::warning(this, tr("Warning"), tr("Select a ROI item first."));
550  }
551 
552  //get roi
553  std::string label = item->text(0).toStdString();
554  te::cl::ROI* roi = m_rs->getROI(label);
555 
556  bool repaint = false;
557 
558  if(roi)
559  {
560  //create a polygon id
561  static boost::uuids::basic_random_generator<boost::mt19937> gen;
562  boost::uuids::uuid u = gen();
563  std::string id = boost::uuids::to_string(u);
564 
565  //add polygon into roi
566  roi->addPolygon(poly, id);
567 
568  //update tree
569  m_sampleCounter ++;
570 
571  QString sampleCounter;
572  sampleCounter.setNum(m_sampleCounter);
573  QString sampleName(tr("Sample"));
574  QString fullName;
575  fullName.append(sampleName);
576  fullName.append(" - ");
577  fullName.append(sampleCounter);
578 
579  QTreeWidgetItem* subItem = new QTreeWidgetItem(item, ROI_POLYGON_TREE_ITEM);
580  subItem->setText(0, fullName);
581  subItem->setData(0, Qt::UserRole, QVariant(id.c_str()));
582  subItem->setIcon(0, QIcon::fromTheme("file-vector"));
583  item->setExpanded(true);
584 
585  int value = item->childCount();
586  if(value == 1)
587  repaint = true;
588 
589  item->addChild(subItem);
590  }
591 
592  if(repaint)
593  m_ui->m_roiSetTreeWidget->repaint();
594 
595  emit roiSetChanged(m_rs);
596 
597  drawROISet();
598 }
599 
601 {
602  if(!m_ui->m_vectorLayerToolButton->isChecked())
603  return;
604 
605  te::qt::widgets::MapDisplay* mapDisplay = m_navigator->getDisplay();
606 
607  int idxLayer = m_ui->m_vectorLayerComboBox->currentIndex();
608  QVariant varLayer = m_ui->m_vectorLayerComboBox->itemData(idxLayer, Qt::UserRole);
609  te::map::AbstractLayerPtr layer = varLayer.value<te::map::AbstractLayerPtr>();
610 
611  //create envelope
612  te::gm::Envelope envelope(x, y, x, y);
613 
614  //reproject rect if needs
615  te::gm::Envelope reprojectedEnvelope(envelope);
616 
617  if((layer->getSRID() != TE_UNKNOWN_SRS) && (mapDisplay->getSRID() != TE_UNKNOWN_SRS) && (layer->getSRID() != mapDisplay->getSRID()))
618  reprojectedEnvelope.transform(mapDisplay->getSRID(), layer->getSRID());
619 
620  if(!reprojectedEnvelope.intersects(layer->getExtent()))
621  return;
622 
623  //get geometries
624  try
625  {
626  // Gets the layer schema
627  std::auto_ptr<const te::map::LayerSchema> schema(layer->getSchema());
628  if(!schema->hasGeom())
629  return;
630 
632 
633  // Gets the dataset
634  std::auto_ptr<te::da::DataSet> dataset = layer->getData(gp->getName(), &reprojectedEnvelope, te::gm::INTERSECTS);
635 
636  // Generates a geometry from the given extent. It will be used to refine the results
637  std::auto_ptr<te::gm::Geometry> geometryFromEnvelope(te::gm::GetGeomFromEnvelope(&reprojectedEnvelope, layer->getSRID()));
638 
639  // The restriction point. It will be used to refine the results
640  te::gm::Coord2D center = reprojectedEnvelope.getCenter();
641  te::gm::Point point(center.x, center.y, layer->getSRID());
642 
643  while(dataset->moveNext())
644  {
645  std::auto_ptr<te::gm::Geometry> g(dataset->getGeometry(gp->getName()));
646 
647  if(g->contains(&point) || g->crosses(geometryFromEnvelope.get()) || geometryFromEnvelope->contains(g.get()))
648  {
649  te::gm::MultiPolygon* mp = (te::gm::MultiPolygon*)dataset->getGeometry(gp->getName()).release();
651 
652  onGeomAquired(p);
653 
654  break;
655  }
656  }
657  }
658  catch(...)
659  {
660  }
661 }
662 
void onROITreItemClicked(QTreeWidgetItem *item, int column)
void onPointPicked(double x, double y)
const Fill * getFill() const
Gets the Fill associates with the PolygonSymbolizer.
#define ROI_POLYGON_TREE_ITEM
MultiPolygon is a MultiSurface whose elements are Polygons.
Definition: MultiPolygon.h:50
Geometric property.
double y
y-coordinate.
Definition: Coord2D.h:114
#define TE_CL_ROI_LABEL_NAME
This mark defines the label attribute name.
Definition: Config.h:52
bool intersects(const Envelope &rhs) const
It returns true if the envelopes "spatially intersects".
Definition: Envelope.h:493
std::auto_ptr< te::qt::widgets::RasterNavigatorWidget > m_navigator
void setList(std::list< te::map::AbstractLayerPtr > &layerList)
This method is used to set the list of layers.
The Style defines the styling that is to be applied to a geographic dataset (vector geometries or cov...
Definition: Style.h:65
This file has the ROIManagerWidget class.
A PolygonSymbolizer is used to draw a polygon (or other area-type geometries), including filling its ...
double x
x-coordinate.
Definition: Coord2D.h:113
A Symbolizer describes how a feature is to appear on a map.
Definition: Symbolizer.h:80
static te::cl::ROISet * createROISet(std::auto_ptr< te::da::DataSet > ds)
Imports the ROISet from a dataset.
Definition: ROISet.cpp:126
double m_urx
Upper right corner x-coordinate.
Definition: Envelope.h:346
void addPolygon(te::gm::Polygon *p, std::string id)
Add a new region into this ROI.
Definition: ROI.cpp:67
A widget to control the display of a set of layers.
Definition: MapDisplay.h:66
An utility struct for representing 2D coordinates.
Definition: Coord2D.h:40
A ROISet is a set of ROI's.
Definition: ROISet.h:53
std::auto_ptr< Ui::ROIManagerWidgetForm > m_ui
Rule * getRule(std::size_t i) const
Definition: Style.cpp:105
Coord2D getCenter() const
It returns the rectangle's center coordinate.
Definition: Envelope.cpp:51
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).
Definition: Canvas.cpp:147
double m_llx
Lower left corner x-coordinate.
Definition: Envelope.h:344
Custom tool button used to pick a color.
A point with x and y coordinate values.
Definition: Point.h:50
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:51
#define TE_UNKNOWN_SRS
A numeric value to represent a unknown SRS identification in TerraLib.
Definition: Config.h:44
virtual int getSRID() const
It return the Spatial Reference System used by the Map Display.
Definition: MapDisplay.cpp:73
GeomType getGeometryType() const
It returns the geometry subtype allowed for the property.
virtual const te::gm::Envelope & getExtent() const
It returns the world extent showned by the MapDisplay.
Definition: MapDisplay.cpp:63
void setOpacity(const std::string &opacity)
Definition: Fill.cpp:71
void set(te::map::AbstractLayerPtr layer)
This method is used to set current layer.
A Fill specifies the pattern for filling an area geometry.
Definition: Fill.h:59
void onGeomAquired(te::gm::Polygon *poly)
void setColor(std::string color)
Set the ROI color using the hexadecimal color name.
Definition: ROI.cpp:52
A region of interest (often abbreviated ROI), is a selected subset of samples within a dataset identi...
Definition: ROI.h:60
Ui::ROIManagerWidgetForm * getForm() const
double m_lly
Lower left corner y-coordinate.
Definition: Envelope.h:345
A canvas built on top of Qt.
Definition: Canvas.h:54
Fill * clone() const
It creates a new copy of this object.
Definition: Fill.cpp:86
void removePolygon(std::string id)
Removes a region from this ROI.
Definition: ROI.cpp:72
Polygon is a subclass of CurvePolygon whose rings are defined by linear rings.
Definition: Polygon.h:50
A Rule is used to attach property/scale conditions to and group the individual symbols used for rende...
Definition: Rule.h:78
virtual QPixmap * getDraftPixmap() const
It returns the map display draft pixmap.
Definition: MapDisplay.cpp:222
double m_ury
Upper right corner y-coordinate.
Definition: Envelope.h:347
This class is used to navigate over a DataSetLayer (having a raster representation) and given a set o...
#define TE_CL_ROI_GEOM_ID_NAME
This mark defines the geom id attribute name.
Definition: Config.h:45
A helper class for 32-bit RGBA (Red-Green-Blue-Alpha channel) color.
Definition: RGBAColor.h:57
std::string toString() const
It returns the data value in a WKT representation.
Definition: Geometry.h:858
const std::vector< Geometry * > & getGeometries() const
It returns a reference to the internal list of geometries.
std::string getLabel()
Get the ROI label.
Definition: ROI.cpp:47
Symbolizer * clone() const
It creates a new copy of this object.
void setFill(Fill *f)
A Fill specifies the pattern for filling an area geometry.
Q_DECLARE_METATYPE(te::map::AbstractLayerPtr)
void setSymbolizer(std::size_t i, Symbolizer *s)
Definition: Rule.cpp:144
#define TE_CL_ROI_COLOR_NAME
This mark defines the color attribute name.
Definition: Config.h:59
TEDATAACCESSEXPORT te::gm::GeometryProperty * GetFirstGeomProperty(const DataSetType *dt)
Definition: Utils.cpp:557
virtual const std::string & getType() const =0
It returns the symbolizer type.
virtual Symbolizer * clone() const =0
It creates a new copy of this object.
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
void transform(int oldsrid, int newsrid)
It will transform the coordinates of the Envelope from the old SRS to the new one.
Definition: Envelope.cpp:92
#define ROI_TREE_ITEM
const Symbolizer * getSymbolizer(std::size_t i) const
Definition: Rule.cpp:163
ROIManagerWidget(QWidget *parent=0, Qt::WindowFlags f=0)
TEGEOMEXPORT Geometry * GetGeomFromEnvelope(const Envelope *const e, int srid)
It creates a Geometry (a polygon) from the given envelope.
Definition: Utils.cpp:38
ColorPickerToolButton * m_colorPicker
std::map< std::string, te::gm::Polygon * > & getPolygons()
Get all polygons belongs to this roi.
Definition: ROI.cpp:62
const std::string & getName() const
It returns the property name.
Definition: Property.h:127
std::string getColor()
Get the ROI color defined by a hexadecimal color name.
Definition: ROI.cpp:57