All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ChannelSelectionWidget.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/ChannelSelectionWidget.cpp
22 
23  \brief A dialog used to build a ChannelSelection element.
24 */
25 
26 // TerraLib
27 #include "../../../common/STLUtils.h"
28 #include "ChannelSelectionWidget.h"
29 #include "SelectedChannelWidget.h"
30 #include "ui_ChannelSelectionWidgetForm.h"
31 #include "../../../raster.h"
32 #include "../../../se.h"
33 
34 // Qt
35 
36 
37 // STL
38 #include <cassert>
39 
41  : QWidget(parent, f),
42  m_ui(new Ui::ChannelSelectionWidgetForm),
43  m_scRed(new te::se::SelectedChannel),
44  m_scGreen(new te::se::SelectedChannel),
45  m_scBlue(new te::se::SelectedChannel),
46  m_scMono(new te::se::SelectedChannel),
47  m_cs(new te::se::ChannelSelection)
48 {
49  m_ui->setupUi(this);
50 
51  //Selected Channel Widget
53 
54  // Adjusting...
55  QGridLayout* layout = new QGridLayout(m_ui->m_frame);
56  layout->setContentsMargins(0,0,0,0);
57  layout->addWidget(m_sCWidget);
58  m_sCWidget->show();
59 
60  // Signals & slots
61  connect(m_ui->m_rgbColorRadioButton, SIGNAL(clicked()), SLOT(onRGBColorSelected()));
62  connect(m_ui->m_grayScaleRadioButton, SIGNAL(clicked()), SLOT(onGrayScalelSelected()));
63 
64  connect(m_ui->m_redRadioButton, SIGNAL(clicked()), SLOT(onRedChannelSelected()));
65  connect(m_ui->m_greenRadioButton, SIGNAL(clicked()), SLOT(onGreenChannelSelected()));
66  connect(m_ui->m_blueRadioButton, SIGNAL(clicked()), SLOT(onBlueChannelSelected()));
67  connect(m_ui->m_monoRadioButton, SIGNAL(clicked()), SLOT(onGrayScalelSelected()));
68 
69 
70  connect(m_sCWidget, SIGNAL(selectedChannelChanged()), SLOT(onSelectedChannelChanged()));
71 
72  initialize();
73 }
74 
76 {
77  delete m_cs;
78 }
79 
81 {
82  assert(cs);
83 
84  delete m_cs;
85 
86  m_cs = cs->clone();
87 }
88 
90 {
91  return m_cs->clone();
92 }
93 
94 void te::qt::widgets::ChannelSelectionWidget::setProperty(std::vector<te::rst::BandProperty*>& p)
95 {
96  m_bands = p;
97 
98  updateUi();
99 }
100 
102 {
103  m_cs->setRedChannel(m_scRed);
104  m_cs->setGreenChannel(m_scGreen);
105  m_cs->setBlueChannel(m_scBlue);
106  m_cs->setGrayChannel(m_scMono);
107 }
108 
110 {
111  QStringList bandNames;
112 
113  for(size_t i = 0; i < m_bands.size(); ++i)
114  {
115  // if the band property does not have the description information
116  // we must used the index information.
117  if(m_bands[i]->m_description.empty())
118  {
119  QString bandInfo;
120  bandInfo.setNum(m_bands[i]->m_idx);
121 
122  bandNames.push_back(bandInfo);
123  }
124  else
125  {
126  bandNames.push_back(m_bands[i]->m_description.c_str());
127  }
128  }
129 
130  if(m_sCWidget)
131  {
132  m_sCWidget->setChannelNames(bandNames);
133  }
134 }
135 
137 {
138  m_ui->m_redRadioButton->setEnabled(true);
139  m_ui->m_greenRadioButton->setEnabled(true);
140  m_ui->m_blueRadioButton->setEnabled(true);
141  m_ui->m_monoRadioButton->setEnabled(false);
142 
143  m_ui->m_redRadioButton->setChecked(true);
144  onRedChannelSelected();
145 }
146 
148 {
149  m_ui->m_redRadioButton->setEnabled(false);
150  m_ui->m_greenRadioButton->setEnabled(false);
151  m_ui->m_blueRadioButton->setEnabled(false);
152  m_ui->m_monoRadioButton->setEnabled(true);
153 
154  m_ui->m_monoRadioButton->setChecked(true);
155 
156 
157  m_sCWidget->setSelectedChannel(m_scMono);
158 }
159 
161 {
162  if(m_ui->m_redRadioButton->isChecked())
163  {
164  m_sCWidget->setSelectedChannel(m_scRed);
165  }
166 }
167 
169 {
170  if(m_ui->m_greenRadioButton->isChecked())
171  {
172  m_sCWidget->setSelectedChannel(m_scGreen);
173  }
174 }
175 
177 {
178  if(m_ui->m_blueRadioButton->isChecked())
179  {
180  m_sCWidget->setSelectedChannel(m_scBlue);
181  }
182 }
184 {
185  if(m_ui->m_monoRadioButton->isChecked())
186  {
187  m_sCWidget->setSelectedChannel(m_scMono);
188  }
189 }
190 
192 {
193  if(m_ui->m_redRadioButton->isChecked())
194  {
195  m_scRed = m_sCWidget->getSelectedChannel();
196  }
197  else if(m_ui->m_greenRadioButton->isChecked())
198  {
199  m_scGreen = m_sCWidget->getSelectedChannel();
200  }
201  else if(m_ui->m_blueRadioButton->isChecked())
202  {
203  m_scBlue = m_sCWidget->getSelectedChannel();
204  }
205  else if(m_ui->m_monoRadioButton->isChecked())
206  {
207  m_scMono = m_sCWidget->getSelectedChannel();
208  }
209 }
ChannelSelection * clone() const
It creates a new copy of this object.
void setChannelSelection(const te::se::ChannelSelection *cs)
void setProperty(std::vector< te::rst::BandProperty * > &p)
Sets the band information.
std::auto_ptr< Ui::ChannelSelectionWidgetForm > m_ui
Dialog form.
void initialize()
Internal method to initialize the widget (e.g.: color, combos, icons, etc.)
A widget used to build SelectedChannel element.
void updateUi()
Updates the widget form based on internal mark element.
te::qt::widgets::SelectedChannelWidget * m_sCWidget
Selected Channel Widget.
te::se::ChannelSelection * getChannelSelection() const
A dialog used to build a SelectedChannelWidget element.
ChannelSelectionWidget(QWidget *parent=0, Qt::WindowFlags f=0)
Constructs a ChannelSelectionWidget dialog which is a child of parent, with widget flags set to f...
A widget used to build.
ChannelSelection specifies the false-color channel selection for a multi-spectral raster source (such...