21 #include "ui_mainwindow.h" 75 ui->datasetTreeView->setModel(dataset_tree_model_);
76 data_viewer_ =
new DataViewer(
this, workspace_);
77 plot_viewer_ =
new PlotViewer(
this, workspace_);
85 setCentralWidget(ui->datasetTreeView);
87 global_map_count_ = 0;
88 workspace_->SetPointers(
this, dataset_tree_model_);
91 addDockWidget(Qt::BottomDockWidgetArea, data_viewer_);
92 addDockWidget(Qt::BottomDockWidgetArea, plot_viewer_);
93 addDockWidget(Qt::RightDockWidgetArea, spectrum_editor_);
134 item_selected_ =
false;
151 dataset_tree_model_ =
new DatasetTreeModel(ui->datasetTreeView, data_model);
152 ui->datasetTreeView->setModel(dataset_tree_model_);
153 ui->datasetTreeView->resizeColumnToContents(0);
154 ui->datasetTreeView->resizeColumnToContents(1);
164 int response = QMessageBox::question(
this,
166 "Are you sure you want to exit?");
167 if (response == QMessageBox::Yes) {
168 for (
auto name: workspace_->dataset_names()){
183 void MainWindow::on_actionExit_triggered()
191 void MainWindow::on_actionImport_Dataset_from_File_triggered()
194 dataset_import_dialog->setAttribute(Qt::WA_DeleteOnClose);
195 dataset_import_dialog->show();
201 void MainWindow::on_actionAbout_Vespucci_triggered()
204 about_window->setAttribute(Qt::WA_DeleteOnClose);
205 about_window->show();
211 void MainWindow::on_actionCiting_Vespucci_triggered()
214 citation_window->setAttribute(Qt::WA_DeleteOnClose);
215 citation_window->show();
221 void MainWindow::on_actionNew_Univariate_Map_triggered()
223 TreeItem *item = dataset_tree_model_->
getItem(ui->datasetTreeView->currentIndex());
224 if (item->
type() == TreeItem::ItemType::Base){
225 QMessageBox::information(
this,
226 "No datasets loaded",
227 "No dataset exists on which to perform this operation");
230 QSharedPointer<VespucciDataset> dataset = workspace_->GetDataset(item->
DatasetKey());
233 univariate_dialog->setAttribute(Qt::WA_DeleteOnClose);
234 univariate_dialog->show();
240 void MainWindow::on_actionNew_Band_Ratio_Map_triggered()
242 TreeItem *item = dataset_tree_model_->
getItem(ui->datasetTreeView->currentIndex());
243 if (item->
type() == TreeItem::ItemType::Base){
244 QMessageBox::information(
this,
245 "No datasets loaded",
246 "No dataset exists on which to perform this operation");
250 QSharedPointer<VespucciDataset> dataset = workspace_->GetDataset(item->
DatasetKey());
253 band_ratio_dialog->setAttribute(Qt::WA_DeleteOnClose);
254 band_ratio_dialog->show();
260 void MainWindow::on_actionPrincipal_Components_Analysis_triggered()
262 TreeItem *item = dataset_tree_model_->
getItem(ui->datasetTreeView->currentIndex());
263 if (item->
type() == TreeItem::ItemType::Base){
264 QMessageBox::information(
this,
265 "No datasets loaded",
266 "No dataset exists on which to perform this operation");
270 QSharedPointer<VespucciDataset> dataset = workspace_->GetDataset(item->
DatasetKey());
274 principal_components_dialog->setAttribute(Qt::WA_DeleteOnClose);
275 principal_components_dialog->show();
282 void MainWindow::on_actionVertex_Components_triggered()
284 TreeItem *item = dataset_tree_model_->
getItem(ui->datasetTreeView->currentIndex());
285 if (item->
type() == TreeItem::ItemType::Base){
286 QMessageBox::information(
this,
287 "No datasets loaded",
288 "No dataset exists on which to perform this operation");
292 QSharedPointer<VespucciDataset> dataset = workspace_->GetDataset(item->
DatasetKey());
295 vca_dialog->setAttribute(Qt::WA_DeleteOnClose);
304 void MainWindow::on_actionPartial_Least_Squares_triggered()
306 TreeItem *item = dataset_tree_model_->
getItem(ui->datasetTreeView->currentIndex());
307 if (item->
type() == TreeItem::ItemType::Base){
308 QMessageBox::information(
this,
309 "No datasets loaded",
310 "No dataset exists on which to perform this operation");
315 QSharedPointer<VespucciDataset> dataset = workspace_->GetDataset(item->
DatasetKey());
318 new PLSDialog(
this, workspace_, dataset);
319 pls_dialog->setAttribute(Qt::WA_DeleteOnClose);
327 void MainWindow::on_actionK_Means_Clustering_triggered()
329 TreeItem *item = dataset_tree_model_->
getItem(ui->datasetTreeView->currentIndex());
330 if (item->
type() == TreeItem::ItemType::Base){
331 QMessageBox::information(
this,
332 "No datasets loaded",
333 "No dataset exists on which to perform this operation");
338 QSharedPointer<VespucciDataset> dataset = workspace_->GetDataset(item->
DatasetKey());
341 k_means_dialog->setAttribute(Qt::WA_DeleteOnClose);
342 k_means_dialog->show();
350 void MainWindow::on_actionNormalize_Standardize_triggered()
352 TreeItem *item = dataset_tree_model_->
getItem(ui->datasetTreeView->currentIndex());
353 if (item->
type() == TreeItem::ItemType::Base){
354 QMessageBox::information(
this,
355 "No datasets loaded",
356 "No dataset exists on which to perform this operation");
360 QSharedPointer<VespucciDataset> dataset = workspace_->GetDataset(dataset_key);
362 methods <<
"Min/Max" <<
"2-Norm (Unit Length)" <<
"1-Norm (Unit Area)" <<
"Z-score" 363 <<
"Standard Normal Variate" <<
"Peak Intensity" <<
"Scale Spectra" 364 <<
"Absolute Value" <<
"Mean Center";
366 QString method = QInputDialog::getItem(
this,
367 "Normalization/Standardization",
368 "Method:", methods, 0,
false, &ok);
369 double scaling_factor, offset;
371 if (ok && method ==
"Min/Max"){dataset->MinMaxNormalize();}
372 else if (ok && method ==
"2-Norm (Unit Length)"){dataset->VectorNormalize(2);}
373 else if (ok && method ==
"Mean Center"){dataset->MeanCenter();}
374 else if (ok && method ==
"1-Norm (Unit Area)"){dataset->VectorNormalize(1);}
375 else if (ok && method ==
"Z-score"){
376 offset = QInputDialog::getDouble(
this,
"Enter Offset",
"Offset",
377 0, -2147483647, 2147483647, 4, &ok);
378 dataset->SNVNormalize(offset,
true);
381 else if (ok && method ==
"Peak Intensity"){
382 double min = dataset->wavelength_ptr()->min();
383 double max = dataset->wavelength_ptr()->max();
385 range_dialog->setWindowTitle(
"Peak Intensity Normalization");
388 range_dialog->show();
390 else if (ok && method ==
"Scale Spectra"){
391 scaling_factor = QInputDialog::getDouble(
this,
"Enter Scaling Factor",
392 "Factor", 1, -100, 100, 2, &ok);
393 dataset->Scale(scaling_factor);
395 else if (ok && method ==
"Standard Normal Variate"){
396 offset = QInputDialog::getDouble(
this,
"Enter Offset",
"Offset",
397 0, -2147483647, 2147483647, 4, &ok);
398 dataset->SNVNormalize(offset,
false);
400 else if (ok && method ==
"Absolute Value"){dataset->AbsoluteValue();}
413 void MainWindow::on_actionSubtract_Background_triggered()
415 TreeItem *item = dataset_tree_model_->
getItem(ui->datasetTreeView->currentIndex());
416 if (item->
type() == TreeItem::ItemType::Base){
417 QMessageBox::information(
this,
418 "No datasets loaded",
419 "No dataset exists on which to perform this operation");
425 QSharedPointer<VespucciDataset> dataset = workspace_->GetDataset(dataset_key);
427 matrix_selection_dialog_->
SetModel(dataset_tree_model_);
428 matrix_selection_dialog_->show();
430 if (selected_item_->
type() == TreeItem::ItemType::Matrix){
432 dataset->SubtractBackground(selected_item_->
keys());
441 item_selected_ =
false;
447 void MainWindow::on_actionSpectra_triggered()
449 TreeItem *item = dataset_tree_model_->
getItem(ui->datasetTreeView->currentIndex());
450 if (item->
type() == TreeItem::ItemType::Base){
451 QMessageBox::information(
this,
452 "No datasets loaded",
453 "No dataset exists on which to perform this operation");
459 QSharedPointer<VespucciDataset> dataset = workspace_->GetDataset(dataset_key);
461 QFileDialog::getSaveFileName(
this,
462 tr(
"Save Spectra Matrix"),
463 workspace_->directory(),
464 tr(
"Vespucci Binary (*.arma);;" 465 "Comma-separated Values (*.csv);;" 466 "Tab-separated Txt (*.txt);;"));
467 QFileInfo file_info(filename);
468 workspace_->set_directory(file_info.dir().path());
470 if (file_info.suffix() ==
"arma")
471 success = dataset->spectra().save(filename.toStdString(), arma_binary);
472 else if (file_info.suffix() ==
"csv")
473 success = dataset->spectra().save(filename.toStdString(), csv_ascii);
475 success = dataset->spectra().save(filename.toStdString(), raw_ascii);
478 QMessageBox::information(
this,
"File Saved",
"File written successfully!");
480 QMessageBox::warning(
this,
"File Not Saved",
"Could not save file.");
486 void MainWindow::on_actionSpectra_as_Columns_triggered()
488 TreeItem *item = dataset_tree_model_->
getItem(ui->datasetTreeView->currentIndex());
489 if (item->
type() == TreeItem::ItemType::Base){
490 QMessageBox::information(
this,
491 "No datasets loaded",
492 "No dataset exists on which to perform this operation");
499 QSharedPointer<VespucciDataset> dataset = workspace_->GetDataset(dataset_key);
502 QFileDialog::getSaveFileName(
this,
503 tr(
"Save Spectra Matrix"),
504 workspace_->directory(),
505 tr(
"Vespucci Binary (*.arma);;" 506 "Comma-separated Values (*.csv);;" 507 "Tab-separated Txt (*.txt);;"));
508 QFileInfo file_info(filename);
509 workspace_->set_directory(file_info.dir().path());
510 mat output = dataset->spectra().t();
512 if (file_info.suffix() ==
"arma")
513 success = output.save(filename.toStdString(), arma_binary);
514 else if (file_info.suffix() ==
"csv")
515 success = output.save(filename.toStdString(), csv_ascii);
517 success = output.save(filename.toStdString(), raw_ascii);
520 QMessageBox::information(
this,
"File Saved",
"File written successfully!");
522 QMessageBox::warning(
this,
"File Not Saved",
"Could not save file.");
528 void MainWindow::on_actionAverage_Spectra_triggered()
530 TreeItem *item = dataset_tree_model_->
getItem(ui->datasetTreeView->currentIndex());
531 if (item->
type() == TreeItem::ItemType::Base){
532 QMessageBox::information(
this,
533 "No datasets loaded",
534 "No dataset exists on which to perform this operation");
541 QSharedPointer<VespucciDataset> dataset = workspace_->GetDataset(dataset_key);
544 QFileDialog::getSaveFileName(
this,
545 tr(
"Save Average Spectrum"),
546 workspace_->directory(),
547 tr(
"Vespucci Binary (*.arma);;" 548 "Comma-separated Values (*.csv);;" 549 "Tab-separated Txt (*.txt);;"));
550 QFileInfo file_info(filename);
551 workspace_->set_directory(file_info.dir().path());
553 if (file_info.suffix() ==
"arma")
554 success = dataset->AverageSpectrum(
false).save(filename.toStdString(), arma_binary);
555 else if (file_info.suffix() ==
"csv")
556 success = dataset->AverageSpectrum(
true).save(filename.toStdString(), csv_ascii);
558 success = dataset->AverageSpectrum(
true).save(filename.toStdString(), raw_ascii);
561 QMessageBox::information(
this,
"File Saved",
"File written successfully!");
563 QMessageBox::warning(
this,
"File Not Saved",
"Could not save file.");
569 void MainWindow::on_actionAverage_Spectra_with_Abscissa_triggered()
571 TreeItem *item = dataset_tree_model_->
getItem(ui->datasetTreeView->currentIndex());
572 if (item->
type() == TreeItem::ItemType::Base){
573 QMessageBox::information(
this,
574 "No datasets loaded",
575 "No dataset exists on which to perform this operation");
582 QSharedPointer<VespucciDataset> dataset = workspace_->GetDataset(dataset_key);
585 QFileDialog::getSaveFileName(
this,
586 tr(
"Save Spectra Matrix"),
587 workspace_->directory(),
588 tr(
"Vespucci Binary (*.arma);;" 589 "Comma-separated Values (*.csv);;" 590 "Tab-separated Txt (*.txt);;"));
591 QFileInfo file_info(filename);
592 workspace_->set_directory(file_info.dir().path());
595 vec wavelength = dataset->wavelength();
596 mat output(wavelength);
598 output.insert_cols(1, dataset->AverageSpectrum(
true));
604 if (file_info.suffix() ==
"arma")
605 success = output.save(filename.toStdString(), arma_binary);
606 else if (file_info.suffix() ==
"csv")
607 success = output.save(filename.toStdString(), csv_ascii);
609 success = output.save(filename.toStdString(), raw_ascii);
612 QMessageBox::information(
this,
"File Saved",
"File written successfully!");
614 QMessageBox::warning(
this,
"File Not Saved",
"Could not save file.");
620 void MainWindow::on_actionSpectral_Abscissa_triggered()
622 TreeItem *item = dataset_tree_model_->
getItem(ui->datasetTreeView->currentIndex());
623 if (item->
type() == TreeItem::ItemType::Base){
624 QMessageBox::information(
this,
625 "No datasets loaded",
626 "No dataset exists on which to perform this operation");
633 QSharedPointer<VespucciDataset> dataset = workspace_->GetDataset(dataset_key);
636 QFileDialog::getSaveFileName(
this,
637 tr(
"Save Spectra Matrix"),
638 workspace_->directory(),
639 tr(
"Vespucci Binary (*.arma);;" 640 "Comma-separated Values (*.csv);;" 641 "Tab-separated Txt (*.txt);;"));
642 QFileInfo file_info(filename);
643 workspace_->set_directory(file_info.dir().path());
646 if (file_info.suffix() ==
"arma")
647 success = dataset->wavelength().save(filename.toStdString(), arma_binary);
648 else if (file_info.suffix() ==
"csv")
649 success = dataset->wavelength().save(filename.toStdString(), csv_ascii);
651 success = dataset->wavelength().save(filename.toStdString(), raw_ascii);
654 QMessageBox::information(
this,
"File Saved",
"File written successfully!");
656 QMessageBox::warning(
this,
"File Not Saved",
"Could not save file.");
662 void MainWindow::on_actionAll_Data_triggered()
664 TreeItem *item = dataset_tree_model_->
getItem(ui->datasetTreeView->currentIndex());
665 if (item->
type() == TreeItem::ItemType::Base){
666 QMessageBox::information(
this,
667 "No datasets loaded",
668 "No dataset exists on which to perform this operation");
671 if (ui->datasetTreeView->model()->rowCount() < 1)
677 QSharedPointer<VespucciDataset> dataset = workspace_->GetDataset(dataset_key);
680 QFileDialog::getSaveFileName(
this,
681 tr(
"Save Spectra Matrix"),
682 workspace_->directory(),
683 tr(
"Vespucci Dataset (*.vds)"));
685 QFileInfo file_info(filename);
686 workspace_->set_directory(file_info.dir().path());
690 success = dataset->Save(filename);
698 QMessageBox::information(
this,
"File Saved",
"File written successfully!");
700 QMessageBox::warning(
this,
"File Not Saved",
"Could not save file.");
706 void MainWindow::on_actionFilter_Derivatize_triggered()
708 TreeItem *item = dataset_tree_model_->
getItem(ui->datasetTreeView->currentIndex());
709 if (item->
type() == TreeItem::ItemType::Base){
710 QMessageBox::information(
this,
711 "No datasets loaded",
712 "No dataset exists on which to perform this operation");
719 filter_dialog->setAttribute(Qt::WA_DeleteOnClose);
720 filter_dialog->show();
726 void MainWindow::on_actionClose_Dataset_triggered()
728 TreeItem *item = dataset_tree_model_->
getItem(ui->datasetTreeView->currentIndex());
729 if (item->
type() == TreeItem::ItemType::Base){
730 QMessageBox::information(
this,
731 "No datasets loaded",
732 "No dataset exists on which to perform this operation");
738 CloseDataset(dataset_key);
744 void MainWindow::on_actionDocumentation_triggered()
746 QUrl website_url(
"http://vespucciproject.org/");
747 QDesktopServices::openUrl(website_url);
753 void MainWindow::on_actionCrop_triggered()
755 TreeItem *item = dataset_tree_model_->
getItem(ui->datasetTreeView->currentIndex());
756 if (item->
type() == TreeItem::ItemType::Base){
757 QMessageBox::information(
this,
758 "No datasets loaded",
759 "No dataset exists on which to perform this operation");
765 crop_dialog->setAttribute(Qt::WA_DeleteOnClose);
772 void MainWindow::on_actionCorrect_Baseline_triggered()
774 TreeItem *item = dataset_tree_model_->
getItem(ui->datasetTreeView->currentIndex());
775 if (item->
type() == TreeItem::ItemType::Base){
776 QMessageBox::information(
this,
777 "No datasets loaded",
778 "No dataset exists on which to perform this operation");
786 baseline_dialog->setAttribute(Qt::WA_DeleteOnClose);
787 baseline_dialog->show();
799 void MainWindow::on_actionUndo_triggered()
801 TreeItem *item = dataset_tree_model_->
getItem(ui->datasetTreeView->currentIndex());
802 if (item->
type() == TreeItem::ItemType::Base){
803 QMessageBox::information(
this,
804 "No datasets loaded",
805 "No dataset exists on which to perform this operation");
812 QSharedPointer<VespucciDataset> dataset = workspace_->GetDataset(dataset_key);
814 if (!dataset->Undoable()){
816 QMessageBox::information(
this,
"Nothing to Undo",
"There are no actions to undo");
820 QString text = tr(
"Are you sure you want to undo ") + dataset->last_operation()
821 +
" on " + dataset->name() +
"?";
823 QMessageBox::question(
this,
824 tr(
"Undo Operation"),
826 QMessageBox::Ok | QMessageBox::Cancel);
828 if (response == QMessageBox::Ok){
847 string str =
"The following exception was thrown: " + string(e.what());
848 QMessageBox::warning(
this,
"Exception Occurred", QString::fromStdString(str));
853 string str =
"The following exception was thrown: " 855 +
". In the internal function: " 858 QMessageBox::warning(
this,
"Exception Occurred", QString::fromStdString(str));
863 ui->datasetTreeView->setCurrentIndex(index);
869 QMessageBox *warning =
new QMessageBox(QMessageBox::Warning, title, text,
870 QMessageBox::Ok,
this);
871 warning->setAttribute(Qt::WA_DeleteOnClose);
877 QMessageBox::information(
this, title, text);
882 ui->datasetTreeView->setModel(new_model);
887 return dataset_tree_model_;
901 void MainWindow::on_actionDelete_Map_triggered()
903 TreeItem *item = dataset_tree_model_->
getItem(ui->datasetTreeView->currentIndex());
904 if (item->
type() == TreeItem::ItemType::Map){
905 workspace_->GetDataset(item->
keys().first())->RemoveMap(item->
keys().last());
909 void MainWindow::on_actionNew_Composite_Dataset_triggered()
911 TreeItem *item = dataset_tree_model_->
getItem(ui->datasetTreeView->currentIndex());
912 if (item->
type() == TreeItem::ItemType::Base){
913 QMessageBox::information(
this,
914 "No datasets loaded",
915 "No dataset exists on which to perform this operation");
919 meta_dialog->setAttribute(Qt::WA_DeleteOnClose);
925 void MainWindow::on_actionReject_Clipped_Spectra_triggered()
927 TreeItem *item = dataset_tree_model_->
getItem(ui->datasetTreeView->currentIndex());
928 if (item->
type() == TreeItem::ItemType::Base){
929 QMessageBox::information(
this,
930 "No datasets loaded",
931 "No dataset exists on which to perform this operation");
936 dialog->setAttribute(Qt::WA_DeleteOnClose);
943 if (ui->datasetTreeView->model()->rowCount() < 1)
945 TreeItem *item = dataset_tree_model_->
getItem(ui->datasetTreeView->currentIndex());
949 QSharedPointer<VespucciDataset> dataset = workspace_->GetDataset(dataset_key);
951 dataset->PeakIntensityNormalize(min, max);
960 ui->actionPlot_Viewer->setChecked(checked);
965 ui->actionData_Viewer->setChecked(checked);
970 ui->actionStatistics_Viewer->setChecked(checked);
975 ui->actionSpectrum_Editor->setChecked(checked);
980 ui->actionMacro_Editor->setChecked(checked);
985 ui->actionPython_Shell->setChecked(checked);
990 ui->actionHistory->setChecked(checked);
995 QSharedPointer<VespucciDataset> dataset = workspace_->GetDataset(dataset_key);
996 if (!dataset.isNull()){
997 mat spectrum = join_horiz(dataset->abscissa(), dataset->spectra(uvec({index})));
1004 QSharedPointer<VespucciDataset> dataset = workspace_->GetDataset(dataset_key);
1005 if (!dataset.isNull()){
1006 mat spectrum = join_horiz(dataset->abscissa(), dataset->spectra(uvec({index})));
1007 plot_viewer_->
AddPlot(spectrum, map_name);
1013 selected_item_ = item;
1014 item_selected_ =
true;
1017 void MainWindow::on_actionBooleanize_Clamp_triggered()
1019 TreeItem *item = dataset_tree_model_->
getItem(ui->datasetTreeView->currentIndex());
1020 if (item->
type() == TreeItem::ItemType::Base){
1021 QMessageBox::information(
this,
1022 "No datasets loaded",
1023 "No dataset exists on which to perform this operation");
1028 booleanize_dialog->setAttribute(Qt::WA_DeleteOnClose);
1029 booleanize_dialog->show();
1032 void MainWindow::on_actionRemove_Vectors_of_Zeros_triggered()
1034 TreeItem *item = dataset_tree_model_->
getItem(ui->datasetTreeView->currentIndex());
1035 if (item->
type() == TreeItem::ItemType::Base){
1036 QMessageBox::information(
this,
1037 "No datasets loaded",
1038 "No dataset exists on which to perform this operation");
1041 QSharedPointer<VespucciDataset> dataset = workspace_->GetDataset(item->
DatasetKey());
1044 items <<
"Remove columns of zeros (removes spectra)" <<
"Remove rows of zeros (removes wavelengths)";
1045 QString input = QInputDialog::getItem(
this,
"Select dimension",
"Behavior", items, 0,
false, &ok);
1050 QSharedPointer<VespucciDataset> data = workspace_->DatasetAt(ui->datasetTreeView->currentIndex());
1051 if (input ==
"Remove columns of zeros (removes spectra)"){
1053 dataset->ShedZeroSpectra();
1055 catch(std::exception e){
1059 else if (input ==
"Remove rows of zeros (removes wavelengths)"){
1061 dataset->ShedZeroWavelengths();
1063 catch(std::exception e){
1068 QMessageBox::warning(
this,
"Invalid Entry",
"Invalid response to QInputDialog::getItem()");
1074 void MainWindow::on_actionRun_script_triggered()
1076 TreeItem *item = dataset_tree_model_->
getItem(ui->datasetTreeView->currentIndex());
1077 if (item->
type() == TreeItem::ItemType::Base){
1078 QMessageBox::information(
this,
1079 "No datasets loaded",
1080 "No dataset exists on which to perform this operation");
1087 script_dialog->setAttribute(Qt::WA_DeleteOnClose);
1088 script_dialog->show();
1091 void MainWindow::on_actionDetect_Peaks_triggered()
1093 TreeItem *item = dataset_tree_model_->
getItem(ui->datasetTreeView->currentIndex());
1094 if (item->
type() == TreeItem::ItemType::Base){
1095 QMessageBox::information(
this,
1096 "No datasets loaded",
1097 "No dataset exists on which to perform this operation");
1106 void MainWindow::on_actionCalculate_Peak_Populations_triggered()
1108 TreeItem *item = dataset_tree_model_->
getItem(ui->datasetTreeView->currentIndex());
1109 if (item->
type() == TreeItem::ItemType::Base){
1110 QMessageBox::information(
this,
1111 "No datasets loaded",
1112 "No dataset exists on which to perform this operation");
1122 void MainWindow::on_actionImport_From_Multiple_Point_Spectra_triggered()
1125 import_dialog->setAttribute(Qt::WA_DeleteOnClose);
1126 import_dialog->show();
1130 void MainWindow::on_actionBatch_File_Conversion_triggered()
1133 conversion_dialog->setAttribute(Qt::WA_DeleteOnClose);
1134 conversion_dialog->show();
1137 void MainWindow::on_actionClassical_Least_Squares_triggered()
1139 TreeItem *item = dataset_tree_model_->
getItem(ui->datasetTreeView->currentIndex());
1140 if (item->
type() == TreeItem::ItemType::Base){
1141 QMessageBox::information(
this,
1142 "No datasets loaded",
1143 "No dataset exists on which to perform this operation");
1147 QSharedPointer<VespucciDataset> dataset = workspace_->GetDataset(item->
DatasetKey());
1150 cls_dialog->setAttribute(Qt::WA_DeleteOnClose);
1154 void MainWindow::on_actionSettings_triggered()
1157 settings_dialog->setAttribute(Qt::WA_DeleteOnClose);
1158 settings_dialog->show();
1161 void MainWindow::on_actionTransform_Abscissa_triggered()
1163 TreeItem *item = dataset_tree_model_->
getItem(ui->datasetTreeView->currentIndex());
1164 if (item->
type() == TreeItem::ItemType::Base){
1165 QMessageBox::information(
this,
1166 "No datasets loaded",
1167 "No dataset exists on which to perform this operation");
1175 abscissa_transform_dialog->setAttribute(Qt::WA_DeleteOnClose);
1176 abscissa_transform_dialog->show();
1179 void MainWindow::on_actionFourierTransform_triggered()
1181 TreeItem *item = dataset_tree_model_->
getItem(ui->datasetTreeView->currentIndex());
1182 if (item->
type() == TreeItem::ItemType::Base){
1183 QMessageBox::information(
this,
1184 "No datasets loaded",
1185 "No dataset exists on which to perform this operation");
1193 fourier_transform_dialog->setAttribute(Qt::WA_DeleteOnClose);
1194 fourier_transform_dialog->show();
1198 void MainWindow::on_actionInterpolate_to_New_Abscissa_triggered()
1200 TreeItem *item = dataset_tree_model_->
getItem(ui->datasetTreeView->currentIndex());
1201 if (item->
type() == TreeItem::ItemType::Base){
1202 QMessageBox::information(
this,
1203 "No datasets loaded",
1204 "No dataset exists on which to perform this operation");
1212 abs_interp_dialog->setAttribute(Qt::WA_DeleteOnClose);
1213 abs_interp_dialog->show();
1216 void MainWindow::on_actionSave_Log_File_triggered()
1220 void MainWindow::on_actionImport_Dataset_from_Multiple_Files_triggered()
1223 stitch_dialog->setAttribute(Qt::WA_DeleteOnClose);
1224 stitch_dialog->show();
1227 void MainWindow::on_actionCreate_Plot_triggered()
1232 void MainWindow::on_actionPlot_Viewer_toggled(
bool arg1)
1234 plot_viewer_->setVisible(arg1);
1237 void MainWindow::ChildDialogVisibleToggled(
const QString &key,
bool arg1)
1239 if (child_dialogs_.contains(key)){
1240 child_dialogs_[key]->setVisible(arg1);
1244 void MainWindow::on_actionData_Viewer_toggled(
bool arg1)
1246 if (arg1) data_viewer_->show();
1247 else data_viewer_->close();
1250 void MainWindow::on_actionStatistics_Viewer_toggled(
bool arg1)
1252 if (arg1) stats_viewer_->show();
1253 else stats_viewer_->close();
1256 void MainWindow::on_actionSpectrum_Editor_toggled(
bool arg1)
1258 if (arg1) spectrum_editor_->show();
1259 else spectrum_editor_->close();
1262 void MainWindow::on_actionPython_Shell_toggled(
bool arg1)
1264 if (arg1) python_shell_->show();
1265 else python_shell_->close();
1268 void MainWindow::on_actionMacro_Editor_toggled(
bool arg1)
1270 if (arg1) macro_editor_->show();
1271 else macro_editor_->close();
1274 void MainWindow::on_actionMapResult_triggered()
1276 TreeItem *item = dataset_tree_model_->
getItem(ui->datasetTreeView->currentIndex());
1277 if (item->
type() == TreeItem::ItemType::Matrix && workspace_->Mappable(item->
keys())){
1278 QStringList item_keys = item->
keys();
1280 map_dialog->setAttribute(Qt::WA_DeleteOnClose);
1285 void MainWindow::on_actionOnline_Documentation_triggered()
1287 QUrl website_url(
"http://vespucciproject.org/Vespucci-docs");
1288 QDesktopServices::openUrl(website_url);
1291 void MainWindow::on_actionGlobal_Color_Scales_triggered()
1294 gradient_dialog->setAttribute(Qt::WA_DeleteOnClose);
1295 gradient_dialog->show();
1298 void MainWindow::on_datasetTreeView_clicked(
const QModelIndex &index)
1301 if (!item->
keys().size())
return;
1302 QStringList data_keys = item->
keys();
1304 if (item->
type() == TreeItem::ItemType::Matrix)
1308 void MainWindow::on_datasetTreeView_doubleClicked(
const QModelIndex &index)
1311 QStringList data_keys = item->
keys();
1312 if (!data_keys.size())
return;
1314 if (item->
type() == TreeItem::ItemType::Matrix){
1315 data_viewer_->
AddTab(data_keys);
1316 data_viewer_->setVisible(
true);
1319 if (item->
type() == TreeItem::ItemType::Map)
1320 workspace_->GetMap(data_keys.first(), data_keys.last())->ShowMapWindow(
true);
1323 void MainWindow::on_actionShow_in_Data_Viewer_triggered()
1325 TreeItem *item = dataset_tree_model_->
getItem(ui->datasetTreeView->currentIndex());
1326 QStringList data_keys = item->
keys();
1327 if (item->
type() == TreeItem::ItemType::Matrix){
1328 data_viewer_->
AddTab(data_keys);
1329 data_viewer_->setVisible(
true);
1334 void MainWindow::on_actionView_Statistics_triggered()
1336 stats_viewer_->setVisible(
true);
1339 void MainWindow::on_actionPlotResult_triggered()
1341 TreeItem *item = dataset_tree_model_->
getItem(ui->datasetTreeView->currentIndex());
1342 if (item->
type() == TreeItem::ItemType::Matrix){
1343 QStringList data_keys = item->
keys();
1349 plot_maker_dialog->setAttribute(Qt::WA_DeleteOnClose);
1350 plot_maker_dialog->show();
1355 void MainWindow::on_actionSave_Dataset_triggered()
1357 TreeItem *item = dataset_tree_model_->
getItem(ui->datasetTreeView->currentIndex());
1358 if (!item->
keys().size())
return;
1359 QString dataset_name = item->
keys().first();
1360 QString path = workspace_->directory() +
"/" + dataset_name;
1361 QSharedPointer<VespucciDataset> dataset = workspace_->GetDataset(dataset_name);
1363 if (dataset->saved())
1364 filename = dataset->last_save_filename();
1366 filename = QFileDialog::getSaveFileName(
this,
1369 "Vespucci Dataset (*.h5)");
1370 if (!filename.isEmpty()){
1371 bool ok = dataset->Save(filename);
1372 if (!ok)
DisplayWarning(
"Dataset Not Saved",
"The file failed to save");
1373 else QMessageBox::information(
this,
"Success",
"Dataset saved successfully");
1377 void MainWindow::on_actionOpenDataset_triggered()
1379 QString filename = QFileDialog::getOpenFileName(
this,
1381 workspace_->directory(),
1382 "Vespucci Dataset (*.h5)");
1383 QSharedPointer<VespucciDataset> dataset(NULL);
1386 dataset = QSharedPointer<VespucciDataset>(
new VespucciDataset(filename,
1389 }
catch (exception e){
1394 if (!dataset.isNull() && !dataset->ConstructorCancelled()){
1396 QString name = dataset->name();
1397 while (workspace_->dataset_names().contains(dataset->name()))
1398 dataset->SetName(name +
"(" + QString::number(count++) +
")");
1399 workspace_->AddDataset(dataset);
1402 DisplayWarning(
"Dataset Loading Error",
"The dataset file could not be loaded");
1406 void MainWindow::CloseDataset(
const QString &name)
1408 QSharedPointer<VespucciDataset> dataset = workspace_->GetDataset(name);
1412 QString path = workspace_->directory() +
"/" + dataset->name();
1413 if (dataset->state_changed()){
1415 response = QMessageBox::question(
this,
1417 "Would you like to save " +
1418 name +
"?", QMessageBox::Yes,
1420 if (response == QMessageBox::No)
break;
1421 if (dataset->saved())
1422 filename = dataset->last_save_filename();
1424 filename = QFileDialog::getSaveFileName(
this,
1427 "Vespucci Dataset (*.h5)");
1428 }
while (response == QMessageBox::Yes && filename.isEmpty());
1430 if (response == QMessageBox::Yes) dataset->Save(filename);
1434 workspace_->RemoveDataset(name);
1437 void MainWindow::on_actionSave_Dataset_As_triggered()
1439 TreeItem *item = dataset_tree_model_->
getItem(ui->datasetTreeView->currentIndex());
1440 if (!item->
keys().size())
return;
1441 QString dataset_name = item->
keys().first();
1442 QString path = workspace_->directory() +
"/" + dataset_name;
1443 QString filename = QFileDialog::getSaveFileName(
this,
1446 "Vespucci Dataset (*.h5)");
1447 if (!filename.isEmpty()){
1448 QSharedPointer<VespucciDataset> dataset = workspace_->GetDataset(dataset_name);
1449 bool ok = dataset->Save(filename);
1450 if (!ok)
DisplayWarning(
"Dataset Not Saved",
"The file failed to save");
1454 void MainWindow::on_actionExport_Matrix_triggered()
1456 TreeItem *item = dataset_tree_model_->
getItem(ui->datasetTreeView->currentIndex());
1457 if (item->
type() == TreeItem::ItemType::Matrix){
1458 QString filename = QFileDialog::getSaveFileName(
this,
"Save " + item->
keys().last(),
1459 workspace_->directory(),
1460 "Comma-separated text (*.csv);;" 1461 "Space-delimited text (*.txt);;" 1462 "Armadillo binary (*.arma);;" 1463 "Raw binary (*.bin)");
1464 QString extension = QFileInfo(filename).suffix();
1466 if (extension ==
"bin")
1467 workspace_->GetMatrix(item->
keys()).save(filename.toStdString(), raw_binary);
1468 else if (extension ==
"arma")
1469 workspace_->GetMatrix(item->
keys()).save(filename.toStdString(), arma_binary);
1470 else if (extension ==
"csv")
1471 workspace_->GetMatrix(item->
keys()).save(filename.toStdString(), csv_ascii);
1473 workspace_->GetMatrix(item->
keys()).save(filename.toStdString(), raw_ascii);
1474 }
catch(exception e){
1480 void MainWindow::on_actionImport_Data_Into_Dataset_triggered()
1482 QString filename = QFileDialog::getOpenFileName(
this,
"Select data file",
1483 workspace_->directory());
1485 bool ok = matrix.load(filename.toStdString());
1486 QFileInfo file_info(filename);
1487 QString matrix_name = file_info.completeBaseName();
1489 TreeItem *item = dataset_tree_model_->
getItem(ui->datasetTreeView->currentIndex());
1490 QSharedPointer<VespucciDataset> dataset = workspace_->GetDataset(item->
DatasetKey());
1491 dataset->AddAuxiliaryMatrix(matrix_name, matrix);
1494 DisplayWarning(
"Could not load file",
"The matrix could not be loaded from the selected file");
1498 void MainWindow::on_actionCalculate_Representative_Spectrum_triggered()
1500 TreeItem *item = dataset_tree_model_->
getItem(ui->datasetTreeView->currentIndex());
1502 if (workspace_->dataset_names().contains(key)){
1506 dialog->setAttribute(Qt::WA_DeleteOnClose);
1511 void MainWindow::on_actionTransform_triggered()
1513 TreeItem *item = dataset_tree_model_->
getItem(ui->datasetTreeView->currentIndex());
1514 if (item->
type() == TreeItem::ItemType::Matrix){
1516 dialog->setAttribute(Qt::WA_DeleteOnClose);
1521 void MainWindow::on_actionOn_Multiple_Datasets_triggered()
1528 void MainWindow::on_actionHierarchical_Clustering_triggered()
1530 TreeItem *item = dataset_tree_model_->
getItem(ui->datasetTreeView->currentIndex());
1531 QSharedPointer<VespucciDataset> dataset = workspace_->GetDataset(item->
DatasetKey());
1534 dialog->setAttribute(Qt::WA_DeleteOnClose);
1540 void MainWindow::on_actionHistory_toggled(
bool arg1)
1542 if (arg1 && !history_dialog_->isVisible())
1543 history_dialog_->show();
1544 if (!arg1 && history_dialog_->isVisible())
1545 history_dialog_->close();
1548 void MainWindow::on_actionConcatenate_triggered()
1550 TreeItem *item = dataset_tree_model_->
getItem(ui->datasetTreeView->currentIndex());
1552 if (!dataset_key.isEmpty()){
1554 dialog->setAttribute(Qt::WA_DeleteOnClose);
1559 void MainWindow::on_actionAnalyze_triggered()
1561 TreeItem *item = dataset_tree_model_->
getItem(ui->datasetTreeView->currentIndex());
1562 if (item->
type() == TreeItem::ItemType::Matrix){
1569 void MainWindow::on_actionNew_Dataset_from_Matrix_triggered()
1571 TreeItem *item = dataset_tree_model_->
getItem(ui->datasetTreeView->currentIndex());
1572 if (item->
type() == TreeItem::ItemType::Matrix){
1574 dialog->setAttribute(Qt::WA_DeleteOnClose);
1579 void MainWindow::on_actionEstimate_Dimensionality_triggered()
1581 TreeItem *item = dataset_tree_model_->
getItem(ui->datasetTreeView->currentIndex());
1582 if (item->
type() == TreeItem::ItemType::Matrix){
1584 dialog->setAttribute(Qt::WA_DeleteOnClose);
void MatrixToBeRemoved(QStringList keys)
void SetHistoryDialogActionChecked(bool checked)
void DisplayInformation(const QString &title, const QString &text)
void DatasetToBeRemoved(QString name)
The BandRatioDialog class The dialog that allows the user to create a band-ratio map.
void DatasetSelectionChanged(QString dataset_key)
void SetActionChecked(bool checked)
void DisplayExceptionWarning(std::exception e)
MainWindow::DisplayExceptionWarning.
VESPUCCI_EXPORT arma::uword max(arma::uword a, arma::uword b)
Vespucci::Math::max.
TreeItem::ItemType type() const
QSharedPointer< VespucciWorkspace > workspace_ptr()
MainWindow::workspace_ptr.
void SetDataViewerActionChecked(bool checked)
void SetPythonShellActionChecked(bool checked)
void DatasetSelectionChanged(QString key)
void DatasetToBeRemoved(QString name)
DataViewer::DatasetRemoved.
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...
The CropDialog class A dialog that allows the user to "Crop" the dataset (delete all spectra that are...
void DatasetSelectionChanged(QString dataset_key)
void SetModel(DatasetTreeModel *model)
void MatrixToBeRemoved(QStringList matrix_keys)
PlotViewer * plot_viewer()
void SetActiveDatasetTreeIndex(const QModelIndex &index)
The DataViewer class Window that displays dataset elements in a QTableView widget inside a QTabWidget...
The AboutDialog class A QDialog that displays information about Vespucci.
void RangeDialogAccepted(double min, double max)
void closeEvent(QCloseEvent *event)
MainWindow::closeEvent.
void DialogAccepted(double min, double max)
void SpectrumRequested(QString dataset_key, QString map_name, size_t index)
void HeldSpectrumRequested(QString dataset_key, QString map_name, size_t index)
The PLSDialog class Dialog that allows the user to perform PLS determinant analysis.
void SetActionChecked(bool checked)
void MatrixSelectionChanged(QStringList matrix_keys)
TreeItem * getItem(const QModelIndex &index) const
void DatasetToBeRemoved(QString key)
DatasetTreeModel * dataset_tree_model()
void MatrixSelectionChanged(QStringList matrix_keys)
VESPUCCI_EXPORT arma::uword min(arma::uword a, arma::uword b)
Vespucci::Math::min.
void SetActionChecked(bool checked)
MainWindow(QWidget *parent, QSharedPointer< VespucciWorkspace > ws)
MainWindow::MainWindow.
void SetStatsViewerActionChecked(bool checked)
void MatrixToBeRemoved(QStringList keys)
DataViewer::MatrixToBeRemoved.
void SetMacroEditorActionChecked(bool checked)
The CitationDialog class The dialog that displays how to cite Vespucci.
void SetPlotViewerActionChecked(bool checked)
void ItemSelected(TreeItem *item)
const QString DatasetKey() const
void DatasetSelectionChanged(QString dataset_key)
void MacroRequested(const QStringList ¯o)
void AddTab(QStringList keys)
The FilterDialog class This dialog allows the user to apply filtering, smoothing or derivatization to...
The UnivariateDialog class Class allowing user to create univariate images.
void AddPlot(const mat &paired_data, const QString &tab_title)
The PrincipalComponentsDialog class Dialog for performing principal components analysis.
void SetActionChecked(bool checked)
void DisplayWarning(const QString &title, const QString &text)
The KMeansDialog class Allows the user to create a k-means clustering map.
void SetActionChecked(bool checked)
void SetSpectrumEditorActionChecked(bool checked)
The MainWindow class The main window of the program, this is where the user performs most operations...
void MacroRequested(const QStringList ¯o)
void ItemSelected(TreeItem *item)
void AddTransientPlot(const vec &abscissa, const vec &data, const QString &tab_title)
void DatasetToBeRemoved(QString name)
The VCADialog class A dialog that allows the user to perform vertex components analysis.
void RefreshTreeModel(const DataModel *data_model)
MainWindow::RefreshTreeModel.
void SetActionChecked(bool checked)
The BaselineDialog class The dialog that allows the user to baseline-correct the data.
DataViewer * data_viewer()
void SetDatasetTreeModel(DatasetTreeModel *new_model)