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 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.1
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  m_ui->m_gainValueLabel->setText(QString::number(m_gainValue + 1.));
294  m_ui->m_offSetValueLabel->setText(QString::number(m_offsetValue));
295 }
296 
298 {
299  if(m_symbolizer)
300  {
301  if(m_symbolizer->getOpacity())
302  {
303  double value = te::se::GetDouble(m_symbolizer->getOpacity()) * 100.;
304  m_sliderWidget->setCurrentValue((int)value);
305  }
306  else
307  {
308  onOpacityChanged(m_sliderWidget->getValue());
309  }
310 
311  if(m_symbolizer->getGain())
312  {
313  m_gainValue = te::se::GetDouble(m_symbolizer->getGain());
314  m_gainOriginalValue = m_gainValue;
315  }
316  else
317  {
318  QString s;
319  s.setNum(m_gainValue);
320  m_symbolizer->setGain(new te::se::ParameterValue(s.toStdString()));
321  }
322 
323  m_ui->m_gainValueLabel->setText(QString::number(m_gainValue + 1.));
324 
325  if(m_symbolizer->getOffset())
326  {
327  m_offsetValue = te::se::GetDouble(m_symbolizer->getOffset());
328  m_offsetOriginalValue = m_offsetValue;
329  }
330  else
331  {
332  QString s;
333  s.setNum(m_offsetValue);
334  m_symbolizer->setOffset(new te::se::ParameterValue(s.toStdString()));
335  }
336 
337  m_ui->m_offSetValueLabel->setText(QString::number(m_offsetValue));
338 
339  //update channel selection
340  if(m_cs->getRedChannel())
341  {
342  te::se::SelectedChannel* channel = m_cs->getRedChannel();
343  std::string name = channel->getSourceChannelName();
344  setComboBoxText(m_ui->m_composeRComboBox, name);
345 
346  if(channel->getContrastEnhancement())
347  {
349  double v = ce->getGammaValue() * 100.;
350  m_ui->m_contrastRHorizontalSlider->setValue((int)v);
351  m_ui->m_contrastTypeComboBox->setCurrentIndex(m_ui->m_contrastTypeComboBox->findText(m_ceNames[ce->getContrastEnhancementType()]));
352 
353  m_ui->m_contrastGroupBox->setChecked(true);
354  }
355  else
356  {
357  m_ui->m_contrastRHorizontalSlider->setValue(100.);
358  }
359  }
360 
361  if(m_cs->getGreenChannel())
362  {
363  te::se::SelectedChannel* channel = m_cs->getGreenChannel();
364  std::string name = channel->getSourceChannelName();
365  setComboBoxText(m_ui->m_composeGComboBox, name);
366 
367  if(channel->getContrastEnhancement())
368  {
370  double v = ce->getGammaValue() * 100.;
371  m_ui->m_contrastGHorizontalSlider->setValue((int)v);
372  m_ui->m_contrastTypeComboBox->setCurrentIndex(m_ui->m_contrastTypeComboBox->findText(m_ceNames[ce->getContrastEnhancementType()]));
373 
374  m_ui->m_contrastGroupBox->setChecked(true);
375  }
376  else
377  {
378  m_ui->m_contrastGHorizontalSlider->setValue(100.);
379  }
380  }
381 
382  if(m_cs->getBlueChannel())
383  {
384  te::se::SelectedChannel* channel = m_cs->getBlueChannel();
385  std::string name = channel->getSourceChannelName();
386  setComboBoxText(m_ui->m_composeBComboBox, name);
387 
388  if(channel->getContrastEnhancement())
389  {
391  double v = ce->getGammaValue() * 100.;
392  m_ui->m_contrastBHorizontalSlider->setValue((int)v);
393  m_ui->m_contrastTypeComboBox->setCurrentIndex(m_ui->m_contrastTypeComboBox->findText(m_ceNames[ce->getContrastEnhancementType()]));
394 
395  m_ui->m_contrastGroupBox->setChecked(true);
396  }
397  else
398  {
399  m_ui->m_contrastBHorizontalSlider->setValue(100.);
400  }
401  }
402 
403  if(m_cs->getGrayChannel())
404  {
405  te::se::SelectedChannel* channel = m_cs->getGrayChannel();
406  std::string name = channel->getSourceChannelName();
407  setComboBoxText(m_ui->m_composeMComboBox, name);
408 
409  if(channel->getContrastEnhancement())
410  {
412  double v = ce->getGammaValue() * 100.;
413  m_ui->m_contrastMHorizontalSlider->setValue((int)v);
414  m_ui->m_contrastTypeComboBox->setCurrentIndex(m_ui->m_contrastTypeComboBox->findText(m_ceNames[ce->getContrastEnhancementType()]));
415 
416  m_ui->m_contrastGroupBox->setChecked(true);
417  }
418  else
419  {
420  m_ui->m_contrastMHorizontalSlider->setValue(100.);
421  }
422  }
423  }
424 
425  setContrastVisibility();
426 }
427 
428 void te::qt::widgets::RasterSymbolizerWidget::setComboBoxText(QComboBox* cb, std::string value)
429 {
430  QString name = value.c_str();
431 
432  bool found = false;
433 
434  for(int i = 0; i < cb->count(); ++i)
435  {
436  if(cb->itemText(i) == name)
437  {
438  cb->setCurrentIndex(i);
439  found = true;
440  break;
441  }
442  }
443 
444  if(!found)
445  {
446  cb->addItem(name);
447  cb->setCurrentIndex(cb->count() - 1);
448  }
449 }
450 
452 {
453  if(m_symbolizer)
454  {
455  int opacity = value;
456  double seOpacity = opacity / 100.;
457  QString qStrOpacity;
458  qStrOpacity.setNum(seOpacity);
459 
460  m_symbolizer->setOpacity(new te::se::ParameterValue(qStrOpacity.toStdString()));
461  }
462 }
463 
465 {
466  m_ui->m_composeMComboBox->setEnabled(true);
467  m_ui->m_composeRComboBox->setEnabled(false);
468  m_ui->m_composeGComboBox->setEnabled(false);
469  m_ui->m_composeBComboBox->setEnabled(false);
470 
471  if(m_scMono == 0)
472  {
473  m_scMono = new te::se::SelectedChannel();
474  m_scMono->setSourceChannelName(m_ui->m_composeMComboBox->currentText().toStdString());
475  m_cs->setGrayChannel(m_scMono);
476  }
477 
478  m_cs->setColorCompositionType(te::se::GRAY_COMPOSITION);
479 
480  onSymbolizerChanged();
481 
482  setContrastVisibility();
483 }
484 
486 {
487  m_ui->m_composeMComboBox->setEnabled(false);
488  m_ui->m_composeRComboBox->setEnabled(true);
489  m_ui->m_composeGComboBox->setEnabled(false);
490  m_ui->m_composeBComboBox->setEnabled(false);
491 
492  if(m_scRed == 0)
493  {
494  m_scRed = new te::se::SelectedChannel();
495  m_scRed->setSourceChannelName(m_ui->m_composeRComboBox->currentText().toStdString());
496  m_cs->setRedChannel(m_scRed);
497  }
498 
499  m_cs->setColorCompositionType(te::se::RED_COMPOSITION);
500 
501  onSymbolizerChanged();
502 
503  setContrastVisibility();
504 }
505 
507 {
508  m_ui->m_composeMComboBox->setEnabled(false);
509  m_ui->m_composeRComboBox->setEnabled(false);
510  m_ui->m_composeGComboBox->setEnabled(true);
511  m_ui->m_composeBComboBox->setEnabled(false);
512 
513  if(m_scGreen== 0)
514  {
515  m_scGreen = new te::se::SelectedChannel();
516  m_scGreen->setSourceChannelName(m_ui->m_composeGComboBox->currentText().toStdString());
517  m_cs->setGreenChannel(m_scGreen);
518  }
519 
520  m_cs->setColorCompositionType(te::se::GREEN_COMPOSITION);
521 
522  onSymbolizerChanged();
523 
524  setContrastVisibility();
525 }
526 
528 {
529  m_ui->m_composeMComboBox->setEnabled(false);
530  m_ui->m_composeRComboBox->setEnabled(false);
531  m_ui->m_composeGComboBox->setEnabled(false);
532  m_ui->m_composeBComboBox->setEnabled(true);
533 
534  if(m_scBlue== 0)
535  {
536  m_scBlue = new te::se::SelectedChannel();
537  m_scBlue->setSourceChannelName(m_ui->m_composeBComboBox->currentText().toStdString());
538  m_cs->setBlueChannel(m_scBlue);
539  }
540 
541  m_cs->setColorCompositionType(te::se::BLUE_COMPOSITION);
542 
543  onSymbolizerChanged();
544 
545  setContrastVisibility();
546 }
547 
549 {
550  m_ui->m_composeMComboBox->setEnabled(false);
551  m_ui->m_composeRComboBox->setEnabled(true);
552  m_ui->m_composeGComboBox->setEnabled(true);
553  m_ui->m_composeBComboBox->setEnabled(true);
554 
555  if(m_scRed == 0)
556  {
557  m_scRed = new te::se::SelectedChannel();
558  m_scRed->setSourceChannelName(m_ui->m_composeRComboBox->currentText().toStdString());
559  m_cs->setRedChannel(m_scRed);
560  }
561 
562  if(m_scGreen== 0)
563  {
564  m_scGreen = new te::se::SelectedChannel();
565  m_scGreen->setSourceChannelName(m_ui->m_composeGComboBox->currentText().toStdString());
566  m_cs->setGreenChannel(m_scGreen);
567  }
568 
569  if(m_scBlue== 0)
570  {
571  m_scBlue = new te::se::SelectedChannel();
572  m_scBlue->setSourceChannelName(m_ui->m_composeBComboBox->currentText().toStdString());
573  m_cs->setBlueChannel(m_scBlue);
574  }
575 
576  m_cs->setColorCompositionType(te::se::RGB_COMPOSITION);
577 
578  onSymbolizerChanged();
579 
580  setContrastVisibility();
581 }
582 
584 {
585  m_scMono->setSourceChannelName(s.toLatin1().data());
586 
587  onSymbolizerChanged();
588 }
589 
591 {
592  m_scRed->setSourceChannelName(s.toLatin1().data());
593 
594  onSymbolizerChanged();
595 }
596 
598 {
599  m_scGreen->setSourceChannelName(s.toLatin1().data());
600 
601  onSymbolizerChanged();
602 }
603 
605 {
606  m_scBlue->setSourceChannelName(s.toLatin1().data());
607 
608  onSymbolizerChanged();
609 }
610 
612 {
613  if(m_contrastRed == 0)
614  {
615  m_contrastRed = new te::se::ContrastEnhancement();
616  m_scRed->setContrastEnhancement(m_contrastRed);
617  }
618 
619  if(m_contrastGreen == 0)
620  {
621  m_contrastGreen = new te::se::ContrastEnhancement();
622  m_scGreen->setContrastEnhancement(m_contrastGreen);
623  }
624 
625  if(m_contrastBlue == 0)
626  {
627  m_contrastBlue = new te::se::ContrastEnhancement();
628  m_scBlue->setContrastEnhancement(m_contrastBlue);
629  }
630 
631  if(m_contrastMono == 0)
632  {
633  m_contrastMono = new te::se::ContrastEnhancement();
634  m_scMono->setContrastEnhancement(m_contrastMono);
635  }
636 
637  std::map<te::se::ContrastEnhancement::ContrastEnhancementType, QString>::iterator it = m_ceNames.begin();
638 
639  while(it != m_ceNames.end())
640  {
641  if(it->second == s)
642  {
643  m_contrastRed->setContrastEnhancementType(it->first);
644  m_contrastGreen->setContrastEnhancementType(it->first);
645  m_contrastBlue->setContrastEnhancementType(it->first);
646  m_contrastMono->setContrastEnhancementType(it->first);
647 
648  break;
649  }
650 
651  ++it;
652  }
653 
654  onSymbolizerChanged();
655 }
656 
658 {
659  if(m_contrastMono == 0)
660  {
661  m_contrastMono = new te::se::ContrastEnhancement();
662  m_scMono->setContrastEnhancement(m_contrastMono);
663  }
664 
665  double value = double(v) / 100.;
666 
667  m_contrastMono->setGammaValue(value);
668 }
669 
671 {
672  if(m_contrastRed == 0)
673  {
674  m_contrastRed = new te::se::ContrastEnhancement();
675  m_scRed->setContrastEnhancement(m_contrastRed);
676  }
677 
678  double value = double(v) / 100.;
679 
680  m_contrastRed->setGammaValue(value);
681 }
682 
684 {
685  if(m_contrastGreen == 0)
686  {
687  m_contrastGreen = new te::se::ContrastEnhancement();
688  m_scGreen->setContrastEnhancement(m_contrastGreen);
689  }
690 
691  double value = double(v) / 100.;
692 
693  m_contrastGreen->setGammaValue(value);
694 }
695 
697 {
698  if(m_contrastBlue == 0)
699  {
700  m_contrastBlue = new te::se::ContrastEnhancement();
701  m_scBlue->setContrastEnhancement(m_contrastBlue);
702  }
703 
704  double value = double(v) / 100.;
705 
706  m_contrastBlue->setGammaValue(value);
707 }
708 
710 {
711  m_gainValue += GAIN_CONSTANT_VALUE;
712 
713  QString s;
714  s.setNum(m_gainValue);
715 
716  if(m_symbolizer)
717  {
718  m_symbolizer->setGain(new te::se::ParameterValue(s.toStdString()));
719 
720  onSymbolizerChanged();
721  }
722 
723  m_ui->m_gainValueLabel->setText(QString::number(m_gainValue + 1.));
724 }
725 
727 {
728  m_gainValue -= GAIN_CONSTANT_VALUE;
729 
730  QString s;
731  s.setNum(m_gainValue);
732 
733  if(m_symbolizer)
734  {
735  m_symbolizer->setGain(new te::se::ParameterValue(s.toStdString()));
736 
737  onSymbolizerChanged();
738  }
739 
740  m_ui->m_gainValueLabel->setText(QString::number(m_gainValue + 1.));
741 }
742 
744 {
745  m_gainValue = m_gainOriginalValue;
746 
747  QString s;
748  s.setNum(m_gainValue);
749 
750  if(m_symbolizer)
751  {
752  m_symbolizer->setGain(new te::se::ParameterValue(s.toStdString()));
753 
754  onSymbolizerChanged();
755  }
756 
757  m_ui->m_gainValueLabel->setText(QString::number(m_gainValue + 1.));
758 }
759 
761 {
762  m_offsetValue += OFFSET_CONSTANT_VALUE;
763 
764  QString s;
765  s.setNum(m_offsetValue);
766 
767  if(m_symbolizer)
768  {
769  m_symbolizer->setOffset(new te::se::ParameterValue(s.toStdString()));
770 
771  onSymbolizerChanged();
772  }
773 
774  m_ui->m_offSetValueLabel->setText(QString::number(m_offsetValue));
775 }
776 
778 {
779  m_offsetValue -= OFFSET_CONSTANT_VALUE;
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  m_ui->m_offSetValueLabel->setText(QString::number(m_offsetValue));
792 }
793 
795 {
796  m_offsetValue = m_offsetOriginalValue;
797 
798  QString s;
799  s.setNum(m_offsetValue);
800 
801  if(m_symbolizer)
802  {
803  m_symbolizer->setOffset(new te::se::ParameterValue(s.toStdString()));
804 
805  onSymbolizerChanged();
806  }
807 
808  m_ui->m_offSetValueLabel->setText(QString::number(m_offsetValue));
809 }
810 
812 {
813  emit symbolizerChanged();
814 }
815 
817 {
818  if(m_ui->m_contrastGroupBox->isChecked() == false)
819  {
820  m_ui->m_contrastRHorizontalSlider->setValue(100);
821  m_ui->m_contrastGHorizontalSlider->setValue(100);
822  m_ui->m_contrastBHorizontalSlider->setValue(100);
823  m_ui->m_contrastMHorizontalSlider->setValue(100);
824 
825  return;
826  }
827 
828  m_ui->m_contrastRHorizontalSlider->setEnabled(false);
829  m_ui->m_contrastGHorizontalSlider->setEnabled(false);
830  m_ui->m_contrastBHorizontalSlider->setEnabled(false);
831  m_ui->m_contrastMHorizontalSlider->setEnabled(false);
832 
833  if(m_ui->m_composeMRadioButton->isChecked())
834  {
835  m_ui->m_contrastMHorizontalSlider->setEnabled(true);
836  }
837 
838  if(m_ui->m_composeRRadioButton->isChecked())
839  {
840  m_ui->m_contrastRHorizontalSlider->setEnabled(true);
841  }
842 
843  if(m_ui->m_composeGRadioButton->isChecked())
844  {
845  m_ui->m_contrastGHorizontalSlider->setEnabled(true);
846  }
847 
848  if(m_ui->m_composeBRadioButton->isChecked())
849  {
850  m_ui->m_contrastBHorizontalSlider->setEnabled(true);
851  }
852 
853  if(m_ui->m_composeCRadioButton->isChecked())
854  {
855  m_ui->m_contrastRHorizontalSlider->setEnabled(true);
856  m_ui->m_contrastGHorizontalSlider->setEnabled(true);
857  m_ui->m_contrastBHorizontalSlider->setEnabled(true);
858  }
859 }
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)