21 #include "ui_bandratiodialog.h" 25 QSharedPointer<VespucciWorkspace> ws,
26 QSharedPointer<AbstractDataAnalyzer> analyzer) :
48 second_min_line_->
setPen(QPen(Qt::GlobalColor::red));
49 second_max_line_->
setPen(QPen(Qt::GlobalColor::red));
51 double min = analyzer_->AbscissaMin();
52 double max = analyzer_->AbscissaMax();
54 QDoubleValidator *validator =
new QDoubleValidator(min, max, 2,
this);
57 QString label_text = QString::number(min) +
"–" + QString::number(max);
58 ui->rangeLabel->setText(label_text);
59 ui->indexSpinBox->setRange(0, analyzer_->columns() - 1);
61 uword middle = analyzer_->columns() / 2;
62 ui->indexSpinBox->setValue(middle);
68 ui->firstMinLineEdit->setValidator(validator);
69 ui->firstMaxLineEdit->setValidator(validator);
70 ui->secondMinLineEdit->setValidator(validator);
71 ui->secondMaxLineEdit->setValidator(validator);
72 ui->spectrumCustomPlot->addGraph();
73 ui->spectrumCustomPlot->graph(0)->addData(wavelength, plot_data);
74 ui->spectrumCustomPlot->rescaleAxes();
88 void BandRatioDialog::on_buttonBox_accepted()
90 bool ok = !ui->firstMinLineEdit->text().isEmpty()
91 && !ui->firstMaxLineEdit->text().isEmpty()
92 && !ui->secondMinLineEdit->text().isEmpty()
93 && !ui->secondMaxLineEdit->text().isEmpty();
96 double first_entered_min = ui->firstMinLineEdit->text().toDouble();
97 double second_entered_min = ui->secondMinLineEdit->text().toDouble();
98 double first_entered_max = ui->firstMaxLineEdit->text().toDouble();
99 double second_entered_max = ui->secondMaxLineEdit->text().toDouble();
101 if (first_entered_min < analyzer_->AbscissaMin()
102 || second_entered_min < analyzer_->AbscissaMin()){
103 QMessageBox::warning(
this,
105 "You have entered a left bound that is smaller " 106 "than the smallest number on the spectral abscissa");
110 if (first_entered_max > analyzer_->AbscissaMax()
111 || second_entered_max > analyzer_->AbscissaMax()){
112 QMessageBox::warning(
this,
114 "You have entered a right bound that is larger " 115 "than the largest number on the spectral abscissa");
118 uint bound_window = ui->searchWindowSpinBox->value();
121 QString name = ui->nameLineEdit->text();
122 QString value_method = ui->methodComboBox->currentText();
124 if (value_method ==
"Empirical"){
126 analyzer_->BandRatio(name, first_entered_min, first_entered_max,
127 second_entered_min, second_entered_max,
130 workspace_->main_window()->DisplayExceptionWarning(e);
133 else if (value_method ==
"Gaussian Fit"){
137 workspace_->main_window()->DisplayExceptionWarning(e);
141 QMessageBox::warning(
this,
"Error Occurred",
142 "A non-fatal error occurred: invalid input from ui->methodComboBox");
146 QMessageBox::warning(
this,
148 "You must enter numbers for left and right bounds.");
158 void BandRatioDialog::on_buttonBox_rejected()
164 void BandRatioDialog::on_firstMinLineEdit_textChanged(
const QString &arg1)
167 double value = arg1.toDouble(&ok);
172 if (!ui->spectrumCustomPlot->hasItem(first_min_line_))
173 ui->spectrumCustomPlot->addItem(first_min_line_);
174 ui->spectrumCustomPlot->repaint();
177 void BandRatioDialog::on_firstMaxLineEdit_textChanged(
const QString &arg1)
180 double value = arg1.toDouble(&ok);
185 if (!ui->spectrumCustomPlot->hasItem(first_max_line_))
186 ui->spectrumCustomPlot->addItem(first_max_line_);
187 ui->spectrumCustomPlot->repaint();
190 void BandRatioDialog::on_secondMinLineEdit_textChanged(
const QString &arg1)
193 double value = arg1.toDouble(&ok);
198 if (!ui->spectrumCustomPlot->hasItem(second_min_line_))
199 ui->spectrumCustomPlot->addItem(second_min_line_);
202 void BandRatioDialog::on_secondMaxLineEdit_textChanged(
const QString &arg1)
205 double value = arg1.toDouble(&ok);
210 if (!ui->spectrumCustomPlot->hasItem(second_max_line_))
211 ui->spectrumCustomPlot->addItem(second_max_line_);
215 void BandRatioDialog::on_indexSpinBox_editingFinished()
217 size_t index = ui->indexSpinBox->value();
220 ui->spectrumCustomPlot->graph(0)->clearData();
221 ui->spectrumCustomPlot->graph(0)->addData(abscissa, plot_data);
0x001 Axis ranges are draggable (see QCPAxisRect::setRangeDrag, QCPAxisRect::setRangeDragAxes) ...
The BandRatioDialog class The dialog that allows the user to create a band-ratio map.
BandRatioDialog(QWidget *parent, QSharedPointer< VespucciWorkspace > ws, QSharedPointer< AbstractDataAnalyzer > analyzer)
VESPUCCI_EXPORT arma::uword max(arma::uword a, arma::uword b)
Vespucci::Math::max.
void setCoords(double key, double value)
QVector< double > FromArmaVec(const arma::vec &data)
A straight line that spans infinitely in both directions.
VESPUCCI_EXPORT arma::uword min(arma::uword a, arma::uword b)
Vespucci::Math::min.
The QCustomPlot surface is immediately refreshed, by calling QWidget::repaint() after the replot...
QCPItemPosition *const point1
0x002 Axis ranges are zoomable with the mouse wheel (see QCPAxisRect::setRangeZoom, QCPAxisRect::setRangeZoomAxes)
QCPItemPosition *const point2
void setPen(const QPen &pen)