MixtureModelAction.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/rp/MixtureModelAction.cpp
22 
23  \brief This file defines the mixture model class
24 */
25 
26 // Terralib
27 #include "../../../qt/widgets/rp/MixtureModelWizard.h"
28 #include "../../af/ApplicationController.h"
29 #include "../../af/BaseApplication.h"
30 #include "../../af/events/LayerEvents.h"
31 #include "MixtureModelAction.h"
32 
33 // Qt
34 #include <QObject>
35 #include <QMessageBox>
36 
37 // STL
38 #include <memory>
39 
40 te::qt::plugins::rp::MixtureModelAction::MixtureModelAction(QMenu* menu, QMenu* popupMenu):te::qt::plugins::rp::AbstractAction(menu, popupMenu)
41 {
42  createAction(tr("Mixture Model...").toUtf8().data(), "mixmodel");
43  m_action->setObjectName("Processing.Raster Processing.Mixture Model");
44 
45  //createPopUpAction(tr("Mixture Model...").toUtf8().data(), "mixmodel");
46 }
47 
49 
51  bool /*checked*/)
52 {
54 
56 
58  m_mixtureModelWizard->setMapDisplay(ba->getMapDisplay());
59 
60  connect(m_mixtureModelWizard.get(), SIGNAL(addLayer(te::map::AbstractLayerPtr)), this, SLOT(addLayerSlot(te::map::AbstractLayerPtr)));
61 
62  connect(m_mixtureModelWizard.get(), SIGNAL(finished(int)), this, SLOT(onMixtureModelWizardFinished()));
63 
64  QActionGroup* mapEditionTools = te::qt::af::AppCtrlSingleton::getInstance().findActionGroup("Map.ToolsGroup");
65  assert(mapEditionTools);
66 
67  m_mixtureModelWizard->setActionGroup(mapEditionTools);
68 
69  std::list<te::map::AbstractLayerPtr> layersList = getLayers();
70 
71  m_mixtureModelWizard->setAttribute(Qt::WA_DeleteOnClose);
72 
73  m_mixtureModelWizard->setList(layersList);
74 
75  m_mixtureModelWizard->setModal(false);
76 
77  m_mixtureModelWizard->show();
78 }
79 
81 {
82  te::qt::af::AppCtrlSingleton::getInstance().removeListener(this);
83 
84  m_mixtureModelWizard.release();
85 }
86 
88  bool /*checked*/)
89 {
90  std::list<te::map::AbstractLayerPtr> layer;
91  layer.push_back(getCurrentLayer());
92 
93  if (layer.size())
94  {
96 
97  dlg.setLayer(layer);
98 
99  if(dlg.exec() == QDialog::Accepted)
100  {
101  //add new layer
102  std::list<te::map::AbstractLayerPtr>::iterator itl;
103  for (itl = dlg.getOutputLayers().begin(); itl != dlg.getOutputLayers().end();++itl)
104  addNewLayer(*itl);
105  }
106  }
107  else
108  {
109  QMessageBox::warning(te::qt::af::AppCtrlSingleton::getInstance().getMainWindow(), tr("Warning"), tr("The layer selected is invalid or does not have an raster representation."));
110  }
111 }
112 
114 {
115  addNewLayer(layer);
116 }
117 
119 {
120  switch(e->m_id)
121  {
123  {
124  m_mixtureModelWizard->onMapDisplayExtentChanged();
125  }
126  break;
127 
128  default:
129  break;
130  }
131 }
This is an abstract class used to register actions into rp pluging.
This file defines the mixture model class.
This class is GUI used to define the mixture model wizard for the RP constast operation.
std::list< te::map::AbstractLayerPtr > getOutputLayers()
A base class for application events.
MixtureModelAction(QMenu *menu, QMenu *popupMenu)
void onApplicationTriggered(te::qt::af::evt::Event *e)
virtual void onPopUpActionActivated(bool checked)
std::unique_ptr< te::qt::widgets::MixtureModelWizard > m_mixtureModelWizard
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.
virtual void onActionActivated(bool checked)
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.
te::qt::widgets::MapDisplay * getMapDisplay()
void addLayerSlot(te::map::AbstractLayerPtr layer)
void addNewLayer(te::map::AbstractLayerPtr layer)
Add a new layer into layer explorer widget.
void setLayer(std::list< te::map::AbstractLayerPtr > layers)
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
std::list< te::map::AbstractLayerPtr > getLayers()
Get the list of layers from app.