All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
RasterNavigatorWidget.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/rp/RasterNavigatorWidget.cpp
22 
23  \brief This file has the RasterNavigatorWidget class.
24 */
25 
26 // TerraLib
27 #include "../../../color/RGBAColor.h"
28 #include "../../../dataaccess/dataset/DataSet.h"
29 #include "../../../dataaccess/utils/Utils.h"
30 #include "../../../geometry/Coord2D.h"
31 #include "../../../geometry/Geometry.h"
32 #include "../../../geometry/Point.h"
33 #include "../../../geometry/Utils.h"
34 #include "../../../maptools/Utils.h"
35 #include "../../../raster/Grid.h"
36 #include "../../../raster/Raster.h"
37 #include "../../../se/CoverageStyle.h"
38 #include "../../../se/ChannelSelection.h"
39 #include "../../../se/RasterSymbolizer.h"
40 #include "../../../se/Rule.h"
41 #include "../../../se/SelectedChannel.h"
42 #include "../../../se/Utils.h"
43 #include "../../widgets/tools/AbstractTool.h"
44 #include "../../widgets/tools/CoordTracking.h"
45 #include "../../widgets/tools/ExtentAcquire.h"
46 #include "../../widgets/tools/Pan.h"
47 #include "../../widgets/tools/PolygonAcquire.h"
48 #include "../../widgets/tools/PointPicker.h"
49 #include "../../widgets/tools/ReadPixelTool.h"
50 #include "../../widgets/tools/ZoomArea.h"
51 #include "../../widgets/tools/ZoomClick.h"
52 #include "../../widgets/tools/ZoomWheel.h"
53 #include "../canvas/Canvas.h"
54 #include "../canvas/EyeBirdMapDisplayWidget.h"
55 #include "../canvas/MultiThreadMapDisplay.h"
56 #include "../canvas/ZoomInMapDisplayWidget.h"
57 #include "RasterNavigatorWidget.h"
58 #include "ui_RasterNavigatorWidgetForm.h"
59 
60 //STL
61 #include <memory>
62 
63 
65  : QWidget(parent, f),
66  m_ui(new Ui::RasterNavigatorWidgetForm),
67  m_symbolizer(0),
68  m_tool(0), m_panTool(0), m_zoomTool(0)
69 {
70  m_ui->setupUi(this);
71 
72 //build form
73  QGridLayout* displayLayout = new QGridLayout(m_ui->m_frame);
74  m_mapDisplay = new te::qt::widgets::MultiThreadMapDisplay(m_ui->m_frame->size(), m_ui->m_frame);
76  displayLayout->addWidget(m_mapDisplay);
77  displayLayout->setContentsMargins(0,0,0,0);
78 
79  QGridLayout* eyeBirdDisplayLayout = new QGridLayout(m_ui->m_eyeBirdFrame);
81  eyeBirdDisplayLayout->addWidget(m_eyeBirdMapDisplay);
82  eyeBirdDisplayLayout->setContentsMargins(0,0,0,0);
83 
84  QGridLayout* zoomInDisplayLayout = new QGridLayout(m_ui->m_zoomInFrame);
86  zoomInDisplayLayout->addWidget(m_zoomInMapDisplay);
87  zoomInDisplayLayout->setContentsMargins(0,0,0,0);
88 
89  m_pointCursor = Qt::CrossCursor;
90 
91 // CoordTracking tool
93  m_mapDisplay->installEventFilter(coordTracking);
94 
95 // signals & slots
96  connect(m_ui->m_previewToolButton, SIGNAL(clicked()), this, SLOT(onPreviewClicked()));
97 
98  connect(m_ui->m_zoomInActionToolButtontoolButton, SIGNAL(toggled(bool)), this, SLOT(onZoomAreaToggled(bool)));
99  connect(m_ui->m_zoomOutActionToolButtontoolButton, SIGNAL(toggled(bool)), this, SLOT(onZoomOutToggled(bool)));
100  connect(m_ui->m_panActionToolButtontoolButton, SIGNAL(toggled(bool)), this, SLOT(onPanToggled(bool)));
101  connect(m_ui->m_pointActionToolButtontoolButton, SIGNAL(toggled(bool)), this, SLOT(onPointPickerToggled(bool)));
102  connect(m_ui->m_geomActionToolButtontoolButton, SIGNAL(toggled(bool)), this, SLOT(onGeomToggled(bool)));
103  connect(m_ui->m_extentActionToolButtontoolButton, SIGNAL(toggled(bool)), this, SLOT(onBoxToggled(bool)));
104  connect(m_ui->m_readPixelActionToolButton, SIGNAL(toggled(bool)), this, SLOT(onReadPixelToggled(bool)));
105  connect(m_ui->m_extraDisplaysToolButton, SIGNAL(toggled(bool)), this, SLOT(onExtraDisplaysToggled(bool)));
106  connect(m_ui->m_recomposeActionToolButton, SIGNAL(clicked()), this, SLOT(onRecomposeClicked()));
107 
108  connect(m_ui->m_redComboBox, SIGNAL(activated(int)), this, SLOT(onRedComboBoxActivated(int)));
109  connect(m_ui->m_greenComboBox, SIGNAL(activated(int)), this, SLOT(onGreenComboBoxActivated(int)));
110  connect(m_ui->m_blueComboBox, SIGNAL(activated(int)), this, SLOT(onBlueComboBoxActivated(int)));
111  connect(m_ui->m_monoComboBox, SIGNAL(activated(int)), this, SLOT(onMonoComboBoxActivated(int)));
112  connect(m_ui->m_monoToolButton, SIGNAL(clicked(bool)), this, SLOT(onMonoToolClicked(bool)));
113  connect(m_ui->m_compositionToolButton, SIGNAL(clicked(bool)), this, SLOT(onCompositionToolClicked(bool)));
114  connect(m_ui->m_redToolButton, SIGNAL(clicked(bool)), this, SLOT(onRedToolClicked(bool)));
115  connect(m_ui->m_greenToolButton, SIGNAL(clicked(bool)), this, SLOT(onGreenToolClicked(bool)));
116  connect(m_ui->m_blueToolButton, SIGNAL(clicked(bool)), this, SLOT(onBlueToolClicked(bool)));
117 
118  connect(coordTracking, SIGNAL(coordTracked(QPointF&)), this, SLOT(onCoordTrackedChanged(QPointF&)));
119  connect(m_mapDisplay, SIGNAL(extentChanged()), this, SLOT(onMapDisplayExtentChanged()));
120 
121 //pixmap
122  m_ui->m_previewToolButton->setIcon(QIcon::fromTheme("check"));
123  m_ui->m_zoomInActionToolButtontoolButton->setIcon(QIcon::fromTheme("zoom-area"));
124  m_ui->m_zoomOutActionToolButtontoolButton->setIcon(QIcon::fromTheme("zoom-out"));
125  m_ui->m_panActionToolButtontoolButton->setIcon(QIcon::fromTheme("pan"));
126  m_ui->m_recomposeActionToolButton->setIcon(QIcon::fromTheme("zoom-extent"));
127  m_ui->m_pointActionToolButtontoolButton->setIcon(QIcon::fromTheme("placemark"));
128  m_ui->m_geomActionToolButtontoolButton->setIcon(QIcon::fromTheme("edit-polygon"));
129  m_ui->m_extentActionToolButtontoolButton->setIcon(QIcon::fromTheme("edit-box"));
130  m_ui->m_readPixelActionToolButton->setIcon(QIcon::fromTheme("color-picker"));
131  m_ui->m_extraDisplaysToolButton->setIcon(QIcon::fromTheme("view-map-display-extra"));
132  m_ui->m_monoLabel->setPixmap(QIcon::fromTheme("bullet-black").pixmap(16,16));
133  m_ui->m_redLabel->setPixmap(QIcon::fromTheme("bullet-red").pixmap(16,16));
134  m_ui->m_greenLabel->setPixmap(QIcon::fromTheme("bullet-green").pixmap(16,16));
135  m_ui->m_blueLabel->setPixmap(QIcon::fromTheme("bullet-blue").pixmap(16,16));
136  m_ui->m_monoToolButton->setIcon(QIcon::fromTheme("channel-gray"));
137  m_ui->m_compositionToolButton->setIcon(QIcon::fromTheme("channels"));
138  m_ui->m_redToolButton->setIcon(QIcon::fromTheme("channel-red"));
139  m_ui->m_greenToolButton->setIcon(QIcon::fromTheme("channel-green"));
140  m_ui->m_blueToolButton->setIcon(QIcon::fromTheme("channel-blue"));
141 
142  m_ui->m_previewToolButton->setVisible(false);
143 
144  onExtraDisplaysToggled(false);
145 }
146 
148 {
149  if(m_layer.get())
150  m_layer->setVisibility(m_visibility);
151 
152  delete m_tool;
153  delete m_panTool;
154  delete m_zoomTool;
155 }
156 
158 {
159  m_layer = layer;
160 
161  m_visibility = m_layer->getVisibility();
162 
163  m_layer->setVisibility(te::map::VISIBLE);
164 
165  std::list<te::map::AbstractLayerPtr> list;
166  list.push_back(m_layer);
167 
168  te::gm::Envelope e = m_layer->getExtent();
169 
170  m_mapDisplay->setMouseTracking(true);
171  m_mapDisplay->setLayerList(list);
172  m_mapDisplay->setSRID(m_layer->getSRID(), false);
173 
174  if(!setFullScaleBox)
175  m_mapDisplay->setExtent(e, false);
176  else
177  {
178  //get raster
179  std::auto_ptr<te::da::DataSet> ds(m_layer->getData());
180  std::size_t rpos = te::da::GetFirstPropertyPos(ds.get(), te::dt::RASTER_TYPE);
181  std::auto_ptr<te::rst::Raster> inputRst = ds->getRaster(rpos);
182 
183  //calculate extent full scale
184  int w = m_mapDisplay->getWidth();
185  int h = m_mapDisplay->getHeight();
186  double resX = inputRst->getResolutionX();
187  double resY = inputRst->getResolutionY();
188  te::gm::Coord2D cc(inputRst->getExtent()->getCenter().x, inputRst->getExtent()->getCenter().y);
189  te::gm::Coord2D bowerLeftWorld(cc.x - (resX * ( w / 2 )), cc.y - (resY * ( h / 2 )));
190  te::gm::Coord2D bowerUpperWorld(cc.x + (resX * ( w / 2 )), cc.y + (resY * ( h / 2 )));
191 
192  te::gm::Envelope env(bowerLeftWorld.x, bowerLeftWorld.y, bowerUpperWorld.x, bowerUpperWorld.y);
193 
194  m_mapDisplay->setExtent(env, false);
195  }
196 
197  m_zoomInMapDisplay->setList(list, m_layer->getSRID());
198  m_eyeBirdMapDisplay->setList(list, m_layer->getSRID());
199 
200 // list bands
201  listBands();
202 
203 // get band composition information
204  getCompositionInfo();
205 }
206 
208 {
209  std::list<te::map::AbstractLayerPtr> list;
210  list.push_back(layer);
211  list.push_back(m_layer);
212 
213  m_mapDisplay->setLayerList(list);
214  m_zoomInMapDisplay->setList(list, m_layer->getSRID());
215  m_eyeBirdMapDisplay->setList(list, m_layer->getSRID());
216 
217  te::gm::Envelope e = m_mapDisplay->getExtent();
218  m_mapDisplay->setExtent(e, true);
219 }
220 
222 {
223  //m_mapDisplay->setExtent(env, true);
224 }
225 
227 {
228  std::list<te::map::AbstractLayerPtr> list;
229  list.push_back(m_layer);
230 
231  m_mapDisplay->setLayerList(list);
232  m_zoomInMapDisplay->setList(list, m_layer->getSRID());
233  m_eyeBirdMapDisplay->setList(list, m_layer->getSRID());
234 
235  te::gm::Envelope e = m_mapDisplay->getExtent();
236  m_mapDisplay->setExtent(e, true);
237 }
238 
240 {
241  return m_mapDisplay->getExtent();
242 }
243 
245 {
246  return m_mapDisplay;
247 }
248 
250 {
251  //get box info
252  te::gm::Envelope reprojectedBBOX(m_mapDisplay->getExtent());
253  reprojectedBBOX.transform(m_mapDisplay->getSRID(), m_layer->getSRID());
254  te::gm::Envelope ibbox = reprojectedBBOX.intersection(m_layer->getExtent());
255 
256  //get raster
257  std::auto_ptr<te::da::DataSet> ds(m_layer->getData());
258  std::size_t rpos = te::da::GetFirstPropertyPos(ds.get(), te::dt::RASTER_TYPE);
259  std::auto_ptr<te::rst::Raster> inputRst = ds->getRaster(rpos);
260 
261  te::rst::Raster* raster = 0;
262 
263  if(fullScale)
264  {
265  te::gm::Coord2D startGrid = inputRst->getGrid()->geoToGrid(ibbox.getLowerLeftX(), ibbox.getLowerLeftY());
266  te::gm::Coord2D endGrid = inputRst->getGrid()->geoToGrid(ibbox.getUpperRightX(), ibbox.getUpperRightY());
267 
268  int w = (int)endGrid.x - (int)startGrid.x;
269  int h = (int)startGrid.y - (int)endGrid.y;
270 
271  raster = te::map::GetExtentRaster(inputRst.get(), w, h, reprojectedBBOX, m_mapDisplay->getSRID(), ibbox, m_layer->getSRID());
272  }
273  else
274  {
275  raster = te::map::GetExtentRaster(inputRst.get(), m_mapDisplay->getWidth(), m_mapDisplay->getHeight(), reprojectedBBOX, m_mapDisplay->getSRID(), ibbox, m_layer->getSRID());
276  }
277 
278  return raster;
279 }
280 
282 {
283  const te::gm::Envelope& env = m_mapDisplay->getExtent();
284  const te::gm::Envelope& envRst = *rst->getExtent();
285 
286  QPixmap* draft = m_mapDisplay->getDraftPixmap();
287  draft->fill(Qt::transparent);
288 
289  // Prepares the canvas
290  Canvas canvas(m_mapDisplay->width(), m_mapDisplay->height());
291  canvas.setDevice(draft, false);
292  canvas.setWindow(env.m_llx, env.m_lly, env.m_urx, env.m_ury);
293 
294  bool hasToDelete = false;
295  //style
296  if(!style)
297  {
299 
300  hasToDelete = true;
301  }
302 
303  te::se::CoverageStyle* cs = dynamic_cast<te::se::CoverageStyle*>(style);
304 
305  // Draw raster
306  te::map::DrawRaster(rst, &canvas, env, m_mapDisplay->getSRID(), envRst, rst->getSRID(), cs);
307 
308  if(hasToDelete)
309  delete style;
310 
311  m_mapDisplay->repaint();
312 }
313 
314 void te::qt::widgets::RasterNavigatorWidget::showAsPreview(bool asPreview, bool enableZoom)
315 {
316  delete m_panTool;
317  delete m_zoomTool;
318 
319  m_panTool = 0;
320  m_zoomTool = 0;
321 
322  m_ui->m_toolsFrame->setVisible(!asPreview);
323  m_ui->m_label->setVisible(!asPreview);
324  m_ui->m_previewToolButton->setVisible(asPreview);
325 
326  hideExtraDisplaysTool(asPreview);
327 
328  if(asPreview)
329  {
330  m_panTool = new te::qt::widgets::Pan(m_mapDisplay, Qt::OpenHandCursor, Qt::ClosedHandCursor);
331  m_mapDisplay->installEventFilter(m_panTool);
332 
333  if(enableZoom)
334  {
335  m_zoomTool = new te::qt::widgets::ZoomWheel(m_mapDisplay, 1.5);
336  m_mapDisplay->installEventFilter(m_zoomTool);
337  }
338  }
339 }
340 
342 {
343  m_ui->m_ccFrame->setVisible(!hide);
344 }
345 
347 {
348  m_ui->m_toolLine->setVisible(!hide);
349  hidePickerTool(hide);
350  hideGeomTool(hide);
351  hideBoxTool(hide);
352  hideInfoTool(hide);
353 }
354 
356 {
357  m_ui->m_pointActionToolButtontoolButton->setVisible(!hide);
358 }
359 
361 {
362  m_ui->m_geomActionToolButtontoolButton->setVisible(!hide);
363 }
364 
366 {
367  m_ui->m_extentActionToolButtontoolButton->setVisible(!hide);
368 }
369 
371 {
372  m_ui->m_readPixelActionToolButton->setVisible(!hide);
373 }
374 
376 {
377  m_ui->m_extraDisplaysToolButton->setChecked(false);
378 
379  m_ui->m_extraLine->setVisible(!hide);
380  m_ui->m_extraDisplaysToolButton->setVisible(!hide);
381 }
382 
384 {
385  if(mode)
386  {
387  m_ui->m_pointActionToolButtontoolButton->setIcon(QIcon::fromTheme("pointer-selection"));
388  m_pointCursor = Qt::ArrowCursor;
389  }
390  else
391  {
392  m_ui->m_pointActionToolButtontoolButton->setIcon(QIcon::fromTheme("placemark"));
393  m_pointCursor = Qt::CrossCursor;
394  }
395 }
396 
398 {
399  assert(m_layer.get());
400 
401  if(m_ui->m_extraDisplaysToolButton->isChecked())
402  {
403  //draw cursor position
404  m_zoomInMapDisplay->drawCursorPosition((double) coordinate.rx(), (double)coordinate.ry());
405 
406 
407  //draw zoom in rectangle
408  te::gm::Envelope ext = m_zoomInMapDisplay->getCurrentExtent();
409 
410  m_mapDisplay->getDraftPixmap()->fill(QColor(0, 0, 0, 0));
411  const te::gm::Envelope& mapExt = m_mapDisplay->getExtent();
412  te::qt::widgets::Canvas canvasInstance(m_mapDisplay->getDraftPixmap());
413 
414  canvasInstance.setWindow(mapExt.m_llx, mapExt.m_lly, mapExt.m_urx, mapExt.m_ury);
415  canvasInstance.setPolygonContourColor(te::color::RGBAColor(255,0,0,TE_OPAQUE));
416  canvasInstance.setPolygonFillColor(te::color::RGBAColor(0,0,0,TE_TRANSPARENT));
417 
418  te::gm::Geometry* geom = te::gm::GetGeomFromEnvelope(&ext, m_layer->getSRID());
419  canvasInstance.draw(geom);
420  delete geom;
421 
422  m_mapDisplay->repaint();
423  }
424 
425  //get input raster
426  std::auto_ptr<te::da::DataSet> ds = m_layer->getData();
427 
428  if(ds.get())
429  {
430  std::size_t rpos = te::da::GetFirstPropertyPos(ds.get(), te::dt::RASTER_TYPE);
431  std::auto_ptr<te::rst::Raster> inputRst = ds->getRaster(rpos);
432 
433  if(inputRst.get())
434  {
435  // find the selected pixel location for component
436  te::gm::Coord2D pixelLocation = inputRst->getGrid()->geoToGrid((double) coordinate.rx(), (double)coordinate.ry());
437  m_currentColumn = pixelLocation.x;
438  m_currentRow = pixelLocation.y;
439 
440  QString xStr("X: ");
441  xStr.append(QString::number(coordinate.rx(), 'f', 5));
442  QString yStr("Y: ");
443  yStr.append(QString::number(coordinate.ry(), 'f', 5));
444  QString cStr(tr("Column: "));
445  cStr.append(QString::number(m_currentColumn));
446  QString lStr(tr("Line: "));
447  lStr.append(QString::number(m_currentRow));
448  QString label;
449  label.append(xStr);
450  label.append(" - ");
451  label.append(yStr);
452  label.append(" / ");
453  label.append(cStr);
454  label.append(" - ");
455  label.append(lStr);
456 
457  m_ui->m_label->setText(label);
458  }
459  }
460 }
461 
463 {
464  //emit signal
465  emit envelopeAcquired(env);
466 }
467 
469 {
470  //emit signal
471  emit geomAquired(poly);
472 }
473 
475 {
476  //emit signal
477  emit pointPicked(point.x(), point.y());
478 }
479 
481 {
482  te::gm::Envelope e = m_mapDisplay->getExtent();
483 
484  //emit signal
485  if(e.isValid())
486  emit mapDisplayExtentChanged();
487 }
488 
490 {
491  if(!checked)
492  return;
493 
494  te::qt::widgets::ZoomArea* zoomArea = new te::qt::widgets::ZoomArea(m_mapDisplay, Qt::BlankCursor);
495  setCurrentTool(zoomArea);
496 }
497 
499 {
500  if(!checked)
501  return;
502 
503  te::qt::widgets::ZoomClick* zoomOut = new te::qt::widgets::ZoomClick(m_mapDisplay, Qt::BlankCursor, 2.0, te::qt::widgets::Zoom::Out);
504  setCurrentTool(zoomOut);
505 }
506 
508 {
509  if(!checked)
510  return;
511 
512  te::qt::widgets::Pan* pan = new te::qt::widgets::Pan(m_mapDisplay, Qt::OpenHandCursor, Qt::ClosedHandCursor);
513  setCurrentTool(pan);
514 }
515 
517 {
518  if(!checked)
519  return;
520 
521  te::qt::widgets::PointPicker* pp = new te::qt::widgets::PointPicker(m_mapDisplay, m_pointCursor);
522  setCurrentTool(pp);
523 
524  connect(pp, SIGNAL(pointPicked(QPointF&)), this, SLOT(onPointPicked(QPointF&)));
525 }
526 
528 {
529  if(!checked)
530  return;
531 
533  setCurrentTool(pa);
534 
535  connect(pa, SIGNAL(polygonAquired(te::gm::Polygon*)), this, SLOT(onGeomAquired(te::gm::Polygon*)));
536 }
537 
539 {
540  if(!checked)
541  return;
542 
543  te::qt::widgets::ExtentAcquire* ea = new te::qt::widgets::ExtentAcquire(m_mapDisplay, Qt::BlankCursor);
544  setCurrentTool(ea);
545 
546  connect(ea, SIGNAL(extentAcquired(te::gm::Envelope)), this, SLOT(onEnvelopeAcquired(te::gm::Envelope)));
547 }
548 
550 {
551  if(!checked)
552  return;
553 
554  te::qt::widgets::ReadPixelTool* pa = new te::qt::widgets::ReadPixelTool(m_mapDisplay, m_layer);
555  setCurrentTool(pa);
556 }
557 
559 {
560  m_ui->m_extraDisplaysFrame->setVisible(checked);
561  m_eyeBirdMapDisplay->setEnabled(checked);
562  m_zoomInMapDisplay->setEnabled(checked);
563 }
564 
566 {
567  te::gm::Envelope env = m_layer->getExtent();
568 
569  m_mapDisplay->setExtent(env);
570 
571  //m_eyeBirdMapDisplay->recompose(env);
572 }
573 
575 {
576  std::string name = m_ui->m_redComboBox->itemText(index).toStdString();
577 
578  m_symbolizer->getChannelSelection()->getRedChannel()->setSourceChannelName(name);
579 
580  m_mapDisplay->refresh();
581 }
582 
584 {
585  std::string name = m_ui->m_greenComboBox->itemText(index).toStdString();
586 
587  m_symbolizer->getChannelSelection()->getGreenChannel()->setSourceChannelName(name);
588 
589  m_mapDisplay->refresh();
590 }
591 
593 {
594  std::string name = m_ui->m_blueComboBox->itemText(index).toStdString();
595 
596  m_symbolizer->getChannelSelection()->getBlueChannel()->setSourceChannelName(name);
597 
598  m_mapDisplay->refresh();
599 }
600 
602 {
603  std::string name = m_ui->m_monoComboBox->itemText(index).toStdString();
604 
605  m_symbolizer->getChannelSelection()->getGrayChannel()->setSourceChannelName(name);
606 
607  m_mapDisplay->refresh();
608 }
609 
611 {
612  if(m_symbolizer->getChannelSelection()->getGrayChannel() == 0)
613  {
615  scMono->setSourceChannelName(m_ui->m_monoComboBox->currentText().toStdString());
616  m_symbolizer->getChannelSelection()->setGrayChannel(scMono);
617  }
618 
619  m_symbolizer->getChannelSelection()->setColorCompositionType(te::se::GRAY_COMPOSITION);
620 
621  getCompositionInfo();
622 
623  m_mapDisplay->refresh();
624 }
625 
627 {
628  if(m_symbolizer->getChannelSelection()->getRedChannel() == 0)
629  {
631  scRed->setSourceChannelName(m_ui->m_redComboBox->currentText().toStdString());
632  m_symbolizer->getChannelSelection()->setRedChannel(scRed);
633  }
634 
635  m_symbolizer->getChannelSelection()->setColorCompositionType(te::se::RED_COMPOSITION);
636 
637  getCompositionInfo();
638 
639  m_mapDisplay->refresh();
640 }
641 
643 {
644  if(m_symbolizer->getChannelSelection()->getGreenChannel() == 0)
645  {
647  scGreen->setSourceChannelName(m_ui->m_greenComboBox->currentText().toStdString());
648  m_symbolizer->getChannelSelection()->setGreenChannel(scGreen);
649  }
650 
651  m_symbolizer->getChannelSelection()->setColorCompositionType(te::se::GREEN_COMPOSITION);
652 
653  getCompositionInfo();
654 
655  m_mapDisplay->refresh();
656 }
657 
659 {
660  if(m_symbolizer->getChannelSelection()->getBlueChannel() == 0)
661  {
663  scBlue->setSourceChannelName(m_ui->m_blueComboBox->currentText().toStdString());
664  m_symbolizer->getChannelSelection()->setBlueChannel(scBlue);
665  }
666 
667  m_symbolizer->getChannelSelection()->setColorCompositionType(te::se::BLUE_COMPOSITION);
668 
669  getCompositionInfo();
670 
671  m_mapDisplay->refresh();
672 }
673 
675 {
676  if(m_symbolizer->getChannelSelection()->getRedChannel() == 0)
677  {
679  scRed->setSourceChannelName(m_ui->m_redComboBox->currentText().toStdString());
680  m_symbolizer->getChannelSelection()->setRedChannel(scRed);
681  }
682 
683  if(m_symbolizer->getChannelSelection()->getGreenChannel() == 0)
684  {
686  scGreen->setSourceChannelName(m_ui->m_greenComboBox->currentText().toStdString());
687  m_symbolizer->getChannelSelection()->setGreenChannel(scGreen);
688  }
689 
690  if(m_symbolizer->getChannelSelection()->getBlueChannel() == 0)
691  {
693  scBlue->setSourceChannelName(m_ui->m_blueComboBox->currentText().toStdString());
694  m_symbolizer->getChannelSelection()->setBlueChannel(scBlue);
695  }
696 
697  m_symbolizer->getChannelSelection()->setColorCompositionType(te::se::RGB_COMPOSITION);
698 
699  getCompositionInfo();
700 
701  m_mapDisplay->refresh();
702 }
703 
705 {
706  emit previewClicked();
707 }
708 
710 {
711  delete m_tool;
712  m_tool = tool;
713 
714  m_mapDisplay->installEventFilter(m_tool);
715 }
716 
718 {
719  m_ui->m_redComboBox->clear();
720  m_ui->m_greenComboBox->clear();
721  m_ui->m_blueComboBox->clear();
722  m_ui->m_monoComboBox->clear();
723 
724  std::auto_ptr<te::da::DataSet> ds = m_layer->getData();
725 
726  if(ds.get())
727  {
728  std::size_t rpos = te::da::GetFirstPropertyPos(ds.get(), te::dt::RASTER_TYPE);
729 
730  std::auto_ptr<te::rst::Raster> inputRst = ds->getRaster(rpos);
731 
732  if(inputRst.get())
733  {
734  for(unsigned int i = 0; i < inputRst->getNumberOfBands(); ++i)
735  {
736  m_ui->m_redComboBox->addItem(QString::number(i));
737  m_ui->m_greenComboBox->addItem(QString::number(i));
738  m_ui->m_blueComboBox->addItem(QString::number(i));
739  m_ui->m_monoComboBox->addItem(QString::number(i));
740  }
741  }
742  }
743 }
744 
746 {
747  assert(m_layer);
748 
749  te::se::Style* style = m_layer->getStyle();
750  assert(style);
751 
752 // should I render this style?
753  te::se::CoverageStyle* cs = dynamic_cast<te::se::CoverageStyle*>(style);
754  assert(cs);
755 
756 // get the raster symbolizer
757  std::size_t nRules = cs->getRules().size();
758  assert(nRules >= 1);
759 
760 // for while, consider one rule
761  const te::se::Rule* rule = cs->getRule(0);
762 
763  const std::vector<te::se::Symbolizer*>& symbolizers = rule->getSymbolizers();
764  assert(!symbolizers.empty());
765 
766 // for while, consider one raster symbolizer
767  m_symbolizer = dynamic_cast<te::se::RasterSymbolizer*>(symbolizers[0]);
768  assert(m_symbolizer);
769 
770  if(m_symbolizer->getChannelSelection())
771  {
772  m_ui->m_monoComboBox->setEnabled(false);
773  m_ui->m_redComboBox->setEnabled(false);
774  m_ui->m_greenComboBox->setEnabled(false);
775  m_ui->m_blueComboBox->setEnabled(false);
776 
777  te::se::ChannelSelection* cs = m_symbolizer->getChannelSelection();
778 
780  {
781  m_ui->m_compositionToolButton->setChecked(true);
782 
783  std::string name = cs->getRedChannel()->getSourceChannelName();
784  setComboBoxText(m_ui->m_redComboBox, name);
785  name = cs->getGreenChannel()->getSourceChannelName();
786  setComboBoxText(m_ui->m_greenComboBox, name);
787  name = cs->getBlueChannel()->getSourceChannelName();
788  setComboBoxText(m_ui->m_blueComboBox, name);
789 
790  m_ui->m_redComboBox->setEnabled(true);
791  m_ui->m_greenComboBox->setEnabled(true);
792  m_ui->m_blueComboBox->setEnabled(true);
793  }
795  {
796  m_ui->m_monoToolButton->setChecked(true);
797 
798  std::string name = cs->getGrayChannel()->getSourceChannelName();
799  setComboBoxText(m_ui->m_redComboBox, name);
800 
801  m_ui->m_monoComboBox->setEnabled(true);
802  }
804  {
805  m_ui->m_redToolButton->setChecked(true);
806 
807  std::string name = cs->getRedChannel()->getSourceChannelName();
808  setComboBoxText(m_ui->m_redComboBox, name);
809 
810  m_ui->m_redComboBox->setEnabled(true);
811  }
813  {
814  m_ui->m_greenToolButton->setChecked(true);
815 
816  std::string name = cs->getGreenChannel()->getSourceChannelName();
817  setComboBoxText(m_ui->m_greenComboBox, name);
818 
819  m_ui->m_greenComboBox->setEnabled(true);
820  }
822  {
823  m_ui->m_blueToolButton->setChecked(true);
824 
825  std::string name = cs->getBlueChannel()->getSourceChannelName();
826  setComboBoxText(m_ui->m_blueComboBox, name);
827 
828  m_ui->m_blueComboBox->setEnabled(true);
829  }
830  }
831 }
832 
833 void te::qt::widgets::RasterNavigatorWidget::setComboBoxText(QComboBox* cb, std::string value)
834 {
835  QString name = value.c_str();
836 
837  bool found = false;
838 
839  for(int i = 0; i < cb->count(); ++i)
840  {
841  if(cb->itemText(i) == name)
842  {
843  cb->setCurrentIndex(i);
844  found = true;
845  break;
846  }
847  }
848 
849  if(!found)
850  {
851  cb->addItem(name);
852  cb->setCurrentIndex(cb->count() - 1);
853  }
854 }
void set(te::map::AbstractLayerPtr layer, bool setFullScaleBox=false)
This method is used to set the selected layer.
te::gm::Envelope * getExtent()
Returns the geographic extension of the raster data.
Definition: Raster.cpp:104
This class defines the map display EyeBird, this component is only a specific map that shows the orig...
A selected channel to be display.
This class defines the map display ZoomIn, this component is only a specific map that shows the curre...
void setDevice(QPaintDevice *device, bool takeOwnerShip)
It sets new device as QPrinter.
Definition: Canvas.cpp:2104
double y
y-coordinate.
Definition: Coord2D.h:87
The Style defines the styling that is to be applied to a geographic dataset (vector geometries or cov...
Definition: Style.h:65
te::qt::widgets::MapDisplay * m_mapDisplay
double x
x-coordinate.
Definition: Coord2D.h:86
This class implements a concrete tool to geographic zoom in operation using a boundary rectangle...
Definition: ZoomArea.h:49
The CoverageStyle defines the styling that is to be applied to a subset of Coverage data...
Definition: CoverageStyle.h:45
te::qt::widgets::ZoomInMapDisplayWidget * m_zoomInMapDisplay
const double & getUpperRightX() const
It returns a constant refernce to the x coordinate of the upper right corner.
Definition: Envelope.h:410
TESEEXPORT Style * CreateCoverageStyle(const std::vector< te::rst::BandProperty * > &properties)
Try creates an appropriate coverage style based on given band properties.
Definition: Utils.cpp:299
double m_urx
Upper right corner x-coordinate.
Definition: Envelope.h:346
std::auto_ptr< Ui::RasterNavigatorWidgetForm > m_ui
const double & getLowerLeftY() const
It returns a constant refernce to the y coordinate of the lower left corner.
Definition: Envelope.h:400
SelectedChannel * getRedChannel() const
A widget to control the display of a set of layers.
Definition: MapDisplay.h:65
An utility struct for representing 2D coordinates.
Definition: Coord2D.h:40
SelectedChannel * getBlueChannel() const
const double & getUpperRightY() const
It returns a constant refernce to the x coordinate of the upper right corner.
Definition: Envelope.h:420
This class defines an interface for objects that can receive application events and respond to them...
Definition: AbstractTool.h:62
This class implements a concrete tool to acquire a polygon geometry.
std::string getSourceChannelName() const
This class implements a concrete tool to define a boundary rectangle.
Definition: ExtentAcquire.h:50
Rule * getRule(std::size_t i) const
Definition: Style.cpp:105
const std::vector< Rule * > & getRules() const
Definition: Style.cpp:94
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
This class implements a concrete tool to geographic pan operation.
Definition: Pan.h:49
double m_llx
Lower left corner x-coordinate.
Definition: Envelope.h:344
virtual void setResizePolicy(const ResizePolicy &policy)
Sets the resize policy to this map display.
Definition: MapDisplay.cpp:231
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:51
void setVectorial(te::map::AbstractLayerPtr layer)
An abstract class for raster data strucutures.
Definition: Raster.h:71
#define TE_OPAQUE
For an RGBA color this is the value of the alpha-channel for totally opaque.
Definition: Config.h:39
void setCurrentTool(te::qt::widgets::AbstractTool *tool)
virtual std::size_t getNumberOfBands() const =0
Returns the number of bands (dimension of cells attribute values) in the raster.
ColorCompositionType getColorCompositionType() const
The RasterSymbolizer describes how to render raster/matrix-coverage data (e.g., satellite photos...
This class implements a concrete tool to geographic zoom operation using the mouse click...
Definition: ZoomClick.h:49
This class implements a concrete tool to geographic coordinate tracking on mouse move operation...
Definition: CoordTracking.h:52
void setComboBoxText(QComboBox *cb, std::string value)
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
Definition: Geometry.h:73
te::qt::widgets::EyeBirdMapDisplayWidget * m_eyeBirdMapDisplay
const std::vector< Symbolizer * > & getSymbolizers() const
Definition: Rule.cpp:158
double m_lly
Lower left corner y-coordinate.
Definition: Envelope.h:345
A canvas built on top of Qt.
Definition: Canvas.h:54
int getSRID() const
Returns the raster spatial reference system identifier.
Definition: Raster.cpp:203
SelectedChannel * getGreenChannel() const
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
double m_ury
Upper right corner y-coordinate.
Definition: Envelope.h:347
#define TE_TRANSPARENT
For an RGBA color this is the value of the alpha-channel for totally transparent. ...
Definition: Config.h:46
This class implements a concrete tool to geographic zoom operation using the mouse wheel...
Definition: ZoomWheel.h:49
const double & getLowerLeftX() const
It returns a constant reference to the x coordinate of the lower left corner.
Definition: Envelope.h:390
A helper class for 32-bit RGBA (Red-Green-Blue-Alpha channel) color.
Definition: RGBAColor.h:57
TEMAPEXPORT te::rst::Raster * GetExtentRaster(te::rst::Raster *raster, int w, int h, const te::gm::Envelope &bbox, int bboxSRID, const te::gm::Envelope &visibleArea, int srid)
Definition: Utils.cpp:649
void setSourceChannelName(const std::string &name)
te::qt::widgets::MapDisplay * getDisplay()
This class implements a concrete tool to geographic coordinate picker on mouse click operation...
Definition: PointPicker.h:50
This file has the RasterNavigatorWidget class.
TEDATAACCESSEXPORT std::size_t GetFirstPropertyPos(const te::da::DataSet *dataset, int datatype)
Definition: Utils.cpp:432
Envelope intersection(const Envelope &rhs) const
It returns an envelope that represents the point set intersection with another envelope.
Definition: Envelope.h:543
SelectedChannel * getGrayChannel() const
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:90
void showAsPreview(bool asPreview, bool enableZoom=true)
bool isValid() const
It tells if the rectangle is valid or not.
Definition: Envelope.h:438
A multi thread Qt4 widget to control the display of a set of layers.
RasterNavigatorWidget(QWidget *parent=0, Qt::WindowFlags f=0)
void drawRaster(te::rst::Raster *rst, te::se::Style *style=0)
TEMAPEXPORT void DrawRaster(te::da::DataSetType *type, te::da::DataSourcePtr ds, Canvas *canvas, const te::gm::Envelope &bbox, int bboxSRID, const te::gm::Envelope &visibleArea, int srid, te::se::CoverageStyle *style)
Definition: Utils.cpp:460
TEGEOMEXPORT Geometry * GetGeomFromEnvelope(const Envelope *const e, int srid)
It creates a Geometry (a polygon) from the given envelope.
Definition: Utils.cpp:35
ChannelSelection specifies the false-color channel selection for a multi-spectral raster source (such...
te::rst::Raster * getExtentRaster(bool fullScale=false)