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/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 "../../../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_RP_HAVE_ARITHMETICOP
36  #include "ArithmeticOpAction.h"
37 #endif
38 
39 #ifdef TE_QT_PLUGIN_RP_HAVE_CLASSIFIER
40  #include "ClassifierAction.h"
41 #endif
42 
43 #ifdef TE_QT_PLUGIN_RP_HAVE_CLIPPING
44  #include "ClippingAction.h"
45 #endif
46 
47 #ifdef TE_QT_PLUGIN_RP_HAVE_COLORTRANSFORM
48  #include "ColorTransformAction.h"
49 #endif
50 
51 #ifdef TE_QT_PLUGIN_RP_HAVE_COMPOSEBANDS
52  #include "ComposeBandsAction.h"
53 #endif
54 
55 #ifdef TE_QT_PLUGIN_RP_HAVE_CONTRAST
56  #include "ContrastAction.h"
57 #endif
58 
59 #ifdef TE_QT_PLUGIN_RP_HAVE_FILTER
60  #include "FilterAction.h"
61 #endif
62 
63 #ifdef TE_QT_PLUGIN_RP_HAVE_FUSION
64  #include "FusionAction.h"
65 #endif
66 
67 #ifdef TE_QT_PLUGIN_RP_HAVE_MIXTUREMODEL
68  #include "MixtureModelAction.h"
69 #endif
70 
71 #ifdef TE_QT_PLUGIN_RP_HAVE_MOSAIC
72  #include "MosaicAction.h"
73 #endif
74 
75 #ifdef TE_QT_PLUGIN_RP_HAVE_SEGMENTER
76  #include "SegmenterAction.h"
77 #endif
78 
79 #ifdef TE_QT_PLUGIN_RP_HAVE_REGISTER
80  #include "RegisterAction.h"
81 #endif
82 
83 #ifdef TE_QT_PLUGIN_RP_HAVE_VECTORIZATION
84  #include "VectorizationAction.h"
85 #endif
86 
87 // QT
88 #include <QAction>
89 #include <QMenu>
90 #include <QMenuBar>
91 
93  : te::plugin::Plugin(pluginInfo), m_rpMenu(0)
94 {
95 }
96 
98 {
99 }
100 
102 {
103  if(m_initialized)
104  return;
105 
106 // it initializes the Translator support for the TerraLib RP Qt Plugin
107  //TE_ADD_TEXT_DOMAIN(TE_QT_PLUGIN_RP_TEXT_DOMAIN, TE_QT_PLUGIN_RP_TEXT_DOMAIN_DIR, "UTF-8");
108 
109  TE_LOG_TRACE(TE_TR("TerraLib Qt RP Plugin startup!"));
110 
111 // add plugin menu
112  QMenu* pluginMenu = te::qt::af::ApplicationController::getInstance().getMenu("Processing");
113  m_rpMenu = new QMenu(pluginMenu);
114  m_rpMenu->setIcon(QIcon::fromTheme("rp-rasterprocessing-icon"));
115 
116  // Insert action before plugin manager action
117  QAction* pluginsSeparator = te::qt::af::ApplicationController::getInstance().findAction("ManagePluginsSeparator");
118 
119  pluginMenu->insertMenu(pluginsSeparator, m_rpMenu);
120 
121  m_rpMenu->setTitle(TE_TR("Raster Processing"));
122 
123 // add pop up menu
124  m_popupAction = new QAction(m_rpMenu);
125  m_popupAction->setText(TE_TR("Raster Processing"));
126 
127  //add to application layer tree pop up menu
128  //te::qt::af::evt::LayerPopUpAddAction evt(m_popupAction, "RASTER_LAYER_ITEM", 2 /*UNIQUE_ITEM_SELECTED*/);
129  //te::qt::af::ApplicationController::getInstance().broadcast(&evt);
130 
131  m_rpPopupMenu = new QMenu(m_rpMenu);
132  m_popupAction->setMenu(m_rpPopupMenu);
133 
134 // register actions
135  registerActions();
136 
137  m_initialized = true;
138 }
139 
141 {
142  if(!m_initialized)
143  return;
144 
145 //remove from application layer tree pop up menu
146  //te::qt::af::evt::LayerPopUpRemoveAction evt(m_popupAction);
147  //te::qt::af::ApplicationController::getInstance().broadcast(&evt);
148 
149 // remove menu
150  delete m_rpMenu;
151 
152 // unregister actions
153  unRegisterActions();
154 
155  TE_LOG_TRACE(TE_TR("TerraLib Qt RP Plugin shutdown!"));
156 
157  m_initialized = false;
158 }
159 
161 {
162 #ifdef TE_QT_PLUGIN_RP_HAVE_ARITHMETICOP
163  m_arithmeticOp = new te::qt::plugins::rp::ArithmeticOpAction(m_rpMenu, m_rpPopupMenu);
164  te::qt::af::AddActionToCustomToolbars(m_arithmeticOp->getAction());
165 #endif
166 
167 #ifdef TE_QT_PLUGIN_RP_HAVE_CLASSIFIER
168  m_classifier = new te::qt::plugins::rp::ClassifierAction(m_rpMenu, m_rpPopupMenu);
169  te::qt::af::AddActionToCustomToolbars(m_classifier->getAction());
170 #endif
171 
172 #ifdef TE_QT_PLUGIN_RP_HAVE_CLIPPING
173  m_clipping = new te::qt::plugins::rp::ClippingAction(m_rpMenu, m_rpPopupMenu);
174  te::qt::af::AddActionToCustomToolbars(m_clipping->getAction());
175 #endif
176 
177 #ifdef TE_QT_PLUGIN_RP_HAVE_COLORTRANSFORM
178  m_colorTrans = new te::qt::plugins::rp::ColorTransformAction(m_rpMenu, m_rpPopupMenu);
179  te::qt::af::AddActionToCustomToolbars(m_colorTrans->getAction());
180 #endif
181 
182 #ifdef TE_QT_PLUGIN_RP_HAVE_COMPOSEBANDS
183  m_composeBands = new te::qt::plugins::rp::ComposeBandsAction(m_rpMenu, m_rpPopupMenu);
184  te::qt::af::AddActionToCustomToolbars(m_composeBands->getAction());
185 #endif
186 
187 #ifdef TE_QT_PLUGIN_RP_HAVE_CONTRAST
188  m_contrast = new te::qt::plugins::rp::ContrastAction(m_rpMenu, m_rpPopupMenu);
189  te::qt::af::AddActionToCustomToolbars(m_contrast->getAction());
190 #endif
191 
192 #ifdef TE_QT_PLUGIN_RP_HAVE_FILTER
193  m_filter = new te::qt::plugins::rp::FilterAction(m_rpMenu, m_rpPopupMenu);
194  te::qt::af::AddActionToCustomToolbars(m_filter->getAction());
195 #endif
196 
197 #ifdef TE_QT_PLUGIN_RP_HAVE_FUSION
198  m_fusion = new te::qt::plugins::rp::FusionAction(m_rpMenu, m_rpPopupMenu);
199  te::qt::af::AddActionToCustomToolbars(m_fusion->getAction());
200 #endif
201 
202 #ifdef TE_QT_PLUGIN_RP_HAVE_MIXTUREMODEL
203  m_mixtureModel = new te::qt::plugins::rp::MixtureModelAction(m_rpMenu, m_rpPopupMenu);
204  te::qt::af::AddActionToCustomToolbars(m_mixtureModel->getAction());
205 #endif
206 
207  #ifdef TE_QT_PLUGIN_RP_HAVE_MOSAIC
208  m_mosaic = new te::qt::plugins::rp::MosaicAction(m_rpMenu, m_rpPopupMenu);
209  te::qt::af::AddActionToCustomToolbars(m_mosaic->getAction());
210 #endif
211 
212 #ifdef TE_QT_PLUGIN_RP_HAVE_REGISTER
213  m_register = new te::qt::plugins::rp::RegisterAction(m_rpMenu, m_rpPopupMenu);
214  te::qt::af::AddActionToCustomToolbars(m_register->getAction());
215 #endif
216 
217 #ifdef TE_QT_PLUGIN_RP_HAVE_SEGMENTER
218  m_segmenter = new te::qt::plugins::rp::SegmenterAction(m_rpMenu, m_rpPopupMenu);
219  te::qt::af::AddActionToCustomToolbars(m_segmenter->getAction());
220 #endif
221 
222 #ifdef TE_QT_PLUGIN_RP_HAVE_VECTORIZATION
223  m_vector = new te::qt::plugins::rp::VectorizationAction(m_rpMenu, m_rpPopupMenu);
224  te::qt::af::AddActionToCustomToolbars(m_vector->getAction());
225 #endif
226 }
227 
229 {
230 #ifdef TE_QT_PLUGIN_RP_HAVE_ARITHMETICOP
231  delete m_arithmeticOp;
232 #endif
233 
234 #ifdef TE_QT_PLUGIN_RP_HAVE_CLASSIFIER
235  delete m_classifier;
236 #endif
237 
238 #ifdef TE_QT_PLUGIN_RP_HAVE_CLIPPING
239  delete m_clipping;
240 #endif
241 
242 #ifdef TE_QT_PLUGIN_RP_HAVE_COLORTRANSFORM
243  delete m_colorTrans;
244 #endif
245 
246 #ifdef TE_QT_PLUGIN_RP_HAVE_COMPOSEBANDS
247  delete m_composeBands;
248 #endif
249 
250 #ifdef TE_QT_PLUGIN_RP_HAVE_CONTRAST
251  delete m_contrast;
252 #endif
253 
254 #ifdef TE_QT_PLUGIN_RP_HAVE_FILTER
255  delete m_filter;
256 #endif
257 
258 #ifdef TE_QT_PLUGIN_RP_HAVE_FUSION
259  delete m_fusion;
260 #endif
261 
262 #ifdef TE_QT_PLUGIN_RP_HAVE_MIXTUREMODEL
263  delete m_mixtureModel;
264 #endif
265 
266  #ifdef TE_QT_PLUGIN_RP_HAVE_MOSAIC
267  delete m_mosaic;
268 #endif
269 
270 #ifdef TE_QT_PLUGIN_RP_HAVE_REGISTER
271  delete m_register;
272 #endif
273 
274 #ifdef TE_QT_PLUGIN_RP_HAVE_SEGMENTER
275  delete m_segmenter;
276 #endif
277 
278 #ifdef TE_QT_PLUGIN_RP_HAVE_VECTORIZATION
279  delete m_vector;
280 #endif
281 }
282 
#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
This file defines the mixture model class.
This file defines the Filter class.
This class register the arithmeticOp action into RP Plugin.
void unRegisterActions()
Function used to unregister all raster processing actions.
Definition: Plugin.cpp:228
This file defines the Segmenter class.
This file defines the Fusion class.
This file defines the Clipping class.
void startup()
Do nothing! Just set plugin as started.
Definition: Plugin.cpp:101
This class register the Segmenter action into RP Plugin.
Plugin implementation for the RP Qt Plugin widget.
This class register the register action into RP Plugin.
This file defines the Classifier class.
#define TE_TR(message)
It marks a string in order to get translated.
Definition: Translator.h:347
This file defines the Mosaic class.
This class register the contrast action into RP Plugin.
This file defines the Contrast class.
#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
static ApplicationController & getInstance()
It returns a reference to the singleton instance.
This class register the classifier action into RP Plugin.
This file defines the Compose Bands class.
This class register the mixture model action into RP Plugin.
Plugin(const te::plugin::PluginInfo &pluginInfo)
Definition: Plugin.cpp:92
~Plugin()
Virtual destructor.
Definition: Plugin.cpp:97
This class register the compose bands action into RP Plugin.
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
This class register the Clipping action into RP Plugin.
This class register the filter action into RP Plugin.
Definition: FilterAction.h:47
This file defines the ColorTransform class.
This class register the colorTransform action into RP Plugin.
The basic information about a plugin.
Definition: PluginInfo.h:61
This file defines the register action class.
This file defines the ArithmeticOp class.
void registerActions()
Function used to register all raster processing actions.
Definition: Plugin.cpp:160
void shutdown()
Do nothing! Just set plugin as stopped.
Definition: Plugin.cpp:140