2 #include "ui_fouriertransformdialog.h" 10 dataset_ = workspace_->GetDataset(dataset_key);
12 ui->parameterDoubleSpinBox->setVisible(
false);
13 ui->parameterLabel->setVisible(
false);
14 ui->endDoubleSpinBox->setVisible(
false);
15 ui->endLabel->setVisible(
false);
16 ui->sinePowerDoubleSpinBox->setVisible(
false);
17 ui->sinePowerLabel->setVisible(
false);
18 ui->spectrumSpinBox->setRange(1, dataset_->spectra_ptr()->n_cols);
20 ui->spectrumCustomPlot->addGraph();
31 void FourierTransformDialog::on_typeComboBox_currentIndexChanged(
const QString &arg1)
33 if (arg1 ==
"Inverse FFT"){
34 ui->endDoubleSpinBox->setVisible(
false);
35 ui->endLabel->setVisible(
false);
36 ui->weightsComboBox->setVisible(
false);
37 ui->weightsLabel->setVisible(
false);
38 ui->parameterLabel->setVisible(
false);
39 ui->parameterDoubleSpinBox->setVisible(
false);
41 QString weights = ui->weightsComboBox->currentText();
43 ui->weightsComboBox->setVisible(
true);
44 ui->weightsLabel->setVisible(
true);
45 if (weights ==
"Sine"){
46 ui->endDoubleSpinBox->setVisible(
true);
47 ui->endLabel->setVisible(
true);
48 ui->endLabel->setText(
"Ending Offset");
49 ui->parameterLabel->setVisible(
true);
50 ui->parameterLabel->setText(
"Starting Offset");
51 ui->sinePowerDoubleSpinBox->setVisible(
true);
52 ui->sinePowerLabel->setVisible(
true);
54 else if (weights ==
"Gaussian"){
55 ui->parameterDoubleSpinBox->setVisible(
true);
56 ui->parameterLabel->setVisible(
true);
57 ui->endDoubleSpinBox->setVisible(
false);
58 ui->endLabel->setVisible(
false);
59 ui->sinePowerLabel->setVisible(
false);
60 ui->sinePowerDoubleSpinBox->setVisible(
false);
61 ui->parameterLabel->setText(
"σ");
63 else if (weights ==
"Exponential"){
64 ui->parameterDoubleSpinBox->setVisible(
true);
65 ui->parameterLabel->setVisible(
true);
66 ui->endDoubleSpinBox->setVisible(
false);
67 ui->endLabel->setVisible(
false);
68 ui->sinePowerLabel->setVisible(
false);
69 ui->sinePowerDoubleSpinBox->setVisible(
false);
70 ui->parameterLabel->setText(
"λ");
73 ui->parameterDoubleSpinBox->setVisible(
false);
74 ui->parameterLabel->setVisible(
false);
75 ui->endDoubleSpinBox->setVisible(
false);
76 ui->endLabel->setVisible(
false);
77 ui->sinePowerDoubleSpinBox->setVisible(
false);
78 ui->sinePowerLabel->setVisible(
false);
83 void FourierTransformDialog::on_weightsComboBox_currentIndexChanged(
const QString &arg1)
86 if (arg1 ==
"Sine Bell"){
87 ui->endDoubleSpinBox->setVisible(
true);
88 ui->endLabel->setVisible(
true);
89 ui->endLabel->setText(
"Ending Offset");
90 ui->parameterLabel->setVisible(
true);
91 ui->parameterLabel->setText(
"Starting Offset");
92 ui->sinePowerDoubleSpinBox->setVisible(
true);
93 ui->sinePowerLabel->setVisible(
true);
95 else if (arg1 ==
"Gaussian"){
96 ui->parameterDoubleSpinBox->setVisible(
true);
97 ui->parameterLabel->setVisible(
true);
98 ui->endDoubleSpinBox->setVisible(
false);
99 ui->endLabel->setVisible(
false);
100 ui->sinePowerLabel->setVisible(
false);
101 ui->sinePowerDoubleSpinBox->setVisible(
false);
102 ui->parameterLabel->setText(
"σ");
104 else if (arg1 ==
"Exponential"){
105 ui->parameterDoubleSpinBox->setVisible(
true);
106 ui->parameterLabel->setVisible(
true);
107 ui->endDoubleSpinBox->setVisible(
false);
108 ui->endLabel->setVisible(
false);
109 ui->sinePowerLabel->setVisible(
false);
110 ui->sinePowerDoubleSpinBox->setVisible(
false);
111 ui->parameterLabel->setText(
"λ");
114 ui->parameterDoubleSpinBox->setVisible(
false);
115 ui->parameterLabel->setVisible(
false);
116 ui->endDoubleSpinBox->setVisible(
false);
117 ui->endLabel->setVisible(
false);
118 ui->sinePowerDoubleSpinBox->setVisible(
false);
119 ui->sinePowerLabel->setVisible(
false);
123 void FourierTransformDialog::on_previewPushButton_clicked()
125 typedef QVector<double>
qvec;
126 typedef std::vector<double>
stdvec;
130 arma::vec abscissa = dataset_->abscissa();
131 arma::uvec ind = {(arma::uword) ui->spectrumSpinBox->value() - 1};
132 arma::uword n = std::pow(2.0, ui->powerSpinBox->value());
134 if (ui->typeComboBox->currentText() ==
"FFT"){
135 arma::cx_mat f_spectrum;
136 arma::vec f_abscissa;
137 arma::mat spectrum = dataset_->spectra(ind);
140 abs_qvec = qvec::fromStdVector(arma::conv_to<stdvec>::from(f_abscissa));
141 spc_qvec = qvec::fromStdVector(arma::conv_to<stdvec>::from(arma::real(f_spectrum)));
143 workspace_->main_window()->DisplayExceptionWarning(e);
147 else if (ui->typeComboBox->currentText() ==
"Inverse FFT"){
148 arma::cx_mat t_spectrum;
149 arma::vec t_abscissa;
150 arma::cx_mat cx_spectrum = dataset_->cx_spectra(ind);
154 t_spectrum, t_abscissa,
157 qvec::fromStdVector(arma::conv_to<stdvec>::from(t_abscissa));
159 qvec::fromStdVector(arma::conv_to<stdvec>::from(arma::real(t_spectrum)));
161 workspace_->main_window()->DisplayExceptionWarning(e);
167 ui->spectrumCustomPlot->graph(0)->setData(abs_qvec, spc_qvec);
168 ui->spectrumCustomPlot->replot();
173 void FourierTransformDialog::on_powerSpinBox_valueChanged(
int arg1)
175 ui->valueLabel->setText(
"= " + QString::number( std::pow(2.0, arg1) ) );
178 void FourierTransformDialog::on_weightsPushButton_clicked()
180 QString type = ui->weightsComboBox->currentText();
181 int response = QMessageBox::warning(
this,
"Apply Weights",
182 "Applying weights will change the spectra permanently." 183 "This can be undone, but only once. Are you sure you " 185 QMessageBox::Ok, QMessageBox::Cancel);
186 if (response == QMessageBox::Cancel){
return;}
187 if (type ==
"Sine Bell"){
188 dataset_->ApplyFTWeight(ui->parameterDoubleSpinBox->value(),
189 ui->endDoubleSpinBox->value(),
190 ui->sinePowerDoubleSpinBox->value());
192 else if (type ==
"Exponential" 193 || type ==
"Gaussian"){
194 dataset_->ApplyFTWeight(type, ui->parameterDoubleSpinBox->value());
201 void FourierTransformDialog::on_buttonBox_accepted()
203 int n = std::pow(2, ui->powerSpinBox->value());
204 cout <<
"n = " << n <<
"\n";
207 if (ui->typeComboBox->currentText() ==
"FFT"){
208 QProgressDialog *progress =
211 "Performing FFT...");
213 dataset_->FourierTransform(n);
215 workspace_->main_window()->DisplayExceptionWarning(e);
220 else if (ui->typeComboBox->currentText() ==
"Inverse FFT"){
221 QProgressDialog *progress =
223 "Performing Inverse FFT",
224 "Performing Inverse FFT...");
226 dataset_->InverseFourierTransform(n);
228 workspace_->main_window()->DisplayExceptionWarning(e);
QProgressDialog * DisplayProgressDialog(QWidget *parent, QString title, QString text)
std::vector< double > stdvec