RasterNavigatorWidget.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file terralib/qt/widgets/rp/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 "../../../raster/RasterFactory.h"
38 #include "../../../raster/RasterProperty.h"
39 #include "../../../raster/RasterSummary.h"
40 #include "../../../raster/RasterSummaryManager.h"
41 #include "../../../raster/Utils.h"
42 #include "../../../se/CoverageStyle.h"
43 #include "../../../se/ChannelSelection.h"
44 #include "../../../se/RasterSymbolizer.h"
45 #include "../../../se/Rule.h"
46 #include "../../../se/SelectedChannel.h"
47 #include "../../../se/Utils.h"
48 #include "../../widgets/tools/AbstractTool.h"
49 #include "../../widgets/tools/CoordTracking.h"
50 #include "../../widgets/tools/ExtentAcquire.h"
51 #include "../../widgets/tools/Pan.h"
52 #include "../../widgets/tools/PolygonAcquire.h"
53 #include "../../widgets/tools/PointPicker.h"
54 #include "../../widgets/tools/PointMove.h"
55 #include "../../widgets/tools/ReadPixelTool.h"
56 #include "../../widgets/tools/ZoomArea.h"
57 #include "../../widgets/tools/ZoomClick.h"
58 #include "../../widgets/tools/ZoomWheel.h"
59 #include "../canvas/Canvas.h"
60 #include "../canvas/EyeBirdMapDisplayWidget.h"
61 #include "../canvas/MultiThreadMapDisplay.h"
62 #include "../canvas/ZoomInMapDisplayWidget.h"
63 #include "RasterNavigatorWidget.h"
64 #include "ui_RasterNavigatorWidgetForm.h"
65 
66 //STL
67 #include <memory>
68 
69 
71  : QWidget(parent, f),
72  m_ui(new Ui::RasterNavigatorWidgetForm),
73  m_symbolizer(nullptr),
74  m_tool(nullptr), m_panTool(nullptr), m_zoomTool(nullptr),
75  m_draftOriginal(nullptr)
76 {
77  m_ui->setupUi(this);
78 
79 //build form
80  QGridLayout* displayLayout = new QGridLayout(m_ui->m_frame);
81  m_mapDisplay = new te::qt::widgets::MultiThreadMapDisplay(m_ui->m_frame->size(), m_ui->m_frame);
83  displayLayout->addWidget(m_mapDisplay);
84  displayLayout->setContentsMargins(0,0,0,0);
85 
86  QGridLayout* eyeBirdDisplayLayout = new QGridLayout(m_ui->m_eyeBirdFrame);
88  eyeBirdDisplayLayout->addWidget(m_eyeBirdMapDisplay);
89  eyeBirdDisplayLayout->setContentsMargins(0,0,0,0);
90 
91  QGridLayout* zoomInDisplayLayout = new QGridLayout(m_ui->m_zoomInFrame);
93  zoomInDisplayLayout->addWidget(m_zoomInMapDisplay);
94  zoomInDisplayLayout->setContentsMargins(0,0,0,0);
95 
96  m_pointCursor = Qt::CrossCursor;
97 
98 // CoordTracking tool
100  m_mapDisplay->installEventFilter(coordTracking);
101 
102 // signals & slots
103  connect(m_ui->m_previewToolButton, SIGNAL(clicked()), this, SLOT(onPreviewClicked()));
104 
105  connect(m_ui->m_zoomInActionToolButtontoolButton, SIGNAL(toggled(bool)), this, SLOT(onZoomAreaToggled(bool)));
106  connect(m_ui->m_zoomOutActionToolButtontoolButton, SIGNAL(toggled(bool)), this, SLOT(onZoomOutToggled(bool)));
107  connect(m_ui->m_panActionToolButtontoolButton, SIGNAL(toggled(bool)), this, SLOT(onPanToggled(bool)));
108  connect(m_ui->m_pointActionToolButtontoolButton, SIGNAL(toggled(bool)), this, SLOT(onPointPickerToggled(bool)));
109  connect(m_ui->m_pointMoveActionToolButton, SIGNAL(toggled(bool)), this, SLOT(onPointMoveToggled(bool)));
110  connect(m_ui->m_geomActionToolButtontoolButton, SIGNAL(toggled(bool)), this, SLOT(onGeomToggled(bool)));
111  connect(m_ui->m_extentActionToolButtontoolButton, SIGNAL(toggled(bool)), this, SLOT(onBoxToggled(bool)));
112  connect(m_ui->m_readPixelActionToolButton, SIGNAL(toggled(bool)), this, SLOT(onReadPixelToggled(bool)));
113  connect(m_ui->m_extraDisplaysToolButton, SIGNAL(toggled(bool)), this, SLOT(onExtraDisplaysToggled(bool)));
114  connect(m_ui->m_recomposeActionToolButton, SIGNAL(clicked()), this, SLOT(onRecomposeClicked()));
115 
116  connect(m_ui->m_redComboBox, SIGNAL(activated(int)), this, SLOT(onRedComboBoxActivated(int)));
117  connect(m_ui->m_greenComboBox, SIGNAL(activated(int)), this, SLOT(onGreenComboBoxActivated(int)));
118  connect(m_ui->m_blueComboBox, SIGNAL(activated(int)), this, SLOT(onBlueComboBoxActivated(int)));
119  connect(m_ui->m_monoComboBox, SIGNAL(activated(int)), this, SLOT(onMonoComboBoxActivated(int)));
120  connect(m_ui->m_monoToolButton, SIGNAL(clicked(bool)), this, SLOT(onMonoToolClicked(bool)));
121  connect(m_ui->m_compositionToolButton, SIGNAL(clicked(bool)), this, SLOT(onCompositionToolClicked(bool)));
122  connect(m_ui->m_redToolButton, SIGNAL(clicked(bool)), this, SLOT(onRedToolClicked(bool)));
123  connect(m_ui->m_greenToolButton, SIGNAL(clicked(bool)), this, SLOT(onGreenToolClicked(bool)));
124  connect(m_ui->m_blueToolButton, SIGNAL(clicked(bool)), this, SLOT(onBlueToolClicked(bool)));
125 
126  connect(m_ui->m_verticalSlider, SIGNAL(valueChanged(int)), this, SLOT(onVSliderChanged(int)));
127  connect(m_ui->m_horizontalSlider, SIGNAL(valueChanged(int)), this, SLOT(onHSliderChanged(int)));
128 
129  connect(coordTracking, SIGNAL(coordTracked(QPointF&)), this, SLOT(onCoordTrackedChanged(QPointF&)));
130  connect(m_mapDisplay, SIGNAL(extentChanged()), this, SLOT(onMapDisplayExtentChanged()));
131 
132 //pixmap
133  m_ui->m_previewToolButton->setIcon(QIcon::fromTheme("check"));
134  m_ui->m_zoomInActionToolButtontoolButton->setIcon(QIcon::fromTheme("zoom-area"));
135  m_ui->m_zoomOutActionToolButtontoolButton->setIcon(QIcon::fromTheme("zoom-out"));
136  m_ui->m_panActionToolButtontoolButton->setIcon(QIcon::fromTheme("pan"));
137  m_ui->m_recomposeActionToolButton->setIcon(QIcon::fromTheme("zoom-extent"));
138  m_ui->m_pointActionToolButtontoolButton->setIcon(QIcon::fromTheme("placemark"));
139  m_ui->m_geomActionToolButtontoolButton->setIcon(QIcon::fromTheme("edit-polygon"));
140  m_ui->m_extentActionToolButtontoolButton->setIcon(QIcon::fromTheme("edit-box"));
141  m_ui->m_readPixelActionToolButton->setIcon(QIcon::fromTheme("color-picker"));
142  m_ui->m_extraDisplaysToolButton->setIcon(QIcon::fromTheme("view-map-display-extra"));
143  m_ui->m_monoLabel->setPixmap(QIcon::fromTheme("bullet-black").pixmap(16,16));
144  m_ui->m_redLabel->setPixmap(QIcon::fromTheme("bullet-red").pixmap(16,16));
145  m_ui->m_greenLabel->setPixmap(QIcon::fromTheme("bullet-green").pixmap(16,16));
146  m_ui->m_blueLabel->setPixmap(QIcon::fromTheme("bullet-blue").pixmap(16,16));
147  m_ui->m_monoToolButton->setIcon(QIcon::fromTheme("channel-gray"));
148  m_ui->m_compositionToolButton->setIcon(QIcon::fromTheme("channels"));
149  m_ui->m_redToolButton->setIcon(QIcon::fromTheme("channel-red"));
150  m_ui->m_greenToolButton->setIcon(QIcon::fromTheme("channel-green"));
151  m_ui->m_blueToolButton->setIcon(QIcon::fromTheme("channel-blue"));
152 
153  m_ui->m_pointMoveActionToolButton->setIcon(QIcon::fromTheme("move_placemark"));
154 
155  //hide preview options
156  m_ui->m_previewToolButton->setVisible(false);
157  m_ui->m_horizontalSlider->setVisible(false);
158  m_ui->m_verticalSlider->setVisible(false);
159 
160  onExtraDisplaysToggled(false);
161 }
162 
164 {
165  if(m_layer.get())
166  m_layer->setVisibility(m_visibility);
167 
168  delete m_tool;
169  delete m_panTool;
170  delete m_zoomTool;
171  delete m_draftOriginal;
172 
173  m_points.release();
174 
175 }
176 
178 {
179  m_layer = layer;
180 
181  m_visibility = m_layer->getVisibility();
182 
183  m_layer->setVisibility(te::map::VISIBLE);
184 
185  std::list<te::map::AbstractLayerPtr> list;
186  list.push_back(m_layer);
187 
188  te::gm::Envelope e = m_layer->getExtent();
189 
190  m_mapDisplay->setMouseTracking(true);
191  m_mapDisplay->setLayerList(list);
192  m_mapDisplay->setSRID(m_layer->getSRID(), false);
193 
194  if(!setFullScaleBox)
195  m_mapDisplay->setExtent(e, false);
196  else
197  {
198  //get raster
199  std::unique_ptr<te::da::DataSet> ds(m_layer->getData());
200  std::size_t rpos = te::da::GetFirstPropertyPos(ds.get(), te::dt::RASTER_TYPE);
201  std::unique_ptr<te::rst::Raster> inputRst = ds->getRaster(rpos);
202 
203  //calculate extent full scale
204  int w = m_mapDisplay->getWidth();
205  int h = m_mapDisplay->getHeight();
206  double resX = inputRst->getResolutionX();
207  double resY = inputRst->getResolutionY();
208  te::gm::Coord2D cc(inputRst->getExtent()->getCenter().x, inputRst->getExtent()->getCenter().y);
209  te::gm::Coord2D bowerLeftWorld(cc.x - (resX * ( w / 2 )), cc.y - (resY * ( h / 2 )));
210  te::gm::Coord2D bowerUpperWorld(cc.x + (resX * ( w / 2 )), cc.y + (resY * ( h / 2 )));
211 
212  te::gm::Envelope env(bowerLeftWorld.x, bowerLeftWorld.y, bowerUpperWorld.x, bowerUpperWorld.y);
213 
214  m_mapDisplay->setExtent(env, false);
215  }
216 
217  m_zoomInMapDisplay->setList(list, m_layer->getSRID());
218  m_eyeBirdMapDisplay->setList(list, m_layer->getSRID());
219 
220 // list bands
221  listBands();
222 
223 // get band composition information
225 }
226 
228 {
229  std::list<te::map::AbstractLayerPtr> list;
230  list.push_back(layer);
231  list.push_back(m_layer);
232 
233  m_mapDisplay->setLayerList(list);
234  m_zoomInMapDisplay->setList(list, m_layer->getSRID());
235  m_eyeBirdMapDisplay->setList(list, m_layer->getSRID());
236 
238  m_mapDisplay->setExtent(e, true);
239 }
240 
242 {
243  //m_mapDisplay->setExtent(env, true);
244 }
245 
247 {
248  std::list<te::map::AbstractLayerPtr> list;
249  list.push_back(m_layer);
250 
251  m_mapDisplay->setLayerList(list);
252  m_zoomInMapDisplay->setList(list, m_layer->getSRID());
253  m_eyeBirdMapDisplay->setList(list, m_layer->getSRID());
254 
256  m_mapDisplay->setExtent(e, true);
257 }
258 
260 {
261  return m_mapDisplay->getExtent();
262 }
263 
265 {
266  return m_mapDisplay;
267 }
268 
270 {
271  //get box info
272  te::gm::Envelope reprojectedBBOX(m_mapDisplay->getExtent());
273  reprojectedBBOX.transform(m_mapDisplay->getSRID(), m_layer->getSRID());
274  te::gm::Envelope ibbox = reprojectedBBOX.intersection(m_layer->getExtent());
275 
276  //get raster
277  std::unique_ptr<te::da::DataSet> ds(m_layer->getData());
278  std::size_t rpos = te::da::GetFirstPropertyPos(ds.get(), te::dt::RASTER_TYPE);
279  std::unique_ptr<te::rst::Raster> inputRst = ds->getRaster(rpos);
280 
281  te::rst::Raster* raster = nullptr;
282 
283  if(fullScale)
284  {
285  te::gm::Coord2D startGrid = inputRst->getGrid()->geoToGrid(ibbox.getLowerLeftX(), ibbox.getLowerLeftY());
286  te::gm::Coord2D endGrid = inputRst->getGrid()->geoToGrid(ibbox.getUpperRightX(), ibbox.getUpperRightY());
287 
288  int w = (int)endGrid.x - (int)startGrid.x;
289  int h = (int)startGrid.y - (int)endGrid.y;
290 
291  raster = te::map::GetExtentRaster(inputRst.get(), w, h, reprojectedBBOX, m_mapDisplay->getSRID(), ibbox, m_layer->getSRID());
292  }
293  else
294  {
295  raster = te::map::GetExtentRaster(inputRst.get(), m_mapDisplay->getWidth(), m_mapDisplay->getHeight(), reprojectedBBOX, m_mapDisplay->getSRID(), ibbox, m_layer->getSRID());
296  }
297 
298  return raster;
299 }
300 
302 {
303  const te::gm::Envelope& env = m_mapDisplay->getExtent();
304  const te::gm::Envelope& envRst = *rst->getExtent();
305 
306  QPixmap* draft = m_mapDisplay->getDraftPixmap();
307  draft->fill(Qt::transparent);
308 
309  // Prepares the canvas
310  Canvas canvas(m_mapDisplay->width(), m_mapDisplay->height());
311  canvas.setDevice(draft, false);
312  canvas.setWindow(env.m_llx, env.m_lly, env.m_urx, env.m_ury);
313 
314  bool hasToDelete = false;
315  //style
316  if(!style)
317  {
319 
320  hasToDelete = true;
321  }
322 
323  te::se::CoverageStyle* cs = dynamic_cast<te::se::CoverageStyle*>(style);
324 
325  for (std::size_t b = 0; b < rst->getNumberOfBands(); ++b)
326  {
329  const std::complex<double>* cmin = rsMin->at(b).m_minVal;
330  const std::complex<double>* cmax = rsMax->at(b).m_maxVal;
331  double min = cmin->real();
332  double max = cmax->real();
333 
334  rst->getBand(static_cast<unsigned long>(b))->getProperty()->m_min = min;
335  rst->getBand(static_cast<unsigned long>(b))->getProperty()->m_max = max;
336  }
337 
338  // Draw raster
339  bool cancel = false;
340  te::map::DrawRaster(rst, &canvas, env, m_mapDisplay->getSRID(), envRst, rst->getSRID(), cs, nullptr, m_mapDisplay->getScale(), &cancel);
341 
342  if(m_draftOriginal)
343  delete m_draftOriginal;
344 
345  m_draftOriginal = new QPixmap(*m_mapDisplay->getDraftPixmap());
346 
347  if(hasToDelete)
348  delete style;
349 
350  //update slide bars
351 
352  disconnect(m_ui->m_verticalSlider, SIGNAL(valueChanged(int)), this, SLOT(onVSliderChanged(int)));
353  disconnect(m_ui->m_horizontalSlider, SIGNAL(valueChanged(int)), this, SLOT(onHSliderChanged(int)));
354 
355  m_ui->m_horizontalSlider->setMaximum(m_mapDisplay->getWidth() - 1);
356  m_ui->m_horizontalSlider->setValue(m_mapDisplay->getWidth() - 1);
357  m_ui->m_verticalSlider->setMaximum(m_mapDisplay->getHeight() - 1);
358  m_ui->m_verticalSlider->setValue(m_mapDisplay->getHeight() - 1);
359 
360  connect(m_ui->m_verticalSlider, SIGNAL(valueChanged(int)), this, SLOT(onVSliderChanged(int)));
361  connect(m_ui->m_horizontalSlider, SIGNAL(valueChanged(int)), this, SLOT(onHSliderChanged(int)));
362 
363  m_mapDisplay->repaint();
364 }
365 
366 void te::qt::widgets::RasterNavigatorWidget::showAsPreview(bool asPreview, bool enableZoom)
367 {
368  delete m_panTool;
369  delete m_zoomTool;
370 
371  m_panTool = nullptr;
372  m_zoomTool = nullptr;
373 
374  m_ui->m_toolsFrame->setVisible(!asPreview);
375  m_ui->m_label->setVisible(!asPreview);
376  m_ui->m_previewToolButton->setVisible(asPreview);
377 
378  m_ui->m_horizontalSlider->setVisible(asPreview);
379  m_ui->m_verticalSlider->setVisible(asPreview);
380 
381  hideExtraDisplaysTool(asPreview);
382 
383  if(asPreview)
384  {
385  m_panTool = new te::qt::widgets::Pan(m_mapDisplay, Qt::OpenHandCursor, Qt::ClosedHandCursor);
386  m_mapDisplay->installEventFilter(m_panTool);
387 
388  if(enableZoom)
389  {
391  m_mapDisplay->installEventFilter(m_zoomTool);
392  }
393  }
394 }
395 
397 {
398  m_ui->m_ccFrame->setVisible(!hide);
399 }
400 
402 {
403  m_ui->m_toolLine->setVisible(!hide);
404  hidePickerTool(hide);
405  hideGeomTool(hide);
406  hideBoxTool(hide);
407  hideInfoTool(hide);
408 }
409 
411 {
412  m_ui->m_pointActionToolButtontoolButton->setVisible(!hide);
413 }
414 
416 {
417  m_ui->m_geomActionToolButtontoolButton->setVisible(!hide);
418 }
419 
421 {
422  m_ui->m_extentActionToolButtontoolButton->setVisible(!hide);
423 }
424 
426 {
427  m_ui->m_readPixelActionToolButton->setVisible(!hide);
428 }
429 
431 {
432  m_ui->m_extraDisplaysToolButton->setChecked(false);
433 
434  m_ui->m_extraLine->setVisible(!hide);
435  m_ui->m_extraDisplaysToolButton->setVisible(!hide);
436 }
437 
439 {
440  if(mode)
441  {
442  m_ui->m_pointActionToolButtontoolButton->setIcon(QIcon::fromTheme("pointer-selection"));
443  m_pointCursor = Qt::ArrowCursor;
444  }
445  else
446  {
447  m_ui->m_pointActionToolButtontoolButton->setIcon(QIcon::fromTheme("placemark"));
448  m_pointCursor = Qt::CrossCursor;
449  }
450 }
451 
453 {
454  assert(m_layer.get());
455 
456  if(m_ui->m_extraDisplaysToolButton->isChecked())
457  {
458  //draw cursor position
459  m_zoomInMapDisplay->drawCursorPosition((double) coordinate.rx(), (double)coordinate.ry());
460 
461 
462  ////draw zoom in rectangle
463  //te::gm::Envelope ext = m_zoomInMapDisplay->getCurrentExtent();
464 
465  //m_mapDisplay->getDraftPixmap()->fill(QColor(0, 0, 0, 0));
466  //const te::gm::Envelope& mapExt = m_mapDisplay->getExtent();
467  //te::qt::widgets::Canvas canvasInstance(m_mapDisplay->getDraftPixmap());
468 
469  //canvasInstance.setWindow(mapExt.m_llx, mapExt.m_lly, mapExt.m_urx, mapExt.m_ury);
470  //canvasInstance.setPolygonContourColor(te::color::RGBAColor(255,0,0,TE_OPAQUE));
471  //canvasInstance.setPolygonFillColor(te::color::RGBAColor(0,0,0,TE_TRANSPARENT));
472 
473  //te::gm::Geometry* geom = te::gm::GetGeomFromEnvelope(&ext, m_layer->getSRID());
474  //canvasInstance.draw(geom);
475  //delete geom;
476 
477  //m_mapDisplay->repaint();
478  }
479 
480  //get input raster
481  std::unique_ptr<te::da::DataSet> ds = m_layer->getData();
482 
483  if(ds.get())
484  {
485  std::size_t rpos = te::da::GetFirstPropertyPos(ds.get(), te::dt::RASTER_TYPE);
486  std::unique_ptr<te::rst::Raster> inputRst = ds->getRaster(rpos);
487 
488  if(inputRst.get())
489  {
490  // find the selected pixel location for component
491  te::gm::Coord2D pixelLocation = inputRst->getGrid()->geoToGrid((double) coordinate.rx(), (double)coordinate.ry());
492  m_currentColumn = pixelLocation.x;
493  m_currentRow = pixelLocation.y;
494 
495  QString xStr("X: ");
496  xStr.append(QString::number(coordinate.rx(), 'f', 5));
497  QString yStr("Y: ");
498  yStr.append(QString::number(coordinate.ry(), 'f', 5));
499  QString cStr(tr("Column: "));
500  cStr.append(QString::number(m_currentColumn));
501  QString lStr(tr("Line: "));
502  lStr.append(QString::number(m_currentRow));
503  QString label;
504  label.append(xStr);
505  label.append(" - ");
506  label.append(yStr);
507  label.append(" / ");
508  label.append(cStr);
509  label.append(" - ");
510  label.append(lStr);
511 
512  m_ui->m_label->setText(label);
513  }
514  }
515 }
516 
518 {
519  //emit signal
520  emit envelopeAcquired(env);
521 }
522 
524 {
525  //emit signal
526  emit geomAquired(poly);
527 }
528 
530 {
531  //emit signal
532  emit pointPicked(point.x(), point.y());
533 }
534 
536 {
537  onCoordTrackedChanged(point);
538 }
539 
540 void te::qt::widgets::RasterNavigatorWidget::onPointMoved(QPointF& pointoriginal, QPointF& pointnew)
541 {
542  //emit signal
543  emit pointMoved(pointoriginal.x(), pointoriginal.y(), pointnew.x(), pointnew.y());
544 }
545 
547 {
549 
550  //emit signal
551  if(e.isValid())
553 
554  delete m_draftOriginal;
555  m_draftOriginal = nullptr;
556 }
557 
559 {
560  if(!checked)
561  return;
562 
563  QCursor zoomAreaCursor(QIcon::fromTheme("zoom-in").pixmap(QSize(20, 20)));
564 
565  te::qt::widgets::ZoomArea* zoomArea = new te::qt::widgets::ZoomArea(m_mapDisplay, zoomAreaCursor);
566  setCurrentTool(zoomArea);
567 }
568 
570 {
571  if(!checked)
572  return;
573 
574  QCursor zoomOutCursor(QIcon::fromTheme("zoom-out").pixmap(QSize(20, 20)));
575 
577  setCurrentTool(zoomOut);
578 }
579 
581 {
582  if(!checked)
583  return;
584 
585  te::qt::widgets::Pan* pan = new te::qt::widgets::Pan(m_mapDisplay, Qt::OpenHandCursor, Qt::ClosedHandCursor);
586  setCurrentTool(pan);
587 }
588 
590 {
591  if(!checked)
592  return;
593 
595  setCurrentTool(pp);
596 
597  connect(pp, SIGNAL(pointPicked(QPointF&)), this, SLOT(onPointPicked(QPointF&)));
598  connect(pp, SIGNAL(pointPickerMoving(QPointF&)), this, SLOT(onPointMoving(QPointF&)));
599 }
600 
602 {
603  if (!checked)
604  return;
605 
606  QCursor pointMoveCursor(QIcon::fromTheme("pointer_move_cursor").pixmap(QSize(20, 20)),0,0);
607 
609  setCurrentTool(pp);
610 
611  connect(pp, SIGNAL(pointMoved(QPointF&,QPointF&)), this, SLOT(onPointMoved(QPointF&,QPointF&)));
612  connect(pp, SIGNAL(pointMoveMoving(QPointF&)), this, SLOT(onPointMoving(QPointF&)));
613 }
614 
616 {
617  if(!checked)
618  return;
619 
621  setCurrentTool(pa);
622 
623  connect(pa, SIGNAL(polygonAquired(te::gm::Polygon*)), this, SLOT(onGeomAquired(te::gm::Polygon*)));
624 }
625 
627 {
628  if(!checked)
629  return;
630 
632  setCurrentTool(ea);
633 
634  connect(ea, SIGNAL(extentAcquired(te::gm::Envelope)), this, SLOT(onEnvelopeAcquired(te::gm::Envelope)));
635 }
636 
638 {
639  if(!checked)
640  return;
641 
643  setCurrentTool(pa);
644 }
645 
647 {
648  m_ui->m_extraDisplaysFrame->setVisible(checked);
650  m_zoomInMapDisplay->setEnabled(checked);
651 }
652 
654 {
655  te::gm::Envelope env = m_layer->getExtent();
656 
657  m_mapDisplay->setExtent(env);
658 
659  //m_eyeBirdMapDisplay->recompose(env);
660 }
661 
663 {
664  std::string name = m_ui->m_redComboBox->itemText(index).toUtf8().data();
665 
667 
669 }
670 
672 {
673  std::string name = m_ui->m_greenComboBox->itemText(index).toUtf8().data();
674 
676 
678 }
679 
681 {
682  std::string name = m_ui->m_blueComboBox->itemText(index).toUtf8().data();
683 
685 
687 }
688 
690 {
691  std::string name = m_ui->m_monoComboBox->itemText(index).toUtf8().data();
692 
694 
696 }
697 
699 {
700  if(m_symbolizer->getChannelSelection()->getGrayChannel() == nullptr)
701  {
703  scMono->setSourceChannelName(m_ui->m_monoComboBox->currentText().toUtf8().data());
705  }
706 
708 
710 
712 }
713 
715 {
716  if(m_symbolizer->getChannelSelection()->getRedChannel() == nullptr)
717  {
719  scRed->setSourceChannelName(m_ui->m_redComboBox->currentText().toUtf8().data());
721  }
722 
724 
726 
728 }
729 
731 {
733  {
735  scGreen->setSourceChannelName(m_ui->m_greenComboBox->currentText().toUtf8().data());
737  }
738 
740 
742 
744 }
745 
747 {
748  if(m_symbolizer->getChannelSelection()->getBlueChannel() == nullptr)
749  {
751  scBlue->setSourceChannelName(m_ui->m_blueComboBox->currentText().toUtf8().data());
753  }
754 
756 
758 
760 }
761 
763  bool /*flag*/)
764 {
765  if(m_symbolizer->getChannelSelection()->getRedChannel() == nullptr)
766  {
768  scRed->setSourceChannelName(m_ui->m_redComboBox->currentText().toUtf8().data());
770  }
771 
773  {
775  scGreen->setSourceChannelName(m_ui->m_greenComboBox->currentText().toUtf8().data());
777  }
778 
779  if(m_symbolizer->getChannelSelection()->getBlueChannel() == nullptr)
780  {
782  scBlue->setSourceChannelName(m_ui->m_blueComboBox->currentText().toUtf8().data());
784  }
785 
787 
789 
791 }
792 
794 {
795  emit previewClicked();
796 }
797 
799 {
800  drawOverlay();
801 }
802 
804 {
805  drawOverlay();
806 }
807 
809 {
810  if (m_tool != nullptr)
811  delete m_tool;
812  m_tool = tool;
813 
814  m_mapDisplay->installEventFilter(m_tool);
815 }
816 
818 {
819  m_ui->m_redComboBox->clear();
820  m_ui->m_greenComboBox->clear();
821  m_ui->m_blueComboBox->clear();
822  m_ui->m_monoComboBox->clear();
823 
824  std::unique_ptr<te::da::DataSet> ds = m_layer->getData();
825 
826  if(ds.get())
827  {
828  std::size_t rpos = te::da::GetFirstPropertyPos(ds.get(), te::dt::RASTER_TYPE);
829 
830  std::unique_ptr<te::rst::Raster> inputRst = ds->getRaster(rpos);
831 
832  if(inputRst.get())
833  {
834  for(unsigned int i = 0; i < inputRst->getNumberOfBands(); ++i)
835  {
836  m_ui->m_redComboBox->addItem(QString::number(i));
837  m_ui->m_greenComboBox->addItem(QString::number(i));
838  m_ui->m_blueComboBox->addItem(QString::number(i));
839  m_ui->m_monoComboBox->addItem(QString::number(i));
840  }
841  }
842  }
843 }
844 
846 {
847  assert(m_layer);
848 
849  te::se::Style* style = m_layer->getStyle();
850  assert(style);
851 
852 // should I render this style?
853  te::se::CoverageStyle* cs = dynamic_cast<te::se::CoverageStyle*>(style);
854  assert(cs);
855 
856  // for while, consider one rule
857  const te::se::Rule* rule = cs->getRule(0);
858 
859  const std::vector<te::se::Symbolizer*>& symbolizers = rule->getSymbolizers();
860  assert(!symbolizers.empty());
861 
862 // for while, consider one raster symbolizer
863  m_symbolizer = dynamic_cast<te::se::RasterSymbolizer*>(symbolizers[0]);
864  assert(m_symbolizer);
865 
866  if(m_symbolizer->getChannelSelection())
867  {
868  m_ui->m_monoComboBox->setEnabled(false);
869  m_ui->m_redComboBox->setEnabled(false);
870  m_ui->m_greenComboBox->setEnabled(false);
871  m_ui->m_blueComboBox->setEnabled(false);
872 
873  te::se::ChannelSelection* cs = m_symbolizer->getChannelSelection();
874 
876  {
877  m_ui->m_compositionToolButton->setChecked(true);
878 
879  std::string name = cs->getRedChannel()->getSourceChannelName();
880  setComboBoxText(m_ui->m_redComboBox, name);
881  name = cs->getGreenChannel()->getSourceChannelName();
882  setComboBoxText(m_ui->m_greenComboBox, name);
883  name = cs->getBlueChannel()->getSourceChannelName();
884  setComboBoxText(m_ui->m_blueComboBox, name);
885 
886  m_ui->m_redComboBox->setEnabled(true);
887  m_ui->m_greenComboBox->setEnabled(true);
888  m_ui->m_blueComboBox->setEnabled(true);
889  }
891  {
892  m_ui->m_monoToolButton->setChecked(true);
893 
894  std::string name = cs->getGrayChannel()->getSourceChannelName();
895  setComboBoxText(m_ui->m_redComboBox, name);
896 
897  m_ui->m_monoComboBox->setEnabled(true);
898  }
900  {
901  m_ui->m_redToolButton->setChecked(true);
902 
903  std::string name = cs->getRedChannel()->getSourceChannelName();
904  setComboBoxText(m_ui->m_redComboBox, name);
905 
906  m_ui->m_redComboBox->setEnabled(true);
907  }
909  {
910  m_ui->m_greenToolButton->setChecked(true);
911 
912  std::string name = cs->getGreenChannel()->getSourceChannelName();
913  setComboBoxText(m_ui->m_greenComboBox, name);
914 
915  m_ui->m_greenComboBox->setEnabled(true);
916  }
918  {
919  m_ui->m_blueToolButton->setChecked(true);
920 
921  std::string name = cs->getBlueChannel()->getSourceChannelName();
922  setComboBoxText(m_ui->m_blueComboBox, name);
923 
924  m_ui->m_blueComboBox->setEnabled(true);
925  }
926  }
927 }
928 
929 void te::qt::widgets::RasterNavigatorWidget::setComboBoxText(QComboBox* cb, std::string value)
930 {
931  QString name = value.c_str();
932 
933  bool found = false;
934 
935  for(int i = 0; i < cb->count(); ++i)
936  {
937  if(cb->itemText(i) == name)
938  {
939  cb->setCurrentIndex(i);
940  found = true;
941  break;
942  }
943  }
944 
945  if(!found)
946  {
947  cb->addItem(name);
948  cb->setCurrentIndex(cb->count() - 1);
949  }
950 }
951 
953 {
954  if(!m_draftOriginal)
955  return;
956 
957  QImage img = m_draftOriginal->toImage();
958 
959  QPixmap* draft = m_mapDisplay->getDraftPixmap();
960 
961  draft->fill(Qt::transparent);
962 
963  QPainter p(draft);
964  p.drawImage(0, 0, img, 0, 0, m_ui->m_horizontalSlider->value(), m_ui->m_verticalSlider->value());
965  p.end();
966 
967  m_mapDisplay->repaint();
968 }
969 
970 
971 void te::qt::widgets::RasterNavigatorWidget::setPoints(std::map< unsigned int, QPointF > *points)
972 {
973  m_points.release();
974  m_points.reset(points);
975 }
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.
virtual void refresh(bool redraw=false)
It updates the contents in the map display.
void setRedChannel(SelectedChannel *c)
This class defines the map display EyeBird, this component is only a specific map that shows the orig...
A selected channel to be display.
te::qt::widgets::AbstractTool * m_tool
te::qt::widgets::ZoomWheel * m_zoomTool
Zoom tool (used in preview mode)
This class defines the map display ZoomIn, this component is only a specific map that shows the curre...
void onPointMoved(QPointF &pointoriginal, QPointF &pointnew)
unsigned int getWidth() const
It returns the MapDisplay current width in pixels.
void setDevice(QPaintDevice *device, bool takeOwnerShip)
It sets new device as QPrinter.
double y
y-coordinate.
Definition: Coord2D.h:114
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
void geomAquired(te::gm::Polygon *poly)
double x
x-coordinate.
Definition: Coord2D.h:113
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.
TESEEXPORT Style * CreateCoverageStyle(const std::vector< te::rst::BandProperty * > &properties)
Try creates an appropriate coverage style based on given band properties.
double m_min
Minimum pixel value (default is std::numeric_limits<double>::max() which means no value set)...
Definition: BandProperty.h:147
double m_urx
Upper right corner x-coordinate.
void setPoints(std::map< unsigned int, QPointF > *points)
virtual double getScale() const
Calculates and return the current scale.
te::se::ChannelSelection * getChannelSelection() const
const double & getLowerLeftY() const
It returns a constant refernce to the y coordinate of the lower left corner.
SelectedChannel * getRedChannel() const
te::qt::widgets::Pan * m_panTool
Pan tool (used in preview mode)
A widget to control the display of a set of layers.
void setGrayChannel(SelectedChannel *c)
An utility struct for representing 2D coordinates.
Definition: Coord2D.h:40
static te::dt::Date ds(2010, 01, 01)
SelectedChannel * getBlueChannel() const
const double & getUpperRightY() const
It returns a constant refernce to the x coordinate of the upper right corner.
This class defines an interface for objects that can receive application events and respond to them...
Definition: AbstractTool.h:63
double m_max
Maximum pixel value (default is std::numeric_limits<double>::max() which means no value set)...
Definition: BandProperty.h:148
This class implements a concrete tool to acquire a polygon geometry.
void pointMoved(double xorig, double yorig, double xnew, double ynew)
int m_currentRow
The row position of mouse in map display.
std::string getSourceChannelName() const
This class implements a concrete tool to define a boundary rectangle.
Definition: ExtentAcquire.h:50
std::unique_ptr< std::map< unsigned int, QPointF > > m_points
Rule * getRule(std::size_t i) const
Definition: Style.cpp:105
int b
Definition: TsRtree.cpp:32
virtual void setLayerList(const std::list< te::map::AbstractLayerPtr > &layers)
It sets the layer list to be showed in the Map Display.
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, te::map::RasterContrast *rc, const double &scale, bool *cancel)
This class implements a concrete tool to geographic pan operation.
Definition: Pan.h:49
double m_llx
Lower left corner x-coordinate.
virtual void setResizePolicy(const ResizePolicy &policy)
Sets the resize policy to this map display.
static RasterSummaryManager & getInstance()
It returns a reference to the singleton instance.
An Envelope defines a 2D rectangular region.
void setVectorial(te::map::AbstractLayerPtr layer)
An abstract class for raster data strucutures.
virtual std::size_t getNumberOfBands() const =0
Returns the number of bands (dimension of cells attribute values) in the raster.
virtual int getSRID() const
It return the Spatial Reference System used by the Map Display.
void setCurrentTool(te::qt::widgets::AbstractTool *tool)
BandProperty * getProperty()
Returns the band property.
void setColorCompositionType(ColorCompositionType cct)
ColorCompositionType getColorCompositionType() const
virtual const te::gm::Envelope & getExtent() const
It returns the world extent showned by the MapDisplay.
boost::ptr_vector< BandSummary > RasterSummary
RasterSummary is just a typedef of a boost::ptr_vector.
Definition: RasterSummary.h:44
te::gm::Polygon * p
This class implements a concrete tool to geographic coordinate move a point on mouse click operation...
Definition: PointMove.h:50
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
virtual const Band * getBand(std::size_t i) const =0
Returns the raster i-th band.
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)
std::unique_ptr< Ui::RasterNavigatorWidgetForm > m_ui
te::qt::widgets::EyeBirdMapDisplayWidget * m_eyeBirdMapDisplay
const std::vector< Symbolizer * > & getSymbolizers() const
Definition: Rule.cpp:158
double m_lly
Lower left corner y-coordinate.
void setList(std::list< te::map::AbstractLayerPtr > &layerList, int srid)
This method is used to set the selected layer for mixture model operation.
int getSRID() const
Returns the raster spatial reference system identifier.
unsigned int getHeight() const
It returns the MapDisplay current height in pixels.
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:76
virtual QPixmap * getDraftPixmap() const
It returns the map display draft pixmap.
double m_ury
Upper right corner y-coordinate.
void envelopeAcquired(te::gm::Envelope env)
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.
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)
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.
int m_currentColumn
The column position of mouse in map display.
TEDATAACCESSEXPORT std::size_t GetFirstPropertyPos(const te::da::DataSet *dataset, int datatype)
Envelope intersection(const Envelope &rhs) const
It returns an envelope that represents the point set intersection with another envelope.
Calculate the min value.
void setBlueChannel(SelectedChannel *c)
SelectedChannel * getGrayChannel() const
void setList(std::list< te::map::AbstractLayerPtr > &layerList, int srid)
This method is used to set the selected layer for mixture model operation.
virtual void setSRID(const int &srid, bool doRefresh=true)
It sets a new Spatial Reference System to be used by the Map Display.
Calculate the max value.
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.
virtual void setExtent(te::gm::Envelope &e, bool doRefresh=true)
It sets the world visible area and refreshes the contents in the map display.
void showAsPreview(bool asPreview, bool enableZoom=true)
bool isValid() const
It tells if the rectangle is valid or not.
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)
void pointPicked(double x, double y)
void setGreenChannel(SelectedChannel *c)
ChannelSelection specifies the false-color channel selection for a multi-spectral raster source (such...
te::rst::Raster * getExtentRaster(bool fullScale=false)