All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
RasterSymbolizerWidget.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2008-2014 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/se/RasterSymbolizerWidget.cpp
22 
23  \brief A widget used to configure a Raster Symbolizer SE element.
24 */
25 
26 // TerraLib
27 #include "../../../common/STLUtils.h"
28 #include "../../../raster.h"
29 #include "../../../se/Utils.h"
30 #include "../utils/HorizontalSliderWidget.h"
31 #include "RasterSymbolizerWidget.h"
32 #include "ui_RasterSymbolizerWidgetForm.h"
33 
34 // Qt
35 #include <QLabel>
36 
37 // STL
38 #include <cassert>
39 
40 #define GAIN_CONSTANT_VALUE 0.2
41 #define OFFSET_CONSTANT_VALUE 10
42 
44  : QWidget(parent, f),
45  m_ui(new Ui::RasterSymbolizerWidgetForm),
46  m_sliderWidget(0),
47  m_symbolizer(0),
48  m_contrastRed(0),
49  m_contrastGreen(0),
50  m_contrastBlue(0),
51  m_contrastMono(0),
52  m_scRed(0),
53  m_scGreen(0),
54  m_scBlue(0),
55  m_scMono(0),
56  m_cs(new te::se::ChannelSelection)
57 {
58  m_ui->setupUi(this);
59 
60  // add opacity scrool bar
62  m_sliderWidget->setTitle(tr("Opacity"));
65 
66  QGridLayout* layout = new QGridLayout(m_ui->m_opacityWidget);
67  layout->setContentsMargins(0,0,0,0);
68  layout->setAlignment(Qt::AlignTop);
69  layout->addWidget(m_sliderWidget);
70 
71 
72  //connect slots
73  connect(m_sliderWidget, SIGNAL(sliderValueChanged(int)), this, SLOT(onOpacityChanged(int)));
74  connect(m_sliderWidget, SIGNAL(sliderReleased()), this, SLOT(onSymbolizerChanged()));
75 
76  connect(m_ui->m_composeMRadioButton, SIGNAL(clicked()), this, SLOT(onMonoChannelSelectionClicked()));
77  connect(m_ui->m_composeRRadioButton, SIGNAL(clicked()), this, SLOT(onRedChannelSelectionClicked()));
78  connect(m_ui->m_composeGRadioButton, SIGNAL(clicked()), this, SLOT(onGreenChannelSelectionClicked()));
79  connect(m_ui->m_composeBRadioButton, SIGNAL(clicked()), this, SLOT(onBlueChannelSelectionClicked()));
80  connect(m_ui->m_composeCRadioButton, SIGNAL(clicked()), this, SLOT(onCompositionChannelSelectionClicked()));
81 
82  connect(m_ui->m_composeMComboBox, SIGNAL(activated(QString)), this, SLOT(onMonoChannelNameChanged(QString)));
83  connect(m_ui->m_composeRComboBox, SIGNAL(activated(QString)), this, SLOT(onRedChannelNameChanged(QString)));
84  connect(m_ui->m_composeGComboBox, SIGNAL(activated(QString)), this, SLOT(onGreenChannelNameChanged(QString)));
85  connect(m_ui->m_composeBComboBox, SIGNAL(activated(QString)), this, SLOT(onBlueChannelNameChanged(QString)));
86 
87  connect(m_ui->m_contrastTypeComboBox, SIGNAL(activated(QString)), this, SLOT(onTypeConstratChanged(QString)));
88 
89  connect(m_ui->m_contrastMHorizontalSlider, SIGNAL(valueChanged(int)), this, SLOT(onMonoGammaChanged(int)));
90  connect(m_ui->m_contrastRHorizontalSlider, SIGNAL(valueChanged(int)), this, SLOT(onRedGammaChanged(int)));
91  connect(m_ui->m_contrastGHorizontalSlider, SIGNAL(valueChanged(int)), this, SLOT(onGreenGammaChanged(int)));
92  connect(m_ui->m_contrastBHorizontalSlider, SIGNAL(valueChanged(int)), this, SLOT(onBlueGammaChanged(int)));
93 
94  connect(m_ui->m_contrastMHorizontalSlider, SIGNAL(sliderReleased()), this, SLOT(onSymbolizerChanged()));
95  connect(m_ui->m_contrastRHorizontalSlider, SIGNAL(sliderReleased()), this, SLOT(onSymbolizerChanged()));
96  connect(m_ui->m_contrastGHorizontalSlider, SIGNAL(sliderReleased()), this, SLOT(onSymbolizerChanged()));
97  connect(m_ui->m_contrastBHorizontalSlider, SIGNAL(sliderReleased()), this, SLOT(onSymbolizerChanged()));
98 
99  connect(m_ui->m_gainPlusPushButton, SIGNAL(clicked()), this, SLOT(onIncreaseGain()));
100  connect(m_ui->m_gainMinusPushButton, SIGNAL(clicked()), this, SLOT(onDecreaseGain()));
101  connect(m_ui->m_gainResetPushButton, SIGNAL(clicked()), this, SLOT(onDefaultGain()));
102  connect(m_ui->m_offsetPlusPushButton, SIGNAL(clicked()), this, SLOT(onIncreaseOffset()));
103  connect(m_ui->m_offsetMinusPushButton, SIGNAL(clicked()), this, SLOT(onDecreaseOffset()));
104  connect(m_ui->m_offsetResetPushButton, SIGNAL(clicked()), this, SLOT(onDefaultOffset()));
105 
106  connect(m_ui->m_contrastGroupBox, SIGNAL(clicked()), this, SLOT(setContrastVisibility()));
107 
108  //init interface
109  initialize();
110 }
111 
113 {
114  m_ceNames.clear();
115 }
116 
118 {
119  assert(rs);
120 
121  m_symbolizer = rs;
122 
123  if(m_symbolizer->getChannelSelection())
124  {
125  m_cs = m_symbolizer->getChannelSelection();
126 
127  m_scRed = m_cs->getRedChannel();
128  m_scGreen = m_cs->getGreenChannel();
129  m_scBlue = m_cs->getBlueChannel();
130  m_scMono = m_cs->getGrayChannel();
131 
132  if(m_cs->getColorCompositionType() == te::se::RGB_COMPOSITION)
133  {
134  m_ui->m_composeCRadioButton->setChecked(true);
135 
136  onCompositionChannelSelectionClicked();
137  }
138  else if(m_cs->getColorCompositionType() == te::se::GRAY_COMPOSITION)
139  {
140  m_ui->m_composeMRadioButton->setChecked(true);
141 
142  onMonoChannelSelectionClicked();
143  }
144  else if(m_cs->getColorCompositionType() == te::se::RED_COMPOSITION)
145  {
146  m_ui->m_composeRRadioButton->setChecked(true);
147 
148  onRedChannelSelectionClicked();
149  }
150  else if(m_cs->getColorCompositionType() == te::se::GREEN_COMPOSITION)
151  {
152  m_ui->m_composeGRadioButton->setChecked(true);
153 
154  onGreenChannelSelectionClicked();
155  }
156  else if(m_cs->getColorCompositionType() == te::se::BLUE_COMPOSITION)
157  {
158  m_ui->m_composeBRadioButton->setChecked(true);
159 
160  onBlueChannelSelectionClicked();
161  }
162 
163  m_contrastRed = 0;
164  if(m_scRed && m_scRed->getContrastEnhancement())
165  {
166  m_contrastRed = m_scRed->getContrastEnhancement();
167  }
168 
169  m_contrastGreen = 0;
170  if(m_scGreen && m_scGreen->getContrastEnhancement())
171  {
172  m_contrastGreen = m_scGreen->getContrastEnhancement();
173  }
174 
175  m_contrastBlue = 0;
176  if(m_scBlue && m_scBlue->getContrastEnhancement())
177  {
178  m_contrastBlue = m_scBlue->getContrastEnhancement();
179  }
180 
181  m_contrastMono = 0;
182  if(m_scMono && m_scMono->getContrastEnhancement())
183  {
184  m_contrastMono = m_scMono->getContrastEnhancement();
185  }
186  }
187  else
188  {
189  m_symbolizer->setChannelSelection(m_cs);
190  }
191 
192  updateUi();
193 }
194 
195 void te::qt::widgets::RasterSymbolizerWidget::setBandProperty(std::vector<te::rst::BandProperty*> bp)
196 {
197  QStringList bandNames;
198 
199  for(size_t i = 0; i < bp.size(); ++i)
200  {
201  // if the band property does not have the description information
202  // we must used the index information.
203  if(bp[i]->m_description.empty())
204  {
205  QString bandInfo;
206  bandInfo.setNum(bp[i]->m_idx);
207 
208  bandNames.push_back(bandInfo);
209  }
210  else
211  {
212  bandNames.push_back(bp[i]->m_description.c_str());
213  }
214  }
215 
216  m_ui->m_composeMComboBox->clear();
217  m_ui->m_composeMComboBox->addItems(bandNames);
218 
219  m_ui->m_composeRComboBox->clear();
220  m_ui->m_composeRComboBox->addItems(bandNames);
221 
222  m_ui->m_composeGComboBox->clear();
223  m_ui->m_composeGComboBox->addItems(bandNames);
224 
225  m_ui->m_composeBComboBox->clear();
226  m_ui->m_composeBComboBox->addItems(bandNames);
227 }
228 
230 {
231  //set the pixmaps
232  m_ui->m_gainLabel->setPixmap(QIcon::fromTheme("gain").pixmap(16,16));
233  m_ui->m_offSetLabel->setPixmap(QIcon::fromTheme("offset").pixmap(16,16));
234  m_ui->m_gainPlusPushButton->setIcon(QIcon::fromTheme("list-add"));
235  m_ui->m_gainPlusPushButton->setIconSize(QSize(16,16));
236  m_ui->m_gainMinusPushButton->setIcon(QIcon::fromTheme("list-remove"));
237  m_ui->m_gainMinusPushButton->setIconSize(QSize(16,16));
238  m_ui->m_gainResetPushButton->setIcon(QIcon::fromTheme("edit-undo"));
239  m_ui->m_gainResetPushButton->setIconSize(QSize(16,16));
240  m_ui->m_offsetPlusPushButton->setIcon(QIcon::fromTheme("list-add"));
241  m_ui->m_offsetPlusPushButton->setIconSize(QSize(16,16));
242  m_ui->m_offsetMinusPushButton->setIcon(QIcon::fromTheme("list-remove"));
243  m_ui->m_offsetMinusPushButton->setIconSize(QSize(16,16));
244  m_ui->m_offsetResetPushButton->setIcon(QIcon::fromTheme("edit-undo"));
245  m_ui->m_offsetResetPushButton->setIconSize(QSize(16,16));
246 
247  m_ui->m_composeMonoLabel->setPixmap(QIcon::fromTheme("bullet-black").pixmap(16,16));
248  m_ui->m_composeRedLabel->setPixmap(QIcon::fromTheme("bullet-red").pixmap(16,16));
249  m_ui->m_composeGreenLabel->setPixmap(QIcon::fromTheme("bullet-green").pixmap(16,16));
250  m_ui->m_composeBlueLabel->setPixmap(QIcon::fromTheme("bullet-blue").pixmap(16,16));
251 
252  m_ui->m_composeCRadioButton->setIcon(QIcon::fromTheme("channels").pixmap(16,16));
253  m_ui->m_composeRRadioButton->setIcon(QIcon::fromTheme("channel-red").pixmap(16,16));
254  m_ui->m_composeGRadioButton->setIcon(QIcon::fromTheme("channel-green").pixmap(16,16));
255  m_ui->m_composeBRadioButton->setIcon(QIcon::fromTheme("channel-blue").pixmap(16,16));
256  m_ui->m_composeMRadioButton->setIcon(QIcon::fromTheme("channel-gray").pixmap(16,16));
257 
258  m_ui->m_rContrastLabel->setPixmap(QIcon::fromTheme("contrast-red").pixmap(16,16));
259  m_ui->m_gContrastLabel->setPixmap(QIcon::fromTheme("contrast-green").pixmap(16,16));
260  m_ui->m_bContrastLabel->setPixmap(QIcon::fromTheme("contrast-blue").pixmap(16,16));
261  m_ui->m_mContrastLabel->setPixmap(QIcon::fromTheme("contrast-mono").pixmap(16,16));
262 
263  //set the contrast enhancement names
264  m_ceNames.clear();
265 
266  m_ceNames.insert(std::map<te::se::ContrastEnhancement::ContrastEnhancementType, QString>::value_type
268  m_ceNames.insert(std::map<te::se::ContrastEnhancement::ContrastEnhancementType, QString>::value_type
270  m_ceNames.insert(std::map<te::se::ContrastEnhancement::ContrastEnhancementType, QString>::value_type
272 
273  std::map<te::se::ContrastEnhancement::ContrastEnhancementType, QString>::iterator it = m_ceNames.begin();
274 
275  while(it != m_ceNames.end())
276  {
277  m_ui->m_contrastTypeComboBox->addItem(it->second);
278 
279  ++it;
280  }
281 
282  m_ui->m_contrastTypeComboBox->setCurrentIndex(m_ui->m_contrastTypeComboBox->findText(m_ceNames[te::se::ContrastEnhancement::ENHANCEMENT_NONE]));
283 
284  m_ui->m_contrastTypeComboBox->setVisible(false);
285  m_ui->m_contrastTypeLabel->setVisible(false);
286 
287  // other values
288  m_gainValue = 0.0;
289  m_offsetValue = 0.0;
290  m_gainOriginalValue = m_gainValue;
291  m_offsetOriginalValue = m_offsetValue;
292 }
293 
295 {
296  if(m_symbolizer)
297  {
298  if(m_symbolizer->getOpacity())
299  {
300  double value = te::se::GetDouble(m_symbolizer->getOpacity()) * 100.;
301  m_sliderWidget->setCurrentValue((int)value);
302  }
303  else
304  {
305  onOpacityChanged(m_sliderWidget->getValue());
306  }
307 
308  if(m_symbolizer->getGain())
309  {
310  m_gainValue = te::se::GetDouble(m_symbolizer->getGain());
311  m_gainOriginalValue = m_gainValue;
312  }
313  else
314  {
315  QString s;
316  s.setNum(m_gainValue);
317  m_symbolizer->setGain(new te::se::ParameterValue(s.toStdString()));
318  }
319 
320  if(m_symbolizer->getOffset())
321  {
322  m_offsetValue = te::se::GetDouble(m_symbolizer->getOffset());
323  m_offsetOriginalValue = m_offsetValue;
324  }
325  else
326  {
327  QString s;
328  s.setNum(m_offsetValue);
329  m_symbolizer->setOffset(new te::se::ParameterValue(s.toStdString()));
330  }
331 
332  //update channel selection
333  if(m_cs->getRedChannel())
334  {
335  te::se::SelectedChannel* channel = m_cs->getRedChannel();
336  std::string name = channel->getSourceChannelName();
337  setComboBoxText(m_ui->m_composeRComboBox, name);
338 
339  if(channel->getContrastEnhancement())
340  {
342  double v = ce->getGammaValue() * 100.;
343  m_ui->m_contrastRHorizontalSlider->setValue((int)v);
344  m_ui->m_contrastTypeComboBox->setCurrentIndex(m_ui->m_contrastTypeComboBox->findText(m_ceNames[ce->getContrastEnhancementType()]));
345 
346  m_ui->m_contrastGroupBox->setChecked(true);
347  }
348  else
349  {
350  m_ui->m_contrastRHorizontalSlider->setValue(100.);
351  }
352  }
353 
354  if(m_cs->getGreenChannel())
355  {
356  te::se::SelectedChannel* channel = m_cs->getGreenChannel();
357  std::string name = channel->getSourceChannelName();
358  setComboBoxText(m_ui->m_composeGComboBox, name);
359 
360  if(channel->getContrastEnhancement())
361  {
363  double v = ce->getGammaValue() * 100.;
364  m_ui->m_contrastGHorizontalSlider->setValue((int)v);
365  m_ui->m_contrastTypeComboBox->setCurrentIndex(m_ui->m_contrastTypeComboBox->findText(m_ceNames[ce->getContrastEnhancementType()]));
366 
367  m_ui->m_contrastGroupBox->setChecked(true);
368  }
369  else
370  {
371  m_ui->m_contrastGHorizontalSlider->setValue(100.);
372  }
373  }
374 
375  if(m_cs->getBlueChannel())
376  {
377  te::se::SelectedChannel* channel = m_cs->getBlueChannel();
378  std::string name = channel->getSourceChannelName();
379  setComboBoxText(m_ui->m_composeBComboBox, name);
380 
381  if(channel->getContrastEnhancement())
382  {
384  double v = ce->getGammaValue() * 100.;
385  m_ui->m_contrastBHorizontalSlider->setValue((int)v);
386  m_ui->m_contrastTypeComboBox->setCurrentIndex(m_ui->m_contrastTypeComboBox->findText(m_ceNames[ce->getContrastEnhancementType()]));
387 
388  m_ui->m_contrastGroupBox->setChecked(true);
389  }
390  else
391  {
392  m_ui->m_contrastBHorizontalSlider->setValue(100.);
393  }
394  }
395 
396  if(m_cs->getGrayChannel())
397  {
398  te::se::SelectedChannel* channel = m_cs->getGrayChannel();
399  std::string name = channel->getSourceChannelName();
400  setComboBoxText(m_ui->m_composeMComboBox, name);
401 
402  if(channel->getContrastEnhancement())
403  {
405  double v = ce->getGammaValue() * 100.;
406  m_ui->m_contrastMHorizontalSlider->setValue((int)v);
407  m_ui->m_contrastTypeComboBox->setCurrentIndex(m_ui->m_contrastTypeComboBox->findText(m_ceNames[ce->getContrastEnhancementType()]));
408 
409  m_ui->m_contrastGroupBox->setChecked(true);
410  }
411  else
412  {
413  m_ui->m_contrastMHorizontalSlider->setValue(100.);
414  }
415  }
416  }
417 
418  setContrastVisibility();
419 }
420 
421 void te::qt::widgets::RasterSymbolizerWidget::setComboBoxText(QComboBox* cb, std::string value)
422 {
423  QString name = value.c_str();
424 
425  bool found = false;
426 
427  for(int i = 0; i < cb->count(); ++i)
428  {
429  if(cb->itemText(i) == name)
430  {
431  cb->setCurrentIndex(i);
432  found = true;
433  break;
434  }
435  }
436 
437  if(!found)
438  {
439  cb->addItem(name);
440  cb->setCurrentIndex(cb->count() - 1);
441  }
442 }
443 
445 {
446  if(m_symbolizer)
447  {
448  int opacity = value;
449  double seOpacity = opacity / 100.;
450  QString qStrOpacity;
451  qStrOpacity.setNum(seOpacity);
452 
453  m_symbolizer->setOpacity(new te::se::ParameterValue(qStrOpacity.toStdString()));
454  }
455 }
456 
458 {
459  m_ui->m_composeMComboBox->setEnabled(true);
460  m_ui->m_composeRComboBox->setEnabled(false);
461  m_ui->m_composeGComboBox->setEnabled(false);
462  m_ui->m_composeBComboBox->setEnabled(false);
463 
464  if(m_scMono == 0)
465  {
466  m_scMono = new te::se::SelectedChannel();
467  m_scMono->setSourceChannelName(m_ui->m_composeMComboBox->currentText().toStdString());
468  m_cs->setGrayChannel(m_scMono);
469  }
470 
471  m_cs->setColorCompositionType(te::se::GRAY_COMPOSITION);
472 
473  onSymbolizerChanged();
474 
475  setContrastVisibility();
476 }
477 
479 {
480  m_ui->m_composeMComboBox->setEnabled(false);
481  m_ui->m_composeRComboBox->setEnabled(true);
482  m_ui->m_composeGComboBox->setEnabled(false);
483  m_ui->m_composeBComboBox->setEnabled(false);
484 
485  if(m_scRed == 0)
486  {
487  m_scRed = new te::se::SelectedChannel();
488  m_scRed->setSourceChannelName(m_ui->m_composeRComboBox->currentText().toStdString());
489  m_cs->setRedChannel(m_scRed);
490  }
491 
492  m_cs->setColorCompositionType(te::se::RED_COMPOSITION);
493 
494  onSymbolizerChanged();
495 
496  setContrastVisibility();
497 }
498 
500 {
501  m_ui->m_composeMComboBox->setEnabled(false);
502  m_ui->m_composeRComboBox->setEnabled(false);
503  m_ui->m_composeGComboBox->setEnabled(true);
504  m_ui->m_composeBComboBox->setEnabled(false);
505 
506  if(m_scGreen== 0)
507  {
508  m_scGreen = new te::se::SelectedChannel();
509  m_scGreen->setSourceChannelName(m_ui->m_composeGComboBox->currentText().toStdString());
510  m_cs->setGreenChannel(m_scGreen);
511  }
512 
513  m_cs->setColorCompositionType(te::se::GREEN_COMPOSITION);
514 
515  onSymbolizerChanged();
516 
517  setContrastVisibility();
518 }
519 
521 {
522  m_ui->m_composeMComboBox->setEnabled(false);
523  m_ui->m_composeRComboBox->setEnabled(false);
524  m_ui->m_composeGComboBox->setEnabled(false);
525  m_ui->m_composeBComboBox->setEnabled(true);
526 
527  if(m_scBlue== 0)
528  {
529  m_scBlue = new te::se::SelectedChannel();
530  m_scBlue->setSourceChannelName(m_ui->m_composeBComboBox->currentText().toStdString());
531  m_cs->setBlueChannel(m_scBlue);
532  }
533 
534  m_cs->setColorCompositionType(te::se::BLUE_COMPOSITION);
535 
536  onSymbolizerChanged();
537 
538  setContrastVisibility();
539 }
540 
542 {
543  m_ui->m_composeMComboBox->setEnabled(false);
544  m_ui->m_composeRComboBox->setEnabled(true);
545  m_ui->m_composeGComboBox->setEnabled(true);
546  m_ui->m_composeBComboBox->setEnabled(true);
547 
548  if(m_scRed == 0)
549  {
550  m_scRed = new te::se::SelectedChannel();
551  m_scRed->setSourceChannelName(m_ui->m_composeRComboBox->currentText().toStdString());
552  m_cs->setRedChannel(m_scRed);
553  }
554 
555  if(m_scGreen== 0)
556  {
557  m_scGreen = new te::se::SelectedChannel();
558  m_scGreen->setSourceChannelName(m_ui->m_composeGComboBox->currentText().toStdString());
559  m_cs->setGreenChannel(m_scGreen);
560  }
561 
562  if(m_scBlue== 0)
563  {
564  m_scBlue = new te::se::SelectedChannel();
565  m_scBlue->setSourceChannelName(m_ui->m_composeBComboBox->currentText().toStdString());
566  m_cs->setBlueChannel(m_scBlue);
567  }
568 
569  m_cs->setColorCompositionType(te::se::RGB_COMPOSITION);
570 
571  onSymbolizerChanged();
572 
573  setContrastVisibility();
574 }
575 
577 {
578  m_scMono->setSourceChannelName(s.toLatin1().data());
579 
580  onSymbolizerChanged();
581 }
582 
584 {
585  m_scRed->setSourceChannelName(s.toLatin1().data());
586 
587  onSymbolizerChanged();
588 }
589 
591 {
592  m_scGreen->setSourceChannelName(s.toLatin1().data());
593 
594  onSymbolizerChanged();
595 }
596 
598 {
599  m_scBlue->setSourceChannelName(s.toLatin1().data());
600 
601  onSymbolizerChanged();
602 }
603 
605 {
606  if(m_contrastRed == 0)
607  {
608  m_contrastRed = new te::se::ContrastEnhancement();
609  m_scRed->setContrastEnhancement(m_contrastRed);
610  }
611 
612  if(m_contrastGreen == 0)
613  {
614  m_contrastGreen = new te::se::ContrastEnhancement();
615  m_scGreen->setContrastEnhancement(m_contrastGreen);
616  }
617 
618  if(m_contrastBlue == 0)
619  {
620  m_contrastBlue = new te::se::ContrastEnhancement();
621  m_scBlue->setContrastEnhancement(m_contrastBlue);
622  }
623 
624  if(m_contrastMono == 0)
625  {
626  m_contrastMono = new te::se::ContrastEnhancement();
627  m_scMono->setContrastEnhancement(m_contrastMono);
628  }
629 
630  std::map<te::se::ContrastEnhancement::ContrastEnhancementType, QString>::iterator it = m_ceNames.begin();
631 
632  while(it != m_ceNames.end())
633  {
634  if(it->second == s)
635  {
636  m_contrastRed->setContrastEnhancementType(it->first);
637  m_contrastGreen->setContrastEnhancementType(it->first);
638  m_contrastBlue->setContrastEnhancementType(it->first);
639  m_contrastMono->setContrastEnhancementType(it->first);
640 
641  break;
642  }
643 
644  ++it;
645  }
646 
647  onSymbolizerChanged();
648 }
649 
651 {
652  if(m_contrastMono == 0)
653  {
654  m_contrastMono = new te::se::ContrastEnhancement();
655  m_scMono->setContrastEnhancement(m_contrastMono);
656  }
657 
658  double value = double(v) / 100.;
659 
660  m_contrastMono->setGammaValue(value);
661 }
662 
664 {
665  if(m_contrastRed == 0)
666  {
667  m_contrastRed = new te::se::ContrastEnhancement();
668  m_scRed->setContrastEnhancement(m_contrastRed);
669  }
670 
671  double value = double(v) / 100.;
672 
673  m_contrastRed->setGammaValue(value);
674 }
675 
677 {
678  if(m_contrastGreen == 0)
679  {
680  m_contrastGreen = new te::se::ContrastEnhancement();
681  m_scGreen->setContrastEnhancement(m_contrastGreen);
682  }
683 
684  double value = double(v) / 100.;
685 
686  m_contrastGreen->setGammaValue(value);
687 }
688 
690 {
691  if(m_contrastBlue == 0)
692  {
693  m_contrastBlue = new te::se::ContrastEnhancement();
694  m_scBlue->setContrastEnhancement(m_contrastBlue);
695  }
696 
697  double value = double(v) / 100.;
698 
699  m_contrastBlue->setGammaValue(value);
700 }
701 
703 {
704  m_gainValue += GAIN_CONSTANT_VALUE;
705 
706  QString s;
707  s.setNum(m_gainValue);
708 
709  if(m_symbolizer)
710  {
711  m_symbolizer->setGain(new te::se::ParameterValue(s.toStdString()));
712 
713  onSymbolizerChanged();
714  }
715 }
716 
718 {
719  m_gainValue -= GAIN_CONSTANT_VALUE;
720 
721  QString s;
722  s.setNum(m_gainValue);
723 
724  if(m_symbolizer)
725  {
726  m_symbolizer->setGain(new te::se::ParameterValue(s.toStdString()));
727 
728  onSymbolizerChanged();
729  }
730 }
731 
733 {
734  m_gainValue = m_gainOriginalValue;
735 
736  QString s;
737  s.setNum(m_gainValue);
738 
739  if(m_symbolizer)
740  {
741  m_symbolizer->setGain(new te::se::ParameterValue(s.toStdString()));
742 
743  onSymbolizerChanged();
744  }
745 }
746 
748 {
749  m_offsetValue += OFFSET_CONSTANT_VALUE;
750 
751  QString s;
752  s.setNum(m_offsetValue);
753 
754  if(m_symbolizer)
755  {
756  m_symbolizer->setOffset(new te::se::ParameterValue(s.toStdString()));
757 
758  onSymbolizerChanged();
759  }
760 }
761 
763 {
764  m_offsetValue -= OFFSET_CONSTANT_VALUE;
765 
766  QString s;
767  s.setNum(m_offsetValue);
768 
769  if(m_symbolizer)
770  {
771  m_symbolizer->setOffset(new te::se::ParameterValue(s.toStdString()));
772 
773  onSymbolizerChanged();
774  }
775 }
776 
778 {
779  m_offsetValue = m_offsetOriginalValue;
780 
781  QString s;
782  s.setNum(m_offsetValue);
783 
784  if(m_symbolizer)
785  {
786  m_symbolizer->setOffset(new te::se::ParameterValue(s.toStdString()));
787 
788  onSymbolizerChanged();
789  }
790 }
791 
793 {
794  emit symbolizerChanged();
795 }
796 
798 {
799  if(m_ui->m_contrastGroupBox->isChecked() == false)
800  {
801  m_ui->m_contrastRHorizontalSlider->setValue(100);
802  m_ui->m_contrastGHorizontalSlider->setValue(100);
803  m_ui->m_contrastBHorizontalSlider->setValue(100);
804  m_ui->m_contrastMHorizontalSlider->setValue(100);
805 
806  return;
807  }
808 
809  m_ui->m_contrastRHorizontalSlider->setEnabled(false);
810  m_ui->m_contrastGHorizontalSlider->setEnabled(false);
811  m_ui->m_contrastBHorizontalSlider->setEnabled(false);
812  m_ui->m_contrastMHorizontalSlider->setEnabled(false);
813 
814  if(m_ui->m_composeMRadioButton->isChecked())
815  {
816  m_ui->m_contrastMHorizontalSlider->setEnabled(true);
817  }
818 
819  if(m_ui->m_composeRRadioButton->isChecked())
820  {
821  m_ui->m_contrastRHorizontalSlider->setEnabled(true);
822  }
823 
824  if(m_ui->m_composeGRadioButton->isChecked())
825  {
826  m_ui->m_contrastGHorizontalSlider->setEnabled(true);
827  }
828 
829  if(m_ui->m_composeBRadioButton->isChecked())
830  {
831  m_ui->m_contrastBHorizontalSlider->setEnabled(true);
832  }
833 
834  if(m_ui->m_composeCRadioButton->isChecked())
835  {
836  m_ui->m_contrastRHorizontalSlider->setEnabled(true);
837  m_ui->m_contrastGHorizontalSlider->setEnabled(true);
838  m_ui->m_contrastBHorizontalSlider->setEnabled(true);
839  }
840 }
void setComboBoxText(QComboBox *cb, std::string value)
A selected channel to be display.
void initialize()
Internal method to initialize the widget (e.g.: color, combos, icons, etc.)
RasterSymbolizerWidget(QWidget *parent=0, Qt::WindowFlags f=0)
Constructs a RasterSymbolizerWidget dialog which is a child of parent, with widget flags set to f...
te::se::ChannelSelection * getChannelSelection() const
SelectedChannel * getRedChannel() const
std::auto_ptr< Ui::RasterSymbolizerWidgetForm > m_ui
Widget form.
TESEEXPORT double GetDouble(const te::se::ParameterValue *param)
It gets the parameter value as a double.
Definition: Utils.cpp:448
The "ParameterValueType" uses WFS-Filter expressions to give values for SE graphic parameters...
std::string getSourceChannelName() const
ContrastEnhancement defines the 'stretching' of contrast for a channel of a false-color image or for ...
A widget used to configure a Raster Symbolizer SE element.
#define OFFSET_CONSTANT_VALUE
The RasterSymbolizer describes how to render raster/matrix-coverage data (e.g., satellite photos...
#define GAIN_CONSTANT_VALUE
te::qt::widgets::HorizontalSliderWidget * m_sliderWidget
Slider widget used for opacity information.
ContrastEnhancementType getContrastEnhancementType() const
ContrastEnhancement * getContrastEnhancement() const
void setRasterSymbolizer(te::se::RasterSymbolizer *rs)
void updateUi()
Updates the widget form based on internal mark element.
void setBandProperty(std::vector< te::rst::BandProperty * > bp)