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