src/terralib/qt/plugins/wtss/Plugin.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
3 
4  This file is part of the TerraLib - a Framework for building GIS enabled
5  applications.
6 
7  TerraLib is free software: you can redistribute it and/or modify
8  it under the terms of the GNU Lesser General Public License as published by
9  the Free Software Foundation, either version 3 of the License,
10  or (at your option) any later version.
11 
12  TerraLib is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU Lesser General Public License for more details.
16 
17  You should have received a copy of the GNU Lesser General Public License
18  along with TerraLib. See COPYING. If not, write to
19  TerraLib Team at <terralib-team@terralib.org>.
20 */
21 
22 
23 /*!
24  \file terralib/qt/plugins/wtss/plugin.cpp
25 
26  \brief Add a plugin interface for dynamic loading of the Web Time Series Data
27  Service plugin.
28 
29  \author Matheus Cavassan Zaglia
30  */
31 
32 // Terralib
33 #include "../../af/ApplicationController.h"
34 #include "../../af/Utils.h"
35 #include "../../af/events/ApplicationEvents.h"
36 #include "../../af/events/MapEvents.h"
37 #include "../../af/BaseApplication.h"
38 #include "../../widgets/canvas/MapDisplay.h"
39 
40 // QT
41 #include <QApplication>
42 
43 // wtss
44 #include "Plugin.h"
45 #include "ServerManager.h"
46 #include "WtssDialog.h"
47 
49  : te::core::CppPlugin(pluginInfo)
50 {
53 }
54 
56 
58 {
59  if(m_initialized)
60  return;
61 
62  m_initialized = true;
63 
64  {
66 
67  m_wtssAction = new QAction(this);
68  m_wtssAction->setText("Web Time Series Services");
69  m_wtssAction->setIcon(QIcon::fromTheme("chart-time-series"));
70  m_wtssAction->setObjectName("Tools.WTSS");
71 
72  m_menu->addAction(m_wtssAction);
73 
74  m_timeSeriesAction = new QAction(this);
75  m_timeSeriesAction->setText("Query Time Series...");
76  m_timeSeriesAction->setObjectName("Tools.WTSS.Query Time Series");
77  m_timeSeriesAction->setCheckable(true);
78  m_timeSeriesAction->setIcon(QIcon::fromTheme("chart-time-series"));
79  m_timeSeriesAction->setEnabled(true);
80 
81  m_wtssToolBar = new QToolBar("WTSS Toolbar");
83  m_wtssToolBar->setEnabled(true);
84 
86  }
87 }
88 
90 {
91  if(!m_initialized)
92  return;
93 
94  m_initialized = false;
95 
96  delete m_wtssAction;
97  delete m_timeSeriesAction;
98  delete m_wtssToolBar;
99 
100  te::qt::af::AppCtrlSingleton::getInstance().removeToolBar("WTSS Toolbar");
101 
102  te::qt::af::AppCtrlSingleton::getInstance().removeListener(this);
103 }
104 
106 {
107  connect(m_wtssAction, SIGNAL(triggered(bool)), this,
108  SLOT(onActionActivated(bool)));
109 
110  connect(m_timeSeriesAction, SIGNAL(toggled(bool)), this,
111  SLOT(onActionQueryToggled()));
112 }
113 
115 
117 {
120  e.m_category = "WTSSToolbar";
121 
122  emit triggered(&e);
123 }
124 
126 {
127  if(!m_timeSeriesAction->isChecked())
128  {
129  m_timeSeriesAction->blockSignals(true);
130  m_timeSeriesAction->setChecked(true);
131  m_timeSeriesAction->blockSignals(false);
132  return;
133  }
134 
136  te::qt::af::AppCtrlSingleton::getInstance().getMainWindow()));
137 
138  te::qt::af::BaseApplication* baseApplication =
139  dynamic_cast<te::qt::af::BaseApplication*>(
141 
142  connect(m_wtssDlg.get(), SIGNAL(close()), this, SLOT(onCloseTool()));
143 
144  QActionGroup* mapEditionTools = te::qt::af::AppCtrlSingleton::getInstance().findActionGroup("Map.ToolsGroup");
145  assert(mapEditionTools);
146 
147  m_wtssDlg->setActionGroup(mapEditionTools);
148 
149  m_wtssDlg->setMapDisplay(baseApplication->getMapDisplay());
150 
151  m_wtssDlg->setModal(false);
152 
153  m_wtssDlg->show();
154 }
155 
157 {
158  m_timeSeriesAction->blockSignals(true);
159  m_timeSeriesAction->setChecked(false);
160  m_timeSeriesAction->blockSignals(false);
161 
162  m_wtssDlg.reset(nullptr);
163 }
164 
Basic information about a plugin.
Manage the JSON file for services configuration of the Web Time Series Services plugin.
void triggered(te::qt::af::evt::Event *e)
static ApplicationController & getInstance()
It returns a reference to the singleton instance.
URI C++ Library.
Definition: Attributes.h:37
std::unique_ptr< te::qt::plugins::wtss::WtssDialog > m_wtssDlg
#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 shutdown()
This method will be called by applicatons to shutdown plugin&#39;s functionality.
te::qt::widgets::MapDisplay * getMapDisplay()
Configuration dialog for Web Time Series Services plugin.
void startup()
This method will be called by applications to startup some plugin&#39;s functionality.
Plugin(const te::core::PluginInfo &pluginInfo)