PCAAction.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/PCAAction.cpp
22 
23  \brief This file defines the PCA class
24 */
25 
26 // Terralib
27 #include "../../../qt/widgets/rp/PCAWizard.h"
28 #include "../../../raster/Raster.h"
29 #include "../../af/ApplicationController.h"
30 #include "../../af/BaseApplication.h"
31 #include "../../af/events/LayerEvents.h"
32 #include "PCAAction.h"
33 
34 // Qt
35 #include <QObject>
36 #include <QMessageBox>
37 
38 // STL
39 #include <memory>
40 
41 te::qt::plugins::rp::PCAAction::PCAAction(QMenu* menu, QMenu* popupMenu):te::qt::plugins::rp::AbstractAction(menu, popupMenu)
42 {
43  createAction(tr("PCA...").toUtf8().data(), "pca");
44  m_action->setObjectName("Processing.Raster Processing.PCA");
45 
46  createPopUpAction(tr("PCA...").toUtf8().data(), "Principal Components Analysis");
47 }
48 
50 
52 {
54 
56 
57 /// -- ?????????
58 // -> te::qt::af::BaseApplication* ba = dynamic_cast<te::qt::af::BaseApplication*>(te::qt::af::AppCtrlSingleton::getInstance().getMainWindow());
59 // m_Wizard->setMapDisplay(ba->getMapDisplay());
60 
61  connect(m_Wizard.get(), SIGNAL(addLayer(te::map::AbstractLayerPtr)), this, SLOT(addLayerSlot(te::map::AbstractLayerPtr)));
62 
63  connect(m_Wizard.get(), SIGNAL(finished(int)), this, SLOT(onPCAWizardFinished()));
64 
65 // m_Wizard->setActionGroup(mapEditionTools);
66 
67  std::list<te::map::AbstractLayerPtr> layersList = getLayers();
68 
69  m_Wizard->setAttribute(Qt::WA_DeleteOnClose);
70 
71  m_Wizard->setList(layersList);
72 
73  m_Wizard->setModal(false);
74 
75  m_Wizard->show();
76 }
77 
79 {
80  addNewLayer(layer);
81 }
82 
84 {
85  te::qt::af::AppCtrlSingleton::getInstance().removeListener(this);
86 
87  m_Wizard.release();
88 }
89 
91 {
93 
94  if(layer.get())
95  {
97 
98  dlg.setLayer(layer);
99 
100  if(dlg.exec() == QDialog::Accepted)
101  {
102  addNewLayer( dlg.getOutputLayer() );
103  }
104  }
105  else
106  {
107  QMessageBox::warning(te::qt::af::AppCtrlSingleton::getInstance().getMainWindow(), tr("Warning"), tr("The layer selected is invalid or does not have an raster representation."));
108  }
109 }
110 
112 {
113 }
This is an abstract class used to register actions into rp pluging.
virtual void onPopUpActionActivated(bool checked)
Definition: PCAAction.cpp:90
void createPopUpAction(std::string name, std::string pixmap="")
Create and set the actions parameters.
virtual void onActionActivated(bool checked)
Definition: PCAAction.cpp:51
A base class for application events.
virtual void onPCAWizardFinished()
Definition: PCAAction.cpp:83
void onApplicationTriggered(te::qt::af::evt::Event *e)
Definition: PCAAction.cpp:111
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.
void addLayerSlot(te::map::AbstractLayerPtr layer)
Definition: PCAAction.cpp:78
te::map::AbstractLayerPtr getOutputLayer()
This function returns the layer that has been created by the wizard with the sliced raster...
Definition: PCAWizard.cpp:107
This file defines the PCA class.
void setLayer(te::map::AbstractLayerPtr layer)
This function sets the layer that contains the raster that will be sliced.
Definition: PCAWizard.cpp:127
void addNewLayer(te::map::AbstractLayerPtr layer)
Add a new layer into layer explorer widget.
std::unique_ptr< te::qt::widgets::PCAWizard > m_Wizard
Definition: PCAAction.h:73
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
PCAAction(QMenu *menu, QMenu *popupMenu)
Definition: PCAAction.cpp:41
std::list< te::map::AbstractLayerPtr > getLayers()
Get the list of layers from app.