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) 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 "../../../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  m_draftOriginal(0)
70 {
71  m_ui->setupUi(this);
72 
73 //build form
74  QGridLayout* displayLayout = new QGridLayout(m_ui->m_frame);
75  m_mapDisplay = new te::qt::widgets::MultiThreadMapDisplay(m_ui->m_frame->size(), m_ui->m_frame);
77  displayLayout->addWidget(m_mapDisplay);
78  displayLayout->setContentsMargins(0,0,0,0);
79 
80  QGridLayout* eyeBirdDisplayLayout = new QGridLayout(m_ui->m_eyeBirdFrame);
82  eyeBirdDisplayLayout->addWidget(m_eyeBirdMapDisplay);
83  eyeBirdDisplayLayout->setContentsMargins(0,0,0,0);
84 
85  QGridLayout* zoomInDisplayLayout = new QGridLayout(m_ui->m_zoomInFrame);
87  zoomInDisplayLayout->addWidget(m_zoomInMapDisplay);
88  zoomInDisplayLayout->setContentsMargins(0,0,0,0);
89 
90  m_pointCursor = Qt::CrossCursor;
91 
92 // CoordTracking tool
94  m_mapDisplay->installEventFilter(coordTracking);
95 
96 // signals & slots
97  connect(m_ui->m_previewToolButton, SIGNAL(clicked()), this, SLOT(onPreviewClicked()));
98 
99  connect(m_ui->m_zoomInActionToolButtontoolButton, SIGNAL(toggled(bool)), this, SLOT(onZoomAreaToggled(bool)));
100  connect(m_ui->m_zoomOutActionToolButtontoolButton, SIGNAL(toggled(bool)), this, SLOT(onZoomOutToggled(bool)));
101  connect(m_ui->m_panActionToolButtontoolButton, SIGNAL(toggled(bool)), this, SLOT(onPanToggled(bool)));
102  connect(m_ui->m_pointActionToolButtontoolButton, SIGNAL(toggled(bool)), this, SLOT(onPointPickerToggled(bool)));
103  connect(m_ui->m_geomActionToolButtontoolButton, SIGNAL(toggled(bool)), this, SLOT(onGeomToggled(bool)));
104  connect(m_ui->m_extentActionToolButtontoolButton, SIGNAL(toggled(bool)), this, SLOT(onBoxToggled(bool)));
105  connect(m_ui->m_readPixelActionToolButton, SIGNAL(toggled(bool)), this, SLOT(onReadPixelToggled(bool)));
106  connect(m_ui->m_extraDisplaysToolButton, SIGNAL(toggled(bool)), this, SLOT(onExtraDisplaysToggled(bool)));
107  connect(m_ui->m_recomposeActionToolButton, SIGNAL(clicked()), this, SLOT(onRecomposeClicked()));
108 
109  connect(m_ui->m_redComboBox, SIGNAL(activated(int)), this, SLOT(onRedComboBoxActivated(int)));
110  connect(m_ui->m_greenComboBox, SIGNAL(activated(int)), this, SLOT(onGreenComboBoxActivated(int)));
111  connect(m_ui->m_blueComboBox, SIGNAL(activated(int)), this, SLOT(onBlueComboBoxActivated(int)));
112  connect(m_ui->m_monoComboBox, SIGNAL(activated(int)), this, SLOT(onMonoComboBoxActivated(int)));
113  connect(m_ui->m_monoToolButton, SIGNAL(clicked(bool)), this, SLOT(onMonoToolClicked(bool)));
114  connect(m_ui->m_compositionToolButton, SIGNAL(clicked(bool)), this, SLOT(onCompositionToolClicked(bool)));
115  connect(m_ui->m_redToolButton, SIGNAL(clicked(bool)), this, SLOT(onRedToolClicked(bool)));
116  connect(m_ui->m_greenToolButton, SIGNAL(clicked(bool)), this, SLOT(onGreenToolClicked(bool)));
117  connect(m_ui->m_blueToolButton, SIGNAL(clicked(bool)), this, SLOT(onBlueToolClicked(bool)));
118 
119  connect(m_ui->m_verticalSlider, SIGNAL(valueChanged(int)), this, SLOT(onVSliderChanged(int)));
120  connect(m_ui->m_horizontalSlider, SIGNAL(valueChanged(int)), this, SLOT(onHSliderChanged(int)));
121 
122  connect(coordTracking, SIGNAL(coordTracked(QPointF&)), this, SLOT(onCoordTrackedChanged(QPointF&)));
123  connect(m_mapDisplay, SIGNAL(extentChanged()), this, SLOT(onMapDisplayExtentChanged()));
124 
125 //pixmap
126  m_ui->m_previewToolButton->setIcon(QIcon::fromTheme("check"));
127  m_ui->m_zoomInActionToolButtontoolButton->setIcon(QIcon::fromTheme("zoom-area"));
128  m_ui->m_zoomOutActionToolButtontoolButton->setIcon(QIcon::fromTheme("zoom-out"));
129  m_ui->m_panActionToolButtontoolButton->setIcon(QIcon::fromTheme("pan"));
130  m_ui->m_recomposeActionToolButton->setIcon(QIcon::fromTheme("zoom-extent"));
131  m_ui->m_pointActionToolButtontoolButton->setIcon(QIcon::fromTheme("placemark"));
132  m_ui->m_geomActionToolButtontoolButton->setIcon(QIcon::fromTheme("edit-polygon"));
133  m_ui->m_extentActionToolButtontoolButton->setIcon(QIcon::fromTheme("edit-box"));
134  m_ui->m_readPixelActionToolButton->setIcon(QIcon::fromTheme("color-picker"));
135  m_ui->m_extraDisplaysToolButton->setIcon(QIcon::fromTheme("view-map-display-extra"));
136  m_ui->m_monoLabel->setPixmap(QIcon::fromTheme("bullet-black").pixmap(16,16));
137  m_ui->m_redLabel->setPixmap(QIcon::fromTheme("bullet-red").pixmap(16,16));
138  m_ui->m_greenLabel->setPixmap(QIcon::fromTheme("bullet-green").pixmap(16,16));
139  m_ui->m_blueLabel->setPixmap(QIcon::fromTheme("bullet-blue").pixmap(16,16));
140  m_ui->m_monoToolButton->setIcon(QIcon::fromTheme("channel-gray"));
141  m_ui->m_compositionToolButton->setIcon(QIcon::fromTheme("channels"));
142  m_ui->m_redToolButton->setIcon(QIcon::fromTheme("channel-red"));
143  m_ui->m_greenToolButton->setIcon(QIcon::fromTheme("channel-green"));
144  m_ui->m_blueToolButton->setIcon(QIcon::fromTheme("channel-blue"));
145 
146  //hide preview options
147  m_ui->m_previewToolButton->setVisible(false);
148  m_ui->m_horizontalSlider->setVisible(false);
149  m_ui->m_verticalSlider->setVisible(false);
150 
151  onExtraDisplaysToggled(false);
152 }
153 
155 {
156  if(m_layer.get())
157  m_layer->setVisibility(m_visibility);
158 
159  delete m_tool;
160  delete m_panTool;
161  delete m_zoomTool;
162  delete m_draftOriginal;
163 }
164 
166 {
167  m_layer = layer;
168 
169  m_visibility = m_layer->getVisibility();
170 
171  m_layer->setVisibility(te::map::VISIBLE);
172 
173  std::list<te::map::AbstractLayerPtr> list;
174  list.push_back(m_layer);
175 
176  te::gm::Envelope e = m_layer->getExtent();
177 
178  m_mapDisplay->setMouseTracking(true);
179  m_mapDisplay->setLayerList(list);
180  m_mapDisplay->setSRID(m_layer->getSRID(), false);
181 
182  if(!setFullScaleBox)
183  m_mapDisplay->setExtent(e, false);
184  else
185  {
186  //get raster
187  std::auto_ptr<te::da::DataSet> ds(m_layer->getData());
188  std::size_t rpos = te::da::GetFirstPropertyPos(ds.get(), te::dt::RASTER_TYPE);
189  std::auto_ptr<te::rst::Raster> inputRst = ds->getRaster(rpos);
190 
191  //calculate extent full scale
192  int w = m_mapDisplay->getWidth();
193  int h = m_mapDisplay->getHeight();
194  double resX = inputRst->getResolutionX();
195  double resY = inputRst->getResolutionY();
196  te::gm::Coord2D cc(inputRst->getExtent()->getCenter().x, inputRst->getExtent()->getCenter().y);
197  te::gm::Coord2D bowerLeftWorld(cc.x - (resX * ( w / 2 )), cc.y - (resY * ( h / 2 )));
198  te::gm::Coord2D bowerUpperWorld(cc.x + (resX * ( w / 2 )), cc.y + (resY * ( h / 2 )));
199 
200  te::gm::Envelope env(bowerLeftWorld.x, bowerLeftWorld.y, bowerUpperWorld.x, bowerUpperWorld.y);
201 
202  m_mapDisplay->setExtent(env, false);
203  }
204 
205  m_zoomInMapDisplay->setList(list, m_layer->getSRID());
206  m_eyeBirdMapDisplay->setList(list, m_layer->getSRID());
207 
208 // list bands
209  listBands();
210 
211 // get band composition information
212  getCompositionInfo();
213 }
214 
216 {
217  std::list<te::map::AbstractLayerPtr> list;
218  list.push_back(layer);
219  list.push_back(m_layer);
220 
221  m_mapDisplay->setLayerList(list);
222  m_zoomInMapDisplay->setList(list, m_layer->getSRID());
223  m_eyeBirdMapDisplay->setList(list, m_layer->getSRID());
224 
225  te::gm::Envelope e = m_mapDisplay->getExtent();
226  m_mapDisplay->setExtent(e, true);
227 }
228 
230 {
231  //m_mapDisplay->setExtent(env, true);
232 }
233 
235 {
236  std::list<te::map::AbstractLayerPtr> list;
237  list.push_back(m_layer);
238 
239  m_mapDisplay->setLayerList(list);
240  m_zoomInMapDisplay->setList(list, m_layer->getSRID());
241  m_eyeBirdMapDisplay->setList(list, m_layer->getSRID());
242 
243  te::gm::Envelope e = m_mapDisplay->getExtent();
244  m_mapDisplay->setExtent(e, true);
245 }
246 
248 {
249  return m_mapDisplay->getExtent();
250 }
251 
253 {
254  return m_mapDisplay;
255 }
256 
258 {
259  //get box info
260  te::gm::Envelope reprojectedBBOX(m_mapDisplay->getExtent());
261  reprojectedBBOX.transform(m_mapDisplay->getSRID(), m_layer->getSRID());
262  te::gm::Envelope ibbox = reprojectedBBOX.intersection(m_layer->getExtent());
263 
264  //get raster
265  std::auto_ptr<te::da::DataSet> ds(m_layer->getData());
266  std::size_t rpos = te::da::GetFirstPropertyPos(ds.get(), te::dt::RASTER_TYPE);
267  std::auto_ptr<te::rst::Raster> inputRst = ds->getRaster(rpos);
268 
269  te::rst::Raster* raster = 0;
270 
271  if(fullScale)
272  {
273  te::gm::Coord2D startGrid = inputRst->getGrid()->geoToGrid(ibbox.getLowerLeftX(), ibbox.getLowerLeftY());
274  te::gm::Coord2D endGrid = inputRst->getGrid()->geoToGrid(ibbox.getUpperRightX(), ibbox.getUpperRightY());
275 
276  int w = (int)endGrid.x - (int)startGrid.x;
277  int h = (int)startGrid.y - (int)endGrid.y;
278 
279  raster = te::map::GetExtentRaster(inputRst.get(), w, h, reprojectedBBOX, m_mapDisplay->getSRID(), ibbox, m_layer->getSRID());
280  }
281  else
282  {
283  raster = te::map::GetExtentRaster(inputRst.get(), m_mapDisplay->getWidth(), m_mapDisplay->getHeight(), reprojectedBBOX, m_mapDisplay->getSRID(), ibbox, m_layer->getSRID());
284  }
285 
286  return raster;
287 }
288 
290 {
291  const te::gm::Envelope& env = m_mapDisplay->getExtent();
292  const te::gm::Envelope& envRst = *rst->getExtent();
293 
294  QPixmap* draft = m_mapDisplay->getDraftPixmap();
295  draft->fill(Qt::transparent);
296 
297  // Prepares the canvas
298  Canvas canvas(m_mapDisplay->width(), m_mapDisplay->height());
299  canvas.setDevice(draft, false);
300  canvas.setWindow(env.m_llx, env.m_lly, env.m_urx, env.m_ury);
301 
302  bool hasToDelete = false;
303  //style
304  if(!style)
305  {
307 
308  hasToDelete = true;
309  }
310 
311  te::se::CoverageStyle* cs = dynamic_cast<te::se::CoverageStyle*>(style);
312 
313  // Draw raster
314  te::map::DrawRaster(rst, &canvas, env, m_mapDisplay->getSRID(), envRst, rst->getSRID(), cs);
315 
316  if(m_draftOriginal)
317  delete m_draftOriginal;
318 
319  m_draftOriginal = new QPixmap(*m_mapDisplay->getDraftPixmap());
320 
321  if(hasToDelete)
322  delete style;
323 
324  //update slide bars
325 
326  disconnect(m_ui->m_verticalSlider, SIGNAL(valueChanged(int)), this, SLOT(onVSliderChanged(int)));
327  disconnect(m_ui->m_horizontalSlider, SIGNAL(valueChanged(int)), this, SLOT(onHSliderChanged(int)));
328 
329  m_ui->m_horizontalSlider->setMaximum(m_mapDisplay->getWidth() - 1);
330  m_ui->m_horizontalSlider->setValue(m_mapDisplay->getWidth() - 1);
331  m_ui->m_verticalSlider->setMaximum(m_mapDisplay->getHeight() - 1);
332  m_ui->m_verticalSlider->setValue(m_mapDisplay->getHeight() - 1);
333 
334  connect(m_ui->m_verticalSlider, SIGNAL(valueChanged(int)), this, SLOT(onVSliderChanged(int)));
335  connect(m_ui->m_horizontalSlider, SIGNAL(valueChanged(int)), this, SLOT(onHSliderChanged(int)));
336 
337  m_mapDisplay->repaint();
338 }
339 
340 void te::qt::widgets::RasterNavigatorWidget::showAsPreview(bool asPreview, bool enableZoom)
341 {
342  delete m_panTool;
343  delete m_zoomTool;
344 
345  m_panTool = 0;
346  m_zoomTool = 0;
347 
348  m_ui->m_toolsFrame->setVisible(!asPreview);
349  m_ui->m_label->setVisible(!asPreview);
350  m_ui->m_previewToolButton->setVisible(asPreview);
351 
352  m_ui->m_horizontalSlider->setVisible(asPreview);
353  m_ui->m_verticalSlider->setVisible(asPreview);
354 
355  hideExtraDisplaysTool(asPreview);
356 
357  if(asPreview)
358  {
359  m_panTool = new te::qt::widgets::Pan(m_mapDisplay, Qt::OpenHandCursor, Qt::ClosedHandCursor);
360  m_mapDisplay->installEventFilter(m_panTool);
361 
362  if(enableZoom)
363  {
364  m_zoomTool = new te::qt::widgets::ZoomWheel(m_mapDisplay, 1.5);
365  m_mapDisplay->installEventFilter(m_zoomTool);
366  }
367  }
368 }
369 
371 {
372  m_ui->m_ccFrame->setVisible(!hide);
373 }
374 
376 {
377  m_ui->m_toolLine->setVisible(!hide);
378  hidePickerTool(hide);
379  hideGeomTool(hide);
380  hideBoxTool(hide);
381  hideInfoTool(hide);
382 }
383 
385 {
386  m_ui->m_pointActionToolButtontoolButton->setVisible(!hide);
387 }
388 
390 {
391  m_ui->m_geomActionToolButtontoolButton->setVisible(!hide);
392 }
393 
395 {
396  m_ui->m_extentActionToolButtontoolButton->setVisible(!hide);
397 }
398 
400 {
401  m_ui->m_readPixelActionToolButton->setVisible(!hide);
402 }
403 
405 {
406  m_ui->m_extraDisplaysToolButton->setChecked(false);
407 
408  m_ui->m_extraLine->setVisible(!hide);
409  m_ui->m_extraDisplaysToolButton->setVisible(!hide);
410 }
411 
413 {
414  if(mode)
415  {
416  m_ui->m_pointActionToolButtontoolButton->setIcon(QIcon::fromTheme("pointer-selection"));
417  m_pointCursor = Qt::ArrowCursor;
418  }
419  else
420  {
421  m_ui->m_pointActionToolButtontoolButton->setIcon(QIcon::fromTheme("placemark"));
422  m_pointCursor = Qt::CrossCursor;
423  }
424 }
425 
427 {
428  assert(m_layer.get());
429 
430  if(m_ui->m_extraDisplaysToolButton->isChecked())
431  {
432  //draw cursor position
433  m_zoomInMapDisplay->drawCursorPosition((double) coordinate.rx(), (double)coordinate.ry());
434 
435 
436  ////draw zoom in rectangle
437  //te::gm::Envelope ext = m_zoomInMapDisplay->getCurrentExtent();
438 
439  //m_mapDisplay->getDraftPixmap()->fill(QColor(0, 0, 0, 0));
440  //const te::gm::Envelope& mapExt = m_mapDisplay->getExtent();
441  //te::qt::widgets::Canvas canvasInstance(m_mapDisplay->getDraftPixmap());
442 
443  //canvasInstance.setWindow(mapExt.m_llx, mapExt.m_lly, mapExt.m_urx, mapExt.m_ury);
444  //canvasInstance.setPolygonContourColor(te::color::RGBAColor(255,0,0,TE_OPAQUE));
445  //canvasInstance.setPolygonFillColor(te::color::RGBAColor(0,0,0,TE_TRANSPARENT));
446 
447  //te::gm::Geometry* geom = te::gm::GetGeomFromEnvelope(&ext, m_layer->getSRID());
448  //canvasInstance.draw(geom);
449  //delete geom;
450 
451  //m_mapDisplay->repaint();
452  }
453 
454  //get input raster
455  std::auto_ptr<te::da::DataSet> ds = m_layer->getData();
456 
457  if(ds.get())
458  {
459  std::size_t rpos = te::da::GetFirstPropertyPos(ds.get(), te::dt::RASTER_TYPE);
460  std::auto_ptr<te::rst::Raster> inputRst = ds->getRaster(rpos);
461 
462  if(inputRst.get())
463  {
464  // find the selected pixel location for component
465  te::gm::Coord2D pixelLocation = inputRst->getGrid()->geoToGrid((double) coordinate.rx(), (double)coordinate.ry());
466  m_currentColumn = pixelLocation.x;
467  m_currentRow = pixelLocation.y;
468 
469  QString xStr("X: ");
470  xStr.append(QString::number(coordinate.rx(), 'f', 5));
471  QString yStr("Y: ");
472  yStr.append(QString::number(coordinate.ry(), 'f', 5));
473  QString cStr(tr("Column: "));
474  cStr.append(QString::number(m_currentColumn));
475  QString lStr(tr("Line: "));
476  lStr.append(QString::number(m_currentRow));
477  QString label;
478  label.append(xStr);
479  label.append(" - ");
480  label.append(yStr);
481  label.append(" / ");
482  label.append(cStr);
483  label.append(" - ");
484  label.append(lStr);
485 
486  m_ui->m_label->setText(label);
487  }
488  }
489 }
490 
492 {
493  //emit signal
494  emit envelopeAcquired(env);
495 }
496 
498 {
499  //emit signal
500  emit geomAquired(poly);
501 }
502 
504 {
505  //emit signal
506  emit pointPicked(point.x(), point.y());
507 }
508 
510 {
511  te::gm::Envelope e = m_mapDisplay->getExtent();
512 
513  //emit signal
514  if(e.isValid())
515  emit mapDisplayExtentChanged();
516 
517  delete m_draftOriginal;
518  m_draftOriginal = 0;
519 }
520 
522 {
523  if(!checked)
524  return;
525 
526  te::qt::widgets::ZoomArea* zoomArea = new te::qt::widgets::ZoomArea(m_mapDisplay, Qt::BlankCursor);
527  setCurrentTool(zoomArea);
528 }
529 
531 {
532  if(!checked)
533  return;
534 
535  te::qt::widgets::ZoomClick* zoomOut = new te::qt::widgets::ZoomClick(m_mapDisplay, Qt::BlankCursor, 2.0, te::qt::widgets::Zoom::Out);
536  setCurrentTool(zoomOut);
537 }
538 
540 {
541  if(!checked)
542  return;
543 
544  te::qt::widgets::Pan* pan = new te::qt::widgets::Pan(m_mapDisplay, Qt::OpenHandCursor, Qt::ClosedHandCursor);
545  setCurrentTool(pan);
546 }
547 
549 {
550  if(!checked)
551  return;
552 
553  te::qt::widgets::PointPicker* pp = new te::qt::widgets::PointPicker(m_mapDisplay, m_pointCursor);
554  setCurrentTool(pp);
555 
556  connect(pp, SIGNAL(pointPicked(QPointF&)), this, SLOT(onPointPicked(QPointF&)));
557 }
558 
560 {
561  if(!checked)
562  return;
563 
565  setCurrentTool(pa);
566 
567  connect(pa, SIGNAL(polygonAquired(te::gm::Polygon*)), this, SLOT(onGeomAquired(te::gm::Polygon*)));
568 }
569 
571 {
572  if(!checked)
573  return;
574 
575  te::qt::widgets::ExtentAcquire* ea = new te::qt::widgets::ExtentAcquire(m_mapDisplay, Qt::BlankCursor);
576  setCurrentTool(ea);
577 
578  connect(ea, SIGNAL(extentAcquired(te::gm::Envelope)), this, SLOT(onEnvelopeAcquired(te::gm::Envelope)));
579 }
580 
582 {
583  if(!checked)
584  return;
585 
586  te::qt::widgets::ReadPixelTool* pa = new te::qt::widgets::ReadPixelTool(m_mapDisplay, m_layer);
587  setCurrentTool(pa);
588 }
589 
591 {
592  m_ui->m_extraDisplaysFrame->setVisible(checked);
593  m_eyeBirdMapDisplay->setEnabled(checked);
594  m_zoomInMapDisplay->setEnabled(checked);
595 }
596 
598 {
599  te::gm::Envelope env = m_layer->getExtent();
600 
601  m_mapDisplay->setExtent(env);
602 
603  //m_eyeBirdMapDisplay->recompose(env);
604 }
605 
607 {
608  std::string name = m_ui->m_redComboBox->itemText(index).toStdString();
609 
610  m_symbolizer->getChannelSelection()->getRedChannel()->setSourceChannelName(name);
611 
612  m_mapDisplay->refresh();
613 }
614 
616 {
617  std::string name = m_ui->m_greenComboBox->itemText(index).toStdString();
618 
619  m_symbolizer->getChannelSelection()->getGreenChannel()->setSourceChannelName(name);
620 
621  m_mapDisplay->refresh();
622 }
623 
625 {
626  std::string name = m_ui->m_blueComboBox->itemText(index).toStdString();
627 
628  m_symbolizer->getChannelSelection()->getBlueChannel()->setSourceChannelName(name);
629 
630  m_mapDisplay->refresh();
631 }
632 
634 {
635  std::string name = m_ui->m_monoComboBox->itemText(index).toStdString();
636 
637  m_symbolizer->getChannelSelection()->getGrayChannel()->setSourceChannelName(name);
638 
639  m_mapDisplay->refresh();
640 }
641 
643 {
644  if(m_symbolizer->getChannelSelection()->getGrayChannel() == 0)
645  {
647  scMono->setSourceChannelName(m_ui->m_monoComboBox->currentText().toStdString());
648  m_symbolizer->getChannelSelection()->setGrayChannel(scMono);
649  }
650 
651  m_symbolizer->getChannelSelection()->setColorCompositionType(te::se::GRAY_COMPOSITION);
652 
653  getCompositionInfo();
654 
655  m_mapDisplay->refresh();
656 }
657 
659 {
660  if(m_symbolizer->getChannelSelection()->getRedChannel() == 0)
661  {
663  scRed->setSourceChannelName(m_ui->m_redComboBox->currentText().toStdString());
664  m_symbolizer->getChannelSelection()->setRedChannel(scRed);
665  }
666 
667  m_symbolizer->getChannelSelection()->setColorCompositionType(te::se::RED_COMPOSITION);
668 
669  getCompositionInfo();
670 
671  m_mapDisplay->refresh();
672 }
673 
675 {
676  if(m_symbolizer->getChannelSelection()->getGreenChannel() == 0)
677  {
679  scGreen->setSourceChannelName(m_ui->m_greenComboBox->currentText().toStdString());
680  m_symbolizer->getChannelSelection()->setGreenChannel(scGreen);
681  }
682 
683  m_symbolizer->getChannelSelection()->setColorCompositionType(te::se::GREEN_COMPOSITION);
684 
685  getCompositionInfo();
686 
687  m_mapDisplay->refresh();
688 }
689 
691 {
692  if(m_symbolizer->getChannelSelection()->getBlueChannel() == 0)
693  {
695  scBlue->setSourceChannelName(m_ui->m_blueComboBox->currentText().toStdString());
696  m_symbolizer->getChannelSelection()->setBlueChannel(scBlue);
697  }
698 
699  m_symbolizer->getChannelSelection()->setColorCompositionType(te::se::BLUE_COMPOSITION);
700 
701  getCompositionInfo();
702 
703  m_mapDisplay->refresh();
704 }
705 
707 {
708  if(m_symbolizer->getChannelSelection()->getRedChannel() == 0)
709  {
711  scRed->setSourceChannelName(m_ui->m_redComboBox->currentText().toStdString());
712  m_symbolizer->getChannelSelection()->setRedChannel(scRed);
713  }
714 
715  if(m_symbolizer->getChannelSelection()->getGreenChannel() == 0)
716  {
718  scGreen->setSourceChannelName(m_ui->m_greenComboBox->currentText().toStdString());
719  m_symbolizer->getChannelSelection()->setGreenChannel(scGreen);
720  }
721 
722  if(m_symbolizer->getChannelSelection()->getBlueChannel() == 0)
723  {
725  scBlue->setSourceChannelName(m_ui->m_blueComboBox->currentText().toStdString());
726  m_symbolizer->getChannelSelection()->setBlueChannel(scBlue);
727  }
728 
729  m_symbolizer->getChannelSelection()->setColorCompositionType(te::se::RGB_COMPOSITION);
730 
731  getCompositionInfo();
732 
733  m_mapDisplay->refresh();
734 }
735 
737 {
738  emit previewClicked();
739 }
740 
742 {
743  drawOverlay();
744 }
745 
747 {
748  drawOverlay();
749 }
750 
752 {
753  delete m_tool;
754  m_tool = tool;
755 
756  m_mapDisplay->installEventFilter(m_tool);
757 }
758 
760 {
761  m_ui->m_redComboBox->clear();
762  m_ui->m_greenComboBox->clear();
763  m_ui->m_blueComboBox->clear();
764  m_ui->m_monoComboBox->clear();
765 
766  std::auto_ptr<te::da::DataSet> ds = m_layer->getData();
767 
768  if(ds.get())
769  {
770  std::size_t rpos = te::da::GetFirstPropertyPos(ds.get(), te::dt::RASTER_TYPE);
771 
772  std::auto_ptr<te::rst::Raster> inputRst = ds->getRaster(rpos);
773 
774  if(inputRst.get())
775  {
776  for(unsigned int i = 0; i < inputRst->getNumberOfBands(); ++i)
777  {
778  m_ui->m_redComboBox->addItem(QString::number(i));
779  m_ui->m_greenComboBox->addItem(QString::number(i));
780  m_ui->m_blueComboBox->addItem(QString::number(i));
781  m_ui->m_monoComboBox->addItem(QString::number(i));
782  }
783  }
784  }
785 }
786 
788 {
789  assert(m_layer);
790 
791  te::se::Style* style = m_layer->getStyle();
792  assert(style);
793 
794 // should I render this style?
795  te::se::CoverageStyle* cs = dynamic_cast<te::se::CoverageStyle*>(style);
796  assert(cs);
797 
798 // get the raster symbolizer
799  std::size_t nRules = cs->getRules().size();
800  assert(nRules >= 1);
801 
802 // for while, consider one rule
803  const te::se::Rule* rule = cs->getRule(0);
804 
805  const std::vector<te::se::Symbolizer*>& symbolizers = rule->getSymbolizers();
806  assert(!symbolizers.empty());
807 
808 // for while, consider one raster symbolizer
809  m_symbolizer = dynamic_cast<te::se::RasterSymbolizer*>(symbolizers[0]);
810  assert(m_symbolizer);
811 
812  if(m_symbolizer->getChannelSelection())
813  {
814  m_ui->m_monoComboBox->setEnabled(false);
815  m_ui->m_redComboBox->setEnabled(false);
816  m_ui->m_greenComboBox->setEnabled(false);
817  m_ui->m_blueComboBox->setEnabled(false);
818 
819  te::se::ChannelSelection* cs = m_symbolizer->getChannelSelection();
820 
822  {
823  m_ui->m_compositionToolButton->setChecked(true);
824 
825  std::string name = cs->getRedChannel()->getSourceChannelName();
826  setComboBoxText(m_ui->m_redComboBox, name);
827  name = cs->getGreenChannel()->getSourceChannelName();
828  setComboBoxText(m_ui->m_greenComboBox, name);
829  name = cs->getBlueChannel()->getSourceChannelName();
830  setComboBoxText(m_ui->m_blueComboBox, name);
831 
832  m_ui->m_redComboBox->setEnabled(true);
833  m_ui->m_greenComboBox->setEnabled(true);
834  m_ui->m_blueComboBox->setEnabled(true);
835  }
837  {
838  m_ui->m_monoToolButton->setChecked(true);
839 
840  std::string name = cs->getGrayChannel()->getSourceChannelName();
841  setComboBoxText(m_ui->m_redComboBox, name);
842 
843  m_ui->m_monoComboBox->setEnabled(true);
844  }
846  {
847  m_ui->m_redToolButton->setChecked(true);
848 
849  std::string name = cs->getRedChannel()->getSourceChannelName();
850  setComboBoxText(m_ui->m_redComboBox, name);
851 
852  m_ui->m_redComboBox->setEnabled(true);
853  }
855  {
856  m_ui->m_greenToolButton->setChecked(true);
857 
858  std::string name = cs->getGreenChannel()->getSourceChannelName();
859  setComboBoxText(m_ui->m_greenComboBox, name);
860 
861  m_ui->m_greenComboBox->setEnabled(true);
862  }
864  {
865  m_ui->m_blueToolButton->setChecked(true);
866 
867  std::string name = cs->getBlueChannel()->getSourceChannelName();
868  setComboBoxText(m_ui->m_blueComboBox, name);
869 
870  m_ui->m_blueComboBox->setEnabled(true);
871  }
872  }
873 }
874 
875 void te::qt::widgets::RasterNavigatorWidget::setComboBoxText(QComboBox* cb, std::string value)
876 {
877  QString name = value.c_str();
878 
879  bool found = false;
880 
881  for(int i = 0; i < cb->count(); ++i)
882  {
883  if(cb->itemText(i) == name)
884  {
885  cb->setCurrentIndex(i);
886  found = true;
887  break;
888  }
889  }
890 
891  if(!found)
892  {
893  cb->addItem(name);
894  cb->setCurrentIndex(cb->count() - 1);
895  }
896 }
897 
899 {
900  if(!m_draftOriginal)
901  return;
902 
903  QImage img = m_draftOriginal->toImage();
904 
905  QPixmap* draft = m_mapDisplay->getDraftPixmap();
906 
907  draft->fill(Qt::transparent);
908 
909  QPainter p(draft);
910  p.drawImage(0, 0, img, 0, 0, m_ui->m_horizontalSlider->value(), m_ui->m_verticalSlider->value());
911  p.end();
912 
913  m_mapDisplay->repaint();
914 }
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: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
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.
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:66
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
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:227
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
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)
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
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
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:680
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:481
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:92
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
ChannelSelection specifies the false-color channel selection for a multi-spectral raster source (such...
te::rst::Raster * getExtentRaster(bool fullScale=false)