2 #include "ui_multiimportdialog.h" 11 ws->dataset_loading_count();
12 ui->nameLineEdit->setText(
"Dataset" + QString::number(ws->dataset_loading_count()));
14 ui->filenameTableWidget->setRowCount(1);
15 ui->filenameTableWidget->setColumnCount(1);
23 void MultiImportDialog::on_rowSpinBox_valueChanged(
int arg1)
25 ui->filenameTableWidget->setRowCount(arg1);
26 ui->countLabel->setText(QString::number(arg1 * ui->filenameTableWidget->columnCount()));
29 void MultiImportDialog::on_colSpinBox_valueChanged(
int arg1)
31 ui->filenameTableWidget->setColumnCount(arg1);
32 ui->countLabel->setText(QString::number(arg1 * ui->filenameTableWidget->rowCount()));
35 void MultiImportDialog::on_addFilesPushButton_clicked()
37 QStringList filenames = QFileDialog::getOpenFileNames(
this,
"Select Files", workspace_->directory(),
"Text Files (*.txt *.csv *.dat);;" 39 QStringList filenames_cpy = filenames;
41 QString path = filenames_cpy.first();
42 QFileInfo file_info(path);
43 QString new_directory = file_info.absoluteDir().absolutePath();
44 workspace_->set_directory(new_directory);
46 QStringList::Iterator it = filenames_cpy.begin();
47 int current_row = ui->filenameTableWidget->currentRow();
48 int current_col = ui->filenameTableWidget->currentColumn();
49 int col_count = ui->filenameTableWidget->columnCount();
50 int row_count = ui->filenameTableWidget->rowCount();
53 while (current_row < row_count){
55 while (current_col < col_count && it != filenames_cpy.end()){
57 QTableWidgetItem *current_item =
new QTableWidgetItem;
58 current_item->setText(*it);
59 ui->filenameTableWidget->setItem(current_row, current_col, current_item);
66 if (it != filenames_cpy.end()){
67 QMessageBox::warning(
this,
68 "Too many files selected.",
69 "The number of files selected exceeds the number of" 70 "cells in the table. Not all filenames have been " 71 "added to the table.");
79 void MultiImportDialog::on_buttonBox_accepted()
81 int cols = ui->filenameTableWidget->columnCount();
82 int rows = ui->filenameTableWidget->rowCount();
83 QString name = ui->nameLineEdit->text();
84 QString x_axis_description = ui->abscissaLineEdit->text();
85 QString y_axis_description = ui->ordinateLineEdit->text();
87 map<pair<int,int>,
string> filename_map;
89 for (
int row = 0; row < rows; ++row){
90 for (
int col = 0; col < cols; ++col){
91 QTableWidgetItem *item = ui->filenameTableWidget->takeItem(row, col);
92 string value = item->text().toStdString();
93 pair<int, int> key(row, col);
94 filename_map[key] = value;
100 arma::vec x, y, abscissa;
107 QMessageBox::warning(
this,
"Import Failure",
"Import of at least one file failed, or no abscissa present in any file.");
110 QSharedPointer<VespucciDataset> dataset(
new VespucciDataset(filename_map,
111 workspace_->main_window(),
112 workspace_->directory_ptr(),
117 workspace_->AddDataset(dataset);
122 void MultiImportDialog::on_buttonBox_rejected()
MultiImportDialog(QWidget *parent, QSharedPointer< VespucciWorkspace > ws)
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.
VESPUCCI_EXPORT bool ImportMultiplePoints(std::map< std::pair< int, int >, std::string > filenames, int rows, int cols, arma::mat &spectra, arma::vec &abscissa, arma::vec &x, arma::vec &y)
TextImport::ImportMultiplePoints.