src/terralib/qt/plugins/rp/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/rp/Plugin.cpp
22 
23  \brief Plugin implementation for the RP 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 "../../af/ApplicationController.h"
31 #include "../../af/events/LayerEvents.h"
32 #include "../../af/Utils.h"
34 #include "Plugin.h"
35 
36 #ifdef TE_QT_PLUGIN_RP_HAVE_ARITHMETICOP
37  #include "ArithmeticOpAction.h"
38 #endif
39 
40 #ifdef TE_QT_PLUGIN_RP_HAVE_CLASSIFIER
41  #include "ClassifierAction.h"
42 #endif
43 
44 #ifdef TE_QT_PLUGIN_RP_HAVE_CLIPPING
45  #include "ClippingAction.h"
46 #endif
47 
48 #ifdef TE_QT_PLUGIN_RP_HAVE_CLOUDDETECTION
49 #include "CloudDetectionAction.h"
50 #endif
51 
52 #ifdef TE_QT_PLUGIN_RP_HAVE_COLORTRANSFORM
53  #include "ColorTransformAction.h"
54 #endif
55 
56 #ifdef TE_QT_PLUGIN_RP_HAVE_COMPOSEBANDS
57  #include "ComposeBandsAction.h"
58 #endif
59 
60 #ifdef TE_QT_PLUGIN_RP_HAVE_CONTRAST
61  #include "ContrastAction.h"
62 #endif
63 
64 #ifdef TE_QT_PLUGIN_RP_HAVE_FILTER
65  #include "FilterAction.h"
66 #endif
67 
68 #ifdef TE_QT_PLUGIN_RP_HAVE_FUSION
69  #include "FusionAction.h"
70 #endif
71 
72 #ifdef TE_QT_PLUGIN_RP_HAVE_MIXTUREMODEL
73  #include "MixtureModelAction.h"
74 #endif
75 
76 #ifdef TE_QT_PLUGIN_RP_HAVE_MOSAIC
77  #include "MosaicAction.h"
78 #endif
79 
80 #ifdef TE_QT_PLUGIN_RP_HAVE_PCA
81 #include "PCAAction.h"
82 #endif
83 
84 #ifdef TE_QT_PLUGIN_RP_HAVE_POSTCLASSIFICATION
86 #endif
87 
88 #ifdef TE_QT_PLUGIN_RP_HAVE_RASTERSLICING
89  #include "RasterSlicingAction.h"
90 #endif
91 
92 #ifdef TE_QT_PLUGIN_RP_HAVE_RASTERIZATION
93  #include "RasterizationAction.h"
94 #endif
95 
96 #ifdef TE_QT_PLUGIN_RP_HAVE_SEGMENTER
97  #include "SegmenterAction.h"
98 #endif
99 
100 #ifdef TE_QT_PLUGIN_RP_HAVE_REGISTER
101  #include "RegisterAction.h"
102 #endif
103 
104 #ifdef TE_QT_PLUGIN_RP_HAVE_VECTORIZATION
105  #include "VectorizationAction.h"
106 #endif
107 
108 // QT
109 #include <QAction>
110 #include <QMenu>
111 #include <QMenuBar>
112 
114  : te::core::CppPlugin(pluginInfo), m_rpMenu(nullptr)
115 {
116 }
117 
119 
121 {
122  if(m_initialized)
123  return;
124 
126 
127 // it initializes the Translator support for the TerraLib RP Qt Plugin
128  //TE_ADD_TEXT_DOMAIN(TE_QT_PLUGIN_RP_TEXT_DOMAIN, TE_QT_PLUGIN_RP_TEXT_DOMAIN_DIR, "UTF-8");
129 
130  TE_LOG_TRACE(TE_TR("TerraLib Qt RP Plugin startup!"));
131 
132 // add plugin menu
133  QMenu* pluginMenu = te::qt::af::AppCtrlSingleton::getInstance().getMenu("Processing");
134  m_rpMenu = new QMenu(pluginMenu);
135  m_rpMenu->setIcon(QIcon::fromTheme("rp-rasterprocessing-icon"));
136 
137  // Insert action before plugin manager action
138  QAction* pluginsSeparator = te::qt::af::AppCtrlSingleton::getInstance().findAction("ManagePluginsSeparator");
139 
140  pluginMenu->insertMenu(pluginsSeparator, m_rpMenu);
141 
142  m_rpMenu->setTitle(tr("Raster Processing"));
143 
144 // add pop up menu
145  m_popupAction = new QAction(m_rpMenu);
146  m_popupAction->setText(tr("Raster Processing"));
147 
148 //add to application layer tree pop up menu
149  //te::qt::af::evt::LayerPopUpAddAction evt(m_popupAction, "RASTER_LAYER_ITEM", 2 /*UNIQUE_ITEM_SELECTED*/);
150  //te::qt::af::AppCtrlSingleton::getInstance().trigger(&evt);
151 
152  m_rpPopupMenu = new QMenu(m_rpMenu);
153  m_popupAction->setMenu(m_rpPopupMenu);
154 
155 // register actions
156  registerActions();
157 
159 
160  m_initialized = true;
161 }
162 
164 {
165  if(!m_initialized)
166  return;
167 
168 //remove from application layer tree pop up menu
169  //te::qt::af::evt::LayerPopUpRemoveAction evt(m_popupAction);
170  //te::qt::af::AppCtrlSingleton::getInstance().trigger(&evt);
171 
172 // remove menu
173  delete m_rpMenu;
174 
175 // unregister actions
177 
179 
180  TE_LOG_TRACE(TE_TR("TerraLib Qt RP Plugin shutdown!"));
181 
182  m_initialized = false;
183 }
184 
186 {
187 #ifdef TE_QT_PLUGIN_RP_HAVE_ARITHMETICOP
191 #endif
192 
193 #ifdef TE_QT_PLUGIN_RP_HAVE_CLASSIFIER
197 #endif
198 
199 #ifdef TE_QT_PLUGIN_RP_HAVE_CLIPPING
203 #endif
204 
205 #ifdef TE_QT_PLUGIN_RP_HAVE_CLOUDDETECTION
209 #endif
210 
211 #ifdef TE_QT_PLUGIN_RP_HAVE_COLORTRANSFORM
215 #endif
216 
217 #ifdef TE_QT_PLUGIN_RP_HAVE_COMPOSEBANDS
221 #endif
222 
223 #ifdef TE_QT_PLUGIN_RP_HAVE_CONTRAST
227 #endif
228 
229 #ifdef TE_QT_PLUGIN_RP_HAVE_FILTER
233 #endif
234 
235 #ifdef TE_QT_PLUGIN_RP_HAVE_FUSION
239 #endif
240 
241 #ifdef TE_QT_PLUGIN_RP_HAVE_MIXTUREMODEL
245 #endif
246 
247  #ifdef TE_QT_PLUGIN_RP_HAVE_MOSAIC
251 #endif
252 
253 #ifdef TE_QT_PLUGIN_RP_HAVE_PCA
257 #endif
258 
259 #ifdef TE_QT_PLUGIN_RP_HAVE_POSTCLASSIFICATION
263 #endif
264 
265 #ifdef TE_QT_PLUGIN_RP_HAVE_RASTERSLICING
269 #endif
270 
271 #ifdef TE_QT_PLUGIN_RP_HAVE_RASTERIZATION
275 #endif
276 
277 #ifdef TE_QT_PLUGIN_RP_HAVE_REGISTER
281 #endif
282 
283 #ifdef TE_QT_PLUGIN_RP_HAVE_SEGMENTER
287 #endif
288 
289 #ifdef TE_QT_PLUGIN_RP_HAVE_VECTORIZATION
293 #endif
294 }
295 
297 {
298 #ifdef TE_QT_PLUGIN_RP_HAVE_ARITHMETICOP
299  delete m_arithmeticOp;
300 #endif
301 
302 #ifdef TE_QT_PLUGIN_RP_HAVE_CLASSIFIER
303  delete m_classifier;
304 #endif
305 
306 #ifdef TE_QT_PLUGIN_RP_HAVE_CLIPPING
307  delete m_clipping;
308 #endif
309 
310 #ifdef TE_QT_PLUGIN_RP_HAVE_CLOUDDETECTION
311  delete m_cloudDetection;
312 #endif
313 
314 #ifdef TE_QT_PLUGIN_RP_HAVE_COLORTRANSFORM
315  delete m_colorTrans;
316 #endif
317 
318 #ifdef TE_QT_PLUGIN_RP_HAVE_COMPOSEBANDS
319  delete m_composeBands;
320 #endif
321 
322 #ifdef TE_QT_PLUGIN_RP_HAVE_CONTRAST
323  delete m_contrast;
324 #endif
325 
326 #ifdef TE_QT_PLUGIN_RP_HAVE_FILTER
327  delete m_filter;
328 #endif
329 
330 #ifdef TE_QT_PLUGIN_RP_HAVE_FUSION
331  delete m_fusion;
332 #endif
333 
334 #ifdef TE_QT_PLUGIN_RP_HAVE_MIXTUREMODEL
335  delete m_mixtureModel;
336 #endif
337 
338  #ifdef TE_QT_PLUGIN_RP_HAVE_MOSAIC
339  delete m_mosaic;
340 #endif
341 
342 #ifdef TE_QT_PLUGIN_RP_HAVE_PCA
343  delete m_PCA;
344 #endif
345 
346 #ifdef TE_QT_PLUGIN_RP_HAVE_POSTCLASSIFICATION
347  delete m_postClass;
348 #endif
349 
350 #ifdef TE_QT_PLUGIN_RP_HAVE_RASTERSLICING
351  delete m_rasterSlicing;
352 #endif
353 
354 #ifdef TE_QT_PLUGIN_RP_HAVE_RASTERIZATION
355  delete m_raster;
356 #endif
357 
358 #ifdef TE_QT_PLUGIN_RP_HAVE_REGISTER
359  delete m_register;
360 #endif
361 
362 #ifdef TE_QT_PLUGIN_RP_HAVE_SEGMENTER
363  delete m_segmenter;
364 #endif
365 
366 #ifdef TE_QT_PLUGIN_RP_HAVE_VECTORIZATION
367  delete m_vector;
368 #endif
369 }
370 
void registerActions()
Function used to register all raster processing actions.
This file defines the mixture model class.
te::qt::plugins::rp::RasterSlicingAction * m_rasterSlicing
Raster slicing Process Action.
This file defines the Filter class.
TEQTAFEXPORT void AddActionToCustomToolbars(te::qt::af::ApplicationController *appController, QAction *act)
Check QSettings for existance of act and adds it if necessary.
This class register the arithmeticOp action into RP Plugin.
te::qt::plugins::rp::PostClassificationAction * m_postClass
Post Classification Process Action.
This file defines the Segmenter class.
A base class for application events.
QMenu * m_rpMenu
RP Main Menu registered.
This file defines the Fusion class.
This file defines the Clipping class.
This class register the Post Classification action into RP Plugin.
This file defines the PostClassification class.
void startup()
This method will be called by applications to startup some plugin&#39;s functionality.
This class register the Segmenter action into RP Plugin.
te::qt::plugins::rp::VectorizationAction * m_vector
Vectorization Process Action.
This class register the register action into RP Plugin.
Basic information about a plugin.
te::qt::plugins::rp::ContrastAction * m_contrast
Contrast Process Action.
This file defines the Classifier class.
#define TE_TR(message)
It marks a string in order to get translated.
Definition: Translator.h:242
This file defines the Mosaic class.
This class register the contrast action into RP Plugin.
te::qt::plugins::rp::FilterAction * m_filter
Filter Process Action.
te::qt::plugins::rp::ClippingAction * m_clipping
Clipping Process Action.
te::qt::plugins::rp::ColorTransformAction * m_colorTrans
Color Transform Process Action.
This file defines the Contrast class.
void shutdown()
This method will be called by applicatons to shutdown plugin&#39;s functionality.
QAction * m_popupAction
RP pop up action registered.
te::qt::plugins::rp::FusionAction * m_fusion
Fusion Process Action.
te::qt::plugins::rp::ClassifierAction * m_classifier
Classifier Process Action.
void triggered(te::qt::af::evt::Event *e)
static ApplicationController & getInstance()
It returns a reference to the singleton instance.
QMenu * m_rpPopupMenu
RP Main Menu registered.
This class register the classifier action into RP Plugin.
te::qt::plugins::rp::RasterizationAction * m_raster
Rasterization Process Action.
This file defines the Compose Bands class.
te::qt::plugins::rp::RegisterAction * m_register
Register Process Action.
URI C++ Library.
Definition: Attributes.h:37
This class register the mixture model action into RP Plugin.
void unRegisterActions()
Function used to unregister all raster processing actions.
Plugin implementation for the RP Qt Plugin widget.
#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 class register the compose bands action into RP Plugin.
A factory to build the raster processing config frame object.
te::qt::plugins::rp::PCAAction * m_PCA
PCA Action.
This class register the fusion action into RP Plugin.
Definition: FusionAction.h:47
This class register the mosaic action into RP Plugin.
Definition: MosaicAction.h:47
te::qt::plugins::rp::ArithmeticOpAction * m_arithmeticOp
Arithmetic Operation Process Action.
This class register the PCA action into RP Plugin.
Definition: PCAAction.h:49
This class register the Clipping action into RP Plugin.
Plugin(const te::core::PluginInfo &pluginInfo)
This class register the RasterSlicing action into RP Plugin.
#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
This file defines the PCA class.
te::qt::plugins::rp::MixtureModelAction * m_mixtureModel
Mixture Model Process Action.
This class register the filter action into RP Plugin.
Definition: FilterAction.h:50
te::qt::plugins::rp::ComposeBandsAction * m_composeBands
Compose Bands Process Action.
This file defines the ColorTransform class.
This class register the colorTransform action into RP Plugin.
te::qt::plugins::rp::SegmenterAction * m_segmenter
Segmenter Process Action.
This file defines the register action class.
This file defines the ArithmeticOp class.
te::qt::plugins::rp::CloudDetectionAction * m_cloudDetection
Cloud Detection Process Action.
This class register the action into Cloud Detection Plugin.
This file defines the RasterSlicing class.
te::qt::plugins::rp::MosaicAction * m_mosaic
Mosaic Process Action.