All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Plugin.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/sa/Plugin.cpp
22 
23  \brief Plugin implementation for the SA Qt Plugin widget.
24 */
25 
26 // TerraLib
27 #include "../../../common/Config.h"
28 #include "../../../common/Translator.h"
29 #include "../../../common/Logger.h"
30 #include "../../af/ApplicationController.h"
31 #include "../../af/events/LayerEvents.h"
32 #include "../../af/Utils.h"
33 #include "Plugin.h"
34 
35 #ifdef TE_QT_PLUGIN_SA_HAVE_BAYESGLOBAL
36  #include "BayesGlobalAction.h"
37 #endif
38 
39 #ifdef TE_QT_PLUGIN_SA_HAVE_BAYESLOCAL
40  #include "BayesLocalAction.h"
41 #endif
42 
43 #ifdef TE_QT_PLUGIN_SA_HAVE_KERNELMAP
44  #include "KernelMapAction.h"
45 #endif
46 
47 #ifdef TE_QT_PLUGIN_SA_HAVE_KERNELRATIO
48  #include "KernelRatioAction.h"
49 #endif
50 
51 #ifdef TE_QT_PLUGIN_SA_HAVE_GEOSTATISTICALMETHODS
53 #endif
54 
55 #ifdef TE_QT_PLUGIN_SA_HAVE_PROXIMITYMATRIXCREATOR
57 #endif
58 
59 #ifdef TE_QT_PLUGIN_SA_HAVE_SAMPLEPOINTSGENERATOR
61 #endif
62 
63 #ifdef TE_QT_PLUGIN_SA_HAVE_SKATER
64  #include "SkaterAction.h"
65 #endif
66 
67 #ifdef TE_QT_PLUGIN_SA_HAVE_SPATIALSTATISTICS
68  #include "SpatialStatisticsAction.h"
69 #endif
70 
71 
72 // QT
73 #include <QMenu>
74 #include <QMenuBar>
75 
77  : te::plugin::Plugin(pluginInfo), m_saMenu(0)
78 {
79 }
80 
82 {
83 }
84 
86 {
87  if(m_initialized)
88  return;
89 
90  TE_LOG_TRACE(TE_TR("TerraLib Qt SA Plugin startup!"));
91 
92  // add sa entry in plugin menu
93  QMenu* pluginMenu = te::qt::af::ApplicationController::getInstance().getMenu("Processing");
94  m_saMenu = new QMenu(pluginMenu);
95  m_saMenu->setIcon(QIcon::fromTheme("sa-spatialanalysis-icon"));
96 
97  // Insert action before plugin manager action
98  QAction* pluginsSeparator = te::qt::af::ApplicationController::getInstance().findAction("ManagePluginsSeparator");
99 
100  pluginMenu->insertMenu(pluginsSeparator, m_saMenu);
101 
102  m_saMenu->setTitle(TE_TR("Spatial Analysis"));
103 
104 // add pop up menu
105  m_popupAction = new QAction(m_saMenu);
106  m_popupAction->setText(TE_TR("Spatial Analysis"));
107 
108 // register actions
109  registerActions();
110 
111  m_initialized = true;
112 }
113 
115 {
116  if(!m_initialized)
117  return;
118 
119 // remove menu
120  delete m_saMenu;
121 
122 // unregister actions
123  unRegisterActions();
124 
125  TE_LOG_TRACE(TE_TR("TerraLib Qt SA Plugin shutdown!"));
126 
127  m_initialized = false;
128 }
129 
131 {
132 
133 #ifdef TE_QT_PLUGIN_SA_HAVE_PROXIMITYMATRIXCREATOR
134  m_proxMatrixCreator = new te::qt::plugins::sa::ProximityMatrixCreatorAction(m_saMenu);
135  te::qt::af::AddActionToCustomToolbars(m_proxMatrixCreator->getAction());
136 #endif
137 
138 #ifdef TE_QT_PLUGIN_SA_HAVE_SPATIALSTATISTICS
139  m_saMenu->addSeparator();
140  m_spatialStatistics = new te::qt::plugins::sa::SpatialStatisticsAction(m_saMenu);
141  te::qt::af::AddActionToCustomToolbars(m_spatialStatistics->getAction());
142 #endif
143 
144 #ifdef TE_QT_PLUGIN_SA_HAVE_BAYESGLOBAL
145  m_saMenu->addSeparator();
146  m_bayesGlobal = new te::qt::plugins::sa::BayesGlobalAction(m_saMenu);
147  te::qt::af::AddActionToCustomToolbars(m_bayesGlobal->getAction());
148 #endif
149 
150 #ifdef TE_QT_PLUGIN_SA_HAVE_BAYESLOCAL
151  m_bayesLocal = new te::qt::plugins::sa::BayesLocalAction(m_saMenu);
152  te::qt::af::AddActionToCustomToolbars(m_bayesLocal->getAction());
153 #endif
154 
155 #ifdef TE_QT_PLUGIN_SA_HAVE_KERNELMAP
156  m_saMenu->addSeparator();
157  m_kernelMap = new te::qt::plugins::sa::KernelMapAction(m_saMenu);
158  te::qt::af::AddActionToCustomToolbars(m_kernelMap->getAction());
159 #endif
160 
161 #ifdef TE_QT_PLUGIN_SA_HAVE_KERNELRATIO
162  m_kernelRatio = new te::qt::plugins::sa::KernelRatioAction(m_saMenu);
163  te::qt::af::AddActionToCustomToolbars(m_kernelRatio->getAction());
164 #endif
165 
166 #ifdef TE_QT_PLUGIN_SA_HAVE_SKATER
167  m_saMenu->addSeparator();
168  m_skater = new te::qt::plugins::sa::SkaterAction(m_saMenu);
169  te::qt::af::AddActionToCustomToolbars(m_skater->getAction());
170 #endif
171 
172 #ifdef TE_QT_PLUGIN_SA_HAVE_GEOSTATISTICALMETHODS
173  m_saMenu->addSeparator();
174  m_geostatistics = new te::qt::plugins::sa::GeostatisticalMethodsAction(m_saMenu);
175  te::qt::af::AddActionToCustomToolbars(m_geostatistics->getAction());
176 #endif
177 
178 #ifdef TE_QT_PLUGIN_SA_HAVE_SAMPLEPOINTSGENERATOR
179  m_saMenu->addSeparator();
180  m_samplePointsGenerator = new te::qt::plugins::sa::SamplePointsGeneratorAction(m_saMenu);
181  te::qt::af::AddActionToCustomToolbars(m_samplePointsGenerator->getAction());
182 #endif
183 
184 }
185 
187 {
188 
189 #ifdef TE_QT_PLUGIN_SA_HAVE_BAYESGLOBAL
190  delete m_bayesGlobal;
191 #endif
192 
193 #ifdef TE_QT_PLUGIN_SA_HAVE_BAYESLOCAL
194  delete m_bayesLocal;
195 #endif
196 
197 #ifdef TE_QT_PLUGIN_SA_HAVE_KERNELMAP
198  delete m_kernelMap;
199 #endif
200 
201 #ifdef TE_QT_PLUGIN_SA_HAVE_KERNELRATIO
202  delete m_kernelRatio;
203 #endif
204 
205 #ifdef TE_QT_PLUGIN_SA_HAVE_GEOSTATISTICALMETHODS
206  delete m_geostatistics;
207 #endif
208 
209 #ifdef TE_QT_PLUGIN_SA_HAVE_PROXIMITYMATRIXCREATOR
210  delete m_proxMatrixCreator;
211 #endif
212 
213 #ifdef TE_QT_PLUGIN_SA_HAVE_SAMPLEPOINTSGENERATOR
214  delete m_samplePointsGenerator;
215 #endif
216 
217 #ifdef TE_QT_PLUGIN_SA_HAVE_SKATER
218  delete m_skater;
219 #endif
220 
221 #ifdef TE_QT_PLUGIN_SA_HAVE_SPATIALSTATISTICS
222  delete m_spatialStatistics;
223 #endif
224 
225 }
226 
#define TE_LOG_TRACE(msg)
Use this tag in order to log a message to a specified logger with the TRACE level.
Definition: Logger.h:137
Plugin(const te::plugin::PluginInfo &pluginInfo)
Definition: Plugin.cpp:76
This file defines the concrete class for Geostatistical Methods Action.
This file defines the concrete class for SpatialStatistics Action.
#define TE_TR(message)
It marks a string in order to get translated.
Definition: Translator.h:347
This file defines the concrete class for Skater Action.
#define PLUGIN_CALL_BACK_IMPL(PLUGIN_CLASS_NAME)
This macro should be used by C++ plugins in order to declare the exportable/callable DLL function...
Definition: Config.h:57
TEQTAFEXPORT void AddActionToCustomToolbars(QAction *act)
Check QSettings for existance of act and adds it if necessary.
Definition: Utils.cpp:763
~Plugin()
Virtual destructor.
Definition: Plugin.cpp:81
static ApplicationController & getInstance()
It returns a reference to the singleton instance.
This file defines the concrete class for KernelMap Action.
This file defines the concrete class for BayesLocal Action.
void unRegisterActions()
Function used to unregister all raster processing actions.
Definition: Plugin.cpp:186
void shutdown()
Do nothing! Just set plugin as stopped.
Definition: Plugin.cpp:114
void startup()
Do nothing! Just set plugin as started.
Definition: Plugin.cpp:85
Plugin implementation for the SA Qt Plugin widget.
This file defines the concrete class for SamplePointsGenerator Action.
This file defines the concrete class for ProximityMatrixCreator Action.
void registerActions()
Function used to register all raster processing actions.
Definition: Plugin.cpp:130
The basic information about a plugin.
Definition: PluginInfo.h:61
This file defines the concrete class for KernelRatio Action.
This file defines the concrete class for BayesGlobal Action.