src/terralib/qt/plugins/vp/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/vp/Plugin.cpp
22 
23  \brief Plugin implementation for the VP Qt Plugin widget.
24 */
25 
26 // TerraLib
27 #include "../../../common/Config.h"
28 #include "../../../common/SystemApplicationSettings.h"
29 #include "../../../core/translator/Translator.h"
30 #include "../../../core/logger/Logger.h"
31 #include "../../af/ApplicationController.h"
32 #include "../../af/Utils.h"
33 #include "BufferAction.h"
35 #include "DifferenceAction.h"
36 #include "DissolveAction.h"
37 #include "GeometricOpAction.h"
38 #include "IdentityAction.h"
39 #include "IntersectionAction.h"
40 #include "LineToPolygonAction.h"
41 #include "MergeAction.h"
43 #include "Plugin.h"
44 #include "PolygonToLineAction.h"
45 #include "UnionAction.h"
47 
48 // QT
49 #include <QMenu>
50 #include <QMenuBar>
51 #include <QString>
52 
53 // STL
54 #include <string>
55 
57  : te::core::CppPlugin(pluginInfo),
58  m_vpMenu(nullptr),
59  m_buffer(nullptr),
60  m_difference(nullptr),
61  m_dissolve(nullptr),
62  m_geometricOp(nullptr),
63  m_identity(nullptr),
64  m_intersection(nullptr),
65  m_lineToPolygon(nullptr),
66  m_merge(nullptr),
67  m_multipart2singlepart(nullptr),
68  m_polygonToLine(nullptr),
69  m_union(nullptr)
70 {
71 }
72 
74 
76 {
77  if(m_initialized)
78  return;
79 
80 // it initializes the Translator support for the TerraLib VP Qt Plugin
81  // TE_ADD_TEXT_DOMAIN(TE_QT_PLUGIN_VP_TEXT_DOMAIN,
82  // TE_QT_PLUGIN_VP_TEXT_DOMAIN_DIR, "UTF-8");
83 
84  TE_LOG_TRACE(TE_TR("TerraLib Qt VP Plugin startup!"));
85 
86 // add plugin menu
87  QMenu* pluginMenu =
88  te::qt::af::AppCtrlSingleton::getInstance().getMenu("Processing");
89 
90  pluginMenu->setTitle(tr("Processing"));
91 
92  m_vpMenu = new QMenu(pluginMenu);
93  m_vpMenu->setIcon(QIcon::fromTheme("vp-vectorprocessing-icon"));
94 
95  // Insert action before plugin manager action
96  QAction* pluginsSeparator =
98  "ManagePluginsSeparator");
99 
100  pluginMenu->insertMenu(pluginsSeparator, m_vpMenu);
101 
102  m_vpMenu->setTitle(tr("Vector Processing"));
103 
104 // register actions
105  registerActions();
106 
108 
109  m_initialized = true;
110 
113 }
114 
116 {
117  if(!m_initialized)
118  return;
119 
120 // remove menu
121  delete m_vpMenu;
122 
123 // unregister actions
125 
127 
128  TE_LOG_TRACE(TE_TR("TerraLib Qt VP Plugin shutdown!"));
129 
130  m_initialized = false;
131 
132  te::qt::af::AppCtrlSingleton::getInstance().removeListener(this);
133 }
134 
136 {
149 
150  connect(m_buffer, SIGNAL(triggered(te::qt::af::evt::Event*)),
152  connect(m_difference, SIGNAL(triggered(te::qt::af::evt::Event*)),
154  connect(m_dissolve, SIGNAL(triggered(te::qt::af::evt::Event*)),
158  connect(m_identity, SIGNAL(triggered(te::qt::af::evt::Event*)),
164  connect(m_merge, SIGNAL(triggered(te::qt::af::evt::Event*)),
170  connect(m_union, SIGNAL(triggered(te::qt::af::evt::Event*)),
174 
197 
198  m_vpMenu->insertSeparator(m_checkGeomValidity->getAction());
202 }
203 
205 {
206  delete m_buffer;
207  delete m_difference;
208  delete m_dissolve;
209  delete m_geometricOp;
210  delete m_identity;
211  delete m_intersection;
212  delete m_lineToPolygon;
213  delete m_merge;
214  delete m_multipart2singlepart;
215  delete m_polygonToLine;
216  delete m_union;
217 
218  delete m_checkGeomValidity;
219 
220 }
221 
223 
MergeAction * m_merge
Merge Operation Action.
TEQTAFEXPORT void AddActionToCustomToolbars(te::qt::af::ApplicationController *appController, QAction *act)
Check QSettings for existance of act and adds it if necessary.
GeometricOpAction * m_geometricOp
Geometric Operation Action.
This class register the line to polygon action into VP Plugin.
LineToPolygonAction * m_lineToPolygon
Line to Polygon Operation Action.
QMenu * m_vpMenu
VP Main Menu registered.
A base class for application events.
This class register the dissolve action into VP Plugin.
This file defines the Difference class.
IntersectionAction * m_intersection
Intersection Operation Action.
PolygonToLineAction * m_polygonToLine
Polygon to Line Operation Action.
Basic information about a plugin.
#define TE_TR(message)
It marks a string in order to get translated.
Definition: Translator.h:242
This file defines the PolygonToLine class.
void startup()
This method will be called by applications to startup some plugin&#39;s functionality.
This file defines the Multipart to Singlepart class.
This class register the contrast action into VP Plugin.
Definition: UnionAction.h:47
CheckGeomValidityAction * m_checkGeomValidity
Check Geometry Validity Operation Action.
This file defines the LineToPolygon class.
This file defines the Union class.
This file defines the Identity class.
MultipartToSinglepartAction * m_multipart2singlepart
Multipart to Singlepart Operation Action.
static ApplicationController & getInstance()
It returns a reference to the singleton instance.
This class register the polygon to line action into VP Plugin.
void shutdown()
This method will be called by applicatons to shutdown plugin&#39;s functionality.
This file defines the Buffer class.
This class register the merge action into VP Plugin.
Definition: MergeAction.h:47
URI C++ Library.
Definition: Attributes.h:37
This class register the check geometry validity action into VP Plugin.
IdentityAction * m_identity
Identity Operation Action.
BufferAction * m_buffer
Buffer Operation Action.
This file defines the check geometry validity class.
Plugin(const te::core::PluginInfo &pluginInfo)
#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...
void unRegisterActions()
Function used to unregister all raster processing actions.
DifferenceAction * m_difference
Difference Operation Action.
This class register the multipart to singlepart action into VP Plugin.
This class register the difference action into VP Plugin.
Plugin implementation for the VP Qt Plugin widget.
#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
void triggered(te::qt::af::evt::Event *e)
UnionAction * m_union
Union Operation Action.
This class register the buffer action into VP Plugin.
Definition: BufferAction.h:47
This class register the intersection action into VP Plugin.
This file defines the Dissolve class.
A factory to build the vector processing config frame object.
This file defines the Intersection class.
This class register the identity action into VP Plugin.
This file defines the Merge class.
void registerActions()
Function used to register all raster processing actions.
DissolveAction * m_dissolve
Dissolve Operation Action.