examples/layerexplorer/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 // TerraLib
22 #include <terralib/common.h>
23 #include <terralib/dataaccess.h>
24 #include <terralib/maptools.h>
25 #include <terralib/qt/widgets.h>
28 
29 //Qt
30 #include <QApplication>
31 #include <QTableView>
32 
33 // STL
34 #include <ctime>
35 #include <iostream>
36 
37 
38 int main(int argc, char *argv[])
39 {
41 
42  QApplication app(argc, argv);
43 
44  clock_t begin = 0;
45  clock_t end = 0;
46 
47 // create the layers
48  begin = clock();
49 
50  const int maxi = 1000;
51  const int maxj = 10;
52  const int maxk = 5;
53 
54  std::list<te::map::AbstractLayerPtr> layers;
55 
56  for(int i = 1; i <= maxi; ++i)
57  {
58  std::string id = te::common::Convert2String(i);
59  std::string title = "Folder Layer " + id;
60 
61  te::map::FolderLayer* f = new te::map::FolderLayer(id, title, 0);
62 
63  for(int j = 1; j <= maxj; ++j)
64  {
65  std::string jid = id + "." + te::common::Convert2String(j);
66  title = "Folder Layer " + jid;
67 
68  te::map::FolderLayer* fj = new te::map::FolderLayer(jid, title, f);
69 
70  for(int k = 1; k <= maxk; ++k)
71  {
72  std::string kid = jid + "." + te::common::Convert2String(k);
73  title = "DataSet Layer " + kid;
74 
75  /*te::map::DataSetLayer* fk = */new te::map::DataSetLayer(kid, title, fj);
76  }
77  }
78 
79  te::map::AbstractLayerPtr layerPtr(f);
80 
81  layers.push_back(layerPtr);
82  }
83 
84  end = clock();
85 
86  std::cout << std::endl << "Time to create te::map::AbstractLayer hierarchical tree with " << maxi * maxj * maxk << " items in: " << end - begin << " miliseconds" << std:: endl;
87 
88  // Create the layer view
89  begin = clock();
90 
92 
93  end = clock();
94 
95  std::cout << std::endl << "Time to create LayerExplorer for the hierarchical tree with " << maxi * maxj * maxk << " items in: " << end - begin << " miliseconds" << std:: endl;
96 
97  begin = clock();
98 
99  layerItemView->setLayers(layers);
100 
101  layerItemView->show();
102 
103  end = clock();
104 
105  std::cout << std::endl << "Time to show the LayerExplorer widget for the first time: " << end - begin << " miliseconds" << std:: endl;
106 
107  int ret = app.exec();
108 
109  delete layerItemView;
110 
112 
113  return ret;
114 }
int main(int argc, char *argv[])
An utility class to control the startup and cleanup of the TerraLib Platform and its resources...
A layer that can be used as a container for other kind of layers.
Definition: FolderLayer.h:45
void finalize()
It finalizes the TerraLib Platform.
static TerraLib & getInstance()
It returns a reference to the singleton instance.
This file contains include headers for the TerraLib Qt widgets.
A specialization of QTreeView for manipulate layers.
Definition: LayerItemView.h:78
Defines a layer item model for Qt5.
void setLayers(const std::list< te::map::AbstractLayerPtr > &layers)
Sets the list of layers. Old layers in the tree are then removed.
Defines a layer item view for Qt5.
void initialize()
It initializes the TerraLib Platform.
This file contains include headers for the TerraLib Common Runtime module.
A layer with reference to a dataset.
Definition: DataSetLayer.h:47
std::string Convert2String(boost::int16_t value)
It converts a short integer value to a string.
Definition: StringUtils.h:56
This file contains include headers for the Data Access module of TerraLib.
This file contains include headers for the Map Tools module of TerraLib.
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr