Vespucci  1.0.0
abscissainterpolationdialog.cpp
Go to the documentation of this file.
2 #include "ui_abscissainterpolationdialog.h"
3 AbscissaInterpolationDialog::AbscissaInterpolationDialog(QWidget *parent, QSharedPointer<VespucciWorkspace> ws, const QString &dataset_key) :
4  QDialog(parent),
6 {
7  ui->setupUi(this);
8  workspace_ = ws;
9  dataset_ = workspace_->GetDataset(dataset_key);
10 
11  ui->orderSpinBox->setVisible(false);
12  ui->orderLabel->setVisible(false);
13  ui->windowSpinBox->setVisible(false);
14  ui->windowLabel->setVisible(false);
15 
16  ui->datasetComboBox->setVisible(true);
17  ui->datasetLabel->setVisible(true);
18  ui->fileLabel->setVisible(false);
19  ui->browsePushButton->setVisible(false);
20  ui->filenameLineEdit->setVisible(false);
21 
22  QStringList dataset_names = workspace_->dataset_names();
23  ui->datasetComboBox->addItems(dataset_names);
24 
25 }
26 
28 {
29  delete ui;
30 }
31 
32 
33 void AbscissaInterpolationDialog::on_buttonBox_accepted()
34 {
35  /*
36  arma::vec new_abscissa;
37  if (ui->sourceComboBox->currentText() == "Dataset"){
38  new_abscissa =
39  workspace_->DatasetAtt)
40  workspace_->DatasetAt(ui->datasetComboBox->currentIndex())->abscissa();
41  }
42  else if (ui->sourceComboBox->currentText() == "File"){
43  arma::mat infile;
44  bool ok = infile.load(ui->filenameLineEdit->text().toStdString());
45  if (ok){
46  new_abscissa = infile.col(0);
47  }
48  else{
49  QMessageBox::warning(this, "Error Opening File",
50  "The file " + ui->filenameLineEdit->text()\
51  + " could not be opened");\
52  return;
53  }
54  }
55  else{dataset_.clear(); return;}
56  QProgressDialog progress(this);
57  progress.setWindowModality(Qt::WindowModal);
58  progress.setLabelText("Interpolating Spectra...");
59  progress.setCancelButton(0);
60  progress.setRange(0,0);
61  progress.exec();
62  if (ui->methodComboBox->currentText() == "Two-Point Linear"){
63  try{
64  dataset_->InterpolateToNewAbscissa(new_abscissa);
65  }catch(exception e){
66  progress.close();
67  workspace_->main_window()->DisplayExceptionWarning(e);
68  }
69  }
70  else if (ui->methodComboBox->currentText() == "Spline"){
71  int poly_order = ui->orderSpinBox->value();
72  int window_size = ui->windowSpinBox->value();
73  try{
74  dataset_->InterpolateToNewAbscissa(new_abscissa,
75  poly_order,
76  window_size);
77  }catch(exception e){
78  progress.close();
79  workspace_->main_window()->DisplayExceptionWarning(e);
80  }
81 
82  }
83  else{
84  progress.close();
85  dataset_.clear();
86  return;
87  }
88  progress.close();
89  dataset_.clear();
90 */
91 }
92 
93 void AbscissaInterpolationDialog::on_sourceComboBox_currentIndexChanged(const QString &arg1)
94 {
95  if (arg1 == "Dataset"){
96  ui->datasetComboBox->setVisible(true);
97  ui->datasetLabel->setVisible(true);
98  ui->fileLabel->setVisible(false);
99  ui->browsePushButton->setVisible(false);
100  ui->filenameLineEdit->setVisible(false);
101  }
102 
103  if (arg1 == "File"){
104  ui->datasetComboBox->setVisible(false);
105  ui->datasetLabel->setVisible(false);
106  ui->fileLabel->setVisible(true);
107  ui->browsePushButton->setVisible(true);
108  ui->filenameLineEdit->setVisible(true);
109  }
110 }
111 
112 void AbscissaInterpolationDialog::on_methodComboBox_currentIndexChanged(const QString &arg1)
113 {
114  if (arg1 == "Two-Point Linear"){
115  ui->orderSpinBox->setVisible(false);
116  ui->orderLabel->setVisible(false);
117  ui->windowSpinBox->setVisible(false);
118  ui->windowLabel->setVisible(false);
119  }
120  if (arg1 == "Spline"){
121  ui->orderSpinBox->setVisible(true);
122  ui->orderLabel->setVisible(true);
123  ui->windowSpinBox->setVisible(true);
124  ui->windowLabel->setVisible(true);
125  }
126 }
Definition: ahcadialog.h:26
AbscissaInterpolationDialog(QWidget *parent, QSharedPointer< VespucciWorkspace > ws, const QString &dataset_key)