examples/qt/query/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 A list of examples for the TerraLib Widgets.
24  */
25 
26 // TerraLib
27 #include "../../Config.h"
28 #include "Config.h"
29 #include "LoadModules.h"
30 #include "QueryExamples.h"
31 #include <terralib/common.h>
32 #include <terralib/core/plugin.h>
37 
41 
42 // QT
43 #include <QApplication>
44 #include <QGridLayout>
45 #include <QIcon>
46 #include <QMessageBox>
47 
48 // STL
49 #include <string>
50 #include <exception>
51 #include <iostream>
52 
53 int main(int argc, char** argv)
54 {
55  QApplication app(argc, argv);
56 
57  try
58  {
59  // initialize Terralib support
61 
62  LoadModules();
63 
64  // Adjusting icons theme
65  QStringList ithemes = QIcon::themeSearchPaths();
66  ithemes.push_back(te::core::FindInTerraLibPath("share/terralib/icons").c_str());
67  QIcon::setThemeName("terralib");
68  QIcon::setThemeSearchPaths(ithemes);
69 
70  // Load datasource
71  std::string fileName = TERRALIB_DATA_DIR "/shp/munic_2001.shp";
72 
74 
76 
77  w.setDataSource(ds);
78 
79  if(w.exec() == QDialog::Accepted)
80  {
82 
83  te::da::DataSet* dataSet = GetDataSet(s, ds);
84 
85  //create dialog to show the result
86  QDialog dlg;
87  dlg.setFixedSize(600, 300);
88 
89  QGridLayout* layout = new QGridLayout(&dlg);
90 
92 
93  layout->addWidget(&tv);
94  tv.show();
95 
96  //show result
97  tv.setDataSet(dataSet);
98 
99  dlg.exec();
100 
101  delete dataSet;
102  }
103 
104  }
105  catch(const std::exception& e)
106  {
107  std::string msg = "An exception has occurred: ";
108  msg += e.what();
109 
110  QMessageBox::warning(0, "Query Example", msg.c_str());
111 
112  return EXIT_FAILURE;
113  }
114  catch(...)
115  {
116  std::string msg = "An unexpected exception has occurred!";
117 
118  QMessageBox::warning(0, "Query Example", msg.c_str());
119 
120  return EXIT_FAILURE;
121  }
122 
124 
125 // finalize Terralib support
127 
128  return EXIT_SUCCESS;
129 }
Include files for Core Plugin Library.
boost::shared_ptr< DataSource > DataSourcePtr
A Qt dialog that allows users to create query builder based on TerraLib query framework.
An abstract class for data providers like a DBMS, Web Services or a regular file. ...
This file is a wrapper around platform specific include files.
te::da::DataSourcePtr LoadPGISDataSource(const std::string &dsId)
static te::dt::Date ds(2010, 01, 01)
void setDataSource(const te::da::DataSourcePtr &ds)
Proxy file for the real global configuration of TerraLib examples.
void setDataSet(te::da::DataSet *dset, const bool &clearEditor=true)
Updates the data set being visualized.
static PluginManager & instance()
Access the singleton.
A table view for a dataset.
void finalize()
It finalizes the TerraLib Platform.
static TerraLib & getInstance()
It returns a reference to the singleton instance.
Several examples declarations.
A Select models a query to be used when retrieving data from a data source.
A Select models a query to be used when retrieving data from a DataSource.
Definition: Select.h:65
void initialize()
It initializes the TerraLib Platform.
A dataset is the unit of information manipulated by the data access module of TerraLib.
int main(int argc, char **argv)
TECOREEXPORT std::string FindInTerraLibPath(const std::string &path)
Returns the path relative to a directory or file in the context of TerraLib.
A customized table view for te::map::AbstractLayer objects. Uses a te::qt::widgets::DataSetModel as i...
This file contains include headers for the TerraLib Common Runtime module.
A dataset is the unit of information manipulated by the data access module of TerraLib.
void clear()
Stop and unload all plugins, then clear the internal list of plugins.
void LoadModules()
Load terralib modules.
A Qt dialog that allows users to create query builder based on TerraLib query framework.
te::da::DataSet * GetDataSet(te::da::Select &s, te::da::DataSourcePtr &ds)