All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Plugin.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2008-2013 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 "Plugin.h"
33 
34 #ifdef TE_QT_PLUGIN_RP_HAVE_CLASSIFIER
35  #include "ClassifierAction.h"
36 #endif
37 
38 #ifdef TE_QT_PLUGIN_RP_HAVE_CONTRAST
39  #include "ContrastAction.h"
40 #endif
41 
42 #ifdef TE_QT_PLUGIN_RP_HAVE_MIXTUREMODEL
43  #include "MixtureModelAction.h"
44 #endif
45 
46 #ifdef TE_QT_PLUGIN_RP_HAVE_SEGMENTER
47  #include "SegmenterAction.h"
48 #endif
49 
50 #ifdef TE_QT_PLUGIN_RP_HAVE_REGISTER
51  #include "RegisterAction.h"
52 #endif
53 
54 // QT
55 #include <QtGui/QMenu>
56 #include <QtGui/QMenuBar>
57 
59  : te::plugin::Plugin(pluginInfo), m_rpMenu(0)
60 {
61 }
62 
64 {
65 }
66 
68 {
69  if(m_initialized)
70  return;
71 
72 // it initializes the Translator support for the TerraLib RP Qt Plugin
74 
75  TE_LOG_TRACE(TE_QT_PLUGIN_RP("TerraLib Qt RP Plugin startup!"));
76 
77 // add plugin menu
79 
80  m_rpMenu->setTitle(TE_QT_PLUGIN_RP("Raster Processing"));
81 
82 // add pop up menu
83  m_popupAction = new QAction(m_rpMenu);
84  m_popupAction->setText(TE_QT_PLUGIN_RP("Raster Processing"));
85 
86  //add to application layer tree pop up menu
87  //te::qt::af::evt::LayerPopUpAddAction evt(m_popupAction, "RASTER_LAYER_ITEM", 2 /*UNIQUE_ITEM_SELECTED*/);
88  //te::qt::af::ApplicationController::getInstance().broadcast(&evt);
89 
90  m_rpPopupMenu = new QMenu(m_rpMenu);
91  m_popupAction->setMenu(m_rpPopupMenu);
92 
93 // register actions
94  registerActions();
95 
96  m_initialized = true;
97 }
98 
100 {
101  if(!m_initialized)
102  return;
103 
104 //remove from application layer tree pop up menu
105  //te::qt::af::evt::LayerPopUpRemoveAction evt(m_popupAction);
106  //te::qt::af::ApplicationController::getInstance().broadcast(&evt);
107 
108 // remove menu
109  delete m_rpMenu;
110 
111 // unregister actions
112  unRegisterActions();
113 
114  TE_LOG_TRACE(TE_QT_PLUGIN_RP("TerraLib Qt RP Plugin shutdown!"));
115 
116  m_initialized = false;
117 }
118 
120 {
121 #ifdef TE_QT_PLUGIN_RP_HAVE_CLASSIFIER
122  m_classifier = new te::qt::plugins::rp::ClassifierAction(m_rpMenu, m_rpPopupMenu);
123 #endif
124 
125 #ifdef TE_QT_PLUGIN_RP_HAVE_CONTRAST
126  m_contrast = new te::qt::plugins::rp::ContrastAction(m_rpMenu, m_rpPopupMenu);
127 #endif
128 
129 #ifdef TE_QT_PLUGIN_RP_HAVE_MIXTUREMODEL
130  m_mixtureModel = new te::qt::plugins::rp::MixtureModelAction(m_rpMenu, m_rpPopupMenu);
131 #endif
132 
133 #ifdef TE_QT_PLUGIN_RP_HAVE_SEGMENTER
134  m_segmenter = new te::qt::plugins::rp::SegmenterAction(m_rpMenu, m_rpPopupMenu);
135 #endif
136 
137 #ifdef TE_QT_PLUGIN_RP_HAVE_REGISTER
138  m_register = new te::qt::plugins::rp::RegisterAction(m_rpMenu, m_rpPopupMenu);
139 #endif
140 }
141 
143 {
144 #ifdef TE_QT_PLUGIN_RP_HAVE_CLASSIFIER
145  delete m_classifier;
146 #endif
147 
148 #ifdef TE_QT_PLUGIN_RP_HAVE_CONTRAST
149  delete m_contrast;
150 #endif
151 
152 #ifdef TE_QT_PLUGIN_RP_HAVE_CONTRAST
153  delete m_mixtureModel;
154 #endif
155 
156 #ifdef TE_QT_PLUGIN_RP_HAVE_SEGMENTER
157  delete m_segmenter;
158 #endif
159 
160 #ifdef TE_QT_PLUGIN_RP_HAVE_REGISTER
161  delete m_register;
162 #endif
163 }
164 
The basic information about a plugin.
Definition: PluginInfo.h:61
This file defines the register action class.
This class register the classifier action into RP Plugin.
void registerActions()
Function used to register all raster processing actions.
Definition: Plugin.cpp:119
This file defines the Contrast class.
This file defines the Classifier class.
#define TE_QT_PLUGIN_RP_TEXT_DOMAIN
It contains the name of the text domain used in the translation of messages in TerraLib RP Qt Plugin ...
Definition: Config.h:81
This class register the Segmenter action into RP Plugin.
static ApplicationController & getInstance()
It gives access to the controller singleton.
void unRegisterActions()
Function used to unregister all raster processing actions.
Definition: Plugin.cpp:142
#define TE_LOG_TRACE(msg)
Use this tag in order to log a message to a specified logger with the TRACE level.
Definition: Config.h:418
#define TE_QT_PLUGIN_RP_TEXT_DOMAIN_DIR
It contains the translation catalog directory.
Definition: Config.h:88
This class register the contrast action into RP Plugin.
#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
This file defines the Segmenter class.
#define TE_ADD_TEXT_DOMAIN(domain, domaindir, codeset)
It adds the given text domain located at domain-dir with the given codeset to the multilingual system...
Definition: Config.h:118
This file defines the mixture model class.
#define TE_QT_PLUGIN_RP(message)
It marks a string in order to get translated. This is a special mark used in the RP QtPlugin of Terra...
Definition: Config.h:95
~Plugin()
Virtual destructor.
Definition: Plugin.cpp:63
This class register the mixture model action into RP Plugin.
void shutdown()
Do nothing! Just set plugin as stopped.
Definition: Plugin.cpp:99
Plugin implementation for the RP Qt Plugin widget.
void startup()
Do nothing! Just set plugin as started.
Definition: Plugin.cpp:67
Plugin(const te::plugin::PluginInfo &pluginInfo)
Definition: Plugin.cpp:58
This class register the register action into RP Plugin.
QMenu * getMenu(const QString &id)
Returns a menu registered with key id.