TerraView.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 TerraView - A Free and Open Source GIS Application.
4 
5  TerraView is free software: you can redistribute it and/or modify
6  it under the terms of the GNU 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  TerraView 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 General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with TerraLib Code Editor. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@dpi.inpe.br>.
18  */
19 
20 /*!
21  \file terraview/TerraView.cpp
22 
23  \brief The main class of TerraView.
24 */
25 
26 // TerraView
27 #include "AboutDialog.h"
28 #include "Config.h"
29 #include "Project.h"
30 #include "ProjectInfoDialog.h"
31 #include "TerraView.h"
32 #include "Utils.h"
33 #include "XMLFormatter.h"
34 
35 // TerraLib
54 #include <terralib/qt/af/Utils.h>
90 
91 #include "events/ProjectEvents.h"
93 
94 // STL
95 #include <memory>
96 
97 // Qt
98 #include <QAction>
99 #include <QApplication>
100 #include <QCloseEvent>
101 #include <QFileDialog>
102 #include <QInputDialog>
103 #include <QMenu>
104 #include <QMenuBar>
105 #include <QMessageBox>
106 #include <QModelIndex>
107 #include <QToolBar>
108 
109 // Boost
110 #include <boost/filesystem.hpp>
111 #include <boost/format.hpp>
112 #include <boost/uuid/random_generator.hpp>
113 #include <boost/uuid/uuid_io.hpp>
114 
116 {
117  QString title = app->getAppTitle() + " - ";
118  title += TE_TR("Project:");
119  title += " ";
120  title += project.m_title;
121  title += " - ";
122 
123  boost::filesystem::path p(project.m_fileName.toUtf8().data());
124 
125  std::string filename = p.filename().string();
126 
127  title += filename.c_str();
128 
129  return title;
130 }
131 
132 void GetProjectsFromSettings(QStringList& prjTitles, QStringList& prjPaths)
133 {
134  QSettings s(QSettings::IniFormat,
135  QSettings::UserScope,
136  qApp->organizationName(),
137  qApp->applicationName());
138 
139  s.beginGroup("projects");
140 
141  s.beginGroup("most_recent");
142  QString path = s.value("path").toString();
143  QString title = s.value("title").toString();
144 
145  s.endGroup();
146 
147  if(path.isEmpty() || title.isEmpty())
148  return;
149 
150  prjPaths.append(path);
151  prjTitles.append(title);
152 
153  int size = s.beginReadArray("recents");
154 
155  for(int i=0; i<size; i++)
156  {
157  s.setArrayIndex(i);
158 
159  path = s.value("project/path").toString();
160  title = s.value("project/title").toString();
161 
162  prjPaths.append(path);
163  prjTitles.append(title);
164  }
165 
166  s.endArray();
167  s.endGroup();
168 }
169 
170 void WriteProjectsToSettings(const QStringList& prjTitles, const QStringList& prjPaths)
171 {
172  QSettings s(QSettings::IniFormat,
173  QSettings::UserScope,
174  qApp->organizationName(),
175  qApp->applicationName());
176 
177  s.beginGroup("projects");
178  s.beginGroup("most_recent");
179  s.setValue("path", *prjPaths.begin());
180  s.setValue("title", *prjTitles.begin());
181  s.endGroup();
182 
183  s.beginWriteArray("recents");
184  for(int i=1; i<prjTitles.size(); i++)
185  {
186  s.setArrayIndex(i-1);
187 
188  s.setValue("project/path", prjPaths.at(i));
189  s.setValue("project/title", prjTitles.at(i));
190  }
191  s.endArray();
192  s.endGroup();
193 }
194 
195 void AddRecentProjectToSettings(const QString& prjTitle, const QString& prjPath)
196 {
197  QStringList prjPaths,
198  prjTitles;
199 
200  GetProjectsFromSettings(prjTitles, prjPaths);
201 
202  if(!prjPaths.contains(prjPath))
203  {
204  prjTitles.prepend(prjTitle);
205  prjPaths.prepend(prjPath);
206  }
207  else
208  {
209  int prjPathIdx = prjPaths.indexOf(prjPath);
210 
211  if(!prjTitles.contains(prjTitle))
212  prjTitles.replace(prjPathIdx, prjTitle);
213 
214  prjTitles.move(prjPathIdx, 0);
215  prjPaths.move(prjPathIdx, 0);
216  }
217 
218  WriteProjectsToSettings(prjTitles, prjPaths);
219 }
220 
221 QModelIndex GetParent(QTreeView* view)
222 {
223  QModelIndex res;
224 
225  QModelIndexList idxs = view->selectionModel()->selectedIndexes();
226 
227  if(idxs.size() == 1)
228  {
229  QModelIndex idx = idxs.at(0);
230  te::qt::widgets::TreeItem* item = static_cast<te::qt::widgets::TreeItem*>(idx.internalPointer());
231 
232  if(item->getType() == "FOLDER")
233  res = idx;
234  }
235 
236  return res;
237 }
238 
240 {
241  p->m_author = "INPE";
242  p->m_title = QObject::tr("Default project");
243  p->m_changed = false;
244 }
245 
247  : te::qt::af::BaseApplication(parent),
248  m_helpManager(nullptr),
249  m_iController(nullptr),
250  m_queryDlg(nullptr),
251  m_compModeMenu(nullptr),
252  m_tvController(nullptr),
253  m_pvb(nullptr),
254  m_pvw(nullptr)
255 {
257 
259 }
260 
262 {
263  if (m_iController)
264  {
267  }
268 
269  delete m_iController;
270  delete m_compModeMenu;
271  delete m_queryDlg;
272  delete m_project;
273  delete m_tvController;
274 
275  //register settings for project
277 
279 }
280 
281 void TerraView::init(const QString& cfgFile)
282 {
283  //init base application
284  BaseApplication::init(cfgFile);
285 
287  m_app, cfgFile.toUtf8().data());
288 
290 
291  QStringList prjTitles,
292  prjPaths;
293 
294  GetProjectsFromSettings(prjTitles, prjPaths);
295 
296  if(!prjPaths.empty())
297  openProject(*prjPaths.begin());
298  else
299  setWindowTitle(windowTitle() + " - " + m_project->m_title);
300 
302 }
303 
304 void TerraView::startProject(const QString& projectFileName)
305 {
306  openProject(projectFileName);
307 }
308 
310 {
312 
313  addMenusActions();
314 
315  addPopUpMenu();
316 
317  //composition mode
320 
321  //interface controller
324 
325  //progress support
327  m_pvb->setFixedWidth(220);
328 
330 
331  m_statusbar->addPermanentWidget(m_pvb);
332 
333  connect(m_pvb, SIGNAL(clicked()), this, SLOT(showProgressDockWidget()));
334 
335  m_progressDockWidget = new QDockWidget(this);
336  m_progressDockWidget->setObjectName("ProgressDockWidget");
337  m_progressDockWidget->setWidget(m_pvw);
338  m_progressDockWidget->setMinimumHeight(300);
339  m_progressDockWidget->setAllowedAreas(Qt::RightDockWidgetArea);
340  m_progressDockWidget->setWindowTitle(tr("Tasks Progress"));
341  addDockWidget(Qt::RightDockWidgetArea, m_progressDockWidget);
342  m_progressDockWidget->setVisible(false);
343 
344  //register settings for project
346 
347  //add styleExplorer to interface controller
348  if (m_iController)
350 }
351 
353 {
355 
356  // Menu -Tools- actions
357  initAction(m_toolsCustomize, "preferences-system", "Tools.Customize", tr("&Customize..."), tr("Customize the system preferences"), true, false, true, m_menubar);
358  initAction(m_toolsDataExchanger, "datasource-exchanger", "Tools.Exchanger.All to All", tr("&Advanced..."), tr("Exchange data sets between data sources"), true, false, true, m_menubar);
359  initAction(m_toolsDataExchangerDirect, "data-exchange-direct-icon", "Tools.Exchanger.Direct", tr("&Layer..."), tr("Exchange data sets from layers"), true, false, true, m_menubar);
360  initAction(m_toolsDataExchangerDirectPopUp, "data-exchange-direct-icon", "Tools.Exchanger.Direct", tr("&Exchange..."), tr("Exchange data sets from layers"), true, false, true, m_menubar);
361  initAction(m_toolsDataSourceExplorer, "datasource-explorer", "Tools.Data Source Explorer", tr("&Data Source Explorer..."), tr("Show or hide the data source explorer"), true, false, true, m_menubar);
362  initAction(m_toolsQueryDataSource, "datasource-query", "Tools.Query Data Source", tr("&Query Data Source..."), tr("Allows you to query data in a data source"), true, false, true, m_menubar);
363  initAction(m_toolsRasterMultiResolution, "raster-multiresolution-icon", "Tools.Raster Multi Resolution", tr("&Raster Multi Resolution..."), tr("Creates multi resolution over a raster..."), true, false, true, m_menubar);
364 
365  // Menu -Plugins- actions
366  initAction(m_pluginsManager, "plugin", "Plugins.Management", tr("&Manage Plugins..."), tr("Manage the application plugins"), true, false, true, m_menubar);
367 
368  // Menu -Help- actions
369  initAction(m_helpContents, "help-browser", "Help.View Help", tr("&View Help..."), tr("Shows help dialog"), true, false, true, m_menubar);
370  initAction(m_helpAbout, "help-about-browser", "Help.About", tr("&About..."), tr(""), true, false, true, m_menubar);
371 
372  // Menu -Project- actions
373  initAction(m_projectAddLayerDataset, "datasource", "Project.Add Layer.All Sources", tr("&From Data Source..."), tr("Add a new layer from all available data sources"), true, false, true, m_menubar);
374  initAction(m_projectAddFolderLayer, "folderlayer-new", "Project.New Folder Layer", tr("Add &Folder Layer..."), tr("Add a new folder layer"), true, false, true, m_menubar);
375  initAction(m_projectAddLayerQueryDataSet, "view-filter", "Project.Add Layer.Query Dataset", tr("&Query Dataset..."), tr("Add a new layer from a queried dataset"), true, false, true, m_menubar);
376  initAction(m_projectAddLayerTabularDataSet, "view-data-table", "Project.Add Layer.Tabular File", tr("&Tabular File..."), tr("Add a new layer from a Tabular file"), true, false, true, m_menubar);
377  initAction(m_projectUpdateLayerDataSource, "", "Project.Update Layer Data Source", tr("&Update Layer Data Source"), tr("Update layer Data Source"), true, false, true, this);
378  initAction(m_projectProperties, "document-info", "Project.Properties", tr("&Properties..."), tr("Show the project properties"), true, false, true, m_menubar);
379 
380  // Menu -Layer- actions
381  initAction(m_layerObjectGrouping, "grouping", "Layer.ObjectGrouping", tr("&Edit Legend..."), tr(""), true, false, true, m_menubar);
382  initAction(m_layerChartsHistogram, "chart-bar", "Layer.Charts.Histogram", tr("&Histogram..."), tr(""), true, false, true, m_menubar);
383  initAction(m_layerChartsScatter, "chart-scatter", "Layer.Charts.Scatter", tr("&Scatter..."), tr(""), true, false, true, m_menubar);
384  initAction(m_layerChart, "chart-pie", "Layer.Charts.Chart", tr("&Pie/Bar Chart..."), tr(""), true, false, true, m_menubar);
385  initAction(m_layerQuery, "view-filter", "Layer.Query", tr("Query..."), tr(""), true, false, true, m_menubar);
386  initAction(m_layerLinkTable, "layer-link", "Layer.Link", tr("&Link..."), tr(""), true, false, true, m_menubar);
387  initAction(m_layerCompositionMode, "layer-compose", "Layer.Composition Mode", tr("&Composition Mode..."), tr("Set the composition mode to renderer the selected layer"), true, false, true, m_menubar);
388  initAction(m_layerDuplicateLayer, "layer-duplicate", "Layer.Duplicate Layer", tr("&Duplicate Layer"), tr("Create a copy of a layer"), true, false, true, m_menubar);
389 
390  // Menu -File- actions
391  initAction(m_fileNewProject, "document-new", "File.New Project", tr("&New Project..."), tr(""), true, false, true, m_menubar);
392  initAction(m_fileSaveProject, "document-save", "File.Save Project", tr("&Save Project"), tr(""), true, false, true, m_menubar);
393  initAction(m_fileSaveProjectAs, "document-save-as", "File.Save Project As", tr("Save Project &As..."), tr(""), true, false, false, m_menubar);
394  initAction(m_fileOpenProject, "document-open", "File.Open Project", tr("&Open Project..."), tr(""), true, false, true, m_menubar);
395  initAction(m_fileRestartSystem, "", "File.Restart System", tr("&Restart System..."), tr("Restart the system."), true, false, true, m_menubar);
396  initAction(m_fileExit, "system-log-out", "File.Exit", tr("E&xit"), tr(""), true, false, true, m_menubar);
397  initAction(m_filePrintPreview, "document-print-preview", "File.Print Preview", tr("Print Pre&view..."), tr(""), true, false, false, m_menubar);
398  initAction(m_filePrint, "document-print", "File.Print", tr("&Print..."), tr(""), true, false, false, m_menubar);
399 }
400 
402 {
404 
405  connect(m_fileNewProject, SIGNAL(triggered()), SLOT(onNewProjectTriggered()));
406  connect(m_fileOpenProject, SIGNAL(triggered()), SLOT(onOpenProjectTriggered()));
407  connect(m_fileSaveProject, SIGNAL(triggered()), SLOT(onSaveProjectTriggered()));
408  connect(m_fileSaveProjectAs, SIGNAL(triggered()), SLOT(onSaveProjectAsTriggered()));
409  connect(m_fileExit, SIGNAL(triggered()), SLOT(close()));
410  connect(m_fileRestartSystem, SIGNAL(triggered()), SLOT(onRestartSystemTriggered()));
411 
412  connect(m_helpContents, SIGNAL(triggered()), SLOT(onHelpTriggered()));
413  connect(m_helpAbout, SIGNAL(triggered()), SLOT(showAboutDialog()));
414 
415  connect(m_layerChartsHistogram, SIGNAL(triggered()), SLOT(onLayerHistogramTriggered()));
416  connect(m_layerLinkTable, SIGNAL(triggered()), SLOT(onLinkTriggered()));
417  connect(m_layerChartsScatter, SIGNAL(triggered()), SLOT(onLayerScatterTriggered()));
418  connect(m_layerChart, SIGNAL(triggered()), SLOT(onLayerChartTriggered()));
419  connect(m_layerObjectGrouping, SIGNAL(triggered()), SLOT(onLayerGroupingTriggered()));
420  connect(m_layerCompositionMode, SIGNAL(hovered()), SLOT(onLayerCompositionModeTriggered()));
421  connect(m_layerQuery, SIGNAL(triggered()), SLOT(onQueryLayerTriggered()));
423 
427  connect(m_projectAddFolderLayer, SIGNAL(triggered()), SLOT(onAddFolderLayerTriggered()));
428  connect(m_projectProperties, SIGNAL(triggered()), SLOT(onProjectPropertiesTriggered()));
430  connect(m_recentProjectsMenu, SIGNAL(triggered(QAction*)), SLOT(onRecentProjectsTriggered(QAction*)));
431 
432  connect(m_pluginsManager, SIGNAL(triggered()), SLOT(onPluginsManagerTriggered()));
433 
434  connect(m_toolsCustomize, SIGNAL(triggered()), SLOT(onToolsCustomizeTriggered()));
435  connect(m_toolsDataExchanger, SIGNAL(triggered()), SLOT(onToolsDataExchangerTriggered()));
441 }
442 
444 {
445  QSettings sett(QSettings::IniFormat, QSettings::UserScope, qApp->organizationName(), qApp->applicationName());
446 
447  sett.beginGroup("toolbars");
448 
449  sett.beginGroup("File Tool Bar");
450  sett.setValue("name", "File Tool Bar");
451  sett.beginWriteArray("Actions");
452  sett.setArrayIndex(0);
453  sett.setValue("action", "File.New Project");
454  sett.setArrayIndex(1);
455  sett.setValue("action", "File.Open Project");
456  sett.setArrayIndex(2);
457  sett.setValue("action", "File.Save Project");
458  sett.setArrayIndex(3);
459  sett.setValue("action", "");
460  sett.setArrayIndex(4);
461  sett.setValue("action", "Project.New Folder");
462  sett.setArrayIndex(5);
463  sett.setValue("action", "Project.Add Layer.All Sources");
464  sett.endArray();
465  sett.endGroup();
466 
467  sett.beginGroup("View Tool Bar");
468  sett.setValue("name", "View Tool Bar");
469  sett.beginWriteArray("Actions");
470  sett.setArrayIndex(0);
471  sett.setValue("action", "View.Layer Explorer");
472  sett.setArrayIndex(1);
473  sett.setValue("action", "View.Map Display");
474  sett.setArrayIndex(2);
475  sett.setValue("action", "View.Data Table");
476  sett.setArrayIndex(3);
477  sett.setValue("action", "View.Style Explorer");
478  sett.endArray();
479  sett.endGroup();
480 
481  sett.beginGroup("Map Tool Bar");
482  sett.setValue("name", "Map Tool Bar");
483  sett.beginWriteArray("Actions");
484  sett.setArrayIndex(0);
485  sett.setValue("action", "Map.Draw");
486  sett.setArrayIndex(1);
487  sett.setValue("action", "Map.Previous Extent");
488  sett.setArrayIndex(2);
489  sett.setValue("action", "Map.Next Extent");
490  sett.setArrayIndex(3);
491  sett.setValue("action", "Map.Zoom Extent");
492  sett.setArrayIndex(4);
493  sett.setValue("action", "");
494  sett.setArrayIndex(5);
495  sett.setValue("action", "Map.Zoom In");
496  sett.setArrayIndex(6);
497  sett.setValue("action", "Map.Zoom Out");
498  sett.setArrayIndex(7);
499  sett.setValue("action", "Map.Pan");
500  sett.setArrayIndex(8);
501  sett.setValue("action", "");
502  sett.setArrayIndex(9);
503  sett.setValue("action", "Map.Info");
504  sett.setArrayIndex(10);
505  sett.setValue("action", "Map.Selection");
506  sett.setArrayIndex(11);
507  sett.setValue("action", "Layer.Invert Selection");
508  sett.endArray();
509  sett.endGroup();
510 
511  sett.endGroup();
512 
513  sett.beginGroup("projects");
514 
515  sett.setValue("author_name", "");
516  sett.setValue("recents_history_size", "8");
517 
518  sett.endGroup();
519 }
520 
522 {
523  // File menu
524  m_fileMenu->setObjectName("File");
525  m_fileMenu->setTitle(tr("&File"));
526 
527  m_recentProjectsMenu->setObjectName("File.Recent Projects");
528  m_recentProjectsMenu->setTitle(tr("Recent &Projects"));
529 
530  m_fileMenu->addAction(m_fileNewProject);
531  m_fileMenu->addAction(m_fileOpenProject);
532  m_fileMenu->addAction(m_fileSaveProject);
533  m_fileMenu->addAction(m_fileSaveProjectAs);
534  m_fileMenu->addSeparator();
536  m_recentProjectsMenu->setEnabled(false);
537  m_fileMenu->addSeparator();
538  m_fileMenu->addAction(m_filePrintPreview);
539  m_fileMenu->addAction(m_filePrint);
540  m_fileMenu->addSeparator();
541  m_fileMenu->addAction(m_fileRestartSystem);
542 
543 #if TE_PLATFORM != TE_PLATFORMCODE_APPLE
544  m_fileMenu->addSeparator();
545 #endif
546 
547  m_fileMenu->addAction(m_fileExit);
548 
549  // View menu
550  m_viewMenu->setObjectName("View");
551  m_viewMenu->setTitle(tr("&View"));
552 
553  m_viewToolBarsMenu->setObjectName("View.Toolbars");
554  m_viewToolBarsMenu->setTitle(tr("&Toolbars"));
555 
556  m_viewMenu->addAction(m_viewDataTable);
557  m_viewMenu->addAction(m_viewLayerExplorer);
558  m_viewMenu->addAction(m_viewStyleExplorer);
559  m_viewMenu->addSeparator();
560  m_viewMenu->addAction(m_viewFullScreen);
561  m_viewMenu->addSeparator();
562  m_viewMenu->addMenu(m_viewToolBarsMenu);
563 
564  // Project menu
565  m_projectMenu->setObjectName("Project");
566  m_projectMenu->setTitle(tr("&Project"));
567 
568  m_projectAddLayerMenu->setObjectName("Project.Add Layer");
569  m_projectAddLayerMenu->setTitle(tr("&Add Layer"));
570  m_projectAddLayerMenu->setIcon(QIcon::fromTheme("layer-add"));
573  m_projectAddLayerMenu->addSeparator();
575  m_projectAddLayerMenu->addSeparator();
577  m_projectMenu->addSeparator();
578  m_projectMenu->addAction(m_layerRemove);
579  m_projectMenu->addAction(m_layerRename);
580  m_projectMenu->addSeparator();
582 
583  m_layerMenu->setObjectName("Layer");
584  m_layerMenu->setTitle(tr("&Layer"));
585 
588  m_layerMenu->addAction(m_layerChart);
589  m_layerMenu->addAction(m_layerQuery);
590  m_layerMenu->addAction(m_layerChartsScatter);
591  m_layerMenu->addSeparator();
595  m_layerMenu->addSeparator();
596  m_layerMenu->addAction(m_layerShowTable);
597  m_layerMenu->addAction(m_viewStyleExplorer);
598  m_layerMenu->addSeparator();
601  m_layerMenu->addSeparator();
602  m_layerMenu->addAction(m_layerSRS);
603  m_layerMenu->addSeparator();
604  m_layerMenu->addAction(m_layerProperties);
605  m_layerMenu->addSeparator();
607  m_layerMenu->addSeparator();
609 
610  // Map Menu
611  m_mapMenu->setObjectName("Map");
612  m_mapMenu->setTitle(tr("&Map"));
613 
614  m_mapMenu->addAction(m_mapDraw);
615  m_mapMenu->addAction(m_mapStopDrawing);
616  m_mapMenu->addSeparator();
617  m_mapMenu->addAction(m_mapInfo);
618  m_mapMenu->addAction(m_mapRemoveSelection);
619  m_mapMenu->addAction(m_mapSelection);
620  m_mapMenu->addSeparator();
621  m_mapMenu->addAction(m_mapPan);
622  m_mapMenu->addAction(m_mapZoomExtent);
623  m_mapMenu->addAction(m_mapZoomIn);
624  m_mapMenu->addAction(m_mapZoomOut);
625  m_mapMenu->addSeparator();
626  m_mapMenu->addAction(m_mapNextExtent);
627  m_mapMenu->addAction(m_mapPreviousExtent);
628  m_mapMenu->addSeparator();
629  m_mapMenu->addAction(m_mapMeasureAngle);
630  m_mapMenu->addAction(m_mapMeasureArea);
631  m_mapMenu->addAction(m_mapMeasureDistance);
632  m_mapMenu->addSeparator();
633  m_mapMenu->addAction(m_mapSRID);
634  m_mapMenu->addAction(m_mapUnknownSRID);
635  m_mapMenu->addSeparator();
636  m_mapMenu->addAction(m_mapShowGraphicScale);
637  m_mapMenu->addAction(m_mapEditGraphicScale);
638  m_mapMenu->addSeparator();
640  m_mapMenu->addAction(m_mapEditGrid);
641  m_mapMenu->addSeparator();
643 
644  // Tools menu
645  m_toolsMenu->setObjectName("Tools");
646  m_toolsMenu->setTitle(tr("&Tools"));
647 
648  m_toolsExchangerMenu->setObjectName("Tools.Exchanger");
649  m_toolsExchangerMenu->setTitle(tr("&Data Exchanger"));
650  m_toolsExchangerMenu->setIcon(QIcon::fromTheme("datasource-exchanger"));
653 
656  m_toolsMenu->addSeparator();
658  m_toolsMenu->addSeparator();
659  m_toolsMenu->addAction(m_toolsCustomize);
660 
661  // Plugins menu
662  m_pluginsMenu->setObjectName("Plugins");
663  m_pluginsMenu->setTitle(tr("Pl&ugins"));
664 
665  m_pluginsMenu->addSeparator()->setObjectName("ManagePluginsSeparator");
666  m_pluginsMenu->addAction(m_pluginsManager);
667 
668  // Help menu
669  m_helpMenu->setObjectName("Help");
670  m_helpMenu->setTitle(tr("&Help"));
671 
672  m_helpMenu->addAction(m_helpContents);
673  m_helpMenu->addAction(m_helpAbout);
674 }
675 
677 {
679  treeView->setAnimated(true);
680 
681  //// Actions to be added to the context menu when there is no item selected
682  treeView->addNoLayerAction(m_projectAddLayerMenu->menuAction());
683 
684  QAction* noItemSelectedSep = new QAction(this);
685  noItemSelectedSep->setSeparator(true);
686  treeView->addNoLayerAction(noItemSelectedSep);
687 
689 
690  //// Actions to be added to the context menu when there is a unique item selected
691 
692  treeView->addAllLayerAction(m_layerRemove);
693 
694  //// Actions for the folder layer item
696  treeView->addFolderLayerAction(m_projectAddLayerMenu->menuAction());
697 
698  QAction* folderSep1 = new QAction(this);
699  folderSep1->setSeparator(true);
700  treeView->addFolderLayerAction(folderSep1);
701 
703 
704  QAction* folderSep2 = new QAction(this);
705  folderSep2->setSeparator(true);
706  treeView->addFolderLayerAction(folderSep2);
707 
709 
710  //// Actions for the single layer item that is not a raster layer
715 
716  QAction* actionStyleSep1 = new QAction(this);
717  actionStyleSep1->setSeparator(true);
718  treeView->addVectorLayerAction(actionStyleSep1);
719 
727 
728  QAction* actionChartSep = new QAction(this);
729  actionChartSep->setSeparator(true);
730  treeView->addVectorLayerAction(actionChartSep);
731 
734 
735  QAction* actionStyleSep = new QAction(this);
736  actionStyleSep->setSeparator(true);
737  treeView->addVectorLayerAction(actionStyleSep);
738 
739  QAction* actionRemoveSep = new QAction(this);
740  actionRemoveSep->setSeparator(true);
741  treeView->addVectorLayerAction(actionRemoveSep);
742 
746 
747  QAction* actionFitSep = new QAction(this);
748  actionFitSep->setSeparator(true);
749  treeView->addVectorLayerAction(actionFitSep);
750 
752 
753  QAction* actionSaveAsSep = new QAction(this);
754  actionSaveAsSep->setSeparator(true);
755  treeView->addVectorLayerAction(actionSaveAsSep);
756 
757  treeView->addVectorLayerAction(m_layerSRS);
759 
760  QAction* actionSRSSep = new QAction(this);
761  actionSRSSep->setSeparator(true);
762  treeView->addVectorLayerAction(actionSRSSep);
763 
766 
767  //// Actions for the raster layer item
769 
770  actionStyleSep1 = new QAction(this);
771  actionStyleSep1->setSeparator(true);
772  treeView->addVectorLayerAction(actionStyleSep1);
773 
777 
778  QAction* rasterSep1 = new QAction(this);
779  rasterSep1->setSeparator(true);
780  treeView->addRasterLayerAction(rasterSep1);
781 
783 
784  QAction* rasterSep2 = new QAction(this);
785  rasterSep2->setSeparator(true);
786  treeView->addRasterLayerAction(rasterSep2);
787 
788  QAction* rasterSep3 = new QAction(this);
789  rasterSep3->setSeparator(true);
790  treeView->addRasterLayerAction(rasterSep3);
791 
793 
794  QAction* rasterSep4 = new QAction(this);
795  rasterSep4->setSeparator(true);
796  treeView->addRasterLayerAction(rasterSep4);
797 
798  treeView->addRasterLayerAction(m_layerSRS);
799 
800  QAction* rasterSep5 = new QAction(this);
801  rasterSep5->setSeparator(true);
802  treeView->addRasterLayerAction(rasterSep5);
803 
806 
807  //// Actions for tabular layers
809 
810  actionStyleSep1 = new QAction(this);
811  actionStyleSep1->setSeparator(true);
812  treeView->addTabularLayerAction(actionStyleSep1);
813 
818 
819  actionChartSep = new QAction(this);
820  actionChartSep->setSeparator(true);
821  treeView->addTabularLayerAction(actionChartSep);
822 
824 
825  actionSaveAsSep = new QAction(this);
826  actionSaveAsSep->setSeparator(true);
827  treeView->addTabularLayerAction(actionSaveAsSep);
828 
830 
831  actionSRSSep = new QAction(this);
832  actionSRSSep->setSeparator(true);
833  treeView->addTabularLayerAction(actionSRSSep);
834 
836 
837  //// Actions for invalid layers
839 
840  //// Action for multi selected layers
844 }
845 
847 {
849 
850  m_fileMenu = new QMenu(m_menubar);
851  m_recentProjectsMenu = new QMenu(m_fileMenu);
852  m_menubar->addAction(m_fileMenu->menuAction());
853  m_viewMenu = new QMenu(m_menubar);
854  m_menubar->addAction(m_viewMenu->menuAction());
855  m_viewToolBarsMenu = new QMenu(m_viewMenu);
856  m_viewMenu->addMenu(m_viewToolBarsMenu);
857  m_projectMenu = new QMenu(m_menubar);
859  m_menubar->addAction(m_projectMenu->menuAction());
861  m_layerMenu = new QMenu(m_menubar);
862  m_menubar->addAction(m_layerMenu->menuAction());
863  m_mapMenu = new QMenu(m_menubar);
864  m_mapMenu->setObjectName("Map");
865  m_menubar->addAction(m_mapMenu->menuAction());
866  m_toolsMenu = new QMenu(m_menubar);
867  m_toolsExchangerMenu = new QMenu(m_toolsMenu);
868  m_toolsMenu->addAction(m_toolsExchangerMenu->menuAction());
869  m_menubar->addAction(m_toolsMenu->menuAction());
870  m_pluginsMenu = new QMenu(m_menubar);
871  m_pluginsMenu->setObjectName("Plugins");
872  m_menubar->addMenu(m_pluginsMenu);
873  m_helpMenu = new QMenu(m_menubar);
874  m_helpMenu->setObjectName("Help");
875  m_menubar->addAction(m_helpMenu->menuAction());
876 }
877 
879 {
881 
882  std::vector<QToolBar*> toolBars = m_app->getToolBars();
883 
884 
885  for (std::size_t t = 0; t < toolBars.size(); ++t)
886  {
887  QToolBar* bar = toolBars[t];
888 
889  m_viewToolBarsMenu->addAction(bar->toggleViewAction());
890  }
891 }
892 
894 {
895  AboutDialog dialog(this);
896 
897  std::string logoTVLargeFileName = m_app->getAboutLogo().toUtf8().data();
898  std::string logoTEFileName = m_app->getTlibLogo().toUtf8().data();
899 
900  dialog.setTerraViewLogoFilePath(logoTVLargeFileName);
901  dialog.setTerraLibLogoFilePath(logoTEFileName);
902 
903  dialog.exec();
904 }
905 
906 
908 {
909  switch (e->m_id)
910  {
912  {
914 
915  if(!evt->m_actions.empty())
916  addActions(evt->m_plgName.c_str(), evt->m_category.c_str(), evt->m_actions);
917  else if(evt->m_toolbar != nullptr)
918  QMainWindow::addToolBar(Qt::TopToolBarArea, evt->m_toolbar);
919  }
920  break;
921 
923  {
924  std::list<te::map::AbstractLayerPtr> layers;
925  te::qt::widgets::GetValidLayers(getLayerExplorer()->model(), QModelIndex(), layers);
926 
927  getMapDisplay()->setLayerList(layers);
928  getMapDisplay()->refresh();
929 
930  projectChanged();
931  }
932  break;
933 
937  projectChanged();
938  break;
939 
940  default:
941  BaseApplication::onApplicationTriggered(e);
942  }
943 }
944 
945 
947 {
948  QMessageBox msgBox(this);
949 
950  msgBox.setText(tr("The system will be restarted."));
951  msgBox.setInformativeText(tr("Do you want to continue?"));
952  msgBox.setWindowTitle(tr("Restart system"));
953 
954  msgBox.addButton(QMessageBox::No);
955  msgBox.addButton(QMessageBox::Yes);
956 
957  msgBox.setDefaultButton(QMessageBox::Yes);
958 
959  if (msgBox.exec() == QMessageBox::Yes)
960  {
962  qApp->exit(1000);
963  }
964 }
965 
967 {
968  bool status = checkAndSaveProject();
969 
970  if (!status)
971  return;
972 
973  resetComponents();
974 
975  m_project->m_title = tr("Default Project");
976 
977  setWindowTitle(m_app->getAppName() + " - " + m_project->m_title);
978 }
979 
981 {
982  bool status = checkAndSaveProject();
983 
984  if (!status)
985  return;
986 
987  resetComponents();
988 
989  QString file = QFileDialog::getOpenFileName(this, tr("Open project file"), qApp->applicationDirPath(), m_tvController->getExtensionFilter());
990 
991  if (file.isEmpty())
992  return;
993 
994  try
995  {
996  openProject(file);
997  }
998  catch (const te::common::Exception& e)
999  {
1000  QString msg = tr("Fail to open project.");
1001  msg += " ";
1002  msg += e.what();
1003  QMessageBox::warning(this, m_app->getAppTitle(), msg);
1004  }
1005 }
1006 
1008 {
1009  QString projFile = m_project->m_fileName;
1010 
1011  if (projFile.isEmpty() || save_as)
1012  {
1013  QFileDialog d(this);
1014 
1015  QString filter = tr("TerraView project(*.") + m_tvController->getAppProjectExtension() + ")";
1016 
1017  QString fileName = d.getSaveFileName(this, tr("Save project"), qApp->applicationDirPath(), filter);
1018 
1019  if(fileName.isEmpty())
1020  return;
1021 
1022  QFileInfo info(fileName);
1023 
1024  if(info.suffix().isEmpty())
1025  fileName.append("." + m_tvController->getAppProjectExtension());
1026 
1027  m_project->m_fileName = fileName;
1028  m_project->m_title = info.baseName();
1029  }
1030 
1031  std::list<te::map::AbstractLayerPtr> lays = getLayerExplorer()->getAllLayers();
1032 
1033  m_project->m_changed = false;
1034 
1035  setWindowTitle(m_app->getAppName() + " - " + m_project->m_title);
1036 
1038 
1040 
1041  XMLFormatter::format(m_project, lays, true);
1043 
1044  SaveProject(*m_project, lays);
1045 
1047 
1048  XMLFormatter::format(m_project, lays, false);
1050 }
1051 
1053 {
1054  onSaveProjectTriggered(true);
1055 }
1056 
1057 
1059 {
1060  te::qt::widgets::HelpManager::getInstance().showHelp("terraview/index.html", "dpi.inpe.br.terraview");
1061 }
1062 
1063 
1065 {
1066  try
1067  {
1068  // Get the parent layer where the dataset layer(s) will be added.
1069  QModelIndex par = GetParent(getLayerExplorer());
1070 
1071  std::list<te::map::AbstractLayerPtr> selectedLayers = te::qt::widgets::GetSelectedLayersOnly(getLayerExplorer());
1072 
1073  if(selectedLayers.empty())
1074  {
1075  QMessageBox::warning(this, m_app->getAppTitle(), tr("Select a layer in the layer explorer!"));
1076  return;
1077  }
1078  else
1079  {
1080  for(std::list<te::map::AbstractLayerPtr>::iterator it = selectedLayers.begin(); it != selectedLayers.end(); ++it)
1081  {
1082  if(!it->get()->isValid())
1083  {
1084  QMessageBox::warning(this, m_app->getAppTitle(), tr("There are invalid layers selected!"));
1085  return;
1086  }
1087  }
1088  }
1089 
1090  te::map::AbstractLayerPtr selectedLayer = *(selectedLayers.begin());
1091 
1092  std::unique_ptr<te::qt::widgets::TableLinkDialog> elb(new te::qt::widgets::TableLinkDialog(this));
1093  elb->setInputLayer(selectedLayer);
1094 
1095  int retval = elb->exec();
1096 
1097  if(retval == QDialog::Rejected)
1098  return;
1099 
1100  te::map::AbstractLayerPtr layer = elb->getQueryLayer();
1101  std::list<te::map::AbstractLayerPtr> layers;
1102 
1103  layers.push_back(layer);
1104 
1105  getLayerExplorer()->addLayers(layers, par);
1106 
1107  projectChanged();
1108  }
1109  catch(const std::exception& e)
1110  {
1111  QMessageBox::warning(this, m_app->getAppTitle(), e.what());
1112  }
1113  catch(...)
1114  {
1115  QMessageBox::warning(this, m_app->getAppTitle(), tr("Unknown error while trying to add a layer from a queried dataset!"));
1116  }
1117 }
1118 
1120 {
1121  try
1122  {
1123  std::list<te::map::AbstractLayerPtr> selectedLayers = te::qt::widgets::GetSelectedLayersOnly(getLayerExplorer());
1124 
1125  if(selectedLayers.empty())
1126  {
1127  QMessageBox::warning(this, m_app->getAppTitle(),
1128  tr("Select a layer in the layer explorer!"));
1129  return;
1130  }
1131  else
1132  {
1133  for(std::list<te::map::AbstractLayerPtr>::iterator it = selectedLayers.begin(); it != selectedLayers.end(); ++it)
1134  {
1135  if(!it->get()->isValid())
1136  {
1137  QMessageBox::warning(this, m_app->getAppTitle(),
1138  tr("There are invalid layers selected!"));
1139  return;
1140  }
1141  }
1142  }
1143 
1144  // The histogram will be created based on the first selected layer
1145  te::map::AbstractLayerPtr selectedLayer = *(selectedLayers.begin());
1146 
1147  te::qt::widgets::HistogramDialog dlg(selectedLayer, this);
1148 
1149  dlg.setWindowTitle(dlg.windowTitle() + " (" + tr("Layer") + ":" + selectedLayer->getTitle().c_str() + ")");
1150 
1151  int res = dlg.exec();
1152  if(res == QDialog::Accepted)
1153  {
1156  doc->setWindowTitle(tr("Histogram"));
1157  doc->setWindowIcon(QIcon::fromTheme("chart-bar"));
1158  doc->setLayer(selectedLayer.get());
1159  doc->setAppController(m_app);
1160 
1161  m_app->addListener(doc);
1162  addDockWidget(Qt::RightDockWidgetArea, doc, Qt::Horizontal);
1163  doc->show();
1164  }
1165  }
1166  catch(const std::exception& e)
1167  {
1168  QMessageBox::warning(this, m_app->getAppTitle(), e.what());
1169  }
1170 }
1171 
1173 {
1174  try
1175  {
1176  std::list<te::map::AbstractLayerPtr> selectedLayers = te::qt::widgets::GetSelectedLayersOnly(getLayerExplorer());
1177 
1178  if(selectedLayers.empty())
1179  {
1180  QMessageBox::warning(this, m_app->getAppTitle(), tr("Select a layer in the layer explorer!"));
1181  return;
1182  }
1183  else
1184  {
1185  for(std::list<te::map::AbstractLayerPtr>::iterator it = selectedLayers.begin(); it != selectedLayers.end(); ++it)
1186  {
1187  if(!it->get()->isValid())
1188  {
1189  QMessageBox::warning(this, m_app->getAppTitle(), tr("There are invalid layers selected!"));
1190  return;
1191  }
1192  }
1193  }
1194 
1195  // The scatter will be created based on the first selected layer
1196  te::map::AbstractLayerPtr selectedLayer = *(selectedLayers.begin());
1197 
1198  const te::map::LayerSchema* schema = selectedLayer->getSchema().release();
1199 
1200  te::da::DataSet* dataset = selectedLayer->getData().release();
1201  te::da::DataSetType* dataType = (te::da::DataSetType*) schema;
1202 
1203  te::qt::widgets::ScatterDialog dlg(dataset, dataType, this);
1204 
1205  dlg.setWindowTitle(dlg.windowTitle() + " (" + tr("Layer") + ":" + selectedLayer->getTitle().c_str() + ")");
1206 
1207  int res = dlg.exec();
1208  if(res == QDialog::Accepted)
1209  {
1211 
1213  doc->setWindowTitle(tr("Scatter"));
1214  doc->setWindowIcon(QIcon::fromTheme("chart-scatter"));
1215  m_app->addListener(doc);
1216  doc->setLayer(selectedLayer.get());
1217  doc->setAppController(m_app);
1218 
1219  addDockWidget(Qt::RightDockWidgetArea, doc, Qt::Horizontal);
1220  doc->show();
1221  }
1222  }
1223  catch(const std::exception& e)
1224  {
1225  QMessageBox::warning(this, m_app->getAppTitle(), e.what());
1226  }
1227 }
1228 
1230 {
1231  try
1232  {
1233  std::list<te::map::AbstractLayerPtr> selectedLayers = te::qt::widgets::GetSelectedLayersOnly(getLayerExplorer());
1234 
1235  if(selectedLayers.empty())
1236  {
1237  QMessageBox::warning(this, m_app->getAppTitle(),
1238  tr("Select a single layer in the layer explorer!"));
1239  return;
1240  }
1241  else
1242  {
1243  for(std::list<te::map::AbstractLayerPtr>::iterator it = selectedLayers.begin(); it != selectedLayers.end(); ++it)
1244  {
1245  if(!(*it)->isValid())
1246  {
1247  QMessageBox::warning(this, m_app->getAppTitle(),
1248  tr("There are invalid layers selected!"));
1249  return;
1250  }
1251  }
1252  }
1253 
1254  // The chart will be accomplished only on the first single layer selected
1255  te::map::AbstractLayerPtr selectedLayer = *selectedLayers.begin();
1256 
1258 
1259  dlg.setWindowTitle(dlg.windowTitle() + " (" + tr("Layer") + ":" + selectedLayer->getTitle().c_str() + ")");
1260 
1261  dlg.setLayer(selectedLayer);
1262 
1263  // If the selected layer has a chart associated to it, set the chart layer
1264  // dialog for initializing with this chart.
1265  te::map::Chart* chart = selectedLayer->getChart();
1266 
1267  if(chart)
1268  dlg.setChart(chart);
1269 
1270  if(dlg.exec() == QDialog::Accepted)
1271  {
1272  getLayerExplorer()->updateChart(*getLayerExplorer()->selectionModel()->selectedIndexes().begin());
1273 
1275 
1276  projectChanged();
1277  }
1278  }
1279  catch(const std::exception& e)
1280  {
1281  QMessageBox::warning(this, m_app->getAppTitle(), e.what());
1282  }
1283 }
1284 
1286 {
1287  try
1288  {
1289  std::list<te::map::AbstractLayerPtr> selectedLayers = te::qt::widgets::GetSelectedLayersOnly(getLayerExplorer(), true);
1290 
1291  if (selectedLayers.empty())
1292  {
1293  QMessageBox::warning(this, m_app->getAppTitle(), tr("Select a single layer in the layer explorer!"));
1294  return;
1295  }
1296  else
1297  {
1298  for (std::list<te::map::AbstractLayerPtr>::iterator it = selectedLayers.begin(); it != selectedLayers.end(); ++it)
1299  {
1300  te::map::AbstractLayer* lptr = it->get();
1301 
1302  if (!lptr->isValid())
1303  {
1304  QMessageBox::warning(this, m_app->getAppTitle(), tr("There are invalid layers selected!"));
1305 
1306  return;
1307  }
1308  }
1309  }
1310 
1311  te::map::AbstractLayerPtr selectedLayer = *selectedLayers.begin();
1312 
1313  te::map::AbstractLayerPtr newLayer = selectedLayer->clone();
1314 
1315  QModelIndex res;
1316  QModelIndexList idxs = getLayerExplorer()->selectionModel()->selectedIndexes();
1317 
1318  if (idxs.size() == 1)
1319  {
1320  res = idxs.at(0);
1321  te::qt::widgets::TreeItem* item = static_cast<te::qt::widgets::TreeItem*>(res.internalPointer());
1322 
1323  if (item->getType() == "FOLDER")
1324  res = res.parent();
1325  }
1326 
1327  std::list<te::map::AbstractLayerPtr> layers;
1328  layers.push_back(newLayer);
1329 
1330  getLayerExplorer()->addLayers(layers, res);
1331 
1332  projectChanged();
1333  }
1334  catch (const std::exception& e)
1335  {
1336  QMessageBox::warning(this, m_app->getAppTitle(), e.what());
1337  }
1338 }
1339 
1341 {
1342  try
1343  {
1344  std::list<te::map::AbstractLayerPtr> selectedLayers = te::qt::widgets::GetSelectedLayersOnly(getLayerExplorer());
1345 
1346  if(selectedLayers.empty())
1347  {
1348  QMessageBox::warning(this, m_app->getAppTitle(), tr("Select a single layer in the layer explorer!"));
1349  return;
1350  }
1351  else
1352  {
1353  for(std::list<te::map::AbstractLayerPtr>::iterator it = selectedLayers.begin(); it != selectedLayers.end(); ++it)
1354  {
1355  if(!(*it)->isValid())
1356  {
1357  QMessageBox::warning(this, m_app->getAppTitle(), tr("There are invalid layers selected!"));
1358 
1359  return;
1360  }
1361  }
1362  }
1363 
1364  // The object grouping will be accomplished only on the first layer selected
1365  te::map::AbstractLayerPtr selectedLayer = *selectedLayers.begin();
1366 
1367  // Get all layer with grouping to dispose to import
1368  std::vector<te::map::AbstractLayerPtr> allLayers;
1369  te::qt::widgets::GetValidLayers(getLayerExplorer()->model(), QModelIndex(), allLayers);
1370 
1372  dlg.setLayers(selectedLayer, allLayers);
1373 
1374 
1375  if(dlg.exec() == QDialog::Accepted)
1376  {
1377  getLayerExplorer()->updateLegend(selectedLayer.get());
1378 
1379  projectChanged();
1380 
1381  te::qt::af::evt::LayerChanged e2(selectedLayer.get());
1382  emit triggered(&e2);
1383 
1385  }
1386  }
1387  catch(const std::exception& e)
1388  {
1389  QMessageBox::warning(this, m_app->getAppTitle(), e.what());
1390  }
1391 }
1392 
1394 {
1395  std::list<te::map::AbstractLayerPtr> selectedLayers = te::qt::widgets::GetSelectedLayersOnly(getLayerExplorer());
1396 
1397  if(!selectedLayers.empty())
1398  {
1399  std::list<te::map::AbstractLayerPtr>::iterator it = selectedLayers.begin();
1400 
1401  m_compModeMenu->setLayer(*it);
1402  }
1403 }
1404 
1406 {
1407  std::list<te::map::AbstractLayerPtr> selectedLayers = te::qt::widgets::GetSelectedLayersOnly(getLayerExplorer());
1408 
1409  if(selectedLayers.empty())
1410  {
1411  QMessageBox::warning(this, m_app->getAppTitle(),
1412  tr("Select a layer in the layer explorer!"));
1413  return;
1414  }
1415  else
1416  {
1417  std::list<te::map::AbstractLayerPtr>::iterator it = selectedLayers.begin();
1418 
1419  while(it != selectedLayers.end())
1420  {
1421  if(!it->get()->isValid())
1422  {
1423  QMessageBox::warning(this, m_app->getAppTitle(),
1424  tr("There are invalid layers selected!"));
1425  return;
1426  }
1427 
1428  ++it;
1429  }
1430  }
1431 
1432  if(!m_queryDlg)
1433  {
1435 
1436  connect(m_queryDlg, SIGNAL(highlightLayerObjects(const te::map::AbstractLayerPtr&, te::da::DataSet*, const QColor&)),
1437  SLOT(onHighlightLayerObjects(const te::map::AbstractLayerPtr&, te::da::DataSet*, const QColor&)));
1438 
1439  connect(m_queryDlg, SIGNAL(layerSelectedObjectsChanged(const te::map::AbstractLayerPtr&)),
1441 
1443 
1444  if(m_iController)
1446  }
1447 
1448  std::list<te::map::AbstractLayerPtr> allLayersList;
1449  te::qt::widgets::GetValidLayers(getLayerExplorer()->model(), QModelIndex(), allLayersList);
1450 
1451  m_queryDlg->setLayerList(allLayersList);
1452 
1453  selectedLayers = GetSelectedLayersOnly(getLayerExplorer());
1454 
1455  if(!selectedLayers.empty())
1456  m_queryDlg->setCurrentLayer(*(selectedLayers.begin()));
1457 
1458  m_queryDlg->show();
1459 }
1460 
1462 {
1463  if (layer)
1464  {
1465  std::list<te::map::AbstractLayerPtr> layers;
1466  layers.push_back(layer);
1467 
1468  if (layers.empty())
1469  return;
1470 
1471  QModelIndex pF = GetParent(getLayerExplorer());
1472 
1473  getLayerExplorer()->addLayers(layers, pF);
1474 
1475  projectChanged();
1476  }
1477 }
1478 
1480 {
1481  try
1482  {
1483  if(m_project == nullptr)
1484  throw te::common::Exception(TE_TR("Error: there is no opened project!"));
1485 
1486  QApplication::setOverrideCursor(Qt::WaitCursor);
1487 
1488  // Get the parent layer where the dataset layer(s) will be added.
1489  QModelIndex pF = GetParent(getLayerExplorer());
1490 
1491  // Get the layer(s) to be added
1492  std::unique_ptr<te::qt::widgets::DataSourceSelectorDialog> dselector(new te::qt::widgets::DataSourceSelectorDialog(this));
1493 
1494  QString dsTypeSett = te::qt::af::GetLastDatasourceFromSettings();
1495 
1496  if(!dsTypeSett.isNull() && !dsTypeSett.isEmpty())
1497  dselector->setDataSourceToUse(dsTypeSett);
1498 
1499  QApplication::restoreOverrideCursor();
1500 
1501  int retval = dselector->exec();
1502 
1503  QApplication::setOverrideCursor(Qt::WaitCursor);
1504 
1505  if(retval == QDialog::Rejected)
1506  {
1507  QApplication::restoreOverrideCursor();
1508  return;
1509  }
1510 
1511  std::list<te::da::DataSourceInfoPtr> selectedDatasources = dselector->getSelecteds();
1512 
1513  if(selectedDatasources.empty())
1514  {
1515  QApplication::restoreOverrideCursor();
1516  return;
1517  }
1518 
1519  dselector.reset(nullptr);
1520 
1521  const std::string& dsTypeId = selectedDatasources.front()->getType();
1522 
1524 
1525  std::unique_ptr<QWidget> lselectorw(dsType->getWidget(te::qt::widgets::DataSourceType::WIDGET_LAYER_SELECTOR, this));
1526 
1527  if(lselectorw.get() == nullptr)
1528  {
1529  QApplication::restoreOverrideCursor();
1530  throw te::common::Exception((boost::format(TE_TR("No layer selector widget found for this type of data source: %1%!")) % dsTypeId).str());
1531  }
1532 
1533  te::qt::widgets::AbstractLayerSelector* lselector = dynamic_cast<te::qt::widgets::AbstractLayerSelector*>(lselectorw.get());
1534 
1535  if(lselector == nullptr)
1536  {
1537  QApplication::restoreOverrideCursor();
1538  throw te::common::Exception(TE_TR("Wrong type of object for layer selection!"));
1539  }
1540 
1541  lselector->set(selectedDatasources);
1542 
1543  QApplication::restoreOverrideCursor();
1544 
1545  std::list<te::map::AbstractLayerPtr> layers = lselector->getLayers();
1546 
1547  if(layers.empty())
1548  return;
1549 
1550  QApplication::setOverrideCursor(Qt::WaitCursor);
1551 
1552  lselectorw.reset(nullptr);
1553 
1554  getLayerExplorer()->addLayers(layers, pF);
1555 
1556  te::qt::af::SaveLastDatasourceOnSettings(dsTypeId.c_str());
1557 
1558  projectChanged();
1559  }
1560  catch(const std::exception& e)
1561  {
1562  QApplication::restoreOverrideCursor();
1563  QMessageBox::warning(this, m_app->getAppTitle(), e.what());
1564  }
1565  catch(...)
1566  {
1567  QApplication::restoreOverrideCursor();
1568  QMessageBox::warning(this,
1569  m_app->getAppTitle(),
1570  tr("Unknown error while trying to add a layer from a dataset!"));
1571  }
1572 
1573  QApplication::restoreOverrideCursor();
1574 }
1575 
1577 {
1578  try
1579  {
1580  if(m_project == nullptr)
1581  throw te::common::Exception(TE_TR("Error: there is no opened project!"));
1582 
1583  // Get the parent layer where the dataset layer(s) will be added.
1584  QModelIndex par = GetParent(getLayerExplorer());
1585 
1586  std::unique_ptr<te::qt::widgets::QueryLayerBuilderWizard> qlb(new te::qt::widgets::QueryLayerBuilderWizard(this));
1587 
1588  std::list<te::map::AbstractLayerPtr> layers;
1589  te::qt::widgets::GetValidLayers(getLayerExplorer()->model(), QModelIndex(), layers);
1590 
1591  qlb->setLayerList(layers);
1592 
1593  int retval = qlb->exec();
1594 
1595  if(retval == QDialog::Rejected)
1596  return;
1597 
1598  te::map::AbstractLayerPtr layer = qlb->getQueryLayer();
1599 
1600  if((m_layerExplorer != nullptr) && (m_layerExplorer->getExplorer() != nullptr))
1601  {
1602  std::list<te::map::AbstractLayerPtr> ls;
1603  ls.push_back(layer);
1604 
1605  getLayerExplorer()->addLayers(ls, par);
1606 
1607  projectChanged();
1608  }
1609  }
1610  catch(const std::exception& e)
1611  {
1612  QMessageBox::warning(this, m_app->getAppTitle(), e.what());
1613  }
1614  catch(...)
1615  {
1616  QMessageBox::warning(this,
1617  m_app->getAppTitle(),
1618  tr("Unknown error while trying to add a layer from a queried dataset!"));
1619  }
1620 
1621 }
1622 
1624 {
1625  try
1626  {
1627  if(m_project == nullptr)
1628  throw te::common::Exception(TE_TR("Error: there is no opened project!"));
1629 
1630  // Get the parent layer where the tabular layer will be added.
1631  QModelIndex par = GetParent(getLayerExplorer());
1632 
1634  int res = dlg.exec();
1635 
1636  if(res == QDialog::Accepted)
1637  {
1638  if((m_layerExplorer != nullptr) && (m_layerExplorer->getExplorer() != nullptr))
1639  {
1640  std::list<te::map::AbstractLayerPtr> ls;
1641  ls.push_back(dlg.getDataSetAdapterLayer());
1642 
1643  getLayerExplorer()->addLayers(ls, par);
1644 
1645  projectChanged();
1646  }
1647  }
1648  }
1649  catch(const std::exception& e)
1650  {
1651  QMessageBox::warning(this, m_app->getAppTitle(), e.what());
1652  }
1653  catch(...)
1654  {
1655  QMessageBox::warning(this,
1656  m_app->getAppTitle(),
1657  tr("Unknown error while trying to add a layer from a queried dataset!"));
1658  }
1659 }
1660 
1662 {
1663  // Get the parent item where the folder layer will be added.
1664  QModelIndex idx = GetParent(getLayerExplorer());
1665 
1666  // Get the folder layer to be added
1667  bool ok;
1668  QString text = QInputDialog::getText(this, m_app->getAppTitle(),
1669  tr("Folder layer name:"), QLineEdit::Normal,
1670  tr("Enter folder layer name"), &ok);
1671 
1672  if(!ok)
1673  return;
1674 
1675  if(text.isEmpty())
1676  {
1677  QMessageBox::warning(this, m_app->getAppTitle(), tr("Enter the layer name!"));
1678  return;
1679  }
1680 
1681  getLayerExplorer()->addFolder(text.toUtf8().data(), idx);
1682 
1683  projectChanged();
1684 }
1685 
1687 {
1688  if (m_project == nullptr)
1689  {
1690  QMessageBox::warning(this, m_app->getAppTitle(), tr("There's no current project!"));
1691  return;
1692  }
1693 
1694  ProjectInfoDialog editor(this);
1695  editor.setProject(m_project);
1696 
1697  if (editor.exec() == QDialog::Accepted)
1698  {
1699  // Set window title
1700  if(m_project->m_changed)
1701  projectChanged();
1702  }
1703 }
1704 
1706 {
1707  try
1708  {
1709  std::list<te::qt::widgets::TreeItem*> selectedLayerItems = getLayerExplorer()->getSelectedItems();
1710 
1711  if(selectedLayerItems.empty())
1712  return;
1713 
1714  te::map::AbstractLayerPtr layer = ((te::qt::widgets::LayerItem*)selectedLayerItems.front())->getLayer();
1715 
1716  te::map::DataSetLayer* dsl = (te::map::DataSetLayer*)layer.get();
1717 
1718  if(!dsl)
1719  return;
1720 
1721  std::list<te::da::DataSourceInfoPtr> selecteds;
1722 
1724 
1725  if (ds)
1726  {
1727  selecteds.push_back(ds);
1728 
1729  const std::string& dsTypeId = selecteds.front()->getType();
1730 
1732 
1733  std::unique_ptr<QWidget> connectorw(dsType->getWidget(te::qt::widgets::DataSourceType::WIDGET_DATASOURCE_CONNECTOR, this));
1734 
1735  if (connectorw.get() == nullptr)
1736  {
1737  throw te::common::Exception((boost::format(TE_TR("No layer selector widget found for this type of data source: %1%!")) % dsTypeId).str());
1738  }
1739 
1741 
1742  if (connector == nullptr)
1743  {
1744  throw te::common::Exception(TE_TR("Wrong type of object for layer selection!"));
1745  }
1746 
1747  connector->update(selecteds);
1748 
1749  }
1750  else
1751  {
1753 
1754  if (dlg.exec() == QDialog::Rejected)
1755  return;
1756 
1757  te::da::DataSourceInfoPtr selected = dlg.getSelecteds().front();
1758 
1759  dsl->setDataSourceId(selected->getId());
1760 
1761  }
1762  }
1763  catch(const std::exception& e)
1764  {
1765  QMessageBox::warning(this, m_app->getAppTitle(), e.what());
1766  }
1767  catch(...)
1768  {
1769  QMessageBox::warning(this,
1770  m_app->getAppTitle(),
1771  tr("Unknown error while trying to update a layer data source!"));
1772  }
1773 }
1774 
1776 {
1777  bool status = checkAndSaveProject();
1778 
1779  if (!status)
1780  return;
1781 
1782  QString projFile = proj->data().toString();
1783 
1784  resetComponents();
1785 
1786  openProject(projFile);
1787 }
1788 
1789 
1791 {
1792  try
1793  {
1795  dlg.exec();
1796  }
1797  catch (const std::exception& e)
1798  {
1799  QMessageBox::warning(this, m_app->getAppTitle(), e.what());
1800  }
1801 }
1802 
1804 {
1805  try
1806  {
1807  te::qt::af::SettingsDialog dlg(this);
1809  dlg.exec();
1810  }
1811  catch (const std::exception& e)
1812  {
1813  QMessageBox::warning(this, m_app->getAppTitle(), e.what());
1814  }
1815 }
1816 
1818 {
1819  try
1820  {
1822  dlg.exec();
1823  }
1824  catch (const std::exception& e)
1825  {
1826  QMessageBox::warning(this, m_app->getAppTitle(), e.what());
1827  }
1828 }
1829 
1831 {
1832  try
1833  {
1835 
1836  std::list<te::map::AbstractLayerPtr> layers;
1837  te::qt::widgets::GetValidLayers(getLayerExplorer()->model(), QModelIndex(), layers);
1838 
1839  dlg.setLayers(layers);
1840 
1841  QString dsTypeSett = te::qt::af::GetLastDatasourceFromSettings();
1842 
1843  if(!dsTypeSett.isNull() && !dsTypeSett.isEmpty())
1844  dlg.setLastDataSource(dsTypeSett.toUtf8().data());
1845 
1846  dlg.exec();
1847  }
1848  catch(const std::exception& e)
1849  {
1850  QMessageBox::warning(this, m_app->getAppTitle(), e.what());
1851  }
1852 }
1853 
1855 {
1856  try
1857  {
1859 
1860  std::list<te::map::AbstractLayerPtr> selectedLayerItems = te::qt::widgets::GetSelectedLayersOnly(getLayerExplorer());
1861 
1862  if(selectedLayerItems.empty())
1863  {
1864  QMessageBox::warning(this, m_app->getAppTitle(),
1865  tr("Select a single layer in the layer explorer!"));
1866  return;
1867  }
1868 
1869  std::list<te::map::AbstractLayerPtr> layers;
1870  layers.push_back(selectedLayerItems.front());
1871 
1872  dlg.setLayers(layers);
1873 
1874  dlg.exec();
1875  }
1876  catch(const std::exception& e)
1877  {
1878  QMessageBox::warning(this, m_app->getAppTitle(), e.what());
1879  }
1880 }
1881 
1883 {
1884  try
1885  {
1887 
1888  connect(&dlg, SIGNAL(createNewLayer(te::map::AbstractLayerPtr)), this, SLOT(onCreateNewLayer(te::map::AbstractLayerPtr)));
1889 
1890  std::list<te::map::AbstractLayerPtr> layers;
1891  te::qt::widgets::GetValidLayers(getLayerExplorer()->model(), QModelIndex(), layers);
1892 
1893  dlg.setLayerList(layers);
1895 
1896  dlg.exec();
1897  }
1898  catch(const std::exception& e)
1899  {
1900  QMessageBox::warning(this, m_app->getAppTitle(), e.what());
1901  }
1902 }
1903 
1905 {
1906  try
1907  {
1909 
1910  std::list<te::map::AbstractLayerPtr> layers;
1911  te::qt::widgets::GetValidLayers(getLayerExplorer()->model(), QModelIndex(), layers);
1912 
1913  dlg.setLayerList(layers);
1914 
1915  dlg.exec();
1916  }
1917  catch(const std::exception& e)
1918  {
1919  QMessageBox::warning(this, m_app->getAppTitle(), e.what());
1920  }
1921 }
1922 
1924 {
1925  try
1926  {
1927  std::unique_ptr<te::qt::widgets::DataSourceExplorerDialog> dExplorer(new te::qt::widgets::DataSourceExplorerDialog(this));
1928 
1929  QString dsTypeSett = te::qt::af::GetLastDatasourceFromSettings();
1930 
1931  if (!dsTypeSett.isNull() && !dsTypeSett.isEmpty())
1932  dExplorer->setDataSourceToUse(dsTypeSett);
1933 
1934 
1935  int retval = dExplorer->exec();
1936 
1937  if (retval == QDialog::Rejected)
1938  return;
1939 
1940  std::list<te::da::DataSourceInfoPtr> selectedDatasources = dExplorer->getSelecteds();
1941 
1942  if (selectedDatasources.empty())
1943  return;
1944 
1945  dExplorer.reset(nullptr);
1946 
1947  const std::string& dsTypeId = selectedDatasources.front()->getType();
1948 
1949  te::qt::af::SaveLastDatasourceOnSettings(dsTypeId.c_str());
1950  }
1951  catch (const std::exception& e)
1952  {
1953  QMessageBox::warning(this, m_app->getAppTitle(), e.what());
1954  }
1955  catch (...)
1956  {
1957  QMessageBox::warning(this,
1958  m_app->getAppTitle(),
1959  tr("DataSetExplorer Error!"));
1960  }
1961 }
1962 
1963 
1965 {
1966  m_progressDockWidget->setVisible(true);
1967 }
1968 
1970 {
1971  assert(layer.get());
1972  assert(dataset);
1973 
1974  te::qt::af::evt::HighlightLayerObjects e(layer, dataset, style);
1975  m_app->trigger(&e);
1976 }
1977 
1979 {
1980  te::qt::af::evt::LayerAdded evt(layer);
1981  m_app->trigger(&evt);
1982 }
1983 
1984 
1986 {
1987  m_project->m_changed = true;
1988 
1989  setWindowTitle(qApp->applicationName() + " - " + m_project->m_title + " *");
1990 }
1991 
1993 {
1994  if(m_project->m_changed)
1995  {
1996  QString msg = tr("The current project has unsaved changes. Do you want to save them?");
1997  QMessageBox::StandardButton btn = QMessageBox::question(this, windowTitle(), msg, QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Save);
1998 
1999  if (btn == QMessageBox::Save)
2001 
2002  if (btn == QMessageBox::Cancel)
2003  return false;
2004  }
2005 
2006  return true;
2007 }
2008 
2009 void TerraView::openProject(const QString& prjFileName)
2010 {
2011  std::list<te::map::AbstractLayerPtr> lst;
2012 
2013  try
2014  {
2015  LoadProject(prjFileName, *m_project, lst);
2016 
2017  XMLFormatter::format(m_project, lst, false);
2019 
2020  getLayerExplorer()->setLayers(lst);
2021 
2022  m_project->m_changed = false;
2023 
2024  setWindowTitle(m_app->getAppName() + " - " + m_project->m_title);
2025 
2027  }
2028  catch(te::common::Exception&)
2029  {
2030  QString msg = tr("The project ") + m_project->m_title + tr(" is invalid or from an older TerraView version. \nAn empty project will be created.");
2031  QMessageBox::warning(this, m_app->getAppTitle(), msg);
2032 
2034  }
2035  catch (const boost::exception&)
2036  {
2037  QString msg = tr("The project ") + m_project->m_title + tr(" is invalid or from an older TerraView version. \nAn empty project will be created.");
2038  QMessageBox::warning(this, m_app->getAppTitle(), msg);
2039 
2041  }
2042 }
2043 
2045 {
2046  m_project->m_fileName = "";
2047  m_project->m_title = "";
2048  m_project->m_changed = false;
2049 
2050  // Closing tables
2051  for (std::size_t i = 0; i < m_tables.size(); ++i)
2052  {
2053  m_tables[i]->close();
2054  }
2055 
2056  setWindowTitle(m_app->getAppName() + " - " + m_project->m_title);
2057 
2058  std::list<te::map::AbstractLayerPtr> ls;
2059 
2060  getLayerExplorer()->setLayers(ls);
2061 
2062  getMapDisplay()->setLayerList(ls);
2063 
2064  getMapDisplay()->refresh(true);
2065 
2067 
2068  // Set map srid 0
2069  te::qt::af::evt::MapSRIDChanged mapSRIDChagned(std::pair<int, std::string>(0, ""));
2070  m_app->trigger(&mapSRIDChagned);
2071 
2072  m_display->getDisplay()->setSRID(0);
2073 }
2074 
2075 void TerraView::closeEvent(QCloseEvent* event)
2076 {
2078 
2079 
2080  if(checkAndSaveProject())
2081  QMainWindow::close();
2082  else
2083  event->ignore();
2084 }
2085 
2086 void TerraView::addActions(const QString& plgName, const QString& category, const QList<QAction*>& acts)
2087 {
2088  if(category == "Processing")
2089  {
2090  QMenu* mnu = m_app->getMenu("Processing");
2091 
2092  if(mnu == nullptr)
2093  return;
2094 
2095  QMenu* p = new QMenu(plgName, mnu);
2096 
2097  for(QList<QAction*>::const_iterator it = acts.begin(); it != acts.end(); ++it)
2098  p->addAction(*it);
2099 
2100  mnu->addMenu(p);
2101  }
2102  else if(category == "Dataaccess")
2103  {
2104  for(QList<QAction*>::const_iterator it = acts.begin(); it != acts.end(); ++it)
2105  m_projectAddLayerMenu->addAction(*it);
2106  }
2107  else
2108  {
2109  for(QList<QAction*>::const_iterator it = acts.begin(); it != acts.end(); ++it)
2110  m_pluginsMenu->insertAction(m_app->findAction("ManagePluginsSeparator"), *it);
2111  }
2112 }
2113 
QAction * m_projectAddLayerTabularDataSet
Definition: TerraView.h:217
QAction * m_layerChartsScatter
Definition: TerraView.h:205
virtual std::list< te::map::AbstractLayerPtr > getLayers()=0
This event signals that a new layer was created.
Definition: LayerEvents.h:71
QAction * m_projectAddLayerQueryDataSet
Definition: TerraView.h:216
ApplicationController * m_app
void onLayerScatterTriggered()
Definition: TerraView.cpp:1172
virtual void refresh(bool redraw=false)
It updates the contents in the map display.
QAction * m_layerCompositionMode
Definition: TerraView.h:210
TEXSDEXPORT void Save(All *all, te::xml::AbstractWriter &writer)
void onAddTabularLayerTriggered()
Definition: TerraView.cpp:1623
void onOpenProjectTriggered()
Definition: TerraView.cpp:980
A dock widget for table view objects.
QAction * m_fileRestartSystem
Definition: TerraView.h:198
QAction * m_toolsCustomize
Definition: TerraView.h:223
virtual void setDataSourceId(const std::string &id)
This file defines a class for a Query Data Source Dialog Dialog.
te::qt::widgets::ChartDisplayWidget * getDisplayWidget()
Returns a pointer to the generated ChartDisplayWidget.
te::qt::widgets::ChartDisplayWidget * getDisplayWidget()
Returns a pointer to the generated ChartDisplayWidget.
This file has the ZoomInMapDisplayWidget class.
void onToolsDataExchangerTriggered()
Definition: TerraView.cpp:1817
void onLinkTriggered()
Definition: TerraView.cpp:1064
A dialog for selecting a data source.
The Style defines the styling that is to be applied to a geographic dataset (vector geometries or cov...
Definition: Style.h:65
A dock widget for ChartDisplayWidget objects.
QDockWidget * m_progressDockWidget
Dock widget used to show progress information.
Definition: TerraView.h:246
A class that defines the interface of a qt widget to group a set of ProgressWidgetItem.
This is the base class for layers.
Definition: AbstractLayer.h:77
void addMultipleSelectionAction(QAction *act)
Adds the action to the popup menu presented when there is multiple items selected.
void addNoLayerAction(QAction *act)
Adds the action to the popup menu presented when there is no layers selected.
void onSaveProjectAsTriggered()
Definition: TerraView.cpp:1052
void onApplicationTriggered(te::qt::af::evt::Event *e)
Definition: TerraView.cpp:907
A dialog used to build a chart.
void onToolsDataExchangerDirectPopUpTriggered()
Definition: TerraView.cpp:1854
A for customization of the application components.
QAction * m_toolsQueryDataSource
Definition: TerraView.h:229
An item that contains a te::map::AbstractLayerPtr.
Definition: LayerItem.h:51
TEQTAFEXPORT void SaveDataSourcesFile(te::qt::af::ApplicationController *appController)
Saves data sources file.
A Qt dialog that allows users to create query builder based on TerraLib query framework.
A singleton class used to manage tasks progresses and their viewers.
const QString & getAppTitle() const
Returns the application title.
void onProjectPropertiesTriggered()
Definition: TerraView.cpp:1686
void onLayerSelectedObjectsChanged(const te::map::AbstractLayerPtr &layer)
void SaveProject(const ProjectMetadata &proj, const std::list< te::map::AbstractLayerPtr > &layers)
Definition: Project.cpp:97
QMenu * getMenu(const QString &id)
Returns a menu registered with key id.
A class that models the description of a dataset.
Definition: DataSetType.h:72
void onToolsDataExchangerDirectTriggered()
Definition: TerraView.cpp:1830
te::qt::widgets::CompositionModeMenuWidget * m_compModeMenu
Definition: TerraView.h:254
static void formatDataSourceInfos(const bool &encode)
Formats all data source informations registered in the te::da::DataSourceInfoManager object...
void setApplicationController(te::qt::af::ApplicationController *app)
A base class for application events.
virtual const char * what() const
It outputs the exception message.
void updateLegend(te::map::AbstractLayer *l)
updateLegend
void projectChanged()
Definition: TerraView.cpp:1985
void addInterface(te::qt::widgets::InterfaceController *i)
QMenu * m_projectMenu
Definition: TerraView.h:237
void setSelectionColor(QColor selColor)
color used to hgihlight selected objects on this display.
QAction * m_filePrintPreview
Definition: TerraView.h:197
This file is a wrapper around platform specific include files.
This event indicates that the objects of the given layer must be highlighted.
Definition: LayerEvents.h:227
This event signals that the srid of the map display changed.
Definition: MapEvents.h:54
The base API for TerraLib applications.
void setCurrentLayer(te::map::AbstractLayerPtr layer)
This method is used to set current layer.
This class models the concept of a project for the TerraView.
A connector for the te::qt::widgets::StyleDockWidget class to the Application Framework.
void LoadProject(const QString &projFile, ProjectMetadata &proj, std::list< te::map::AbstractLayerPtr > &layers)
Definition: Project.cpp:185
Contains a list of the map display events.
QAction * m_fileExit
Definition: TerraView.h:195
A dock widget used control the geographic data style using SE elements and a property browser to show...
QAction * m_layerChartsHistogram
Definition: TerraView.h:204
te::qt::widgets::StyleDockWidget * getExplorer() const
virtual void initializeProjectMenus()
Initializes the menus for the most recent open projects.
void setChart(te::map::Chart *chart)
Update the interface with the chart properties.
static void format(ProjectMetadata *p, const std::list< te::map::AbstractLayerPtr > &layers, const bool &encode)
Formats the project informations.
static te::dt::Date ds(2010, 01, 01)
QAction * m_fileSaveProject
Definition: TerraView.h:192
bool m_changed
Flag indicating that the project needs to be saved.
Definition: Project.h:43
void addFolder(const std::string &name, const QModelIndex &idx)
Adds a folder layer to the model.
A dialog to create multi resolution over a raster.
QAction * m_toolsDataExchangerDirect
Definition: TerraView.h:225
TEQTAFEXPORT void SaveLastDatasourceOnSettings(const QString &dsType)
#define TE_TR(message)
It marks a string in order to get translated.
Definition: Translator.h:242
An abstract class for layer selection widgets.
virtual void makeDialog()
Definition: TerraView.cpp:309
const QString & getAppProjectExtension() const
Returns the application project extension.
QMenu * m_toolsMenu
Definition: TerraView.h:240
A dialog used to build a grouping.
QMenu * m_projectAddLayerMenu
Definition: TerraView.h:238
void onAddFolderLayerTriggered()
Definition: TerraView.cpp:1661
virtual bool isValid() const =0
It returns true if the layer can be used for instance to draw, otherwise, it returns false...
A multi thread Qt4 widget to control the display of a set of layers.
Defines a hierarchical structure.
A dialog for edition of Project informations.
te::qt::widgets::LayerItemView * getExplorer() const
This class implements a concrete tool to measure operation (distance, area, and angle).
virtual void update(std::list< te::da::DataSourceInfoPtr > &datasources)=0
QMenu * m_viewMenu
Definition: TerraView.h:242
virtual void initAction(QAction *&act, const QString &icon, const QString &name, const QString &text, const QString &tooltip, bool iconVisibleInMenu, bool isCheckable, bool enabled, QObject *parent)
A singleton to keep all the registered data sources.
QMenu * m_toolsExchangerMenu
Definition: TerraView.h:241
void onToolsRasterMultiResolutionTriggered()
Definition: TerraView.cpp:1904
void setLayer(te::map::AbstractLayerPtr layer)
Set the layer that can be used.
void addLayers(const std::list< te::map::AbstractLayerPtr > &layers, const QModelIndex &idx, const std::string &idxPath="./")
Add the layers to the model.
void setLayer(te::map::AbstractLayerPtr layer)
Set a layer.
Contains the list of the project events.
QString m_fileName
The project file.
Definition: Project.h:44
void setTerraViewLogoFilePath(std::string path)
Definition: AboutDialog.cpp:60
const QString & getAppName() const
Returns the application name.
TEQTWIDGETSEXPORT void GetValidLayers(QAbstractItemModel *model, const QModelIndex &parent, std::vector< te::map::AbstractLayerPtr > &layers)
QAction * m_layerChart
Definition: TerraView.h:206
QAction * m_toolsDataSourceExplorer
Definition: TerraView.h:227
virtual void setLayerList(const std::list< te::map::AbstractLayerPtr > &layers)
It sets the layer list to be showed in the Map Display.
QAction * m_projectAddFolderLayer
Definition: TerraView.h:219
void resetComponents()
Definition: TerraView.cpp:2044
QMenu * m_mapMenu
Definition: TerraView.h:235
A class that defines the interface of a qt widget to group a set of ProgressWidgetItem.
void onDataSourceExplorerTriggered()
Definition: TerraView.cpp:1923
QAction * m_projectProperties
Definition: TerraView.h:221
QColor getSelectionColor() const
Returns the application selection color.
A connector of the te::qt::widgets::MapDisplay class to the Application Framework.
This file defines a class for a CompositionModeMenuWidget.
void WriteProjectsToSettings(const QStringList &prjTitles, const QStringList &prjPaths)
Definition: TerraView.cpp:170
This class represents the informations needed to build map charts.
Definition: Chart.h:51
QString GetWindowTitle(const ProjectMetadata &project, te::qt::af::ApplicationController *app)
Definition: TerraView.cpp:115
void showProgressDockWidget()
Definition: TerraView.cpp:1964
void onPluginsManagerTriggered()
Definition: TerraView.cpp:1790
static ProgressManager & getInstance()
It returns a reference to the singleton instance.
te::qt::widgets::ProgressViewerBar * m_pvb
Definition: TerraView.h:260
A dialog used to configure the properties of a new textual file based layer.
A connector for the te::qt::widgets::LayerExplorer class to the Application Framework.
void startProject(const QString &projectFileName)
Definition: TerraView.cpp:304
A base class for widgets that allows application to create, edit or remove data sources.
A widget used to controll the style se element.
bool checkAndSaveProject()
Definition: TerraView.cpp:1992
QAction * m_fileNewProject
Definition: TerraView.h:191
URI C++ Library.
Definition: Attributes.h:37
void setLayers(te::map::AbstractLayerPtr selectedLayer, std::vector< te::map::AbstractLayerPtr > allLayers)
void removeInteface(te::qt::widgets::InterfaceController *i)
static te::dt::DateTime d(2010, 8, 9, 15, 58, 39)
void ResetProject(ProjectMetadata *p)
Definition: TerraView.cpp:239
Contains a list of the layer events.
QAction * m_projectAddLayerDataset
Definition: TerraView.h:215
const_iterator begin() const
It returns the constant iterator associated to the first child of this item.
A Qt dialog showing MGis about window.
A class that defines the interface of a qt bar progress viewer.
void setLayer(te::map::AbstractLayer *layer)
Sets the layer to be showed on view. This DOES NOT takes the ownership of layer.
QMenu * m_pluginsMenu
Definition: TerraView.h:236
QAction * m_fileSaveProjectAs
Definition: TerraView.h:193
void onLayerDuplicateLayerTriggered()
Definition: TerraView.cpp:1285
te::qt::widgets::LayerItemView * getLayerExplorer()
An abstract class for layer selection widgets.
void onAddQueryLayerTriggered()
Definition: TerraView.cpp:1576
A specialization of QTreeView for manipulate layers.
Definition: LayerItemView.h:78
virtual void initSlotsConnections()
Definition: TerraView.cpp:401
te::gm::Polygon * p
void openProject(const QString &prjFileName)
Definition: TerraView.cpp:2009
This file has the EyeBirdMapDisplayWidget class.
void addTabularLayerAction(QAction *act)
Adds the action to the popup menu presented when the selected layer has tabular representation.
A dialog used to build a grouping.
void addMenusActions()
Definition: TerraView.cpp:521
QAction * m_toolsDataExchangerDirectPopUp
Definition: TerraView.h:226
void onToolsQueryDataSourceTriggered()
Definition: TerraView.cpp:1882
void setLayers(std::list< te::map::AbstractLayerPtr > layers)
Set the layer that can be used.
void addAllLayerAction(QAction *act)
Adds the action to the popup menu presented for all kinds of selected items.
te::qt::widgets::ProgressViewerWidget * m_pvw
Definition: TerraView.h:262
void init(const QString &cfgFile)
Definition: TerraView.cpp:281
QMenu * m_helpMenu
Definition: TerraView.h:233
QString getExtensionFilter()
Returns the project extension filter .
QMenu * m_recentProjectsMenu
Definition: TerraView.h:239
A singleton that contains a pointer to a help manager implementation.
A dialog for selecting a data source.
te::qt::af::InterfaceController * m_iController
Definition: TerraView.h:250
void onRecentProjectsTriggered(QAction *proj)
Definition: TerraView.cpp:1775
virtual void createDefaultSettings()
Definition: TerraView.cpp:443
A direct exchanger dialog for ADO, POSTGIS and SHP data sources.
This class is designed to declare objects to be thrown as exceptions by TerraLib. ...
A progress dialog.
void showAboutDialog()
Definition: TerraView.cpp:893
void setLayers(const std::list< te::map::AbstractLayerPtr > &layers)
Sets the list of layers. Old layers in the tree are then removed.
void updateChart(const QModelIndex &idx)
Updates the chart item of the element.
Defines a layer item view for Qt5.
A dock widget for chart display objects.
QAction * m_projectUpdateLayerDataSource
Definition: TerraView.h:220
QMenu * m_fileMenu
Definition: TerraView.h:232
void addActions(const QString &name, const QString &category, const QList< QAction * > &acts)
Definition: TerraView.cpp:2086
A base class for widgets that allows application to create, edit or remove data sources.
QString m_author
The author of the project.
Definition: Project.h:42
This file defines a class for a Query Dialog Dialog.
Definition: QueryDialog.h:66
void triggered(te::qt::af::evt::Event *e)
void addListener(QObject *obj, const ListenerType &type=BOTH)
Insert an application item that will listen to framework events.
std::list< te::qt::widgets::TreeItem * > getSelectedItems() const
Returns a list of TreeItem that are selected.
ProjectMetadata * m_project
Definition: TerraView.h:256
This class is designed for dealing with multi-language text translation in TerraLib.
QMenu * m_viewToolBarsMenu
Definition: TerraView.h:243
A dataset is the unit of information manipulated by the data access module of TerraLib.
This file defines a class for a Query Dialog Dialog.
QAction * m_pluginsManager
Definition: TerraView.h:213
void setAppController(ApplicationController *app)
Sets the app controller to emit signal to app. This DOES NOT takes the ownership of app controller...
void setLayerList(std::list< te::map::AbstractLayerPtr > layerList)
This method is used to set the list of layers.
void onNewProjectTriggered()
Definition: TerraView.cpp:966
te::map::DataSetAdapterLayerPtr getDataSetAdapterLayer()
Returns a new DataSetAdapterLayer.
std::vector< te::qt::af::DataSetTableDockWidget * > m_tables
void setTerraLibLogoFilePath(std::string path)
Definition: AboutDialog.cpp:67
Utility routines for the TerraLib Application Framework module.
te::map::DataSetLayerPtr createLayer(te::da::DataSourcePtr source, te::da::DataSetTypePtr &dataset)
void setLastDataSource(std::string dataSource)
Function used to set the last data source used.
TerraView(QWidget *parent=0)
Definition: TerraView.cpp:246
const std::list< te::da::DataSourceInfoPtr > & getSelecteds() const
void onAddDataSetLayerTriggered()
Definition: TerraView.cpp:1479
void updateRecentProjects(const QString &prjFile, const QString &prjTitle)
Update the list of recent projects. This is commonly used when there&#39;s a new most recent project...
QAction * m_layerObjectGrouping
Definition: TerraView.h:209
void trigger(te::qt::af::evt::Event *)
This class represents a TableLinkDialog component.
TEQTWIDGETSEXPORT std::list< te::map::AbstractLayerPtr > GetSelectedLayersOnly(te::qt::widgets::LayerItemView *view, const bool getFolder=false)
te::qt::widgets::MapDisplay * getMapDisplay()
void onQueryLayerCreateLayer(te::map::AbstractLayerPtr layer)
Definition: TerraView.cpp:1461
void onHighlightLayerObjects(const te::map::AbstractLayerPtr &layer, te::da::DataSet *dataset, te::se::Style *style)
Definition: TerraView.cpp:1969
void GetProjectsFromSettings(QStringList &prjTitles, QStringList &prjPaths)
Definition: TerraView.cpp:132
QAction * findAction(const QString &id) const
Returns the action identified by id or NULL if there&#39;s not an action identified by id...
void onLayerGroupingTriggered()
Definition: TerraView.cpp:1340
QAction * m_fileOpenProject
Definition: TerraView.h:194
A class for xml serialization formatting strings.
The API for controller of TerraView application.
Defines a layer item.
A dialog for selecting a data source.
std::vector< QToolBar * > getToolBars() const
Return the list of registered toolbars.
QAction * m_toolsRasterMultiResolution
Definition: TerraView.h:230
The main class of TerraView.
A dialog used to customize a Scatter parameters and generate it&#39;s ChartDisplayWidget.
Definition: ScatterDialog.h:59
void setAppMapDisplay(te::qt::widgets::MapDisplay *appMapDisplay)
std::list< te::map::AbstractLayerPtr > getAllLayers() const
Returs all layers in the tree including folders.
virtual void initActions()
Definition: TerraView.cpp:352
A dialog used to configure the properties of a new textual file based layer.
QAction * m_helpContents
Definition: TerraView.h:201
void addRasterLayerAction(QAction *act)
Adds the action to the popup menu presented when the selected layer has raster representation.
QAction * m_helpAbout
Definition: TerraView.h:200
void onHelpTriggered()
Definition: TerraView.cpp:1058
QAction * m_layerQuery
Definition: TerraView.h:211
This class is designed to declare objects to be thrown as exceptions by TerraLib. ...
Proxy configuration file for TerraView (see terraview_config.h).
void onLayerChartTriggered()
Definition: TerraView.cpp:1229
A layer with reference to a dataset.
Definition: DataSetLayer.h:47
A connector to controll all non modal interfaces.
void onLayerHistogramTriggered()
Definition: TerraView.cpp:1119
te::qt::widgets::QueryDialog * m_queryDlg
Definition: TerraView.h:252
QAction * m_filePrint
Definition: TerraView.h:196
void onQueryLayerTriggered()
Definition: TerraView.cpp:1405
A Qt dialog for plugin management.
void addPopUpMenu()
Definition: TerraView.cpp:676
void addVectorLayerAction(QAction *act)
Adds the action to the popup menu presented when the selected layer has vector representation.
void clearAll()
Removes references for Viewers and tasks.
A dialog to create multi resolution over a raster.
QString m_title
The title of the project.
Definition: Project.h:41
A Dialog used to customize a Histogram parameters and generate it&#39;s ChartDisplayWidget.
std::list< te::map::AbstractLayerPtr > GetSelectedLayersOnly(te::qt::widgets::LayerItemView *view)
A dialog used to define the basic parameters of a new histogram.
Utility functions for MapTools module.
This class is widget that provides a menu for composition mode selection.
A class that defines the interface of a qt bar progress viewer.
void addFolderLayerAction(QAction *act)
Adds the action to the popup menu presented when the selected item is a folder.
virtual void setSRID(const int &srid, bool doRefresh=true)
It sets a new Spatial Reference System to be used by the Map Display.
void onUpdateLayerDataSourceTriggered()
Definition: TerraView.cpp:1705
void setLayerList(std::list< te::map::AbstractLayerPtr > &layerList)
This method is used to set the list of layers.
Definition: QueryDialog.cpp:94
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
void onLayerCompositionModeTriggered()
Definition: TerraView.cpp:1393
QAction * m_toolsDataExchanger
Definition: TerraView.h:224
Contains the list of the application events.
void setProject(ProjectMetadata *proj)
Sets the project to be inspected.
QAction * m_layerLinkTable
Definition: TerraView.h:208
virtual void initMenus()
Definition: TerraView.cpp:846
virtual const std::string & getDataSourceId() const
The base API for controllers of TerraLib applications.
void addInvalidLayerAction(QAction *act)
Adds the action to the popup menu presented when the selected layer is invalid.
This file defines a class for a Query DataSource Dialog Dialog.
QMenu * m_layerMenu
Definition: TerraView.h:234
virtual void initToolbars()
Definition: TerraView.cpp:878
std::string getType() const
Returns the type of the item.
A dialog for selecting a data source.
A connector to controll all non modal interfaces.
TEQTAFEXPORT QString GetLastDatasourceFromSettings()
TerraViewController * m_tvController
Definition: TerraView.h:258
file(WRITE ${CMAKE_BINARY_DIR}/config_qhelp.cmake"configure_file (${TERRALIB_ABSOLUTE_ROOT_DIR}/doc/qhelp/help.qhcp.in ${CMAKE_BINARY_DIR}/share/terraview/help/help.qhcp @ONLY)") add_custom_command(OUTPUT del_dir COMMAND $
void closeEvent(QCloseEvent *event)
Definition: TerraView.cpp:2075
QAction * m_layerDuplicateLayer
Definition: TerraView.h:207
virtual QWidget * getWidget(int widgetType, QWidget *parent=0, Qt::WindowFlags f=0) const =0
virtual void set(const std::list< te::da::DataSourceInfoPtr > &datasources)=0
void onToolsCustomizeTriggered()
Definition: TerraView.cpp:1803
void setLayerList(std::list< te::map::AbstractLayerPtr > &layerList)
boost::shared_ptr< DataSourceInfo > DataSourceInfoPtr
A dialog used to build a chart.
void AddRecentProjectToSettings(const QString &prjTitle, const QString &prjPath)
Definition: TerraView.cpp:195
void onSaveProjectTriggered(bool save_as=false)
Definition: TerraView.cpp:1007
void onCreateNewLayer(te::map::AbstractLayerPtr layer)
Definition: TerraView.cpp:1978
A base class for the suppported types of data source.
const QString & getAboutLogo() const
Returns the application project extension.
void onRestartSystemTriggered()
Definition: TerraView.cpp:946
QModelIndex GetParent(QTreeView *view)
Definition: TerraView.cpp:221