CloudDetectionAction.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/plugins/cellspace/CreateCellLayerAction.cpp
22 
23  \brief This file defines the CreateCellLayer class
24 */
25 
26 // Terralib
27 #include "../../../qt/widgets/rp/CloudDetectionDialog.h"
28 #include "../../af/ApplicationController.h"
29 #include "../../af/BaseApplication.h"
30 #include "../../af/events/LayerEvents.h"
31 #include "CloudDetectionAction.h"
32 
33 // Qt
34 #include <QObject>
35 #include <QMessageBox>
36 #include <QActionGroup>
37 
38 // STL
39 #include <memory>
40 
41 te::qt::plugins::rp::CloudDetectionAction::CloudDetectionAction(QMenu* menu, QMenu* popupMenu):te::qt::plugins::rp::AbstractAction(menu, popupMenu)
42 {
43  createAction(tr("Cloud Detection...").toUtf8().data(), "cloudDetection");
44  m_action->setObjectName("Processing.Raster Processing.Cloud Detection");
45 }
46 
48 
50  bool /*checked*/)
51 {
53 
54  if(!layer.get())
55  {
56  QMessageBox::warning(te::qt::af::AppCtrlSingleton::getInstance().getMainWindow(), tr("Cloud Detection"), tr("There is no selected raster layer."));
57  return;
58  }
59 
60  if(layer->getVisibility() != te::map::VISIBLE)
61  {
62  QMessageBox::warning(te::qt::af::AppCtrlSingleton::getInstance().getMainWindow(), tr("Cloud Detection"), tr("The layer is not checked."));
63  return;
64  }
65 
67 
68  connect(m_dlg.get(), SIGNAL(addLayer(te::map::AbstractLayerPtr)), this, SLOT(addLayer(te::map::AbstractLayerPtr)));
69  connect(m_dlg.get(), SIGNAL(closeTool()), this, SLOT(closeTool()));
70 
72 
73  QActionGroup* mapEditionTools = te::qt::af::AppCtrlSingleton::getInstance().findActionGroup("Map.ToolsGroup");
74  assert(mapEditionTools);
75 
76  m_dlg->setMapDisplay(ba->getMapDisplay());
77  m_dlg->setActionGroup(mapEditionTools);
78  m_dlg->setLayers(getLayers());
79  m_dlg->setModal(false);
80  m_dlg->setUserPath(te::qt::af::AppCtrlSingleton::getInstance().getUserDataDir().toUtf8().data());
81  m_dlg->show();
82 }
83 
85 {
86  te::qt::af::evt::LayerAdded evt(outputLayer);
87 
88  emit triggered(&evt);
89 }
90 
92 {
93  te::qt::af::evt::LayerAdded evt(layer.get());
94 
95  emit triggered(&evt);
96 }
97 
98 std::list<te::map::AbstractLayerPtr> te::qt::plugins::rp::CloudDetectionAction::getLayers()
99 {
102 
103  emit triggered(&e);
104  emit triggered(&ed);
105 
106  std::list<te::map::AbstractLayerPtr> layers = e.m_layers;
107  te::map::AbstractLayerPtr selectedlayer = ed.m_layer;
108 
109  if (!selectedlayer)
110  return layers;
111 
112  std::list<te::map::AbstractLayerPtr> result;
113 
114  result.push_back(selectedlayer);
115 
116  for (std::list<te::map::AbstractLayerPtr>::iterator it = layers.begin(); it != layers.end(); ++it)
117  {
118  if ((*it)->getId() != selectedlayer->getId())
119  result.push_back(*it);
120  }
121 
122  return result;
123 }
124 
126 {
127  m_dlg.reset(nullptr);
128 }
This event signals that a new layer was created.
Definition: LayerEvents.h:71
This is an abstract class used to register actions into rp pluging.
te::map::AbstractLayerPtr m_layer
Layer selected.
Definition: LayerEvents.h:336
This event is used to get a single layer selected in layer tree.
Definition: LayerEvents.h:325
CloudDetectionAction(QMenu *menu, QMenu *popupMenu)
void addLayer(te::map::AbstractLayerPtr outputLayer)
void addNewLayer(te::map::AbstractLayerPtr layer)
Add a new layer into layer explorer widget.
std::unique_ptr< te::qt::widgets::CloudDetectionDialog > m_dlg
static ApplicationController & getInstance()
It returns a reference to the singleton instance.
void createAction(std::string name, std::string pixmap="")
Create and set the actions parameters.
te::map::AbstractLayerPtr getCurrentLayer()
Get the selected layer from layer explorer in app.
URI C++ Library.
Definition: Attributes.h:37
QAction * m_action
Action used to call the process.
std::list< te::map::AbstractLayerPtr > getLayers()
Get the list of layers from app.
void triggered(te::qt::af::evt::Event *e)
std::list< te::map::AbstractLayerPtr > m_layers
Definition: LayerEvents.h:345
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr