src/terralib/qt/plugins/sa/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 "../../../core/translator/Translator.h"
29 #include "../../../core/logger/Logger.h"
30 #include "../../../graph/Module.h"
31 #include "../../af/ApplicationController.h"
32 #include "../../af/events/LayerEvents.h"
33 #include "../../af/Utils.h"
34 #include "Plugin.h"
35 
36 #ifdef TE_QT_PLUGIN_SA_HAVE_BAYESGLOBAL
37  #include "BayesGlobalAction.h"
38 #endif
39 
40 #ifdef TE_QT_PLUGIN_SA_HAVE_BAYESLOCAL
41  #include "BayesLocalAction.h"
42 #endif
43 
44 #ifdef TE_QT_PLUGIN_SA_HAVE_KERNELMAP
45  #include "KernelMapAction.h"
46 #endif
47 
48 #ifdef TE_QT_PLUGIN_SA_HAVE_KERNELRATIO
49  #include "KernelRatioAction.h"
50 #endif
51 
52 #ifdef TE_QT_PLUGIN_SA_HAVE_GEOSTATISTICALMETHODS
54 #endif
55 
56 #ifdef TE_QT_PLUGIN_SA_HAVE_PROXIMITYMATRIXCREATOR
58 #endif
59 
60 #ifdef TE_QT_PLUGIN_SA_HAVE_SAMPLEPOINTSGENERATOR
62 #endif
63 
64 #ifdef TE_QT_PLUGIN_SA_HAVE_SKATER
65  #include "SkaterAction.h"
66 #endif
67 
68 #ifdef TE_QT_PLUGIN_SA_HAVE_SPATIALSTATISTICS
69  #include "SpatialStatisticsAction.h"
70 #endif
71 
72 
73 // QT
74 #include <QMenu>
75 #include <QMenuBar>
76 
78  : te::core::CppPlugin(pluginInfo), m_saMenu(nullptr)
79 {
80 }
81 
83 
85 {
86  if(m_initialized)
87  return;
88 
89  //initialize graph module
91 
92  TE_LOG_TRACE(TE_TR("TerraLib Qt SA Plugin startup!"));
93 
94  // add sa entry in plugin menu
95  QMenu* pluginMenu = te::qt::af::AppCtrlSingleton::getInstance().getMenu("Processing");
96  m_saMenu = new QMenu(pluginMenu);
97  m_saMenu->setIcon(QIcon::fromTheme("sa-spatialanalysis-icon"));
98 
99  // Insert action before plugin manager action
100  QAction* pluginsSeparator = te::qt::af::AppCtrlSingleton::getInstance().findAction("ManagePluginsSeparator");
101 
102  pluginMenu->insertMenu(pluginsSeparator, m_saMenu);
103 
104  m_saMenu->setTitle(tr("Spatial Analysis"));
105 
106 // add pop up menu
107  m_popupAction = new QAction(m_saMenu);
108  m_popupAction->setText(tr("Spatial Analysis"));
109 
110 // register actions
111  registerActions();
112 
113  m_initialized = true;
114 
116 }
117 
119 {
120  if(!m_initialized)
121  return;
122 
123 // remove menu
124  delete m_saMenu;
125 
126 // unregister actions
128 
129  TE_LOG_TRACE(TE_TR("TerraLib Qt SA Plugin shutdown!"));
130 
131  m_initialized = false;
132 
133  te::qt::af::AppCtrlSingleton::getInstance().removeListener(this);
134 }
135 
137 {
138 
139 #ifdef TE_QT_PLUGIN_SA_HAVE_PROXIMITYMATRIXCREATOR
143 #endif
144 
145 #ifdef TE_QT_PLUGIN_SA_HAVE_SPATIALSTATISTICS
146  m_saMenu->addSeparator();
150 #endif
151 
152 #ifdef TE_QT_PLUGIN_SA_HAVE_BAYESGLOBAL
153  m_saMenu->addSeparator();
157 #endif
158 
159 #ifdef TE_QT_PLUGIN_SA_HAVE_BAYESLOCAL
163 #endif
164 
165 #ifdef TE_QT_PLUGIN_SA_HAVE_KERNELMAP
166  m_saMenu->addSeparator();
170 #endif
171 
172 #ifdef TE_QT_PLUGIN_SA_HAVE_KERNELRATIO
176 #endif
177 
178 #ifdef TE_QT_PLUGIN_SA_HAVE_SKATER
179  m_saMenu->addSeparator();
183 #endif
184 
185 #ifdef TE_QT_PLUGIN_SA_HAVE_GEOSTATISTICALMETHODS
186  m_saMenu->addSeparator();
190 #endif
191 
192 #ifdef TE_QT_PLUGIN_SA_HAVE_SAMPLEPOINTSGENERATOR
193  m_saMenu->addSeparator();
197 #endif
198 
199 }
200 
202 {
203 
204 #ifdef TE_QT_PLUGIN_SA_HAVE_BAYESGLOBAL
205  delete m_bayesGlobal;
206 #endif
207 
208 #ifdef TE_QT_PLUGIN_SA_HAVE_BAYESLOCAL
209  delete m_bayesLocal;
210 #endif
211 
212 #ifdef TE_QT_PLUGIN_SA_HAVE_KERNELMAP
213  delete m_kernelMap;
214 #endif
215 
216 #ifdef TE_QT_PLUGIN_SA_HAVE_KERNELRATIO
217  delete m_kernelRatio;
218 #endif
219 
220 #ifdef TE_QT_PLUGIN_SA_HAVE_GEOSTATISTICALMETHODS
221  delete m_geostatistics;
222 #endif
223 
224 #ifdef TE_QT_PLUGIN_SA_HAVE_PROXIMITYMATRIXCREATOR
225  delete m_proxMatrixCreator;
226 #endif
227 
228 #ifdef TE_QT_PLUGIN_SA_HAVE_SAMPLEPOINTSGENERATOR
230 #endif
231 
232 #ifdef TE_QT_PLUGIN_SA_HAVE_SKATER
233  delete m_skater;
234 #endif
235 
236 #ifdef TE_QT_PLUGIN_SA_HAVE_SPATIALSTATISTICS
237  delete m_spatialStatistics;
238 #endif
239 
240 }
241 
void registerActions()
Function used to register all raster processing actions.
TEQTAFEXPORT void AddActionToCustomToolbars(te::qt::af::ApplicationController *appController, QAction *act)
Check QSettings for existance of act and adds it if necessary.
Plugin implementation for the SA Qt Plugin widget.
A base class for application events.
This file defines the concrete class for Geostatistical Methods Action.
void startup()
This method will be called by applications to startup some plugin&#39;s functionality.
te::qt::plugins::sa::KernelRatioAction * m_kernelRatio
Kernel Ratio Process Action.
Basic information about a plugin.
This file defines the concrete class for SpatialStatistics Action.
te::qt::plugins::sa::SamplePointsGeneratorAction * m_samplePointsGenerator
Sample points generator Process Action.
#define TE_TR(message)
It marks a string in order to get translated.
Definition: Translator.h:242
This file defines the concrete class for Skater Action.
void shutdown()
This method will be called by applicatons to shutdown plugin&#39;s functionality.
te::qt::plugins::sa::SpatialStatisticsAction * m_spatialStatistics
Spatial Statistics Process Action.
static ApplicationController & getInstance()
It returns a reference to the singleton instance.
This file defines the concrete class for KernelMap Action.
te::qt::plugins::sa::SkaterAction * m_skater
Skater Process Action.
This file defines the concrete class for BayesLocal Action.
te::qt::plugins::sa::ProximityMatrixCreatorAction * m_proxMatrixCreator
Proximity Matrix Creator Process Action.
void triggered(te::qt::af::evt::Event *e)
URI C++ Library.
Definition: Attributes.h:37
void unRegisterActions()
Function used to unregister all raster processing actions.
This file defines the concrete class for SamplePointsGenerator Action.
#define TERRALIB_PLUGIN_CALL_BACK_IMPL(PLUGIN_CLASS_NAME)
This macro should be used by C++ plugins in order to declare the exportable/callable DLL function...
This file defines the concrete class for ProximityMatrixCreator Action.
static void initialize()
This is the startup function for the TerraLib Symbology Encoding module.
Plugin(const te::core::PluginInfo &pluginInfo)
#define TE_LOG_TRACE(message)
Use this tag in order to log a message to the TerraLib default logger with the TRACE level...
Definition: Logger.h:293
te::qt::plugins::sa::BayesLocalAction * m_bayesLocal
Local Bayes Process Action.
te::qt::plugins::sa::GeostatisticalMethodsAction * m_geostatistics
Geostatistics methods Process Action.
te::qt::plugins::sa::KernelMapAction * m_kernelMap
Kernel Map Process Action.
QAction * m_popupAction
SA pop up action registered.
te::qt::plugins::sa::BayesGlobalAction * m_bayesGlobal
Global Bayes Process Action.
This file defines the concrete class for KernelRatio Action.
This file defines the concrete class for BayesGlobal Action.
QMenu * m_saMenu
SA Main Menu registered.