All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
SelectedChannelWidget.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/SelectedChannelWidget.cpp
22 
23  \brief A dialog used to build a SelectedChannel element.
24 */
25 
26 // TerraLib
27 #include "../../../common/STLUtils.h"
29 #include "SelectedChannelWidget.h"
30 #include "ui_SelectedChannelWidgetForm.h"
31 #include "../../../se.h"
32 
33 // Qt
34 
35 
36 // STL
37 #include <cassert>
38 
39 
41  : QWidget(parent, f),
42  m_ui(new Ui::SelectedChannelWidgetForm),
43  m_se(new te::se::SelectedChannel)
44 {
45  m_ui->setupUi(this);
46 
47  //Constrast Enhancement Widget
49 
50  // Adjusting...
51  QGridLayout* layout = new QGridLayout(m_ui->m_contrastEnhancementFrame);
52  layout->addWidget(m_contrastWidget);
53 
54  // Signals & slots
55  connect(m_ui->m_channelNameComboBox, SIGNAL(activated(QString)), SLOT(onChannelNameChanged(QString)));
56  connect(m_contrastWidget, SIGNAL(contrastEnhancementChanged()), SLOT(onContrastEnhancementChanged()));
57 
58  initialize();
59 }
60 
62 {
63 // delete m_se;
64 }
65 
67 {
68  assert(sc);
69 
70  //delete m_se;
71 
72  m_se = sc;//->clone();
73 
74  updateUi();
75 }
76 
78 {
79  m_se->setContrastEnhancement(m_contrastWidget->getContrastEnhancement());
80 
81  return m_se;//->clone();
82 }
83 
85 {
86  m_ui->m_channelNameComboBox->clear();
87  m_ui->m_channelNameComboBox->addItems(list);
88 
89  m_se->setSourceChannelName(m_ui->m_channelNameComboBox->currentText().toLatin1().data());
90 }
91 
93 {
94 }
95 
97 {
98  // update the channel name
99  QString name = m_se->getSourceChannelName().c_str();
100 
101  bool found = false;
102 
103  for(int i = 0; i < m_ui->m_channelNameComboBox->count(); ++i)
104  {
105  if(m_ui->m_channelNameComboBox->itemText(i) == name)
106  {
107  m_ui->m_channelNameComboBox->setCurrentIndex(i);
108  found = true;
109  break;
110  }
111  }
112 
113  if(!found)
114  {
115  m_ui->m_channelNameComboBox->addItem(m_se->getSourceChannelName().c_str());
116  m_ui->m_channelNameComboBox->setCurrentIndex(m_ui->m_channelNameComboBox->count() - 1);
117  }
118 
119  if(m_se->getContrastEnhancement())
120  {
121  m_contrastWidget->setContrastEnhancement(m_se->getContrastEnhancement());
122  }
123 }
124 
126 {
127  m_se->setSourceChannelName(value.toLatin1().data());
128 
129  emit selectedChannelChanged();
130 }
131 
133 {
134  m_se->setContrastEnhancement(m_contrastWidget->getContrastEnhancement());
135 
136  emit selectedChannelChanged();
137 }
A selected channel to be display.
void setChannelNames(const QStringList &list)
std::auto_ptr< Ui::SelectedChannelWidgetForm > m_ui
Dialog form.
te::se::SelectedChannel * getSelectedChannel() const
A widget used to build ContrastEnhancement element.
A widget used to build SelectedChannel element.
void updateUi()
Updates the widget form based on internal fill element.
A dialog used to build a ContrastEnhancementWidget element.
te::qt::widgets::ContrastEnhancementWidget * m_contrastWidget
Constrast Widget form.
void setSelectedChannel(te::se::SelectedChannel *sc)
void setContrastEnhancement(ContrastEnhancement *c)
void initialize()
Internal method to initialize the widget (e.g.: color, combos, icons, etc.)
SelectedChannelWidget(QWidget *parent=0, Qt::WindowFlags f=0)
Constructs a SelectedChannelWidget dialog which is a child of parent, with widget flags set to f...