2 #include "ui_abscissatransformdialog.h" 3 #include <mlpack/core.hpp> 11 dataset_ = workspace_->GetDataset(dataset_key);
12 ui->descriptionLineEdit->setText(dataset_->x_axis_description());
21 void AbscissaTransformDialog::on_buttonBox_accepted()
23 double out_factor = ParseInput(ui->outFactorLineEdit->text());
24 double in_factor = ParseInput(ui->inFactorLineEdit->text());
25 QString out_units = ui->outUnitsComboBox->currentText();
26 QString in_units = ui->inUnitsComboBox->currentText();
27 QString description = ui->descriptionLineEdit->text();
28 if (in_factor * out_factor){
29 dataset_->TransformAbscissa(in_units, in_factor, out_units, out_factor, description);
33 double AbscissaTransformDialog::ParseInput(QString text)
const 37 QStringList segments = text.split(
"*", QString::SkipEmptyParts);
39 for (
auto segment: segments){
40 factor *= TextToDouble(segment);
45 double AbscissaTransformDialog::TextToDouble(QString text)
const 49 if (text ==
"eV"){val = arma::datum::eV; ok =
true;}
50 else{val = text.toDouble(&ok);}
51 return (ok ? val : 0);