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) 2011-2012 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/Translator.h"
29 #include "../../../common/Logger.h"
30 #include "../../af/ApplicationController.h"
31 #include "AggregationAction.h"
32 #include "GeometricOpAction.h"
33 #include "BufferAction.h"
34 #include "IntersectionAction.h"
35 #include "Plugin.h"
36 //#include "PolygonToLineAction.h"
37 //#include "SummarizationAction.h"
38 //#include "TransformationAction.h"
39 
40 #if defined(TERRALIB_APACHE_LOG4CXX_ENABLED) && defined(TERRALIB_LOGGER_ENABLED)
41 //Log4cxx
42 #include <log4cxx/basicconfigurator.h>
43 #include <log4cxx/consoleappender.h>
44 #include <log4cxx/fileappender.h>
45 #include <log4cxx/helpers/pool.h>
46 #include <log4cxx/helpers/transcoder.h>
47 #include <log4cxx/logger.h>
48 #include <log4cxx/logmanager.h>
49 #include <log4cxx/logstring.h>
50 #include <log4cxx/simplelayout.h>
51 #endif
52 
53 // QT
54 #include <QMenu>
55 #include <QMenuBar>
56 #include <QString>
57 
59  : te::plugin::Plugin(pluginInfo), m_vpMenu(0)
60 {
61 }
62 
64 {
65 }
66 
68 {
69  if(m_initialized)
70  return;
71 
72 // it initializes the Translator support for the TerraLib VP Qt Plugin
73  //TE_ADD_TEXT_DOMAIN(TE_QT_PLUGIN_VP_TEXT_DOMAIN, TE_QT_PLUGIN_VP_TEXT_DOMAIN_DIR, "UTF-8");
74 
75  TE_LOG_TRACE(TE_TR("TerraLib Qt VP Plugin startup!"));
76 
77 // add plugin menu
78  m_vpMenu = te::qt::af::ApplicationController::getInstance().getMenu("VP");
79 
80  m_vpMenu->setTitle(TE_TR("Vector Processing"));
81 
82 // register actions
83  registerActions();
84 
85 // vp log startup
86  std::string path = te::qt::af::ApplicationController::getInstance().getUserDataDir().toStdString();
87  path += "/log/terralib_vp.log";
88 
89 #if defined(TERRALIB_APACHE_LOG4CXX_ENABLED) && defined(TERRALIB_LOGGER_ENABLED)
90  log4cxx::FileAppender* fileAppender = new log4cxx::FileAppender(log4cxx::LayoutPtr(new log4cxx::SimpleLayout()),
91  log4cxx::helpers::Transcoder::decode(path.c_str()), false);
92 
93  log4cxx::helpers::Pool p;
94  fileAppender->activateOptions(p);
95 
96  log4cxx::BasicConfigurator::configure(log4cxx::AppenderPtr(fileAppender));
97  log4cxx::Logger::getRootLogger()->setLevel(log4cxx::Level::getDebug());
98  log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger("vp");
99 #endif
100  m_initialized = true;
101 }
102 
104 {
105  if(!m_initialized)
106  return;
107 
108 // remove menu
109  delete m_vpMenu;
110 
111 // unregister actions
112  unRegisterActions();
113 
114 #if defined(TERRALIB_APACHE_LOG4CXX_ENABLED) && defined(TERRALIB_LOGGER_ENABLED)
115  log4cxx::LogManager::shutdown();
116 #endif
117 
118  TE_LOG_TRACE(TE_TR("TerraLib Qt VP Plugin shutdown!"));
119 
120  m_initialized = false;
121 }
122 
124 {
125  m_aggregation = new te::qt::plugins::vp::AggregationAction(m_vpMenu);
126  m_buffer = new te::qt::plugins::vp::BufferAction(m_vpMenu);
127  m_geometricOp = new te::qt::plugins::vp::GeometricOpAction(m_vpMenu);
128  m_intersection = new te::qt::plugins::vp::IntersectionAction(m_vpMenu);
129  //m_polygonToLine = new te::qt::plugins::vp::PolygonToLineAction(m_vpMenu);
130  //m_summarization = new te::qt::plugins::vp::SummarizationAction(m_vpMenu);
131  //m_transformation = new te::qt::plugins::vp::TransformationAction(m_vpMenu);
132 }
133 
135 {
136  delete m_aggregation;
137  delete m_buffer;
138  delete m_geometricOp;
139  delete m_intersection;
140  //delete m_polygonToLine;
141  //delete m_summarization;
142  //delete m_transformation;
143 }
144 
#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:136
This class register the contrast action into VP Plugin.
This file defines the Aggregation class.
#define TE_TR(message)
It marks a string in order to get translated.
Definition: Translator.h:345
Plugin implementation for the VP Qt Plugin widget.
#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
Plugin(const te::plugin::PluginInfo &pluginInfo)
Definition: Plugin.cpp:58
void shutdown()
Do nothing! Just set plugin as stopped.
Definition: Plugin.cpp:103
static ApplicationController & getInstance()
It returns a reference to the singleton instance.
This file defines the Buffer class.
bool decode(std::string &s)
Decode the pct-encoded (hex) sequences, if any, return success.
Definition: urisyn.cpp:171
void registerActions()
Function used to register all raster processing actions.
Definition: Plugin.cpp:123
This class register the contrast action into VP Plugin.
Definition: BufferAction.h:47
This class register the contrast action into VP Plugin.
~Plugin()
Virtual destructor.
Definition: Plugin.cpp:63
This file defines the Intersection class.
The basic information about a plugin.
Definition: PluginInfo.h:61
void unRegisterActions()
Function used to unregister all raster processing actions.
Definition: Plugin.cpp:134
void startup()
Do nothing! Just set plugin as started.
Definition: Plugin.cpp:67