GroupingDialog.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/GroupingDialog.cpp
22 
23  \brief A dialog used to build a grouping.
24 */
25 
26 // TerraLib
27 #include "../../../dataaccess/dataset/DataSet.h"
28 #include "../../../dataaccess/dataset/DataSetType.h"
29 #include "../../../dataaccess/utils/Utils.h"
30 #include "../../../maptools/DataSetLayer.h"
31 #include "../../../maptools/RasterLayer.h"
32 #include "../../../se/ChannelSelection.h"
33 #include "../../../se/ColorMap.h"
34 #include "../../../se/CoverageStyle.h"
35 #include "../../../se/RasterSymbolizer.h"
36 #include "../../../se/SelectedChannel.h"
37 #include "../../../se/Utils.h"
38 #include "ColorMapWidget.h"
39 #include "GroupingDialog.h"
40 #include "GroupingWidget.h"
41 #include "ui_GroupingDialogForm.h"
42 
44  : QDialog(parent, f),
45  m_ui(new Ui::GroupingDialogForm),
46  m_groupingWidget(nullptr),
47  m_colorMapWidget(nullptr),
48  m_rasterSymb(nullptr)
49 {
50  m_ui->setupUi(this);
51 
52  m_ui->m_okPushButton->setEnabled(false);
53 
54  //connect
55  connect(m_ui->m_okPushButton, SIGNAL(clicked()), this, SLOT(onPushButtonClicked()));
56  m_ui->m_helpPushButton->setPageReference("widgets/grouping/grouping.html");
57 }
58 
60 
61 void te::qt::widgets::GroupingDialog::setLayers(te::map::AbstractLayerPtr selectedLayer, std::vector<te::map::AbstractLayerPtr> allLayers)
62 {
63  m_layer = selectedLayer;
64  m_allLayers = allLayers;
65 
66  setWindowTitle(windowTitle() + " (" + tr("Layer") + ":" + selectedLayer->getTitle().c_str() +")");
67 
68  //VERIFY LATER
69  std::unique_ptr<te::map::LayerSchema> dsType(selectedLayer->getSchema());
70 
71  if(dsType->hasGeom())
72  {
74  }
75  else if(dsType->hasRaster())
76  {
78 
79  if(selectedLayer->getType() == "DATASETLAYER")
80  {
81  te::map::DataSetLayer* l = dynamic_cast<te::map::DataSetLayer*>(selectedLayer.get());
82 
83  if(l)
84  {
86 
87  std::unique_ptr<te::da::DataSet> ds = m_layer->getData();
88 
89  if(ds.get())
90  {
91  std::size_t rpos = te::da::GetFirstPropertyPos(ds.get(), te::dt::RASTER_TYPE);
92  m_raster.reset(ds->getRaster(rpos).release());
93  }
94  }
95  }
96  else if(selectedLayer->getType() == "RASTERLAYER")
97  {
98  te::map::RasterLayer* l = dynamic_cast<te::map::RasterLayer*>(selectedLayer.get());
99 
100  if(l)
101  {
103 
104  m_raster.reset(l->getRaster());
105  }
106  }
107 
108  if(m_rasterSymb)
109  {
111  {
113  }
114  else
115  {
117 
119  }
120  }
121 
122  if(m_raster.get())
123  {
125  }
126  }
127 }
128 
130 {
131  // Fill Widget
133 
135 
136  connect(m_groupingWidget, SIGNAL(applyPushButtonClicked()), this, SLOT(onApplyClicked()));
137 
138  // Adjusting...
139  QGridLayout* layout = new QGridLayout(m_ui->m_widget);
140  layout->setContentsMargins(0,0,0,0);
141  layout->addWidget(m_groupingWidget);
142 }
143 
145 {
146  // Fill Widget
148 
150 
151  connect(m_colorMapWidget, SIGNAL(applyPushButtonClicked()), this, SLOT(onApplyClicked()));
152 
153  // Adjusting...
154  QGridLayout* layout = new QGridLayout(m_ui->m_widget);
155  layout->setContentsMargins(0,0,0,0);
156  layout->addWidget(m_colorMapWidget);
157 }
158 
160 {
161  if(m_groupingWidget)
162  {
164 
165  m_layer->setGrouping(g);
166 
168  }
169 
170  if(m_colorMapWidget)
171  {
173 
174  if (!cm)
175  reject();
176 
178 
179  std::string band = m_colorMapWidget->getCurrentBand();
180 
182 
183  if(cs->getGrayChannel())
184  {
185  te::se::SelectedChannel* scGray = cs->getGrayChannel();
186 
187  scGray->setSourceChannelName(band);
188  }
189  else
190  {
192 
193  scGray->setSourceChannelName(band);
194 
195  cs->setGrayChannel(scGray);
196  }
197 
199  }
200 
201  accept();
202 }
203 
205 {
206  m_ui->m_okPushButton->setEnabled(true);
207 }
unsigned int band
A selected channel to be display.
te::map::AbstractLayerPtr m_layer
Layer ptr.
A dialog used to build a ColorMap element.
GroupingDialog(QWidget *parent=0, Qt::WindowFlags f=0)
Constructs a basic fill dialog which is a child of parent, with widget flags set to f...
te::qt::widgets::GroupingWidget * m_groupingWidget
Grouping Widget used to configure the grouping operation.
TESEEXPORT RasterSymbolizer * GetRasterSymbolizer(Style *s)
Try to get raster symbolizer from a style.
te::rst::Raster * getRaster() const
te::se::ChannelSelection * getChannelSelection() const
void setGrayChannel(SelectedChannel *c)
static te::dt::Date ds(2010, 01, 01)
te::qt::widgets::ColorMapWidget * m_colorMapWidget
Color Map Widget used to configure the grouping operation over a raster.
A dialog used to build a grouping.
A widget used to build.
This class contains the parameters needed for grouping the values of a Property.
Definition: Grouping.h:57
std::unique_ptr< te::rst::Raster > m_raster
A widget used to build a grouping.
A layer with reference to a raster.
Definition: RasterLayer.h:52
void setColorMap(te::se::ColorMap *cm)
virtual te::se::Style * getStyle() const
It returns the Style associated to the layer.
void setColorCompositionType(ColorCompositionType cct)
void setLayers(te::map::AbstractLayerPtr selectedLayer, std::vector< te::map::AbstractLayerPtr > allLayers)
std::unique_ptr< Ui::GroupingDialogForm > m_ui
Dialog form.
void setRaster(te::rst::Raster *r)
void setLayers(te::map::AbstractLayerPtr selectedLayer, std::vector< te::map::AbstractLayerPtr > allLayers)
void setColorMap(ColorMap *c)
void setLayers(te::map::AbstractLayerPtr selectedLayer, std::vector< te::map::AbstractLayerPtr > allLayers)
te::se::ColorMap * getColorMap()
void setSourceChannelName(const std::string &name)
A widget used to build a grouping.
std::vector< te::map::AbstractLayerPtr > m_allLayers
All Project Layers with Grouping.
std::unique_ptr< te::map::Grouping > getGrouping()
te::se::RasterSymbolizer * m_rasterSymb
te::se::ColorMap * getColorMap() const
A layer with reference to a dataset.
Definition: DataSetLayer.h:47
TEDATAACCESSEXPORT std::size_t GetFirstPropertyPos(const te::da::DataSet *dataset, int datatype)
SelectedChannel * getGrayChannel() const
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
A ColorMap defines either the colors of a pallette-type raster source or the mapping of numeric pixel...
Definition: ColorMap.h:61
ChannelSelection specifies the false-color channel selection for a multi-spectral raster source (such...