OutputRasterParametersWidget.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 terralib/qt/widgets/rp/OutputRasterParametersWidget.cpp
22 
23  \brief This file has the OutputRasterParametersWidget class.
24 */
25 
26 // TerraLib
28 #include "../raster/RasterInfoDialog.h"
29 #include "../raster/RasterInfoWidget.h"
30 #include "ui_OutputRasterParametersWidgetForm.h"
31 
32 //QT
33 #include <QFileDialog>
34 
36  : QWidget(parent, f),
37  m_ui(new Ui::OutputRasterParametersWidgetForm),
38  m_fileGDAL(false),
39  m_dataSource(false)
40 {
41 //build form
42  m_ui->setupUi(this);
43 
44  m_ui->m_fileToolButton->setIcon(QIcon::fromTheme("folder"));
45  m_ui->m_sourceToolButton->setIcon(QIcon::fromTheme("datasource"));
46 
47  m_rasterInfoDlg.reset( new te::qt::widgets::RasterInfoDialog(true, this, nullptr));
48 
49 //connects
50  connect(m_ui->m_sourceToolButton, SIGNAL(clicked()), this, SLOT(onSourceToolButtonClicked()));
51  connect(m_ui->m_fileToolButton, SIGNAL(clicked()), this, SLOT(onFileToolButtonClicked()));
52 }
53 
55  default;
56 
57 Ui::OutputRasterParametersWidgetForm* te::qt::widgets::OutputRasterParametersWidget::getForm() const
58 {
59  return m_ui.get();
60 }
61 
63 {
64  if(m_dataSource)
65  return m_rasterInfoDlg->getWidget()->getType();
66 
67  if(m_fileGDAL)
68  return "GDAL";
69 
70  return "";
71 }
72 
73 std::map<std::string, std::string> te::qt::widgets::OutputRasterParametersWidget::getInfo() const
74 {
75  if(m_dataSource)
76  return m_rasterInfoDlg->getWidget()->getInfo();
77 
78  if(m_fileGDAL)
79  {
80  std::map<std::string, std::string> rinfo;
81  std::string name = m_ui->m_outputLineEdit->text().toUtf8().data();
82  rinfo["URI"] = name;
83 
84  return rinfo;
85  }
86 
87  return std::map<std::string, std::string>();
88 }
89 
91 {
92  if(m_dataSource)
93  return m_rasterInfoDlg->getWidget()->getName();
94 
95  if(m_fileGDAL && !m_ui->m_outputLineEdit->text().isEmpty())
96  return m_ui->m_outputLineEdit->text().toUtf8().data();
97 
98  return "";
99 }
100 
102 {
103  if(m_rasterInfoDlg->exec() == QDialog::Accepted)
104  {
105  std::string name = m_rasterInfoDlg->getWidget()->getName();
106 
107  m_ui->m_outputLineEdit->setText(name.c_str());
108 
109  m_dataSource = true;
110  m_fileGDAL = false;
111  }
112 }
113 
115 {
116  QString fileName = QFileDialog::getSaveFileName(this, tr("Save Raster to File"), "", tr("GDAL File (*.tif *.TIF)"));
117 
118  if (fileName.isEmpty())
119  return;
120 
121  QFileInfo file(fileName);
122 
123  if(file.suffix().isEmpty())
124  fileName.append(".tif");
125 
126  m_ui->m_outputLineEdit->setText(fileName);
127 
128  m_dataSource = false;
129  m_fileGDAL = true;
130 }
std::unique_ptr< Ui::OutputRasterParametersWidgetForm > m_ui
Ui::OutputRasterParametersWidgetForm * getForm() const
std::map< std::string, std::string > getInfo() const
OutputRasterParametersWidget(QWidget *parent=0, Qt::WindowFlags f=0)
This file has the OutputRasterParametersWidget class.
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 $
This class is a dialog for the RasterInfoWidget.