All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RasterInfoWidget.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2011-2012 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/RasterInfoWidget.cpp
22 
23  \brief This file has the RasterInfoWidget class.
24 */
25 
26 // TerraLib
27 #include "ParameterTableWidget.h"
28 #include "RasterInfoWidget.h"
29 #include "ui_RasterInfoWidgetForm.h"
30 #include "ui_ParameterTableWidgetForm.h"
31 
32 // QT
33 #include <QFileDialog>
34 
35 te::qt::widgets::RasterInfoWidget::RasterInfoWidget(QWidget* parent, Qt::WindowFlags f)
36  : QWidget(parent, f),
37  m_ui(new Ui::RasterInfoWidgetForm),
38  m_dir("")
39 {
40  m_ui->setupUi(this);
41 
42  QGridLayout* layout = new QGridLayout(m_ui->m_widget);
43  m_table.reset( new te::qt::widgets::ParameterTableWidget(m_ui->m_widget));
44  layout->addWidget(m_table.get());
45  layout->setContentsMargins(0,0,0,0);
46 
47  m_table->getForm()->m_parameterTitle->setText(tr("Extra parameters"));
48 
49  //connects
50  connect(m_ui->m_openFileDlgToolButton, SIGNAL(clicked()), this, SLOT(onOpenFileDlgToolButtonClicked()));
51 
52 
53 }
54 
56 {
57 }
58 
59 Ui::RasterInfoWidgetForm* te::qt::widgets::RasterInfoWidget::getForm() const
60 {
61  return m_ui.get();
62 }
63 
65 {
66  if(m_ui->m_fileRadioButton->isChecked())
67  {
68  return "GDAL";
69  }
70  else if(m_ui->m_memRadioButton->isChecked())
71  {
72  return "MEM";
73  }
74  else if(m_ui->m_dsRadioButton->isChecked())
75  {
76  return "";
77  }
78 
79  return "";
80 }
81 
82 std::map<std::string, std::string> te::qt::widgets::RasterInfoWidget::getInfo() const
83 {
84  std::map<std::string, std::string> rinfo;
85 
86  std::string name = getBaseName();
87 
88  if(m_ui->m_fileRadioButton->isChecked())
89  {
90  std::string fileName = m_dir + "/" + name + ".tif";
91 
92  rinfo["URI"] = fileName;
93  }
94  else if(m_ui->m_memRadioButton->isChecked())
95  {
96 
97  }
98  else if(m_ui->m_dsRadioButton->isChecked())
99  {
100 
101  }
102 
103  if(m_ui->m_overightRadioButton->isChecked() == false)
104  {
105  //get extra parameters
106  std::map<std::string, std::string> extra = m_table->getMap();
107 
108  rinfo.insert(extra.begin(), extra.end());
109  }
110 
111  return rinfo;
112 }
113 
115 {
116  std::string name = getBaseName();
117 
118  if(m_ui->m_fileRadioButton->isChecked())
119  {
120  name += ".tif";
121  }
122 
123  return name;
124 }
125 
127 {
128  return m_ui->m_overightRadioButton->isChecked();
129 }
130 
132 {
133  if(m_ui->m_fileRadioButton->isChecked())
134  {
135  std::string name = getBaseName();
136 
137  std::string fileName = m_dir + "/" + name + ".tif";
138 
139  QFile file(fileName.c_str());
140 
141  return file.exists();
142  }
143 
144  return false;
145 }
146 
148 {
149  std::string name = "";
150 
151  if(m_ui->m_nameLineEdit->text().isEmpty() == false)
152  {
153  name = m_ui->m_nameLineEdit->text().toStdString();
154 
155  QFileInfo file(name.c_str());
156 
157  name = file.baseName().toStdString();
158  }
159 
160  return name;
161 }
162 
164 {
165  QString dir = QFileDialog::getExistingDirectory(this, tr("Open Directory"), "", QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
166 
167  if(dir.isEmpty() == false)
168  {
169  m_dir = dir.replace(QRegExp("\\\\"), "/").toStdString();
170 
171  m_ui->m_fileNameLineEdit->setText(m_dir.c_str());
172  }
173 }
std::map< std::string, std::string > getInfo() const
This file has the RasterInfoWidget class.
Ui::RasterInfoWidgetForm * getForm() const
std::auto_ptr< Ui::RasterInfoWidgetForm > m_ui
RasterInfoWidget(QWidget *parent=0, Qt::WindowFlags f=0)
std::auto_ptr< te::qt::widgets::ParameterTableWidget > m_table