examples/qt/tools/main.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 main.cpp
22 
23  \brief Example for the TerraLib Qt Tools.
24  */
25 
26 // Example
27 #include "MainWindow.h"
28 
29 // TerraLib
31 #include <terralib/core/plugin.h>
32 #include <terralib/common.h>
33 
34 
35 // Qt
36 #include <QMetaType>
37 #include <QApplication>
38 #include <QMessageBox>
39 
40 // STL
41 #include <exception>
42 #include <iostream>
43 
45 {
47 
48  std::string plugins_path = te::core::FindInTerraLibPath("share/terralib/plugins");
49 
50 #ifdef TERRALIB_MOD_OGR_ENABLED
51  info = te::core::JSONPluginInfoSerializer(plugins_path + "/te.da.ogr.teplg.json");
54 #endif
55 
56 #ifdef TERRALIB_MOD_GDAL_ENABLED
57  info = te::core::JSONPluginInfoSerializer(plugins_path + "/te.da.gdal.teplg.json");
60 #endif
61 }
62 
63 
64 int main(int argc, char** argv)
65 {
66 // initialize Terralib support
68 
69  try
70  {
71  QApplication app(argc, argv);
72 
73  qRegisterMetaType<QImage>("QImage");
74 
75  // Adjusting icons theme
76  QStringList ithemes = QIcon::themeSearchPaths();
77  ithemes.push_back(te::core::FindInTerraLibPath("share/terralib/icons").c_str());
78  QIcon::setThemeName("terralib");
79  QIcon::setThemeSearchPaths(ithemes);
80 
81  LoadModules();
82 
83  // Instructions
84  QString text = QString::fromUtf8("<p>Here you have a Map Display component associated with a set of geographic tools.\
85  <p>There are somes tools always active. e.g.:\
86  <ul><li><b>CoordTracking:</b> move the mouse on Map Display and see the tracked geographic coordinate on status bar;</li>\
87  <li><b>ZoomWheel:</b> use the mouse wheel to performs a zoom on MapDisplay;</li>\
88  <li><b>ZoomKeyboard:</b> you can use the keys (+) / (Up) or (-) / (Down) to performs a zoom also.</li>\
89  </ul>\
90  <p>Some tools can be activated using the tool bar. e.g.\
91  <ul><li><b>Pan:</b> click on MapDisplay using the left mouse button. Keep the button hold and move. Release the button to perform a pan;</li>\
92  <li><b>ZoomIn:</b> click on MapDisplay using the left mouse button. You will perform a zoom in on clicked point;</li>\
93  <li><b>ZoomOut:</b> click on MapDisplay using the left mouse button. You will perform a zoom out on clicked point;</li>\
94  <li><b>ZoomArea:</b> click on MapDisplay using the left mouse button. Keep the button hold and move to define a boundary rectangle. Release the button to perform a zoom in on this area;</li>\
95  <li><b>Measure:</b> you can measure distance, area and angles. Try it!\
96  Select the specified tool. Click on MapDisplay using the left mouse button to fix a point. Move the mouse to see a geometry and the measured value.\
97  Double click left button to stop the measuring.</li>\
98  </ul>\
99  <p>Finally, this example also provides a tool called <b>Selection</b>.<br>\
100  The only purpose of this tool is to show how you can implement a new tool.<br>\
101  Do not consider it as a final application!<br>\
102  So, select it and click with the left button. You will see the feature attributes.\
103  ");
104 
105  // Show instructions
106  QMessageBox instructions;
107  instructions.setWindowTitle("Information");
108  instructions.setText(text);
109  instructions.setTextFormat(Qt::RichText);
110  instructions.setWindowModality(Qt::NonModal);
111  instructions.move(0, 0);
112  instructions.show();
113 
114  // Example MainWindow
115  MainWindow window;
116  window.show();
117 
118  app.exec();
119  }
120  catch(...)
121  {
122  std::cout << std::endl << "An unexpected exception has occurred!" << std::endl;
123 
124  return EXIT_FAILURE;
125  }
126 
128 
129 // finalize Terralib support
131 
132  return EXIT_SUCCESS;
133 }
Include files for Core Plugin Library.
void insert(const PluginInfo &pinfo)
Adds plugin with its plugin information to the list of unloaded plugins.
This file is a wrapper around platform specific include files.
Basic information about a plugin.
int main(int argc, char **argv)
void load(const std::string &plugin_name, const bool start=true)
It tries to load the informed plugin.
std::string name
The plugin name: an internal value used to identify the plugin in the system. Must be a unique value...
void LoadModules()
It loads the data source drivers.
static PluginManager & instance()
Access the singleton.
void finalize()
It finalizes the TerraLib Platform.
static TerraLib & getInstance()
It returns a reference to the singleton instance.
void initialize()
It initializes the TerraLib Platform.
TECOREEXPORT PluginInfo JSONPluginInfoSerializer(const std::string &file_name)
A plugin finder that search for plugins in some special directories defined by compile time macros...
Definition: Serializers.cpp:44
TECOREEXPORT std::string FindInTerraLibPath(const std::string &path)
Returns the path relative to a directory or file in the context of TerraLib.
This file contains include headers for the TerraLib Common Runtime module.
void clear()
Stop and unload all plugins, then clear the internal list of plugins.
A simple main window to show example of TerraLib Qt Tools.