21 #include "ui_datasetimportdialog.h" 22 #include <QFileDialog> 37 directory_ = ws->directory_ptr();
38 QString name =
"Dataset" + QString::number(workspace_->dataset_loading_count());
39 ui->nameLineEdit->setText(name);
41 QPushButton *ok_button = ui->buttonBox->button(QDialogButtonBox::Ok);
42 ok_button->setDisabled(
true);
44 ws->settings()->beginGroup(
"specdata");
45 QString abs_label = ws->settings()->value(
"absLabel").toString();
46 QString abs_units = ws->settings()->value(
"absUnits").toString();
47 QString ord_label = ws->settings()->value(
"ordLabel").toString();
48 QString ord_units = ws->settings()->value(
"ordUnits").toString();
49 ws->settings()->endGroup();
51 ui->yDescriptionLineEdit->setText(ord_label);
52 ui->yUnitsLineEdit->setText(ord_units);
53 ui->xDescriptionLineEdit->setText(abs_label);
54 ui->xUnitsLineEdit->setText(abs_units);
56 connect(ui->filenameLineEdit,
57 &QLineEdit::textChanged,
69 QFileInfo info(new_filename);
70 QString basename = info.completeBaseName();
71 QString dataset_name = basename;
73 while (workspace_->dataset_names().contains(dataset_name))
74 dataset_name = basename +
" (" + QString::number(i++) +
")";
76 ui->nameLineEdit->setText(dataset_name);
82 void DatasetImportDialog::on_browseButton_clicked()
86 filename = QFileDialog::getOpenFileName(
this, tr(
"Open Data File"),
87 workspace_->directory(),
88 tr(
"Text Files (*.txt);;" 89 "Vespucci Dataset Files (*.vds);;"));
90 ui->filenameLineEdit->setText(filename);
98 void DatasetImportDialog::on_buttonBox_accepted()
100 QString y_description = ui->yDescriptionLineEdit->text() +
" (" + ui->yUnitsLineEdit->text() +
")";
101 QString x_description = ui->xDescriptionLineEdit->text() +
" (" + ui->xUnitsLineEdit->text() +
")";
103 QString name = ui->nameLineEdit->text();
104 QString filename = ui->filenameLineEdit->text();
105 QFileInfo file_info(filename);
106 QString extension = file_info.suffix();
108 if (workspace_->dataset_names().contains(name)){
109 QMessageBox::warning(
this,
"Name Exists",
"A dataset with this name already exists.");
114 const QString data_format_string = ui->dataFormatComboBox->currentText();
115 if (data_format_string ==
"Wide Text")
116 format =
"WideTabDel";
117 else if (data_format_string ==
"Wide Text (CSV)")
119 else if (data_format_string ==
"Long Text")
120 format =
"LongTabDel";
121 else if (data_format_string ==
"Long Text (CSV)")
123 else if (data_format_string ==
"Old Vespucci Dataset")
124 format =
"OldVBinary";
130 if (data_format_string ==
"Old Vespucci Dataset"){
139 workspace_->main_window(),
140 workspace_->directory_ptr()));
141 dataset->SetData(spectra, abscissa, x, y);
142 if (!dataset->ConstructorCancelled()){
143 workspace_->AddDataset(dataset);
144 workspace_->set_directory(file_info.dir().absolutePath());
148 workspace_->main_window()->DisplayExceptionWarning(e);
149 workspace_->RemoveDataset(name);
155 bool swap = ui->swapCheckBox->isChecked();
159 workspace_->main_window(),
166 if (!dataset->ConstructorCancelled()){
167 workspace_->AddDataset(dataset);
168 workspace_->set_directory(file_info.dir().absolutePath());
173 workspace_->main_window()->DisplayExceptionWarning(e);
174 workspace_->RemoveDataset(name);
186 void DatasetImportDialog::on_buttonBox_rejected()
191 void DatasetImportDialog::on_filenameLineEdit_textChanged(
const QString &arg1)
193 QFileInfo file_info(arg1);
194 QPushButton *ok_button = ui->buttonBox->button(QDialogButtonBox::Ok);
196 if(file_info.exists()){
197 double file_size = file_info.size()/1048576;
198 QString file_size_string = QString::number(file_size,
'f', 3);
199 ui->fileSizeLabel->setText(file_size_string);
200 ok_button->setEnabled(
true);
204 ui->fileSizeLabel->setText(
"File does not exist!");
205 ok_button->setDisabled(
true);
VESPUCCI_EXPORT bool ImportOldVespucciBinary(std::string filename, arma::mat &spectra, arma::vec &abscissa, arma::vec &x, arma::vec &y)
The VespucciDataset class This is the main class for dealing with hyperspectral data. This handles the import and export of spectra, and the creation of maps. Images are handled by the MapData class. This class is intended to be allocated on the heap inside of a smart pointer, there is no copy constructor.
The DatasetImportDialog class Dialog that allows the user to import files into the program...
DatasetImportDialog(QWidget *parent, QSharedPointer< VespucciWorkspace > ws)
DatasetImportDialog::DatasetImportDialog.
void FilenameChanged(QString new_filename)