All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 "RasterInfoDialog.h"
29 #include "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 
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 {
56 }
57 
58 Ui::OutputRasterParametersWidgetForm* te::qt::widgets::OutputRasterParametersWidget::getForm() const
59 {
60  return m_ui.get();
61 }
62 
64 {
65  if(m_dataSource)
66  return m_rasterInfoDlg->getWidget()->getType();
67 
68  if(m_fileGDAL)
69  return "GDAL";
70 
71  return "";
72 }
73 
74 std::map<std::string, std::string> te::qt::widgets::OutputRasterParametersWidget::getInfo() const
75 {
76  if(m_dataSource)
77  return m_rasterInfoDlg->getWidget()->getInfo();
78 
79  if(m_fileGDAL)
80  {
81  std::map<std::string, std::string> rinfo;
82  std::string name = m_ui->m_outputLineEdit->text().toStdString();
83  rinfo["URI"] = name;
84 
85  return rinfo;
86  }
87 
88  return std::map<std::string, std::string>();
89 }
90 
92 {
93  if(m_dataSource)
94  return m_rasterInfoDlg->getWidget()->getName();
95 
96  if(m_fileGDAL && !m_ui->m_outputLineEdit->text().isEmpty())
97  return m_ui->m_outputLineEdit->text().toStdString();
98 
99  return "";
100 }
101 
103 {
104  if(m_dataSource)
105  return m_rasterInfoDlg->getWidget()->overight();
106 
107  if(m_fileGDAL)
108  return false;
109 
110  return false;
111 }
112 
114 {
115  if(m_rasterInfoDlg->exec() == QDialog::Accepted)
116  {
117  std::string name = m_rasterInfoDlg->getWidget()->getName();
118 
119  m_ui->m_outputLineEdit->setText(name.c_str());
120 
121  m_dataSource = true;
122  m_fileGDAL = false;
123  }
124 }
125 
127 {
128  QString fileName = QFileDialog::getSaveFileName(this, tr("Save Raster to File"), "", tr("GDAL File (*.tif *.TIF)"));
129 
130  if (fileName.isEmpty())
131  return;
132 
133  QFileInfo file(fileName);
134 
135  if(file.suffix().isEmpty())
136  fileName.append(".tif");
137 
138  m_ui->m_outputLineEdit->setText(fileName);
139 
140  m_dataSource = false;
141  m_fileGDAL = true;
142 }
Ui::OutputRasterParametersWidgetForm * getForm() const
std::map< std::string, std::string > getInfo() const
OutputRasterParametersWidget(QWidget *parent=0, Qt::WindowFlags f=0)
This file has the RasterInfoWidget class.
std::auto_ptr< Ui::OutputRasterParametersWidgetForm > m_ui
This file has the OutputRasterParametersWidget class.
This file defines a class for a RasterInfoDialog.
This class is a dialog for the RasterInfoWidget.