All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ContrastEnhancementWidget.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/ContrastEnhancementWidget.cpp
22 
23  \brief A dialog used to build a ContrastEnhancement element.
24 */
25 
26 // TerraLib
27 #include "../../../common/STLUtils.h"
28 #include "../../../se.h"
30 #include "ui_ContrastEnhancementWidgetForm.h"
31 
32 // Qt
33 
34 
35 // STL
36 #include <cassert>
37 
38 
40  : QWidget(parent, f),
41  m_ui(new Ui::ContrastEnhancementWidgetForm),
42  m_contrast(new te::se::ContrastEnhancement)
43 {
44  m_ui->setupUi(this);
45 
46  initialize();
47 
48  // Signals & slots
49  connect(m_ui->m_gammaDoubleSpinBox, SIGNAL(valueChanged(double)), SLOT(onGammaValueChanged(double)));
50  connect(m_ui->m_typeComboBox, SIGNAL(activated(QString)), SLOT(onTypeChanged(QString)));
51 }
52 
54 {
55  delete m_contrast;
56 
57  m_ceNames.clear();
58 }
59 
61 {
62  assert(ce);
63 
64  delete m_contrast;
65 
66  m_contrast = ce->clone();
67 
68  updateUi();
69 }
70 
72 {
73  return m_contrast->clone();
74 }
75 
77 {
78  //set the contrast enhancement names
79  m_ceNames.clear();
80 
81  m_ceNames.insert(std::map<te::se::ContrastEnhancement::ContrastEnhancementType, QString>::value_type
83  m_ceNames.insert(std::map<te::se::ContrastEnhancement::ContrastEnhancementType, QString>::value_type
85  m_ceNames.insert(std::map<te::se::ContrastEnhancement::ContrastEnhancementType, QString>::value_type
87 
88  //fill interface combo box
89  std::map<te::se::ContrastEnhancement::ContrastEnhancementType, QString>::iterator it = m_ceNames.begin();
90 
91  while(it != m_ceNames.end())
92  {
93  m_ui->m_typeComboBox->addItem(it->second);
94 
95  ++it;
96  }
97 
98  //set default values
99  m_contrast->setContrastEnhancementType(te::se::ContrastEnhancement::ENHANCEMENT_NONE);
100  m_contrast->setGammaValue(m_ui->m_gammaDoubleSpinBox->value());
101 
102  updateUi();
103 }
104 
106 {
107  m_ui->m_typeComboBox->setCurrentIndex(m_ui->m_typeComboBox->findText(m_ceNames[m_contrast->getContrastEnhancementType()]));
108  m_ui->m_gammaDoubleSpinBox->setValue(m_contrast->getGammaValue());
109 }
110 
112 {
113  m_contrast->setGammaValue(value);
114 
115  emit contrastEnhancementChanged();
116 }
117 
119 {
120  std::map<te::se::ContrastEnhancement::ContrastEnhancementType, QString>::iterator it = m_ceNames.begin();
121 
122  while(it != m_ceNames.end())
123  {
124  if(it->second == value)
125  {
126  m_contrast->setContrastEnhancementType(it->first);
127  break;
128  }
129 
130  ++it;
131  }
132 
133  emit contrastEnhancementChanged();
134 }
135 
std::auto_ptr< Ui::ContrastEnhancementWidgetForm > m_ui
Dialog form.
te::se::ContrastEnhancement * getContrastEnhancement() const
void updateUi()
Updates the widget form based on internal fill element.
ContrastEnhancementWidget(QWidget *parent=0, Qt::WindowFlags f=0)
Constructs a ContrastEnhancementWidget dialog which is a child of parent, with widget flags set to f...
A widget used to build ContrastEnhancement element.
ContrastEnhancement defines the 'stretching' of contrast for a channel of a false-color image or for ...
void initialize()
Internal method to initialize the widget (e.g.: color, combos, icons, etc.)
void setContrastEnhancement(te::se::ContrastEnhancement *ce)
ContrastEnhancement * clone() const
It creates a new copy of this object.